diff options
| author | 2021-11-21 12:59:51 -0600 | |
|---|---|---|
| committer | 2021-11-24 20:30:28 -0600 | |
| commit | c4760489a0386cdeaed68ecbed7f87532193743e (patch) | |
| tree | 2ac91b9c1c6bb0bb70fe7bcf148b2469e96e7247 /src/input_common/drivers/sdl_driver.cpp | |
| parent | bootmanager: Use cross-platform keyboard input (diff) | |
| download | yuzu-c4760489a0386cdeaed68ecbed7f87532193743e.tar.gz yuzu-c4760489a0386cdeaed68ecbed7f87532193743e.tar.xz yuzu-c4760489a0386cdeaed68ecbed7f87532193743e.zip | |
input_common: Fix SDL controller with inverted axis
Diffstat (limited to '')
| -rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 23 |
1 files changed, 0 insertions, 23 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index 0b24f1858..d5af6c09b 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp | |||
| @@ -220,24 +220,6 @@ public: | |||
| 220 | return "Unknown"; | 220 | return "Unknown"; |
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | bool IsYAxis(u8 index) { | ||
| 224 | if (!sdl_controller) { | ||
| 225 | return false; | ||
| 226 | } | ||
| 227 | |||
| 228 | const auto& binding_left_y = | ||
| 229 | SDL_GameControllerGetBindForAxis(sdl_controller.get(), SDL_CONTROLLER_AXIS_LEFTY); | ||
| 230 | const auto& binding_right_y = | ||
| 231 | SDL_GameControllerGetBindForAxis(sdl_controller.get(), SDL_CONTROLLER_AXIS_RIGHTY); | ||
| 232 | if (index == binding_left_y.value.axis) { | ||
| 233 | return true; | ||
| 234 | } | ||
| 235 | if (index == binding_right_y.value.axis) { | ||
| 236 | return true; | ||
| 237 | } | ||
| 238 | return false; | ||
| 239 | } | ||
| 240 | |||
| 241 | private: | 223 | private: |
| 242 | std::string guid; | 224 | std::string guid; |
| 243 | int port; | 225 | int port; |
| @@ -376,11 +358,6 @@ void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) { | |||
| 376 | case SDL_JOYAXISMOTION: { | 358 | case SDL_JOYAXISMOTION: { |
| 377 | if (const auto joystick = GetSDLJoystickBySDLID(event.jaxis.which)) { | 359 | if (const auto joystick = GetSDLJoystickBySDLID(event.jaxis.which)) { |
| 378 | const PadIdentifier identifier = joystick->GetPadIdentifier(); | 360 | const PadIdentifier identifier = joystick->GetPadIdentifier(); |
| 379 | // Vertical axis is inverted on nintendo compared to SDL | ||
| 380 | if (joystick->IsYAxis(event.jaxis.axis)) { | ||
| 381 | SetAxis(identifier, event.jaxis.axis, -event.jaxis.value / 32767.0f); | ||
| 382 | break; | ||
| 383 | } | ||
| 384 | SetAxis(identifier, event.jaxis.axis, event.jaxis.value / 32767.0f); | 361 | SetAxis(identifier, event.jaxis.axis, event.jaxis.value / 32767.0f); |
| 385 | } | 362 | } |
| 386 | break; | 363 | break; |