From d38bec39b6ec2a1a8d663cfd6752de104694d6eb Mon Sep 17 00:00:00 2001 From: Daniel Pavel Date: Sat, 8 Dec 2012 00:41:43 +0200 Subject: [PATCH] improved hid++ support --- lib/hidapi/udev.py | 1 + lib/logitech/unifying_receiver/receiver.py | 2 +- lib/logitech/unifying_receiver/status.py | 8 +++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/hidapi/udev.py b/lib/hidapi/udev.py index 98ee6558..acdf0045 100644 --- a/lib/hidapi/udev.py +++ b/lib/hidapi/udev.py @@ -195,6 +195,7 @@ def read(device_handle, bytes_count, timeout_ms=-1): if rlist: assert rlist == [device_handle] data = _os.read(device_handle, bytes_count) + assert data is not None return data else: return b'' diff --git a/lib/logitech/unifying_receiver/receiver.py b/lib/logitech/unifying_receiver/receiver.py index 54ad45bf..ed8f33e7 100644 --- a/lib/logitech/unifying_receiver/receiver.py +++ b/lib/logitech/unifying_receiver/receiver.py @@ -252,7 +252,7 @@ class Receiver(object): return False if enable: # set all possible flags - ok = self.request(0x8000, 0xFF, 0xFF) # and self.request(0x8002, 0x02) + ok = self.request(0x8000, 0xFF, 0xFF, 0xFF) else: # clear out all possible flags ok = self.request(0x8000) diff --git a/lib/logitech/unifying_receiver/status.py b/lib/logitech/unifying_receiver/status.py index ccdc43b4..a7a87a17 100644 --- a/lib/logitech/unifying_receiver/status.py +++ b/lib/logitech/unifying_receiver/status.py @@ -193,9 +193,15 @@ class DeviceStatus(dict): return True + if event.sub_id == 0x49: + # raw input event? just ignore it + # if event.address == 0x01, no idea what it is + # if event.address == 0x03, it's an actual input event + return True + if event.sub_id == 0x4B: if event.address == 0x01: - _log.debug("device came online? %d", event.devnumber) + _log.debug("device came online %d", event.devnumber) self._changed(alert=ALERT.LOW, reason='powered on') else: _log.warn("unknown event %s", event)