receiver: only check for device features once per device
This commit is contained in:
parent
f198b2706b
commit
89995656cd
|
@ -71,6 +71,7 @@ class PairedDevice(object):
|
||||||
self._keys = None
|
self._keys = None
|
||||||
self._registers = None
|
self._registers = None
|
||||||
self._settings = None
|
self._settings = None
|
||||||
|
self._feature_settings_checked = False
|
||||||
|
|
||||||
# Misc stuff that's irrelevant to any functionality, but may be
|
# Misc stuff that's irrelevant to any functionality, but may be
|
||||||
# displayed in the UI and caching it here helps.
|
# displayed in the UI and caching it here helps.
|
||||||
|
@ -251,8 +252,8 @@ class PairedDevice(object):
|
||||||
self._settings = [s(self) for s in self.descriptor.settings]
|
self._settings = [s(self) for s in self.descriptor.settings]
|
||||||
else:
|
else:
|
||||||
self._settings = []
|
self._settings = []
|
||||||
|
if not self._feature_settings_checked:
|
||||||
_check_feature_settings(self, self._settings)
|
self._feature_settings_checked =_check_feature_settings(self, self._settings)
|
||||||
return self._settings
|
return self._settings
|
||||||
|
|
||||||
def enable_notifications(self, enable=True):
|
def enable_notifications(self, enable=True):
|
||||||
|
|
|
@ -371,12 +371,13 @@ del _SETTINGS_LIST
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Returns True if device was queried to find features, False otherwise
|
||||||
def check_feature_settings(device, already_known):
|
def check_feature_settings(device, already_known):
|
||||||
"""Try to auto-detect device settings by the HID++ 2.0 features they have."""
|
"""Try to auto-detect device settings by the HID++ 2.0 features they have."""
|
||||||
if device.features is None or not device.online:
|
if device.features is None or not device.online:
|
||||||
return
|
return False
|
||||||
if device.protocol and device.protocol < 2.0:
|
if device.protocol and device.protocol < 2.0:
|
||||||
return
|
return False
|
||||||
|
|
||||||
def check_feature(name, featureId, field_name=None):
|
def check_feature(name, featureId, field_name=None):
|
||||||
"""
|
"""
|
||||||
|
@ -414,3 +415,4 @@ def check_feature_settings(device, already_known):
|
||||||
check_feature(_POINTER_SPEED[0], _F.POINTER_SPEED)
|
check_feature(_POINTER_SPEED[0], _F.POINTER_SPEED)
|
||||||
check_feature(_SMART_SHIFT[0], _F.SMART_SHIFT)
|
check_feature(_SMART_SHIFT[0], _F.SMART_SHIFT)
|
||||||
check_feature(_BACKLIGHT[0], _F.BACKLIGHT2)
|
check_feature(_BACKLIGHT[0], _F.BACKLIGHT2)
|
||||||
|
return True
|
||||||
|
|
Loading…
Reference in New Issue