diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2014-07-08 13:43:45 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2014-07-09 12:50:37 +1000 |
commit | e874d09b49d34f4e67b7815cd3632f902c281432 (patch) | |
tree | 3749a2d4e8bcd2e11778dedffa9d97624d8fb9e7 | |
parent | 468e6288082ee61ac6a4663726a2728e413804e1 (diff) | |
download | libinput-e874d09b49d34f4e67b7815cd3632f902c281432.tar.gz |
touchpad: normalize the touchpad resolution to 400dpi, not 10 units/mm
In an attempt to bring method into the madness, normalize the touchpad deltas
to those of a USB mouse with 400 dpi. This way the data we're dealing with in
the acceleration code is of a known quantity.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | src/evdev-mt-touchpad.c | 15 | ||||
-rw-r--r-- | src/filter.c | 9 | ||||
-rw-r--r-- | src/filter.h | 2 |
3 files changed, 18 insertions, 8 deletions
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 4f4633d7..fed39b4e 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -663,14 +663,17 @@ tp_init_accel(struct tp_dispatch *tp, double diagonal) /* * Not all touchpads report the same amount of units/mm (resolution). - * Normalize motion events to a resolution of 10 units/mm as base - * (unaccelerated) speed. This also evens out any differences in x - * and y resolution, so that a circle on the touchpad does not turn - * into an elipse on the screen. + * Normalize motion events to a resolution of 15.74 units/mm + * (== 400 dpi) as base (unaccelerated) speed. This also evens out any + * differences in x and y resolution, so that a circle on the + * touchpad does not turn into an elipse on the screen. + * + * We pick 400dpi as thats one of the many default resolutions + * for USB mice, so we end up with a similar base speed on the device. */ if (res_x > 1 && res_y > 1) { - tp->accel.x_scale_coeff = 10.0 / res_x; - tp->accel.y_scale_coeff = 10.0 / res_y; + tp->accel.x_scale_coeff = (400/25.4) / res_x; + tp->accel.y_scale_coeff = (400/25.4) / res_y; } else { /* * For touchpads where the driver does not provide resolution, fall diff --git a/src/filter.c b/src/filter.c index 5b0b8774..e1fb2a96 100644 --- a/src/filter.c +++ b/src/filter.c @@ -341,7 +341,14 @@ pointer_accel_profile_smooth_simple(struct motion_filter *filter, if (accel < 1.0) accel = 1.0; - + /* We use units/ms as velocity but it has no real meaning unless all + devices have the same resolution. For touchpads, we normalize to + 400dpi (15.75 units/mm), but the resolution on USB mice is all + over the place. Though most mice these days have either 400 + dpi (15.75 units/mm), 800 dpi or 1000dpi, excluding gaming mice + that can usually adjust it on the fly anyway and currently go up + to 8200dpi. + */ if (velocity < (threshold / 2.0)) return calc_penumbral_gradient(0.5 + velocity / threshold) * 2.0 - 1.0; diff --git a/src/filter.h b/src/filter.h index e670e1b2..c0b27d0d 100644 --- a/src/filter.h +++ b/src/filter.h @@ -26,7 +26,7 @@ #include "config.h" struct motion_params { - double dx, dy; + double dx, dy; /* in units/ms @ 400dpi */ }; struct motion_filter; |