fixed checking for features of offline 2.0 devices

This commit is contained in:
Daniel Pavel 2013-06-20 17:21:23 +02:00
parent 3d8c764eb0
commit 1d9a3bf23a
2 changed files with 4 additions and 5 deletions

View File

@ -47,7 +47,7 @@ def _feature_fn_swap():
def check_features(device, already_known): def check_features(device, already_known):
if device.protocol < 2.0: if device.protocol is not None and device.protocol < 2.0:
return return
if not any(s.name == _FN_SWAP[0] for s in already_known) and _hidpp20.FEATURE.FN_INVERSION in device.features: if not any(s.name == _FN_SWAP[0] for s in already_known) and _hidpp20.FEATURE.FN_INVERSION in device.features:
already_known.append(_feature_fn_swap()) already_known.append(_feature_fn_swap())

View File

@ -141,19 +141,18 @@ class FeaturesArray(object):
self.supported = False self.supported = False
def _check(self): def _check(self):
# print (self.device, "check") # print (self.device, "check", self.supported, self.features, self.device.protocol)
if self.supported: if self.supported:
assert self.device assert self.device
if self.features is not None: if self.features is not None:
return True return True
protocol = self.device.protocol if hasattr(self.device, 'status') and not bool(self.device.status):
if protocol == 0:
# device is not connected right now, will have to try later # device is not connected right now, will have to try later
return False return False
# I _think_ this is universally true # I _think_ this is universally true
if protocol < 2.0: if self.device.protocol < 2.0:
self.supported = False self.supported = False
# self.device.features = None # self.device.features = None
self.device = None self.device = None