Gracefully handle negative indexes in love.joystick (bug #172)

This commit is contained in:
Bart van Strien
2011-01-17 11:04:02 +01:00
parent fde708160e
commit 98406370eb
+3 -5
View File
@@ -68,15 +68,13 @@ namespace sdl
bool Joystick::checkIndex(int index) bool Joystick::checkIndex(int index)
{ {
if(index < getNumJoysticks()) return index >= 0 && index < getNumJoysticks();
return true;
else
return false;
} }
int Joystick::getNumJoysticks() int Joystick::getNumJoysticks()
{ {
return SDL_NumJoysticks(); int num = SDL_NumJoysticks();
return num < 0 ? 0 : num;
} }
const char * Joystick::getName(int index) const char * Joystick::getName(int index)