From f2dfbc0b826db5e451bc25cae44b07e3b9c827f1 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 4 Jul 2014 12:52:04 +1000 Subject: [PATCH] filter: drop delta-softening MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit I doubt this does what we think it does. It doesn't soften the delta changes, rather it introduces bumps in the smooth processing of the changes. abs(delta) below 1.0 is untouched, and abs(delta) beyond 3 or 4 isn't noticable much. But in the slow range around the 1/-1 mark there is a bump. For example, if our last_delta is 1.0 and delta is 1.1, the "softened" delta is set to 0.6. That is stored as last delta, so an input sequence of: 0.8, 0.9, 1.0, 1.1, 1.2, 1.0, 0.8, 1.1 results in "softened" deltas that don't match the input: 0.8, 0.9, 1.0, 0.6, 0.7, 1.0, 0.8, 0.6 A better approach at smoothing this out would be to calculate the softened as: current = current ± diff(last, current) * 0.5 or even weighted towards the new delta current = current ± diff(last, current) * 0.25 In tests, this makes little difference. Dropping this function altogether is sufficient to make the pointer pointer behave slightly better at low speeds though the increase is small enough to attribute to confirmation bias. Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/filter.c | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/filter.c b/src/filter.c index 51cc0e92..1762f98a 100644 --- a/src/filter.c +++ b/src/filter.c @@ -257,27 +257,6 @@ calculate_acceleration(struct pointer_accelerator *accel, return factor; } -static double -soften_delta(double last_delta, double delta) -{ - if (delta < -1.0 || delta > 1.0) { - if (delta > last_delta) - return delta - 0.5; - else if (delta < last_delta) - return delta + 0.5; - } - - return delta; -} - -static void -apply_softening(struct pointer_accelerator *accel, - struct motion_params *motion) -{ - motion->dx = soften_delta(accel->last_dx, motion->dx); - motion->dy = soften_delta(accel->last_dy, motion->dy); -} - static void accelerator_filter(struct motion_filter *filter, struct motion_params *motion, @@ -295,8 +274,6 @@ accelerator_filter(struct motion_filter *filter, motion->dx = accel_value * motion->dx; motion->dy = accel_value * motion->dy; - apply_softening(accel, motion); - accel->last_dx = motion->dx; accel->last_dy = motion->dy; -- 2.34.1