Discussion:
[Linuxwacom-devel] [PATCH libwacom 2/5] Move printing and freeing a WacomMatch into helper functions
Peter Hutterer
2016-07-07 10:20:09 UTC
Permalink
Signed-off-by: Peter Hutterer <***@who-t.net>
---
libwacom/libwacom.c | 59 ++++++++++++++++++++++++++++----------------------
libwacom/libwacomint.h | 1 +
2 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c
index d20b66c..b093021 100644
--- a/libwacom/libwacom.c
+++ b/libwacom/libwacom.c
@@ -696,13 +696,34 @@ static void print_integrated_flags_for_device (int fd, const WacomDevice *device
dprintf(fd, "\n");
}

+static void print_match(int fd, const WacomMatch *match)
+{
+ const char *name = libwacom_match_get_name(match);
+ WacomBusType type = libwacom_match_get_bustype(match);
+ int vendor = libwacom_match_get_vendor_id(match);
+ int product = libwacom_match_get_product_id(match);
+ const char *bus_name;
+
+ switch(type) {
+ case WBUSTYPE_BLUETOOTH: bus_name = "bluetooth"; break;
+ case WBUSTYPE_USB: bus_name = "usb"; break;
+ case WBUSTYPE_SERIAL: bus_name = "serial"; break;
+ case WBUSTYPE_I2C: bus_name = "i2c"; break;
+ case WBUSTYPE_UNKNOWN: bus_name = "unknown"; break;
+ default: g_assert_not_reached(); break;
+ }
+ dprintf(fd, "%s:%04x:%04x", bus_name, vendor, product);
+ if (name)
+ dprintf(fd, ":%s", name);
+ dprintf(fd, ";");
+}

