From be68d48df56198fc218150c2e24b65eb9106de39 Mon Sep 17 00:00:00 2001 From: Ken Sanislo Date: Fri, 24 Apr 2026 20:54:17 -0700 Subject: [PATCH] HeadsetAdvancedEQ: refresh-read tracks the active slot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- lib/logitech_receiver/settings_templates.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/logitech_receiver/settings_templates.py b/lib/logitech_receiver/settings_templates.py index 09b39e46..35f42709 100644 --- a/lib/logitech_receiver/settings_templates.py +++ b/lib/logitech_receiver/settings_templates.py @@ -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