diff options
author | Jason Gerecke <jason.gerecke@wacom.com> | 2019-07-26 07:24:26 -0700 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2019-07-29 22:38:36 +0000 |
commit | 5521ab03f454107176f766553f0bfbf7ab849dab (patch) | |
tree | 749268374913d64d893e072b679227763f85d2eb /udev | |
parent | 7ee232a91df71fb33e4f770d5a0a04328f35ee1b (diff) | |
download | libinput-5521ab03f454107176f766553f0bfbf7ab849dab.tar.gz |
udev: Reproduce entire LIBINPUT_DEVICE_GROUP for paired ExpressKey Remote
In order for two devices to be in the same group, they need to share
identical LIBINPUT_DEVICE_GROUP attributes. The `wacom_handle_ekr` function
overwrites the VID/PID for an ExpressKey Remote, but the 'phys' path is
left unchanged. This only works if the EKR and the device we want to pair
it with are both direct sibings in the USB tree. It isn't always possible
to actually connect the devices like this, however. The Cintiq Pro 32 and
24, for instance, have multiple internal USB hubs and place the pen sensor
and the USB port for the EKR dongle behind different ones.
By copying the 'phys' path of the device we want to pair with, it is
possible to reproduce the entire LIBINPUT_DEVICE_GROUP and ensure that
the two devices actually end up paired in libinput.
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Diffstat (limited to 'udev')
-rw-r--r-- | udev/libinput-device-group.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/udev/libinput-device-group.c b/udev/libinput-device-group.c index d95e70ee..dfcf9e0a 100644 --- a/udev/libinput-device-group.c +++ b/udev/libinput-device-group.c @@ -94,7 +94,8 @@ find_tree_distance(struct udev_device *a, struct udev_device *b) static void wacom_handle_ekr(struct udev_device *device, int *vendor_id, - int *product_id) + int *product_id, + const char **phys_attr) { struct udev *udev; struct udev_enumerate *e; @@ -109,7 +110,7 @@ wacom_handle_ekr(struct udev_device *device, udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) { struct udev_device *d; - const char *path; + const char *path, *phys; const char *pidstr, *vidstr; int pid, vid, dist; @@ -124,8 +125,9 @@ wacom_handle_ekr(struct udev_device *device, vidstr = udev_device_get_property_value(d, "ID_VENDOR_ID"); pidstr = udev_device_get_property_value(d, "ID_MODEL_ID"); + phys = udev_device_get_sysattr_value(d, "phys"); - if (vidstr && pidstr && + if (vidstr && pidstr && phys && safe_atoi_base(vidstr, &vid, 16) && safe_atoi_base(pidstr, &pid, 16) && vid == VENDOR_ID_WACOM && @@ -135,6 +137,9 @@ wacom_handle_ekr(struct udev_device *device, *vendor_id = vid; *product_id = pid; best_dist = dist; + + free((char*)*phys_attr); + *phys_attr = strdup(phys); } } @@ -150,7 +155,8 @@ int main(int argc, char **argv) struct udev *udev = NULL; struct udev_device *device = NULL; const char *syspath, - *phys = NULL; + *phys = NULL, + *physmatch = NULL; const char *product; int bustype, vendor_id, product_id, version; char group[1024]; @@ -207,7 +213,8 @@ int main(int argc, char **argv) if (product_id == PRODUCT_ID_WACOM_EKR) wacom_handle_ekr(device, &vendor_id, - &product_id); + &product_id, + &physmatch); /* This is called for the EKR as well */ wacom_handle_paired(device, &vendor_id, @@ -220,7 +227,7 @@ int main(int argc, char **argv) bustype, vendor_id, product_id, - phys); + physmatch ? physmatch : phys); } str = strstr(group, "/input"); |