re-read device settings when they come back online
This commit is contained in:
parent
5bdacb377c
commit
30fedf418c
|
@ -35,8 +35,8 @@ def _process_apply_queue():
|
|||
value = setting.write(value)
|
||||
GObject.idle_add(_update_setting_item, sbox, value)
|
||||
elif task[0] == 'read':
|
||||
_, setting, sbox = task
|
||||
value = setting.read()
|
||||
_, setting, sbox, cached = task
|
||||
value = setting.read(cached)
|
||||
GObject.idle_add(_update_setting_item, sbox, value)
|
||||
|
||||
from threading import Thread as _Thread
|
||||
|
@ -155,22 +155,23 @@ def update(frame):
|
|||
box.foreach(lambda x, _: box.remove(x), None)
|
||||
return
|
||||
|
||||
items = box.get_children()
|
||||
if not items and not device.status:
|
||||
# don't bother adding settings for offline devices,
|
||||
# they're useless and might not guess all of them anyway
|
||||
return
|
||||
|
||||
if not device.settings:
|
||||
# nothing to do here
|
||||
return
|
||||
|
||||
items = box.get_children()
|
||||
if not items:
|
||||
items = _add_settings(box, device)
|
||||
assert len(device.settings) == len(list(items))
|
||||
if device.status:
|
||||
items = _add_settings(box, device)
|
||||
assert len(device.settings) == len(list(items))
|
||||
else:
|
||||
# don't bother adding settings for offline devices,
|
||||
# they're useless and might not guess all of them anyway
|
||||
return
|
||||
|
||||
device_active = bool(device.status)
|
||||
was_inactive = not box.get_sensitive()
|
||||
box.set_sensitive(device_active)
|
||||
if device_active:
|
||||
for sbox, s in zip(items, device.settings):
|
||||
_apply_queue.put(('read', s, sbox))
|
||||
_apply_queue.put(('read', s, sbox, was_inactive))
|
||||
|
|
|
@ -72,8 +72,8 @@ class SmoothScroll_Setting(_settings.Setting):
|
|||
assert register is not None
|
||||
self.register = register
|
||||
|
||||
def read(self):
|
||||
if self._value is None and self._device:
|
||||
def read(self, cached=True):
|
||||
if (self._value is None or not cached) and self._device:
|
||||
ss = self.read_register()
|
||||
if ss:
|
||||
self._value = (ss[:1] == b'\x40')
|
||||
|
@ -96,8 +96,8 @@ class MouseDPI_Setting(_settings.Setting):
|
|||
assert register is not None
|
||||
self.register = register
|
||||
|
||||
def read(self):
|
||||
if self._value is None and self._device:
|
||||
def read(self, cached=True):
|
||||
if (self._value is None or not cached) and self._device:
|
||||
dpi = self.read_register()
|
||||
if dpi:
|
||||
value = ord(dpi[:1])
|
||||
|
|
|
@ -302,8 +302,8 @@ class ToggleFN_Setting(_settings.Setting):
|
|||
'When unset, the F1..F12 keys will activate their standard function,\n'
|
||||
'and you must hold the FN key to activate their special function.')
|
||||
|
||||
def read(self):
|
||||
if self._value is None and self._device:
|
||||
def read(self, cached=True):
|
||||
if (self._value is None or not cached) and self._device:
|
||||
fn = self._device.feature_request(FEATURE.FN_STATUS)
|
||||
if fn:
|
||||
self._value = (fn[:1] == b'\x01')
|
||||
|
|
|
@ -38,7 +38,7 @@ class Setting(object):
|
|||
def write_register(self, value, value2=0):
|
||||
return self._device.request(0x8000 | (self.register & 0x2FF), int(value) & 0xFF, int(value2) & 0xFF)
|
||||
|
||||
def read(self):
|
||||
def read(self, cached=True):
|
||||
raise NotImplemented
|
||||
|
||||
def write(self, value):
|
||||
|
|
Loading…
Reference in New Issue