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"};
{
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)
// 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);
// 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)
{
}
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.