device: fix bug in feature lookup

This commit is contained in:
Peter F. Patel-Schneider 2022-04-29 07:22:03 -04:00
parent 13df79d7af
commit 85bcfe7310
2 changed files with 2 additions and 2 deletions

View File

@ -192,7 +192,7 @@ def _process_device_notification(device, status, n):
_log.warn('%s: feature notification but features not set up: %02X %s', device, n.sub_id, n) _log.warn('%s: feature notification but features not set up: %02X %s', device, n.sub_id, n)
return False return False
try: try:
feature = device.features[n.sub_id] feature = device.features.get_feature(n.sub_id)
except IndexError: except IndexError:
_log.warn('%s: notification from invalid feature index %02X: %s', device, n.sub_id, n) _log.warn('%s: notification from invalid feature index %02X: %s', device, n.sub_id, n)
return False return False

View File

@ -1243,7 +1243,7 @@ class ActionSettingRW:
def write(self, device, data_bytes): def write(self, device, data_bytes):
def handler(device, n): # Called on notification events from the device def handler(device, n): # Called on notification events from the device
if n.sub_id < 0x40 and device.features[n.sub_id] == _hidpp20.FEATURE.REPROG_CONTROLS_V4: if n.sub_id < 0x40 and device.features.get_feature(n.sub_id) == _hidpp20.FEATURE.REPROG_CONTROLS_V4:
if n.address == 0x00: if n.address == 0x00:
cids = _unpack('!HHHH', n.data[:8]) cids = _unpack('!HHHH', n.data[:8])
if not self.pressed and int(self.key.key) in cids: # trigger key pressed if not self.pressed and int(self.key.key) in cids: # trigger key pressed