fix some bugs in joystick initialization
authorBradley Bell <btb@icculus.org>
Tue, 5 Apr 2005 07:35:09 +0000 (07:35 +0000)
committerBradley Bell <btb@icculus.org>
Tue, 5 Apr 2005 07:35:09 +0000 (07:35 +0000)
ChangeLog
arch/linux/joystick.c
arch/sdl/joy.c
main/kconfig.c

index 197ba5a..8fd814e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-04-05  Bradley Bell  <btb@icculus.org>
+
+       * arch/linux/joystick.c, arch/sdl/joy.c, main/kconfig.c: fix some
+       bugs in joystick initialization
+
 2005-04-04  Bradley Bell  <btb@icculus.org>
 
        * main/kconfig.c: cosmetic fixes to joystick config screen
index e16ba96..e76077c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: joystick.c,v 1.7 2005-04-04 09:18:08 btb Exp $ */
+/* $Id: joystick.c,v 1.8 2005-04-05 07:35:09 btb Exp $ */
 /*
  *
  * Linux joystick support
@@ -213,10 +213,10 @@ int joy_init () {
                j_joystick[1].buffer = open ("/dev/js1", O_NONBLOCK);
                j_joystick[2].buffer = open ("/dev/js2", O_NONBLOCK);
                j_joystick[3].buffer = open ("/dev/js3", O_NONBLOCK);
-               j_joystick[0].buffer = open("/dev/input/js0", O_NONBLOCK);
-               j_joystick[1].buffer = open("/dev/input/js1", O_NONBLOCK);
-               j_joystick[2].buffer = open("/dev/input/js2", O_NONBLOCK);
-               j_joystick[3].buffer = open("/dev/input/js3", O_NONBLOCK);
+               j_joystick[4].buffer = open("/dev/input/js0", O_NONBLOCK);
+               j_joystick[5].buffer = open("/dev/input/js1", O_NONBLOCK);
+               j_joystick[6].buffer = open("/dev/input/js2", O_NONBLOCK);
+               j_joystick[7].buffer = open("/dev/input/js3", O_NONBLOCK);
 
                // Determine whether any sticks were found
                joystick_found = 0;
index 7d3fbba..760c1a7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: joy.c,v 1.17 2005-04-04 09:18:08 btb Exp $ */
+/* $Id: joy.c,v 1.18 2005-04-05 07:35:09 btb Exp $ */
 /*
  *
  * SDL joystick support
@@ -151,6 +151,8 @@ int joy_init()
        }
 
        memset(&Joystick,0,sizeof(Joystick));
+       memset(joyaxis_text, 0, JOY_MAX_AXES * sizeof(char *));
+       memset(joybutton_text, 0, JOY_MAX_BUTTONS * sizeof(char *));
 
        n = SDL_NumJoysticks();
 
index f9c5fb6..b02ab77 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: kconfig.c,v 1.37 2005-04-04 09:48:50 btb Exp $ */
+/* $Id: kconfig.c,v 1.38 2005-04-05 07:35:09 btb Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -23,7 +23,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 #endif
 
 #ifdef RCS
-static char rcsid[] = "$Id: kconfig.c,v 1.37 2005-04-04 09:48:50 btb Exp $";
+static char rcsid[] = "$Id: kconfig.c,v 1.38 2005-04-05 07:35:09 btb Exp $";
 #endif
 
 #ifdef WINDOWS
@@ -854,7 +854,10 @@ int get_item_height(kc_item *item)
 #ifdef USE_LINUX_JOY
                                sprintf(btext, "J%d B%d", j_button[item->value].joydev, j_Get_joydev_button_number(item->value));
 #elif defined(SDL_INPUT)
-                               strncpy(btext, joybutton_text[item->value], 10);
+                               if (joybutton_text[item->value])
+                                       strncpy(btext, joybutton_text[item->value], 10);
+                               else
+                                       sprintf(btext, "BTN%2d", item->value + 1);
 #else
                                if ( joybutton_text[item->value] !=-1 )
                                        strncpy( btext, Text_string[ joybutton_text[item->value]  ], 10 );
@@ -866,7 +869,10 @@ int get_item_height(kc_item *item)
 #ifdef USE_LINUX_JOY
                                sprintf( btext, "J%d A%d", j_axis[item->value].joydev, j_Get_joydev_axis_number (item->value) );
 #elif defined(SDL_INPUT)
-                               strncpy(btext, joyaxis_text[item->value], 10);
+                               if (joyaxis_text[item->value])
+                                       strncpy(btext, joyaxis_text[item->value], 10);
+                               else
+                                       sprintf(btext, "AXIS%2d", item->value + 1);
 #else
                                strncpy(btext, Text_string[joyaxis_text[item->value]], 10);
 #endif
@@ -1385,7 +1391,10 @@ WIN(DDGRUNLOCK(dd_grd_curcanv));
 #ifdef USE_LINUX_JOY
                                sprintf(btext, "J%d B%d", j_button[item->value].joydev, j_Get_joydev_button_number(item->value));
 #elif defined(SDL_INPUT)
-                               strncpy(btext, joybutton_text[item->value], 10);
+                               if (joybutton_text[item->value])
+                                       strncpy(btext, joybutton_text[item->value], 10);
+                               else
+                                       sprintf(btext, "BTN%2d", item->value + 1);
 #else
 # ifndef MACINTOSH
 #  ifdef WINDOWS
@@ -1410,7 +1419,10 @@ WIN(DDGRUNLOCK(dd_grd_curcanv));
 #ifdef USE_LINUX_JOY
                                sprintf(btext, "J%d A%d", j_axis[item->value].joydev, j_Get_joydev_axis_number(item->value));
 #elif defined(SDL_INPUT)
-                               strncpy(btext, joyaxis_text[item->value], 10);
+                               if (joyaxis_text[item->value])
+                                       strncpy(btext, joyaxis_text[item->value], 10);
+                               else
+                                       sprintf(btext, "AXIS%2d", item->value + 1);
 #else
                                strncpy(btext, Text_string[joyaxis_text[item->value]], 10);
 #endif