Skip to content

Commit

Permalink
Use natural gyro sensitivity scale
Browse files Browse the repository at this point in the history
instead of multiplying m_yaw/m_pitch with
cl_yawspeed/cl_pitchspeed and a hardcoded
value of 1/60.

Note: in practice with default cvar values
the end result was quite close (184 vs 180
for yaw, 198 vs 180 for pitch).
  • Loading branch information
andrei-drexler committed Dec 28, 2023
1 parent cb80585 commit e03e7ca
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions Quake/in_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,7 @@ void IN_JoyMove (usercmd_t *cmd)

void IN_GyroMove(usercmd_t *cmd)
{
float scale;
if (!joy_enable.value)
return;

Expand All @@ -822,17 +823,9 @@ void IN_GyroMove(usercmd_t *cmd)
if (CL_InCutscene ())
return;

float gyroViewFactor = (1.0f / M_PI) * host_frametime/0.01666f;

if (gyro_yaw)
{
cl.viewangles[YAW] += m_yaw.value * gyro_yawsensitivity.value * cl_yawspeed.value * gyro_yaw * gyroViewFactor * gyro_dir;
}

if (gyro_pitch)
{
cl.viewangles[PITCH] -= m_pitch.value * gyro_pitchsensitivity.value * cl_pitchspeed.value * gyro_pitch * gyroViewFactor * gyro_dir;
}
scale = (180.f / M_PI) * gyro_dir * host_frametime;
cl.viewangles[YAW] += scale * gyro_yaw * gyro_yawsensitivity.value;
cl.viewangles[PITCH] -= scale * gyro_pitch * gyro_pitchsensitivity.value;

/* johnfitz -- variable pitch clamping */
if (cl.viewangles[PITCH] > cl_maxpitch.value)
Expand Down

0 comments on commit e03e7ca

Please sign in to comment.