From 51ec36fef4935e0cff8e21e6abac0cfb5a038525 Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Tue, 11 Oct 2022 08:45:06 -0400 Subject: [PATCH] receiver: rationalize receiver information structure --- lib/logitech_receiver/base_usb.py | 4 +--- lib/logitech_receiver/device.py | 2 +- lib/logitech_receiver/receiver.py | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/logitech_receiver/base_usb.py b/lib/logitech_receiver/base_usb.py index 308b3d3c..5ea4d658 100644 --- a/lib/logitech_receiver/base_usb.py +++ b/lib/logitech_receiver/base_usb.py @@ -35,7 +35,6 @@ from .i18n import _ ## should this last be changed so that may_unpair is used for all receivers? writing to _R.receiver_pairing doesn't seem right # re_pairs determines whether a receiver pairs by replacing existing pairings, default to False ## currently only one receiver is so marked - should there be more? -# ex100_27mhz_wpid_fix enable workarounds for EX100 and possible other old 27Mhz receivers _DRIVER = ('hid-generic', 'generic-usb', 'logitech-djreceiver') @@ -135,8 +134,7 @@ _ex100_receiver = lambda product_id: { 'receiver_kind': '27Mhz', 'max_devices': 4, 'may_unpair': False, - 're_pairs': True, - 'ex100_27mhz_wpid_fix': True + 're_pairs': True } # Receivers added here should also be listed in diff --git a/lib/logitech_receiver/device.py b/lib/logitech_receiver/device.py index e2426be1..3f719541 100644 --- a/lib/logitech_receiver/device.py +++ b/lib/logitech_receiver/device.py @@ -116,7 +116,7 @@ class Device: # assert link_notification.address == (0x04 if unifying else 0x03) kind = ord(link_notification.data[0:1]) & 0x0F # get 27Mhz wpid and set kind based on index - if receiver.ex100_27mhz_wpid_fix: # 27 Mhz receiver + if receiver.receiver_kind == '27Mhz': # 27 Mhz receiver self.wpid = '00' + _strhex(link_notification.data[2:3]) kind = self.get_kind_from_index(number, receiver) self._kind = _hidpp10.DEVICE_KIND[kind] diff --git a/lib/logitech_receiver/receiver.py b/lib/logitech_receiver/receiver.py index f0df4353..f24b8804 100644 --- a/lib/logitech_receiver/receiver.py +++ b/lib/logitech_receiver/receiver.py @@ -83,12 +83,11 @@ class Receiver: self.may_unpair = product_info.get('may_unpair', False) self.last_id = self.last_id if self.last_id else self.max_devices - self.name = product_info.get('name', '') + self.name = product_info.get('name', 'Receiver') self.re_pairs = product_info.get('re_pairs', False) self._str = '<%s(%s,%s%s)>' % ( self.name.replace(' ', ''), self.path, '' if isinstance(self.handle, int) else 'T', self.handle ) - self.ex100_27mhz_wpid_fix = product_info.get('ex100_27mhz_wpid_fix', False) self._firmware = None self._devices = {} @@ -174,7 +173,7 @@ class Receiver: wpid = _strhex(pair_info[3:5]) kind = _hidpp10.DEVICE_KIND[ord(pair_info[7:8]) & 0x0F] polling_rate = ord(pair_info[2:3]) - elif self.ex100_27mhz_wpid_fix: # 27Mhz receiver, fill extracting WPID from udev path + elif self.receiver_kind == '27Mz': # 27Mhz receiver, fill extracting WPID from udev path wpid = _hid.find_paired_node_wpid(self.path, n) if not wpid: _log.error('Unable to get wpid from udev for device %d of %s', n, self)