diff --git a/lib/logitech/unifying_receiver/base.py b/lib/logitech/unifying_receiver/base.py index 86a4ad64..40b68e5b 100644 --- a/lib/logitech/unifying_receiver/base.py +++ b/lib/logitech/unifying_receiver/base.py @@ -371,15 +371,15 @@ def ping(handle, devnumber): delta = _timestamp() - now if reply: - report_id, number, data = reply - if number == devnumber: - if data[:2] == request_data[:2] and data[4:5] == request_data[-1:]: + report_id, reply_devnumber, reply_data = reply + if reply_devnumber == devnumber: + if reply_data[:2] == request_data[:2] and reply_data[4:5] == request_data[-1:]: # HID++ 2.0+ device, currently connected - return ord(data[2:3]) + ord(data[3:4]) / 10.0 + return ord(reply_data[2:3]) + ord(reply_data[3:4]) / 10.0 - if report_id == 0x10 and data[:1] == b'\x8F' and data[1:3] == request_data[:2]: - assert data[-1:] == b'\x00' - error = ord(data[3:4]) + if report_id == 0x10 and reply_data[:1] == b'\x8F' and reply_data[1:3] == request_data[:2]: + assert reply_data[-1:] == b'\x00' + error = ord(reply_data[3:4]) if error == _hidpp10.ERROR.invalid_SubID__command: # a valid reply from a HID++ 1.0 device return 1.0 diff --git a/lib/logitech/unifying_receiver/common.py b/lib/logitech/unifying_receiver/common.py index a69c22aa..a506a5cf 100644 --- a/lib/logitech/unifying_receiver/common.py +++ b/lib/logitech/unifying_receiver/common.py @@ -17,7 +17,7 @@ class NamedInt(int): def __new__(cls, value, name): assert isinstance(name, str) or isinstance(name, unicode) obj = int.__new__(cls, value) - obj.name = str(name) + obj.name = unicode(name) return obj def bytes(self, count=2): @@ -66,8 +66,7 @@ class NamedInts(object): def _readable_name(n): if not isinstance(n, str) and not isinstance(n, unicode): raise TypeError("expected string, got " + type(n)) - n = n.replace('__', '/').replace('_', ' ') - return str(n) + return n.replace('__', '/').replace('_', ' ') values = {k: NamedInt(v, _readable_name(k)) for (k, v) in kwargs.items()} self.__dict__ = values @@ -75,8 +74,6 @@ class NamedInts(object): self._indexed = {int(v): v for v in self._values} self._fallback = None - # print ('%r' % self) - @classmethod def range(cls, from_value, to_value, name_generator=lambda x: str(x), step=1): values = {name_generator(x): x for x in range(from_value, to_value + 1, step)} diff --git a/lib/logitech/unifying_receiver/descriptors.py b/lib/logitech/unifying_receiver/descriptors.py index 32dfac90..56849c3a 100644 --- a/lib/logitech/unifying_receiver/descriptors.py +++ b/lib/logitech/unifying_receiver/descriptors.py @@ -82,7 +82,7 @@ _D('Touch Mouse M600') _D('Marathon Mouse M705', settings=[ _register_smooth_scroll(0x01, true_value=0x40, mask=0x40), - # _register_dpi(0x63, _NamedInts.range(9, 11, lambda x: str(x * 100))), + # _register_dpi(0x63, _NamedInts(**{'100': 10, '300': 30, '350':35, '500':50})), ], ) _D('Wireless Keyboard K230') diff --git a/lib/logitech/unifying_receiver/hidpp10.py b/lib/logitech/unifying_receiver/hidpp10.py index 7295e7e9..95da0f37 100644 --- a/lib/logitech/unifying_receiver/hidpp10.py +++ b/lib/logitech/unifying_receiver/hidpp10.py @@ -41,7 +41,7 @@ POWER_SWITCH_LOCATION = _NamedInts( NOTIFICATION_FLAG = _NamedInts( battery_status=0x100000, wireless=0x000100, - software_present=0x0000800) + software_present=0x000800) ERROR = _NamedInts( invalid_SubID__command=0x01, diff --git a/lib/solaar/listener.py b/lib/solaar/listener.py index e93f381c..36f25213 100644 --- a/lib/solaar/listener.py +++ b/lib/solaar/listener.py @@ -25,7 +25,7 @@ del namedtuple def _ghost(device): return _GHOST_DEVICE(number=device.number, name=device.name, kind=device.kind, status=None, max_devices=None) -DUMMY = _GHOST_DEVICE(Receiver.number, Receiver.name, None, 'Receiver not found.', Receiver.max_devices) +DUMMY = _GHOST_DEVICE(Receiver.number, 'dialog-error', None, 'Receiver not found.', 6) # #