shithub: choc

Download patch

ref: 5dfc75633f21b5282422aa2db9d00cc3a766bc68
parent: 200a86cf8378233fbb9e3687620ea9e577c3d773
author: Simon Howard <[email protected]>
date: Fri Jun 1 14:08:42 EDT 2007

Display a meaningful message when trying to start with an invalid
Joystick ID.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 890

--- a/src/i_joystick.c
+++ b/src/i_joystick.c
@@ -75,6 +75,13 @@
         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);