To unify this we need to move the tagging process forward so tp_init() can
rely on it for config setup. This means moving it to the touchpad init code.
Other than that no real functional changes, the rules stay the same:
* serial/i2c/etc. are considered internal touchpads
* Bluetooth is always external
* USB is external for Logitech devices
* USB is external for Wacom devices
* USB is internal for Apple touchpads

And if we can't figure it out, we assume it's external and log a message so we
can put a quirk in place.

https://bugs.freedesktop.org/show_bug.cgi?id=96735

Signed-off-by: Peter Hutterer <[email protected]>
---
 src/evdev-mt-touchpad.c | 65 +++++++++++++++++++++++++++++++++++++++----------
 src/evdev.c             |  1 -
 src/evdev.h             |  9 +++----
 3 files changed, 55 insertions(+), 20 deletions(-)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 96e78b9..21d83ad 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -1421,11 +1421,10 @@ tp_dwt_device_is_blacklisted(struct evdev_device 
*device)
        unsigned int bus = libevdev_get_id_bustype(device->evdev);
 
        /* evemu will set the right bus type */
-       if (bus == BUS_BLUETOOTH || bus == BUS_VIRTUAL)
+       if (bus == BUS_VIRTUAL)
                return true;
 
-       /* Wacom makes touchpads, but not internal ones */
-       if (device->model_flags & EVDEV_MODEL_WACOM_TOUCHPAD)
+       if (device->tags & EVDEV_TAG_EXTERNAL_TOUCHPAD)
                return true;
 
        return false;
@@ -1449,10 +1448,6 @@ tp_want_dwt(struct evdev_device *touchpad,
        if (bus_tp == BUS_I8042 && bus_kbd != bus_tp)
                return false;
 
-       /* Logitech does not have internal touchpads */
-       if (vendor_tp == VENDOR_ID_LOGITECH)
-               return false;
-
        /* For Apple touchpads, always use its internal keyboard */
        if (vendor_tp == VENDOR_ID_APPLE) {
                return vendor_kbd == vendor_tp &&
@@ -1573,11 +1568,25 @@ tp_interface_device_removed(struct evdev_device *device,
        tp_resume(tp, device);
 }
 
-void
+static inline void
+evdev_tag_touchpad_internal(struct evdev_device *device)
+{
+       device->tags |= EVDEV_TAG_INTERNAL_TOUCHPAD;
+       device->tags &= ~EVDEV_TAG_EXTERNAL_TOUCHPAD;
+}
+
+static inline void
+evdev_tag_touchpad_external(struct evdev_device *device)
+{
+       device->tags |= EVDEV_TAG_EXTERNAL_TOUCHPAD;
+       device->tags &= ~EVDEV_TAG_INTERNAL_TOUCHPAD;
+}
+
+static void
 evdev_tag_touchpad(struct evdev_device *device,
                   struct udev_device *udev_device)
 {
-       int bustype;
+       int bustype, vendor;
 
        /* simple approach: touchpads on USB or Bluetooth are considered
         * external, anything else is internal. Exception is Apple -
@@ -1585,11 +1594,39 @@ evdev_tag_touchpad(struct evdev_device *device,
         * external USB touchpads anyway.
         */
        bustype = libevdev_get_id_bustype(device->evdev);
-       if (bustype == BUS_USB) {
+       vendor = libevdev_get_id_vendor(device->evdev);
+
+       switch (bustype) {
+       case BUS_USB:
                if (device->model_flags & EVDEV_MODEL_APPLE_TOUCHPAD)
-                        device->tags |= EVDEV_TAG_INTERNAL_TOUCHPAD;
-       } else if (bustype != BUS_BLUETOOTH)
-               device->tags |= EVDEV_TAG_INTERNAL_TOUCHPAD;
+                        evdev_tag_touchpad_internal(device);
+               break;
+       case BUS_BLUETOOTH:
+               evdev_tag_touchpad_external(device);
+               break;
+       default:
+               evdev_tag_touchpad_internal(device);
+               break;
+       }
+
+       switch (vendor) {
+       /* Logitech does not have internal touchpads */
+       case VENDOR_ID_LOGITECH:
+               evdev_tag_touchpad_external(device);
+               break;
+       }
+
+       /* Wacom makes touchpads, but not internal ones */
+       if (device->model_flags & EVDEV_MODEL_WACOM_TOUCHPAD)
+               evdev_tag_touchpad_external(device);
+
+       if ((device->tags &
+           (EVDEV_TAG_EXTERNAL_TOUCHPAD|EVDEV_TAG_INTERNAL_TOUCHPAD)) == 0) {
+               log_bug_libinput(evdev_libinput_context(device),
+                                "%s: Internal or external? Please file a 
bug.\n",
+                                device->devname);
+               evdev_tag_touchpad_external(device);
+       }
 }
 
 static struct evdev_dispatch_interface tp_interface = {
@@ -2309,6 +2346,8 @@ evdev_mt_touchpad_create(struct evdev_device *device)
 {
        struct tp_dispatch *tp;
 
+       evdev_tag_touchpad(device, device->udev_device);
+
        tp = zalloc(sizeof *tp);
        if (!tp)
                return NULL;
diff --git a/src/evdev.c b/src/evdev.c
index b4a1088..fdbaba1 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2243,7 +2243,6 @@ evdev_configure_device(struct evdev_device *device)
                         "input device '%s', %s is a touchpad\n",
                         device->devname, devnode);
 
-               evdev_tag_touchpad(device, device->udev_device);
                return device->dispatch == NULL ? -1 : 0;
        }
 
diff --git a/src/evdev.h b/src/evdev.h
index ca13318..f0fb2f9 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -68,8 +68,9 @@ enum evdev_device_seat_capability {
 enum evdev_device_tags {
        EVDEV_TAG_EXTERNAL_MOUSE = (1 << 0),
        EVDEV_TAG_INTERNAL_TOUCHPAD = (1 << 1),
-       EVDEV_TAG_TRACKPOINT = (1 << 2),
-       EVDEV_TAG_KEYBOARD = (1 << 3),
+       EVDEV_TAG_EXTERNAL_TOUCHPAD = (1 << 2),
+       EVDEV_TAG_TRACKPOINT = (1 << 3),
+       EVDEV_TAG_KEYBOARD = (1 << 4),
 };
 
 enum evdev_middlebutton_state {
@@ -334,10 +335,6 @@ struct evdev_dispatch *
 evdev_tablet_pad_create(struct evdev_device *device);
 
 void
-evdev_tag_touchpad(struct evdev_device *device,
-                  struct udev_device *udev_device);
-
-void
 evdev_device_led_update(struct evdev_device *device, enum libinput_led leds);
 
 int
-- 
2.7.4

_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to