From f32f70f1456bda31876bd5584d1e3691407ac1f1 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Tue, 1 Aug 2023 20:24:16 +0200 Subject: [PATCH] 2 Heatmap modes, one can blink, another one don't work on some devices --- app/AsusUSB.cs | 83 +++++++++++++++++++++------------------- app/Settings.Designer.cs | 28 +++++++------- 2 files changed, 57 insertions(+), 54 deletions(-) diff --git a/app/AsusUSB.cs b/app/AsusUSB.cs index 9c37c356c..2322d1f96 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 @@ -38,6 +37,7 @@ public class AuraPower public static class AsusUSB { public const int HEATMAP = 20; + public const int HEATMAP_ALT = 21; public const int ASUS_ID = 0x0b05; @@ -67,6 +67,8 @@ public static class AsusUSB static System.Timers.Timer timer = new System.Timers.Timer(2000); static HidDevice? auraDevice = null; + static bool Manual = false; + static byte[] AuraPowerMessage(AuraPower flags) { byte keyb = 0, bar = 0, lid = 0, rear = 0; @@ -169,7 +171,8 @@ public static Dictionary GetSpeeds() { 10, Properties.Strings.AuraStrobe}, { 11, "Comet" }, { 12, "Flash" }, - { HEATMAP, "Heatmap"} + { HEATMAP, "Heatmap"}, + { HEATMAP_ALT, "Heatmap Alt"} }; @@ -473,51 +476,50 @@ public static void ApplyColor(Color color, bool init = false) if (auraDevice is null || !auraDevice.IsConnected) GetAuraDevice(); if (auraDevice is null || !auraDevice.IsConnected) return; - byte[] msg = new byte[0x40]; - int start = 9; + if (Manual) + { + byte[] msg = new byte[0x40]; + int start = 9; - msg[0] = AURA_HID_ID; - msg[1] = 0xbc; - msg[2] = 1; - msg[3] = 1; - msg[4] = 0; + msg[0] = AURA_HID_ID; + msg[1] = 0xbc; + msg[2] = 1; + msg[3] = 1; + msg[4] = 4; - msg[9] = color.R; // R - msg[10] = color.G; // G - msg[11] = color.B; // B + for (int i = 0; i < 5; i++) + { + msg[start + i * 3] = color.R; // R + msg[start + 1 + i * 3] = color.G; // G + msg[start + 2 + i * 3] = color.B; // B + } - /* - for (int i = 0; i < 5; i++) - { - msg[start + i * 3] = color.R; // R - msg[start + 1 + i * 3] = color.G; // G - msg[start + 2 + i * 3] = color.B; // B - } + for (int i = 6; i < 12; i++) + { + msg[start + i * 3] = color.R; // R + msg[start + 1 + i * 3] = color.G; // G + msg[start + 2 + i * 3] = color.B; // B + } - for (int i = 6; i < 12; i++) - { - msg[start + i * 3] = color.R; // R - msg[start + 1 + i * 3] = color.G; // G - msg[start + 2 + i * 3] = color.B; // B - } - */ + if (init) + { + auraDevice.WriteFeatureData(LED_INIT1); + auraDevice.WriteFeatureData(LED_INIT2); + auraDevice.WriteFeatureData(LED_INIT3); + auraDevice.WriteFeatureData(LED_INIT4); + auraDevice.WriteFeatureData(LED_INIT5); + auraDevice.WriteFeatureData(PrepareAuraMessage(new byte[] { AURA_HID_ID, 0xbc, 1, 0, 0, 0 })); + auraDevice.WriteFeatureData(PrepareAuraMessage(new byte[] { AURA_HID_ID, 0xbc, 1, 1, 4, 0 })); + } + + auraDevice.WriteFeatureData(msg); - if (init) + } else { - //auraDevice.WriteFeatureData(AuraMessage(0,Color.Red,color,0)); - //auraDevice.WriteFeatureData(MESSAGE_APPLY); - //auraDevice.WriteFeatureData(MESSAGE_SET); - - auraDevice.WriteFeatureData(LED_INIT1); - auraDevice.WriteFeatureData(LED_INIT2); - auraDevice.WriteFeatureData(LED_INIT3); - auraDevice.WriteFeatureData(LED_INIT4); - auraDevice.WriteFeatureData(LED_INIT5); - auraDevice.WriteFeatureData(PrepareAuraMessage(new byte[] { AURA_HID_ID, 0xbc, 1, 0, 0, 0 })); - auraDevice.WriteFeatureData(PrepareAuraMessage(new byte[] { AURA_HID_ID, 0xbc, 1, 1, 0, 0 })); + auraDevice.WriteFeatureData(AuraMessage(0, color, color, 0)); + auraDevice.WriteFeatureData(MESSAGE_SET); } - auraDevice.WriteFeatureData(msg); } @@ -529,8 +531,9 @@ public static void ApplyAura() SetColor(AppConfig.Get("aura_color")); SetColor2(AppConfig.Get("aura_color2")); - if (Mode == HEATMAP) + if (Mode == HEATMAP || Mode == HEATMAP_ALT) { + Manual = (Mode == HEATMAP_ALT); SetHeatmap(true); timer.Enabled = true; return; diff --git a/app/Settings.Designer.cs b/app/Settings.Designer.cs index 85182d13c..6a753c1bd 100644 --- a/app/Settings.Designer.cs +++ b/app/Settings.Designer.cs @@ -173,7 +173,7 @@ private void InitializeComponent() tableLayoutMatrix.Name = "tableLayoutMatrix"; tableLayoutMatrix.RowCount = 1; tableLayoutMatrix.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); - tableLayoutMatrix.Size = new Size(787, 60); + tableLayoutMatrix.Size = new Size(787, 64); tableLayoutMatrix.TabIndex = 43; // // comboMatrix @@ -215,8 +215,8 @@ private void InitializeComponent() buttonMatrix.Dock = DockStyle.Top; buttonMatrix.FlatAppearance.BorderSize = 0; buttonMatrix.FlatStyle = FlatStyle.Flat; - buttonMatrix.Location = new Point(528, 6); - buttonMatrix.Margin = new Padding(4, 6, 4, 6); + buttonMatrix.Location = new Point(528, 8); + buttonMatrix.Margin = new Padding(4, 8, 4, 8); buttonMatrix.Name = "buttonMatrix"; buttonMatrix.Secondary = true; buttonMatrix.Size = new Size(255, 48); @@ -276,7 +276,7 @@ private void InitializeComponent() panelBattery.Controls.Add(sliderBattery); panelBattery.Controls.Add(panelBatteryTitle); panelBattery.Dock = DockStyle.Top; - panelBattery.Location = new Point(11, 1261); + panelBattery.Location = new Point(11, 1265); panelBattery.Margin = new Padding(0); panelBattery.Name = "panelBattery"; panelBattery.Padding = new Padding(20, 20, 20, 10); @@ -350,7 +350,7 @@ private void InitializeComponent() panelFooter.AutoSizeMode = AutoSizeMode.GrowAndShrink; panelFooter.Controls.Add(tableButtons); panelFooter.Dock = DockStyle.Top; - panelFooter.Location = new Point(11, 1431); + panelFooter.Location = new Point(11, 1435); panelFooter.Margin = new Padding(0); panelFooter.Name = "panelFooter"; panelFooter.Padding = new Padding(20); @@ -1022,7 +1022,7 @@ private void InitializeComponent() panelKeyboard.Margin = new Padding(0); panelKeyboard.Name = "panelKeyboard"; panelKeyboard.Padding = new Padding(20); - panelKeyboard.Size = new Size(827, 140); + panelKeyboard.Size = new Size(827, 144); panelKeyboard.TabIndex = 3; // // tableLayoutKeyboard @@ -1042,7 +1042,7 @@ private void InitializeComponent() tableLayoutKeyboard.Name = "tableLayoutKeyboard"; tableLayoutKeyboard.RowCount = 1; tableLayoutKeyboard.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); - tableLayoutKeyboard.Size = new Size(787, 60); + tableLayoutKeyboard.Size = new Size(787, 64); tableLayoutKeyboard.TabIndex = 39; // // buttonKeyboard @@ -1057,8 +1057,8 @@ private void InitializeComponent() buttonKeyboard.FlatStyle = FlatStyle.Flat; buttonKeyboard.Image = Properties.Resources.icons8_settings_32; buttonKeyboard.ImageAlign = ContentAlignment.MiddleRight; - buttonKeyboard.Location = new Point(528, 6); - buttonKeyboard.Margin = new Padding(4, 6, 4, 6); + buttonKeyboard.Location = new Point(528, 8); + buttonKeyboard.Margin = new Padding(4, 8, 4, 8); buttonKeyboard.Name = "buttonKeyboard"; buttonKeyboard.Secondary = true; buttonKeyboard.Size = new Size(255, 48); @@ -1074,8 +1074,8 @@ private void InitializeComponent() panelColor.Controls.Add(pictureColor); panelColor.Controls.Add(buttonKeyboardColor); panelColor.Dock = DockStyle.Fill; - panelColor.Location = new Point(266, 6); - panelColor.Margin = new Padding(4, 6, 4, 6); + panelColor.Location = new Point(266, 8); + panelColor.Margin = new Padding(4, 8, 4, 8); panelColor.Name = "panelColor"; panelColor.Size = new Size(254, 48); panelColor.TabIndex = 36; @@ -1111,7 +1111,7 @@ private void InitializeComponent() buttonKeyboardColor.FlatStyle = FlatStyle.Flat; buttonKeyboardColor.ForeColor = SystemColors.ControlText; buttonKeyboardColor.Location = new Point(0, 0); - buttonKeyboardColor.Margin = new Padding(4, 6, 4, 6); + buttonKeyboardColor.Margin = new Padding(4, 8, 4, 8); buttonKeyboardColor.Name = "buttonKeyboardColor"; buttonKeyboardColor.Secondary = false; buttonKeyboardColor.Size = new Size(254, 48); @@ -1188,7 +1188,7 @@ private void InitializeComponent() panelVersion.Controls.Add(labelVersion); panelVersion.Controls.Add(checkStartup); panelVersion.Dock = DockStyle.Top; - panelVersion.Location = new Point(11, 1375); + panelVersion.Location = new Point(11, 1379); panelVersion.Margin = new Padding(4); panelVersion.Name = "panelVersion"; panelVersion.Size = new Size(827, 56); @@ -1201,7 +1201,7 @@ private void InitializeComponent() panelPeripherals.Controls.Add(tableLayoutPeripherals); panelPeripherals.Controls.Add(panelPeripheralsTile); panelPeripherals.Dock = DockStyle.Top; - panelPeripherals.Location = new Point(11, 1063); + panelPeripherals.Location = new Point(11, 1067); panelPeripherals.Margin = new Padding(0); panelPeripherals.Name = "panelPeripherals"; panelPeripherals.Padding = new Padding(20, 20, 20, 10);