Skip to content

Commit

Permalink
Screenpad controls cleanup #3067
Browse files Browse the repository at this point in the history
  • Loading branch information
seerge committed Sep 7, 2024
1 parent c69150f commit 2e025ed
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/Input/InputDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ public static void ToggleCamera()

private static System.Threading.Timer screenpadActionTimer;
private static int screenpadBrightnessToSet;
public static void ApplyScreenpadAction(int brightness, bool doToggle = false)
public static void ApplyScreenpadAction(int brightness, bool instant = true)
{
var delay = AppConfig.Get("screenpad_delay", 1500);

Expand All @@ -949,7 +949,7 @@ public static void ApplyScreenpadAction(int brightness, bool doToggle = false)
if (b < 0) Program.acpi.DeviceSet(AsusACPI.ScreenPadToggle, 0, "ScreenpadOff");
};

if(delay <= 0 || (brightness > 0 && brightness < 100 && doToggle == false)) //instant action
if(delay <= 0 || instant) //instant action
{
action(brightness);
}
Expand All @@ -975,20 +975,19 @@ public static void SetScreenpad(int delta)
if (brightness < 0) brightness = 100;
else if (brightness >= 100) brightness = 0;
else brightness = -10;
ApplyScreenpadAction(brightness, false);
}
else
{
brightness = Math.Max(Math.Min(100, brightness + delta), 0);
ApplyScreenpadAction(brightness);
}

AppConfig.Set("screenpad", brightness);

ApplyScreenpadAction(brightness);

string toast;

if (brightness < 0) toast = "Off";
else if (brightness == 0) toast = "Hidden";
else toast = brightness.ToString() + "%";

Program.toast.RunToast($"Screen Pad {toast}", delta > 0 ? ToastIcon.BrightnessUp : ToastIcon.BrightnessDown);
Expand Down

0 comments on commit 2e025ed

Please sign in to comment.