Slash lightning (#2058)

* Slash Lightning

* Slash lightning UI tweaks

* Slash Lightning tweaks

* Minor tweaks

* Slash Interval settings

* UI tweaks

* Slash tweaks

* More slash modes

* Cleanup
This commit is contained in:
Serge
2024-02-12 18:43:27 +01:00
committed by GitHub
parent d2cb6965e0
commit 85725fb782
10 changed files with 342 additions and 92 deletions

View File

@@ -1,6 +1,5 @@
using NAudio.CoreAudioApi;
using NAudio.Wave;
using Starlight.AnimeMatrix;
using System.Diagnostics;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
@@ -15,14 +14,17 @@ namespace GHelper.AnimeMatrix
SettingsForm settings;
System.Timers.Timer matrixTimer = default!;
public AnimeMatrixDevice? device;
public AnimeMatrixDevice? deviceMatrix;
public SlashDevice? deviceSlash;
double[]? AudioValues;
WasapiCapture? AudioDevice;
string? AudioDeviceId;
private MMDeviceEnumerator? AudioDeviceEnum;
public bool IsValid => device != null;
public bool IsValid => deviceMatrix != null || deviceSlash != null;
public bool IsSlash => deviceSlash != null;
private long lastPresent;
private List<double> maxes = new List<double>();
@@ -33,38 +35,82 @@ namespace GHelper.AnimeMatrix
try
{
device = new AnimeMatrixDevice();
Task.Run(device.WakeUp);
if (AppConfig.IsSlash())
deviceSlash = new SlashDevice();
else
deviceMatrix = new AnimeMatrixDevice();
matrixTimer = new System.Timers.Timer(100);
matrixTimer.Elapsed += MatrixTimer_Elapsed;
}
catch
catch (Exception ex)
{
device = null;
Logger.WriteLine(ex.Message);
}
}
public void SetDevice(bool wakeUp = false)
{
if (deviceMatrix is not null) SetMatrix(wakeUp);
if (deviceSlash is not null) SetSlash(wakeUp);
}
public void SetSlash(bool wakeUp = false)
{
if (deviceSlash is null) return;
int brightness = AppConfig.Get("matrix_brightness", 0);
int running = AppConfig.Get("matrix_running", 0);
int inteval = AppConfig.Get("matrix_interval", 0);
bool auto = AppConfig.Is("matrix_auto");
Task.Run(() =>
{
try
{
deviceSlash.SetProvider();
}
catch (Exception ex)
{
Logger.WriteLine(ex.Message);
return;
}
if (wakeUp) deviceSlash.WakeUp();
if (brightness == 0 || (auto && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online))
{
deviceSlash.Init();
deviceSlash.SetOptions(false, 0, 0);
}
else
{
deviceSlash.Init();
deviceSlash.SetMode((SlashMode)running);
deviceSlash.SetOptions(true, brightness, inteval);
deviceSlash.Save();
}
});
}
public void SetBatteryAuto()
{
if (deviceSlash is not null) deviceSlash.SetBatterySaver(AppConfig.Is("matrix_auto"));
if (deviceMatrix is not null) SetMatrix();
}
public void SetMatrix(bool wakeUp = false)
{
if (!IsValid) return;
int brightness = AppConfig.Get("matrix_brightness");
int running = AppConfig.Get("matrix_running");
if (deviceMatrix is null) return;
int brightness = AppConfig.Get("matrix_brightness", 0);
int running = AppConfig.Get("matrix_running", 0);
bool auto = AppConfig.Is("matrix_auto");
if (brightness < 0) brightness = 0;
if (running < 0) running = 0;
BuiltInAnimation animation = new BuiltInAnimation(
(BuiltInAnimation.Running)running,
BuiltInAnimation.Sleeping.Starfield,
BuiltInAnimation.Shutdown.SeeYa,
BuiltInAnimation.Startup.StaticEmergence
);
StopMatrixTimer();
StopMatrixAudio();
@@ -72,7 +118,7 @@ namespace GHelper.AnimeMatrix
{
try
{
device.SetProvider();
deviceMatrix.SetProvider();
}
catch (Exception ex)
{
@@ -80,18 +126,18 @@ namespace GHelper.AnimeMatrix
return;
}
if (wakeUp) device.WakeUp();
if (wakeUp) deviceMatrix.WakeUp();
if (brightness == 0 || (auto && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online))
{
device.SetDisplayState(false);
device.SetDisplayState(false); // some devices are dumb
deviceMatrix.SetDisplayState(false);
deviceMatrix.SetDisplayState(false); // some devices are dumb
Logger.WriteLine("Matrix Off");
}
else
{
device.SetDisplayState(true);
device.SetBrightness((BrightnessMode)brightness);
deviceMatrix.SetDisplayState(true);
deviceMatrix.SetBrightness((BrightnessMode)brightness);
switch (running)
{
@@ -105,8 +151,7 @@ namespace GHelper.AnimeMatrix
SetMatrixAudio();
break;
default:
device.SetBuiltInAnimation(true, animation);
Logger.WriteLine("Matrix builtin " + animation.AsByte);
SetBuiltIn(running);
break;
}
@@ -115,6 +160,19 @@ namespace GHelper.AnimeMatrix
}
private void SetBuiltIn(int running)
{
BuiltInAnimation animation = new BuiltInAnimation(
(BuiltInAnimation.Running)running,
BuiltInAnimation.Sleeping.Starfield,
BuiltInAnimation.Shutdown.SeeYa,
BuiltInAnimation.Startup.StaticEmergence
);
deviceMatrix.SetBuiltInAnimation(true, animation);
Logger.WriteLine("Matrix builtin: " + animation.AsByte);
}
private void StartMatrixTimer(int interval = 100)
{
matrixTimer.Interval = interval;
@@ -129,15 +187,16 @@ namespace GHelper.AnimeMatrix
private void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e)
{
//if (!IsValid) return;
if (deviceMatrix is null) return;
switch (AppConfig.Get("matrix_running"))
{
case 2:
device.PresentNextFrame();
deviceMatrix.PresentNextFrame();
break;
case 3:
device.PresentClock();
deviceMatrix.PresentClock();
break;
}
@@ -146,7 +205,7 @@ namespace GHelper.AnimeMatrix
public void SetMatrixClock()
{
device.SetBuiltInAnimation(false);
deviceMatrix.SetBuiltInAnimation(false);
StartMatrixTimer(1000);
Logger.WriteLine("Matrix Clock");
}
@@ -177,9 +236,9 @@ namespace GHelper.AnimeMatrix
void SetMatrixAudio()
{
if (!IsValid) return;
if (deviceMatrix is null) return;
device.SetBuiltInAnimation(false);
deviceMatrix.SetBuiltInAnimation(false);
StopMatrixTimer();
StopMatrixAudio();
@@ -251,18 +310,20 @@ namespace GHelper.AnimeMatrix
for (int x = 0; x < 2 - (y % 2); x++)
{
//color = (byte)(Math.Min(1,(h - y - 2)*2) * 255);
device.SetLedPlanar(x + dx, dy + y, (byte)(h * 255 / 30));
device.SetLedPlanar(x + dx, dy - y, 255);
deviceMatrix.SetLedPlanar(x + dx, dy + y, (byte)(h * 255 / 30));
deviceMatrix.SetLedPlanar(x + dx, dy - y, 255);
}
}
void PresentAudio(double[] audio)
{
if (deviceMatrix is null) return;
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastPresent) < 70) return;
lastPresent = DateTimeOffset.Now.ToUnixTimeMilliseconds();
device.Clear();
deviceMatrix.Clear();
int size = 20;
double[] bars = new double[size];
@@ -280,7 +341,7 @@ namespace GHelper.AnimeMatrix
for (int i = 0; i < size; i++) DrawBar(20 - i, bars[i] * 20 / maxAverage);
device.Present();
deviceMatrix.Present();
}
@@ -309,7 +370,7 @@ namespace GHelper.AnimeMatrix
AppConfig.Set("matrix_running", 2);
SetMatrixPicture(fileName);
settings.SetMatrixRunning(2);
settings.VisualiseMatrixRunning(2);
}
@@ -318,7 +379,8 @@ namespace GHelper.AnimeMatrix
public void SetMatrixPicture(string fileName, bool visualise = true)
{
if (!IsValid) return;
if (deviceMatrix is null) return;
StopMatrixTimer();
try
@@ -338,7 +400,7 @@ namespace GHelper.AnimeMatrix
}
fs.Close();
if (visualise) settings.VisualiseMatrix(fileName);
if (visualise) settings.VisualiseMatrixPicture(fileName);
}
}
catch
@@ -351,8 +413,8 @@ namespace GHelper.AnimeMatrix
protected void ProcessPicture(Image image)
{
device.SetBuiltInAnimation(false);
device.ClearFrames();
deviceMatrix.SetBuiltInAnimation(false);
deviceMatrix.ClearFrames();
int matrixX = AppConfig.Get("matrix_x", 0);
int matrixY = AppConfig.Get("matrix_y", 0);
@@ -380,11 +442,11 @@ namespace GHelper.AnimeMatrix
image.SelectActiveFrame(dimension, i);
if (rotation == MatrixRotation.Planar)
device.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast);
deviceMatrix.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast);
else
device.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast);
deviceMatrix.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast);
device.AddFrame();
deviceMatrix.AddFrame();
}
@@ -397,11 +459,11 @@ namespace GHelper.AnimeMatrix
else
{
if (rotation == MatrixRotation.Planar)
device.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast);
deviceMatrix.GenerateFrame(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast);
else
device.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast);
deviceMatrix.GenerateFrameDiagonal(image, matrixZoom, matrixX, matrixY, matrixQuality, matrixContrast);
device.Present();
deviceMatrix.Present();
}
}

