From 9bb2136bab0ffc2211dc2108c4e43f6971846e13 Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Wed, 8 Feb 2023 10:56:48 +0000 Subject: 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. --- src/filter-touchpad.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/filter-touchpad.c b/src/filter-touchpad.c index c7e7ae9c..dcc2450d 100644 --- a/src/filter-touchpad.c +++ b/src/filter-touchpad.c @@ -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 -- cgit v1.2.1