evdev: Use has_abs only for ABS_X and ABS_Y, introduce has_mt for MT events
authorKristian Høgsberg <krh@bitplanet.net>
Mon, 16 Dec 2013 21:42:40 +0000 (13:42 -0800)
committerJonas Ådahl <jadahl@gmail.com>
Sat, 21 Dec 2013 11:32:31 +0000 (12:32 +0100)
We split up has_abs into plain ABS_X/Y and MT events, but this shouldn't
introduce any logic changes.

src/evdev.c

index 40afceefd9887992323902e61305118edce61d96..0a1f59ed07c58be66f61db15778bc69cea0bb5b3 100644 (file)
@@ -473,18 +473,17 @@ evdev_configure_device(struct evdev_device *device)
        unsigned long abs_bits[NBITS(ABS_MAX)];
        unsigned long rel_bits[NBITS(REL_MAX)];
        unsigned long key_bits[NBITS(KEY_MAX)];
-       int has_key, has_abs, has_rel;
+       int has_key, has_abs, has_rel, has_mt;
        unsigned int i;
 
        has_key = 0;
        has_rel = 0;
        has_abs = 0;
+       has_mt = 0;
        device->caps = 0;
 
        ioctl(device->fd, EVIOCGBIT(0, sizeof(ev_bits)), ev_bits);
        if (TEST_BIT(ev_bits, EV_ABS)) {
-               has_abs = 1;
-
                ioctl(device->fd, EVIOCGBIT(EV_ABS, sizeof(abs_bits)),
                      abs_bits);
 
@@ -501,12 +500,14 @@ evdev_configure_device(struct evdev_device *device)
                        device->abs.min_x = absinfo.minimum;
                        device->abs.max_x = absinfo.maximum;
                        device->caps |= EVDEV_MOTION_ABS;
+                       has_abs = 1;
                }
                if (TEST_BIT(abs_bits, ABS_Y)) {
                        ioctl(device->fd, EVIOCGABS(ABS_Y), &absinfo);
                        device->abs.min_y = absinfo.minimum;
                        device->abs.max_y = absinfo.maximum;
                        device->caps |= EVDEV_MOTION_ABS;
+                       has_abs = 1;
                }
                 /* We only handle the slotted Protocol B in weston.
                    Devices with ABS_MT_POSITION_* but not ABS_MT_SLOT
@@ -523,6 +524,7 @@ evdev_configure_device(struct evdev_device *device)
                        device->abs.max_y = absinfo.maximum;
                        device->is_mt = 1;
                        device->caps |= EVDEV_TOUCH;
+                       has_mt = 1;
 
                        if (!TEST_BIT(abs_bits, ABS_MT_SLOT)) {
                                device->mtdev = mtdev_new_open(device->fd);
@@ -551,7 +553,7 @@ evdev_configure_device(struct evdev_device *device)
                      key_bits);
                if (TEST_BIT(key_bits, BTN_TOOL_FINGER) &&
                    !TEST_BIT(key_bits, BTN_TOOL_PEN) &&
-                   has_abs) {
+                   (has_abs || has_mt)) {
                        device->dispatch = evdev_touchpad_create(device);
                }
                for (i = KEY_ESC; i < KEY_MAX; i++) {