Index: code/sdl/sdl_input.c =================================================================== --- code/sdl/sdl_input.c (revision 1774) +++ code/sdl/sdl_input.c (working copy) @@ -69,6 +69,7 @@ static cvar_t *in_joystickDebug = NULL; static cvar_t *in_joystickThreshold = NULL; static cvar_t *in_joystickNo = NULL; +static cvar_t *in_joystickUseAnalog = NULL; static int vidRestartTime = 0; @@ -563,6 +564,7 @@ { qboolean buttons[16]; // !!! FIXME: these might be too many. unsigned int oldaxes; + int oldaaxes[16]; unsigned int oldhats; } stick_state; @@ -608,6 +610,8 @@ if( in_joystickNo->integer < 0 || in_joystickNo->integer >= total ) Cvar_Set( "in_joystickNo", "0" ); + in_joystickUseAnalog = Cvar_Get( "in_joystickUseAnalog", "0", CVAR_ARCHIVE ); + stick = SDL_JoystickOpen( in_joystickNo->integer ); if (stick == NULL) { @@ -616,11 +620,12 @@ } Com_DPrintf( "Joystick %d opened\n", in_joystickNo->integer ); - Com_DPrintf( "Name: %s\n", SDL_JoystickName(in_joystickNo->integer) ); - Com_DPrintf( "Axes: %d\n", SDL_JoystickNumAxes(stick) ); - Com_DPrintf( "Hats: %d\n", SDL_JoystickNumHats(stick) ); - Com_DPrintf( "Buttons: %d\n", SDL_JoystickNumButtons(stick) ); - Com_DPrintf( "Balls: %d\n", SDL_JoystickNumBalls(stick) ); + Com_DPrintf( "Name: %s\n", SDL_JoystickName(in_joystickNo->integer) ); + Com_DPrintf( "Axes: %d\n", SDL_JoystickNumAxes(stick) ); + Com_DPrintf( "Hats: %d\n", SDL_JoystickNumHats(stick) ); + Com_DPrintf( "Buttons: %d\n", SDL_JoystickNumButtons(stick) ); + Com_DPrintf( "Balls: %d\n", SDL_JoystickNumBalls(stick) ); + Com_DPrintf( "Use Analog: %s\n", in_joystickUseAnalog->integer ? "Yes" : "No" ); SDL_JoystickEventState(SDL_QUERY); } @@ -801,12 +806,28 @@ 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 ) ); - } else if( f > in_joystickThreshold->value ) { - axes |= ( 1 << ( ( i * 2 ) + 1 ) ); + + if (!in_joystickUseAnalog->integer) + { + float f = ( (float) axis ) / 32767.0f; + if( f < -in_joystickThreshold->value ) { + axes |= ( 1 << ( i * 2 ) ); + } else if( f > in_joystickThreshold->value ) { + axes |= ( 1 << ( ( i * 2 ) + 1 ) ); + } } + else + { + float f = ( (float) abs(axis) ) / 32767.0f; + + if( f < in_joystickThreshold->value ) axis = 0; + + if ( axis != stick_state.oldaaxes[i] ) + { + Com_QueueEvent( 0, SE_JOYSTICK_AXIS, i, axis, 0, NULL ); + stick_state.oldaaxes[i] = axis; + } + } } }