icculus quake2 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, 1}
 
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 30 of file in_win.c.

◆ JOY_AXIS_R

#define JOY_AXIS_R   3

Definition at line 36 of file in_win.c.

◆ JOY_AXIS_U

#define JOY_AXIS_U   4

Definition at line 37 of file in_win.c.

◆ JOY_AXIS_V

#define JOY_AXIS_V   5

Definition at line 38 of file in_win.c.

◆ JOY_AXIS_X

#define JOY_AXIS_X   0

Definition at line 33 of file in_win.c.

◆ JOY_AXIS_Y

#define JOY_AXIS_Y   1

Definition at line 34 of file in_win.c.

◆ JOY_AXIS_Z

#define JOY_AXIS_Z   2

Definition at line 35 of file in_win.c.

◆ JOY_MAX_AXES

#define JOY_MAX_AXES   6

Definition at line 32 of file in_win.c.

◆ JOY_RELATIVE_AXIS

#define JOY_RELATIVE_AXIS   0x00000010

Definition at line 31 of file in_win.c.

Enumeration Type Documentation

◆ _ControlList

Enumerator
AxisNada 
AxisForward 
AxisLook 
AxisSide 
AxisTurn 
AxisUp 

Definition at line 40 of file in_win.c.

41 {
43 };

Function Documentation

◆ IN_Activate()

void IN_Activate ( qboolean  active)

Definition at line 406 of file in_win.c.

407 {
408  in_appactive = active;
409  mouseactive = !active; // force a new window check or turn off
410 }

Referenced by AppActivate(), and MainWndProc().

◆ IN_ActivateMouse()

void IN_ActivateMouse ( void  )

Definition at line 143 of file in_win.c.

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

Referenced by IN_Frame().

◆ IN_ClearStates()

void IN_ClearStates ( void  )

Definition at line 465 of file in_win.c.

466 {
467  mx_accum = 0;
468  my_accum = 0;
470 }

◆ IN_Commands()

void IN_Commands ( void  )

Definition at line 654 of file in_win.c.

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

Referenced by CL_SendCommand().

◆ IN_DeactivateMouse()

void IN_DeactivateMouse ( void  )

Definition at line 197 of file in_win.c.

198 {
199  if (!mouseinitialized)
200  return;
201  if (!mouseactive)
202  return;
203 
204  if (restore_spi)
205  SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0);
206 
207  mouseactive = false;
208 
209  ClipCursor (NULL);
210  ReleaseCapture ();
211  while (ShowCursor (TRUE) < 0)
212  ;
213 }

Referenced by IN_Frame(), and IN_Shutdown().

◆ IN_Frame()

void IN_Frame ( void  )

Definition at line 420 of file in_win.c.

421 {
422  if (!mouseinitialized)
423  return;
424 
425  if (!in_mouse || !in_appactive)
426  {
428  return;
429  }
430 
431  if ( !cl.refresh_prepped
432  || cls.key_dest == key_console
433  || cls.key_dest == key_menu)
434  {
435  // temporarily deactivate if in fullscreen
436  if (Cvar_VariableValue ("vid_fullscreen") == 0)
437  {
439  return;
440  }
441  }
442 
443  IN_ActivateMouse ();
444 }

Referenced by CL_Frame().

◆ IN_Init()

void IN_Init ( void  )

Definition at line 346 of file in_win.c.

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

Referenced by CL_Init().

◆ IN_JoyMove()

void IN_JoyMove ( usercmd_t cmd)

Definition at line 752 of file in_win.c.

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

Referenced by IN_Move().

◆ IN_MLookDown()

void IN_MLookDown ( void  )

Definition at line 111 of file in_win.c.

111 { mlooking = true; }

Referenced by IN_Init().

◆ IN_MLookUp()

void IN_MLookUp ( void  )

Definition at line 112 of file in_win.c.

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

Referenced by IN_Init().

◆ IN_MouseEvent()

void IN_MouseEvent ( int  mstate)

Definition at line 240 of file in_win.c.

