From fbfbe8e730e14009ca499e48117c2cb1ee521e4c Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Thu, 25 Jan 2024 16:54:34 +0100 Subject: [PATCH] Ally Backlight control --- app/Ally/AllyControl.cs | 10 +++++++++- app/Extra.cs | 2 ++ app/Settings.cs | 5 +++++ app/UI/RForm.cs | 13 ------------- app/USB/Aura.cs | 18 +++++++++++++++++- 5 files changed, 33 insertions(+), 15 deletions(-) diff --git a/app/Ally/AllyControl.cs b/app/Ally/AllyControl.cs index 8c4581c6..0d591b5f 100644 --- a/app/Ally/AllyControl.cs +++ b/app/Ally/AllyControl.cs @@ -1,5 +1,6 @@ using GHelper.Gpu.AMD; using GHelper.Input; +using GHelper.Mode; using GHelper.USB; using HidSharp; using System.Text; @@ -580,7 +581,6 @@ namespace GHelper.Ally public void ToggleMode() { - switch (_mode) { case ControllerMode.Auto: @@ -596,7 +596,15 @@ namespace GHelper.Ally SetMode(ControllerMode.Auto); break; } + } + public void ToggleXBox() + { + bool status = !AppConfig.IsNotFalse("controller_xbox"); + AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xD1, 0x0B, 0x01, status ? (byte)0x01 : (byte)0x02 }, "XBox"); + AppConfig.Set("controller_xbox", status ? 1 : 0); + + settings.VisualiseXBox(status); } } diff --git a/app/Extra.cs b/app/Extra.cs index 8dfd85d2..5e75cb85 100644 --- a/app/Extra.cs +++ b/app/Extra.cs @@ -228,6 +228,8 @@ namespace GHelper checkGpuApps.Visible = false; checkUSBC.Visible = false; + checkAutoToggleClamshellMode.Visible = false; + checkNoOverdrive.Visible = false; int apuMem = Program.acpi.GetAPUMem(); if (apuMem >= 0) diff --git a/app/Settings.cs b/app/Settings.cs index 65f64a5b..b9d4b84a 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -314,6 +314,11 @@ namespace GHelper } } + public void VisualiseXBox(bool status) + { + + } + public void VisualiseBacklight(int backlight) { buttonBacklight.Text = Math.Round((double)backlight*33.33).ToString() + "%"; diff --git a/app/UI/RForm.cs b/app/UI/RForm.cs index 3df697d2..003f2937 100644 --- a/app/UI/RForm.cs +++ b/app/UI/RForm.cs @@ -21,19 +21,6 @@ namespace GHelper.UI public static Color chartMain; public static Color chartGrid; - static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); - static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2); - static readonly IntPtr HWND_TOP = new IntPtr(0); - static readonly IntPtr HWND_BOTTOM = new IntPtr(1); - const UInt32 SWP_NOSIZE = 0x0001; - const UInt32 SWP_NOMOVE = 0x0002; - const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE; - - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); - protected override bool ShowWithoutActivation => true; - [DllImport("UXTheme.dll", SetLastError = true, EntryPoint = "#138")] public static extern bool CheckSystemDarkModeStatus(); diff --git a/app/USB/Aura.cs b/app/USB/Aura.cs index c1ce061f..8a8e2078 100644 --- a/app/USB/Aura.cs +++ b/app/USB/Aura.cs @@ -343,7 +343,17 @@ namespace GHelper.USB if (flags.SleepRear) rear |= 1 << 6; if (flags.ShutdownRear) rear |= 1 << 7; - return new byte[] { 0x5d, 0xbd, 0x01, keyb, bar, lid, rear, 0xFF }; + return new byte[] { AsusHid.AURA_ID, 0xBD, 0x01, keyb, bar, lid, rear, 0xFF }; + } + + private static void ApplyAllyPower(AuraPower flags) + { + byte power = 0x00; + if (flags.BootKeyb) power |= 0x01; + if (flags.AwakeKeyb) power |= 0x02; + if (flags.SleepKeyb) power |= 0x04; + if (flags.ShutdownKeyb) power |= 0x08; + AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xD1, 0x09, 0x01, power }, "Aura"); } public static void ApplyPower() @@ -381,6 +391,12 @@ namespace GHelper.USB flags.SleepRear = AppConfig.IsNotFalse("keyboard_sleep_lid"); flags.ShutdownRear = AppConfig.IsNotFalse("keyboard_shutdown_lid"); + if (AppConfig.IsAlly()) + { + ApplyAllyPower(flags); + return; + } + AsusHid.Write(AuraPowerMessage(flags)); if (isACPI)