evdev: hook up a generic enable/disable interface for devices
[platform/upstream/libinput.git] / src / evdev-mt-touchpad.c
index 4d4856f..d831b83 100644 (file)
@@ -163,7 +163,7 @@ tp_end_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
 static double
 tp_estimate_delta(int x0, int x1, int x2, int x3)
 {
-       return (x0 + x1 - x2 - x3) / 4;
+       return (x0 + x1 - x2 - x3) / 4.0;
 }
 
 void
@@ -406,6 +406,11 @@ tp_process_state(struct tp_dispatch *tp, uint64_t time)
 
        for (i = 0; i < tp->ntouches; i++) {
                t = tp_get_touch(tp, i);
+
+               /* semi-mt finger postions may "jump" when nfingers changes */
+               if (tp->semi_mt && tp->nfingers_down != tp->old_nfingers_down)
+                       tp_motion_history_reset(t);
+
                if (i >= tp->real_touches && t->state != TOUCH_NONE) {
                        t->x = first->x;
                        t->y = first->y;
@@ -454,6 +459,7 @@ tp_post_process_state(struct tp_dispatch *tp, uint64_t time)
                t->dirty = false;
        }
 
+       tp->old_nfingers_down = tp->nfingers_down;
        tp->buttons.old_state = tp->buttons.state;
 
        tp->queued = TOUCHPAD_EVENT_NONE;
@@ -668,6 +674,8 @@ tp_init_slots(struct tp_dispatch *tp,
                tp->has_mt = false;
        }
 
+       tp->semi_mt = libevdev_has_property(device->evdev, INPUT_PROP_SEMI_MT);
+
        ARRAY_FOR_EACH(max_touches, m) {
                if (libevdev_has_event_code(device->evdev,
                                            EV_KEY,
@@ -777,7 +785,6 @@ tp_init_palmdetect(struct tp_dispatch *tp,
        return 0;
 }
 
-
 static int
 tp_init(struct tp_dispatch *tp,
        struct evdev_device *device)
@@ -817,6 +824,8 @@ tp_init(struct tp_dispatch *tp,
        if (tp_init_palmdetect(tp, device) != 0)
                return -1;
 
+       device->seat_caps |= EVDEV_DEVICE_POINTER;
+
        return 0;
 }