Move DEFAULT_MOUSE_DPI to evdev.h, provide a conversion macro
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 6 Mar 2015 04:18:59 +0000 (14:18 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 9 Mar 2015 21:09:23 +0000 (07:09 +1000)
Ideally we want to specify various thresholds in mm, but not all touchpads
set the hardware resolutions. Rather than conditions to check for resolutions
everywhere, use a macro to give us a normalized value that we use for motion
as well.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
src/evdev-mt-touchpad.c
src/evdev-mt-touchpad.h
src/evdev.h
src/filter.h

index 9b06522..8808850 100644 (file)
@@ -994,9 +994,8 @@ tp_init_accel(struct tp_dispatch *tp, double diagonal)
                   fixed in the actual filter code.
                 */
                {
-                       const double MAGIC = 0.4;
-                       tp->accel.x_scale_coeff *= MAGIC;
-                       tp->accel.y_scale_coeff *= MAGIC;
+                       tp->accel.x_scale_coeff *= TP_MAGIC_SLOWDOWN;
+                       tp->accel.y_scale_coeff *= TP_MAGIC_SLOWDOWN;
                }
        } else {
        /*
index 1b8b560..de8b60d 100644 (file)
 
 #define VENDOR_ID_APPLE 0x5ac
 
+/* Touchpad slowdown factor, see the FIXME in tp_init_accel() */
+#define TP_MAGIC_SLOWDOWN 0.4
+/* Convert mm to a distance normalized to DEFAULT_MOUSE_DPI */
+#define TP_MM_TO_DPI_NORMALIZED(mm) (DEFAULT_MOUSE_DPI/25.4 * TP_MAGIC_SLOWDOWN  * mm)
+
 enum touchpad_event {
        TOUCHPAD_EVENT_NONE             = 0,
        TOUCHPAD_EVENT_MOTION           = (1 << 0),
index 72082e5..9e8d6af 100644 (file)
@@ -33,6 +33,9 @@
 #include "libinput-private.h"
 #include "timer.h"
 
+/* The HW DPI rate we normalize to before calculating pointer acceleration */
+#define DEFAULT_MOUSE_DPI 1000
+
 enum evdev_event_type {
        EVDEV_NONE,
        EVDEV_ABSOLUTE_TOUCH_DOWN,
index 9f6223d..9e90330 100644 (file)
@@ -28,9 +28,6 @@
 #include <stdbool.h>
 #include <stdint.h>
 
-/* The HW DPI rate we normalize to before calculating pointer acceleration */
-#define DEFAULT_MOUSE_DPI 1000
-
 struct motion_params {
        double dx, dy; /* in units/ms @ DEFAULT_MOUSE_DPI resolution */
 };