Updates motion state for mouse and joystick sticks.
| 83 | |
| 84 | // Updates motion state for mouse and joystick sticks. |
| 85 | bool ProcessControllerMotion(const SDL_Event &event) |
| 86 | { |
| 87 | #ifndef USE_SDL1 |
| 88 | if (ProcessGameControllerAxisMotion(event)) |
| 89 | return true; |
| 90 | #endif |
| 91 | if (ProcessJoystickAxisMotion(event)) |
| 92 | return true; |
| 93 | #if HAS_KBCTRL == 1 |
| 94 | if (ProcessKbCtrlAxisMotion(event)) |
| 95 | return true; |
| 96 | #endif |
| 97 | |
| 98 | // SELECT + D-Pad simulating mouse movement. |
| 99 | if (!IsControllerButtonPressed(ControllerButton::BUTTON_BACK)) { |
| 100 | rightStickX = 0; |
| 101 | rightStickY = 0; |
| 102 | return false; |
| 103 | } |
| 104 | |
| 105 | const ControllerButtonEvent ctrl_event = ToControllerButtonEvent(event); |
| 106 | if (!IsDPadButton(ctrl_event.button)) |
| 107 | return false; |
| 108 | if (IsControllerButtonPressed(ControllerButton::BUTTON_DPAD_LEFT)) { |
| 109 | rightStickX = -1; |
| 110 | } else if (IsControllerButtonPressed(ControllerButton::BUTTON_DPAD_RIGHT)) { |
| 111 | rightStickX = 1; |
| 112 | } else { |
| 113 | rightStickX = 0; |
| 114 | } |
| 115 | if (IsControllerButtonPressed(ControllerButton::BUTTON_DPAD_UP)) { |
| 116 | rightStickY = 1; |
| 117 | } else if (IsControllerButtonPressed(ControllerButton::BUTTON_DPAD_DOWN)) { |
| 118 | rightStickY = -1; |
| 119 | } else { |
| 120 | rightStickY = 0; |
| 121 | } |
| 122 | return true; |
| 123 | } |
| 124 | |
| 125 | } // namespace dvl |
no test coverage detected