aboutsummaryrefslogtreecommitdiff
path: root/src/input_common
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/drivers/sdl_driver.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index c3e9a066b3..1f1f9543f4 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -589,6 +589,15 @@ void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) {
}
break;
}
+ case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
+ case SDL_EVENT_GAMEPAD_BUTTON_UP: {
+ const bool down = event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN;
+ if (const auto joystick = GetSDLJoystickBySDLID(event.gbutton.which)) {
+ const PadIdentifier identifier = joystick->GetPadIdentifier();
+ SetButton(identifier, event.gbutton.button, down);
+ }
+ break;
+ }
case SDL_EVENT_JOYSTICK_HAT_MOTION: {
if (const auto joystick = GetSDLJoystickBySDLID(event.jhat.which)) {
const PadIdentifier identifier = joystick->GetPadIdentifier();
@@ -603,6 +612,13 @@ void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) {
}
break;
}
+ case SDL_EVENT_GAMEPAD_AXIS_MOTION: {
+ if (const auto joystick = GetSDLJoystickBySDLID(event.gaxis.which)) {
+ const PadIdentifier identifier = joystick->GetPadIdentifier();
+ SetAxis(identifier, event.gaxis.axis, event.gaxis.value / 32767.0f);
+ }
+ break;
+ }
case SDL_EVENT_GAMEPAD_SENSOR_UPDATE: {
auto joystick = GetSDLJoystickByGamepadID(event.gsensor.which);
if (!joystick) {