On some devices we have a different PID for the touch device which makes grouping the two devices harder in userspace. Provide a call to fetch those.
The call is identical to the DeviceMatch approach but only one ID is allowed for the PairedID. It would get more difficult if we have an NxM match to paired ID, in that case it's likely best to have separate data files. Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> --- data/cintiq-13hdt.tablet | 1 + data/cintiq-22hdt.tablet | 1 + data/cintiq-24hd-touch.tablet | 1 + data/cintiq-27hdt.tablet | 1 + data/cintiq-companion-2.tablet | 1 + data/cintiq-companion-hybrid.tablet | 1 + data/cintiq-companion.tablet | 1 + data/dth-2242.tablet | 1 + data/wacom.example | 7 +++++++ libwacom/libwacom-database.c | 27 +++++++++++++++++++++++++++ libwacom/libwacom.c | 15 +++++++++++++++ libwacom/libwacom.h | 16 ++++++++++++++++ libwacom/libwacomint.h | 2 ++ test/load.c | 13 ++++++++++++- 14 files changed, 87 insertions(+), 1 deletion(-) diff --git a/data/cintiq-13hdt.tablet b/data/cintiq-13hdt.tablet index 15a3499..d220ce7 100644 --- a/data/cintiq-13hdt.tablet +++ b/data/cintiq-13hdt.tablet @@ -26,6 +26,7 @@ Name=Wacom Cintiq 13HD touch Class=Cintiq DeviceMatch=usb:056a:0333 +PairedID=usb:056a:0335 Width=12 Height=7 Layout=cintiq-13hd.svg diff --git a/data/cintiq-22hdt.tablet b/data/cintiq-22hdt.tablet index cc801ac..9e74c41 100644 --- a/data/cintiq-22hdt.tablet +++ b/data/cintiq-22hdt.tablet @@ -34,6 +34,7 @@ [Device] Name=Wacom Cintiq 22HD touch DeviceMatch=usb:056a:005b +PairedID=usb:056a:005e Class=Cintiq Width=19 Height=11 diff --git a/data/cintiq-24hd-touch.tablet b/data/cintiq-24hd-touch.tablet index ca6a9ae..143e705 100644 --- a/data/cintiq-24hd-touch.tablet +++ b/data/cintiq-24hd-touch.tablet @@ -42,6 +42,7 @@ [Device] Name=Wacom Cintiq 24HD touch DeviceMatch=usb:056a:00f8 +PairedID=usb:056a:00f6 Class=Cintiq Width=21 Height=13 diff --git a/data/cintiq-27hdt.tablet b/data/cintiq-27hdt.tablet index 9565bc8..52e3292 100644 --- a/data/cintiq-27hdt.tablet +++ b/data/cintiq-27hdt.tablet @@ -7,6 +7,7 @@ [Device] Name=Wacom Cintiq 27QHD touch DeviceMatch=usb:056a:032b +PairedID=usb:056a:032c Class=Cintiq Width=24 Height=12 diff --git a/data/cintiq-companion-2.tablet b/data/cintiq-companion-2.tablet index ec1b993..a96950c 100644 --- a/data/cintiq-companion-2.tablet +++ b/data/cintiq-companion-2.tablet @@ -30,6 +30,7 @@ Name=Wacom Cintiq Companion 2 Class=Cintiq DeviceMatch=usb:056a:0325 +PairedID=usb:056a:0326 Width=12 Height=7 Layout=cintiq-companion-2.svg diff --git a/data/cintiq-companion-hybrid.tablet b/data/cintiq-companion-hybrid.tablet index ea36d87..66bc09f 100644 --- a/data/cintiq-companion-hybrid.tablet +++ b/data/cintiq-companion-hybrid.tablet @@ -28,6 +28,7 @@ Name=Wacom Cintiq Companion Hybrid Class=Cintiq DeviceMatch=usb:056a:0307 +PairedID=usb:056a:0309 Width=12 Height=7 Layout=cintiq-companion-hybrid.svg diff --git a/data/cintiq-companion.tablet b/data/cintiq-companion.tablet index 734910a..6ccc7fa 100644 --- a/data/cintiq-companion.tablet +++ b/data/cintiq-companion.tablet @@ -28,6 +28,7 @@ Name=Wacom Cintiq Companion Class=Cintiq DeviceMatch=usb:056a:030a +PairedID=usb:056a:030c Width=12 Height=7 Layout=cintiq-companion.svg diff --git a/data/dth-2242.tablet b/data/dth-2242.tablet index 2eb5d09..6fdc047 100644 --- a/data/dth-2242.tablet +++ b/data/dth-2242.tablet @@ -16,6 +16,7 @@ [Device] Name=Wacom DTH2242 DeviceMatch=usb:056a:0059 +PairedID=usb:056a:005d Class=PenDisplay Width=19 Height=11 diff --git a/data/wacom.example b/data/wacom.example index 7c9d34d..376a56d 100644 --- a/data/wacom.example +++ b/data/wacom.example @@ -23,6 +23,13 @@ Name=Wacom Intuos4 6x9 # so it has exactly 4 digits. DeviceMatch=usb:056a:00bc +# Paired PID includes the match line of any device that share the same +# physical device but has different product or vendor ids (e.g. the touch +# device on the 24HDT). The format of the match line is identical to +# DeviceMatch but only one value is permitted. +# Note: the PIDs listed may not be libwacom devices themselves. +PairedIDs=usb:056a:0335 + # Class of the tablet. Valid classes include Intuos3, Intuos4, Graphire, Bamboo, Cintiq # If unsure, or not applicable (the tablet isn't stand-alone for # example), just leave it out. diff --git a/libwacom/libwacom-database.c b/libwacom/libwacom-database.c index f8cad59..1241e99 100644 --- a/libwacom/libwacom-database.c +++ b/libwacom/libwacom-database.c @@ -189,6 +189,26 @@ libwacom_matchstr_to_match(WacomDevice *device, const char *matchstr) return TRUE; } +static gboolean +libwacom_matchstr_to_paired(WacomDevice *device, const char *matchstr) +{ + char *name = NULL; + int vendor_id, product_id; + WacomBusType bus; + + g_return_val_if_fail(device->paired == NULL, FALSE); + + if (!match_from_string(matchstr, &bus, &vendor_id, &product_id, &name)) { + DBG("failed to match '%s' for product/vendor IDs. Ignoring.\n", matchstr); + return FALSE; + } + + device->paired = libwacom_match_new(name, bus, vendor_id, product_id); + + free(name); + return TRUE; +} + static void libwacom_parse_stylus_keyfile(WacomDeviceDatabase *db, const char *path) { @@ -400,6 +420,7 @@ libwacom_parse_tablet_keyfile(const char *datadir, const char *filename) char *path; char *layout; char *class; + char *paired; char **string_list; keyfile = g_key_file_new(); @@ -442,6 +463,12 @@ libwacom_parse_tablet_keyfile(const char *datadir, const char *filename) g_strfreev (string_list); } + paired = g_key_file_get_string(keyfile, DEVICE_GROUP, "PairedID", NULL); + if (paired) { + libwacom_matchstr_to_paired(device, paired); + g_free(paired); + } + device->name = g_key_file_get_string(keyfile, DEVICE_GROUP, "Name", NULL); device->width = g_key_file_get_integer(keyfile, DEVICE_GROUP, "Width", NULL); device->height = g_key_file_get_integer(keyfile, DEVICE_GROUP, "Height", NULL); diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c index 38b6225..863dc2a 100644 --- a/libwacom/libwacom.c +++ b/libwacom/libwacom.c @@ -333,6 +333,8 @@ libwacom_copy(const WacomDevice *device) d->matches[i] = libwacom_copy_match(device->matches[i]); d->matches[d->nmatches] = NULL; d->match = device->match; + if (device->paired) + d->paired = libwacom_copy_match(device->paired); d->cls = device->cls; d->num_strips = device->num_strips; d->features = device->features; @@ -752,6 +754,12 @@ libwacom_print_device_description(int fd, const WacomDevice *device) print_match(fd, *match); dprintf(fd, "\n"); + if (libwacom_get_paired_device(device)) { + dprintf(fd, "PairedID="); + print_match(fd, libwacom_get_paired_device(device)); + dprintf(fd, "\n"); + } + dprintf(fd, "Class=%s\n", class_name); dprintf(fd, "Width=%d\n", libwacom_get_width(device)); dprintf(fd, "Height=%d\n", libwacom_get_height(device)); @@ -793,6 +801,8 @@ libwacom_destroy(WacomDevice *device) g_free (device->name); g_free (device->layout); + if (device->paired) + libwacom_match_destroy(device->paired); for (i = 0; i < device->nmatches; i++) libwacom_match_destroy(device->matches[i]); g_free (device->matches); @@ -880,6 +890,11 @@ const WacomMatch** libwacom_get_matches(const WacomDevice *device) return (const WacomMatch**)device->matches; } +const WacomMatch* libwacom_get_paired_device(const WacomDevice *device) +{ + return (const WacomMatch*)device->paired; +} + int libwacom_get_width(const WacomDevice *device) { return device->width; diff --git a/libwacom/libwacom.h b/libwacom/libwacom.h index a1a618e..d4c94ef 100644 --- a/libwacom/libwacom.h +++ b/libwacom/libwacom.h @@ -387,6 +387,22 @@ const char* libwacom_get_match(const WacomDevice *device); const WacomMatch** libwacom_get_matches(const WacomDevice *device); /** + * Return the match string of the paired device for this device. A paired + * device is a device with a different match string but that shares the + * physical device with this device. + * + * If the return value is NULL, no device is paired with this device or all + * paired devices have the same WacomMatch as this device. + * + * The returned device may not be a libwacom device itself. + * + * @param device The tablet to query + * @return A pointer to paired device for this device. Do not + * modify this pointer or any content! + */ +const WacomMatch* libwacom_get_paired_device(const WacomDevice *device); + +/** * @param device The tablet to query * @return The numeric product ID for this device */ diff --git a/libwacom/libwacomint.h b/libwacom/libwacomint.h index c7d8916..e887d11 100644 --- a/libwacom/libwacomint.h +++ b/libwacom/libwacomint.h @@ -72,6 +72,8 @@ struct _WacomDevice { WacomMatch **matches; /* NULL-terminated */ int nmatches; /* not counting NULL-terminated element */ + WacomMatch *paired; + WacomClass cls; int num_strips; uint32_t features; diff --git a/test/load.c b/test/load.c index 595f453..583cd06 100644 --- a/test/load.c +++ b/test/load.c @@ -60,6 +60,7 @@ int main(int argc, char **argv) { WacomDeviceDatabase *db; WacomDevice *device; + const WacomMatch *match; const char *str; db = libwacom_database_new_for_path(TOPSRCDIR"/data"); @@ -128,8 +129,18 @@ int main(int argc, char **argv) assert(libwacom_get_integration_flags (device) & WACOM_DEVICE_INTEGRATED_DISPLAY); assert(libwacom_get_integration_flags (device) & WACOM_DEVICE_INTEGRATED_SYSTEM); libwacom_destroy(device); + + /* 24HDT has one paired device */ + device = libwacom_new_from_usbid(db, 0x56a, 0x00f8, NULL); + assert(device); + + match = libwacom_get_paired_device(device); + assert(match != NULL); + assert(libwacom_match_get_vendor_id(match) == 0x56a); + assert(libwacom_match_get_product_id(match) == 0xf6); + assert(libwacom_match_get_bustype(match) == WBUSTYPE_USB); + libwacom_database_destroy (db); - return 0; } -- 2.7.4 ------------------------------------------------------------------------------ Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel