diff options
-rw-r--r-- | src/i_joystick.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/i_joystick.c b/src/i_joystick.c index 4d73a3af..0e0f7590 100644 --- a/src/i_joystick.c +++ b/src/i_joystick.c @@ -75,6 +75,13 @@ void I_InitJoystick(void) return; } + if (joystick_index < 0 || joystick_index >= SDL_NumJoysticks()) + { + printf("I_InitJoystick: Invalid joystick ID: %i\n", joystick_index); + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); + return; + } + // Open the joystick joystick = SDL_JoystickOpen(joystick_index); |