diff options
author | Zack Middleton <zturtleman@gmail.com> | 2012-02-15 18:26:08 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-12 20:18:10 +0000 |
commit | 34d3ae31b90edec62239d7b56b078fa11cc80377 (patch) | |
tree | 3af7a278a172e3e122a9b8af5e70be49faece0f0 /src/sdl | |
parent | cfcced7d3f83bd151f5be42bca4449f70375fc0e (diff) |
Support up to 16 joystick axes, select which to use with j_*_axis cvars.
Diffstat (limited to 'src/sdl')
-rw-r--r-- | src/sdl/sdl_input.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/sdl/sdl_input.c b/src/sdl/sdl_input.c index 2e4fa000..4558f4d3 100644 --- a/src/sdl/sdl_input.c +++ b/src/sdl/sdl_input.c @@ -610,7 +610,7 @@ struct { 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; @@ -857,13 +857,12 @@ static void IN_JoyMove( void ) 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; @@ -874,8 +873,13 @@ static void IN_JoyMove( void ) 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 ) ); |