mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Gracefully handle negative indexes in love.joystick (bug #172)
This commit is contained in:
@@ -68,15 +68,13 @@ namespace sdl
|
||||
|
||||
bool Joystick::checkIndex(int index)
|
||||
{
|
||||
if(index < getNumJoysticks())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return index >= 0 && index < getNumJoysticks();
|
||||
}
|
||||
|
||||
int Joystick::getNumJoysticks()
|
||||
{
|
||||
return SDL_NumJoysticks();
|
||||
int num = SDL_NumJoysticks();
|
||||
return num < 0 ? 0 : num;
|
||||
}
|
||||
|
||||
const char * Joystick::getName(int index)
|
||||
|
||||
Reference in New Issue
Block a user