From 0146a40244d98deac87ca52916111de360c637ae Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Wed, 26 Jul 2023 19:13:10 +0200 Subject: [PATCH] Heatmap fix --- app/AsusUSB.cs | 38 +++++++++++++++++++++++++++++++++----- app/Gpu/GPUModeControl.cs | 3 +++ 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/app/AsusUSB.cs b/app/AsusUSB.cs index 9fd86ee7..90c1014d 100644 --- a/app/AsusUSB.cs +++ b/app/AsusUSB.cs @@ -1,5 +1,6 @@ using GHelper.Helpers; using HidLibrary; +using System.Drawing; using System.Text; namespace GHelper @@ -64,8 +65,8 @@ namespace GHelper public static readonly byte[] LED_INIT4 = Encoding.ASCII.GetBytes("^ASUS Tech.Inc."); public static readonly byte[] LED_INIT5 = new byte[] { 0x5e, 0x05, 0x20, 0x31, 0, 0x08 }; - static byte[] MESSAGE_SET = { AURA_HID_ID, 0xb5, 0, 0, 0 }; static byte[] MESSAGE_APPLY = { AURA_HID_ID, 0xb4 }; + static byte[] MESSAGE_SET = { AURA_HID_ID, 0xb5, 0, 0, 0 }; static int[] deviceIds = { 0x1a30, 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0, 0x18c6, 0x1abe }; @@ -431,9 +432,25 @@ namespace GHelper if (auraDevice is null || !auraDevice.IsConnected) GetAuraDevice(); if (auraDevice is null || !auraDevice.IsConnected) return; - auraDevice.WriteFeatureData(AuraMessage(0, color, color, 0)); - auraDevice.WriteFeatureData(MESSAGE_SET); - //auraDevice.WriteFeatureData(MESSAGE_APPLY); + + byte[] msg = new byte[40]; + int start = 9; + + msg[0] = AURA_HID_ID; + msg[1] = 0xBC; + msg[2] = 1; + msg[3] = 1; + msg[4] = 4; + + for (int i = 0; i < 10; i++) + { + msg[start + i * 3] = color.R; // R + msg[start + 1 + i * 3] = color.G; // G + msg[start + 2 + i * 3] = color.B; // B + } + + //Logger.WriteLine(BitConverter.ToString(msg)); + auraDevice.WriteFeatureData(msg); }); } @@ -484,8 +501,8 @@ namespace GHelper if (device.ReadFeatureData(out byte[] data, AURA_HID_ID)) { device.WriteFeatureData(msg); - device.WriteFeatureData(MESSAGE_SET); 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)); } device.CloseDevice(); @@ -519,6 +536,15 @@ namespace GHelper return 0; } + public static void InitXGM() + { + SetXGM(LED_INIT1); + SetXGM(LED_INIT2); + SetXGM(LED_INIT3); + SetXGM(LED_INIT4); + SetXGM(LED_INIT5); + } + public static void ApplyXGMLight(bool status) { SetXGM(new byte[] { 0x5e, 0xc5, status ? (byte)0x50 : (byte)0 }); @@ -535,6 +561,8 @@ namespace GHelper if (AsusACPI.IsInvalidCurve(curve)) return -1; + InitXGM(); + byte[] msg = new byte[19]; Array.Copy(new byte[] { 0x5e, 0xd1, 0x01 }, msg, 3); Array.Copy(curve, 0, msg, 3, curve.Length); diff --git a/app/Gpu/GPUModeControl.cs b/app/Gpu/GPUModeControl.cs index 2331fc7f..46c1046d 100644 --- a/app/Gpu/GPUModeControl.cs +++ b/app/Gpu/GPUModeControl.cs @@ -304,6 +304,9 @@ namespace GHelper.Gpu if (AppConfig.IsMode("auto_apply")) AsusUSB.SetXGMFan(AppConfig.GetFanConfig(AsusFan.XGM)); + + HardwareControl.RecreateGpuControl(); + } settings.Invoke(delegate