| 27 | } |
| 28 | |
| 29 | StaticVector<ControllerButtonEvent, 4> ToControllerButtonEvents(const SDL_Event &event) |
| 30 | { |
| 31 | ControllerButtonEvent result { ControllerButton_NONE, false }; |
| 32 | switch (event.type) { |
| 33 | #ifndef USE_SDL1 |
| 34 | case SDL_CONTROLLERBUTTONUP: |
| 35 | #endif |
| 36 | case SDL_JOYBUTTONUP: |
| 37 | case SDL_KEYUP: |
| 38 | result.up = true; |
| 39 | break; |
| 40 | default: |
| 41 | break; |
| 42 | } |
| 43 | #if HAS_KBCTRL == 1 |
| 44 | if (!demo::IsRunning()) { |
| 45 | result.button = KbCtrlToControllerButton(event); |
| 46 | if (result.button != ControllerButton_NONE) |
| 47 | return { result }; |
| 48 | } |
| 49 | #endif |
| 50 | #ifndef USE_SDL1 |
| 51 | GameController *const controller = GameController::Get(event); |
| 52 | if (controller != nullptr) { |
| 53 | result.button = controller->ToControllerButton(event); |
| 54 | if (result.button != ControllerButton_NONE) { |
| 55 | if (result.button == ControllerButton_AXIS_TRIGGERLEFT || result.button == ControllerButton_AXIS_TRIGGERRIGHT) { |
| 56 | result.up = !controller->IsPressed(result.button); |
| 57 | } |
| 58 | return { result }; |
| 59 | } |
| 60 | } |
| 61 | #endif |
| 62 | |
| 63 | const Joystick *joystick = Joystick::Get(event); |
| 64 | if (joystick != nullptr) { |
| 65 | return devilution::Joystick::ToControllerButtonEvents(event); |
| 66 | } |
| 67 | |
| 68 | return { result }; |
| 69 | } |
| 70 | |
| 71 | bool IsControllerButtonPressed(ControllerButton button) |
| 72 | { |
no test coverage detected