summaryrefslogtreecommitdiff
path: root/udev
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2016-07-18 16:06:28 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2016-08-03 14:06:48 +1000
commit8a8c72983fbf334e1b321ae870c1d13fdeda5bc8 (patch)
tree368a0dfcd5e4f4c24047dcf5f3c0e5af4bcd9b35 /udev
parent90f6e43562f660ee369b03cf866d0ca94fd74dcd (diff)
udev: check wacom devices for a paired product id
The newer Wacom Cintiqs have touch devices with a different PID than the pen device. Use the new libwacom_get_paired_device call where available to pair the two devices and give them the same device group. This isn't that important just yet, so no need to force users to update to a new libwacom version. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Diffstat (limited to 'udev')
-rw-r--r--udev/Makefile.am9
-rw-r--r--udev/libinput-device-group.c64
2 files changed, 70 insertions, 3 deletions
diff --git a/udev/Makefile.am b/udev/Makefile.am
index cfb854e1..f06dc564 100644
--- a/udev/Makefile.am
+++ b/udev/Makefile.am
@@ -7,9 +7,16 @@ litest_rules = 80-libinput-device-groups-litest.rules \
noinst_SCRIPTS = $(litest_rules)
libinput_device_group_SOURCES = libinput-device-group.c
-libinput_device_group_CFLAGS = $(LIBUDEV_CFLAGS) $(GCC_CFLAGS)
+libinput_device_group_CFLAGS = -I$(top_srcdir)/src \
+ $(LIBUDEV_CFLAGS) \
+ $(GCC_CFLAGS)
libinput_device_group_LDADD = $(LIBUDEV_LIBS)
+if HAVE_LIBWACOM_GET_PAIRED_DEVICE
+libinput_device_group_CFLAGS += $(LIBWACOM_CFLAGS)
+libinput_device_group_LDADD += $(LIBWACOM_LIBS)
+endif
+
libinput_model_quirks_SOURCES = libinput-model-quirks.c
libinput_model_quirks_CFLAGS = \
-I$(top_srcdir)/src \
diff --git a/udev/libinput-device-group.c b/udev/libinput-device-group.c
index ab9409bf..fa70e115 100644
--- a/udev/libinput-device-group.c
+++ b/udev/libinput-device-group.c
@@ -21,11 +21,49 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include "config.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libudev.h>
+#include "libinput-util.h"
+
+#if HAVE_LIBWACOM_GET_PAIRED_DEVICE
+#include <libwacom/libwacom.h>
+
+static void
+wacom_handle_paired(struct udev_device *device,
+ int *vendor_id,
+ int *product_id)
+{
+ WacomDeviceDatabase *db = NULL;
+ WacomDevice *tablet = NULL;
+ const WacomMatch *paired;
+
+ db = libwacom_database_new();
+ if (!db)
+ goto out;
+
+ tablet = libwacom_new_from_usbid(db, *vendor_id, *product_id, NULL);
+ if (!tablet)
+ goto out;
+ paired = libwacom_get_paired_device(tablet);
+ if (!paired)
+ goto out;
+
+ *vendor_id = libwacom_match_get_vendor_id(paired);
+ *product_id = libwacom_match_get_product_id(paired);
+
+out:
+ if (tablet)
+ libwacom_destroy(tablet);
+ if (db)
+ libwacom_database_destroy(db);
+}
+#endif
+
int main(int argc, char **argv)
{
int rc = 1;
@@ -34,6 +72,7 @@ int main(int argc, char **argv)
const char *syspath,
*phys = NULL;
const char *product;
+ int bustype, vendor_id, product_id, version;
char group[1024];
char *str;
@@ -73,8 +112,29 @@ int main(int argc, char **argv)
on that*/
product = udev_device_get_property_value(device, "PRODUCT");
if (!product)
- product = "";
- snprintf(group, sizeof(group), "%s:%s", product, phys);
+ product = "00/00/00/00";
+
+ if (sscanf(product,
+ "%x/%x/%x/%x",
+ &bustype,
+ &vendor_id,
+ &product_id,
+ &version) != 4) {
+ snprintf(group, sizeof(group), "%s:%s", product, phys);
+ } else {
+#if HAVE_LIBWACOM_GET_PAIRED_DEVICE
+ if (vendor_id == VENDOR_ID_WACOM)
+ wacom_handle_paired(device, &vendor_id, &product_id);
+#endif
+ snprintf(group,
+ sizeof(group),
+ "%x/%x/%x/%x:%s",
+ bustype,
+ vendor_id,
+ product_id,
+ version,
+ phys);
+ }
str = strstr(group, "/input");
if (str)