diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2024-01-15 15:17:32 +0100 |
|---|---|---|
| committer | Admiral H. Curtiss <pikachu025@gmail.com> | 2024-01-15 15:17:32 +0100 |
| commit | 959c39133b792d13ec27616e7ade82b73adc2086 (patch) | |
| tree | 23604a740116274bd0da80202f06258c2435af4b /Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp | |
| parent | c76dee7807c331582cfb36376329e760eab3f704 (diff) | |
InputCommon/SDL: Fix incorrect use of std::vector::assign() and check bounds.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp index 7887075743..a8546d10e7 100644 --- a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp +++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp @@ -354,13 +354,16 @@ GameController::GameController(SDL_GameController* const gamecontroller, case SDL_CONTROLLER_BINDTYPE_NONE: return; case SDL_CONTROLLER_BINDTYPE_BUTTON: - is_button_mapped.assign(bind.value.button, true); + if (bind.value.button >= 0 && bind.value.button < n_legacy_buttons) + is_button_mapped[bind.value.button] = true; break; case SDL_CONTROLLER_BINDTYPE_AXIS: - is_axis_mapped.assign(bind.value.axis, true); + if (bind.value.axis >= 0 && bind.value.axis < n_legacy_axes) + is_axis_mapped[bind.value.axis] = true; break; case SDL_CONTROLLER_BINDTYPE_HAT: - is_hat_mapped.assign(bind.value.hat.hat, true); + if (bind.value.hat.hat >= 0 && bind.value.hat.hat < n_legacy_hats) + is_hat_mapped[bind.value.hat.hat] = true; break; } }; |
