Code:
/*
===========
Nicholas Steven Davila From the solar system of the Sun planet Earth (AKA: LiTHiuM/Imk0tter)
LiTHiuM's IN_MouseMove
===========
*/
#define PI 3.141592653589793
void IN_MouseMove(float frametime, usercmd_t* cmd)
{
int X, Y;
vec3_t viewangles;
gEngfuncs.GetViewAngles((float*)viewangles);
double CENTER_X = gEngfuncs.GetWindowCenterX();
double CENTER_Y = gEngfuncs.GetWindowCenterY();
// 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
if (!iMouseInUse && !g_iVisibleMouse && !iSpectator)
{
GetCursorPos(¤t_pos);
IN_ResetMouse();
X = ((current_pos.x) - CENTER_X);
Y = ((current_pos.y) - CENTER_Y);
if (m_filter->value)
{
//XVAL and YVAL are the number of radians
double INNER_CIRCLE_X = (X * PI) / CENTER_X;
double INNER_CIRCLE_Y = (Y * PI) / CENTER_Y;
double OUTER_CIRCLE_X = INNER_CIRCLE_X * 2;
double OUTER_CIRCLE_Y = INNER_CIRCLE_Y * 2;
mouse_x = OUTER_CIRCLE_X * CENTER_X * sensitivity->value;
mouse_y = OUTER_CIRCLE_Y * CENTER_Y * sensitivity->value;
}
else
{
mouse_x = X * (PI * sensitivity->value);
mouse_y = Y * (PI * sensitivity->value);
}
// 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)
{
V_StopPitchDrift();
}
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);
}