View File

@@ -5,7 +5,7 @@ using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Text;
namespace Starlight.AnimeMatrix
namespace GHelper.AnimeMatrix
{
public class BuiltInAnimation
{
@@ -91,7 +91,6 @@ namespace Starlight.AnimeMatrix
public int MaxRows = 61;
public int MaxColumns = 34;
public int LedStart = 0;
public int FullRows = 11;
private int frameIndex = 0;

View File

@@ -36,14 +36,12 @@ namespace GHelper.AnimeMatrix.Communication.Platform
{
HidDevice = DeviceList.Local
.GetHidDevices(vendorId, productId)
.First(x => x.GetMaxFeatureReportLength() == maxFeatureReportLength);
Logger.WriteLine("Matrix Device: " + HidDevice.DevicePath);
.First(x => x.GetMaxFeatureReportLength() >= maxFeatureReportLength);
Logger.WriteLine("Matrix Device: " + HidDevice.DevicePath + " " + HidDevice.GetMaxFeatureReportLength());
}
catch
{
throw new IOException("AniMe Matrix control device was not found on your machine.");
throw new IOException("Matrix control device was not found on your machine.");
}
var config = new OpenConfiguration();

View File

@@ -0,0 +1,138 @@
using GHelper.AnimeMatrix.Communication;
using System.Text;
namespace GHelper.AnimeMatrix
{
public enum SlashMode
{
Bounce,
Slash,
Loading,
BitStream,
Transmission,
Flow,
Flux,
Phantom,
Spectrum,
Hazard,
Interfacing,
Ramp,
GameOver,
Start,
Buzzer
}
internal class SlashPacket : Packet
{
public SlashPacket(byte[] command) : base(0x5E, 128, command)
{
}
}
public class SlashDevice : Device
{
public static Dictionary<SlashMode, string> Modes = new Dictionary<SlashMode, string>
{
{ SlashMode.Bounce, "Bounce"},
{ SlashMode.Slash, "Slash"},
{ SlashMode.Loading, "Loading"},
{ SlashMode.BitStream, "Bit Stream"},
{ SlashMode.Transmission, "Transmission"},
{ SlashMode.Flow, "Flow"},
{ SlashMode.Flux, "Flux"},
{ SlashMode.Phantom, "Phantom"},
{ SlashMode.Spectrum, "Spectrum"},
{ SlashMode.Hazard, "Hazard"},
{ SlashMode.Interfacing, "Interfacing"},
{ SlashMode.Ramp, "Ramp"},
{ SlashMode.GameOver, "Game Over"},
{ SlashMode.Start, "Start"},
{ SlashMode.Buzzer, "Buzzer"},
};
private static Dictionary<SlashMode, byte> modeCodes = new Dictionary<SlashMode, byte>
{
{ SlashMode.Bounce, 0x10},
{ SlashMode.Slash, 0x12},
{ SlashMode.Loading, 0x13},
{ SlashMode.BitStream, 0x1D},
{ SlashMode.Transmission, 0x1A},
{ SlashMode.Flow, 0x19},
{ SlashMode.Flux, 0x25},
{ SlashMode.Phantom, 0x24},
{ SlashMode.Spectrum, 0x26},
{ SlashMode.Hazard, 0x32},
{ SlashMode.Interfacing, 0x33},
{ SlashMode.Ramp, 0x34},
{ SlashMode.GameOver, 0x42},
{ SlashMode.Start, 0x43},
{ SlashMode.Buzzer, 0x44},
};
public SlashDevice() : base(0x0B05, 0x193B, 128)
{
}
public void WakeUp()
{
Set(Packet<SlashPacket>(Encoding.ASCII.GetBytes("ASUS Tech.Inc.")));
}
public void Init()
{
Set(Packet<SlashPacket>(0xD7, 0x00, 0x00, 0x01, 0xAC));
Set(Packet<SlashPacket>(0xD2, 0x02, 0x01, 0x08, 0xAB));
}
public void Save()
{
Set(Packet<SlashPacket>(0xD4, 0x00, 0x00, 0x01, 0xAB));
}
public void SetMode(SlashMode mode)
{
byte modeByte;
try
{
modeByte = modeCodes[mode];
}
catch (Exception)
{
modeByte = 0x00;
}
Set(Packet<SlashPacket>(0xD2, 0x03, 0x00, 0x0C));
Set(Packet<SlashPacket>(0xD3, 0x04, 0x00, 0x0C, 0x01, modeByte, 0x02, 0x19, 0x03, 0x13, 0x04, 0x11, 0x05, 0x12, 0x06, 0x13));
}
public void SetOptions(bool status, int brightness = 0, int interval = 0)
{
byte brightnessByte = (byte)(brightness * 85.333);
Set(Packet<SlashPacket>(0xD3, 0x03, 0x01, 0x08, 0xAB, 0xFF, 0x01, status ? (byte)0x01 : (byte)0x00, 0x06, brightnessByte, 0xFF, (byte)interval));
}
public void SetBatterySaver(bool status)
{
Set(Packet<SlashPacket>(0xD8, 0x01, 0x00, 0x01, status ? (byte)0x80 : (byte)0x00));
}
public void Set(Packet packet)
{
_usbProvider?.Set(packet.Data);
Logger.WriteLine("Slash:" + BitConverter.ToString(packet.Data));
}
}
}

View File

@@ -101,6 +101,8 @@ public static class AppConfig
}
}
//if (_model.Contains("GA402RK")) _model = "ROG Zephyrus G14 GA403UI"; // Debug Purposes
return _model;
}
@@ -377,9 +379,14 @@ public static class AppConfig
return ContainsModel("GA401") || ContainsModel("FX517Z") || ContainsModel("FX516P") || ContainsModel("X13") || IsARCNM() || ContainsModel("GA502IU");
}
public static bool IsSlash()
{
return ContainsModel("GA403") || ContainsModel("GU605");
}
public static bool IsInputBacklight()
{
return ContainsModel("GA503") || ContainsModel("GA403");
return ContainsModel("GA503") || IsSlash();
}
public static bool IsStrix()

