hidpp20: be defensive about no device features
This commit is contained in:
parent
94e94c1254
commit
7520c9cc28
|
|
@ -204,7 +204,7 @@ class Device:
|
|||
self.registers = self.descriptor.registers if self.descriptor.registers else []
|
||||
|
||||
if self._protocol is not None:
|
||||
self.features = None if self._protocol < 2.0 else hidpp20.FeaturesArray(self)
|
||||
self.features = {} if self._protocol < 2.0 else hidpp20.FeaturesArray(self)
|
||||
else:
|
||||
self.features = hidpp20.FeaturesArray(self) # may be a 2.0 device; if not, it will fix itself later
|
||||
|
||||
|
|
|
|||
|
|
@ -1690,10 +1690,10 @@ class Hidpp20:
|
|||
def get_keys(self, device: Device):
|
||||
# TODO: add here additional variants for other REPROG_CONTROLS
|
||||
count = None
|
||||
if SupportedFeature.REPROG_CONTROLS_V2 in device.features:
|
||||
if device.features and SupportedFeature.REPROG_CONTROLS_V2 in device.features:
|
||||
count = device.feature_request(SupportedFeature.REPROG_CONTROLS_V2)
|
||||
return KeysArrayV2(device, ord(count[:1]))
|
||||
elif SupportedFeature.REPROG_CONTROLS_V4 in device.features:
|
||||
elif device.features and SupportedFeature.REPROG_CONTROLS_V4 in device.features:
|
||||
count = device.feature_request(SupportedFeature.REPROG_CONTROLS_V4)
|
||||
return KeysArrayV4(device, ord(count[:1]))
|
||||
return None
|
||||
|
|
|
|||
Loading…
Reference in New Issue