summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-03-29 11:53:28 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-03-29 14:14:54 +1000
commit7e1e1e4f1a4379ec2e1568caaf5b6fc4b933c11e (patch)
treeed952e59b0442806a65d0123e8a833ee909d3b21
parentf56bc2445dfc5169f91065d00b89f2cd52d0d5b5 (diff)
lib: Add make_match_string() helper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--libwacom/libwacom-database.c9
-rw-r--r--libwacom/libwacom.c4
-rw-r--r--libwacom/libwacomint.h1
3 files changed, 10 insertions, 4 deletions
diff --git a/libwacom/libwacom-database.c b/libwacom/libwacom-database.c
index bb2cf6a..ff87d54 100644
--- a/libwacom/libwacom-database.c
+++ b/libwacom/libwacom-database.c
@@ -114,6 +114,12 @@ bus_to_str (WacomBusType bus)
g_assert_not_reached ();
}
+char *
+make_match_string (WacomBusType bus, int vendor_id, int product_id)
+{
+ return g_strdup_printf("%s:%04x:%04x", bus_to_str (bus), vendor_id, product_id);
+}
+
static int
libwacom_matchstr_to_ints(const char *match, uint32_t *vendor_id, uint32_t *product_id, WacomBusType *bus)
{
@@ -145,7 +151,6 @@ libwacom_parse_stylus_keyfile(WacomDeviceDatabase *db, const char *path)
rc = g_key_file_load_from_file(keyfile, path, G_KEY_FILE_NONE, &error);
g_assert (rc);
-
groups = g_key_file_get_groups (keyfile, NULL);
for (i = 0; groups[i]; i++) {
WacomStylus *stylus;
@@ -301,7 +306,7 @@ libwacom_parse_tablet_keyfile(const char *path)
device = NULL;
goto out;
}
- device->match = g_strdup_printf ("%s:%04x:%04x", bus_to_str (device->bus), device->vendor_id, device->product_id);
+ device->match = make_match_string(device->bus, device->vendor_id, device->product_id);
g_free (match);
}
diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c
index e00af67..ad9cc3f 100644
--- a/libwacom/libwacom.c
+++ b/libwacom/libwacom.c
@@ -207,7 +207,7 @@ libwacom_new (WacomDeviceDatabase *db, int vendor_id, int product_id, WacomBusTy
return NULL;
}
- match = g_strdup_printf ("%s:%04x:%04x", bus_to_str (bus), vendor_id, product_id);
+ match = make_match_string(bus, vendor_id, product_id);
device = libwacom_get_device(db, match);
g_free (match);
@@ -341,7 +341,7 @@ libwacom_update_match(WacomDevice *device, WacomBusType bus, int vendor_id, int
device->product_id = product_id;
device->bus = bus;
g_free(device->match);
- device->match = g_strdup_printf("%s:0x%x:0x%x", bus_to_str (bus), vendor_id, product_id);
+ device->match = make_match_string(device->bus, device->vendor_id, device->product_id);
}
int libwacom_get_vendor_id(WacomDevice *device)
diff --git a/libwacom/libwacomint.h b/libwacom/libwacomint.h
index a5bbd81..6bdb6df 100644
--- a/libwacom/libwacomint.h
+++ b/libwacom/libwacomint.h
@@ -110,6 +110,7 @@ void libwacom_update_match(WacomDevice *device, WacomBusType bus, int vendor_id,
WacomBusType bus_from_str (const char *str);
const char *bus_to_str (WacomBusType bus);
+char *make_match_string(WacomBusType bus, int vendor_id, int product_id);
#endif /* _LIBWACOMINT_H_ */