241 {
242  int i;
243 
244  if (!mouseinitialized)
245  return;
246 
247 // perform button actions
248  for (i=0 ; i<mouse_buttons ; i++)
249  {
250  if ( (mstate & (1<<i)) &&
251  !(mouse_oldbuttonstate & (1<<i)) )
252  {
253  Key_Event (K_MOUSE1 + i, true, sys_msg_time);
254  }
255 
256  if ( !(mstate & (1<<i)) &&
257  (mouse_oldbuttonstate & (1<<i)) )
258  {
259  Key_Event (K_MOUSE1 + i, false, sys_msg_time);
260  }
261  }
262 
263  mouse_oldbuttonstate = mstate;
264 }

Referenced by MainWndProc().

◆ IN_MouseMove()

void IN_MouseMove ( usercmd_t cmd)

Definition at line 272 of file in_win.c.

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

Referenced by IN_Move().

◆ IN_Move()

void IN_Move ( usercmd_t cmd)

Definition at line 451 of file in_win.c.

452 {
453  IN_MouseMove (cmd);
454 
455  if (ActiveApp)
456  IN_JoyMove (cmd);
457 }

Referenced by CL_CreateCmd().

◆ IN_ReadJoystick()

qboolean IN_ReadJoystick ( void  )

Definition at line 724 of file in_win.c.

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

Referenced by IN_JoyMove().

◆ IN_Shutdown()

void IN_Shutdown ( void  )

Definition at line 391 of file in_win.c.

392 {
394 }

Referenced by CL_Shutdown().

◆ IN_StartupJoystick()

void IN_StartupJoystick ( void  )

Definition at line 486 of file in_win.c.

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

Referenced by IN_Init().

◆ IN_StartupMouse()

void IN_StartupMouse ( void  )

Definition at line 222 of file in_win.c.

223 {
224  cvar_t *cv;
225 
226  cv = Cvar_Get ("in_initmouse", "1", CVAR_NOSET);
227  if ( !cv->value )
228  return;
229 
230  mouseinitialized = true;
231  mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0);
232  mouse_buttons = 3;
233 }

Referenced by IN_Init().

◆ Joy_AdvancedUpdate_f()

void Joy_AdvancedUpdate_f ( void  )

Definition at line 582 of file in_win.c.

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

Referenced by IN_Init(), and IN_JoyMove().

◆ RawValuePointer()

PDWORD RawValuePointer ( int  axis)

Definition at line 557 of file in_win.c.

558 {
559  switch (axis)
560  {
561  case JOY_AXIS_X:
562  return &ji.dwXpos;
563  case JOY_AXIS_Y:
564  return &ji.dwYpos;
565  case JOY_AXIS_Z:
566  return &ji.dwZpos;
567  case JOY_AXIS_R:
568  return &ji.dwRpos;
569  case JOY_AXIS_U:
570  return &ji.dwUpos;
571  case JOY_AXIS_V:
572  return &ji.dwVpos;
573  }
574 }

Referenced by Joy_AdvancedUpdate_f().

Variable Documentation

◆ current_pos

POINT current_pos

Definition at line 120 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 45 of file in_win.c.

Referenced by Joy_AdvancedUpdate_f().

◆ dwAxisMap

DWORD dwAxisMap[JOY_MAX_AXES]

Definition at line 50 of file in_win.c.

Referenced by IN_JoyMove(), and Joy_AdvancedUpdate_f().

◆ dwControlMap

DWORD dwControlMap[JOY_MAX_AXES]

Definition at line 51 of file in_win.c.

Referenced by IN_JoyMove(), and Joy_AdvancedUpdate_f().

◆ in_appactive

qboolean in_appactive

Definition at line 91 of file in_win.c.

Referenced by IN_Activate(), and IN_Frame().

◆ in_joystick

cvar_t* in_joystick

Definition at line 55 of file in_win.c.

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

◆ in_mouse

cvar_t* in_mouse

Definition at line 54 of file in_win.c.

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

◆ ji

JOYINFOEX ji
static

Definition at line 89 of file in_win.c.

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

◆ joy_advanced

cvar_t* joy_advanced

Definition at line 64 of file in_win.c.

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

◆ joy_advancedinit

qboolean joy_advancedinit

Definition at line 82 of file in_win.c.

Referenced by IN_JoyMove(), and IN_StartupJoystick().

◆ joy_advaxisr

cvar_t* joy_advaxisr

Definition at line 68 of file in_win.c.

Referenced by IN_Init(), and Joy_AdvancedUpdate_f().

◆ joy_advaxisu

cvar_t* joy_advaxisu

Definition at line 69 of file in_win.c.

Referenced by IN_Init(), and Joy_AdvancedUpdate_f().

◆ joy_advaxisv

cvar_t* joy_advaxisv

Definition at line 70 of file in_win.c.

Referenced by IN_Init(), and Joy_AdvancedUpdate_f().

◆ joy_advaxisx

cvar_t* joy_advaxisx

Definition at line 65 of file in_win.c.

Referenced by IN_Init(), and Joy_AdvancedUpdate_f().

◆ joy_advaxisy

cvar_t* joy_advaxisy

Definition at line 66 of file in_win.c.

Referenced by IN_Init(), and Joy_AdvancedUpdate_f().

◆ joy_advaxisz

cvar_t* joy_advaxisz

Definition at line 67 of file in_win.c.

Referenced by IN_Init(), and Joy_AdvancedUpdate_f().

◆ joy_avail

qboolean joy_avail

Definition at line 82 of file in_win.c.

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

◆ joy_flags

DWORD joy_flags

Definition at line 86 of file in_win.c.

Referenced by IN_ReadJoystick(), and Joy_AdvancedUpdate_f().

◆ joy_forwardsensitivity

cvar_t* joy_forwardsensitivity

Definition at line 75 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_forwardthreshold

cvar_t* joy_forwardthreshold

Definition at line 71 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_haspov

qboolean joy_haspov

Definition at line 82 of file in_win.c.

Referenced by IN_Commands(), and IN_StartupJoystick().

◆ joy_id

int joy_id

Definition at line 85 of file in_win.c.

Referenced by IN_ReadJoystick(), and IN_StartupJoystick().

◆ joy_name

cvar_t* joy_name

Definition at line 63 of file in_win.c.

Referenced by IN_Init(), and Joy_AdvancedUpdate_f().

◆ joy_numbuttons

DWORD joy_numbuttons

Definition at line 87 of file in_win.c.

Referenced by IN_Commands(), and IN_StartupJoystick().

◆ joy_oldbuttonstate

DWORD joy_oldbuttonstate

Definition at line 83 of file in_win.c.

Referenced by IN_Commands(), and IN_StartupJoystick().

◆ joy_oldpovstate

DWORD joy_oldpovstate

Definition at line 83 of file in_win.c.

Referenced by IN_Commands(), and IN_StartupJoystick().

◆ joy_pitchsensitivity

cvar_t* joy_pitchsensitivity

Definition at line 77 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_pitchthreshold

cvar_t* joy_pitchthreshold

Definition at line 73 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_sidesensitivity

cvar_t* joy_sidesensitivity

Definition at line 76 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_sidethreshold

cvar_t* joy_sidethreshold

Definition at line 72 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_upsensitivity

cvar_t* joy_upsensitivity

Definition at line 80 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_upthreshold

cvar_t* joy_upthreshold

Definition at line 79 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_yawsensitivity

cvar_t* joy_yawsensitivity

Definition at line 78 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ joy_yawthreshold

cvar_t* joy_yawthreshold

Definition at line 74 of file in_win.c.

Referenced by IN_Init(), and IN_JoyMove().

◆ m_filter

cvar_t* m_filter

Definition at line 107 of file in_win.c.

Referenced by IN_Init(), and IN_MouseMove().

◆ mlooking

qboolean mlooking

Definition at line 109 of file in_win.c.

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

◆ mouse_buttons

int mouse_buttons

Definition at line 118 of file in_win.c.

Referenced by IN_MouseEvent(), and IN_StartupMouse().

◆ mouse_oldbuttonstate

int mouse_oldbuttonstate

Definition at line 119 of file in_win.c.

Referenced by IN_ClearStates(), and IN_MouseEvent().

◆ mouse_x

int mouse_x

Definition at line 121 of file in_win.c.

Referenced by IN_MouseMove().

◆ mouse_y

int mouse_y

Definition at line 121 of file in_win.c.

Referenced by IN_MouseMove().

◆ mouseactive

qboolean mouseactive

Definition at line 125 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 130 of file in_win.c.

Referenced by IN_ActivateMouse(), and IN_StartupMouse().

◆ mx_accum

int mx_accum

Definition at line 121 of file in_win.c.

Referenced by IN_ClearStates().

◆ my_accum