View File

@@ -62,8 +62,8 @@ namespace GHelper
comboRotation.SelectedValueChanged += ComboRotation_SelectedValueChanged; ;
uiScale = panelPicture.Width / matrixControl.device.MaxColumns / 3;
panelPicture.Height = (int)(matrixControl.device.MaxRows * uiScale);
uiScale = panelPicture.Width / matrixControl.deviceMatrix.MaxColumns / 3;
panelPicture.Height = (int)(matrixControl.deviceMatrix.MaxRows * uiScale);
}

View File

@@ -229,7 +229,7 @@ namespace GHelper
BatteryControl.AutoBattery(init);
settingsForm.matrixControl.SetMatrix(true);
settingsForm.matrixControl.SetDevice(true);
if (AppConfig.IsAlly())
{

View File

@@ -65,6 +65,7 @@ namespace GHelper
panelGPU = new Panel();
labelTipGPU = new Label();
tableAMD = new TableLayoutPanel();
buttonOverlay = new RButton();
buttonFPS = new RButton();
tableGPU = new TableLayoutPanel();
buttonStopGPU = new RButton();
@@ -118,7 +119,7 @@ namespace GHelper
panelAllyTitle = new Panel();
pictureAlly = new PictureBox();
labelAlly = new Label();
buttonOverlay = new RButton();
comboInterval = new RComboBox();
panelMatrix.SuspendLayout();
tableLayoutMatrix.SuspendLayout();
panelMatrixTitle.SuspendLayout();
@@ -187,6 +188,7 @@ namespace GHelper
tableLayoutMatrix.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutMatrix.Controls.Add(comboMatrix, 0, 0);
tableLayoutMatrix.Controls.Add(comboMatrixRunning, 1, 0);
tableLayoutMatrix.Controls.Add(comboInterval, 2, 0);
tableLayoutMatrix.Controls.Add(buttonMatrix, 2, 0);
tableLayoutMatrix.Dock = DockStyle.Top;
tableLayoutMatrix.Location = new Point(20, 60);
@@ -194,7 +196,8 @@ namespace GHelper
tableLayoutMatrix.Name = "tableLayoutMatrix";
tableLayoutMatrix.RowCount = 1;
tableLayoutMatrix.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
tableLayoutMatrix.Size = new Size(787, 64);
tableLayoutMatrix.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));
tableLayoutMatrix.Size = new Size(787, 84);
tableLayoutMatrix.TabIndex = 43;
//
// comboMatrix
@@ -707,6 +710,28 @@ namespace GHelper
tableAMD.TabIndex = 24;
tableAMD.Visible = false;
//
// buttonOverlay
//
buttonOverlay.Activated = false;
buttonOverlay.BackColor = SystemColors.ControlLightLight;
buttonOverlay.BorderColor = Color.Transparent;
buttonOverlay.BorderRadius = 5;
buttonOverlay.Dock = DockStyle.Fill;
buttonOverlay.FlatAppearance.BorderSize = 0;
buttonOverlay.FlatStyle = FlatStyle.Flat;
buttonOverlay.ForeColor = SystemColors.ControlText;
buttonOverlay.Image = Properties.Resources.icons8_heartbeat_32;
buttonOverlay.ImageAlign = ContentAlignment.MiddleRight;
buttonOverlay.Location = new Point(266, 4);
buttonOverlay.Margin = new Padding(4);
buttonOverlay.Name = "buttonOverlay";
buttonOverlay.Secondary = false;
buttonOverlay.Size = new Size(254, 72);
buttonOverlay.TabIndex = 12;
buttonOverlay.Text = "AMD Overlay";
buttonOverlay.TextImageRelation = TextImageRelation.ImageBeforeText;
buttonOverlay.UseVisualStyleBackColor = false;
//
// buttonFPS
//
buttonFPS.Activated = false;
@@ -1586,27 +1611,20 @@ namespace GHelper
labelAlly.TabIndex = 26;
labelAlly.Text = "Ally Controller";
//
// buttonOverlay
// comboInterval
//
buttonOverlay.Activated = false;
buttonOverlay.BackColor = SystemColors.ControlLightLight;
buttonOverlay.BorderColor = Color.Transparent;
buttonOverlay.BorderRadius = 5;
buttonOverlay.Dock = DockStyle.Fill;
buttonOverlay.FlatAppearance.BorderSize = 0;
buttonOverlay.FlatStyle = FlatStyle.Flat;
buttonOverlay.ForeColor = SystemColors.ControlText;
buttonOverlay.Image = Properties.Resources.icons8_heartbeat_32;
buttonOverlay.ImageAlign = ContentAlignment.MiddleRight;
buttonOverlay.Location = new Point(266, 4);
buttonOverlay.Margin = new Padding(4);
buttonOverlay.Name = "buttonOverlay";
buttonOverlay.Secondary = false;
buttonOverlay.Size = new Size(254, 72);
buttonOverlay.TabIndex = 12;
buttonOverlay.Text = "AMD Overlay";
buttonOverlay.TextImageRelation = TextImageRelation.ImageBeforeText;
buttonOverlay.UseVisualStyleBackColor = false;
comboInterval.BorderColor = Color.White;
comboInterval.ButtonColor = Color.FromArgb(255, 255, 255);
comboInterval.Dock = DockStyle.Top;
comboInterval.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboInterval.FormattingEnabled = true;
comboInterval.ItemHeight = 32;
comboInterval.Location = new Point(7, 75);
comboInterval.Margin = new Padding(7, 11, 7, 8);
comboInterval.Name = "comboInterval";
comboInterval.Size = new Size(248, 40);
comboInterval.TabIndex = 19;
comboInterval.Visible = false;
//
// SettingsForm
//
@@ -1784,5 +1802,6 @@ namespace GHelper
private RButton buttonFPS;
private RButton buttonController;
private RButton buttonOverlay;
private RComboBox comboInterval;
}
}

