vkQuake2 doxygen  1.0 dev
in_win.c File Reference
#include "../client/client.h"
#include "winquake.h"

Go to the source code of this file.

Macros

#define JOY_ABSOLUTE_AXIS   0x00000000
 
#define JOY_RELATIVE_AXIS   0x00000010
 
#define JOY_MAX_AXES   6
 
#define JOY_AXIS_X   0
 
#define JOY_AXIS_Y   1
 
#define JOY_AXIS_Z   2
 
#define JOY_AXIS_R   3
 
#define JOY_AXIS_U   4
 
#define JOY_AXIS_V   5
 

Enumerations

enum  _ControlList {
  AxisNada = 0, AxisForward, AxisLook, AxisSide,
  AxisTurn, AxisUp
}
 

Functions

void IN_StartupJoystick (void)
 
void Joy_AdvancedUpdate_f (void)
 
void IN_JoyMove (usercmd_t *cmd)
 
void IN_MLookDown (void)
 
void IN_MLookUp (void)
 
void IN_ActivateMouse (void)
 
void IN_DeactivateMouse (void)
 
void IN_StartupMouse (void)
 
void IN_MouseEvent (int mstate)
 
void IN_MouseMove (usercmd_t *cmd)
 
void IN_Init (void)
 
void IN_Shutdown (void)
 
void IN_Activate (qboolean active)
 
void IN_Frame (void)
 
void IN_Move (usercmd_t *cmd)
 
void IN_ClearStates (void)
 
PDWORD RawValuePointer (int axis)
 
void IN_Commands (void)
 
qboolean IN_ReadJoystick (void)
 

Variables

unsigned sys_msg_time
 
DWORD dwAxisFlags [JOY_MAX_AXES]
 
DWORD dwAxisMap [JOY_MAX_AXES]
 
DWORD dwControlMap [JOY_MAX_AXES]
 
PDWORD pdwRawValue [JOY_MAX_AXES]
 
cvar_tin_mouse
 
cvar_tin_joystick
 
cvar_tjoy_name
 
cvar_tjoy_advanced
 
cvar_tjoy_advaxisx
 
cvar_tjoy_advaxisy
 
cvar_tjoy_advaxisz
 
cvar_tjoy_advaxisr
 
cvar_tjoy_advaxisu
 
cvar_tjoy_advaxisv
 
cvar_tjoy_forwardthreshold
 
cvar_tjoy_sidethreshold
 
cvar_tjoy_pitchthreshold
 
cvar_tjoy_yawthreshold
 
cvar_tjoy_forwardsensitivity
 
cvar_tjoy_sidesensitivity
 
cvar_tjoy_pitchsensitivity
 
cvar_tjoy_yawsensitivity
 
cvar_tjoy_upthreshold
 
cvar_tjoy_upsensitivity
 
qboolean joy_avail
 
qboolean joy_advancedinit
 
qboolean joy_haspov
 
DWORD joy_oldbuttonstate
 
DWORD joy_oldpovstate
 
int joy_id
 
DWORD joy_flags
 
DWORD joy_numbuttons
 
static JOYINFOEX ji
 
qboolean in_appactive
 
cvar_tm_filter
 
qboolean mlooking
 
int mouse_buttons
 
int mouse_oldbuttonstate
 
POINT current_pos
 
int mouse_x
 
int mouse_y
 
int old_mouse_x
 
int old_mouse_y
 
int mx_accum
 
int my_accum
 
int old_x
 
int old_y
 
qboolean mouseactive
 
qboolean restore_spi
 
qboolean mouseinitialized
 
int originalmouseparms [3]
 
int newmouseparms [3] = {0, 0, 0}
 
qboolean mouseparmsvalid
 
int window_center_x
 
int window_center_y
 
RECT window_rect
 
cvar_tv_centermove
 
cvar_tv_centerspeed
 

Macro Definition Documentation

◆ JOY_ABSOLUTE_AXIS

#define JOY_ABSOLUTE_AXIS   0x00000000

Definition at line 31 of file in_win.c.

◆ JOY_AXIS_R

#define JOY_AXIS_R   3

Definition at line 37 of file in_win.c.

◆ JOY_AXIS_U

#define JOY_AXIS_U   4

Definition at line 38 of file in_win.c.

◆ JOY_AXIS_V

#define JOY_AXIS_V   5

Definition at line 39 of file in_win.c.

◆ JOY_AXIS_X

#define JOY_AXIS_X   0

Definition at line 34 of file in_win.c.

◆ JOY_AXIS_Y

#define JOY_AXIS_Y   1

Definition at line 35 of file in_win.c.

◆ JOY_AXIS_Z

#define JOY_AXIS_Z   2

Definition at line 36 of file in_win.c.

◆ JOY_MAX_AXES

#define JOY_MAX_AXES   6

Definition at line 33 of file in_win.c.

◆ JOY_RELATIVE_AXIS

#define JOY_RELATIVE_AXIS   0x00000010

Definition at line 32 of file in_win.c.

Enumeration Type Documentation

◆ _ControlList

Enumerator
AxisNada 
AxisForward 
AxisLook 
AxisSide 
AxisTurn 
AxisUp 

Definition at line 41 of file in_win.c.

42 {
44 };

Function Documentation

◆ IN_Activate()

void IN_Activate ( qboolean  active)

Definition at line 399 of file in_win.c.

400 {
401  in_appactive = active;
402  mouseactive = !active; // force a new window check or turn off
403 }

Referenced by AppActivate(), and MainWndProc().

◆ IN_ActivateMouse()

void IN_ActivateMouse ( void  )

Definition at line 144 of file in_win.c.

