diff --git a/app/AppConfig.cs b/app/AppConfig.cs index 41168871..097e6da6 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -355,7 +355,7 @@ public static class AppConfig public static bool IsStrixLimitedRGB() { - return ContainsModel("G614JV") || ContainsModel("G614JZ") || ContainsModel("G512LI"); + return ContainsModel("G614JV") || ContainsModel("G614JZ") || ContainsModel("G512LI") || ContainsModel("G513RS"); } public static bool IsZ13() @@ -441,4 +441,9 @@ public static class AppConfig return ContainsModel("GV301RA") || ContainsModel("GV302XA") || IsAlly(); } + public static bool IsHardwareTouchpadToggle() + { + return ContainsModel("FA507"); + } + } diff --git a/app/Extra.cs b/app/Extra.cs index 50f11821..889e3909 100644 --- a/app/Extra.cs +++ b/app/Extra.cs @@ -564,7 +564,7 @@ namespace GHelper AppConfig.Set("keyboard_sleep_logo", (checkSleepLogo.Checked ? 1 : 0)); AppConfig.Set("keyboard_shutdown_logo", (checkShutdownLogo.Checked ? 1 : 0)); - Aura.ApplyAuraPower(); + Aura.ApplyPower(); } diff --git a/app/Input/InputDispatcher.cs b/app/Input/InputDispatcher.cs index 768b5e67..8154f6ed 100644 --- a/app/Input/InputDispatcher.cs +++ b/app/Input/InputDispatcher.cs @@ -303,10 +303,10 @@ namespace GHelper.Input KeyboardHook.KeyKeyPress(Keys.LWin, Keys.P); break; case Keys.F10: - HandleOptimizationEvent(107); + ToggleTouchpadEvent(true); break; case Keys.F11: - HandleOptimizationEvent(108); + SleepEvent(); break; case Keys.F12: KeyboardHook.KeyKeyPress(Keys.LWin, Keys.A); @@ -477,11 +477,23 @@ namespace GHelper.Input } } + static void ToggleTouchpadEvent(bool hotkey = false) + { + if (hotkey || !AppConfig.IsHardwareTouchpadToggle()) ToggleTouchpad(); + Thread.Sleep(200); + Program.toast.RunToast(GetTouchpadState() ? "On" : "Off", ToastIcon.Touchpad); + } + static void ToggleTouchpad() { KeyboardHook.KeyKeyKeyPress(Keys.LWin, Keys.LControlKey, Keys.F24, 50); } + static void SleepEvent() + { + Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.KB_Sleep, "Sleep"); + } + public static void ToggleArrowLock() { int arLock = AppConfig.Is("arrow_lock") ? 0 : 1; @@ -620,12 +632,10 @@ namespace GHelper.Input Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.Brightness_Up, "Brightness"); break; case 107: // FN+F10 - ToggleTouchpad(); - Thread.Sleep(200); - Program.toast.RunToast(GetTouchpadState() ? "On" : "Off", ToastIcon.Touchpad); + ToggleTouchpadEvent(); break; case 108: // FN+F11 - Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.KB_Sleep, "Sleep"); + SleepEvent(); break; case 106: // Screenpad button on DUO if (Control.ModifierKeys == Keys.Shift) diff --git a/app/Settings.cs b/app/Settings.cs index eac41e79..74057849 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -1045,7 +1045,7 @@ namespace GHelper if (!AppConfig.Is("skip_aura")) { - Aura.ApplyAuraPower(); + Aura.ApplyPower(); Aura.ApplyAura(); } diff --git a/app/USB/AsusHid.cs b/app/USB/AsusHid.cs index cc2bae75..faf9535e 100644 --- a/app/USB/AsusHid.cs +++ b/app/USB/AsusHid.cs @@ -12,7 +12,7 @@ public static class AsusHid static int[] deviceIds = { 0x1a30, 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0, 0x18c6, 0x1abe }; - static HidStream _stream; + static HidStream auraStream; public static HidStream FindHidStream(byte reportId, int minFeatureLength = 1) { @@ -50,23 +50,23 @@ public static class AsusHid return null; } - static void WriteData(HidStream stream, byte[] data) + static void WriteData(HidStream stream, byte[] data, string log = "USB") { try { stream.Write(data); - Logger.WriteLine("USB " + stream.Device.ProductID + ": " + BitConverter.ToString(data)); + Logger.WriteLine($"{log} " + stream.Device.ProductID + ": " + BitConverter.ToString(data)); } catch (Exception ex) { - Debug.WriteLine($"Error writing to HID device: {ex.Message} {BitConverter.ToString(data)}"); + Debug.WriteLine($"Error writing {log} to HID device: {ex.Message} {BitConverter.ToString(data)}"); } } - public static void Write(byte[] data, byte reportId = AURA_ID) + public static void Write(byte[] data, byte reportId = AURA_ID, string log = "USB") { using (var stream = FindHidStream(reportId)) - WriteData(stream, data); + WriteData(stream, data, log); } public static void Write(List dataList, byte reportId = AURA_ID) { @@ -75,19 +75,19 @@ public static class AsusHid WriteData(stream, data); } - public static void WriteAura(byte[] data, byte reportId = AURA_ID) + public static void WriteAura(byte[] data) { - if (_stream == null) _stream = FindHidStream(reportId); - if (_stream == null) return; + if (auraStream == null) auraStream = FindHidStream(AURA_ID); + if (auraStream == null) return; try { - _stream.Write(data); + auraStream.Write(data); } catch (Exception ex) { - _stream.Dispose(); + auraStream.Dispose(); Debug.WriteLine($"Error writing data to HID device: {ex.Message}"); } } diff --git a/app/USB/Aura.cs b/app/USB/Aura.cs index 4c38b290..347f2dd4 100644 --- a/app/USB/Aura.cs +++ b/app/USB/Aura.cs @@ -58,7 +58,7 @@ namespace GHelper.USB static bool isOldHeatmap = AppConfig.Is("old_heatmap"); - static System.Timers.Timer timer = new System.Timers.Timer(80); + static System.Timers.Timer timer = new System.Timers.Timer(1000); static byte[] AuraPowerMessage(AuraPower flags) { @@ -286,15 +286,15 @@ namespace GHelper.USB if (delay) await Task.Delay(TimeSpan.FromSeconds(1)); if (isTuf) Program.acpi.TUFKeyboardBrightness(brightness); - AsusHid.Write(new byte[] { AsusHid.AURA_ID, 0xba, 0xc5, 0xc4, (byte)brightness }); - if (AppConfig.ContainsModel("GA503")) AsusHid.Write(new byte[] { AsusHid.INPUT_ID, 0xba, 0xc5, 0xc4, (byte)brightness }, AsusHid.INPUT_ID); + AsusHid.Write(new byte[] { AsusHid.AURA_ID, 0xba, 0xc5, 0xc4, (byte)brightness }, AsusHid.AURA_ID, log); + if (AppConfig.ContainsModel("GA503")) AsusHid.Write(new byte[] { AsusHid.INPUT_ID, 0xba, 0xc5, 0xc4, (byte)brightness }, AsusHid.INPUT_ID, log); }); } - public static void ApplyAuraPower() + public static void ApplyPower() { AuraPower flags = new();