diff options
author | Arkadiusz Miśkiewicz <arekm@maven.pl> | 2013-03-28 09:59:55 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2013-03-28 12:14:11 +0000 |
commit | 09fa9d5463f4c64f6d24448545948761b258d226 (patch) | |
tree | 9756f8eb576607f54998775842084b384f0ef5ee | |
parent | d4bec29c8296edffad717c579528234b52cca89c (diff) | |
download | upower-09fa9d5463f4c64f6d24448545948761b258d226.tar.gz |
Locate non-unifying receiver by looking for hidraw with hiddev exposed.
For non unifying receiver we were trying to locate receiver hiddraw
device by looking into INTERFACES property. This doesn't work well
for non-unifying devices from keyboard+mouse sets (which use single
dongle for 2 devices but are still non-unifying).
The only thing that's different between hiddraw receiver and other
devices (mouse, keyboard etc) is that receiver also exposes hiddev
interface.
Use that fact to reliably locate receiver.
Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
Signed-off-by: Richard Hughes <richard@hughsie.com>
-rw-r--r-- | src/linux/up-device-unifying.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/linux/up-device-unifying.c b/src/linux/up-device-unifying.c index ea8b0b3..d98ba88 100644 --- a/src/linux/up-device-unifying.c +++ b/src/linux/up-device-unifying.c @@ -183,11 +183,32 @@ up_device_unifying_coldplug (UpDevice *device) hidraw_list = g_udev_client_query_by_subsystem (client, "hidraw"); for (l = hidraw_list; l != NULL; l = l->next) { if (g_strcmp0 (type, "lg-wireless") == 0) { + gboolean receiver_found = FALSE; + const gchar *filename; + GDir* dir; + if (g_strcmp0 (g_udev_device_get_sysfs_path (native), g_udev_device_get_sysfs_path(g_udev_device_get_parent(l->data))) != 0) continue; - // Ugly way to distinguish receiver itself from mouse/keyboard etc for non-unifying dongles - if (g_strcmp0(g_udev_device_get_property(g_udev_device_get_parent (native), "INTERFACE"), "3/0/0") != 0) + + /* hidraw device which exposes hiddev interface is our receiver */ + tmp = g_build_filename(g_udev_device_get_sysfs_path (g_udev_device_get_parent(native)), + "usbmisc", NULL); + dir = g_dir_open (tmp, 0, &error); + g_free(tmp); + if (error) { + g_clear_error(&error); + continue; + } + while ( (filename = g_dir_read_name(dir)) ) { + if (g_ascii_strncasecmp(filename, "hiddev", 6) == 0) { + receiver_found = TRUE; + break; + } + } + g_dir_close(dir); + + if (!receiver_found) continue; } else { if (g_strcmp0 (g_udev_device_get_sysfs_path (parent), |