HeadsetAdvancedEQ: refresh-read tracks the active slot
read_prefix was hardcoded to b'\\x00\\x00' (direction=0, slot=0), so every panel refresh re-read slot 0's bands regardless of which slot the device considered active — the panel would silently show the wrong EQ if the user had switched away from slot 0 (via G HUB on another host, an onboard button, etc.). Replace the static prefix with a custom rw_class that calls getActiveEQ before each read and feeds the resulting slot into the read_prefix. Direction stays hardcoded to 0 (playback); mic-side EQ isn't exposed yet.
This commit is contained in:
parent
d7a279fd78
commit
be68d48df5
|
|
@ -1877,9 +1877,22 @@ class HeadsetAdvancedEQ(settings.RangeFieldSetting):
|
|||
label = _("Headset Advanced EQ (read-only)")
|
||||
description = _("Display the headset's active parametric EQ. Writes are disabled pending verification.")
|
||||
feature = _F.HEADSET_ADVANCED_PARA_EQ
|
||||
rw_options = {"read_fnid": 0x10, "write_fnid": 0x20, "read_prefix": b"\x00\x00"}
|
||||
rw_options = {"read_fnid": 0x10, "write_fnid": 0x20}
|
||||
keys_universe = []
|
||||
|
||||
class rw_class(settings.FeatureRW):
|
||||
"""getCustomEQ takes [direction, slot]; the slot is the *active*
|
||||
EQ preset, which the device may have switched while we weren't
|
||||
looking (G HUB on another machine, an onboard button, etc.).
|
||||
Re-query it on every read instead of caching slot 0 at build
|
||||
time. Direction is hardcoded to 0 (playback) — mic-side EQ
|
||||
isn't exposed yet."""
|
||||
|
||||
def read(self, device, data_bytes=b""):
|
||||
active_slot = hidpp20.get_advanced_eq_active_slot(device, direction=0)
|
||||
self.read_prefix = bytes([0, active_slot if active_slot is not None else 0])
|
||||
return super().read(device, data_bytes)
|
||||
|
||||
class validator_class(settings_validator.PackedRangeValidator):
|
||||
kind = settings.Kind.GRAPHIC_EQ
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue