MCPcopy Create free account
hub / github.com/diasurgical/devilution / JoyButtonToControllerButton

Function JoyButtonToControllerButton

SourceX/controls/devices/joystick.cpp:9–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7namespace dvl {
8
9ControllerButton JoyButtonToControllerButton(const SDL_Event &event)
10{
11 switch (event.type) {
12 case SDL_JOYBUTTONDOWN:
13 case SDL_JOYBUTTONUP:
14 switch (event.jbutton.button) {
15#ifdef JOY_BUTTON_A
16 case JOY_BUTTON_A:
17 return ControllerButton::BUTTON_A;
18#endif
19#ifdef JOY_BUTTON_B
20 case JOY_BUTTON_B:
21 return ControllerButton::BUTTON_B;
22#endif
23#ifdef JOY_BUTTON_X
24 case JOY_BUTTON_X:
25 return ControllerButton::BUTTON_X;
26#endif
27#ifdef JOY_BUTTON_Y
28 case JOY_BUTTON_Y:
29 return ControllerButton::BUTTON_Y;
30#endif
31#ifdef JOY_BUTTON_LEFTSTICK
32 case JOY_BUTTON_LEFTSTICK:
33 return ControllerButton::BUTTON_LEFTSTICK;
34#endif
35#ifdef JOY_BUTTON_RIGHTSTICK
36 case JOY_BUTTON_RIGHTSTICK:
37 return ControllerButton::BUTTON_RIGHTSTICK;
38#endif
39#ifdef JOY_BUTTON_LEFTSHOULDER
40 case JOY_BUTTON_LEFTSHOULDER:
41 return ControllerButton::BUTTON_LEFTSHOULDER;
42#endif
43#ifdef JOY_BUTTON_RIGHTSHOULDER
44 case JOY_BUTTON_RIGHTSHOULDER:
45 return ControllerButton::BUTTON_RIGHTSHOULDER;
46#endif
47#ifdef JOY_BUTTON_TRIGGERLEFT
48 case JOY_BUTTON_TRIGGERLEFT:
49 return ControllerButton::AXIS_TRIGGERLEFT;
50#endif
51#ifdef JOY_BUTTON_TRIGGERRIGHT
52 case JOY_BUTTON_TRIGGERRIGHT:
53 return ControllerButton::AXIS_TRIGGERRIGHT;
54#endif
55#ifdef JOY_BUTTON_START
56 case JOY_BUTTON_START:
57 return ControllerButton::BUTTON_START;
58#endif
59#ifdef JOY_BUTTON_BACK
60 case JOY_BUTTON_BACK:
61 return ControllerButton::BUTTON_BACK;
62#endif
63#ifdef JOY_BUTTON_DPAD_LEFT
64 case JOY_BUTTON_DPAD_LEFT:
65 return ControllerButton::BUTTON_DPAD_LEFT;
66#endif

Callers 2

ToControllerButtonEventFunction · 0.85
IsJoystickButtonPressedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected