From: Peter Hutterer Date: Mon, 17 Aug 2015 23:11:48 +0000 (+1000) Subject: filter: move the TP_MAGIC_SLOWDOWN to a single definition X-Git-Tag: 0.99.1~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e4fd60ce5ef0f634ecbc3c445b5a05acee66a09d;p=platform%2Fupstream%2Flibinput.git filter: move the TP_MAGIC_SLOWDOWN to a single definition Requires splitting out the X230 one so we don't accidentally break things if we ever change this. Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- diff --git a/src/filter.c b/src/filter.c index d05b53ad..f92b9fdc 100644 --- a/src/filter.c +++ b/src/filter.c @@ -36,6 +36,12 @@ #include "libinput-util.h" #include "filter-private.h" +/* Once normalized, touchpads see the same acceleration as mice. that is + * technically correct but subjectively wrong, we expect a touchpad to be a + * lot slower than a mouse. Apply a magic factor to slow down all movements + */ +#define TP_MAGIC_SLOWDOWN 0.4 /* unitless factor */ + /* Convert speed/velocity from units/us to units/ms */ static inline double v_us2ms(double units_per_us) @@ -581,12 +587,6 @@ touchpad_accel_profile_linear(struct motion_filter *filter, double speed_in, /* units/us */ uint64_t time) { - /* Once normalized, touchpads see the same - acceleration as mice. that is technically correct but - subjectively wrong, we expect a touchpad to be a lot - slower than a mouse. Apply a magic factor here and proceed - as normal. */ - const double TP_MAGIC_SLOWDOWN = 0.4; /* unitless */ double factor; /* unitless */ speed_in *= TP_MAGIC_SLOWDOWN; @@ -603,7 +603,7 @@ touchpad_lenovo_x230_accel_profile(struct motion_filter *filter, uint64_t time) { /* Keep the magic factor from touchpad_accel_profile_linear. */ - const double TP_MAGIC_SLOWDOWN = 0.4; /* unitless */ + const double X230_MAGIC_SLOWDOWN = 0.4; /* unitless */ /* Those touchpads presents an actual lower resolution that what is * advertised. We see some jumps from the cursor due to the big steps @@ -629,14 +629,14 @@ touchpad_lenovo_x230_accel_profile(struct motion_filter *filter, * pointer_accel_profile_linear(), look at the git history of that * function for an explaination of what the min/max/etc. does. */ - speed_in *= TP_MAGIC_SLOWDOWN / TP_MAGIC_LOW_RES_FACTOR; + speed_in *= X230_MAGIC_SLOWDOWN / TP_MAGIC_LOW_RES_FACTOR; f1 = min(1, v_us2ms(speed_in) * 5); f2 = 1 + (v_us2ms(speed_in) - v_us2ms(threshold)) * incline; factor = min(max_accel, f2 > 1 ? f2 : f1); - return factor * TP_MAGIC_SLOWDOWN / TP_MAGIC_LOW_RES_FACTOR; + return factor * X230_MAGIC_SLOWDOWN / TP_MAGIC_LOW_RES_FACTOR; } double