Single Color detection

This commit is contained in:
Serge
2023-08-11 12:51:03 +02:00
parent 3efb2e0db9
commit cf33b0cc52
4 changed files with 18 additions and 11 deletions

View File

@@ -298,7 +298,7 @@ public static class AppConfig
return ContainsModel("GA401I") && !ContainsModel("GA401IHR"); return ContainsModel("GA401I") && !ContainsModel("GA401IHR");
} }
public static bool NoAuraColor() public static bool IsSingleColor()
{ {
return ContainsModel("GA401") || ContainsModel("X13"); return ContainsModel("GA401") || ContainsModel("X13");
} }

View File

@@ -1,6 +1,5 @@
using GHelper.Helpers; using GHelper.Helpers;
using HidLibrary; using HidLibrary;
using System.Diagnostics;
using System.Text; using System.Text;
namespace GHelper namespace GHelper
@@ -63,12 +62,15 @@ namespace GHelper
static bool isTuf = AppConfig.IsTUF(); static bool isTuf = AppConfig.IsTUF();
static bool isStrix = AppConfig.IsStrix(); static bool isStrix = AppConfig.IsStrix();
static public bool isSingleColor = false;
static bool isOldHeatmap = AppConfig.Is("old_heatmap"); static bool isOldHeatmap = AppConfig.Is("old_heatmap");
static System.Timers.Timer timer = new System.Timers.Timer(2000); static System.Timers.Timer timer = new System.Timers.Timer(2000);
static HidDevice? auraDevice = null; static HidDevice? auraDevice = null;
static byte[] AuraPowerMessage(AuraPower flags) static byte[] AuraPowerMessage(AuraPower flags)
{ {
byte keyb = 0, bar = 0, lid = 0, rear = 0; byte keyb = 0, bar = 0, lid = 0, rear = 0;
@@ -113,6 +115,11 @@ namespace GHelper
static AsusUSB() static AsusUSB()
{ {
timer.Elapsed += Timer_Elapsed; 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) private static void Timer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
@@ -182,10 +189,11 @@ namespace GHelper
_modes.Remove(3); _modes.Remove(3);
} }
if (AppConfig.NoAuraColor()) if (isSingleColor)
{ {
_modes.Remove(2); _modes.Remove(2);
_modes.Remove(3); _modes.Remove(3);
_modes.Remove(HEATMAP);
} }
if (AppConfig.IsAdvantageEdition()) if (AppConfig.IsAdvantageEdition())
@@ -467,7 +475,7 @@ namespace GHelper
if (isStrix && !isOldHeatmap) if (isStrix && !isOldHeatmap)
{ {
byte[] msg = new byte[0x40]; byte[] msg = new byte[0x40];
byte start = 9; byte start = 9;
byte maxLeds = 0x93; byte maxLeds = 0x93;
@@ -495,7 +503,7 @@ namespace GHelper
auraDevice.Write(LED_INIT3); auraDevice.Write(LED_INIT3);
auraDevice.Write(LED_INIT4); auraDevice.Write(LED_INIT4);
auraDevice.Write(LED_INIT5); 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) for (byte b = 0; b < maxLeds; b += 0x10)
@@ -569,11 +577,11 @@ namespace GHelper
device.OpenDevice(); device.OpenDevice();
if (device.ReadFeatureData(out byte[] data, AURA_HID_ID)) 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(msg);
device.WriteFeatureData(MESSAGE_APPLY); device.WriteFeatureData(MESSAGE_APPLY);
device.WriteFeatureData(MESSAGE_SET); 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(); device.CloseDevice();
} }

View File

@@ -131,8 +131,7 @@ namespace GHelper.Gpu
if (eco == 1) if (eco == 1)
{ {
/*
if (NvidiaSmi.GetDisplayActiveStatus()) if (NvidiaSmi.GetDisplayActiveStatus())
{ {
DialogResult dialogResult = MessageBox.Show(Properties.Strings.EnableOptimusText, Properties.Strings.EnableOptimusTitle, MessageBoxButtons.YesNo); DialogResult dialogResult = MessageBox.Show(Properties.Strings.EnableOptimusText, Properties.Strings.EnableOptimusTitle, MessageBoxButtons.YesNo);
@@ -142,7 +141,7 @@ namespace GHelper.Gpu
return; return;
} }
} }
*/
HardwareControl.KillGPUApps(); HardwareControl.KillGPUApps();
} }

View File

@@ -633,7 +633,7 @@ namespace GHelper
comboKeyboard.SelectedValueChanged += ComboKeyboard_SelectedValueChanged; comboKeyboard.SelectedValueChanged += ComboKeyboard_SelectedValueChanged;
if (AppConfig.NoAuraColor()) if (AsusUSB.isSingleColor)
{ {
panelColor.Visible = false; panelColor.Visible = false;
} }