receiver: use only product records to determine whether receivers can unpair

This commit is contained in:
Peter F. Patel-Schneider 2022-09-15 09:34:18 -04:00
parent 5ed4c05db8
commit a1aa584b7e
2 changed files with 7 additions and 9 deletions

View File

@ -56,7 +56,8 @@ _unifying_receiver = lambda product_id: {
'usb_interface': 2,
'hid_driver': _DRIVER, # noqa: F821
'name': _('Unifying Receiver'),
'receiver_kind': 'unifying'
'receiver_kind': 'unifying',
'may_unpair': True
}
_nano_receiver = lambda product_id: {
@ -112,7 +113,8 @@ _lenovo_receiver = lambda product_id: {
'usb_interface': 1,
'hid_driver': _DRIVER, # noqa: F821
'name': _('Nano Receiver'),
'receiver_kind': 'nano'
'receiver_kind': 'nano',
'may_unpair': False
}
_lightspeed_receiver = lambda product_id: {
@ -120,7 +122,8 @@ _lightspeed_receiver = lambda product_id: {
'product_id': product_id,
'usb_interface': 2,
'hid_driver': _DRIVER, # noqa: F821
'name': _('Lightspeed Receiver')
'name': _('Lightspeed Receiver'),
'may_unpair': False
}
_ex100_receiver = lambda product_id: {

View File

@ -76,12 +76,7 @@ class Receiver:
self.last_id = ord(serial_reply[7:8])
if self.max_devices <= 0 or self.max_devices > 6:
self.max_devices = product_info.get('max_devices', 1)
# TODO _properly_ figure out which receivers do and which don't support unpairing
# This code supposes that receivers that don't unpair support a pairing request for device index 0
if 'unpair' in product_info:
self.may_unpair = product_info['unpair']
else:
self.may_unpair = self.write_register(_R.receiver_pairing) is None
self.may_unpair = product_info.get('may_unpair', False)
else: # handle receivers that don't have a serial number specially (i.e., c534 and Bolt receivers)
self.serial = None
self.max_devices = product_info.get('max_devices', 1)