[quake3-commits] r2223 - in trunk/code: qcommon sdl

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Feb 15 13:26:08 EST 2012


Author: ztm
Date: 2012-02-15 13:26:08 -0500 (Wed, 15 Feb 2012)
New Revision: 2223

Modified:
   trunk/code/qcommon/qcommon.h
   trunk/code/sdl/sdl_input.c
Log:
Support up to 16 joystick axes, select which to use with j_*_axis cvars.

Modified: trunk/code/qcommon/qcommon.h
===================================================================
--- trunk/code/qcommon/qcommon.h	2012-02-15 18:15:49 UTC (rev 2222)
+++ trunk/code/qcommon/qcommon.h	2012-02-15 18:26:08 UTC (rev 2223)
@@ -1059,15 +1059,7 @@
 ==============================================================
 */
 
-typedef enum {
-	AXIS_SIDE,
-	AXIS_FORWARD,
-	AXIS_UP,
-	AXIS_ROLL,
-	AXIS_YAW,
-	AXIS_PITCH,
-	MAX_JOYSTICK_AXIS
-} joystickAxis_t;
+#define MAX_JOYSTICK_AXIS 16
 
 void	Sys_Init (void);
 

Modified: trunk/code/sdl/sdl_input.c
===================================================================
--- trunk/code/sdl/sdl_input.c	2012-02-15 18:15:49 UTC (rev 2222)
+++ trunk/code/sdl/sdl_input.c	2012-02-15 18:26:08 UTC (rev 2223)
@@ -561,7 +561,7 @@
 {
 	qboolean buttons[16];  // !!! FIXME: these might be too many.
 	unsigned int oldaxes;
-	int oldaaxes[16];
+	int oldaaxes[MAX_JOYSTICK_AXIS];
 	unsigned int oldhats;
 } stick_state;
 
@@ -808,13 +808,12 @@
 	total = SDL_JoystickNumAxes(stick);
 	if (total > 0)
 	{
-		if (total > 16) total = 16;
-		for (i = 0; i < total; i++)
+		if (in_joystickUseAnalog->integer)
 		{
-			Sint16 axis = SDL_JoystickGetAxis(stick, i);
-
-			if (in_joystickUseAnalog->integer)
+			if (total > MAX_JOYSTICK_AXIS) total = MAX_JOYSTICK_AXIS;
+			for (i = 0; i < total; i++)
 			{
+				Sint16 axis = SDL_JoystickGetAxis(stick, i);
 				float f = ( (float) abs(axis) ) / 32767.0f;
 				
 				if( f < in_joystickThreshold->value ) axis = 0;
@@ -825,8 +824,13 @@
 					stick_state.oldaaxes[i] = axis;
 				}
 			}
-			else
+		}
+		else
+		{
+			if (total > 16) total = 16;
+			for (i = 0; i < total; i++)
 			{
+				Sint16 axis = SDL_JoystickGetAxis(stick, i);
 				float f = ( (float) axis ) / 32767.0f;
 				if( f < -in_joystickThreshold->value ) {
 					axes |= ( 1 << ( i * 2 ) );



More information about the quake3-commits mailing list