touchpad: normalize the touchpad resolution to 400dpi, not 10 units/mm
authorPeter Hutterer <peter.hutterer@who-t.net>
Tue, 8 Jul 2014 03:43:45 +0000 (13:43 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 9 Jul 2014 02:50:37 +0000 (12:50 +1000)
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>
src/evdev-mt-touchpad.c
src/filter.c
src/filter.h

index 4f4633d7bd3e216bec66280bc84d3be93ee925c6..fed39b4edccddb5cb2b192bc292961258b1ba45c 100644 (file)
@@ -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
index 5b0b87744666f648f04f6fcfc9c7e1a564f898b2..e1fb2a96955df52602bdb5e193ccb462ac22a5aa 100644 (file)
@@ -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;
 
index e670e1b2e6ade249008d7b7170ab461ca69b4e91..c0b27d0da170e13b78ca2294066b2fcc0761fda5 100644 (file)
@@ -26,7 +26,7 @@
 #include "config.h"
 
 struct motion_params {
-       double dx, dy;
+       double dx, dy; /* in units/ms @ 400dpi */
 };
 
 struct motion_filter;