diff options
-rw-r--r-- | doc/client.txt | 8 | ||||
-rw-r--r-- | src/client/client.h | 1 | ||||
-rw-r--r-- | src/client/entities.c | 1 | ||||
-rw-r--r-- | src/client/input.c | 23 | ||||
-rw-r--r-- | src/client/view.c | 2 |
5 files changed, 27 insertions, 8 deletions
diff --git a/doc/client.txt b/doc/client.txt index b0973a3..6cbb2ed 100644 --- a/doc/client.txt +++ b/doc/client.txt @@ -840,10 +840,10 @@ in_smart_grab:: is up). m_autosens:: - When enabled, mouse sensitivity is scaled proportional to current player field - of view. When FOV is exactly 90, no scaling is applied. Higher FOV values will - scale sensitivity higher, lower FOV values will scale sensitivity lower. - Default value is 0 (scaling disabled). + Enables automatic scaling of mouse sensitivity proportional to the current + player field of view. Values between 90 and 179 specify the default FOV + value to scale sensitivity from. Zero disables automatic scaling. Any other + value assumes default FOV of 90 degrees. Default value is 0. m_accel:: Specifies mouse acceleration factor. Default value is 0 (acceleration diff --git a/src/client/client.h b/src/client/client.h index eaf8f87..f342383 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -223,6 +223,7 @@ typedef struct client_state_s { refdef_t refdef; float fov_x; // interpolated + float fov_y; // derived from fov_x assuming 4/3 aspect ratio int lightlevel; vec3_t v_forward, v_right, v_up; // set when refdef.angles is set diff --git a/src/client/entities.c b/src/client/entities.c index 2c79b3b..fc461b0 100644 --- a/src/client/entities.c +++ b/src/client/entities.c @@ -1193,6 +1193,7 @@ void CL_CalcViewValues(void) // interpolate field of view cl.fov_x = lerp_client_fov(ops->fov, ps->fov, lerp); + cl.fov_y = V_CalcFov(cl.fov_x, 4, 3); // don't interpolate blend color Vector4Copy(ps->blend, cl.refdef.blend); diff --git a/src/client/input.c b/src/client/input.c index f69523a..41f9b5f 100644 --- a/src/client/input.c +++ b/src/client/input.c @@ -552,6 +552,9 @@ static float CL_KeyState(kbutton_t *key) //========================================================================== +static float autosens_x; +static float autosens_y; + /* ================ CL_MouseMove @@ -596,9 +599,9 @@ static void CL_MouseMove(void) mx *= speed; my *= speed; - if (m_autosens->integer && cl.fov_x >= 1) { - mx *= cl.fov_x / 90.0f; - my *= V_CalcFov(cl.fov_x, 4, 3) / 73.739795291688f; + if (m_autosens->integer) { + mx *= cl.fov_x * autosens_x; + my *= cl.fov_y * autosens_y; } // add mouse X/Y movement @@ -746,6 +749,18 @@ void CL_UpdateCmd(int msec) cl.cmd.angles[2] = ANGLE2SHORT(cl.viewangles[2]); } +static void m_autosens_changed(cvar_t *self) +{ + float fov; + + if (self->value > 90.0f && self->value <= 179.0f) + fov = self->value; + else + fov = 90.0f; + + autosens_x = 1.0f / fov; + autosens_y = 1.0f / V_CalcFov(fov, 4, 3); +} /* ============ @@ -822,6 +837,8 @@ void CL_RegisterInput(void) m_filter = Cvar_Get("m_filter", "0", 0); m_accel = Cvar_Get("m_accel", "0", 0); m_autosens = Cvar_Get("m_autosens", "0", 0); + m_autosens->changed = m_autosens_changed; + m_autosens_changed(m_autosens); } /* diff --git a/src/client/view.c b/src/client/view.c index b9669e1..ed5b840 100644 --- a/src/client/view.c +++ b/src/client/view.c @@ -426,7 +426,7 @@ void V_RenderView(void) // adjust for non-4/3 screens if (cl_adjustfov->integer) { - cl.refdef.fov_y = V_CalcFov(cl.fov_x, 4, 3); + cl.refdef.fov_y = cl.fov_y; cl.refdef.fov_x = V_CalcFov(cl.refdef.fov_y, cl.refdef.height, cl.refdef.width); } else { cl.refdef.fov_x = cl.fov_x; |