From 11ca4976d9d38fe9bb633b5ccd34a0211e304a7d Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Mon, 4 Apr 2005 09:21:25 +0000 Subject: [PATCH] change MAX_BUTTONS to JOY_MAX_BUTTONS --- ChangeLog | 3 ++- arch/dos/joyc.c | 27 +++++++++++++++------------ arch/include/joy.h | 6 +++--- arch/linux/include/joystick.h | 4 ++-- arch/linux/joydefs.c | 4 ++-- arch/linux/joystick.c | 8 ++++---- arch/sdl/joy.c | 4 ++-- arch/win32/include/joy.h | 2 +- arch/win32/joyhh.c | 24 +++++++++++++++--------- main/kconfig.c | 8 ++++---- unused/bios/joyc.c | 29 ++++++++++++++++++----------- unused/win95/joyc.c | 29 ++++++++++++++++++----------- 12 files changed, 86 insertions(+), 62 deletions(-) diff --git a/ChangeLog b/ChangeLog index 28ad5998..a5b3c821 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,8 @@ * arch/dos/joyc.c, arch/include/joy.h, arch/linux/joydefs.c, arch/linux/joystick.c, arch/linux/include/joystick.h, arch/sdl/joy.c, arch/win32/joyhh.c, arch/win32/include/joy.h, - main/kconfig.c: change MAX_BUTTONS to JOY_MAX_BUTTONS + main/kconfig.c, unused/bios/joyc.c, unused/win95/joyc.c: change + MAX_BUTTONS to JOY_MAX_BUTTONS * arch/sdl/joy.c, main/kconfig.c: don't use hardcoded descriptions of joystick buttons/axes diff --git a/arch/dos/joyc.c b/arch/dos/joyc.c index ae4da9a2..0c8ef2b9 100644 --- a/arch/dos/joyc.c +++ b/arch/dos/joyc.c @@ -1,3 +1,4 @@ +/* $Id: joyc.c,v 1.7 2005-04-04 09:18:08 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -12,10 +13,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ /* - * $Source: /cvs/cvsroot/d2x/arch/dos/joyc.c,v $ - * $Revision: 1.6 $ - * $Author: schaffner $ - * $Date: 2004-08-28 23:17:45 $ * * Routines for joystick reading. * @@ -74,7 +71,7 @@ typedef struct Joy_info { int max_timer; int read_count; ubyte last_value; - Button_info buttons[MAX_BUTTONS]; + Button_info buttons[JOY_MAX_BUTTONS]; int axis_min[4]; int axis_center[4]; int axis_max[4]; @@ -133,7 +130,8 @@ void joy_flush() { if (!joy_installed) return; _disable(); - for (i=0; iignore) { if ( i < 5 ) @@ -319,7 +318,7 @@ int joy_init() joy_flush(); _disable(); - for (i=0; i= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; _disable(); count = joystick.buttons[btn].state; @@ -596,7 +596,8 @@ int joy_get_button_up_cnt( int btn ) if ((!joy_installed)||(!joy_present)) return 0; - if ( btn >= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; _disable(); count = joystick.buttons[btn].upcount; @@ -611,7 +612,8 @@ int joy_get_button_down_cnt( int btn ) int count; if ((!joy_installed)||(!joy_present)) return 0; - if ( btn >= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; _disable(); count = joystick.buttons[btn].downcount; @@ -627,7 +629,8 @@ fix joy_get_button_down_time( int btn ) fix count; if ((!joy_installed)||(!joy_present)) return 0; - if ( btn >= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; _disable(); count = joystick.buttons[btn].timedown; diff --git a/arch/include/joy.h b/arch/include/joy.h index dc6f7b21..eb75568a 100644 --- a/arch/include/joy.h +++ b/arch/include/joy.h @@ -1,4 +1,4 @@ -/* $Id: joy.h,v 1.9 2004-11-22 23:32:54 btb Exp $ */ +/* $Id: joy.h,v 1.10 2005-04-04 09:18:08 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -66,9 +66,9 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define JOY_FRIENDLY_READINGS 8 #ifdef USE_LINUX_JOY -#define MAX_BUTTONS 64 +#define JOY_MAX_BUTTONS 64 #else -#define MAX_BUTTONS 20 +#define JOY_MAX_BUTTONS 20 #endif //========================================================================== diff --git a/arch/linux/include/joystick.h b/arch/linux/include/joystick.h index 03203fb6..73e88a22 100644 --- a/arch/linux/include/joystick.h +++ b/arch/linux/include/joystick.h @@ -1,4 +1,4 @@ -/* $Id: joystick.h,v 1.4 2004-11-22 23:32:54 btb Exp $ */ +/* $Id: joystick.h,v 1.5 2005-04-04 09:18:08 btb Exp $ */ typedef struct joystick_device { int device_number; @@ -32,7 +32,7 @@ extern int j_num_buttons; extern joystick_device j_joystick[MAX_JOY_DEVS]; extern joystick_axis j_axis[JOY_MAX_AXES]; -extern joystick_button j_button[MAX_BUTTONS]; +extern joystick_button j_button[JOY_MAX_BUTTONS]; extern int j_Update_state (); extern int j_Get_joydev_axis_number (int all_axis_number); diff --git a/arch/linux/joydefs.c b/arch/linux/joydefs.c index 1a6b4391..83cc80fe 100644 --- a/arch/linux/joydefs.c +++ b/arch/linux/joydefs.c @@ -1,4 +1,4 @@ -/* $Id: joydefs.c,v 1.4 2004-11-22 23:32:54 btb Exp $ */ +/* $Id: joydefs.c,v 1.5 2005-04-04 09:18:08 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -84,7 +84,7 @@ extern int WriteConfigFile(); extern joystick_device j_joystick[MAX_JOY_DEVS]; extern joystick_axis j_axis[JOY_MAX_AXES]; -extern joystick_button j_button[MAX_BUTTONS]; +extern joystick_button j_button[JOY_MAX_BUTTONS]; void joydefs_calibrate() { diff --git a/arch/linux/joystick.c b/arch/linux/joystick.c index 8bef9b25..e16ba96b 100644 --- a/arch/linux/joystick.c +++ b/arch/linux/joystick.c @@ -1,4 +1,4 @@ -/* $Id: joystick.c,v 1.6 2004-11-22 23:32:54 btb Exp $ */ +/* $Id: joystick.c,v 1.7 2005-04-04 09:18:08 btb Exp $ */ /* * * Linux joystick support @@ -28,7 +28,7 @@ char joy_present = 0; joystick_device j_joystick[MAX_JOY_DEVS]; joystick_axis j_axis[JOY_MAX_AXES]; -joystick_button j_button[MAX_BUTTONS]; +joystick_button j_button[JOY_MAX_BUTTONS]; int joy_num_axes = 0, j_num_buttons = 0; int timer_rate; @@ -285,8 +285,8 @@ int joy_init () { if (joy_num_axes > JOY_MAX_AXES) joy_num_axes = JOY_MAX_AXES; - if (j_num_buttons > MAX_BUTTONS) - j_num_buttons = MAX_BUTTONS; + if (j_num_buttons > JOY_MAX_BUTTONS) + j_num_buttons = JOY_MAX_BUTTONS; joy_present = 1; joy_installed = 1; diff --git a/arch/sdl/joy.c b/arch/sdl/joy.c index ee5e40cd..7d3fbba8 100644 --- a/arch/sdl/joy.c +++ b/arch/sdl/joy.c @@ -1,4 +1,4 @@ -/* $Id: joy.c,v 1.16 2005-04-04 08:56:34 btb Exp $ */ +/* $Id: joy.c,v 1.17 2005-04-04 09:18:08 btb Exp $ */ /* * * SDL joystick support @@ -59,7 +59,7 @@ static struct joyinfo { int n_axes; int n_buttons; struct joyaxis axes[JOY_MAX_AXES]; - struct joybutton buttons[MAX_BUTTONS]; + struct joybutton buttons[JOY_MAX_BUTTONS]; } Joystick; /* This struct is an array, with one entry for each physical joystick diff --git a/arch/win32/include/joy.h b/arch/win32/include/joy.h index adb7de9c..3313eb2b 100644 --- a/arch/win32/include/joy.h +++ b/arch/win32/include/joy.h @@ -41,7 +41,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define JOY_NUM_AXES 6 -#define MAX_BUTTONS 20 +#define JOY_MAX_BUTTONS 20 //========================================================================== // This initializes the joy and does a "quick" calibration which diff --git a/arch/win32/joyhh.c b/arch/win32/joyhh.c index 728effe8..3b0dd36d 100644 --- a/arch/win32/joyhh.c +++ b/arch/win32/joyhh.c @@ -1,4 +1,4 @@ -/* $Id: joyhh.c,v 1.5 2004-05-22 08:00:04 btb Exp $ */ +/* $Id: joyhh.c,v 1.6 2005-04-04 09:18:08 btb Exp $ */ //JOYC.C for D1_3Dfx and D1OpenGL //D1_3Dfx is a Win32 executable using Glide and DirectX 3 //D1OpenGL is a Win32 executable using OpenGL and DirectX 3 @@ -72,7 +72,7 @@ typedef struct Joy_info { int max_timer; int read_count; ubyte last_value; - Button_info buttons[MAX_BUTTONS]; + Button_info buttons[JOY_MAX_BUTTONS]; int axis_min[JOY_NUM_AXES]; //changed int axis_center[JOY_NUM_AXES]; //changed --orulz int axis_max[JOY_NUM_AXES]; //changed @@ -122,7 +122,8 @@ void joy_flush() { if (!joy_installed) return; - for (i=0; i> i) & 0x1; if (!joystick.buttons[i].last_state && joystick.buttons[i].state) { @@ -235,7 +237,7 @@ int joy_init(int joyid) //HH: added joyid parameter joy_flush(); memset(&joystick, 0, sizeof(joystick)); - for (i=0; i= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; joy_get_btns(); @@ -506,7 +509,8 @@ int joy_get_button_up_cnt( int btn ) if ((!joy_installed)||(!joy_present)) return 0; - if ( btn >= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; count = joystick.buttons[btn].upcount; joystick.buttons[btn].upcount = 0; @@ -519,7 +523,8 @@ int joy_get_button_down_cnt( int btn ) int count; if ((!joy_installed)||(!joy_present)) return 0; - if ( btn >= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; joy_get_btns(); @@ -534,7 +539,8 @@ fix joy_get_button_down_time( int btn ) fix count; if ((!joy_installed)||(!joy_present)) return 0; - if ( btn >= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; joy_get_btns(); diff --git a/main/kconfig.c b/main/kconfig.c index c12fb75c..21539a5c 100644 --- a/main/kconfig.c +++ b/main/kconfig.c @@ -1,4 +1,4 @@ -/* $Id: kconfig.c,v 1.35 2005-04-04 08:56:34 btb Exp $ */ +/* $Id: kconfig.c,v 1.36 2005-04-04 09:18:08 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.35 2005-04-04 08:56:34 btb Exp $"; +static char rcsid[] = "$Id: kconfig.c,v 1.36 2005-04-04 09:18:08 btb Exp $"; #endif #ifdef WINDOWS @@ -118,7 +118,7 @@ int invert_text[2] = { TNUM_N, TNUM_Y }; }; int joyaxis_text[7] = { TNUM_X1, TNUM_Y1, TNUM_Z1, TNUM_UN, TNUM_P1,TNUM_R1,TNUM_YA1 }; #elif defined(SDL_INPUT) -char *joybutton_text[MAX_BUTTONS]; +char *joybutton_text[JOY_MAX_BUTTONS]; char *joyaxis_text[JOY_MAX_AXES]; #else int joybutton_text[28] = @@ -1608,7 +1608,7 @@ WIN(DDGRUNLOCK(dd_grd_curcanv)); } } } else { - for (i = 0; i < MAX_BUTTONS; i++) + for (i = 0; i < JOY_MAX_BUTTONS; i++) { if ( joy_get_button_state(i) ) code = i; diff --git a/unused/bios/joyc.c b/unused/bios/joyc.c index efe720b9..812e5933 100644 --- a/unused/bios/joyc.c +++ b/unused/bios/joyc.c @@ -1,3 +1,4 @@ +/* $Id: joyc.c,v 1.2 2005-04-04 09:21:25 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -13,7 +14,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #pragma off (unreferenced) -static char rcsid[] = "$Id: joyc.c,v 1.1.1.1 2001-01-19 03:30:14 bradleyb Exp $"; +static char rcsid[] = "$Id: joyc.c,v 1.2 2005-04-04 09:21:25 btb Exp $"; #pragma on (unreferenced) #include @@ -50,9 +51,9 @@ char joy_present = 0; #define JOY_READ_BUTTONS ((~(inp(0x201) >> 4))&0xf) #ifdef ARCADE #define JOY_READ_BUTTONS_ARCADE (~(inp(0x2A1))) -#define MAX_BUTTONS 28 +#define JOY_MAX_BUTTONS 28 #else -#define MAX_BUTTONS 20 +#define JOY_MAX_BUTTONS 20 #endif typedef struct Button_info { @@ -70,7 +71,7 @@ typedef struct Joy_info { int max_timer; int read_count; ubyte last_value; - Button_info buttons[MAX_BUTTONS]; + Button_info buttons[JOY_MAX_BUTTONS]; int axis_min[4]; int axis_center[4]; int axis_max[4]; @@ -122,7 +123,8 @@ void joy_flush() { if (!joy_installed) return; _disable(); - for (i=0; iignore) { if ( i < 5 ) @@ -311,7 +314,7 @@ int joy_init() joy_flush(); _disable(); - for (i=0; i= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; _disable(); count = joystick.buttons[btn].state; @@ -532,7 +536,8 @@ int joy_get_button_up_cnt( int btn ) if ((!joy_installed)||(!joy_present)) return 0; - if ( btn >= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; _disable(); count = joystick.buttons[btn].upcount; @@ -547,7 +552,8 @@ int joy_get_button_down_cnt( int btn ) int count; if ((!joy_installed)||(!joy_present)) return 0; - if ( btn >= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; _disable(); count = joystick.buttons[btn].downcount; @@ -563,7 +569,8 @@ fix joy_get_button_down_time( int btn ) fix count; if ((!joy_installed)||(!joy_present)) return 0; - if ( btn >= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; _disable(); count = joystick.buttons[btn].timedown; diff --git a/unused/win95/joyc.c b/unused/win95/joyc.c index 0c505932..54f67f03 100644 --- a/unused/win95/joyc.c +++ b/unused/win95/joyc.c @@ -1,3 +1,4 @@ +/* $Id: joyc.c,v 1.2 2005-04-04 09:21:25 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -13,7 +14,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #pragma off (unreferenced) -static char rcsid[] = "$Id: joyc.c,v 1.1.1.1 2001-01-19 03:30:15 bradleyb Exp $"; +static char rcsid[] = "$Id: joyc.c,v 1.2 2005-04-04 09:21:25 btb Exp $"; #pragma on (unreferenced) #define WIN95 @@ -42,7 +43,7 @@ static char rcsid[] = "$Id: joyc.c,v 1.1.1.1 2001-01-19 03:30:15 bradleyb Exp $" #define WIN_TACTILE_ON #define JOY_READ_BUTTONS -#define MAX_BUTTONS 20 +#define JOY_MAX_BUTTONS 20 #define JOY_POLL_RATE 75 // 100 ms. @@ -63,7 +64,7 @@ typedef struct Joy_info { int max_timer; int read_count; ubyte last_value; - Button_info buttons[MAX_BUTTONS]; + Button_info buttons[JOY_MAX_BUTTONS]; int axis_min[7]; int axis_center[7]; int axis_max[7]; @@ -110,7 +111,7 @@ int joy_init(int joy, int spjoy) joy_flush(); memset(&joystick, 0, sizeof(joystick)); - for (i=0; i= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; count = joystick.buttons[btn].state; @@ -556,7 +559,8 @@ int joy_get_button_up_cnt( int btn ) if ((!joy_installed)||(!joy_present)) return 0; - if ( btn >= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; count = joystick.buttons[btn].upcount; joystick.buttons[btn].upcount = 0; @@ -570,7 +574,8 @@ int joy_get_button_down_cnt( int btn ) int count; if ((!joy_installed)||(!joy_present)) return 0; - if ( btn >= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; count = joystick.buttons[btn].downcount; joystick.buttons[btn].downcount = 0; @@ -584,7 +589,8 @@ fix joy_get_button_down_time( int btn ) fix count; if ((!joy_installed)||(!joy_present)) return 0; - if ( btn >= MAX_BUTTONS ) return 0; + if (btn >= JOY_MAX_BUTTONS) + return 0; count = joystick.buttons[btn].timedown; joystick.buttons[btn].timedown = 0; @@ -830,14 +836,15 @@ LRESULT joy_handler_win(HWND hWnd, UINT joymsg, UINT wParam, LPARAM lParam) if (new_time < old_time) old_time = abs(new_time - old_time); interval_time = new_time - old_time; - for (i = 0; i < MAX_BUTTONS; i++) + for (i = 0; i < JOY_MAX_BUTTONS; i++) { // Check status of each button and translate information to the button // structure. button = &joystick.buttons[i]; if (!button->ignore) { - if ( i < (MAX_BUTTONS-4) ) state = (value >> i) & 1; + if (i < (JOY_MAX_BUTTONS - 4)) + state = (value >> i) & 1; else state = 0; if ( button->last_state == state ) { -- 2.39.2