From 3feae30784b73c79dbca93908d13aec6e149f5fb Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Wed, 8 Jan 2025 12:42:41 +0100 Subject: [PATCH] Option to limit max backlight level https://github.com/seerge/g-helper/issues/3559 --- app/Input/InputDispatcher.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Input/InputDispatcher.cs b/app/Input/InputDispatcher.cs index 4b4dcf42..d417060c 100644 --- a/app/Input/InputDispatcher.cs +++ b/app/Input/InputDispatcher.cs @@ -916,11 +916,12 @@ public static void SetBacklight(int delta, bool force = false) bool onBattery = SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online; int backlight = onBattery ? backlight_battery : backlight_power; + int backlightMax = AppConfig.Get("max_brightness", 3); - if (delta >= 4) - backlight = ++backlight % 4; + if (delta > backlightMax) + backlight = ++backlight % (backlightMax + 1); else - backlight = Math.Max(Math.Min(3, backlight + delta), 0); + backlight = Math.Max(Math.Min(backlightMax, backlight + delta), 0); if (onBattery) AppConfig.Set("keyboard_brightness_ac", backlight);