diff options
author | Lioncash <mathew1800@gmail.com> | 2020-08-29 03:13:23 +0200 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2020-08-29 03:13:26 +0200 |
commit | e92164e6a06361382b8072228530f69a6b10189f (patch) | |
tree | 9a92ac94e4f5d57c8c2606fd196a13b22cf58820 | |
parent | sdl_impl: Prevent type truncation in BuildAnalogParamPackageForButton() default arguments (diff) | |
download | yuzu-e92164e6a06361382b8072228530f69a6b10189f.tar yuzu-e92164e6a06361382b8072228530f69a6b10189f.tar.gz yuzu-e92164e6a06361382b8072228530f69a6b10189f.tar.bz2 yuzu-e92164e6a06361382b8072228530f69a6b10189f.tar.lz yuzu-e92164e6a06361382b8072228530f69a6b10189f.tar.xz yuzu-e92164e6a06361382b8072228530f69a6b10189f.tar.zst yuzu-e92164e6a06361382b8072228530f69a6b10189f.zip |
Diffstat (limited to '')
-rw-r--r-- | src/input_common/sdl/sdl_impl.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index 9d3d1803c..85fcd457c 100644 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp @@ -697,16 +697,17 @@ ButtonMapping SDLState::GetButtonMappingForDevice(const Common::ParamPackage& pa return {}; } const auto joystick = GetSDLJoystickByGUID(params.Get("guid", ""), params.Get("port", 0)); - auto controller = joystick->GetSDLGameController(); - if (!controller) { + auto* controller = joystick->GetSDLGameController(); + if (controller == nullptr) { return {}; } ButtonMapping mapping{}; for (const auto& [switch_button, sdl_button] : switch_to_sdl_button) { const auto& binding = SDL_GameControllerGetBindForButton(controller, sdl_button); - mapping[switch_button] = - BuildParamPackageForBinding(joystick->GetPort(), joystick->GetGUID(), binding); + mapping.insert_or_assign( + switch_button, + BuildParamPackageForBinding(joystick->GetPort(), joystick->GetGUID(), binding)); } // Add the missing bindings for ZL/ZR @@ -717,8 +718,9 @@ ButtonMapping SDLState::GetButtonMappingForDevice(const Common::ParamPackage& pa }; for (const auto& [switch_button, sdl_axis] : switch_to_sdl_axis) { const auto& binding = SDL_GameControllerGetBindForAxis(controller, sdl_axis); - mapping[switch_button] = - BuildParamPackageForBinding(joystick->GetPort(), joystick->GetGUID(), binding); + mapping.insert_or_assign( + switch_button, + BuildParamPackageForBinding(joystick->GetPort(), joystick->GetGUID(), binding)); } return mapping; @@ -729,8 +731,8 @@ AnalogMapping SDLState::GetAnalogMappingForDevice(const Common::ParamPackage& pa return {}; } const auto joystick = GetSDLJoystickByGUID(params.Get("guid", ""), params.Get("port", 0)); - auto controller = joystick->GetSDLGameController(); - if (!controller) { + auto* controller = joystick->GetSDLGameController(); + if (controller == nullptr) { return {}; } @@ -739,16 +741,18 @@ AnalogMapping SDLState::GetAnalogMappingForDevice(const Common::ParamPackage& pa SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_LEFTX); const auto& binding_left_y = SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_LEFTY); - mapping[Settings::NativeAnalog::LStick] = - BuildParamPackageForAnalog(joystick->GetPort(), joystick->GetGUID(), - binding_left_x.value.axis, binding_left_y.value.axis); + mapping.insert_or_assign(Settings::NativeAnalog::LStick, + BuildParamPackageForAnalog(joystick->GetPort(), joystick->GetGUID(), + binding_left_x.value.axis, + binding_left_y.value.axis)); const auto& binding_right_x = SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX); const auto& binding_right_y = SDL_GameControllerGetBindForAxis(controller, SDL_CONTROLLER_AXIS_RIGHTY); - mapping[Settings::NativeAnalog::RStick] = - BuildParamPackageForAnalog(joystick->GetPort(), joystick->GetGUID(), - binding_right_x.value.axis, binding_right_y.value.axis); + mapping.insert_or_assign(Settings::NativeAnalog::RStick, + BuildParamPackageForAnalog(joystick->GetPort(), joystick->GetGUID(), + binding_right_x.value.axis, + binding_right_y.value.axis)); return mapping; } |