evdev: add DPI to evdev calculations
authorDerek Foreman <derekf@osg.samsung.com>
Thu, 30 Oct 2014 21:34:15 +0000 (16:34 -0500)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 31 Oct 2014 04:31:51 +0000 (14:31 +1000)
Assume "normal" mice are 400DPI, and that all calculations should be
normalized to this before being fed into the filter.

There isn't yet a way to configure a device's DPI.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev.c
src/evdev.h

index 1f51b4a..3aa87a7 100644 (file)
@@ -42,6 +42,8 @@
 
 #define DEFAULT_AXIS_STEP_DISTANCE 10
 #define DEFAULT_MIDDLE_BUTTON_SCROLL_TIMEOUT 200
+/* The HW DPI rate we normalize to before calculating pointer acceleration */
+#define DEFAULT_MOUSE_DPI 400
 
 enum evdev_key_type {
        EVDEV_KEY_TYPE_NONE,
@@ -205,8 +207,8 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
        case EVDEV_NONE:
                return;
        case EVDEV_RELATIVE_MOTION:
-               motion.dx = device->rel.dx;
-               motion.dy = device->rel.dy;
+               motion.dx = device->rel.dx / ((double)device->dpi / DEFAULT_MOUSE_DPI);
+               motion.dy = device->rel.dy / ((double)device->dpi / DEFAULT_MOUSE_DPI);
                device->rel.dx = 0;
                device->rel.dy = 0;
 
@@ -1293,6 +1295,7 @@ evdev_device_create(struct libinput_seat *seat,
        device->devname = libevdev_get_name(device->evdev);
        device->scroll.threshold = 5.0; /* Default may be overridden */
        device->scroll.direction = 0;
+       device->dpi = DEFAULT_MOUSE_DPI;
 
        matrix_init_identity(&device->abs.calibration);
        matrix_init_identity(&device->abs.usermatrix);
index 9e84623..666c8dc 100644 (file)
@@ -136,6 +136,7 @@ struct evdev_device {
                void (*change_to_left_handed)(struct evdev_device *device);
        } buttons;
 
+       int dpi; /* HW resolution */
        /* The number of times libevdev processes a SYN_DROPPED, so we can
         * stop logging them to avoid flooding the logs. */
        int syn_drops_received;