From 991eab1280675f26e3c9f9211ae51a4be704b36b Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Sun, 11 Aug 2024 10:44:13 +0200 Subject: [PATCH] Softwar FN-Lock for ProArt --- app/AppConfig.cs | 5 +++++ app/AsusACPI.cs | 1 + app/Input/InputDispatcher.cs | 43 +++++++++++++++++++++++++++++++++--- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/app/AppConfig.cs b/app/AppConfig.cs index 05aaec29..8b9ed60b 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -372,6 +372,11 @@ public static class AppConfig return ContainsModel("ProArt"); } + public static bool IsHWFNLock() + { + return ContainsModel("Vivobook") || ContainsModel("Zenbook"); + } + public static bool IsVivoZenPro() { return ContainsModel("Vivobook") || ContainsModel("Zenbook") || ContainsModel("ProArt"); diff --git a/app/AsusACPI.cs b/app/AsusACPI.cs index 3a7575f4..73265de4 100644 --- a/app/AsusACPI.cs +++ b/app/AsusACPI.cs @@ -46,6 +46,7 @@ public class AsusACPI public const int KB_TouchpadToggle = 0x6b; public const int KB_MuteToggle = 0x7c; + public const int KB_NumlockToggle = 0x4e; public const int KB_DUO_PgUpDn = 0x4B; public const int KB_DUO_SecondDisplay = 0x6A; diff --git a/app/Input/InputDispatcher.cs b/app/Input/InputDispatcher.cs index 7289dd65..3a5ec050 100644 --- a/app/Input/InputDispatcher.cs +++ b/app/Input/InputDispatcher.cs @@ -85,7 +85,7 @@ namespace GHelper.Input InitBacklightTimer(); - if (AppConfig.IsVivoZenPro()) + if (AppConfig.IsHWFNLock()) Program.acpi.DeviceSet(AsusACPI.FnLock, AppConfig.Is("fn_lock") ^ AppConfig.IsInvertedFNLock() ? 1 : 0, "FnLock"); } @@ -155,7 +155,7 @@ namespace GHelper.Input // FN-Lock group - if (AppConfig.Is("fn_lock") && !AppConfig.IsVivoZenPro()) + if (AppConfig.Is("fn_lock") && !AppConfig.IsHWFNLock()) for (Keys i = Keys.F1; i <= Keys.F11; i++) hook.RegisterHotKey(ModifierKeys.None, i); // Arrow-lock group @@ -281,6 +281,43 @@ namespace GHelper.Input } } + if (AppConfig.IsProArt()) + { + switch (e.Key) + { + case Keys.F2: + KeyboardHook.KeyPress(Keys.VolumeDown); + return; + case Keys.F3: + KeyboardHook.KeyPress(Keys.VolumeUp); + return; + case Keys.F4: + HandleEvent(199); // Backlight cycle + return; + case Keys.F5: + SetBrightness(-10); + return; + case Keys.F6: + SetBrightness(+10); + return; + case Keys.F7: + KeyboardHook.KeyKeyPress(Keys.LWin, Keys.P); + return; + case Keys.F8: + HandleEvent(126); // Emojis + return; + case Keys.F9: + KeyProcess("m3"); // MicMute + return; + case Keys.F10: + HandleEvent(133); // Camera Toggle + return; + case Keys.F11: + KeyboardHook.KeyPress(Keys.Snapshot); // PrintScreen + return; + } + } + if (AppConfig.IsZ13() || AppConfig.IsDUO()) { switch (e.Key) @@ -597,7 +634,7 @@ namespace GHelper.Input bool fnLock = !AppConfig.Is("fn_lock"); AppConfig.Set("fn_lock", fnLock ? 1 : 0); - if (AppConfig.IsVivoZenPro()) + if (AppConfig.IsHWFNLock()) Program.acpi.DeviceSet(AsusACPI.FnLock, fnLock ^ AppConfig.IsInvertedFNLock() ? 1 : 0, "FnLock"); else Program.settingsForm.BeginInvoke(Program.inputDispatcher.RegisterKeys);