foxygit / doom Log in
commit 5dfc75633f21b5282422aa2db9d00cc3a766bc68
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Fri Jun 1 18:08:42 2007 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Fri Jun 1 18:08:42 2007 +0000

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

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 890
---
 src/i_joystick.c | 7 +++++++
 1 file changed, 7 insertions(+)

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);