Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #279 from Sonicadvance1/Reject-InvalidControllers
Don't use SDL devices that report invalid ranges.
  • Loading branch information
delroth committed Apr 16, 2014
2 parents 1ab8ced + c88b836 commit 0908bd6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp
Expand Up @@ -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));
Expand Down

0 comments on commit 0908bd6

Please sign in to comment.