fixed handling of protocol version when the device is offline
This commit is contained in:
parent
141a5c3dee
commit
a966bbff6f
|
@ -140,7 +140,7 @@ def get_battery(device):
|
|||
return
|
||||
|
||||
"""Reads a device's battery level, if provided by the HID++ 1.0 protocol."""
|
||||
if device.protocol >= 2.0:
|
||||
if device.protocol and device.protocol >= 2.0:
|
||||
# let's just assume HID++ 2.0 devices do not provide the battery info in a register
|
||||
return
|
||||
|
||||
|
@ -288,8 +288,7 @@ def get_notification_flags(device):
|
|||
# or the device does not support registers.
|
||||
if device.kind is not None:
|
||||
# peripherals with protocol >= 2.0 don't support registers
|
||||
p = device.protocol
|
||||
if p is not None and p >= 2.0:
|
||||
if device.protocol and device.protocol >= 2.0:
|
||||
return
|
||||
|
||||
flags = read_register(device, REGISTERS.notifications)
|
||||
|
@ -305,8 +304,7 @@ def set_notification_flags(device, *flag_bits):
|
|||
# or the device does not support registers.
|
||||
if device.kind is not None:
|
||||
# peripherals with protocol >= 2.0 don't support registers
|
||||
p = device.protocol
|
||||
if p is not None and p >= 2.0:
|
||||
if device.protocol and device.protocol >= 2.0:
|
||||
return
|
||||
|
||||
flag_bits = sum(int(b) for b in flag_bits)
|
||||
|
|
|
@ -146,7 +146,7 @@ class FeaturesArray(object):
|
|||
return False
|
||||
|
||||
# I _think_ this is universally true
|
||||
if self.device.protocol is not None and self.device.protocol < 2.0:
|
||||
if self.device.protocol and self.device.protocol < 2.0:
|
||||
self.supported = False
|
||||
self.device.features = None
|
||||
self.device = None
|
||||
|
|
|
@ -143,7 +143,7 @@ class PairedDevice(object):
|
|||
@property
|
||||
def name(self):
|
||||
if self._name is None:
|
||||
if self.protocol >= 2.0 and self.online:
|
||||
if self.online and self.protocol >= 2.0:
|
||||
self._name = _hidpp20.get_name(self)
|
||||
return self._name or self.codename or ('Unknown device %s' % self.wpid)
|
||||
|
||||
|
@ -155,7 +155,7 @@ class PairedDevice(object):
|
|||
kind = ord(pair_info[7:8]) & 0x0F
|
||||
self._kind = _hidpp10.DEVICE_KIND[kind]
|
||||
self._polling_rate = ord(pair_info[2:3])
|
||||
elif self.protocol >= 2.0:
|
||||
elif self.online and self.protocol >= 2.0:
|
||||
self._kind = _hidpp20.get_kind(self)
|
||||
return self._kind or '?'
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ def check_feature_settings(device, already_known):
|
|||
"""Try to auto-detect device settings by the HID++ 2.0 features they have."""
|
||||
if device.features is None:
|
||||
return
|
||||
if device.protocol is not None and device.protocol < 2.0:
|
||||
if device.protocol and device.protocol < 2.0:
|
||||
return
|
||||
if not any(s.name == _FN_SWAP[0] for s in already_known) and _F.FN_INVERSION in device.features:
|
||||
fn_swap = FeatureSettings.fn_swap()
|
||||
|
|
Loading…
Reference in New Issue