From a8c5d3bc2405c8b423522f39ed758fcedabc4be0 Mon Sep 17 00:00:00 2001 From: Daniel Pavel Date: Thu, 18 Jul 2013 14:01:36 +0200 Subject: [PATCH] Nano receivers were unsupported on kernel 3.2; fixes #88 --- lib/hidapi/udev.py | 8 ++++++-- lib/logitech_receiver/base_usb.py | 26 ++++++++++++++++---------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/lib/hidapi/udev.py b/lib/hidapi/udev.py index f7404d1e..56786822 100644 --- a/lib/hidapi/udev.py +++ b/lib/hidapi/udev.py @@ -94,8 +94,12 @@ def _match(action, device, vendor_id=None, product_id=None, interface_number=Non if not hid_device: return hid_driver_name = hid_device['DRIVER'] - if hid_driver is not None and hid_driver != hid_driver_name: - return + if hid_driver: + if isinstance(hid_driver, tuple): + if hid_driver_name not in hid_driver: + return + elif hid_driver_name != hid_driver: + return intf_device = device.find_parent('usb', 'usb_interface') # print ("*** usb interface", action, device, "usb_interface:", intf_device) diff --git a/lib/logitech_receiver/base_usb.py b/lib/logitech_receiver/base_usb.py index 8b1e82ce..173faa3e 100644 --- a/lib/logitech_receiver/base_usb.py +++ b/lib/logitech_receiver/base_usb.py @@ -23,23 +23,29 @@ from __future__ import absolute_import, division, print_function, unicode_literals +_UNIFYING_DRIVER = 'logitech-djreceiver' +_GENERIC_DRIVER = ('hid-generic', 'generic-usb') + + # each tuple contains (vendor_id, product_id, usb interface number, hid driver) # standard Unifying receivers (marked with the orange Unifying logo) -UNIFYING_RECEIVER = (0x046d, 0xc52b, 2, 'logitech-djreceiver') -UNIFYING_RECEIVER_2 = (0x046d, 0xc532, 2, 'logitech-djreceiver') +UNIFYING_RECEIVER = (0x046d, 0xc52b, 2, _UNIFYING_DRIVER) +UNIFYING_RECEIVER_2 = (0x046d, 0xc532, 2, _UNIFYING_DRIVER) + + # Nano receviers that support the Unifying protocol -NANO_RECEIVER_ADVANCED = (0x046d, 0xc52f, 1, 'hid-generic') +NANO_RECEIVER_ADVANCED = (0x046d, 0xc52f, 1, _GENERIC_DRIVER) # Nano receivers that don't support the Unifying protocol -NANO_RECEIVER_C517 = (0x046d, 0xc517, 1, 'hid-generic') -NANO_RECEIVER_C518 = (0x046d, 0xc518, 1, 'hid-generic') -NANO_RECEIVER_C51A = (0x046d, 0xc51a, 1, 'hid-generic') -NANO_RECEIVER_C51B = (0x046d, 0xc51b, 1, 'hid-generic') -NANO_RECEIVER_C521 = (0x046d, 0xc521, 1, 'hid-generic') -NANO_RECEIVER_C525 = (0x046d, 0xc525, 1, 'hid-generic') -NANO_RECEIVER_C526 = (0x046d, 0xc526, 1, 'hid-generic') +NANO_RECEIVER_C517 = (0x046d, 0xc517, 1, _GENERIC_DRIVER) +NANO_RECEIVER_C518 = (0x046d, 0xc518, 1, _GENERIC_DRIVER) +NANO_RECEIVER_C51A = (0x046d, 0xc51a, 1, _GENERIC_DRIVER) +NANO_RECEIVER_C51B = (0x046d, 0xc51b, 1, _GENERIC_DRIVER) +NANO_RECEIVER_C521 = (0x046d, 0xc521, 1, _GENERIC_DRIVER) +NANO_RECEIVER_C525 = (0x046d, 0xc525, 1, _GENERIC_DRIVER) +NANO_RECEIVER_C526 = (0x046d, 0xc526, 1, _GENERIC_DRIVER)