]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
added joy_axiskeyevents_deadzone cvar which makes the arrow key
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 28 Mar 2011 23:00:30 +0000 (23:00 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 28 Mar 2011 23:00:30 +0000 (23:00 +0000)
emulation far less sensitive

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10980 d7cf8633-e32d-0410-b094-e92efae38249

vid_sdl.c
vid_wgl.c

index 1db4b6549ebf4f74e3b01d33258ad675aac32a6e..38abe8176ba77eb1fc470d6214f7e07c9944c71b 100644 (file)
--- 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
index 9129377a1dae264d4690f947b085b623d419b425..1eb65241fd22b342ad5a4e1cfc291ca8871e018e 100644 (file)
--- 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");
 }