summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2014-04-17 00:16:19 +0200
committerPierre Bourdon <delroth@gmail.com>2014-04-17 00:16:19 +0200
commit0908bd64dc9d9393dbce2ad192b6634d32ea5ad9 (patch)
treed674eb50017c6f0d39878a1f661485a5e88f36ec /Source/Core/InputCommon/ControllerInterface
parent1ab8cedfceeb07212b5d327b8249d05ec3cb4f42 (diff)
parentc88b83699ee40147fa73b7ee8548aef1881fb0ca (diff)
Merge pull request #279 from Sonicadvance1/Reject-InvalidControllers
Don't use SDL devices that report invalid ranges.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp
index 56c526a079..4b738d4dbf 100644
--- a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp
@@ -78,6 +78,17 @@ Joystick::Joystick(SDL_Joystick* const joystick, const int sdl_index, const unsi
}
#endif
+ if (SDL_JoystickNumButtons(joystick) > 255 ||
+ SDL_JoystickNumAxes(joystick) > 255 ||
+ SDL_JoystickNumHats(joystick) > 255 ||
+ SDL_JoystickNumBalls(joystick) > 255)
+ {
+ // This device is invalid, don't use it
+ // Some crazy devices(HP webcam 2100) end up as HID devices
+ // SDL tries parsing these as joysticks
+ return;
+ }
+
// get buttons
for (u8 i = 0; i != SDL_JoystickNumButtons(m_joystick); ++i)
AddInput(new Button(i, m_joystick));