int my_accum

Definition at line 121 of file in_win.c.

Referenced by IN_ClearStates().

◆ newmouseparms

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

Definition at line 129 of file in_win.c.

Referenced by IN_ActivateMouse().

◆ old_mouse_x

int old_mouse_x

Definition at line 121 of file in_win.c.

Referenced by IN_MouseMove().

◆ old_mouse_y

int old_mouse_y

Definition at line 121 of file in_win.c.

Referenced by IN_MouseMove().

◆ old_x

int old_x

Definition at line 123 of file in_win.c.

Referenced by IN_ActivateMouse().

◆ old_y

int old_y

Definition at line 123 of file in_win.c.

Referenced by IN_ActivateMouse().

◆ originalmouseparms

int originalmouseparms[3]

Definition at line 129 of file in_win.c.

Referenced by IN_DeactivateMouse(), and IN_StartupMouse().

◆ pdwRawValue

PDWORD pdwRawValue[JOY_MAX_AXES]

Definition at line 52 of file in_win.c.

Referenced by IN_JoyMove(), and Joy_AdvancedUpdate_f().

◆ restore_spi

qboolean restore_spi

Definition at line 127 of file in_win.c.

Referenced by IN_ActivateMouse(), and IN_DeactivateMouse().

◆ sys_msg_time

unsigned sys_msg_time

Definition at line 47 of file sys_win.c.

Referenced by IN_MouseEvent().

◆ v_centermove

cvar_t* v_centermove

Definition at line 337 of file in_win.c.

Referenced by IN_Init().

◆ v_centerspeed

cvar_t* v_centerspeed

Definition at line 338 of file in_win.c.

Referenced by IN_Init().

◆ window_center_x

int window_center_x

Definition at line 132 of file in_win.c.

Referenced by IN_ActivateMouse(), and IN_MouseMove().

◆ window_center_y

int window_center_y

Definition at line 132 of file in_win.c.

Referenced by IN_ActivateMouse(), and IN_MouseMove().

◆ window_rect

RECT window_rect

Definition at line 133 of file in_win.c.

Referenced by IN_ActivateMouse().

