2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // in_win.c -- windows 95 mouse and joystick code
21 // 02/21/97 JCB Added extended DirectInput code to support external controllers.
28 #define DINPUT_BUFFERSIZE 16
29 #define iDirectInputCreate(a,b,c,d) pDirectInputCreate(a,b,c,d)
31 HRESULT (WINAPI *pDirectInputCreate)(HINSTANCE hinst, DWORD dwVersion,
32 LPDIRECTINPUT * lplpDirectInput, LPUNKNOWN punkOuter);
36 int mouse_oldbuttonstate;
38 int mouse_x, mouse_y, old_mouse_x, old_mouse_y, mx_accum, my_accum;
40 static qboolean restore_spi;
41 static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1};
43 unsigned int uiWheelMessage;
45 qboolean mouseinitialized;
46 static qboolean mouseparmsvalid, mouseactivatetoggle;
47 static qboolean mouseshowtoggle = 1;
48 static qboolean dinput_acquired;
50 static unsigned int mstate_di;
52 // joystick defines and variables
53 // where should defines be moved?
54 #define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick
55 #define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, trackball
56 #define JOY_MAX_AXES 6 // X, Y, Z, R, U, V
66 AxisNada = 0, AxisForward, AxisLook, AxisSide, AxisTurn
69 DWORD dwAxisFlags[JOY_MAX_AXES] =
71 JOY_RETURNX, JOY_RETURNY, JOY_RETURNZ, JOY_RETURNR, JOY_RETURNU, JOY_RETURNV
74 DWORD dwAxisMap[JOY_MAX_AXES];
75 DWORD dwControlMap[JOY_MAX_AXES];
76 PDWORD pdwRawValue[JOY_MAX_AXES];
78 // none of these cvars are saved over a session
79 // this means that advanced controller configuration needs to be executed
80 // each time. this avoids any problems with getting back to a default usage
81 // or when changing from one controller to another. this way at least something
83 cvar_t in_joystick = {CVAR_SAVE, "joystick","0"};
84 cvar_t joy_name = {0, "joyname", "joystick"};
85 cvar_t joy_advanced = {0, "joyadvanced", "0"};
86 cvar_t joy_advaxisx = {0, "joyadvaxisx", "0"};
87 cvar_t joy_advaxisy = {0, "joyadvaxisy", "0"};
88 cvar_t joy_advaxisz = {0, "joyadvaxisz", "0"};
89 cvar_t joy_advaxisr = {0, "joyadvaxisr", "0"};
90 cvar_t joy_advaxisu = {0, "joyadvaxisu", "0"};
91 cvar_t joy_advaxisv = {0, "joyadvaxisv", "0"};
92 cvar_t joy_forwardthreshold = {0, "joyforwardthreshold", "0.15"};
93 cvar_t joy_sidethreshold = {0, "joysidethreshold", "0.15"};
94 cvar_t joy_pitchthreshold = {0, "joypitchthreshold", "0.15"};
95 cvar_t joy_yawthreshold = {0, "joyyawthreshold", "0.15"};
96 cvar_t joy_forwardsensitivity = {0, "joyforwardsensitivity", "-1.0"};
97 cvar_t joy_sidesensitivity = {0, "joysidesensitivity", "-1.0"};
98 cvar_t joy_pitchsensitivity = {0, "joypitchsensitivity", "1.0"};
99 cvar_t joy_yawsensitivity = {0, "joyyawsensitivity", "-1.0"};
100 cvar_t joy_wwhack1 = {0, "joywwhack1", "0.0"};
101 cvar_t joy_wwhack2 = {0, "joywwhack2", "0.0"};
103 qboolean joy_avail, joy_advancedinit, joy_haspov;
104 DWORD joy_oldbuttonstate, joy_oldpovstate;
108 DWORD joy_numbuttons;
110 static LPDIRECTINPUT g_pdi;
111 static LPDIRECTINPUTDEVICE g_pMouse;
115 static HINSTANCE hInstDI;
117 static qboolean dinput;
119 typedef struct MYDATA {
120 LONG lX; // X axis goes here
121 LONG lY; // Y axis goes here
122 LONG lZ; // Z axis goes here
123 BYTE bButtonA; // One button goes here
124 BYTE bButtonB; // Another button goes here
125 BYTE bButtonC; // Another button goes here
126 BYTE bButtonD; // Another button goes here
129 static DIOBJECTDATAFORMAT rgodf[] = {
130 { &GUID_XAxis, FIELD_OFFSET(MYDATA, lX), DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,},
131 { &GUID_YAxis, FIELD_OFFSET(MYDATA, lY), DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,},
132 { &GUID_ZAxis, FIELD_OFFSET(MYDATA, lZ), 0x80000000 | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,},
133 { 0, FIELD_OFFSET(MYDATA, bButtonA), DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
134 { 0, FIELD_OFFSET(MYDATA, bButtonB), DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
135 { 0, FIELD_OFFSET(MYDATA, bButtonC), 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
136 { 0, FIELD_OFFSET(MYDATA, bButtonD), 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
139 #define NUM_OBJECTS (sizeof(rgodf) / sizeof(rgodf[0]))
141 static DIDATAFORMAT df = {
142 sizeof(DIDATAFORMAT), // this structure
143 sizeof(DIOBJECTDATAFORMAT), // size of object data format
144 DIDF_RELAXIS, // absolute axis coordinates
145 sizeof(MYDATA), // device data size
146 NUM_OBJECTS, // number of objects
147 rgodf, // and here they are
150 // forward-referenced functions
151 void IN_StartupJoystick (void);
152 void Joy_AdvancedUpdate_f (void);
153 void IN_JoyMove (usercmd_t *cmd);
161 void IN_UpdateClipCursor (void)
164 if (mouseinitialized && mouseactive && !dinput)
166 ClipCursor (&window_rect);
176 void IN_ShowMouse (void)
178 if (!mouseshowtoggle)
191 void IN_HideMouse (void)
206 void IN_ActivateMouse (void)
209 mouseactivatetoggle = true;
211 if (mouseinitialized)
217 if (!dinput_acquired)
219 IDirectInputDevice_Acquire(g_pMouse);
220 dinput_acquired = true;
231 restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);
233 SetCursorPos (window_center_x, window_center_y);
234 SetCapture (mainwindow);
235 ClipCursor (&window_rect);
249 void IN_DeactivateMouse (void)
252 mouseactivatetoggle = false;
254 if (mouseinitialized)
262 IDirectInputDevice_Unacquire(g_pMouse);
263 dinput_acquired = false;
270 SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0);
286 qboolean IN_InitDInput (void)
289 DIPROPDWORD dipdw = {
291 sizeof(DIPROPDWORD), // diph.dwSize
292 sizeof(DIPROPHEADER), // diph.dwHeaderSize
294 DIPH_DEVICE, // diph.dwHow
296 DINPUT_BUFFERSIZE, // dwData
301 hInstDI = LoadLibrary("dinput.dll");
305 Con_SafePrintf ("Couldn't load dinput.dll\n");
310 if (!pDirectInputCreate)
312 pDirectInputCreate = (void *)GetProcAddress(hInstDI,"DirectInputCreateA");
314 if (!pDirectInputCreate)
316 Con_SafePrintf ("Couldn't get DI proc addr\n");
321 // register with DirectInput and get an IDirectInput to play with.
322 hr = iDirectInputCreate(global_hInstance, DIRECTINPUT_VERSION, &g_pdi, NULL);
329 // obtain an interface to the system mouse device.
330 hr = IDirectInput_CreateDevice(g_pdi, &GUID_SysMouse, &g_pMouse, NULL);
334 Con_SafePrintf ("Couldn't open DI mouse device\n");
338 // set the data format to "mouse format".
339 hr = IDirectInputDevice_SetDataFormat(g_pMouse, &df);
343 Con_SafePrintf ("Couldn't set DI mouse format\n");
347 // set the cooperativity level.
348 hr = IDirectInputDevice_SetCooperativeLevel(g_pMouse, mainwindow,
349 DISCL_EXCLUSIVE | DISCL_FOREGROUND);
353 Con_SafePrintf ("Couldn't set DI coop level\n");
358 // set the buffer size to DINPUT_BUFFERSIZE elements.
359 // the buffer size is a DWORD property associated with the device
360 hr = IDirectInputDevice_SetProperty(g_pMouse, DIPROP_BUFFERSIZE, &dipdw.diph);
364 Con_SafePrintf ("Couldn't set DI buffersize\n");
377 void IN_StartupMouse (void)
379 if ( COM_CheckParm ("-nomouse") )
382 mouseinitialized = true;
384 if (COM_CheckParm ("-dinput"))
386 dinput = IN_InitDInput ();
390 Con_SafePrintf ("DirectInput initialized\n");
394 Con_SafePrintf ("DirectInput not initialized\n");
400 mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0);
404 if ( COM_CheckParm ("-noforcemspd") )
405 newmouseparms[2] = originalmouseparms[2];
407 if ( COM_CheckParm ("-noforcemaccel") )
409 newmouseparms[0] = originalmouseparms[0];
410 newmouseparms[1] = originalmouseparms[1];
413 if ( COM_CheckParm ("-noforcemparms") )
415 newmouseparms[0] = originalmouseparms[0];
416 newmouseparms[1] = originalmouseparms[1];
417 newmouseparms[2] = originalmouseparms[2];
424 // if a fullscreen video mode was set before the mouse was initialized,
425 // set the mouse state appropriately
426 if (mouseactivatetoggle)
438 // joystick variables
439 Cvar_RegisterVariable (&in_joystick);
440 Cvar_RegisterVariable (&joy_name);
441 Cvar_RegisterVariable (&joy_advanced);
442 Cvar_RegisterVariable (&joy_advaxisx);
443 Cvar_RegisterVariable (&joy_advaxisy);
444 Cvar_RegisterVariable (&joy_advaxisz);
445 Cvar_RegisterVariable (&joy_advaxisr);
446 Cvar_RegisterVariable (&joy_advaxisu);
447 Cvar_RegisterVariable (&joy_advaxisv);
448 Cvar_RegisterVariable (&joy_forwardthreshold);
449 Cvar_RegisterVariable (&joy_sidethreshold);
450 Cvar_RegisterVariable (&joy_pitchthreshold);
451 Cvar_RegisterVariable (&joy_yawthreshold);
452 Cvar_RegisterVariable (&joy_forwardsensitivity);
453 Cvar_RegisterVariable (&joy_sidesensitivity);
454 Cvar_RegisterVariable (&joy_pitchsensitivity);
455 Cvar_RegisterVariable (&joy_yawsensitivity);
456 Cvar_RegisterVariable (&joy_wwhack1);
457 Cvar_RegisterVariable (&joy_wwhack2);
459 Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f);
461 uiWheelMessage = RegisterWindowMessage ( "MSWHEEL_ROLLMSG" );
464 IN_StartupJoystick ();
472 void IN_Shutdown (void)
474 IN_DeactivateMouse ();
479 IDirectInputDevice_Release(g_pMouse);
485 IDirectInput_Release(g_pdi);
496 void IN_MouseEvent (int mstate)
500 if (mouseactive && !dinput)
502 // perform button actions
503 for (i=0 ; i<mouse_buttons ; i++)
505 if ( (mstate & (1<<i)) &&
506 !(mouse_oldbuttonstate & (1<<i)) )
508 Key_Event (K_MOUSE1 + i, true);
511 if ( !(mstate & (1<<i)) &&
512 (mouse_oldbuttonstate & (1<<i)) )
514 Key_Event (K_MOUSE1 + i, false);
518 mouse_oldbuttonstate = mstate;
528 void IN_MouseMove (usercmd_t *cmd)
531 DIDEVICEOBJECTDATA od;
537 GetCursorPos (¤t_pos);
538 ui_mouseupdate(current_pos.x - window_x, current_pos.y - window_y);
551 hr = IDirectInputDevice_GetDeviceData(g_pMouse,
552 sizeof(DIDEVICEOBJECTDATA), &od, &dwElements, 0);
554 if ((hr == DIERR_INPUTLOST) || (hr == DIERR_NOTACQUIRED))
556 dinput_acquired = true;
557 IDirectInputDevice_Acquire(g_pMouse);
561 /* Unable to read data or no data available */
562 if (FAILED(hr) || dwElements == 0)
565 /* Look at the element to see what happened */
578 if (od.dwData & 0x80)
585 if (od.dwData & 0x80)
588 mstate_di &= ~(1<<1);
592 if (od.dwData & 0x80)
595 mstate_di &= ~(1<<2);
600 // perform button actions
601 for (i=0 ; i<mouse_buttons ; i++)
603 if ( (mstate_di & (1<<i)) &&
604 !(mouse_oldbuttonstate & (1<<i)) )
606 Key_Event (K_MOUSE1 + i, true);
609 if ( !(mstate_di & (1<<i)) &&
610 (mouse_oldbuttonstate & (1<<i)) )
612 Key_Event (K_MOUSE1 + i, false);
616 mouse_oldbuttonstate = mstate_di;
620 GetCursorPos (¤t_pos);
621 mx = current_pos.x - window_center_x + mx_accum;
622 my = current_pos.y - window_center_y + my_accum;
627 IN_Mouse(cmd, mx, my);
629 // if the mouse has moved, force it to the center, so there's room to move
630 if (!dinput && (mx || my))
631 SetCursorPos (window_center_x, window_center_y);
640 void IN_Move (usercmd_t *cmd)
642 if (ActiveApp && !Minimized)
648 cl.viewangles[PITCH] = bound (in_pitch_min.value, cl.viewangles[PITCH], in_pitch_max.value);
657 void IN_Accumulate (void)
663 GetCursorPos (¤t_pos);
665 mx_accum += current_pos.x - window_center_x;
666 my_accum += current_pos.y - window_center_y;
668 // force the mouse to the center, so there's room to move
669 SetCursorPos (window_center_x, window_center_y);
680 void IN_ClearStates (void)
686 mouse_oldbuttonstate = 0;
696 void IN_StartupJoystick (void)
703 // assume no joystick
706 // abort startup if user requests no joystick
707 if ( COM_CheckParm ("-nojoy") )
710 // verify joystick driver is present
711 if ((numdevs = joyGetNumDevs ()) == 0)
713 Con_Printf ("\njoystick not found -- driver not present\n\n");
717 // cycle through the joystick ids for the first valid one
718 for (joy_id=0 ; joy_id<numdevs ; joy_id++)
720 memset (&ji, 0, sizeof(ji));
721 ji.dwSize = sizeof(ji);
722 ji.dwFlags = JOY_RETURNCENTERED;
724 if ((mmr = joyGetPosEx (joy_id, &ji)) == JOYERR_NOERROR)
728 // abort startup if we didn't find a valid joystick
729 if (mmr != JOYERR_NOERROR)
731 Con_Printf ("\njoystick not found -- no valid joysticks (%x)\n\n", mmr);
735 // get the capabilities of the selected joystick
736 // abort startup if command fails
737 memset (&jc, 0, sizeof(jc));
738 if ((mmr = joyGetDevCaps (joy_id, &jc, sizeof(jc))) != JOYERR_NOERROR)
740 Con_Printf ("\njoystick not found -- invalid joystick capabilities (%x)\n\n", mmr);
744 // save the joystick's number of buttons and POV status
745 joy_numbuttons = jc.wNumButtons;
746 joy_haspov = jc.wCaps & JOYCAPS_HASPOV;
748 // old button and POV states default to no buttons pressed
749 joy_oldbuttonstate = joy_oldpovstate = 0;
751 // mark the joystick as available and advanced initialization not completed
752 // this is needed as cvars are not available during initialization
755 joy_advancedinit = false;
757 Con_Printf ("\njoystick detected\n\n");
766 PDWORD RawValuePointer (int axis)
783 return NULL; // LordHavoc: hush compiler warning
792 void Joy_AdvancedUpdate_f (void)
795 // called once by IN_ReadJoystick and by user whenever an update is needed
796 // cvars are now available
800 // initialize all the maps
801 for (i = 0; i < JOY_MAX_AXES; i++)
803 dwAxisMap[i] = AxisNada;
804 dwControlMap[i] = JOY_ABSOLUTE_AXIS;
805 pdwRawValue[i] = RawValuePointer(i);
808 if( joy_advanced.integer == 0)
810 // default joystick initialization
811 // 2 axes only with joystick control
812 dwAxisMap[JOY_AXIS_X] = AxisTurn;
813 // dwControlMap[JOY_AXIS_X] = JOY_ABSOLUTE_AXIS;
814 dwAxisMap[JOY_AXIS_Y] = AxisForward;
815 // dwControlMap[JOY_AXIS_Y] = JOY_ABSOLUTE_AXIS;
819 if (strcmp (joy_name.string, "joystick") != 0)
821 // notify user of advanced controller
822 Con_Printf ("\n%s configured\n\n", joy_name.string);
825 // advanced initialization here
826 // data supplied by user via joy_axisn cvars
827 dwTemp = (DWORD) joy_advaxisx.value;
828 dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f;
829 dwControlMap[JOY_AXIS_X] = dwTemp & JOY_RELATIVE_AXIS;
830 dwTemp = (DWORD) joy_advaxisy.value;
831 dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f;
832 dwControlMap[JOY_AXIS_Y] = dwTemp & JOY_RELATIVE_AXIS;
833 dwTemp = (DWORD) joy_advaxisz.value;
834 dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f;
835 dwControlMap[JOY_AXIS_Z] = dwTemp & JOY_RELATIVE_AXIS;
836 dwTemp = (DWORD) joy_advaxisr.value;
837 dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f;
838 dwControlMap[JOY_AXIS_R] = dwTemp & JOY_RELATIVE_AXIS;
839 dwTemp = (DWORD) joy_advaxisu.value;
840 dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f;
841 dwControlMap[JOY_AXIS_U] = dwTemp & JOY_RELATIVE_AXIS;
842 dwTemp = (DWORD) joy_advaxisv.value;
843 dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f;
844 dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS;
847 // compute the axes to collect from DirectInput
848 joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV;
849 for (i = 0; i < JOY_MAX_AXES; i++)
851 if (dwAxisMap[i] != AxisNada)
853 joy_flags |= dwAxisFlags[i];
864 void IN_Commands (void)
867 DWORD buttonstate, povstate;
875 // loop through the joystick buttons
876 // key a joystick event or auxillary event for higher number buttons for each state change
877 buttonstate = ji.dwButtons;
878 for (i=0 ; i < (int) joy_numbuttons ; i++)
880 if ( (buttonstate & (1<<i)) && !(joy_oldbuttonstate & (1<<i)) )
882 key_index = (i < 4) ? K_JOY1 : K_AUX1;
883 Key_Event (key_index + i, true);
886 if ( !(buttonstate & (1<<i)) && (joy_oldbuttonstate & (1<<i)) )
888 key_index = (i < 4) ? K_JOY1 : K_AUX1;
889 Key_Event (key_index + i, false);
892 joy_oldbuttonstate = buttonstate;
896 // convert POV information into 4 bits of state information
897 // this avoids any potential problems related to moving from one
898 // direction to another without going through the center position
900 if(ji.dwPOV != JOY_POVCENTERED)
902 if (ji.dwPOV == JOY_POVFORWARD)
904 if (ji.dwPOV == JOY_POVRIGHT)
906 if (ji.dwPOV == JOY_POVBACKWARD)
908 if (ji.dwPOV == JOY_POVLEFT)
911 // determine which bits have changed and key an auxillary event for each change
912 for (i=0 ; i < 4 ; i++)
914 if ( (povstate & (1<<i)) && !(joy_oldpovstate & (1<<i)) )
916 Key_Event (K_AUX29 + i, true);
919 if ( !(povstate & (1<<i)) && (joy_oldpovstate & (1<<i)) )
921 Key_Event (K_AUX29 + i, false);
924 joy_oldpovstate = povstate;
934 qboolean IN_ReadJoystick (void)
937 memset (&ji, 0, sizeof(ji));
938 ji.dwSize = sizeof(ji);
939 ji.dwFlags = joy_flags;
941 if (joyGetPosEx (joy_id, &ji) == JOYERR_NOERROR)
943 // this is a hack -- there is a bug in the Logitech WingMan Warrior DirectInput Driver
944 // rather than having 32768 be the zero point, they have the zero point at 32668
945 // go figure -- anyway, now we get the full resolution out of the device
946 if (joy_wwhack1.integer != 0.0)
954 // read error occurred
955 // turning off the joystick seems too harsh for 1 read error,
956 // but what should be done?
967 void IN_JoyMove (usercmd_t *cmd)
970 float fAxisValue, fTemp;
971 int i, mouselook = (in_mlook.state & 1) || freelook.integer;
973 // complete initialization if first time in
974 // this is needed as cvars are not available at initialization time
975 if( joy_advancedinit != true )
977 Joy_AdvancedUpdate_f();
978 joy_advancedinit = true;
981 // verify joystick is available and that the user wants to use it
982 if (!joy_avail || !in_joystick.integer)
987 // collect the joystick data, if possible
988 if (IN_ReadJoystick () != true)
993 if (in_speed.state & 1)
994 speed = cl_movespeedkey.value;
997 // LordHavoc: viewzoom affects sensitivity for sniping
998 aspeed = speed * host_realframetime * cl.viewzoom;
1000 // loop through the axes
1001 for (i = 0; i < JOY_MAX_AXES; i++)
1003 // get the floating point zero-centered, potentially-inverted data for the current axis
1004 fAxisValue = (float) *pdwRawValue[i];
1005 // move centerpoint to zero
1006 fAxisValue -= 32768.0;
1008 if (joy_wwhack2.integer != 0.0)
1010 if (dwAxisMap[i] == AxisTurn)
1012 // this is a special formula for the Logitech WingMan Warrior
1013 // y=ax^b; where a = 300 and b = 1.3
1014 // also x values are in increments of 800 (so this is factored out)
1015 // then bounds check result to level out excessively high spin rates
1016 fTemp = 300.0 * pow(abs(fAxisValue) / 800.0, 1.3);
1017 if (fTemp > 14000.0)
1019 // restore direction information
1020 fAxisValue = (fAxisValue > 0.0) ? fTemp : -fTemp;
1024 // convert range from -32768..32767 to -1..1
1025 fAxisValue /= 32768.0;
1027 switch (dwAxisMap[i])
1030 if ((joy_advanced.integer == 0) && mouselook)
1032 // user wants forward control to become look control
1033 if (fabs(fAxisValue) > joy_pitchthreshold.value)
1035 // if mouse invert is on, invert the joystick pitch value
1036 // only absolute control support here (joy_advanced is false)
1037 if (m_pitch.value < 0.0)
1039 cl.viewangles[PITCH] -= (fAxisValue * joy_pitchsensitivity.value) * aspeed * cl_pitchspeed.value;
1043 cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity.value) * aspeed * cl_pitchspeed.value;
1049 // no pitch movement
1050 // disable pitch return-to-center unless requested by user
1051 // *** this code can be removed when the lookspring bug is fixed
1052 // *** the bug always has the lookspring feature on
1053 if(lookspring.value == 0.0)
1059 // user wants forward control to be forward control
1060 if (fabs(fAxisValue) > joy_forwardthreshold.value)
1062 cmd->forwardmove += (fAxisValue * joy_forwardsensitivity.value) * speed * cl_forwardspeed.value;
1068 if (fabs(fAxisValue) > joy_sidethreshold.value)
1070 cmd->sidemove += (fAxisValue * joy_sidesensitivity.value) * speed * cl_sidespeed.value;
1075 if ((in_strafe.state & 1) || (lookstrafe.integer && mouselook))
1077 // user wants turn control to become side control
1078 if (fabs(fAxisValue) > joy_sidethreshold.value)
1080 cmd->sidemove -= (fAxisValue * joy_sidesensitivity.value) * speed * cl_sidespeed.value;
1085 // user wants turn control to be turn control
1086 if (fabs(fAxisValue) > joy_yawthreshold.value)
1088 if(dwControlMap[i] == JOY_ABSOLUTE_AXIS)
1090 cl.viewangles[YAW] += (fAxisValue * joy_yawsensitivity.value) * aspeed * cl_yawspeed.value;
1094 cl.viewangles[YAW] += (fAxisValue * joy_yawsensitivity.value) * speed * 180.0;
1104 if (fabs(fAxisValue) > joy_pitchthreshold.value)
1106 // pitch movement detected and pitch movement desired by user
1107 if(dwControlMap[i] == JOY_ABSOLUTE_AXIS)
1109 cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity.value) * aspeed * cl_pitchspeed.value;
1113 cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity.value) * speed * 180.0;
1119 // no pitch movement
1120 // disable pitch return-to-center unless requested by user
1121 // *** this code can be removed when the lookspring bug is fixed
1122 // *** the bug always has the lookspring feature on
1123 if(lookspring.integer == 0)