From cf33b0cc52c2d06fa9650a34f302e78def483b1b Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Fri, 11 Aug 2023 12:51:03 +0200 Subject: [PATCH] Single Color detection --- app/AppConfig.cs | 2 +- app/AsusUSB.cs | 20 ++++++++++++++------ app/Gpu/GPUModeControl.cs | 5 ++--- app/Settings.cs | 2 +- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/AppConfig.cs b/app/AppConfig.cs index cbad1d84..2cf998f2 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -298,7 +298,7 @@ public static class AppConfig return ContainsModel("GA401I") && !ContainsModel("GA401IHR"); } - public static bool NoAuraColor() + public static bool IsSingleColor() { return ContainsModel("GA401") || ContainsModel("X13"); } diff --git a/app/AsusUSB.cs b/app/AsusUSB.cs index f5f9f6aa..d5f0b8d0 100644 --- a/app/AsusUSB.cs +++ b/app/AsusUSB.cs @@ -1,6 +1,5 @@ using GHelper.Helpers; using HidLibrary; -using System.Diagnostics; using System.Text; namespace GHelper @@ -63,12 +62,15 @@ namespace GHelper static bool isTuf = AppConfig.IsTUF(); static bool isStrix = AppConfig.IsStrix(); + static public bool isSingleColor = false; + static bool isOldHeatmap = AppConfig.Is("old_heatmap"); static System.Timers.Timer timer = new System.Timers.Timer(2000); static HidDevice? auraDevice = null; + static byte[] AuraPowerMessage(AuraPower flags) { byte keyb = 0, bar = 0, lid = 0, rear = 0; @@ -113,6 +115,11 @@ namespace GHelper static AsusUSB() { timer.Elapsed += Timer_Elapsed; + + isSingleColor = AppConfig.IsSingleColor(); + + var device = GetDevice(AURA_HID_ID); + if (device is not null && device.Attributes.Version == 22 && AppConfig.ContainsModel("GA402X")) isSingleColor = true; } private static void Timer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e) @@ -182,10 +189,11 @@ namespace GHelper _modes.Remove(3); } - if (AppConfig.NoAuraColor()) + if (isSingleColor) { _modes.Remove(2); _modes.Remove(3); + _modes.Remove(HEATMAP); } if (AppConfig.IsAdvantageEdition()) @@ -467,7 +475,7 @@ namespace GHelper if (isStrix && !isOldHeatmap) { byte[] msg = new byte[0x40]; - + byte start = 9; byte maxLeds = 0x93; @@ -495,7 +503,7 @@ namespace GHelper auraDevice.Write(LED_INIT3); auraDevice.Write(LED_INIT4); auraDevice.Write(LED_INIT5); - auraDevice.Write(new byte[] { AURA_HID_ID, 0xbc}); + auraDevice.Write(new byte[] { AURA_HID_ID, 0xbc }); } for (byte b = 0; b < maxLeds; b += 0x10) @@ -569,11 +577,11 @@ namespace GHelper device.OpenDevice(); if (device.ReadFeatureData(out byte[] data, AURA_HID_ID)) { - msg = AuraMessage(Mode, Color1, Color2, _speed, device.Attributes.Version == 22 && AppConfig.ContainsModel("GA402X")); + msg = AuraMessage(Mode, Color1, Color2, _speed, isSingleColor); device.WriteFeatureData(msg); device.WriteFeatureData(MESSAGE_APPLY); device.WriteFeatureData(MESSAGE_SET); - Logger.WriteLine("USB-KB " + device.Capabilities.FeatureReportByteLength + "|" + device.Capabilities.InputReportByteLength + device.Description + device.DevicePath + ":" + BitConverter.ToString(msg)); + Logger.WriteLine("USB-KB " + device.Attributes.Version + device.Description + device.DevicePath + ":" + BitConverter.ToString(msg)); } device.CloseDevice(); } diff --git a/app/Gpu/GPUModeControl.cs b/app/Gpu/GPUModeControl.cs index 5ececff9..c96932fb 100644 --- a/app/Gpu/GPUModeControl.cs +++ b/app/Gpu/GPUModeControl.cs @@ -131,8 +131,7 @@ namespace GHelper.Gpu if (eco == 1) { - - + /* if (NvidiaSmi.GetDisplayActiveStatus()) { DialogResult dialogResult = MessageBox.Show(Properties.Strings.EnableOptimusText, Properties.Strings.EnableOptimusTitle, MessageBoxButtons.YesNo); @@ -142,7 +141,7 @@ namespace GHelper.Gpu return; } } - + */ HardwareControl.KillGPUApps(); } diff --git a/app/Settings.cs b/app/Settings.cs index 5a53f5aa..99fb4824 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -633,7 +633,7 @@ namespace GHelper comboKeyboard.SelectedValueChanged += ComboKeyboard_SelectedValueChanged; - if (AppConfig.NoAuraColor()) + if (AsusUSB.isSingleColor) { panelColor.Visible = false; }