void
libwacom_print_device_description(int fd, const WacomDevice *device)
{
const WacomMatch **match;
WacomClass class;
- const char *bus_name, *class_name;
+ const char *class_name;

class = libwacom_get_class(device);
switch(class) {
@@ -724,25 +745,8 @@ libwacom_print_device_description(int fd, const WacomDevice *device)
dprintf(fd, "[Device]\n");
dprintf(fd, "Name=%s\n", libwacom_get_name(device));
dprintf(fd, "DeviceMatch=");
- for (match = libwacom_get_matches(device); *match; match++) {
- const char *name = libwacom_match_get_name(*match);
- WacomBusType type = libwacom_match_get_bustype(*match);
- int vendor = libwacom_match_get_vendor_id(*match);
- int product = libwacom_match_get_product_id(*match);
-
- switch(type) {
- case WBUSTYPE_BLUETOOTH: bus_name = "bluetooth"; break;
- case WBUSTYPE_USB: bus_name = "usb"; break;
- case WBUSTYPE_SERIAL: bus_name = "serial"; break;
- case WBUSTYPE_I2C: bus_name = "i2c"; break;
- case WBUSTYPE_UNKNOWN: bus_name = "unknown"; break;
- default: g_assert_not_reached(); break;
- }
- dprintf(fd, "%s:%04x:%04x", bus_name, vendor, product);
- if (name)
- dprintf(fd, ":%s", name);
- dprintf(fd, ";");
- }
+ for (match = libwacom_get_matches(device); *match; match++)
+ print_match(fd, *match);
dprintf(fd, "\n");

dprintf(fd, "Class=%s\n", class_name);
@@ -768,6 +772,13 @@ libwacom_print_device_description(int fd, const WacomDevice *device)
print_buttons_for_device(fd, device);
}

+void
+libwacom_match_destroy(WacomMatch *match)
+{
+ g_free (match->match);
+ g_free (match->name);
+ g_free (match);
+}

void
libwacom_destroy(WacomDevice *device)
@@ -779,12 +790,8 @@ libwacom_destroy(WacomDevice *device)

g_free (device->name);
g_free (device->layout);
-
- for (i = 0; i < device->nmatches; i++) {
- g_free (device->matches[i]->match);
- g_free (device->matches[i]->name);
- g_free (device->matches[i]);
- }
+ for (i = 0; i < device->nmatches; i++)
+ libwacom_match_destroy(device->matches[i]);
g_free (device->matches);
g_free (device->supported_styli);
g_free (device->status_leds);
diff --git a/libwacom/libwacomint.h b/libwacom/libwacomint.h
index 825f9e9..af47bd5 100644
--- a/libwacom/libwacomint.h
+++ b/libwacom/libwacomint.h
@@ -121,6 +121,7 @@ struct _WacomError {
void libwacom_error_set(WacomError *error, enum WacomErrorCode code, const char *msg, ...);
void libwacom_stylus_destroy(WacomStylus *stylus);
void libwacom_update_match(WacomDevice *device, const char *name, WacomBusType bus, int vendor_id, int product_id);
+void libwacom_match_destroy(WacomMatch *match);

WacomBusType bus_from_str (const char *str);
const char *bus_to_str (WacomBusType bus);
--
2.7.4
Peter Hutterer
2016-07-07 10:20:08 UTC
Permalink
Signed-off-by: Peter Hutterer <***@who-t.net>
---
libwacom/libwacom-database.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libwacom/libwacom-database.c b/libwacom/libwacom-database.c
index 997b53f..884ae20 100644
--- a/libwacom/libwacom-database.c
+++ b/libwacom/libwacom-database.c
@@ -400,7 +400,10 @@ libwacom_parse_tablet_keyfile(const char *datadir, const char *filename)
device = g_new0 (WacomDevice, 1);

string_list = g_key_file_get_string_list(keyfile, DEVICE_GROUP, "DeviceMatch", NULL, NULL);
- if (string_list) {
+ if (!string_list) {
+ DBG("Missing DeviceMatch= line in '%s'\n", path);
+ goto out;
+ } else {
guint i;
guint nmatches = 0;
guint first_valid_match = 0;
--
2.7.4
Peter Hutterer
2016-07-07 10:20:10 UTC
Permalink
Signed-off-by: Peter Hutterer <***@who-t.net>
---
libwacom/libwacom-database.c | 42 +++++++++++++++++++++++++++---------------
1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/libwacom/libwacom-database.c b/libwacom/libwacom-database.c
index 884ae20..e3023e2 100644
--- a/libwacom/libwacom-database.c
+++ b/libwacom/libwacom-database.c
@@ -140,11 +140,30 @@ make_match_string (const char *name, WacomBusType bus, int vendor_id, int produc
}

static gboolean
-libwacom_matchstr_to_match(WacomDevice *device, const char *match)
+match_from_string(const char *str, WacomBusType *bus, int *vendor_id, int *product_id, char **name)
{
int rc = 1;
char busstr[64], namestr[64];
- char *name;
+
+ memset(namestr, 0, sizeof(namestr));
+
+ rc = sscanf(str, "%63[^:]:%x:%x:%63c", busstr, vendor_id, product_id, namestr);
+ if (rc == 4) {
+ *name = g_strdup(namestr);
+ } else if (rc == 3) {
+ *name = NULL;
+ } else {
+ return FALSE;
+ }
+ *bus = bus_from_str (busstr);
+
+ return TRUE;
+}
+
+static gboolean
+libwacom_matchstr_to_match(WacomDevice *device, const char *match)
+{
+ char *name = NULL;
int vendor_id, product_id;
WacomBusType bus;

@@ -152,25 +171,18 @@ libwacom_matchstr_to_match(WacomDevice *device, const char *match)
return FALSE;

if (g_strcmp0 (match, GENERIC_DEVICE_MATCH) == 0) {
- libwacom_update_match(device, NULL, WBUSTYPE_UNKNOWN, 0, 0);
- return TRUE;
- }
-
- memset(namestr, 0, sizeof(namestr));
-
- rc = sscanf(match, "%63[^:]:%x:%x:%63c", busstr, &vendor_id, &product_id, namestr);
- if (rc == 4) {
- name = namestr;
- } else if (rc == 3) {
name = NULL;
- } else {
+ bus = WBUSTYPE_UNKNOWN;
+ vendor_id = 0;
+ product_id = 0;
+ } else if (!match_from_string(match, &bus, &vendor_id, &product_id, &name)) {
DBG("failed to match '%s' for product/vendor IDs. Skipping.\n", match);
- return 0;
+ return FALSE;
}
- bus = bus_from_str (busstr);

libwacom_update_match(device, name, bus, vendor_id, product_id);

+ free(name);
return TRUE;
}
--
2.7.4
Peter Hutterer
2016-07-07 10:20:11 UTC
Permalink
Signed-off-by: Peter Hutterer <***@who-t.net>
---
libwacom/libwacom-database.c | 15 +++++++++------
libwacom/libwacom.c | 41 +++++++++++++++++++++++++----------------
libwacom/libwacomint.h | 3 ++-
3 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/libwacom/libwacom-database.c b/libwacom/libwacom-database.c
index e3023e2..f8cad59 100644
--- a/libwacom/libwacom-database.c
+++ b/libwacom/libwacom-database.c
@@ -161,26 +161,29 @@ match_from_string(const char *str, WacomBusType *bus, int *vendor_id, int *produ
}

static gboolean
-libwacom_matchstr_to_match(WacomDevice *device, const char *match)
+libwacom_matchstr_to_match(WacomDevice *device, const char *matchstr)
{
char *name = NULL;
int vendor_id, product_id;
WacomBusType bus;
+ WacomMatch *match;

- if (match == NULL)
+ if (matchstr == NULL)
return FALSE;

- if (g_strcmp0 (match, GENERIC_DEVICE_MATCH) == 0) {
+ if (g_strcmp0 (matchstr, GENERIC_DEVICE_MATCH) == 0) {
name = NULL;
bus = WBUSTYPE_UNKNOWN;
vendor_id = 0;
product_id = 0;
- } else if (!match_from_string(match, &bus, &vendor_id, &product_id, &name)) {
- DBG("failed to match '%s' for product/vendor IDs. Skipping.\n", match);
+ } else if (!match_from_string(matchstr, &bus, &vendor_id, &product_id, &name)) {
+ DBG("failed to match '%s' for product/vendor IDs. Skipping.\n", matchstr);
return FALSE;
}

- libwacom_update_match(device, name, bus, vendor_id, product_id);
+ match = libwacom_match_new(name, bus, vendor_id, product_id);
+ libwacom_update_match(device, match);
+ libwacom_match_destroy(match);

free(name);
return TRUE;
diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c
index b093021..38b6225 100644
--- a/libwacom/libwacom.c
+++ b/libwacom/libwacom.c
@@ -487,6 +487,7 @@ libwacom_new_from_path(const WacomDeviceDatabase *db, const char *path, WacomFal
WacomDevice *ret = NULL;
WacomIntegrationFlags integration_flags;
char *name, *match_name;
+ WacomMatch *match;

if (!db) {
libwacom_error_set(error, WERROR_INVALID_DB, "db is NULL");
@@ -526,7 +527,9 @@ libwacom_new_from_path(const WacomDeviceDatabase *db, const char *path, WacomFal
}

/* for multiple-match devices, set to the one we requested */
- libwacom_update_match(ret, match_name, bus, vendor_id, product_id);
+ match = libwacom_match_new(match_name, bus, vendor_id, product_id);
+ libwacom_update_match(ret, match);
+ libwacom_match_destroy(match);

g_free (name);

@@ -799,28 +802,37 @@ libwacom_destroy(WacomDevice *device)
g_free (device);
}

-void
-libwacom_update_match(WacomDevice *device, const char *name, WacomBusType bus, int vendor_id, int product_id)
+WacomMatch*
+libwacom_match_new(const char *name, WacomBusType bus, int vendor_id, int product_id)
{
+ WacomMatch *match;
char *newmatch;
- int i;
- WacomMatch match;

+ match = g_malloc(sizeof(*match));
if (name == NULL && bus == WBUSTYPE_UNKNOWN && vendor_id == 0 && product_id == 0)
newmatch = g_strdup("generic");
else
newmatch = make_match_string(name, bus, vendor_id, product_id);

- match.match = newmatch;
- match.name = g_strdup(name);
- match.bus = bus;
- match.vendor_id = vendor_id;
- match.product_id = product_id;
+ match->match = newmatch;
+ match->name = g_strdup(name);
+ match->bus = bus;
+ match->vendor_id = vendor_id;
+ match->product_id = product_id;
+
+ return match;
+}
+
+void
+libwacom_update_match(WacomDevice *device, const WacomMatch *newmatch)
+{
+ int i;

for (i = 0; i < device->nmatches; i++) {
- if (g_strcmp0(libwacom_match_get_match_string(device->matches[i]), newmatch) == 0) {
+ const char *matchstr = libwacom_match_get_match_string(device->matches[i]);
+ if (g_strcmp0(matchstr, newmatch->match) == 0) {
device->match = i;
- goto out;
+ return;
}
}

@@ -828,11 +840,8 @@ libwacom_update_match(WacomDevice *device, const char *name, WacomBusType bus, i

device->matches = g_realloc_n(device->matches, device->nmatches + 1, sizeof(WacomMatch*));
device->matches[device->nmatches] = NULL;
- device->matches[device->nmatches - 1] = libwacom_copy_match(&match);
+ device->matches[device->nmatches - 1] = libwacom_copy_match(newmatch);
device->match = device->nmatches - 1;
-out:
- g_free(newmatch);
- g_free(match.name);
}

int libwacom_get_vendor_id(const WacomDevice *device)
diff --git a/libwacom/libwacomint.h b/libwacom/libwacomint.h
index af47bd5..c7d8916 100644
--- a/libwacom/libwacomint.h
+++ b/libwacom/libwacomint.h
@@ -120,7 +120,8 @@ struct _WacomError {
/* INTERNAL */
void libwacom_error_set(WacomError *error, enum WacomErrorCode code, const char *msg, ...);
void libwacom_stylus_destroy(WacomStylus *stylus);
-void libwacom_update_match(WacomDevice *device, const char *name, WacomBusType bus, int vendor_id, int product_id);
+void libwacom_update_match(WacomDevice *device, const WacomMatch *match);
+WacomMatch* libwacom_match_new(const char *name, WacomBusType bus, int vendor_id, int product_id);
void libwacom_match_destroy(WacomMatch *match);

WacomBusType bus_from_str (const char *str);
--
2.7.4
Peter Hutterer
2016-07-07 10:20:12 UTC
Permalink
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 <***@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
Aaron Armstrong Skomra
2016-07-15 20:00:24 UTC
Permalink
The newer Cintiqs have a different PID for the touch device than the pen
device which makes it hard to associate the two together in th client.
Expose that information so we can e.g. assign the same device group.
Note that this is a one-way assignment only (atm), you can get from the
tablet to the touch device but not the other way round.
Tested-by: Aaron Armstrong Skomra <***@wacom.com>

for the series.
Cheers,
Peter
------------------------------------------------------------------------------
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
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
Loading...