sensitivity
cvar_t * sensitivity
Definition: cl_main.c:80
IN_MLookUp
void IN_MLookUp(void)
Definition: in_win.c:112
dwAxisMap
DWORD dwAxisMap[JOY_MAX_AXES]
Definition: in_win.c:50
height
GLsizei height
Definition: qgl_win.c:69
IN_JoyMove
void IN_JoyMove(usercmd_t *cmd)
Definition: in_win.c:752
dwAxisFlags
DWORD dwAxisFlags[JOY_MAX_AXES]
Definition: in_win.c:45
YAW
#define YAW
Definition: q_shared.h:66
JOY_ABSOLUTE_AXIS
#define JOY_ABSOLUTE_AXIS
Definition: in_win.c:30
joy_id
int joy_id
Definition: in_win.c:85
old_y
int old_y
Definition: in_win.c:123
ActiveApp
int ActiveApp
Definition: sys_win.c:42
CVAR_NOSET
#define CVAR_NOSET
Definition: q_shared.h:312
kbutton_t::state
int state
Definition: client.h:558
AxisNada
@ AxisNada
Definition: in_win.c:42
v_centerspeed
cvar_t * v_centerspeed
Definition: in_win.c:338
dwControlMap
DWORD dwControlMap[JOY_MAX_AXES]
Definition: in_win.c:51
cl_run
cvar_t * cl_run
Definition: cl_input.c:229
in_speed
kbutton_t in_speed
Definition: cl_input.c:60
Key_Event
void Key_Event(int key, qboolean down, unsigned time)
Definition: keys.c:745
joy_forwardsensitivity
cvar_t * joy_forwardsensitivity
Definition: in_win.c:75
IN_StartupJoystick
void IN_StartupJoystick(void)
Definition: in_win.c:486
joy_avail
qboolean joy_avail
Definition: in_win.c:82
joy_name
cvar_t * joy_name
Definition: in_win.c:63
old_x
int old_x
Definition: in_win.c:123
joy_advaxisr
cvar_t * joy_advaxisr
Definition: in_win.c:68
cl_upspeed
cvar_t * cl_upspeed
Definition: cl_input.c:222
joy_sidesensitivity
cvar_t * joy_sidesensitivity
Definition: in_win.c:76
window_center_y
int window_center_y
Definition: in_win.c:132
joy_oldpovstate
DWORD joy_oldpovstate
Definition: in_win.c:83
m_side
cvar_t * m_side
Definition: cl_main.c:85
originalmouseparms
int originalmouseparms[3]
Definition: in_win.c:129
cvar_s::string
char * string
Definition: q_shared.h:320
in_mouse
cvar_t * in_mouse
Definition: in_win.c:54
client_state_t::viewangles
vec3_t viewangles
Definition: client.h:145
cl_sidespeed
cvar_t * cl_sidespeed
Definition: cl_input.c:224
my_accum
int my_accum
Definition: in_win.c:121
JOY_AXIS_R
#define JOY_AXIS_R
Definition: in_win.c:36
i
int i
Definition: q_shared.c:305
IN_DeactivateMouse
void IN_DeactivateMouse(void)
Definition: in_win.c:197
mouse_x
int mouse_x
Definition: in_win.c:121
joy_flags
DWORD joy_flags
Definition: in_win.c:86
joy_upsensitivity
cvar_t * joy_upsensitivity
Definition: in_win.c:80
mlooking
qboolean mlooking
Definition: in_win.c:109
m_forward
cvar_t * m_forward
Definition: cl_main.c:84
RawValuePointer
PDWORD RawValuePointer(int axis)
Definition: in_win.c:557
PITCH
#define PITCH
Definition: q_shared.h:65
joy_oldbuttonstate
DWORD joy_oldbuttonstate
Definition: in_win.c:83
width
GLint GLsizei width
Definition: qgl_win.c:115
Joy_AdvancedUpdate_f
void Joy_AdvancedUpdate_f(void)
Definition: in_win.c:582
JOY_AXIS_X
#define JOY_AXIS_X
Definition: in_win.c:33
usercmd_s::forwardmove
short forwardmove
Definition: q_shared.h:518
joy_pitchthreshold
cvar_t * joy_pitchthreshold
Definition: in_win.c:73
JOY_AXIS_Z
#define JOY_AXIS_Z
Definition: in_win.c:35
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:74
cvar_s
Definition: q_shared.h:317
cl_yawspeed
cvar_t * cl_yawspeed
Definition: cl_input.c:226
key_menu
@ key_menu
Definition: client.h:220
window_center_x
int window_center_x
Definition: in_win.c:132
AxisUp
@ AxisUp
Definition: in_win.c:42
JOY_RELATIVE_AXIS
#define JOY_RELATIVE_AXIS
Definition: in_win.c:31
freelook
cvar_t * freelook
Definition: cl_main.c:24
joy_sidethreshold
cvar_t * joy_sidethreshold
Definition: in_win.c:72
K_AUX29
@ K_AUX29
Definition: keys.h:125
restore_spi
qboolean restore_spi
Definition: in_win.c:127
AxisLook
@ AxisLook
Definition: in_win.c:42
IN_MLookDown
void IN_MLookDown(void)
Definition: in_win.c:111
in_joystick
cvar_t * in_joystick
Definition: in_win.c:55
joy_yawsensitivity
cvar_t * joy_yawsensitivity
Definition: in_win.c:78
joy_haspov
qboolean joy_haspov
Definition: in_win.c:82
usercmd_s::sidemove
short sidemove
Definition: q_shared.h:518
IN_ReadJoystick
qboolean IN_ReadJoystick(void)
Definition: in_win.c:724
current_pos
POINT current_pos
Definition: in_win.c:120
JOY_AXIS_U
#define JOY_AXIS_U
Definition: in_win.c:37
cl_forwardspeed
cvar_t * cl_forwardspeed
Definition: cl_input.c:223
JOY_AXIS_V
#define JOY_AXIS_V
Definition: in_win.c:38
JOY_AXIS_Y
#define JOY_AXIS_Y
Definition: in_win.c:34
K_JOY1
@ K_JOY1
Definition: keys.h:88
joy_advaxisx
cvar_t * joy_advaxisx
Definition: in_win.c:65
newmouseparms
int newmouseparms[3]
Definition: in_win.c:129
mouseparmsvalid
qboolean mouseparmsvalid
Definition: in_win.c:130
old_mouse_x
int old_mouse_x
Definition: in_win.c:121
pdwRawValue
PDWORD pdwRawValue[JOY_MAX_AXES]
Definition: in_win.c:52
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:118
v_centermove
cvar_t * v_centermove
Definition: in_win.c:337
m_yaw
cvar_t * m_yaw
Definition: cl_main.c:83
AxisForward
@ AxisForward
Definition: in_win.c:42
lookspring
cvar_t * lookspring
Definition: cl_main.c:78
CVAR_ARCHIVE
#define CVAR_ARCHIVE
Definition: q_shared.h:309
cl_hwnd
HWND cl_hwnd
Definition: vid_dll.c:53
mouse_buttons
int mouse_buttons
Definition: in_win.c:118
lookstrafe
cvar_t * lookstrafe
Definition: cl_main.c:79
cvar_s::value
float value
Definition: q_shared.h:324
joy_advaxisy
cvar_t * joy_advaxisy
Definition: in_win.c:66
mouseactive
qboolean mouseactive
Definition: in_win.c:125
key_console
@ key_console
Definition: client.h:220
NULL
#define NULL
Definition: q_shared.h:60
joy_advaxisv
cvar_t * joy_advaxisv
Definition: in_win.c:70
AxisSide
@ AxisSide
Definition: in_win.c:42
window_rect
RECT window_rect
Definition: in_win.c:133
mouse_oldbuttonstate
int mouse_oldbuttonstate
Definition: in_win.c:119
K_AUX1
@ K_AUX1
Definition: keys.h:97
usercmd_s::upmove
short upmove
Definition: q_shared.h:518
joy_advaxisz
cvar_t * joy_advaxisz
Definition: in_win.c:67
mx_accum
int mx_accum
Definition: in_win.c:121
in_appactive
qboolean in_appactive
Definition: in_win.c:91
joy_upthreshold
cvar_t * joy_upthreshold
Definition: in_win.c:79
IN_StartupMouse
void IN_StartupMouse(void)
Definition: in_win.c:222
m_filter
cvar_t * m_filter
Definition: in_win.c:107
m_pitch
cvar_t * m_pitch
Definition: cl_main.c:82
joy_advancedinit
qboolean joy_advancedinit
Definition: in_win.c:82
sys_msg_time
unsigned sys_msg_time
Definition: sys_win.c:47
IN_ActivateMouse
void IN_ActivateMouse(void)
Definition: in_win.c:143
cl_pitchspeed
cvar_t * cl_pitchspeed
Definition: cl_input.c:227
client_static_t::frametime
float frametime
Definition: client.h:229
ji
static JOYINFOEX ji
Definition: in_win.c:89
mouseinitialized
qboolean mouseinitialized
Definition: in_win.c:128
joy_advaxisu
cvar_t * joy_advaxisu
Definition: in_win.c:69
joy_forwardthreshold
cvar_t * joy_forwardthreshold
Definition: in_win.c:71
mouse_y
int mouse_y
Definition: in_win.c:121
AxisTurn
@ AxisTurn
Definition: in_win.c:42
IN_CenterView
void IN_CenterView(void)
Definition: cl_input.c:403
joy_advanced
cvar_t * joy_advanced
Definition: in_win.c:64
client_static_t::key_dest
keydest_t key_dest
Definition: client.h:225
DWORD
DWORD
Definition: qgl_win.c:49
JOY_MAX_AXES
#define JOY_MAX_AXES
Definition: in_win.c:32
joy_pitchsensitivity
cvar_t * joy_pitchsensitivity
Definition: in_win.c:77
Com_Printf
void Com_Printf(char *fmt,...)
Definition: common.c:102
IN_MouseMove
void IN_MouseMove(usercmd_t *cmd)
Definition: in_win.c:272
cls
client_static_t cls
Definition: cl_main.c:105
K_MOUSE1
@ K_MOUSE1
Definition: keys.h:79
cl
client_state_t cl
Definition: cl_main.c:106
old_mouse_y
int old_mouse_y
Definition: in_win.c:121
joy_numbuttons
DWORD joy_numbuttons
Definition: in_win.c:87
Cvar_VariableValue
float Cvar_VariableValue(char *var_name)
Definition: cvar.c:63
in_strafe
kbutton_t in_strafe
Definition: cl_input.c:60