145 {
146  int width, height;
147 
148  if (!mouseinitialized)
149  return;
150  if (!in_mouse->value)
151  {
152  mouseactive = false;
153  return;
154  }
155  if (mouseactive)
156  return;
157 
158  mouseactive = true;
159 
160  if (mouseparmsvalid)
161  restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);
162 
163  width = GetSystemMetrics (SM_CXSCREEN);
164  height = GetSystemMetrics (SM_CYSCREEN);
165 
166  GetWindowRect ( cl_hwnd, &window_rect);
167 
168  window_center_x = (window_rect.right + window_rect.left)/2;
169  window_center_y = (window_rect.top + window_rect.bottom)/2;
170 
171  SetCursorPos (window_center_x, window_center_y);
172 
175 
176  SetCapture ( cl_hwnd );
177  ClipCursor (&window_rect);
178  while (ShowCursor (FALSE) >= 0)
179  ;
180 }

Referenced by IN_Frame().

◆ IN_ClearStates()

void IN_ClearStates ( void  )

Definition at line 458 of file in_win.c.

459 {
460  mx_accum = 0;
461  my_accum = 0;
463 }

◆ IN_Commands()

void IN_Commands ( void  )

Definition at line 649 of file in_win.c.

650 {
651  int i, key_index;
652  DWORD buttonstate, povstate;
653 
654  if (!joy_avail)
655  {
656  return;
657  }
658 
659 
660  // loop through the joystick buttons
661  // key a joystick event or auxillary event for higher number buttons for each state change
662  buttonstate = ji.dwButtons;
663  for (i=0 ; i < joy_numbuttons ; i++)
664  {
665  if ( (buttonstate & (1<<i)) && !(joy_oldbuttonstate & (1<<i)) )
666  {
667  key_index = (i < 4) ? K_JOY1 : K_AUX1;
668  Key_Event (key_index + i, true, 0);
669  }
670 
671  if ( !(buttonstate & (1<<i)) && (joy_oldbuttonstate & (1<<i)) )
672  {
673  key_index = (i < 4) ? K_JOY1 : K_AUX1;
674  Key_Event (key_index + i, false, 0);
675  }
676  }
677  joy_oldbuttonstate = buttonstate;
678 
679  if (joy_haspov)
680  {
681  // convert POV information into 4 bits of state information
682  // this avoids any potential problems related to moving from one
683  // direction to another without going through the center position
684  povstate = 0;
685  if(ji.dwPOV != JOY_POVCENTERED)
686  {
687  if (ji.dwPOV == JOY_POVFORWARD)
688  povstate |= 0x01;
689  if (ji.dwPOV == JOY_POVRIGHT)
690  povstate |= 0x02;
691  if (ji.dwPOV == JOY_POVBACKWARD)
692  povstate |= 0x04;
693  if (ji.dwPOV == JOY_POVLEFT)
694  povstate |= 0x08;
695  }
696  // determine which bits have changed and key an auxillary event for each change
697  for (i=0 ; i < 4 ; i++)
698  {
699  if ( (povstate & (1<<i)) && !(joy_oldpovstate & (1<<i)) )
700  {
701  Key_Event (K_AUX29 + i, true, 0);
702  }
703 
704  if ( !(povstate & (1<<i)) && (joy_oldpovstate & (1<<i)) )
705  {
706  Key_Event (K_AUX29 + i, false, 0);
707  }
708  }
709  joy_oldpovstate = povstate;
710  }
711 }

Referenced by CL_SendCommand().

◆ IN_DeactivateMouse()

void IN_DeactivateMouse ( void  )

Definition at line 190 of file in_win.c.

191 {
192  if (!mouseinitialized)
193  return;
194  if (!mouseactive)
195  return;
196 
197  if (restore_spi)
198  SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0);
199 
200  mouseactive = false;
201 
202  ClipCursor (NULL);
203  ReleaseCapture ();
204  while (ShowCursor (TRUE) < 0)
205  ;
206 }

Referenced by IN_Frame(), and IN_Shutdown().

◆ IN_Frame()

void IN_Frame ( void  )

Definition at line 413 of file in_win.c.

414 {
415  if (!mouseinitialized)
416  return;
417 
418  if (!in_mouse || !in_appactive)
419  {
421  return;
422  }
423 
424  if ( !cl.refresh_prepped
425  || cls.key_dest == key_console
426  || cls.key_dest == key_menu)
427  {
428  // temporarily deactivate if in fullscreen
429  if (Cvar_VariableValue ("vid_fullscreen") == 0)
430  {
432  return;
433  }
434  }
435 
436  IN_ActivateMouse ();
437 }

Referenced by CL_Frame().

◆ IN_Init()

void IN_Init ( void  )

Definition at line 339 of file in_win.c.

340 {
341  // mouse variables
342  m_filter = Cvar_Get ("m_filter", "0", 0);
343  in_mouse = Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE);
344 
345  // joystick variables
346  in_joystick = Cvar_Get ("in_joystick", "0", CVAR_ARCHIVE);
347  joy_name = Cvar_Get ("joy_name", "joystick", 0);
348  joy_advanced = Cvar_Get ("joy_advanced", "0", 0);
349  joy_advaxisx = Cvar_Get ("joy_advaxisx", "0", 0);
350  joy_advaxisy = Cvar_Get ("joy_advaxisy", "0", 0);
351  joy_advaxisz = Cvar_Get ("joy_advaxisz", "0", 0);
352  joy_advaxisr = Cvar_Get ("joy_advaxisr", "0", 0);
353  joy_advaxisu = Cvar_Get ("joy_advaxisu", "0", 0);
354  joy_advaxisv = Cvar_Get ("joy_advaxisv", "0", 0);
355  joy_forwardthreshold = Cvar_Get ("joy_forwardthreshold", "0.15", 0);
356  joy_sidethreshold = Cvar_Get ("joy_sidethreshold", "0.15", 0);
357  joy_upthreshold = Cvar_Get ("joy_upthreshold", "0.15", 0);
358  joy_pitchthreshold = Cvar_Get ("joy_pitchthreshold", "0.15", 0);
359  joy_yawthreshold = Cvar_Get ("joy_yawthreshold", "0.15", 0);
360  joy_forwardsensitivity = Cvar_Get ("joy_forwardsensitivity", "-1", 0);
361  joy_sidesensitivity = Cvar_Get ("joy_sidesensitivity", "-1", 0);
362  joy_upsensitivity = Cvar_Get ("joy_upsensitivity", "-1", 0);
363  joy_pitchsensitivity = Cvar_Get ("joy_pitchsensitivity", "1", 0);
364  joy_yawsensitivity = Cvar_Get ("joy_yawsensitivity", "-1", 0);
365 
366  // centering
367  v_centermove = Cvar_Get ("v_centermove", "0.15", 0);
368  v_centerspeed = Cvar_Get ("v_centerspeed", "500", 0);
369 
370  Cmd_AddCommand ("+mlook", IN_MLookDown);
371  Cmd_AddCommand ("-mlook", IN_MLookUp);
372 
373  Cmd_AddCommand ("joy_advancedupdate", Joy_AdvancedUpdate_f);
374 
375  IN_StartupMouse ();
377 }

