fixed joystick naming convention from file descriptor to joystick number
authorHolger Schemel <info@artsoft.org>
Mon, 3 Jul 2017 20:07:06 +0000 (22:07 +0200)
committerHolger Schemel <info@artsoft.org>
Mon, 3 Jul 2017 20:07:06 +0000 (22:07 +0200)
src/libgame/joystick.c
src/libgame/sdl.c
src/libgame/system.c
src/libgame/system.h

index a6a065cddc318a4322279fb8dd20b85d3328b973..61d0a113970302c70e1337d20096cab32b5102b9 100644 (file)
@@ -161,22 +161,22 @@ void CheckJoystickData()
 
 int JoystickExt(int player_nr, boolean use_as_joystick_nr)
 {
-  int joystick_fd = joystick.fd[player_nr];
+  int joystick_nr = joystick.nr[player_nr];
   int js_x, js_y;
   boolean js_b1, js_b2;
   int left, right, up, down;
   int result = JOY_NO_ACTION;
 
   if (use_as_joystick_nr)
-    joystick_fd = player_nr;
+    joystick_nr = player_nr;
 
   if (joystick.status != JOYSTICK_ACTIVATED)
     return JOY_NO_ACTION;
 
-  if (joystick_fd < 0)
+  if (joystick_nr < 0)
     return JOY_NO_ACTION;
 
-  if (!ReadJoystick(joystick_fd, &js_x, &js_y, &js_b1, &js_b2))
+  if (!ReadJoystick(joystick_nr, &js_x, &js_y, &js_b1, &js_b2))
   {
     Error(ERR_WARN, "cannot read joystick device '%s'",
          setup.input[player_nr].joy.device_name);
index ee43dc05b0c1b1795328b129d1ca0a563f0398e2..04a098cdaf0af24fc5af18895ec936123f2bb63d 100644 (file)
@@ -2913,8 +2913,8 @@ void SDLInitJoysticks()
       joystick_nr = -1;
     }
 
-    /* misuse joystick file descriptor variable to store joystick number */
-    joystick.fd[i] = joystick_nr;
+    /* store configured joystick number for each player */
+    joystick.nr[i] = joystick_nr;
   }
 
   /* now open all connected joysticks (regardless if configured or not) */
index de59d77a6ce4bf501d8d278fa43f12c29216c617..5ccf3fb3784650147bc1f70aed77af72925dd0bb 100644 (file)
@@ -1620,7 +1620,7 @@ void InitJoysticks()
   /* always start with reliable default values */
   joystick.status = JOYSTICK_NOT_AVAILABLE;
   for (i = 0; i < MAX_PLAYERS; i++)
-    joystick.fd[i] = -1;               /* joystick device closed */
+    joystick.nr[i] = -1;               /* no joystick configured */
 
   SDLInitJoysticks();
 }
index 72a0754e1b5b5e5ab54904abce54b023eb03d760..ca25b287ff43c9d07bc09d77ddd6370284628718 100644 (file)
@@ -947,7 +947,7 @@ struct OverlayInfo
 struct JoystickInfo
 {
   int status;
-  int fd[MAX_PLAYERS];         /* file descriptor of player's joystick */
+  int nr[MAX_PLAYERS];         /* joystick number for each player */
 };
 
 struct SetupJoystickInfo