View File

@@ -173,9 +173,11 @@ namespace GHelper
comboMatrix.DropDownStyle = ComboBoxStyle.DropDownList;
comboMatrixRunning.DropDownStyle = ComboBoxStyle.DropDownList;
comboInterval.DropDownStyle = ComboBoxStyle.DropDownList;
comboMatrix.DropDownClosed += ComboMatrix_SelectedValueChanged;
comboMatrixRunning.DropDownClosed += ComboMatrixRunning_SelectedValueChanged;
comboInterval.DropDownClosed += ComboInterval_DropDownClosed;
buttonMatrix.Click += ButtonMatrix_Click;
@@ -424,7 +426,7 @@ namespace GHelper
}
}
public void VisualiseMatrix(string image)
public void VisualiseMatrixPicture(string image)
{
if (matrixForm == null || matrixForm.Text == "") return;
matrixForm.VisualiseMatrix(image);
@@ -686,7 +688,7 @@ namespace GHelper
private void CheckMatrix_CheckedChanged(object? sender, EventArgs e)
{
AppConfig.Set("matrix_auto", checkMatrix.Checked ? 1 : 0);
matrixControl.SetMatrix();
matrixControl.SetBatteryAuto();
}
@@ -712,7 +714,7 @@ namespace GHelper
}
public void SetMatrixRunning(int mode)
public void VisualiseMatrixRunning(int mode)
{
Invoke(delegate
{
@@ -721,17 +723,23 @@ namespace GHelper
});
}
private void ComboInterval_DropDownClosed(object? sender, EventArgs e)
{
AppConfig.Set("matrix_interval", comboInterval.SelectedIndex);
matrixControl.SetDevice();
}
private void ComboMatrixRunning_SelectedValueChanged(object? sender, EventArgs e)
{
AppConfig.Set("matrix_running", comboMatrixRunning.SelectedIndex);
matrixControl.SetMatrix();
matrixControl.SetDevice();
}
private void ComboMatrix_SelectedValueChanged(object? sender, EventArgs e)
{
AppConfig.Set("matrix_brightness", comboMatrix.SelectedIndex);
matrixControl.SetMatrix();
matrixControl.SetDevice();
}
@@ -896,8 +904,26 @@ namespace GHelper
return;
}
if (matrixControl.IsSlash)
{
labelMatrix.Text = "Slash Lightning";
comboMatrixRunning.Items.Clear();
foreach (var item in SlashDevice.Modes)
{
comboMatrixRunning.Items.Add(item.Value);
}
comboInterval.Visible = true;
comboInterval.Items.Add($"Interval Off");
for (int i = 1; i <= 5; i++) comboInterval.Items.Add($"Interval {i}s");
buttonMatrix.Visible = false;
}
comboMatrix.SelectedIndex = Math.Min(AppConfig.Get("matrix_brightness", 0), comboMatrix.Items.Count - 1);
comboMatrixRunning.SelectedIndex = Math.Min(AppConfig.Get("matrix_running", 0), comboMatrixRunning.Items.Count - 1);
comboInterval.SelectedIndex = Math.Min(AppConfig.Get("matrix_interval", 0), comboInterval.Items.Count - 1);
checkMatrix.Checked = AppConfig.Is("matrix_auto");
checkMatrix.CheckedChanged += CheckMatrix_CheckedChanged;
@@ -909,7 +935,7 @@ namespace GHelper
{
comboMatrix.SelectedIndex = Math.Min(Math.Max(0, comboMatrix.SelectedIndex + delta), comboMatrix.Items.Count - 1);
AppConfig.Set("matrix_brightness", comboMatrix.SelectedIndex);
matrixControl.SetMatrix();
matrixControl.SetDevice();
Program.toast.RunToast(comboMatrix.GetItemText(comboMatrix.SelectedItem), delta > 0 ? ToastIcon.BacklightUp : ToastIcon.BacklightDown);
}

View File

@@ -294,12 +294,13 @@ namespace GHelper.USB
if (delay) await Task.Delay(TimeSpan.FromSeconds(1));
if (isACPI) Program.acpi.TUFKeyboardBrightness(brightness);
AsusHid.Write(new byte[] { AsusHid.AURA_ID, 0xBA, 0xC5, 0xC4, (byte)brightness }, log);
if (AppConfig.IsInputBacklight())
AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xBA, 0xC5, 0xC4, (byte)brightness }, log);
else
AsusHid.Write(new byte[] { AsusHid.AURA_ID, 0xBA, 0xC5, 0xC4, (byte)brightness }, log);
if (AppConfig.IsAlly()) ApplyAura();
if (AppConfig.IsInputBacklight())
AsusHid.WriteInput(new byte[] { AsusHid.INPUT_ID, 0xBA, 0xC5, 0xC4, (byte)brightness }, log);
});