From 490493d7a34ded3df06bf29a836315a8a3d607d2 Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Sat, 23 Mar 2024 13:27:24 -0400 Subject: [PATCH] device: handle BRIGHTNESS CONTROL notifications --- lib/logitech_receiver/notifications.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/logitech_receiver/notifications.py b/lib/logitech_receiver/notifications.py index d3c2783b..0ef2e90e 100644 --- a/lib/logitech_receiver/notifications.py +++ b/lib/logitech_receiver/notifications.py @@ -437,5 +437,19 @@ def _process_feature_notification(device, n, feature): device.setting_callback(device, _st.AdjustableDpi, [profile.resolutions[resolution_index]]) break + elif feature == _F.BRIGHTNESS_CONTROL: + if n.address > 0x10: + if logger.isEnabledFor(logging.INFO): + logger.info("%s: unknown BRIGHTNESS CONTROL %s", device, n) + else: + if n.address == 0x00: + brightness = _unpack("!H", n.data[:2])[0] + device.setting_callback(device, _st.BrightnessControl, [brightness]) + elif n.address == 0x10: + brightness = n.data[0] & 0x01 + if brightness: + brightness = _unpack("!H", device.feature_request(_F.BRIGHTNESS_CONTROL, 0x10)[:2])[0] + device.setting_callback(device, _st.BrightnessControl, [brightness]) + _diversion.process_notification(device, n, feature) return True