Skip to content

Commit e687094

Browse files
committed
FN+F11 hotkey handler for FX506 #4558
1 parent 023014c commit e687094

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

app/AppConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ public static bool Is4ZoneRGB()
533533
return IsPossible4ZoneRGB() && !Is("per_key_rgb");
534534
}
535535

536-
public static bool IsNoAirplaneMode()
536+
public static bool IsHardwareHotkeys()
537537
{
538538
return ContainsModel("FX506");
539539
}

app/Input/InputDispatcher.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public class InputDispatcher
1818
public static bool tentMode = false;
1919
private static bool? _fnLock = null;
2020

21+
private static long lastSleep;
22+
2123
public static Keys keyProfile = (Keys)AppConfig.Get("keybind_profile", (int)Keys.F5);
2224
public static Keys keyApp = (Keys)AppConfig.Get("keybind_app", (int)Keys.F12);
2325

@@ -703,6 +705,8 @@ static void ToggleTouchpad()
703705

704706
static void SleepEvent()
705707
{
708+
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastSleep) < 1000) return;
709+
lastSleep = DateTimeOffset.Now.ToUnixTimeMilliseconds();
706710
Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.KB_Sleep, "Sleep");
707711
}
708712

@@ -936,7 +940,8 @@ static void HandleOptimizationEvent(int EventID)
936940
ToggleTouchpadEvent();
937941
break;
938942
case 108: // FN+F11
939-
SleepEvent();
943+
if (!AppConfig.IsHardwareHotkeys()) SleepEvent();
944+
else lastSleep = DateTimeOffset.Now.ToUnixTimeMilliseconds();
940945
break;
941946
case 106: // Screenpad button on DUO
942947
if (Control.ModifierKeys == Keys.Shift)
@@ -958,7 +963,7 @@ static void HandleOptimizationEvent(int EventID)
958963
ToggleArrowLock();
959964
return;
960965
case 136: // FN + F12
961-
if (!AppConfig.IsNoAirplaneMode()) Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.Airplane, "Airplane");
966+
if (!AppConfig.IsHardwareHotkeys()) Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.Airplane, "Airplane");
962967
return;
963968
case 50:
964969
// Sound Mute Event

0 commit comments

Comments
 (0)