From cdde44cd2afb69980a6b3e81201d0b9656a44c2b Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 13 Mar 2020 21:29:47 -0400 Subject: [PATCH] make m_accelerate_filter apply to all mouse acceleration, and turn it off by default. It should only be needed on "noisy" mice anyway, and that way it's easier to deal with in a game menu. --- cl_input.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cl_input.c b/cl_input.c index b3bf7b38..ed7c44c3 100644 --- a/cl_input.c +++ b/cl_input.c @@ -402,7 +402,7 @@ cvar_t m_filter = {CVAR_CLIENT | CVAR_SAVE, "m_filter","0", "smoothes mouse move cvar_t m_accelerate = {CVAR_CLIENT | CVAR_SAVE, "m_accelerate","1", "linear mouse acceleration factor (set to 1 to disable the linear acceleration and use only the power acceleration; set to 0 to disable all acceleration)"}; cvar_t m_accelerate_minspeed = {CVAR_CLIENT | CVAR_SAVE, "m_accelerate_minspeed","5000", "below this speed in px/s, no acceleration is done, with a linear slope between (applied only on linear acceleration)"}; cvar_t m_accelerate_maxspeed = {CVAR_CLIENT | CVAR_SAVE, "m_accelerate_maxspeed","10000", "above this speed in px/s, full acceleration is done, with a linear slope between (applied only on linear acceleration)"}; -cvar_t m_accelerate_filter = {CVAR_CLIENT | CVAR_SAVE, "m_accelerate_filter","0.1", "linear mouse acceleration factor filtering lowpass constant in seconds (applied only on linear acceleration)"}; +cvar_t m_accelerate_filter = {CVAR_CLIENT | CVAR_SAVE, "m_accelerate_filter","0", "linear mouse acceleration factor filtering lowpass constant in seconds (set to 0 for no filtering)"}; cvar_t m_accelerate_power_offset = {CVAR_CLIENT | CVAR_SAVE, "m_accelerate_power_offset","0", "below this speed in px/ms, no power acceleration is done"}; cvar_t m_accelerate_power = {CVAR_CLIENT | CVAR_SAVE, "m_accelerate_power","2", "acceleration power (must be above 1 to be useful)"}; cvar_t m_accelerate_power_senscap = {CVAR_CLIENT | CVAR_SAVE, "m_accelerate_power_senscap", "0", "maximum acceleration factor generated by power acceleration; use 0 for unbounded"}; @@ -549,6 +549,13 @@ void CL_Input (void) { float mouse_deltadist = sqrtf(in_mouse_x * in_mouse_x + in_mouse_y * in_mouse_y); float speed = mouse_deltadist / cl.realframetime; + static float averagespeed = 0; + float f, mi, ma; + if(m_accelerate_filter.value > 0) + f = bound(0, cl.realframetime / m_accelerate_filter.value, 1); + else + f = 1; + averagespeed = speed * f + averagespeed * (1 - f); // Note: this check is technically unnecessary, as everything in here cancels out if it is zero. if (m_accelerate.value != 1.0f) @@ -556,13 +563,6 @@ void CL_Input (void) // First do linear slope acceleration which was ripped "in // spirit" from many classic mouse driver implementations. // If m_accelerate.value == 1, this code does nothing at all. - static float averagespeed = 0; - float f, mi, ma; - if(m_accelerate_filter.value > 0) - f = bound(0, cl.realframetime / m_accelerate_filter.value, 1); - else - f = 1; - averagespeed = speed * f + averagespeed * (1 - f); mi = max(1, m_accelerate_minspeed.value); ma = max(m_accelerate_minspeed.value + 1, m_accelerate_maxspeed.value); @@ -593,7 +593,7 @@ void CL_Input (void) // sensitivity.value so that the later multiplication // restores it again. float accelsens = 1.0f; - float adjusted_speed_pxms = (speed * 0.001f - m_accelerate_power_offset.value) * m_accelerate_power_strength.value; + float adjusted_speed_pxms = (averagespeed * 0.001f - m_accelerate_power_offset.value) * m_accelerate_power_strength.value; float inv_sensitivity = 1.0f / sensitivity.value; if (adjusted_speed_pxms > 0) { @@ -605,7 +605,7 @@ void CL_Input (void) } else { - // The limit of the then-branch for m_accel_power -> 1. + // The limit of the then-branch for m_accelerate_power -> 1. accelsens += inv_sensitivity; // Note: QL had just accelsens = 1.0f. // This is mathematically wrong though. -- 2.39.2