Referenced by CL_Init().

◆ IN_JoyMove()

void IN_JoyMove ( usercmd_t cmd)

Definition at line 747 of file in_win.c.

748 {
749  float speed, aspeed;
750  float fAxisValue;
751  int i;
752 
753  // complete initialization if first time in
754  // this is needed as cvars are not available at initialization time
755  if( joy_advancedinit != true )
756  {
758  joy_advancedinit = true;
759  }
760 
761  // verify joystick is available and that the user wants to use it
762  if (!joy_avail || !in_joystick->value)
763  {
764  return;
765  }
766 
767  // collect the joystick data, if possible
768  if (IN_ReadJoystick () != true)
769  {
770  return;
771  }
772 
773  if ( (in_speed.state & 1) ^ (int)cl_run->value)
774  speed = 2;
775  else
776  speed = 1;
777  aspeed = speed * cls.frametime;
778 
779  // loop through the axes
780  for (i = 0; i < JOY_MAX_AXES; i++)
781  {
782  // get the floating point zero-centered, potentially-inverted data for the current axis
783  fAxisValue = (float) *pdwRawValue[i];
784  // move centerpoint to zero
785  fAxisValue -= 32768.0;
786 
787  // convert range from -32768..32767 to -1..1
788  fAxisValue /= 32768.0;
789 
790  switch (dwAxisMap[i])
791  {
792  case AxisForward:
793  if ((joy_advanced->value == 0.0) && mlooking)
794  {
795  // user wants forward control to become look control
796  if (fabs(fAxisValue) > joy_pitchthreshold->value)
797  {
798  // if mouse invert is on, invert the joystick pitch value
799  // only absolute control support here (joy_advanced is false)
800  if (m_pitch->value < 0.0)
801  {
802  cl.viewangles[PITCH] -= (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value;
803  }
804  else
805  {
806  cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value;
807  }
808  }
809  }
810  else
811  {
812  // user wants forward control to be forward control
813  if (fabs(fAxisValue) > joy_forwardthreshold->value)
814  {
815  cmd->forwardmove += (fAxisValue * joy_forwardsensitivity->value) * speed * cl_forwardspeed->value;
816  }
817  }
818  break;
819 
820  case AxisSide:
821  if (fabs(fAxisValue) > joy_sidethreshold->value)
822  {
823  cmd->sidemove += (fAxisValue * joy_sidesensitivity->value) * speed * cl_sidespeed->value;
824  }
825  break;
826 
827  case AxisUp:
828  if (fabs(fAxisValue) > joy_upthreshold->value)
829  {
830  cmd->upmove += (fAxisValue * joy_upsensitivity->value) * speed * cl_upspeed->value;
831  }
832  break;
833 
834  case AxisTurn:
835  if ((in_strafe.state & 1) || (lookstrafe->value && mlooking))
836  {
837  // user wants turn control to become side control
838  if (fabs(fAxisValue) > joy_sidethreshold->value)
839  {
840  cmd->sidemove -= (fAxisValue * joy_sidesensitivity->value) * speed * cl_sidespeed->value;
841  }
842  }
843  else
844  {
845  // user wants turn control to be turn control
846  if (fabs(fAxisValue) > joy_yawthreshold->value)
847  {
849  {
850  cl.viewangles[YAW] += (fAxisValue * joy_yawsensitivity->value) * aspeed * cl_yawspeed->value;
851  }
852  else
853  {
854  cl.viewangles[YAW] += (fAxisValue * joy_yawsensitivity->value) * speed * 180.0;
855  }
856 
857  }
858  }
859  break;
860 
861  case AxisLook:
862  if (mlooking)
863  {
864  if (fabs(fAxisValue) > joy_pitchthreshold->value)
865  {
866  // pitch movement detected and pitch movement desired by user
868  {
869  cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value;
870  }
871  else
872  {
873  cl.viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * speed * 180.0;
874  }
875  }
876  }
877  break;
878 
879  default:
880  break;
881  }
882  }
883 }

Referenced by IN_Move().

◆ IN_MLookDown()

void IN_MLookDown ( void  )

Definition at line 112 of file in_win.c.

112 { mlooking = true; }

Referenced by IN_Init().

◆ IN_MLookUp()

void IN_MLookUp ( void  )

Definition at line 113 of file in_win.c.

113  {
114 mlooking = false;
115 if (!freelook->value && lookspring->value)
116  IN_CenterView ();
117 }

Referenced by IN_Init().

◆ IN_MouseEvent()

void IN_MouseEvent ( int  mstate)

Definition at line 233 of file in_win.c.

234 {
235  int i;
236 
237  if (!mouseinitialized)
238  return;
239 
240 // perform button actions
241  for (i=0 ; i<mouse_buttons ; i++)
242  {
243  if ( (mstate & (1<<i)) &&
244  !(mouse_oldbuttonstate & (1<<i)) )
245  {
246  Key_Event (K_MOUSE1 + i, true, sys_msg_time);
247  }
248 
249  if ( !(mstate & (1<<i)) &&
250  (mouse_oldbuttonstate & (1<<i)) )
251  {
252  Key_Event (K_MOUSE1 + i, false, sys_msg_time);
253  }
254  }
255 
256  mouse_oldbuttonstate = mstate;
257 }

Referenced by MainWndProc().

◆ IN_MouseMove()

void IN_MouseMove ( usercmd_t cmd)

Definition at line 265 of file in_win.c.

266 {
267  int mx, my;
268 
269  if (!mouseactive)
270  return;
271 
272  // find mouse movement
273  if (!GetCursorPos (&current_pos))
274  return;
275 
276  mx = current_pos.x - window_center_x;
277  my = current_pos.y - window_center_y;
278 
279 #if 0
280  if (!mx && !my)
281  return;
282 #endif
283 
284  if (m_filter->value)
285  {
286  mouse_x = (mx + old_mouse_x) * 0.5;
287  mouse_y = (my + old_mouse_y) * 0.5;
288  }
289  else
290  {
291  mouse_x = mx;
292  mouse_y = my;
293  }
294 
295  old_mouse_x = mx;
296  old_mouse_y = my;
297 
300 
301 // add mouse X/Y movement to cmd
302  if ( (in_strafe.state & 1) || (lookstrafe->value && mlooking ))
303  cmd->sidemove += m_side->value * mouse_x;
304  else
306 
307  if ( (mlooking || freelook->value) && !(in_strafe.state & 1))
308  {
310  }
311  else
312  {
313  cmd->forwardmove -= m_forward->value * mouse_y;
314  }
315 
316  // force the mouse to the center, so there's room to move
317  if (mx || my)
318  SetCursorPos (window_center_x, window_center_y);
319 }

Referenced by IN_Move().

◆ IN_Move()

void IN_Move ( usercmd_t cmd)

Definition at line 444 of file in_win.c.

445 {
446  IN_MouseMove (cmd);
447 
448  if (ActiveApp)
449  IN_JoyMove (cmd);
450 }

Referenced by CL_CreateCmd().

◆ IN_ReadJoystick()

qboolean IN_ReadJoystick ( void  )

Definition at line 719 of file in_win.c.

720 {
721 
722  memset (&ji, 0, sizeof(ji));
723  ji.dwSize = sizeof(ji);
724  ji.dwFlags = joy_flags;
725 
726  if (joyGetPosEx (joy_id, &ji) == JOYERR_NOERROR)
727  {
728  return true;
729  }
730  else
731  {
732  // read error occurred
733  // turning off the joystick seems too harsh for 1 read error,\
734  // but what should be done?
735  // Com_Printf ("IN_ReadJoystick: no response\n");
736  // joy_avail = false;
737  return false;
738  }
739 }

Referenced by IN_JoyMove().

◆ IN_Shutdown()

void IN_Shutdown ( void  )

Definition at line 384 of file in_win.c.

385 {
387 }

Referenced by CL_Shutdown().

◆ IN_StartupJoystick()

void IN_StartupJoystick ( void  )

Definition at line 479 of file in_win.c.

480 {
481  int numdevs;
482  JOYCAPS jc;
483  MMRESULT mmr;
484  cvar_t *cv;
485 
486  // assume no joystick
487  joy_avail = false;
488 
489  // abort startup if user requests no joystick
490  cv = Cvar_Get ("in_initjoy", "1", CVAR_NOSET);
491  if ( !cv->value )
492  return;
493 
494  // verify joystick driver is present
495  if ((numdevs = joyGetNumDevs ()) == 0)
496  {
497 // Com_Printf ("\njoystick not found -- driver not present\n\n");
498  return;
499  }
500 
501  // cycle through the joystick ids for the first valid one
502  for (joy_id=0 ; joy_id<numdevs ; joy_id++)
503  {
504  memset (&ji, 0, sizeof(ji));
505  ji.dwSize = sizeof(ji);
506  ji.dwFlags = JOY_RETURNCENTERED;
507 
508  if ((mmr = joyGetPosEx (joy_id, &ji)) == JOYERR_NOERROR)
509  break;
510  }
511 
512  // abort startup if we didn't find a valid joystick
513  if (mmr != JOYERR_NOERROR)
514  {
515  Com_Printf ("\njoystick not found -- no valid joysticks (%x)\n\n", mmr);
516  return;
517  }
518 
519  // get the capabilities of the selected joystick
520  // abort startup if command fails
521  memset (&jc, 0, sizeof(jc));
522  if ((mmr = joyGetDevCaps (joy_id, &jc, sizeof(jc))) != JOYERR_NOERROR)
523  {
524  Com_Printf ("\njoystick not found -- invalid joystick capabilities (%x)\n\n", mmr);
525  return;
526  }
527 
528  // save the joystick's number of buttons and POV status
529  joy_numbuttons = jc.wNumButtons;
530  joy_haspov = jc.wCaps & JOYCAPS_HASPOV;
531 
532  // old button and POV states default to no buttons pressed
534 
535  // mark the joystick as available and advanced initialization not completed
536  // this is needed as cvars are not available during initialization
537 
538  joy_avail = true;
539  joy_advancedinit = false;
540 
541  Com_Printf ("\njoystick detected\n\n");
542 }

Referenced by IN_Init().

◆ IN_StartupMouse()

void IN_StartupMouse ( void  )

Definition at line 215 of file in_win.c.

216 {
217  cvar_t *cv;
218 
219  cv = Cvar_Get ("in_initmouse", "1", CVAR_NOSET);
220  if ( !cv->value )
221  return;
222 
223  mouseinitialized = true;
224  mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0);
225  mouse_buttons = 3;
226 }

