shithub: choc

Download patch

ref: 6aad2f80343bbc527b7f652fc9c1752a34442afd
parent: 59d5f4e54e320dafddb2ad38493a23f7f7fc054c
author: Simon Howard <fraggle@soulsphere.org>
date: Sun Jan 3 10:27:48 EST 2016

joystick: Don't initialize if joystick_index < 0.

We only initialize the joystick subsystem if usejoystick is true, but
joystick_index must also be valid in order to use a joystick, and a
negative value indicates no joystick is set.

--- a/src/i_joystick.c
+++ b/src/i_joystick.c
@@ -107,7 +107,7 @@
 
 void I_InitJoystick(void)
 {
-    if (!usejoystick)
+    if (!usejoystick || joystick_index < 0)
     {
         return;
     }
@@ -117,7 +117,7 @@
         return;
     }
 
-    if (joystick_index < 0 || joystick_index >= SDL_NumJoysticks())
+    if (joystick_index >= SDL_NumJoysticks())
     {
         printf("I_InitJoystick: Invalid joystick ID: %i\n", joystick_index);
         SDL_QuitSubSystem(SDL_INIT_JOYSTICK);