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.
25 //#include "dosisms.h"
29 #define DINPUT_BUFFERSIZE 16
30 #define iDirectInputCreate(a,b,c,d) pDirectInputCreate(a,b,c,d)
32 HRESULT (WINAPI *pDirectInputCreate)(HINSTANCE hinst, DWORD dwVersion,
33 LPDIRECTINPUT * lplpDirectInput, LPUNKNOWN punkOuter);
37 int mouse_oldbuttonstate;
39 int mouse_x, mouse_y, old_mouse_x, old_mouse_y, mx_accum, my_accum;
41 static qboolean restore_spi;
42 static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1};
44 unsigned int uiWheelMessage;
46 qboolean mouseinitialized;
47 static qboolean mouseparmsvalid, mouseactivatetoggle;
48 static qboolean mouseshowtoggle = 1;
49 static qboolean dinput_acquired;
51 static unsigned int mstate_di;
53 // joystick defines and variables
54 // where should defines be moved?
55 #define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick
56 #define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, trackball
57 #define JOY_MAX_AXES 6 // X, Y, Z, R, U, V
67 AxisNada = 0, AxisForward, AxisLook, AxisSide, AxisTurn
70 DWORD dwAxisFlags[JOY_MAX_AXES] =
72 JOY_RETURNX, JOY_RETURNY, JOY_RETURNZ, JOY_RETURNR, JOY_RETURNU, JOY_RETURNV
75 DWORD dwAxisMap[JOY_MAX_AXES];
76 DWORD dwControlMap[JOY_MAX_AXES];
77 PDWORD pdwRawValue[JOY_MAX_AXES];
79 // none of these cvars are saved over a session
80 // this means that advanced controller configuration needs to be executed
81 // each time. this avoids any problems with getting back to a default usage
82 // or when changing from one controller to another. this way at least something
84 cvar_t in_joystick = {CVAR_SAVE, "joystick","0"};
85 cvar_t joy_name = {0, "joyname", "joystick"};
86 cvar_t joy_advanced = {0, "joyadvanced", "0"};
87 cvar_t joy_advaxisx = {0, "joyadvaxisx", "0"};
88 cvar_t joy_advaxisy = {0, "joyadvaxisy", "0"};
89 cvar_t joy_advaxisz = {0, "joyadvaxisz", "0"};
90 cvar_t joy_advaxisr = {0, "joyadvaxisr", "0"};
91 cvar_t joy_advaxisu = {0, "joyadvaxisu", "0"};
92 cvar_t joy_advaxisv = {0, "joyadvaxisv", "0"};
93 cvar_t joy_forwardthreshold = {0, "joyforwardthreshold", "0.15"};
94 cvar_t joy_sidethreshold = {0, "joysidethreshold", "0.15"};
95 cvar_t joy_pitchthreshold = {0, "joypitchthreshold", "0.15"};
96 cvar_t joy_yawthreshold = {0, "joyyawthreshold", "0.15"};
97 cvar_t joy_forwardsensitivity = {0, "joyforwardsensitivity", "-1.0"};
98 cvar_t joy_sidesensitivity = {0, "joysidesensitivity", "-1.0"};
99 cvar_t joy_pitchsensitivity = {0, "joypitchsensitivity", "1.0"};
100 cvar_t joy_yawsensitivity = {0, "joyyawsensitivity", "-1.0"};
101 cvar_t joy_wwhack1 = {0, "joywwhack1", "0.0"};
102 cvar_t joy_wwhack2 = {0, "joywwhack2", "0.0"};
104 qboolean joy_avail, joy_advancedinit, joy_haspov;
105 DWORD joy_oldbuttonstate, joy_oldpovstate;
109 DWORD joy_numbuttons;
111 static LPDIRECTINPUT g_pdi;
112 static LPDIRECTINPUTDEVICE g_pMouse;
116 static HINSTANCE hInstDI;
118 static qboolean dinput;
120 typedef struct MYDATA {
121 LONG lX; // X axis goes here
122 LONG lY; // Y axis goes here
123 LONG lZ; // Z axis goes here
124 BYTE bButtonA; // One button goes here
125 BYTE bButtonB; // Another button goes here
126 BYTE bButtonC; // Another button goes here
127 BYTE bButtonD; // Another button goes here
130 static DIOBJECTDATAFORMAT rgodf[] = {
131 { &GUID_XAxis, FIELD_OFFSET(MYDATA, lX), DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,},
132 { &GUID_YAxis, FIELD_OFFSET(MYDATA, lY), DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,},
133 { &GUID_ZAxis, FIELD_OFFSET(MYDATA, lZ), 0x80000000 | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0,},
134 { 0, FIELD_OFFSET(MYDATA, bButtonA), DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
135 { 0, FIELD_OFFSET(MYDATA, bButtonB), DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
136 { 0, FIELD_OFFSET(MYDATA, bButtonC), 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
137 { 0, FIELD_OFFSET(MYDATA, bButtonD), 0x80000000 | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0,},
140 #define NUM_OBJECTS (sizeof(rgodf) / sizeof(rgodf[0]))
142 static DIDATAFORMAT df = {
143 sizeof(DIDATAFORMAT), // this structure
144 sizeof(DIOBJECTDATAFORMAT), // size of object data format
145 DIDF_RELAXIS, // absolute axis coordinates
146 sizeof(MYDATA), // device data size
147 NUM_OBJECTS, // number of objects
148 rgodf, // and here they are
151 // forward-referenced functions
152 void IN_StartupJoystick (void);
153 void Joy_AdvancedUpdate_f (void);
154 void IN_JoyMove (usercmd_t *cmd);
162 void IN_UpdateClipCursor (void)
165 if (mouseinitialized && mouseactive && !dinput)
167 ClipCursor (&window_rect);
177 void IN_ShowMouse (void)
179 if (!mouseshowtoggle)
192 void IN_HideMouse (void)
207 void IN_ActivateMouse (void)
210 mouseactivatetoggle = true;
212 if (mouseinitialized)
218 if (!dinput_acquired)
220 IDirectInputDevice_Acquire(g_pMouse);
221 dinput_acquired = true;
232 restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);
234 SetCursorPos (window_center_x, window_center_y);
235 SetCapture (mainwindow);
236 ClipCursor (&window_rect);
250 void IN_DeactivateMouse (void)
253 mouseactivatetoggle = false;
255 if (mouseinitialized)
263 IDirectInputDevice_Unacquire(g_pMouse);
264 dinput_acquired = false;
271 SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0);
287 qboolean IN_InitDInput (void)
290 DIPROPDWORD dipdw = {
292 sizeof(DIPROPDWORD), // diph.dwSize
293 sizeof(DIPROPHEADER), // diph.dwHeaderSize
295 DIPH_DEVICE, // diph.dwHow
297 DINPUT_BUFFERSIZE, // dwData
302 hInstDI = LoadLibrary("dinput.dll");
306 Con_SafePrintf ("Couldn't load dinput.dll\n");
311 if (!pDirectInputCreate)
313 pDirectInputCreate = (void *)GetProcAddress(hInstDI,"DirectInputCreateA");
315 if (!pDirectInputCreate)
317 Con_SafePrintf ("Couldn't get DI proc addr\n");
322 // register with DirectInput and get an IDirectInput to play with.
323 hr = iDirectInputCreate(global_hInstance, DIRECTINPUT_VERSION, &g_pdi, NULL);
330 // obtain an interface to the system mouse device.
331 hr = IDirectInput_CreateDevice(g_pdi, &GUID_SysMouse, &g_pMouse, NULL);
335 Con_SafePrintf ("Couldn't open DI mouse device\n");
339 // set the data format to "mouse format".
340 hr = IDirectInputDevice_SetDataFormat(g_pMouse, &df);
344 Con_SafePrintf ("Couldn't set DI mouse format\n");
348 // set the cooperativity level.
349 hr = IDirectInputDevice_SetCooperativeLevel(g_pMouse, mainwindow,
350 DISCL_EXCLUSIVE | DISCL_FOREGROUND);
354 Con_SafePrintf ("Couldn't set DI coop level\n");
359 // set the buffer size to DINPUT_BUFFERSIZE elements.
360 // the buffer size is a DWORD property associated with the device
361 hr = IDirectInputDevice_SetProperty(g_pMouse, DIPROP_BUFFERSIZE, &dipdw.diph);
365 Con_SafePrintf ("Couldn't set DI buffersize\n");
378 void IN_StartupMouse (void)
380 if ( COM_CheckParm ("-nomouse") )
383 mouseinitialized = true;
385 if (COM_CheckParm ("-dinput"))
387 dinput = IN_InitDInput ();
391 Con_SafePrintf ("DirectInput initialized\n");
395 Con_SafePrintf ("DirectInput not initialized\n");
401 mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0);
405 if ( COM_CheckParm ("-noforcemspd") )
406 newmouseparms[2] = originalmouseparms[2];
408 if ( COM_CheckParm ("-noforcemaccel") )
410 newmouseparms[0] = originalmouseparms[0];
411 newmouseparms[1] = originalmouseparms[1];
414 if ( COM_CheckParm ("-noforcemparms") )
416 newmouseparms[0] = originalmouseparms[0];
417 newmouseparms[1] = originalmouseparms[1];
418 newmouseparms[2] = originalmouseparms[2];
425 // if a fullscreen video mode was set before the mouse was initialized,
426 // set the mouse state appropriately
427 if (mouseactivatetoggle)
439 // joystick variables
440 Cvar_RegisterVariable (&in_joystick);
441 Cvar_RegisterVariable (&joy_name);
442 Cvar_RegisterVariable (&joy_advanced);
443 Cvar_RegisterVariable (&joy_advaxisx);
444 Cvar_RegisterVariable (&joy_advaxisy);
445 Cvar_RegisterVariable (&joy_advaxisz);
446 Cvar_RegisterVariable (&joy_advaxisr);
447 Cvar_RegisterVariable (&joy_advaxisu);
448 Cvar_RegisterVariable (&joy_advaxisv);
449 Cvar_RegisterVariable (&joy_forwardthreshold);
450 Cvar_RegisterVariable (&joy_sidethreshold);
451 Cvar_RegisterVariable (&joy_pitchthreshold);
452 Cvar_RegisterVariable (&joy_yawthreshold);
453 Cvar_RegisterVariable (&joy_forwardsensitivity);
454 Cvar_RegisterVariable (&joy_sidesensitivity);
455 Cvar_RegisterVariable (&joy_pitchsensitivity);
456 Cvar_RegisterVariable (&joy_yawsensitivity);
457 Cvar_RegisterVariable (&joy_wwhack1);
458 Cvar_RegisterVariable (&joy_wwhack2);
460 Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f);
462 uiWheelMessage = RegisterWindowMessage ( "MSWHEEL_ROLLMSG" );
465 IN_StartupJoystick ();
473 void IN_Shutdown (void)
475 // usingmouse = false;
476 IN_DeactivateMouse ();
481 IDirectInputDevice_Release(g_pMouse);
487 IDirectInput_Release(g_pdi);
498 void IN_MouseEvent (int mstate)
502 if (mouseactive && !dinput)
504 // perform button actions
505 for (i=0 ; i<mouse_buttons ; i++)
507 if ( (mstate & (1<<i)) &&
508 !(mouse_oldbuttonstate & (1<<i)) )
510 Key_Event (K_MOUSE1 + i, true);
513 if ( !(mstate & (1<<i)) &&
514 (mouse_oldbuttonstate & (1<<i)) )
516 Key_Event (K_MOUSE1 + i, false);
520 mouse_oldbuttonstate = mstate;
530 void IN_MouseMove (usercmd_t *cmd)
532 int i, mx, my, mouselook = (in_mlook.state & 1) || freelook.integer;
533 DIDEVICEOBJECTDATA od;
539 GetCursorPos (¤t_pos);
540 ui_mouseupdate(current_pos.x - window_x, current_pos.y - window_y);
553 hr = IDirectInputDevice_GetDeviceData(g_pMouse,
554 sizeof(DIDEVICEOBJECTDATA), &od, &dwElements, 0);
556 if ((hr == DIERR_INPUTLOST) || (hr == DIERR_NOTACQUIRED))
558 dinput_acquired = true;
559 IDirectInputDevice_Acquire(g_pMouse);
563 /* Unable to read data or no data available */
564 if (FAILED(hr) || dwElements == 0)
569 /* Look at the element to see what happened */
582 if (od.dwData & 0x80)
589 if (od.dwData & 0x80)
592 mstate_di &= ~(1<<1);
596 if (od.dwData & 0x80)
599 mstate_di &= ~(1<<2);
604 // perform button actions
605 for (i=0 ; i<mouse_buttons ; i++)
607 if ( (mstate_di & (1<<i)) &&
608 !(mouse_oldbuttonstate & (1<<i)) )
610 Key_Event (K_MOUSE1 + i, true);
613 if ( !(mstate_di & (1<<i)) &&
614 (mouse_oldbuttonstate & (1<<i)) )
616 Key_Event (K_MOUSE1 + i, false);
620 mouse_oldbuttonstate = mstate_di;
624 GetCursorPos (¤t_pos);
625 mx = current_pos.x - window_center_x + mx_accum;
626 my = current_pos.y - window_center_y + my_accum;
631 IN_Mouse(cmd, mx, my);
633 // if the mouse has moved, force it to the center, so there's room to move
634 if (!dinput && (mx || my))
635 SetCursorPos (window_center_x, window_center_y);
644 void IN_Move (usercmd_t *cmd)
646 if (ActiveApp && !Minimized)
652 cl.viewangles[PITCH] = bound (in_pitch_min.value, cl.viewangles[PITCH], in_pitch_max.value);
661 void IN_Accumulate (void)
667 GetCursorPos (¤t_pos);
669 mx_accum += current_pos.x - window_center_x;
670 my_accum += current_pos.y - window_center_y;
672 // force the mouse to the center, so there's room to move
673 SetCursorPos (window_center_x, window_center_y);
684 void IN_ClearStates (void)
691 mouse_oldbuttonstate = 0;
701 void IN_StartupJoystick (void)
707 // assume no joystick
710 // abort startup if user requests no joystick
711 if ( COM_CheckParm ("-nojoy") )
714 // verify joystick driver is present
715 if ((numdevs = joyGetNumDevs ()) == 0)
717 Con_Printf ("\njoystick not found -- driver not present\n\n");
721 // cycle through the joystick ids for the first valid one
722 for (joy_id=0 ; joy_id<numdevs ; joy_id++)
724 memset (&ji, 0, sizeof(ji));
725 ji.dwSize = sizeof(ji);
726 ji.dwFlags = JOY_RETURNCENTERED;
728 if ((mmr = joyGetPosEx (joy_id, &ji)) == JOYERR_NOERROR)
732 // abort startup if we didn't find a valid joystick
733 if (mmr != JOYERR_NOERROR)
735 Con_Printf ("\njoystick not found -- no valid joysticks (%x)\n\n", mmr);
739 // get the capabilities of the selected joystick
740 // abort startup if command fails
741 memset (&jc, 0, sizeof(jc));
742 if ((mmr = joyGetDevCaps (joy_id, &jc, sizeof(jc))) != JOYERR_NOERROR)
744 Con_Printf ("\njoystick not found -- invalid joystick capabilities (%x)\n\n", mmr);
748 // save the joystick's number of buttons and POV status
749 joy_numbuttons = jc.wNumButtons;
750 joy_haspov = jc.wCaps & JOYCAPS_HASPOV;
752 // old button and POV states default to no buttons pressed
753 joy_oldbuttonstate = joy_oldpovstate = 0;
755 // mark the joystick as available and advanced initialization not completed
756 // this is needed as cvars are not available during initialization
759 joy_advancedinit = false;
761 Con_Printf ("\njoystick detected\n\n");
770 PDWORD RawValuePointer (int axis)
787 return NULL; // LordHavoc: hush compiler warning
796 void Joy_AdvancedUpdate_f (void)
799 // called once by IN_ReadJoystick and by user whenever an update is needed
800 // cvars are now available
804 // initialize all the maps
805 for (i = 0; i < JOY_MAX_AXES; i++)
807 dwAxisMap[i] = AxisNada;
808 dwControlMap[i] = JOY_ABSOLUTE_AXIS;
809 pdwRawValue[i] = RawValuePointer(i);
812 if( joy_advanced.integer == 0)
814 // default joystick initialization
815 // 2 axes only with joystick control
816 dwAxisMap[JOY_AXIS_X] = AxisTurn;
817 // dwControlMap[JOY_AXIS_X] = JOY_ABSOLUTE_AXIS;
818 dwAxisMap[JOY_AXIS_Y] = AxisForward;
819 // dwControlMap[JOY_AXIS_Y] = JOY_ABSOLUTE_AXIS;
823 if (strcmp (joy_name.string, "joystick") != 0)
825 // notify user of advanced controller
826 Con_Printf ("\n%s configured\n\n", joy_name.string);
829 // advanced initialization here
830 // data supplied by user via joy_axisn cvars
831 dwTemp = (DWORD) joy_advaxisx.value;
832 dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f;
833 dwControlMap[JOY_AXIS_X] = dwTemp & JOY_RELATIVE_AXIS;
834 dwTemp = (DWORD) joy_advaxisy.value;
835 dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f;
836 dwControlMap[JOY_AXIS_Y] = dwTemp & JOY_RELATIVE_AXIS;
837 dwTemp = (DWORD) joy_advaxisz.value;
838 dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f;
839 dwControlMap[JOY_AXIS_Z] = dwTemp & JOY_RELATIVE_AXIS;
840 dwTemp = (DWORD) joy_advaxisr.value;
841 dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f;
842 dwControlMap[JOY_AXIS_R] = dwTemp & JOY_RELATIVE_AXIS;
843 dwTemp = (DWORD) joy_advaxisu.value;
844 dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f;
845 dwControlMap[JOY_AXIS_U] = dwTemp & JOY_RELATIVE_AXIS;
846 dwTemp = (DWORD) joy_advaxisv.value;
847 dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f;
848 dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS;
851 // compute the axes to collect from DirectInput
852 joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV;
853 for (i = 0; i < JOY_MAX_AXES; i++)
855 if (dwAxisMap[i] != AxisNada)
857 joy_flags |= dwAxisFlags[i];
868 void IN_Commands (void)
871 DWORD buttonstate, povstate;
879 // loop through the joystick buttons
880 // key a joystick event or auxillary event for higher number buttons for each state change
881 buttonstate = ji.dwButtons;
882 for (i=0 ; i < (int) joy_numbuttons ; i++)
884 if ( (buttonstate & (1<<i)) && !(joy_oldbuttonstate & (1<<i)) )
886 key_index = (i < 4) ? K_JOY1 : K_AUX1;
887 Key_Event (key_index + i, true);
890 if ( !(buttonstate & (1<<i)) && (joy_oldbuttonstate & (1<<i)) )
892 key_index = (i < 4) ? K_JOY1 : K_AUX1;
893 Key_Event (key_index + i, false);
896 joy_oldbuttonstate = buttonstate;
900 // convert POV information into 4 bits of state information
901 // this avoids any potential problems related to moving from one
902 // direction to another without going through the center position
904 if(ji.dwPOV != JOY_POVCENTERED)
906 if (ji.dwPOV == JOY_POVFORWARD)
908 if (ji.dwPOV == JOY_POVRIGHT)
910 if (ji.dwPOV == JOY_POVBACKWARD)
912 if (ji.dwPOV == JOY_POVLEFT)
915 // determine which bits have changed and key an auxillary event for each change
916 for (i=0 ; i < 4 ; i++)
918 if ( (povstate & (1<<i)) && !(joy_oldpovstate & (1<<i)) )
920 Key_Event (K_AUX29 + i, true);
923 if ( !(povstate & (1<<i)) && (joy_oldpovstate & (1<<i)) )
925 Key_Event (K_AUX29 + i, false);
928 joy_oldpovstate = povstate;
938 qboolean IN_ReadJoystick (void)
941 memset (&ji, 0, sizeof(ji));
942 ji.dwSize = sizeof(ji);
943 ji.dwFlags = joy_flags;
945 if (joyGetPosEx (joy_id, &ji) == JOYERR_NOERROR)
947 // this is a hack -- there is a bug in the Logitech WingMan Warrior DirectInput Driver
948 // rather than having 32768 be the zero point, they have the zero point at 32668
949 // go figure -- anyway, now we get the full resolution out of the device
950 if (joy_wwhack1.integer != 0.0)
958 // read error occurred
959 // turning off the joystick seems too harsh for 1 read error,\
960 // but what should be done?
961 // Con_Printf ("IN_ReadJoystick: no response\n");
962 // joy_avail = false;
973 void IN_JoyMove (usercmd_t *cmd)
976 float fAxisValue, fTemp;
977 int i, mouselook = (in_mlook.state & 1) || freelook.integer;
979 // complete initialization if first time in
980 // this is needed as cvars are not available at initialization time
981 if( joy_advancedinit != true )
983 Joy_AdvancedUpdate_f();
984 joy_advancedinit = true;
987 // verify joystick is available and that the user wants to use it
988 if (!joy_avail || !in_joystick.integer)
993 // collect the joystick data, if possible
994 if (IN_ReadJoystick () != true)
999 if (in_speed.state & 1)
1000 speed = cl_movespeedkey.value;
1003 // LordHavoc: viewzoom affects sensitivity for sniping
1004 aspeed = speed * host_realframetime * cl.viewzoom;
1006 // loop through the axes
1007 for (i = 0; i < JOY_MAX_AXES; i++)
1009 // get the floating point zero-centered, potentially-inverted data for the current axis
1010 fAxisValue = (float) *pdwRawValue[i];
1011 // move centerpoint to zero
1012 fAxisValue -= 32768.0;
1014 if (joy_wwhack2.integer != 0.0)
1016 if (dwAxisMap[i] == AxisTurn)
1018 // this is a special formula for the Logitech WingMan Warrior
1019 // y=ax^b; where a = 300 and b = 1.3
1020 // also x values are in increments of 800 (so this is factored out)
1021 // then bounds check result to level out excessively high spin rates
1022 fTemp = 300.0 * pow(abs(fAxisValue) / 800.0, 1.3);
1023 if (fTemp > 14000.0)
1025 // restore direction information
1026 fAxisValue = (fAxisValue > 0.0) ? fTemp : -fTemp;
1030 // convert range from -32768..32767 to -1..1
1031 fAxisValue /= 32768.0;
1033 switch (dwAxisMap[i])
1036 if ((joy_advanced.integer == 0) && mouselook)
1038 // user wants forward control to become look control
1039 if (fabs(fAxisValue) > joy_pitchthreshold.value)
1041 // if mouse invert is on, invert the joystick pitch value
1042 // only absolute control support here (joy_advanced is false)
1043 if (m_pitch.value < 0.0)
1045 cl.viewangles[PITCH] -= (fAxisValue * joy_pitchsensitivity.value) * aspeed * cl_pitchspeed.value;
1049 cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity.value) * aspeed * cl_pitchspeed.value;
1055 // no pitch movement
1056 // disable pitch return-to-center unless requested by user
1057 // *** this code can be removed when the lookspring bug is fixed
1058 // *** the bug always has the lookspring feature on
1059 if(lookspring.value == 0.0)
1065 // user wants forward control to be forward control
1066 if (fabs(fAxisValue) > joy_forwardthreshold.value)
1068 cmd->forwardmove += (fAxisValue * joy_forwardsensitivity.value) * speed * cl_forwardspeed.value;
1074 if (fabs(fAxisValue) > joy_sidethreshold.value)
1076 cmd->sidemove += (fAxisValue * joy_sidesensitivity.value) * speed * cl_sidespeed.value;
1081 if ((in_strafe.state & 1) || (lookstrafe.integer && mouselook))
1083 // user wants turn control to become side control
1084 if (fabs(fAxisValue) > joy_sidethreshold.value)
1086 cmd->sidemove -= (fAxisValue * joy_sidesensitivity.value) * speed * cl_sidespeed.value;
1091 // user wants turn control to be turn control
1092 if (fabs(fAxisValue) > joy_yawthreshold.value)
1094 if(dwControlMap[i] == JOY_ABSOLUTE_AXIS)
1096 cl.viewangles[YAW] += (fAxisValue * joy_yawsensitivity.value) * aspeed * cl_yawspeed.value;
1100 cl.viewangles[YAW] += (fAxisValue * joy_yawsensitivity.value) * speed * 180.0;
1110 if (fabs(fAxisValue) > joy_pitchthreshold.value)
1112 // pitch movement detected and pitch movement desired by user
1113 if(dwControlMap[i] == JOY_ABSOLUTE_AXIS)
1115 cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity.value) * aspeed * cl_pitchspeed.value;
1119 cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity.value) * speed * 180.0;
1125 // no pitch movement
1126 // disable pitch return-to-center unless requested by user
1127 // *** this code can be removed when the lookspring bug is fixed
1128 // *** the bug always has the lookspring feature on
1129 if(lookspring.integer == 0)