mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +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)
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user