mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-25 16:20:05 +01:00
filter: simplify speed_factor()
The `speed_factor()` formula is unnecessarily complex, The behavior that is described in the comment can be achieved with a simple power function. And adjust the comment to explicitly state that 0.05 is the minimum.
This commit is contained in:
parent
74415b13fb
commit
9bb2136bab
1 changed files with 2 additions and 12 deletions
|
|
@ -113,26 +113,16 @@ accelerator_filter_touchpad(struct motion_filter *filter,
|
|||
|
||||
/* Maps the [-1, 1] speed setting into a constant acceleration
|
||||
* range. This isn't a linear scale, we keep 0 as the 'optimized'
|
||||
* mid-point and scale down to 0 for setting -1 and up to 5 for
|
||||
* mid-point and scale down to 0.05 for setting -1 and up to 5 for
|
||||
* setting 1. On the premise that if you want a faster cursor, it
|
||||
* doesn't matter as much whether you have 0.56789 or 0.56790,
|
||||
* but for lower settings it does because you may lose movements.
|
||||
* *shrug*.
|
||||
*
|
||||
* Magic numbers calculated by MyCurveFit.com, data points were
|
||||
* 0.0 0.0
|
||||
* 0.1 0.1 (because we need 4 points)
|
||||
* 1 1
|
||||
* 2 5
|
||||
*
|
||||
* This curve fits nicely into the range necessary.
|
||||
*/
|
||||
static inline double
|
||||
speed_factor(double s)
|
||||
{
|
||||
s += 1; /* map to [0, 2] */
|
||||
return 435837.2 + (0.04762636 - 435837.2)/(1 + pow(s/240.4549,
|
||||
2.377168));
|
||||
return pow(s + 1, 2.38) * 0.95 + 0.05;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue