summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2024-01-15 15:18:38 +0100
committerAdmiral H. Curtiss <pikachu025@gmail.com>2024-01-15 15:18:38 +0100
commitd657ad5932fc678037aa98a32048e8d70cca6562 (patch)
tree83cbfecda504bb1999aa58c685e9d7b1aa6d4ea9 /Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp
parent959c39133b792d13ec27616e7ade82b73adc2086 (diff)
InputCommon/SDL: Check for errors from SDL_JoystickNumButtons(), SDL_JoystickNumAxes(), SDL_JoystickNumHats().
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp
index a8546d10e7..3240a74914 100644
--- a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp
@@ -342,8 +342,26 @@ GameController::GameController(SDL_GameController* const gamecontroller,
// If a Joystick Button has a GameController equivalent, don't detect it
int n_legacy_buttons = SDL_JoystickNumButtons(joystick);
+ if (n_legacy_buttons < 0)
+ {
+ ERROR_LOG_FMT(CONTROLLERINTERFACE, "Error in SDL_JoystickNumButtons(): {}", SDL_GetError());
+ n_legacy_buttons = 0;
+ }
+
int n_legacy_axes = SDL_JoystickNumAxes(joystick);
+ if (n_legacy_axes < 0)
+ {
+ ERROR_LOG_FMT(CONTROLLERINTERFACE, "Error in SDL_JoystickNumAxes(): {}", SDL_GetError());
+ n_legacy_axes = 0;
+ }
+
int n_legacy_hats = SDL_JoystickNumHats(joystick);
+ if (n_legacy_hats < 0)
+ {
+ ERROR_LOG_FMT(CONTROLLERINTERFACE, "Error in SDL_JoystickNumHats(): {}", SDL_GetError());
+ n_legacy_hats = 0;
+ }
+
std::vector<bool> is_button_mapped(n_legacy_buttons);
std::vector<bool> is_axis_mapped(n_legacy_axes);
std::vector<bool> is_hat_mapped(n_legacy_hats);