summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libwacom/libwacom.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c
index 41acbf6..1c34715 100644
--- a/libwacom/libwacom.c
+++ b/libwacom/libwacom.c
@@ -50,7 +50,7 @@ get_device_info (const char *path,
WacomError *error)
{
GUdevClient *client;
- GUdevDevice *device;
+ GUdevDevice *device, *parent = NULL;
const char * const subsystems[] = { "input", NULL };
gboolean retval;
const char *bus_str;
@@ -69,10 +69,17 @@ get_device_info (const char *path,
/* Touchpads are only for the "Finger" part of Bamboo devices */
if (g_udev_device_get_property_as_boolean (device, "ID_INPUT_TABLET") == FALSE &&
g_udev_device_get_property_as_boolean (device, "ID_INPUT_TOUCHPAD") == FALSE) {
- libwacom_error_set(error, WERROR_INVALID_PATH, "Device '%s' is not a tablet", path);
- goto bail;
+ parent = g_udev_device_get_parent(device);
+ if (!parent || (g_udev_device_get_property_as_boolean (parent, "ID_INPUT_TABLET") == FALSE &&
+ g_udev_device_get_property_as_boolean (parent, "ID_INPUT_TOUCHPAD") == FALSE)) {
+ libwacom_error_set(error, WERROR_INVALID_PATH, "Device '%s' is not a tablet", path);
+ goto bail;
+ }
}
+ /* FIXME: ID_BUS on the device is usb even for bluetooth devices,
+ * but ID_BUS on the parent is NULL.
+ */
bus_str = g_udev_device_get_property (device, "ID_BUS");
/* Serial devices are weird */
if (bus_str == NULL) {
@@ -81,12 +88,12 @@ get_device_info (const char *path,
}
/* Poke the parent device for Bluetooth models */
if (bus_str == NULL) {
- GUdevDevice *parent;
-
- parent = g_udev_device_get_parent (device);
+ if (!parent)
+ parent = g_udev_device_get_parent (device);
g_object_unref (device);
device = parent;
+ parent = NULL;
bus_str = "bluetooth";
}
@@ -163,6 +170,8 @@ get_device_info (const char *path,
bail:
if (retval == FALSE)
g_free (*name);
+ if (parent != NULL)
+ g_object_unref (parent);
if (device != NULL)
g_object_unref (device);
if (client != NULL)