diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2012-03-29 11:42:27 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-03-29 14:14:51 +1000 |
commit | f56bc2445dfc5169f91065d00b89f2cd52d0d5b5 (patch) | |
tree | 4bed6014c98516b7faa8db208e46349a58d08770 | |
parent | 65a4f3dc7075f8f0152529c041d7793c09b556da (diff) |
lib: Add internal libwacom_update_match() helper
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | libwacom/libwacom.c | 17 | ||||
-rw-r--r-- | libwacom/libwacomint.h | 2 |
2 files changed, 14 insertions, 5 deletions
diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c index 27fcd98..e00af67 100644 --- a/libwacom/libwacom.c +++ b/libwacom/libwacom.c @@ -98,6 +98,7 @@ get_device_info (const char *path, sysfs_path = g_build_filename ("/sys/class/input", devname, "device/properties", NULL); if (g_file_get_contents (sysfs_path, &contents, NULL, NULL)) { int flag; + /* 0x01: POINTER flag * 0x02: DIRECT flag */ flag = atoi(contents); @@ -253,11 +254,7 @@ libwacom_new_from_path(WacomDeviceDatabase *db, const char *path, int fallback, g_free (ret->name); ret->name = name; } - ret->vendor_id = vendor_id; - ret->product_id = product_id; - ret->bus = bus; - g_free (ret->match); - ret->match = g_strdup_printf ("%s:0x%x:0x%x", bus_to_str (bus), vendor_id, product_id); + libwacom_update_match(ret, bus, vendor_id, product_id); } else { g_free (name); } @@ -337,6 +334,16 @@ libwacom_destroy(WacomDevice *device) g_free (device); } +void +libwacom_update_match(WacomDevice *device, WacomBusType bus, int vendor_id, int product_id) +{ + device->vendor_id = vendor_id; + 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); +} + int libwacom_get_vendor_id(WacomDevice *device) { return device->vendor_id; diff --git a/libwacom/libwacomint.h b/libwacom/libwacomint.h index 60644ce..a5bbd81 100644 --- a/libwacom/libwacomint.h +++ b/libwacom/libwacomint.h @@ -106,10 +106,12 @@ 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, WacomBusType bus, int vendor_id, int product_id); WacomBusType bus_from_str (const char *str); const char *bus_to_str (WacomBusType bus); + #endif /* _LIBWACOMINT_H_ */ /* vim: set noexpandtab shiftwidth=8: */ |