Advertisement
imk0tter

Untitled

Apr 4th, 2024
792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.30 KB | None | 0 0
  1. void IN_MouseMove ( float frametime, usercmd_t *cmd)
  2. {
  3.     int     mx, my;
  4.     vec3_t viewangles;
  5.  
  6.     double mouse_x2, mouse_y2;
  7.  
  8.     gEngfuncs.GetViewAngles( (float *)viewangles );
  9.  
  10.     // Ricochet: Don't let them move the mouse when they're in spectator mode
  11.     int iSpectator = !bCanMoveMouse();
  12.  
  13.     //jjb - this disbles normal mouse control if the user is trying to
  14.     //      move the camera
  15.     if ( !iMouseInUse && !g_iVisibleMouse && !iSpectator )
  16.     {
  17.         GetCursorPos (&current_pos);
  18.         IN_ResetMouse();
  19.  
  20.         mx = (current_pos.x - gEngfuncs.GetWindowCenterX());
  21.         my = (current_pos.y - gEngfuncs.GetWindowCenterY());
  22.         if (cl_acceleration->value == 0)
  23.         {
  24.                 mouse_x2 = TRANSFORM_ORB_PIXELS_TO_DEGREES(mx, SCREEN_WIDTH, gHUD.m_iFOV, sensitivity->value);
  25.                 mouse_y2 = TRANSFORM_ORB_PIXELS_TO_DEGREES(my, SCREEN_HEIGHT, gHUD.m_iFOV, sensitivity->value);
  26.         }
  27.         else
  28.         {
  29.                 mouse_x2 = mx == 0 ? 0 : TRANSDUCE_PIXELS_TO_DEGREES(mx, SCREEN_WIDTH, gHUD.m_iFOV, sensitivity->value);
  30.                 mouse_y2 = my == 0 ? 0 : TRANSDUCE_PIXELS_TO_DEGREES(my, SCREEN_HEIGHT, gHUD.m_iFOV, sensitivity->value);
  31.         }
  32.         // add mouse X/Y movement to cmd
  33.         if ((in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1)))
  34.         {
  35.             cmd->sidemove += mouse_x2;
  36.             //cmd->sidemove += m_side->value * mouse_x;
  37.         }
  38.         else
  39.         {
  40.             viewangles[YAW] -= mouse_x2;
  41.             //viewangles[YAW] -= m_yaw->value * mouse_x;
  42.         }
  43.         if ( in_mlook.state & 1)
  44.         {
  45.             V_StopPitchDrift ();
  46.         }
  47.        
  48.         if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
  49.         {
  50.             viewangles[PITCH] += mouse_y2;
  51.  
  52.             //viewangles[PITCH] += m_pitch->value * mouse_y;
  53.             if (viewangles[PITCH] > cl_pitchdown->value)
  54.             {
  55.                 viewangles[PITCH] = cl_pitchdown->value;
  56.             }
  57.             if (viewangles[PITCH] < -cl_pitchup->value)
  58.             {
  59.                 viewangles[PITCH] = -cl_pitchup->value;
  60.             }
  61.         }
  62.         else
  63.         {
  64.             if ((in_strafe.state & 1) && gEngfuncs.IsNoClipping() )
  65.             {
  66.                 cmd->upmove -= mouse_y2;
  67.                 //cmd->upmove -= m_forward->value * mouse_y;
  68.             }
  69.             else
  70.             {
  71.                 cmd->forwardmove -= mouse_y2;
  72.                 //cmd->forwardmove -= m_forward->value * mouse_y;
  73.             }
  74.         }
  75.     }
  76.  
  77.     gEngfuncs.SetViewAngles( (float *)viewangles );
  78.  
  79. /*
  80. //#define TRACE_TEST
  81. #if defined( TRACE_TEST )
  82.     {
  83.         int mx, my;
  84.         void V_Move( int mx, int my );
  85.         IN_GetMousePos( &mx, &my );
  86.         V_Move( mx, my );
  87.     }
  88. #endif
  89. */
  90. }
  91.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement