From: havoc Date: Mon, 28 Mar 2011 23:00:30 +0000 (+0000) Subject: added joy_axiskeyevents_deadzone cvar which makes the arrow key X-Git-Tag: xonotic-v0.6.0~163^2~566 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f7e415b336b35214c5906fa24f2d75123c11dec2;p=xonotic%2Fdarkplaces.git added joy_axiskeyevents_deadzone cvar which makes the arrow key emulation far less sensitive git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10980 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/vid_sdl.c b/vid_sdl.c index 1db4b654..38abe817 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -91,6 +91,7 @@ cvar_t joy_sensitivitypitch = {0, "joy_sensitivitypitch", "1", "movement multipl cvar_t joy_sensitivityyaw = {0, "joy_sensitivityyaw", "-1", "movement multiplier"}; cvar_t joy_sensitivityroll = {0, "joy_sensitivityroll", "1", "movement multiplier"}; cvar_t joy_axiskeyevents = {CVAR_SAVE, "joy_axiskeyevents", "0", "generate uparrow/leftarrow etc. keyevents for joystick axes, use if your joystick driver is not generating them"}; +cvar_t joy_axiskeyevents_deadzone = {CVAR_SAVE, "joy_axiskeyevents_deadzone", "0.5", "deadzone value for axes"}; #ifdef __IPHONEOS__ # define SETVIDEOMODE 0 @@ -584,10 +585,10 @@ static qboolean IN_JoystickBlockDoubledKeyEvents(int keycode) SDL_Joystick *joy = vid_joysticks[joy_index.integer]; if (keycode == K_UPARROW || keycode == K_DOWNARROW) - if (IN_JoystickGetAxis(joy, joy_axisforward.integer, 1, 0.01) || joy_axescache[joy_axisforward.integer].move || joy_axescache[joy_axisforward.integer].oldmove) + if (IN_JoystickGetAxis(joy, joy_axisforward.integer, 1, joy_axiskeyevents_deadzone.value) || joy_axescache[joy_axisforward.integer].move || joy_axescache[joy_axisforward.integer].oldmove) return true; if (keycode == K_RIGHTARROW || keycode == K_LEFTARROW) - if (IN_JoystickGetAxis(joy, joy_axisside.integer, 1, 0.01) || joy_axescache[joy_axisside.integer].move || joy_axescache[joy_axisside.integer].oldmove) + if (IN_JoystickGetAxis(joy, joy_axisside.integer, 1, joy_axiskeyevents_deadzone.value) || joy_axescache[joy_axisside.integer].move || joy_axescache[joy_axisside.integer].oldmove) return true; } @@ -826,7 +827,7 @@ void IN_Move( void ) for (j = 0; j < numaxes; j++) { joy_axescache[j].oldmove = joy_axescache[j].move; - joy_axescache[j].move = IN_JoystickGetAxis(joy, j, 1, 0.01); + joy_axescache[j].move = IN_JoystickGetAxis(joy, j, 1, joy_axiskeyevents_deadzone.value); } // run keyevents @@ -1786,6 +1787,7 @@ void VID_Init (void) Cvar_RegisterVariable(&joy_sensitivityyaw); //Cvar_RegisterVariable(&joy_sensitivityroll); Cvar_RegisterVariable(&joy_axiskeyevents); + Cvar_RegisterVariable(&joy_axiskeyevents_deadzone); #ifdef __IPHONEOS__ Cvar_SetValueQuick(&vid_touchscreen, 1); #endif diff --git a/vid_wgl.c b/vid_wgl.c index 9129377a..1eb65241 100644 --- a/vid_wgl.c +++ b/vid_wgl.c @@ -259,6 +259,7 @@ static cvar_t joy_yawsensitivity = {0, "joyyawsensitivity", "-1.0", "how fast th static cvar_t joy_wwhack1 = {0, "joywwhack1", "0.0", "special hack for wingman warrior"}; static cvar_t joy_wwhack2 = {0, "joywwhack2", "0.0", "special hack for wingman warrior"}; static cvar_t joy_axiskeyevents = {CVAR_SAVE, "joy_axiskeyevents", "0", "generate uparrow/leftarrow etc. keyevents for joystick axes, use if your joystick driver is not generating them"}; +static cvar_t joy_axiskeyevents_deadzone = {CVAR_SAVE, "joy_axiskeyevents_deadzone", "0.5", "deadzone value for axes"}; static cvar_t vid_forcerefreshrate = {0, "vid_forcerefreshrate", "0", "try to set the given vid_refreshrate even if Windows doesn't list it as valid video mode"}; @@ -2309,11 +2310,11 @@ static qboolean IN_JoystickBlockDoubledKeyEvents(int keycode) return false; axis = IN_JoystickGetAxisNum(AxisForward); if (keycode == K_UPARROW || keycode == K_DOWNARROW) - if (IN_JoystickGetAxis(axis, 1, 0.01) || joy_axescache[axis].move || joy_axescache[axis].oldmove) + if (IN_JoystickGetAxis(axis, 1, joy_axiskeyevents_deadzone.value) || joy_axescache[axis].move || joy_axescache[axis].oldmove) return true; axis = IN_JoystickGetAxisNum(AxisSide); if (keycode == K_RIGHTARROW || keycode == K_LEFTARROW) - if (IN_JoystickGetAxis(axis, 1, 0.01) || joy_axescache[axis].move || joy_axescache[axis].oldmove) + if (IN_JoystickGetAxis(axis, 1, joy_axiskeyevents_deadzone.value) || joy_axescache[axis].move || joy_axescache[axis].oldmove) return true; } @@ -2513,7 +2514,7 @@ static void IN_JoyMove (void) // cache for keyevents joy_axescache[i].oldmove = joy_axescache[i].move; - joy_axescache[i].move = IN_JoystickGetAxis(i, 1, 0.01); + joy_axescache[i].move = IN_JoystickGetAxis(i, 1, joy_axiskeyevents_deadzone.value); } // run keyevents @@ -2549,6 +2550,7 @@ static void IN_Init(void) Cvar_RegisterVariable (&joy_wwhack1); Cvar_RegisterVariable (&joy_wwhack2); Cvar_RegisterVariable (&joy_axiskeyevents); + Cvar_RegisterVariable (&joy_axiskeyevents_deadzone); Cvar_RegisterVariable (&vid_forcerefreshrate); Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f, "applies current joyadv* cvar settings to the joystick driver"); }