From 32daed2dfa22196bd4c51fdabad3d333d4839903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= Date: Fri, 22 Mar 2013 15:28:11 +0100 Subject: [PATCH] Add support for Logitech Wireless (NonUnifying) devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are Logitech Wireless devices similar to Unifying ones with the difference that device is paired with single dongle and dongle doesn't support pairing multiple devices. Add support for these. Tested with Wireless Mouse M187 and M185/M225. Signed-off-by: Arkadiusz Miƛkiewicz Signed-off-by: Richard Hughes --- rules/95-upower-csr.rules | 1 + src/linux/up-device-unifying.c | 34 ++++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/rules/95-upower-csr.rules b/rules/95-upower-csr.rules index b8d92fe..b476660 100644 --- a/rules/95-upower-csr.rules +++ b/rules/95-upower-csr.rules @@ -25,4 +25,5 @@ SUBSYSTEM!="hid", GOTO="up_unifying_end" ATTRS{idVendor}=="046d", ENV{UPOWER_VENDOR}="Logitech, Inc." ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52b", DRIVER=="logitech-djdevice", ENV{UPOWER_BATTERY_TYPE}="unifying" ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c532", DRIVER=="logitech-djdevice", ENV{UPOWER_BATTERY_TYPE}="unifying" +ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52f", ENV{UPOWER_BATTERY_TYPE}="lg-wireless" LABEL="up_unifying_end" diff --git a/src/linux/up-device-unifying.c b/src/linux/up-device-unifying.c index 633909f..f6636e6 100644 --- a/src/linux/up-device-unifying.c +++ b/src/linux/up-device-unifying.c @@ -142,7 +142,7 @@ up_device_unifying_coldplug (UpDevice *device) type = g_udev_device_get_property (native, "UPOWER_BATTERY_TYPE"); if (type == NULL) goto out; - if (g_strcmp0 (type, "unifying") != 0) + if ((g_strcmp0 (type, "unifying") != 0) && (g_strcmp0 (type, "lg-wireless") != 0)) goto out; /* get the device index */ @@ -153,23 +153,37 @@ up_device_unifying_coldplug (UpDevice *device) g_debug ("Could not get physical device index"); goto out; } - hidpp_device_set_index (unifying->priv->hidpp_device, + + if (g_strcmp0 (type, "lg-wireless") == 0) + hidpp_device_set_index (unifying->priv->hidpp_device, 1); + else { + hidpp_device_set_index (unifying->priv->hidpp_device, g_ascii_strtoull (tmp + 1, &endptr, 10)); - if (endptr != NULL && endptr[0] != '\0') { - g_debug ("HID_PHYS malformed: '%s'", bus_address); - goto out; + if (endptr != NULL && endptr[0] != '\0') { + g_debug ("HID_PHYS malformed: '%s'", bus_address); + goto out; + } } - /* find the hidraw device that matches the parent */ + /* find the hidraw device that matches */ parent = g_udev_device_get_parent (native); client = g_udev_client_new (NULL); hidraw_list = g_udev_client_query_by_subsystem (client, "hidraw"); for (l = hidraw_list; l != NULL; l = l->next) { - if (g_strcmp0 (g_udev_device_get_sysfs_path (parent), - g_udev_device_get_sysfs_path(g_udev_device_get_parent(l->data))) == 0) { - receiver = g_object_ref (l->data); - break; + if (g_strcmp0 (type, "lg-wireless") == 0) { + 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) + continue; + } else { + if (g_strcmp0 (g_udev_device_get_sysfs_path (parent), + g_udev_device_get_sysfs_path(g_udev_device_get_parent(l->data))) != 0) + continue; } + receiver = g_object_ref (l->data); + break; } if (receiver == NULL) { g_debug ("Unable to find an hidraw device for Unifying receiver");