Referenced by IN_Init().

◆ Joy_AdvancedUpdate_f()

void Joy_AdvancedUpdate_f ( void  )

Definition at line 577 of file in_win.c.

578 {
579 
580  // called once by IN_ReadJoystick and by user whenever an update is needed
581  // cvars are now available
582  int i;
583  DWORD dwTemp;
584 
585  // initialize all the maps
586  for (i = 0; i < JOY_MAX_AXES; i++)
587  {
588  dwAxisMap[i] = AxisNada;
591  }
592 
593  if( joy_advanced->value == 0.0)
594  {
595  // default joystick initialization
596  // 2 axes only with joystick control
598  // dwControlMap[JOY_AXIS_X] = JOY_ABSOLUTE_AXIS;
600  // dwControlMap[JOY_AXIS_Y] = JOY_ABSOLUTE_AXIS;
601  }
602  else
603  {
604  if (strcmp (joy_name->string, "joystick") != 0)
605  {
606  // notify user of advanced controller
607  Com_Printf ("\n%s configured\n\n", joy_name->string);
608  }
609 
610  // advanced initialization here
611  // data supplied by user via joy_axisn cvars
612  dwTemp = (DWORD) joy_advaxisx->value;
613  dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f;
615  dwTemp = (DWORD) joy_advaxisy->value;
616  dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f;
618  dwTemp = (DWORD) joy_advaxisz->value;
619  dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f;
621  dwTemp = (DWORD) joy_advaxisr->value;
622  dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f;
624  dwTemp = (DWORD) joy_advaxisu->value;
625  dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f;
627  dwTemp = (DWORD) joy_advaxisv->value;
628  dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f;
630  }
631 
632  // compute the axes to collect from DirectInput
633  joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV;
634  for (i = 0; i < JOY_MAX_AXES; i++)
635  {
636  if (dwAxisMap[i] != AxisNada)
637  {
638  joy_flags |= dwAxisFlags[i];
639  }
640  }
641 }

