minor clean-ups
This commit is contained in:
parent
64c36a1562
commit
d7dd9393ff
|
@ -59,6 +59,7 @@ def exit():
|
|||
|
||||
def _match(action, device, vendor_id=None, product_id=None, interface_number=None, driver=None):
|
||||
usb_device = device.find_parent('usb', 'usb_device')
|
||||
# print (action, device, "usb:", usb_device)
|
||||
if not usb_device:
|
||||
return
|
||||
|
||||
|
@ -70,6 +71,7 @@ def _match(action, device, vendor_id=None, product_id=None, interface_number=Non
|
|||
|
||||
if action == 'add':
|
||||
hid_device = device.find_parent('hid')
|
||||
# print (action, device, "hid:", usb_device)
|
||||
if not hid_device:
|
||||
return
|
||||
hid_driver_name = hid_device['DRIVER']
|
||||
|
@ -77,6 +79,7 @@ def _match(action, device, vendor_id=None, product_id=None, interface_number=Non
|
|||
return
|
||||
|
||||
intf_device = device.find_parent('usb', 'usb_interface')
|
||||
# print (action, device, "usb_interface:", usb_device)
|
||||
if interface_number is None:
|
||||
usb_interface = None if intf_device is None else intf_device.attributes.asint('bInterfaceNumber')
|
||||
else:
|
||||
|
|
|
@ -61,7 +61,7 @@ class DeviceUnreachable(_KwException):
|
|||
# vendor_id, product_id, interface number, driver
|
||||
DEVICE_UNIFYING_RECEIVER = (0x046d, 0xc52b, 2, 'logitech-djreceiver')
|
||||
DEVICE_UNIFYING_RECEIVER_2 = (0x046d, 0xc532, 2, 'logitech-djreceiver')
|
||||
#DEVICE_NANO_RECEIVER = (0x046d, 0xc526, 1, 'generic-usb')
|
||||
DEVICE_NANO_RECEIVER = (0x046d, 0xc526, 1, 'generic-usb')
|
||||
|
||||
|
||||
def receivers():
|
||||
|
|
|
@ -214,7 +214,7 @@ class Receiver(object):
|
|||
serial_reply = self.request(0x83B5, 0x03)
|
||||
assert serial_reply
|
||||
self._serial = _strhex(serial_reply[1:5])
|
||||
self.max_devices = ord(serial_reply[6:7][0:1])
|
||||
self.max_devices = ord(serial_reply[6:7])
|
||||
|
||||
if self.max_devices == 1:
|
||||
self.name = 'Nano Receiver'
|
||||
|
|
|
@ -87,7 +87,7 @@ def _print_receiver(receiver, verbose=False):
|
|||
for f in receiver.firmware:
|
||||
print (" %-11s: %s" % (f.kind, f.version))
|
||||
|
||||
print (" Has", paired_count, "paired device(s).")
|
||||
print (" Has", paired_count, "paired device(s) out of a maximum of", receiver.max_devices)
|
||||
|
||||
notification_flags = receiver.request(0x8100)
|
||||
if notification_flags:
|
||||
|
@ -97,7 +97,7 @@ def _print_receiver(receiver, verbose=False):
|
|||
notification_names = hidpp10.NOTIFICATION_FLAG.flag_names(notification_flags)
|
||||
print (" Enabled notifications: 0x%06X = %s." % (notification_flags, ', '.join(notification_names)))
|
||||
else:
|
||||
print (" All notifications disabled.")
|
||||
print (" All notifications disabled")
|
||||
|
||||
if paired_count > 0:
|
||||
activity = receiver.request(0x83B3)
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#
|
||||
#
|
||||
#
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
sys.path += (sys.path[0] + '/../lib',)
|
||||
|
||||
import hidapi
|
||||
from logitech.unifying_receiver.base import DEVICE_UNIFYING_RECEIVER
|
||||
from logitech.unifying_receiver.base import DEVICE_UNIFYING_RECEIVER_2
|
||||
from logitech.unifying_receiver.base import DEVICE_NANO_RECEIVER
|
||||
|
||||
|
||||
def print_event(action, device):
|
||||
print ("~~~~ device [%s] %s" % (action, device))
|
||||
|
||||
|
||||
hidapi.monitor(print_event,
|
||||
DEVICE_UNIFYING_RECEIVER,
|
||||
DEVICE_UNIFYING_RECEIVER_2,
|
||||
DEVICE_NANO_RECEIVER
|
||||
)
|
Loading…
Reference in New Issue