diff --git a/src/filter.c b/src/filter.c index 206695bb..b502d8b2 100644 --- a/src/filter.c +++ b/src/filter.c @@ -827,73 +827,25 @@ touchpad_accel_profile_linear(struct motion_filter *filter, struct pointer_accelerator *accel_filter = (struct pointer_accelerator *)filter; const double max_accel = accel_filter->accel; /* unitless factor */ - const double threshold = accel_filter->threshold; /* units/us */ - const double incline = accel_filter->incline; double factor; /* unitless */ /* Convert to mm/s because that's something one can understand */ speed_in = v_us2s(speed_in) * 25.4/accel_filter->dpi; - /* - Our acceleration function calculates a factor to accelerate input - deltas with. The function is a double incline with a plateau, - with a rough shape like this: - - accel - factor - ^ - | / - | _____/ - | / - |/ - +-------------> speed in - - The two inclines are linear functions in the form - y = ax + b - where y is speed_out - x is speed_in - a is the incline of acceleration - b is minimum acceleration factor - - for speeds up to the lower threshold, we decelerate, down to 30% - of input speed. - hence 1 = a * 7 + 0.3 - 0.7 = a * 7 => a := 0.1 - deceleration function is thus: - y = 0.1x + 0.3 + /* All constants below are based on touchpad accel profile characterization */ + double x_factor = 0.003738 + 0.003058 * filter->speed_adjustment; + double power = 1.3 + 0.2 * filter->speed_adjustment; + factor = 2.2 * pow(speed_in * x_factor, power); - Note: - * The minimum threshold is a result of trial-and-error and - has no other intrinsic meaning. - * 0.3 is chosen simply because it is above the Nyquist frequency - for subpixel motion within a pixel. - */ - if (speed_in < 7.0) { - factor = 0.1 * speed_in + 0.3; - /* up to the threshold, we keep factor 1, i.e. 1:1 movement */ - } else if (speed_in < threshold) { - factor = 1; - } else { - /* Acceleration function above the threshold: - y = ax' + b - where T is threshold - x is speed_in - x' is speed - and - y(T) == 1 - hence 1 = ax' + 1 - => x' := (x - T) - */ - factor = incline * (speed_in - threshold) + 1; + /* Mininum factor for slow speeds */ + if (factor < 0.17) { + factor = 0.17; } - + /* Cap at the maximum acceleration factor */ factor = min(max_accel, factor); - /* Scale everything depending on the acceleration set */ - factor *= 1 + 0.5 * filter->speed_adjustment; - - return factor * TP_MAGIC_SLOWDOWN; + return factor; } double