Referenced by IN_Init(), and IN_JoyMove().

◆ RawValuePointer()

PDWORD RawValuePointer ( int  axis)

Definition at line 550 of file in_win.c.

551 {
552  switch (axis)
553  {
554  case JOY_AXIS_X:
555  return &ji.dwXpos;
556  case JOY_AXIS_Y:
557  return &ji.dwYpos;
558  case JOY_AXIS_Z:
559  return &ji.dwZpos;
560  case JOY_AXIS_R:
561  return &ji.dwRpos;
562  case JOY_AXIS_U:
563  return &ji.dwUpos;
564  case JOY_AXIS_V:
565  return &ji.dwVpos;
566  }
567 
568  return NULL;
569 }

Referenced by Joy_AdvancedUpdate_f().

Variable Documentation

◆ current_pos

POINT current_pos

Definition at line 121 of file in_win.c.

Referenced by IN_MouseMove().

◆ dwAxisFlags

DWORD dwAxisFlags[JOY_MAX_AXES]
Initial value:
=
{
JOY_RETURNX, JOY_RETURNY, JOY_RETURNZ, JOY_RETURNR, JOY_RETURNU, JOY_RETURNV
}

Definition at line 46 of file in_win.c.

Referenced by Joy_AdvancedUpdate_f().

◆ dwAxisMap

DWORD dwAxisMap[JOY_MAX_AXES]

Definition at line 51 of file in_win.c.

Referenced by IN_JoyMove(), and Joy_AdvancedUpdate_f().

◆ dwControlMap

DWORD dwControlMap[JOY_MAX_AXES]

Definition at line 52 of file in_win.c.

Referenced by IN_JoyMove(), and Joy_AdvancedUpdate_f().

◆ in_appactive

qboolean in_appactive

Definition at line 92 of file in_win.c.

Referenced by IN_Activate(), and IN_Frame().

◆ in_joystick

cvar_t* in_joystick

Definition at line 56 of file in_win.c.

Referenced by ControlsSetMenuItemValues(), IN_Init(), and IN_JoyMove().

◆ in_mouse

cvar_t* in_mouse

Definition at line 55 of file in_win.c.

Referenced by IN_ActivateMouse(), IN_Frame(), and IN_Init().

◆ ji

JOYINFOEX ji
static

Definition at line 90 of file in_win.c.

Referenced by IN_Commands(), IN_ReadJoystick(), IN_StartupJoystick(), and RawValuePointer().

◆ joy_advanced

cvar_t* joy_advanced

Definition at line 65 of file in_win.c.

Referenced by IN_Init(), IN_JoyMove(), and Joy_AdvancedUpdate_f().

◆ joy_advancedinit

qboolean joy_advancedinit

Definition at line 83 of file in_win.c.

Referenced by IN_JoyMove(), and IN_StartupJoystick().

◆ joy_advaxisr

cvar_t* joy_advaxisr

Definition at line 69 of file in_win.c.

Referenced by IN_Init(), and Joy_AdvancedUpdate_f().

◆ joy_advaxisu

cvar_t* joy_advaxisu

Definition at line 70 of file in_win.c.

Referenced by IN_Init(), and Joy_AdvancedUpdate_f().

◆ joy_advaxisv

cvar_t* joy_advaxisv

Definition at line 71 of file in_win.c.

Referenced by IN_Init(), and Joy_AdvancedUpdate_f().

◆ joy_advaxisx

cvar_t* joy_advaxisx

Definition at line 66 of file in_win.c.

Referenced by IN_Init(), and Joy_AdvancedUpdate_f().

◆ joy_advaxisy

cvar_t* joy_advaxisy

Definition at line 67 of file in_win.c.

Referenced by IN_Init(), and Joy_AdvancedUpdate_f().

◆ joy_advaxisz

cvar_t* joy_advaxisz

Definition at line 68 of file in_win.c.

Referenced by IN_Init(), and Joy_AdvancedUpdate_f().

◆ joy_avail

qboolean joy_avail

Definition at line 83 of file in_win.c.

Referenced by IN_Commands(), IN_JoyMove(), and IN_StartupJoystick().

◆ joy_flags

DWORD joy_flags

Definition at line 87 of file in_win.c.

Referenced by IN_ReadJoystick(), and Joy_AdvancedUpdate_f().

◆ joy_forwardsensitivity

cvar_t* joy_forwardsensitivity

Definition at line 76 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_forwardthreshold

cvar_t* joy_forwardthreshold

Definition at line 72 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_haspov

qboolean joy_haspov

Definition at line 83 of file in_win.c.

Referenced by IN_Commands(), and IN_StartupJoystick().

◆ joy_id

int joy_id

Definition at line 86 of file in_win.c.

Referenced by IN_ReadJoystick(), and IN_StartupJoystick().

◆ joy_name

cvar_t* joy_name

Definition at line 64 of file in_win.c.

Referenced by IN_Init(), and Joy_AdvancedUpdate_f().

◆ joy_numbuttons

DWORD joy_numbuttons

Definition at line 88 of file in_win.c.

Referenced by IN_Commands(), and IN_StartupJoystick().

◆ joy_oldbuttonstate

DWORD joy_oldbuttonstate

Definition at line 84 of file in_win.c.

Referenced by IN_Commands(), and IN_StartupJoystick().

◆ joy_oldpovstate

DWORD joy_oldpovstate

Definition at line 84 of file in_win.c.

Referenced by IN_Commands(), and IN_StartupJoystick().

◆ joy_pitchsensitivity

cvar_t* joy_pitchsensitivity

Definition at line 78 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_pitchthreshold

cvar_t* joy_pitchthreshold

Definition at line 74 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_sidesensitivity

cvar_t* joy_sidesensitivity

Definition at line 77 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_sidethreshold

cvar_t* joy_sidethreshold

Definition at line 73 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_upsensitivity

cvar_t* joy_upsensitivity

Definition at line 81 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_upthreshold

cvar_t* joy_upthreshold

Definition at line 80 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_yawsensitivity

cvar_t* joy_yawsensitivity

Definition at line 79 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_yawthreshold

cvar_t* joy_yawthreshold

Definition at line 75 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ m_filter

cvar_t* m_filter

Definition at line 108 of file in_win.c.

Referenced by IN_Init(), and IN_MouseMove().

◆ mlooking

qboolean mlooking

Definition at line 110 of file in_win.c.

Referenced by IN_JoyMove(), IN_MLookDown(), IN_MLookUp(), and IN_MouseMove().

◆ mouse_buttons

int mouse_buttons

Definition at line 119 of file in_win.c.

Referenced by IN_MouseEvent(), and IN_StartupMouse().

◆ mouse_oldbuttonstate

int mouse_oldbuttonstate

Definition at line 120 of file in_win.c.

Referenced by IN_ClearStates(), and IN_MouseEvent().

◆ mouse_x

int mouse_x

Definition at line 122 of file in_win.c.

Referenced by IN_MouseMove().

◆ mouse_y

int mouse_y

Definition at line 122 of file in_win.c.

Referenced by IN_MouseMove().

◆ mouseactive

qboolean mouseactive

Definition at line 126 of file in_win.c.

Referenced by IN_Activate(), IN_ActivateMouse(), IN_DeactivateMouse(), and IN_MouseMove().

◆ mouseinitialized

qboolean mouseinitialized

◆ mouseparmsvalid

qboolean mouseparmsvalid

Definition at line 131 of file in_win.c.

Referenced by IN_ActivateMouse(), and IN_StartupMouse().

◆ mx_accum

int mx_accum

Definition at line 122 of file in_win.c.

Referenced by IN_ClearStates().

◆ my_accum

int my_accum

Definition at line 122 of file in_win.c.

Referenced by IN_ClearStates().

◆ newmouseparms

int newmouseparms[3] = {0, 0, 0}

Definition at line 130 of file in_win.c.

Referenced by IN_ActivateMouse().

◆ old_mouse_x

int old_mouse_x

Definition at line 122 of file in_win.c.

Referenced by IN_MouseMove().

◆ old_mouse_y

int old_mouse_y

Definition at line 122 of file in_win.c.

Referenced by IN_MouseMove().

◆ old_x

int old_x

Definition at line 124 of file in_win.c.

Referenced by IN_ActivateMouse().

◆ old_y

int old_y

Definition at line 124 of file in_win.c.

Referenced by IN_ActivateMouse().

◆ originalmouseparms

int originalmouseparms[3]

Definition at line 130 of file in_win.c.

Referenced by IN_DeactivateMouse(), and IN_StartupMouse().

◆ pdwRawValue

PDWORD pdwRawValue[JOY_MAX_AXES]

Definition at line 53 of file in_win.c.

Referenced by IN_JoyMove(), and Joy_AdvancedUpdate_f().

◆ restore_spi

qboolean restore_spi

Definition at line 128 of file in_win.c.

Referenced by IN_ActivateMouse(), and IN_DeactivateMouse().

◆ sys_msg_time

unsigned sys_msg_time

Definition at line 48 of file sys_win.c.

Referenced by IN_MouseEvent().

◆ v_centermove

cvar_t* v_centermove

Definition at line 330 of file in_win.c.

Referenced by IN_Init().

◆ v_centerspeed

cvar_t* v_centerspeed

Definition at line 331 of file in_win.c.

Referenced by IN_Init().

◆ window_center_x

int window_center_x

