evdev: apply calibration to multitouch values as well
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 20 Aug 2014 08:23:43 +0000 (18:23 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 27 Aug 2014 02:33:11 +0000 (12:33 +1000)
We apply calibration to single-touch and absolute devices, but we might as
well do so for multitouch events.

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

index 9c53e32..a029887 100644 (file)
@@ -150,19 +150,20 @@ evdev_device_led_update(struct evdev_device *device, enum libinput_led leds)
 static void
 transform_absolute(struct evdev_device *device, int32_t *x, int32_t *y)
 {
-       if (!device->abs.apply_calibration) {
-               *x = device->abs.x;
-               *y = device->abs.y;
+       int32_t tx, ty;
+
+       if (!device->abs.apply_calibration)
                return;
-       } else {
-               *x = device->abs.x * device->abs.calibration[0] +
-                       device->abs.y * device->abs.calibration[1] +
-                       device->abs.calibration[2];
 
-               *y = device->abs.x * device->abs.calibration[3] +
-                       device->abs.y * device->abs.calibration[4] +
-                       device->abs.calibration[5];
-       }
+       tx = *x * device->abs.calibration[0] +
+               *y * device->abs.calibration[1] +
+               device->abs.calibration[2];
+
+       ty = *x * device->abs.calibration[3] +
+               *y * device->abs.calibration[4] +
+               device->abs.calibration[5];
+       *x = tx;
+       *y = ty;
 }
 
 static inline double
@@ -194,7 +195,7 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
        struct libinput *libinput = device->base.seat->libinput;
        struct motion_params motion;
        int32_t cx, cy;
-       double x, y;
+       int32_t x, y;
        int slot;
        int seat_slot;
        struct libinput_device *base = &device->base;
@@ -239,6 +240,7 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
                seat->slot_map |= 1 << seat_slot;
                x = device->mt.slots[slot].x;
                y = device->mt.slots[slot].y;
+               transform_absolute(device, &x, &y);
 
                touch_notify_touch_down(base, time, slot, seat_slot, x, y);
                break;
@@ -253,6 +255,7 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
                if (seat_slot == -1)
                        break;
 
+               transform_absolute(device, &x, &y);
                touch_notify_touch_motion(base, time, slot, seat_slot, x, y);
                break;
        case EVDEV_ABSOLUTE_MT_UP:
@@ -288,11 +291,15 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time)
 
                seat->slot_map |= 1 << seat_slot;
 
+               cx = device->abs.x;
+               cy = device->abs.y;
                transform_absolute(device, &cx, &cy);
 
                touch_notify_touch_down(base, time, -1, seat_slot, cx, cy);
                break;
        case EVDEV_ABSOLUTE_MOTION:
+               cx = device->abs.x;
+               cy = device->abs.y;
                transform_absolute(device, &cx, &cy);
                x = cx;
                y = cy;