/* ================ CL_AdjustAngles Moves the local angle positions ================ */ void CL_AdjustAngles ( float frametime, float *viewangles ) { float speed; float up, down; if (in_speed.state & 1) { speed = frametime * cl_anglespeedkey->value; } else { speed = frametime; } // Ricochet: Don't let them move the mouse when they're in spectator mode if ( bCanMoveMouse() == FALSE ) return; if (!(in_strafe.state & 1)) { viewangles[YAW] -= speed*cl_yawspeed->value*CL_KeyState (&in_right); viewangles[YAW] += speed*cl_yawspeed->value*CL_KeyState (&in_left); viewangles[YAW] = anglemod(viewangles[YAW]); } if (in_klook.state & 1) { V_StopPitchDrift (); viewangles[PITCH] -= speed*cl_pitchspeed->value * CL_KeyState (&in_forward); viewangles[PITCH] += speed*cl_pitchspeed->value * CL_KeyState (&in_back); } up = CL_KeyState (&in_lookup); down = CL_KeyState(&in_lookdown); viewangles[PITCH] -= speed*cl_pitchspeed->value * up; viewangles[PITCH] += speed*cl_pitchspeed->value * down; if (up || down) V_StopPitchDrift (); if (viewangles[PITCH] > cl_pitchdown->value) viewangles[PITCH] = cl_pitchdown->value; if (viewangles[PITCH] < -cl_pitchup->value) viewangles[PITCH] = -cl_pitchup->value; if (viewangles[ROLL] > 50) viewangles[ROLL] = 50; if (viewangles[ROLL] < -50) viewangles[ROLL] = -50; }
void IN_MouseMove ( float frametime, usercmd_t *cmd) { int mx, my; vec3_t viewangles; gEngfuncs.GetViewAngles( (float *)viewangles ); if ( in_mlook.state & 1) { V_StopPitchDrift (); } // Ricochet: Don't let them move the mouse when they're in spectator mode int iSpectator = !bCanMoveMouse(); //jjb - this disbles normal mouse control if the user is trying to // move the camera, or if the mouse cursor is visible or if we're in intermission if ( !iMouseInUse && !gHUD.m_iIntermission && !g_iVisibleMouse && !iSpectator ) { int deltaX, deltaY; SDL_GetRelativeMouseState( &deltaX, &deltaY ); current_pos.x = deltaX; current_pos.y = deltaY; mx = deltaX + mx_accum; my = deltaY + my_accum; mx_accum = 0; my_accum = 0; if (m_filter->value) { mouse_x = (mx + old_mouse_x) * 0.5; mouse_y = (my + old_mouse_y) * 0.5; } else { mouse_x = mx; mouse_y = my; } old_mouse_x = mx; old_mouse_y = my; // Apply custom mouse scaling/acceleration IN_ScaleMouse( &mouse_x, &mouse_y ); // add mouse X/Y movement to cmd if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) )) cmd->sidemove += m_side->value * mouse_x; else viewangles[YAW] -= m_yaw->value * mouse_x; if ( (in_mlook.state & 1) && !(in_strafe.state & 1)) { viewangles[PITCH] += m_pitch->value * mouse_y; if (viewangles[PITCH] > cl_pitchdown->value) viewangles[PITCH] = cl_pitchdown->value; if (viewangles[PITCH] < -cl_pitchup->value) viewangles[PITCH] = -cl_pitchup->value; } else { if ((in_strafe.state & 1) && gEngfuncs.IsNoClipping() ) { cmd->upmove -= m_forward->value * mouse_y; } else { cmd->forwardmove -= m_forward->value * mouse_y; } } // if the mouse has moved, force it to the center, so there's room to move if ( mx || my ) { IN_ResetMouse(); } } gEngfuncs.SetViewAngles( (float *)viewangles ); /* //#define TRACE_TEST #if defined( TRACE_TEST ) { int mx, my; void V_Move( int mx, int my ); IN_GetMousePos( &mx, &my ); V_Move( mx, my ); } #endif */ }