Definition at line 133 of file in_win.c.

Referenced by IN_ActivateMouse(), and IN_MouseMove().

◆ window_center_y

int window_center_y

Definition at line 133 of file in_win.c.

Referenced by IN_ActivateMouse(), and IN_MouseMove().

◆ window_rect

RECT window_rect

Definition at line 134 of file in_win.c.

Referenced by IN_ActivateMouse().

sensitivity
cvar_t * sensitivity
Definition: cl_main.c:65
IN_MLookUp
void IN_MLookUp(void)
Definition: in_win.c:113
dwAxisMap
DWORD dwAxisMap[JOY_MAX_AXES]
Definition: in_win.c:51
height
GLsizei height
Definition: qgl_win.c:69
IN_JoyMove
void IN_JoyMove(usercmd_t *cmd)
Definition: in_win.c:747
dwAxisFlags
DWORD dwAxisFlags[JOY_MAX_AXES]
Definition: in_win.c:46
YAW
#define YAW
Definition: q_shared.h:73
JOY_ABSOLUTE_AXIS
#define JOY_ABSOLUTE_AXIS
Definition: in_win.c:31
TRUE
#define TRUE
Definition: stb_vorbis.c:617
joy_id
int joy_id
Definition: in_win.c:86
old_y
int old_y
Definition: in_win.c:124
CVAR_NOSET
#define CVAR_NOSET
Definition: q_shared.h:319
kbutton_t::state
int state
Definition: client.h:474
AxisNada
@ AxisNada
Definition: in_win.c:43
v_centerspeed
cvar_t * v_centerspeed
Definition: in_win.c:331
dwControlMap
DWORD dwControlMap[JOY_MAX_AXES]
Definition: in_win.c:52
cl_run
cvar_t * cl_run
Definition: cl_input.c:230
in_speed
kbutton_t in_speed
Definition: cl_input.c:61
Key_Event
void Key_Event(int key, qboolean down, unsigned time)
Definition: keys.c:744
joy_forwardsensitivity
cvar_t * joy_forwardsensitivity
Definition: in_win.c:76
IN_StartupJoystick
void IN_StartupJoystick(void)
Definition: in_win.c:479
joy_avail
qboolean joy_avail
Definition: in_win.c:83
K_JOY1
#define K_JOY1
Definition: keys.h:89
joy_name
cvar_t * joy_name
Definition: in_win.c:64
old_x
int old_x
Definition: in_win.c:124
joy_advaxisr
cvar_t * joy_advaxisr
Definition: in_win.c:69
cl_upspeed
cvar_t * cl_upspeed
Definition: cl_input.c:223
joy_sidesensitivity
cvar_t * joy_sidesensitivity
Definition: in_win.c:77
K_MOUSE1
#define K_MOUSE1
Definition: keys.h:82
window_center_y
int window_center_y
Definition: in_win.c:133
joy_oldpovstate
DWORD joy_oldpovstate
Definition: in_win.c:84
m_side
cvar_t * m_side
Definition: cl_main.c:70
originalmouseparms
int originalmouseparms[3]
Definition: in_win.c:130
cvar_s::string
char * string
Definition: q_shared.h:327
in_mouse
cvar_t * in_mouse
Definition: in_win.c:55
client_state_t::viewangles
vec3_t viewangles
Definition: client.h:125
cl_sidespeed
cvar_t * cl_sidespeed
Definition: cl_input.c:225
my_accum
int my_accum
Definition: in_win.c:122
JOY_AXIS_R
#define JOY_AXIS_R
Definition: in_win.c:37
i
int i
Definition: q_shared.c:305
IN_DeactivateMouse
void IN_DeactivateMouse(void)
Definition: in_win.c:190
mouse_x
int mouse_x
Definition: in_win.c:122
joy_flags
DWORD joy_flags
Definition: in_win.c:87
joy_upsensitivity
cvar_t * joy_upsensitivity
Definition: in_win.c:81
mlooking
qboolean mlooking
Definition: in_win.c:110
m_forward
cvar_t * m_forward
Definition: cl_main.c:69
RawValuePointer
PDWORD RawValuePointer(int axis)
Definition: in_win.c:550
PITCH
#define PITCH
Definition: q_shared.h:72
joy_oldbuttonstate
DWORD joy_oldbuttonstate
Definition: in_win.c:84
width
GLint GLsizei width
Definition: qgl_win.c:115
Joy_AdvancedUpdate_f
void Joy_AdvancedUpdate_f(void)
Definition: in_win.c:577
JOY_AXIS_X
#define JOY_AXIS_X
Definition: in_win.c:34
usercmd_s::forwardmove
short forwardmove
Definition: q_shared.h:522
joy_pitchthreshold
cvar_t * joy_pitchthreshold
Definition: in_win.c:74
JOY_AXIS_Z
#define JOY_AXIS_Z
Definition: in_win.c:36
Cvar_Get
cvar_t * Cvar_Get(char *var_name, char *var_value, int flags)
Definition: cvar.c:127
joy_yawthreshold
cvar_t * joy_yawthreshold
Definition: in_win.c:75
cvar_s
Definition: q_shared.h:324
cl_yawspeed
cvar_t * cl_yawspeed
Definition: cl_input.c:227
key_menu
@ key_menu
Definition: client.h:200
window_center_x
int window_center_x
Definition: in_win.c:133
AxisUp
@ AxisUp
Definition: in_win.c:43
JOY_RELATIVE_AXIS
#define JOY_RELATIVE_AXIS
Definition: in_win.c:32
freelook
cvar_t * freelook
Definition: cl_main.c:24
joy_sidethreshold
cvar_t * joy_sidethreshold
Definition: in_win.c:73
restore_spi
qboolean restore_spi
Definition: in_win.c:128
AxisLook
@ AxisLook
Definition: in_win.c:43
IN_MLookDown
void IN_MLookDown(void)
Definition: in_win.c:112
in_joystick
cvar_t * in_joystick
Definition: in_win.c:56
joy_yawsensitivity
cvar_t * joy_yawsensitivity
Definition: in_win.c:79
K_AUX29
#define K_AUX29
Definition: keys.h:126
joy_haspov
qboolean joy_haspov
Definition: in_win.c:83
usercmd_s::sidemove
short sidemove
Definition: q_shared.h:522
IN_ReadJoystick
qboolean IN_ReadJoystick(void)
Definition: in_win.c:719
current_pos
POINT current_pos
Definition: in_win.c:121
JOY_AXIS_U
#define JOY_AXIS_U
Definition: in_win.c:38
cl_forwardspeed
cvar_t * cl_forwardspeed
Definition: cl_input.c:224
JOY_AXIS_V
#define JOY_AXIS_V
Definition: in_win.c:39
JOY_AXIS_Y
#define JOY_AXIS_Y
Definition: in_win.c:35
joy_advaxisx
cvar_t * joy_advaxisx
Definition: in_win.c:66
newmouseparms
int newmouseparms[3]
Definition: in_win.c:130
mouseparmsvalid
qboolean mouseparmsvalid
Definition: in_win.c:131
old_mouse_x
int old_mouse_x
Definition: in_win.c:122
pdwRawValue
PDWORD pdwRawValue[JOY_MAX_AXES]
Definition: in_win.c:53
Cmd_AddCommand
void Cmd_AddCommand(char *cmd_name, xcommand_t function)
Definition: cmd.c:691
client_state_t::refresh_prepped
qboolean refresh_prepped
Definition: client.h:98
v_centermove
cvar_t * v_centermove
Definition: in_win.c:330
m_yaw
cvar_t * m_yaw
Definition: cl_main.c:68
AxisForward
@ AxisForward
Definition: in_win.c:43
lookspring
cvar_t * lookspring
Definition: cl_main.c:63
CVAR_ARCHIVE
#define CVAR_ARCHIVE
Definition: q_shared.h:316
cl_hwnd
HWND cl_hwnd
Definition: vid_dll.c:58
mouse_buttons
int mouse_buttons
Definition: in_win.c:119
lookstrafe
cvar_t * lookstrafe
Definition: cl_main.c:64
cvar_s::value
float value
Definition: q_shared.h:331
joy_advaxisy
cvar_t * joy_advaxisy
Definition: in_win.c:67
mouseactive
qboolean mouseactive
Definition: in_win.c:126
key_console
@ key_console
Definition: client.h:200
NULL
#define NULL
Definition: q_shared.h:67
joy_advaxisv
cvar_t * joy_advaxisv
Definition: in_win.c:71
AxisSide
@ AxisSide
Definition: in_win.c:43
window_rect
RECT window_rect
Definition: in_win.c:134
mouse_oldbuttonstate
int mouse_oldbuttonstate
Definition: in_win.c:120
usercmd_s::upmove
short upmove
Definition: q_shared.h:522
joy_advaxisz
cvar_t * joy_advaxisz
Definition: in_win.c:68
mx_accum
int mx_accum
Definition: in_win.c:122
in_appactive
qboolean in_appactive
Definition: in_win.c:92
joy_upthreshold
cvar_t * joy_upthreshold
Definition: in_win.c:80
IN_StartupMouse
void IN_StartupMouse(void)
Definition: in_win.c:215
m_filter
cvar_t * m_filter
Definition: in_win.c:108
m_pitch
cvar_t * m_pitch
Definition: cl_main.c:67
ActiveApp
qboolean ActiveApp
Definition: sys_win.c:43
joy_advancedinit
qboolean joy_advancedinit
Definition: in_win.c:83
sys_msg_time
unsigned sys_msg_time
Definition: sys_win.c:48
K_AUX1
#define K_AUX1
Definition: keys.h:98
IN_ActivateMouse
void IN_ActivateMouse(void)
Definition: in_win.c:144
cl_pitchspeed
cvar_t * cl_pitchspeed
Definition: cl_input.c:228
client_static_t::frametime
float frametime
Definition: client.h:209
ji
static JOYINFOEX ji
Definition: in_win.c:90
mouseinitialized
qboolean mouseinitialized
Definition: in_win.c:129
joy_advaxisu
cvar_t * joy_advaxisu
Definition: in_win.c:70
joy_forwardthreshold
cvar_t * joy_forwardthreshold
Definition: in_win.c:72
mouse_y
int mouse_y
Definition: in_win.c:122
AxisTurn
@ AxisTurn
Definition: in_win.c:43
IN_CenterView
void IN_CenterView(void)
Definition: cl_input.c:404
joy_advanced
cvar_t * joy_advanced
Definition: in_win.c:65
client_static_t::key_dest
keydest_t key_dest
Definition: client.h:205
DWORD
DWORD
Definition: qgl_win.c:49
JOY_MAX_AXES
#define JOY_MAX_AXES
Definition: in_win.c:33
joy_pitchsensitivity
cvar_t * joy_pitchsensitivity
Definition: in_win.c:78
Com_Printf
void Com_Printf(char *fmt,...)
Definition: common.c:104
FALSE
#define FALSE
Definition: stb_vorbis.c:618
IN_MouseMove
void IN_MouseMove(usercmd_t *cmd)
Definition: in_win.c:265
cls
client_static_t cls
Definition: cl_main.c:90
cl
client_state_t cl
Definition: cl_main.c:91
old_mouse_y
int old_mouse_y
Definition: in_win.c:122
joy_numbuttons
DWORD joy_numbuttons
Definition: in_win.c:88
Cvar_VariableValue
float Cvar_VariableValue(char *var_name)
Definition: cvar.c:63
in_strafe
kbutton_t in_strafe
Definition: cl_input.c:61