summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2016-03-07 10:12:13 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2016-03-07 13:05:26 +1000
commit5d904b63191538b46d7fe8443990b55c42de0205 (patch)
treebb63351270c2a66d4c3115532c11d8e01afe7479 /src
parentb4a74bcebc8f1d37b2ed78db3440435ead03299a (diff)
tablet: reject mislabelled tablet devices
The HUION 580 has a "consumer control" event node that has an ABS_VOLUME, keys and a REL_HWHEEL. It has the same VID/PID as the pen tablet and libwacom labels it as ID_INPUT_TABLET. This causes a crash later when we try to init pointer acceleration for a device that doesn't have axes. https://bugzilla.redhat.com/show_bug.cgi?id=1314955 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r--src/evdev-tablet.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 0f6fa2cb..73598817 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -1613,6 +1613,31 @@ tablet_init_left_handed(struct evdev_device *device)
}
static int
+tablet_reject_device(struct evdev_device *device)
+{
+ struct libevdev *evdev = device->evdev;
+ int rc = -1;
+
+ if (!libevdev_has_event_code(evdev, EV_ABS, ABS_X) ||
+ !libevdev_has_event_code(evdev, EV_ABS, ABS_Y))
+ goto out;
+
+ if (!libevdev_has_event_code(evdev, EV_KEY, BTN_TOOL_PEN))
+ goto out;
+
+ rc = 0;
+
+out:
+ if (rc) {
+ log_bug_libinput(device->base.seat->libinput,
+ "Device '%s' does not meet tablet criteria. "
+ "Ignoring this device.\n",
+ device->devname);
+ }
+ return rc;
+}
+
+static int
tablet_init(struct tablet_dispatch *tablet,
struct evdev_device *device)
{
@@ -1625,6 +1650,9 @@ tablet_init(struct tablet_dispatch *tablet,
tablet->current_tool_type = LIBINPUT_TOOL_NONE;
list_init(&tablet->tool_list);
+ if (tablet_reject_device(device))
+ return -1;
+
tablet_init_calibration(tablet, device);
tablet_init_proximity_threshold(tablet, device);
rc = tablet_init_accel(tablet, device);