This commit is contained in:
Serge
2023-05-09 16:13:40 +02:00
9 changed files with 387 additions and 295 deletions

View File

@@ -1,5 +1,7 @@
using HidLibrary; using HidLibrary;
using OSD;
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Forms;
namespace GHelper namespace GHelper
{ {
@@ -196,15 +198,16 @@ namespace GHelper
{ {
byte[] msg = { 0x5d, 0xba, 0xc5, 0xc4, (byte)brightness }; byte[] msg = { 0x5d, 0xba, 0xc5, 0xc4, (byte)brightness };
foreach (HidDevice device in GetHidDevices(new int[] { 0x19b6 })) var devices = GetHidDevices(new int[] { 0x19b6 });
if (devices.Count() > 0) Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
foreach (HidDevice device in devices)
{ {
device.OpenDevice(); device.OpenDevice();
device.Write(msg); device.Write(msg);
device.CloseDevice(); device.CloseDevice();
} }
Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
if (Program.config.ContainsModel("TUF")) if (Program.config.ContainsModel("TUF"))
Program.wmi.TUFKeyboardBrightness(brightness); Program.wmi.TUFKeyboardBrightness(brightness);
} }
@@ -215,18 +218,18 @@ namespace GHelper
byte[] msg = AuraDev19b6Extensions.ToBytes(flags.ToArray()); byte[] msg = AuraDev19b6Extensions.ToBytes(flags.ToArray());
Debug.WriteLine(BitConverter.ToString(msg));
foreach (HidDevice device in GetHidDevices(new int[] { 0x19b6 })) var devices = GetHidDevices(new int[] { 0x19b6 });
if (devices.Count() > 0) Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
foreach (HidDevice device in devices)
{ {
device.OpenDevice(); device.OpenDevice();
device.Write(msg); device.Write(msg);
device.CloseDevice(); device.CloseDevice();
} }
Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg)); if (Program.config.ContainsModel("TUF"))
//if (Program.config.ContainsModel("TUF"))
Program.wmi.TUFKeyboardPower( Program.wmi.TUFKeyboardPower(
flags.Contains(AuraDev19b6.AwakeKeyb), flags.Contains(AuraDev19b6.AwakeKeyb),
flags.Contains(AuraDev19b6.BootKeyb), flags.Contains(AuraDev19b6.BootKeyb),
@@ -235,6 +238,22 @@ namespace GHelper
} }
public static void ApplyXGMLight(bool status)
{
byte value = status? (byte)0x50:(byte)0;
var msg = new byte[] { 0x5e, 0xc5, value };
foreach (HidDevice device in GetHidDevices(new int[] { 0x1970 }))
{
device.OpenDevice();
var message = new byte[300];
Array.Copy(msg, message, msg.Length);
Debug.WriteLine(BitConverter.ToString(message));
device.WriteFeatureData(message);
device.CloseDevice();
}
}
public static void ApplyAura() public static void ApplyAura()
{ {
@@ -256,7 +275,10 @@ namespace GHelper
byte[] msg = AuraMessage(Mode, Color1, Color2, _speed); byte[] msg = AuraMessage(Mode, Color1, Color2, _speed);
foreach (HidDevice device in GetHidDevices(deviceIds)) var devices = GetHidDevices(deviceIds);
if (devices.Count() > 0) Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
foreach (HidDevice device in devices)
{ {
device.OpenDevice(); device.OpenDevice();
device.Write(msg); device.Write(msg);

445
app/Extra.Designer.cs generated
View File

@@ -43,31 +43,34 @@ namespace GHelper
comboM3 = new RComboBox(); comboM3 = new RComboBox();
labelM3 = new Label(); labelM3 = new Label();
groupLight = new GroupBox(); groupLight = new GroupBox();
panelBacklightExtra = new Panel();
labelBrightness = new Label();
trackBrightness = new TrackBar();
labelSpeed = new Label();
comboKeyboardSpeed = new RComboBox();
panelXMG = new Panel();
checkXMG = new CheckBox();
tableBacklight = new TableLayoutPanel(); tableBacklight = new TableLayoutPanel();
checkBootLid = new CheckBox(); labelBacklight = new Label();
checkShutdown = new CheckBox();
checkAwake = new CheckBox(); checkAwake = new CheckBox();
checkBoot = new CheckBox(); checkBoot = new CheckBox();
checkSleep = new CheckBox(); checkSleep = new CheckBox();
labelBacklight = new Label(); checkShutdown = new CheckBox();
checkSleepBar = new CheckBox();
checkShutdownBar = new CheckBox();
labelBacklightBar = new Label();
checkAwakeBar = new CheckBox();
checkBootBar = new CheckBox();
checkSleepLid = new CheckBox();
checkShutdownLid = new CheckBox();
labelBacklightLid = new Label();
checkAwakeLid = new CheckBox();
labelBacklightLogo = new Label(); labelBacklightLogo = new Label();
checkAwakeLogo = new CheckBox(); checkAwakeLogo = new CheckBox();
checkBootLogo = new CheckBox(); checkBootLogo = new CheckBox();
checkSleepLogo = new CheckBox(); checkSleepLogo = new CheckBox();
checkShutdownLogo = new CheckBox(); checkShutdownLogo = new CheckBox();
labelBrightness = new Label(); labelBacklightBar = new Label();
trackBrightness = new TrackBar(); checkAwakeBar = new CheckBox();
labelSpeed = new Label(); checkBootBar = new CheckBox();
comboKeyboardSpeed = new RComboBox(); checkSleepBar = new CheckBox();
checkShutdownBar = new CheckBox();
labelBacklightLid = new Label();
checkAwakeLid = new CheckBox();
checkBootLid = new CheckBox();
checkSleepLid = new CheckBox();
checkShutdownLid = new CheckBox();
groupOther = new GroupBox(); groupOther = new GroupBox();
checkUSBC = new CheckBox(); checkUSBC = new CheckBox();
checkNoOverdrive = new CheckBox(); checkNoOverdrive = new CheckBox();
@@ -76,8 +79,10 @@ namespace GHelper
groupBindings.SuspendLayout(); groupBindings.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureHelp).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureHelp).BeginInit();
groupLight.SuspendLayout(); groupLight.SuspendLayout();
tableBacklight.SuspendLayout(); panelBacklightExtra.SuspendLayout();
((System.ComponentModel.ISupportInitialize)trackBrightness).BeginInit(); ((System.ComponentModel.ISupportInitialize)trackBrightness).BeginInit();
panelXMG.SuspendLayout();
tableBacklight.SuspendLayout();
groupOther.SuspendLayout(); groupOther.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
@@ -197,19 +202,94 @@ namespace GHelper
// //
// groupLight // groupLight
// //
groupLight.AutoSize = true;
groupLight.Controls.Add(panelBacklightExtra);
groupLight.Controls.Add(panelXMG);
groupLight.Controls.Add(tableBacklight); groupLight.Controls.Add(tableBacklight);
groupLight.Controls.Add(labelBrightness);
groupLight.Controls.Add(trackBrightness);
groupLight.Controls.Add(labelSpeed);
groupLight.Controls.Add(comboKeyboardSpeed);
groupLight.Dock = DockStyle.Top; groupLight.Dock = DockStyle.Top;
groupLight.Location = new Point(10, 252); groupLight.Location = new Point(10, 252);
groupLight.Name = "groupLight"; groupLight.Name = "groupLight";
groupLight.Size = new Size(848, 444); groupLight.Size = new Size(848, 475);
groupLight.TabIndex = 1; groupLight.TabIndex = 1;
groupLight.TabStop = false; groupLight.TabStop = false;
groupLight.Text = "Keyboard Backlight"; groupLight.Text = "Keyboard Backlight";
// //
// panelBacklightExtra
//
panelBacklightExtra.AutoSize = true;
panelBacklightExtra.Controls.Add(labelBrightness);
panelBacklightExtra.Controls.Add(trackBrightness);
panelBacklightExtra.Controls.Add(labelSpeed);
panelBacklightExtra.Controls.Add(comboKeyboardSpeed);
panelBacklightExtra.Dock = DockStyle.Top;
panelBacklightExtra.Location = new Point(3, 319);
panelBacklightExtra.Name = "panelBacklightExtra";
panelBacklightExtra.Size = new Size(842, 153);
panelBacklightExtra.TabIndex = 43;
//
// labelBrightness
//
labelBrightness.Location = new Point(13, 76);
labelBrightness.Name = "labelBrightness";
labelBrightness.Size = new Size(197, 49);
labelBrightness.TabIndex = 41;
labelBrightness.Text = "Brightness";
//
// trackBrightness
//
trackBrightness.Location = new Point(216, 60);
trackBrightness.Maximum = 3;
trackBrightness.Name = "trackBrightness";
trackBrightness.Size = new Size(600, 90);
trackBrightness.TabIndex = 42;
trackBrightness.TickStyle = TickStyle.TopLeft;
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(13, 15);
labelSpeed.MaximumSize = new Size(200, 0);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(198, 32);
labelSpeed.TabIndex = 44;
labelSpeed.Text = "Animation Speed";
//
// comboKeyboardSpeed
//
comboKeyboardSpeed.BorderColor = Color.White;
comboKeyboardSpeed.ButtonColor = SystemColors.ControlLight;
comboKeyboardSpeed.FlatStyle = FlatStyle.Flat;
comboKeyboardSpeed.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboKeyboardSpeed.FormattingEnabled = true;
comboKeyboardSpeed.ItemHeight = 32;
comboKeyboardSpeed.Items.AddRange(new object[] { "Slow", "Normal", "Fast" });
comboKeyboardSpeed.Location = new Point(220, 12);
comboKeyboardSpeed.Margin = new Padding(4, 10, 4, 8);
comboKeyboardSpeed.Name = "comboKeyboardSpeed";
comboKeyboardSpeed.Size = new Size(291, 40);
comboKeyboardSpeed.TabIndex = 43;
comboKeyboardSpeed.TabStop = false;
//
// panelXMG
//
panelXMG.Controls.Add(checkXMG);
panelXMG.Dock = DockStyle.Top;
panelXMG.Location = new Point(3, 261);
panelXMG.Name = "panelXMG";
panelXMG.Size = new Size(842, 58);
panelXMG.TabIndex = 42;
//
// checkXMG
//
checkXMG.AutoSize = true;
checkXMG.Location = new Point(3, 10);
checkXMG.Name = "checkXMG";
checkXMG.Padding = new Padding(15, 2, 5, 2);
checkXMG.Size = new Size(178, 40);
checkXMG.TabIndex = 2;
checkXMG.Text = "XG Mobile";
checkXMG.UseVisualStyleBackColor = true;
//
// tableBacklight // tableBacklight
// //
tableBacklight.AutoSize = true; tableBacklight.AutoSize = true;
@@ -218,32 +298,26 @@ namespace GHelper
tableBacklight.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableBacklight.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableBacklight.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableBacklight.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableBacklight.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableBacklight.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableBacklight.Controls.Add(labelBacklight, 0, 0); tableBacklight.Controls.Add(labelBacklight, 0, 0);
tableBacklight.Controls.Add(checkAwake, 0, 1); tableBacklight.Controls.Add(checkAwake, 0, 1);
tableBacklight.Controls.Add(checkBoot, 0, 2); tableBacklight.Controls.Add(checkBoot, 0, 2);
tableBacklight.Controls.Add(checkSleep, 0, 3); tableBacklight.Controls.Add(checkSleep, 0, 3);
tableBacklight.Controls.Add(checkShutdown, 0, 4); tableBacklight.Controls.Add(checkShutdown, 0, 4);
tableBacklight.Controls.Add(labelBacklightLogo, 1, 0); tableBacklight.Controls.Add(labelBacklightLogo, 1, 0);
tableBacklight.Controls.Add(checkAwakeLogo, 1, 1); tableBacklight.Controls.Add(checkAwakeLogo, 1, 1);
tableBacklight.Controls.Add(checkBootLogo, 1, 2); tableBacklight.Controls.Add(checkBootLogo, 1, 2);
tableBacklight.Controls.Add(checkSleepLogo, 1, 3); tableBacklight.Controls.Add(checkSleepLogo, 1, 3);
tableBacklight.Controls.Add(checkShutdownLogo, 1, 4); tableBacklight.Controls.Add(checkShutdownLogo, 1, 4);
tableBacklight.Controls.Add(labelBacklightBar, 2, 0); tableBacklight.Controls.Add(labelBacklightBar, 2, 0);
tableBacklight.Controls.Add(checkAwakeBar, 2, 1); tableBacklight.Controls.Add(checkAwakeBar, 2, 1);
tableBacklight.Controls.Add(checkBootBar, 2, 2); tableBacklight.Controls.Add(checkBootBar, 2, 2);
tableBacklight.Controls.Add(checkSleepBar, 2, 3); tableBacklight.Controls.Add(checkSleepBar, 2, 3);
tableBacklight.Controls.Add(checkShutdownBar, 2, 4); tableBacklight.Controls.Add(checkShutdownBar, 2, 4);
tableBacklight.Controls.Add(labelBacklightLid, 3, 0); tableBacklight.Controls.Add(labelBacklightLid, 3, 0);
tableBacklight.Controls.Add(checkAwakeLid, 3, 1); tableBacklight.Controls.Add(checkAwakeLid, 3, 1);
tableBacklight.Controls.Add(checkBootLid, 3, 2); tableBacklight.Controls.Add(checkBootLid, 3, 2);
tableBacklight.Controls.Add(checkSleepLid, 3, 3); tableBacklight.Controls.Add(checkSleepLid, 3, 3);
tableBacklight.Controls.Add(checkShutdownLid, 3, 4); tableBacklight.Controls.Add(checkShutdownLid, 3, 4);
tableBacklight.Dock = DockStyle.Top; tableBacklight.Dock = DockStyle.Top;
tableBacklight.Location = new Point(3, 35); tableBacklight.Location = new Point(3, 35);
tableBacklight.Margin = new Padding(0); tableBacklight.Margin = new Padding(0);
@@ -257,27 +331,16 @@ namespace GHelper
tableBacklight.Size = new Size(842, 226); tableBacklight.Size = new Size(842, 226);
tableBacklight.TabIndex = 41; tableBacklight.TabIndex = 41;
// //
// checkBootLid // labelBacklight
// //
checkBootLid.AutoSize = true; labelBacklight.AutoSize = true;
checkBootLid.Location = new Point(423, 91); labelBacklight.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
checkBootLid.Name = "checkBootLid"; labelBacklight.Location = new Point(3, 0);
checkBootLid.Padding = new Padding(15, 2, 5, 2); labelBacklight.Name = "labelBacklight";
checkBootLid.Size = new Size(116, 40); labelBacklight.Padding = new Padding(10, 5, 5, 5);
checkBootLid.TabIndex = 13; labelBacklight.Size = new Size(139, 42);
checkBootLid.Text = Strings.Boot; labelBacklight.TabIndex = 6;
checkBootLid.UseVisualStyleBackColor = true; labelBacklight.Text = "Keyboard";
//
// checkShutdown
//
checkShutdown.AutoSize = true;
checkShutdown.Location = new Point(3, 183);
checkShutdown.Name = "checkShutdown";
checkShutdown.Padding = new Padding(15, 2, 5, 2);
checkShutdown.Size = new Size(174, 40);
checkShutdown.TabIndex = 4;
checkShutdown.Text = Strings.Shutdown;
checkShutdown.UseVisualStyleBackColor = true;
// //
// checkAwake // checkAwake
// //
@@ -312,121 +375,22 @@ namespace GHelper
checkSleep.Text = Strings.Sleep; checkSleep.Text = Strings.Sleep;
checkSleep.UseVisualStyleBackColor = true; checkSleep.UseVisualStyleBackColor = true;
// //
// labelBacklight // checkShutdown
// //
labelBacklight.AutoSize = true; checkShutdown.AutoSize = true;
labelBacklight.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); checkShutdown.Location = new Point(3, 183);
labelBacklight.Location = new Point(3, 0); checkShutdown.Name = "checkShutdown";
labelBacklight.Name = "labelBacklight"; checkShutdown.Padding = new Padding(15, 2, 5, 2);
labelBacklight.Padding = new Padding(10, 5, 5, 5); checkShutdown.Size = new Size(174, 40);
labelBacklight.Size = new Size(139, 42); checkShutdown.TabIndex = 4;
labelBacklight.TabIndex = 6; checkShutdown.Text = Strings.Shutdown;
labelBacklight.Text = "Keyboard"; checkShutdown.UseVisualStyleBackColor = true;
//
// checkSleepBar
//
checkSleepBar.AutoSize = true;
checkSleepBar.Location = new Point(213, 137);
checkSleepBar.Name = "checkSleepBar";
checkSleepBar.Padding = new Padding(15, 2, 5, 2);
checkSleepBar.Size = new Size(125, 40);
checkSleepBar.TabIndex = 9;
checkSleepBar.Text = Strings.Sleep;
checkSleepBar.UseVisualStyleBackColor = true;
//
// checkShutdownBar
//
checkShutdownBar.AutoSize = true;
checkShutdownBar.Location = new Point(213, 183);
checkShutdownBar.Name = "checkShutdownBar";
checkShutdownBar.Padding = new Padding(15, 2, 5, 2);
checkShutdownBar.Size = new Size(174, 40);
checkShutdownBar.TabIndex = 10;
checkShutdownBar.Text = Strings.Shutdown;
checkShutdownBar.UseVisualStyleBackColor = true;
//
// labelBacklightBar
//
labelBacklightBar.AutoSize = true;
labelBacklightBar.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelBacklightBar.Location = new Point(213, 0);
labelBacklightBar.Name = "labelBacklightBar";
labelBacklightBar.Padding = new Padding(10, 5, 5, 5);
labelBacklightBar.Size = new Size(124, 42);
labelBacklightBar.TabIndex = 11;
labelBacklightBar.Text = "Lightbar";
//
// checkAwakeBar
//
checkAwakeBar.AutoSize = true;
checkAwakeBar.Location = new Point(213, 45);
checkAwakeBar.Name = "checkAwakeBar";
checkAwakeBar.Padding = new Padding(15, 2, 5, 2);
checkAwakeBar.Size = new Size(135, 40);
checkAwakeBar.TabIndex = 7;
checkAwakeBar.Text = Strings.Awake;
checkAwakeBar.UseVisualStyleBackColor = true;
//
// checkBootBar
//
checkBootBar.AutoSize = true;
checkBootBar.Location = new Point(213, 91);
checkBootBar.Name = "checkBootBar";
checkBootBar.Padding = new Padding(15, 2, 5, 2);
checkBootBar.Size = new Size(116, 40);
checkBootBar.TabIndex = 8;
checkBootBar.Text = Strings.Boot;
checkBootBar.UseVisualStyleBackColor = true;
//
// checkSleepLid
//
checkSleepLid.AutoSize = true;
checkSleepLid.Location = new Point(423, 137);
checkSleepLid.Name = "checkSleepLid";
checkSleepLid.Padding = new Padding(15, 2, 5, 2);
checkSleepLid.Size = new Size(125, 40);
checkSleepLid.TabIndex = 14;
checkSleepLid.Text = Strings.Sleep;
checkSleepLid.UseVisualStyleBackColor = true;
//
// checkShutdownLid
//
checkShutdownLid.AutoSize = true;
checkShutdownLid.Location = new Point(423, 183);
checkShutdownLid.Name = "checkShutdownLid";
checkShutdownLid.Padding = new Padding(15, 2, 5, 2);
checkShutdownLid.Size = new Size(174, 40);
checkShutdownLid.TabIndex = 15;
checkShutdownLid.Text = Strings.Shutdown;
checkShutdownLid.UseVisualStyleBackColor = true;
//
// labelBacklightLid
//
labelBacklightLid.AutoSize = true;
labelBacklightLid.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelBacklightLid.Location = new Point(423, 0);
labelBacklightLid.Name = "labelBacklightLid";
labelBacklightLid.Padding = new Padding(10, 5, 5, 5);
labelBacklightLid.Size = new Size(63, 42);
labelBacklightLid.TabIndex = 16;
labelBacklightLid.Text = "Lid";
//
// checkAwakeLid
//
checkAwakeLid.AutoSize = true;
checkAwakeLid.Location = new Point(423, 45);
checkAwakeLid.Name = "checkAwakeLid";
checkAwakeLid.Padding = new Padding(15, 2, 5, 2);
checkAwakeLid.Size = new Size(135, 40);
checkAwakeLid.TabIndex = 12;
checkAwakeLid.Text = Strings.Awake;
checkAwakeLid.UseVisualStyleBackColor = true;
// //
// labelBacklightLogo // labelBacklightLogo
// //
labelBacklightLogo.AutoSize = true; labelBacklightLogo.AutoSize = true;
labelBacklightLogo.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); labelBacklightLogo.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelBacklightLogo.Location = new Point(633, 0); labelBacklightLogo.Location = new Point(213, 0);
labelBacklightLogo.Name = "labelBacklightLogo"; labelBacklightLogo.Name = "labelBacklightLogo";
labelBacklightLogo.Padding = new Padding(10, 5, 5, 5); labelBacklightLogo.Padding = new Padding(10, 5, 5, 5);
labelBacklightLogo.Size = new Size(86, 42); labelBacklightLogo.Size = new Size(86, 42);
@@ -436,7 +400,7 @@ namespace GHelper
// checkAwakeLogo // checkAwakeLogo
// //
checkAwakeLogo.AutoSize = true; checkAwakeLogo.AutoSize = true;
checkAwakeLogo.Location = new Point(633, 45); checkAwakeLogo.Location = new Point(213, 45);
checkAwakeLogo.Name = "checkAwakeLogo"; checkAwakeLogo.Name = "checkAwakeLogo";
checkAwakeLogo.Padding = new Padding(15, 2, 5, 2); checkAwakeLogo.Padding = new Padding(15, 2, 5, 2);
checkAwakeLogo.Size = new Size(135, 40); checkAwakeLogo.Size = new Size(135, 40);
@@ -447,7 +411,7 @@ namespace GHelper
// checkBootLogo // checkBootLogo
// //
checkBootLogo.AutoSize = true; checkBootLogo.AutoSize = true;
checkBootLogo.Location = new Point(633, 91); checkBootLogo.Location = new Point(213, 91);
checkBootLogo.Name = "checkBootLogo"; checkBootLogo.Name = "checkBootLogo";
checkBootLogo.Padding = new Padding(15, 2, 5, 2); checkBootLogo.Padding = new Padding(15, 2, 5, 2);
checkBootLogo.Size = new Size(116, 40); checkBootLogo.Size = new Size(116, 40);
@@ -458,7 +422,7 @@ namespace GHelper
// checkSleepLogo // checkSleepLogo
// //
checkSleepLogo.AutoSize = true; checkSleepLogo.AutoSize = true;
checkSleepLogo.Location = new Point(633, 137); checkSleepLogo.Location = new Point(213, 137);
checkSleepLogo.Name = "checkSleepLogo"; checkSleepLogo.Name = "checkSleepLogo";
checkSleepLogo.Padding = new Padding(15, 2, 5, 2); checkSleepLogo.Padding = new Padding(15, 2, 5, 2);
checkSleepLogo.Size = new Size(125, 40); checkSleepLogo.Size = new Size(125, 40);
@@ -469,7 +433,7 @@ namespace GHelper
// checkShutdownLogo // checkShutdownLogo
// //
checkShutdownLogo.AutoSize = true; checkShutdownLogo.AutoSize = true;
checkShutdownLogo.Location = new Point(633, 183); checkShutdownLogo.Location = new Point(213, 183);
checkShutdownLogo.Name = "checkShutdownLogo"; checkShutdownLogo.Name = "checkShutdownLogo";
checkShutdownLogo.Padding = new Padding(15, 2, 5, 2); checkShutdownLogo.Padding = new Padding(15, 2, 5, 2);
checkShutdownLogo.Size = new Size(174, 40); checkShutdownLogo.Size = new Size(174, 40);
@@ -477,48 +441,115 @@ namespace GHelper
checkShutdownLogo.Text = Strings.Shutdown; checkShutdownLogo.Text = Strings.Shutdown;
checkShutdownLogo.UseVisualStyleBackColor = true; checkShutdownLogo.UseVisualStyleBackColor = true;
// //
// labelBrightness // labelBacklightBar
// //
labelBrightness.Location = new Point(15, 357); labelBacklightBar.AutoSize = true;
labelBrightness.Name = "labelBrightness"; labelBacklightBar.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelBrightness.Size = new Size(197, 49); labelBacklightBar.Location = new Point(423, 0);
labelBrightness.TabIndex = 0; labelBacklightBar.Name = "labelBacklightBar";
labelBrightness.Text = "Brightness"; labelBacklightBar.Padding = new Padding(10, 5, 5, 5);
labelBacklightBar.Size = new Size(124, 42);
labelBacklightBar.TabIndex = 11;
labelBacklightBar.Text = "Lightbar";
// //
// trackBrightness // checkAwakeBar
// //
trackBrightness.Location = new Point(218, 341); checkAwakeBar.AutoSize = true;
trackBrightness.Maximum = 3; checkAwakeBar.Location = new Point(423, 45);
trackBrightness.Name = "trackBrightness"; checkAwakeBar.Name = "checkAwakeBar";
trackBrightness.Size = new Size(600, 90); checkAwakeBar.Padding = new Padding(15, 2, 5, 2);
trackBrightness.TabIndex = 1; checkAwakeBar.Size = new Size(135, 40);
trackBrightness.TickStyle = TickStyle.TopLeft; checkAwakeBar.TabIndex = 7;
checkAwakeBar.Text = Strings.Awake;
checkAwakeBar.UseVisualStyleBackColor = true;
// //
// labelSpeed // checkBootBar
// //
labelSpeed.AutoSize = true; checkBootBar.AutoSize = true;
labelSpeed.Location = new Point(15, 296); checkBootBar.Location = new Point(423, 91);
labelSpeed.MaximumSize = new Size(200, 0); checkBootBar.Name = "checkBootBar";
labelSpeed.Name = "labelSpeed"; checkBootBar.Padding = new Padding(15, 2, 5, 2);
labelSpeed.Size = new Size(198, 32); checkBootBar.Size = new Size(116, 40);
labelSpeed.TabIndex = 40; checkBootBar.TabIndex = 8;
labelSpeed.Text = "Animation Speed"; checkBootBar.Text = Strings.Boot;
checkBootBar.UseVisualStyleBackColor = true;
// //
// comboKeyboardSpeed // checkSleepBar
// //
comboKeyboardSpeed.BorderColor = Color.White; checkSleepBar.AutoSize = true;
comboKeyboardSpeed.ButtonColor = SystemColors.ControlLight; checkSleepBar.Location = new Point(423, 137);
comboKeyboardSpeed.FlatStyle = FlatStyle.Flat; checkSleepBar.Name = "checkSleepBar";
comboKeyboardSpeed.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); checkSleepBar.Padding = new Padding(15, 2, 5, 2);
comboKeyboardSpeed.FormattingEnabled = true; checkSleepBar.Size = new Size(125, 40);
comboKeyboardSpeed.ItemHeight = 32; checkSleepBar.TabIndex = 9;
comboKeyboardSpeed.Items.AddRange(new object[] { "Slow", "Normal", "Fast" }); checkSleepBar.Text = Strings.Sleep;
comboKeyboardSpeed.Location = new Point(222, 293); checkSleepBar.UseVisualStyleBackColor = true;
comboKeyboardSpeed.Margin = new Padding(4, 10, 4, 8); //
comboKeyboardSpeed.Name = "comboKeyboardSpeed"; // checkShutdownBar
comboKeyboardSpeed.Size = new Size(291, 40); //
comboKeyboardSpeed.TabIndex = 39; checkShutdownBar.AutoSize = true;
comboKeyboardSpeed.TabStop = false; checkShutdownBar.Location = new Point(423, 183);
checkShutdownBar.Name = "checkShutdownBar";
checkShutdownBar.Padding = new Padding(15, 2, 5, 2);
checkShutdownBar.Size = new Size(174, 40);
checkShutdownBar.TabIndex = 10;
checkShutdownBar.Text = Strings.Shutdown;
checkShutdownBar.UseVisualStyleBackColor = true;
//
// labelBacklightLid
//
labelBacklightLid.AutoSize = true;
labelBacklightLid.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelBacklightLid.Location = new Point(633, 0);
labelBacklightLid.Name = "labelBacklightLid";
labelBacklightLid.Padding = new Padding(10, 5, 5, 5);
labelBacklightLid.Size = new Size(63, 42);
labelBacklightLid.TabIndex = 16;
labelBacklightLid.Text = "Lid";
//
// checkAwakeLid
//
checkAwakeLid.AutoSize = true;
checkAwakeLid.Location = new Point(633, 45);
checkAwakeLid.Name = "checkAwakeLid";
checkAwakeLid.Padding = new Padding(15, 2, 5, 2);
checkAwakeLid.Size = new Size(135, 40);
checkAwakeLid.TabIndex = 12;
checkAwakeLid.Text = Strings.Awake;
checkAwakeLid.UseVisualStyleBackColor = true;
//
// checkBootLid
//
checkBootLid.AutoSize = true;
checkBootLid.Location = new Point(633, 91);
checkBootLid.Name = "checkBootLid";
checkBootLid.Padding = new Padding(15, 2, 5, 2);
checkBootLid.Size = new Size(116, 40);
checkBootLid.TabIndex = 13;
checkBootLid.Text = Strings.Boot;
checkBootLid.UseVisualStyleBackColor = true;
//
// checkSleepLid
//
checkSleepLid.AutoSize = true;
checkSleepLid.Location = new Point(633, 137);
checkSleepLid.Name = "checkSleepLid";
checkSleepLid.Padding = new Padding(15, 2, 5, 2);
checkSleepLid.Size = new Size(125, 40);
checkSleepLid.TabIndex = 14;
checkSleepLid.Text = Strings.Sleep;
checkSleepLid.UseVisualStyleBackColor = true;
//
// checkShutdownLid
//
checkShutdownLid.AutoSize = true;
checkShutdownLid.Location = new Point(633, 183);
checkShutdownLid.Name = "checkShutdownLid";
checkShutdownLid.Padding = new Padding(15, 2, 5, 2);
checkShutdownLid.Size = new Size(174, 40);
checkShutdownLid.TabIndex = 15;
checkShutdownLid.Text = Strings.Shutdown;
checkShutdownLid.UseVisualStyleBackColor = true;
// //
// groupOther // groupOther
// //
@@ -527,7 +558,7 @@ namespace GHelper
groupOther.Controls.Add(checkKeyboardAuto); groupOther.Controls.Add(checkKeyboardAuto);
groupOther.Controls.Add(checkTopmost); groupOther.Controls.Add(checkTopmost);
groupOther.Dock = DockStyle.Top; groupOther.Dock = DockStyle.Top;
groupOther.Location = new Point(10, 696); groupOther.Location = new Point(10, 727);
groupOther.Name = "groupOther"; groupOther.Name = "groupOther";
groupOther.Size = new Size(848, 293); groupOther.Size = new Size(848, 293);
groupOther.TabIndex = 2; groupOther.TabIndex = 2;
@@ -557,7 +588,7 @@ namespace GHelper
// checkKeyboardAuto // checkKeyboardAuto
// //
checkKeyboardAuto.AutoSize = true; checkKeyboardAuto.AutoSize = true;
checkKeyboardAuto.Location = new Point(25, 51); checkKeyboardAuto.Location = new Point(25, 52);
checkKeyboardAuto.MaximumSize = new Size(780, 0); checkKeyboardAuto.MaximumSize = new Size(780, 0);
checkKeyboardAuto.Name = "checkKeyboardAuto"; checkKeyboardAuto.Name = "checkKeyboardAuto";
checkKeyboardAuto.Size = new Size(712, 36); checkKeyboardAuto.Size = new Size(712, 36);
@@ -597,12 +628,17 @@ namespace GHelper
((System.ComponentModel.ISupportInitialize)pictureHelp).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureHelp).EndInit();
groupLight.ResumeLayout(false); groupLight.ResumeLayout(false);
groupLight.PerformLayout(); groupLight.PerformLayout();
panelBacklightExtra.ResumeLayout(false);
panelBacklightExtra.PerformLayout();
((System.ComponentModel.ISupportInitialize)trackBrightness).EndInit();
panelXMG.ResumeLayout(false);
panelXMG.PerformLayout();
tableBacklight.ResumeLayout(false); tableBacklight.ResumeLayout(false);
tableBacklight.PerformLayout(); tableBacklight.PerformLayout();
((System.ComponentModel.ISupportInitialize)trackBrightness).EndInit();
groupOther.ResumeLayout(false); groupOther.ResumeLayout(false);
groupOther.PerformLayout(); groupOther.PerformLayout();
ResumeLayout(false); ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion
@@ -618,15 +654,11 @@ namespace GHelper
private RComboBox comboFNF4; private RComboBox comboFNF4;
private Label labelFNF4; private Label labelFNF4;
private GroupBox groupLight; private GroupBox groupLight;
private Label labelSpeed;
private RComboBox comboKeyboardSpeed;
private GroupBox groupOther; private GroupBox groupOther;
private CheckBox checkTopmost; private CheckBox checkTopmost;
private CheckBox checkKeyboardAuto; private CheckBox checkKeyboardAuto;
private CheckBox checkNoOverdrive; private CheckBox checkNoOverdrive;
private PictureBox pictureHelp; private PictureBox pictureHelp;
private TrackBar trackBrightness;
private Label labelBrightness;
private CheckBox checkUSBC; private CheckBox checkUSBC;
private TableLayoutPanel tableBacklight; private TableLayoutPanel tableBacklight;
private CheckBox checkShutdown; private CheckBox checkShutdown;
@@ -649,5 +681,12 @@ namespace GHelper
private CheckBox checkBootLogo; private CheckBox checkBootLogo;
private CheckBox checkSleepLogo; private CheckBox checkSleepLogo;
private CheckBox checkShutdownLogo; private CheckBox checkShutdownLogo;
private Panel panelBacklightExtra;
private Label labelBrightness;
private TrackBar trackBrightness;
private Label labelSpeed;
private RComboBox comboKeyboardSpeed;
private Panel panelXMG;
private CheckBox checkXMG;
} }
} }

View File

@@ -148,21 +148,20 @@ namespace GHelper
checkSleepBar.Visible = false; checkSleepBar.Visible = false;
checkShutdownBar.Visible = false; checkShutdownBar.Visible = false;
labelBacklightLid.Visible = false;
checkAwakeLid.Visible = false;
checkBootLid.Visible = false;
checkSleepLid.Visible = false;
checkShutdownLid.Visible = false;
if (!Program.config.ContainsModel("Z13")) if (!Program.config.ContainsModel("Z13"))
{ {
labelBacklightLid.Visible = false;
checkAwakeLid.Visible = false;
checkBootLid.Visible = false;
checkSleepLid.Visible = false;
checkShutdownLid.Visible = false;
labelBacklightLogo.Visible = false; labelBacklightLogo.Visible = false;
checkAwakeLogo.Visible = false; checkAwakeLogo.Visible = false;
checkBootLogo.Visible = false; checkBootLogo.Visible = false;
checkSleepLogo.Visible = false; checkSleepLogo.Visible = false;
checkShutdownLogo.Visible = false; checkShutdownLogo.Visible = false;
} }
} }
checkTopmost.Checked = (Program.config.getConfig("topmost") == 1); checkTopmost.Checked = (Program.config.getConfig("topmost") == 1);
@@ -183,6 +182,17 @@ namespace GHelper
pictureHelp.Click += PictureHelp_Click; pictureHelp.Click += PictureHelp_Click;
trackBrightness.Scroll += TrackBrightness_Scroll; trackBrightness.Scroll += TrackBrightness_Scroll;
panelXMG.Visible = (Program.wmi.DeviceGet(ASUSWmi.GPUXGConnected) == 1);
checkXMG.Checked = !(Program.config.getConfig("xmg_light") == 0);
checkXMG.CheckedChanged += CheckXMG_CheckedChanged;
}
private void CheckXMG_CheckedChanged(object? sender, EventArgs e)
{
Program.config.setConfig("xmg_light", (checkXMG.Checked ? 1 : 0));
Aura.ApplyXGMLight(checkXMG.Checked);
} }
private void CheckUSBC_CheckedChanged(object? sender, EventArgs e) private void CheckUSBC_CheckedChanged(object? sender, EventArgs e)

38
app/Fans.Designer.cs generated
View File

@@ -31,12 +31,12 @@ namespace GHelper
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
ChartArea chartArea4 = new ChartArea(); ChartArea chartArea1 = new ChartArea();
Title title4 = new Title(); Title title1 = new Title();
ChartArea chartArea5 = new ChartArea(); ChartArea chartArea2 = new ChartArea();
Title title5 = new Title(); Title title2 = new Title();
ChartArea chartArea6 = new ChartArea(); ChartArea chartArea3 = new ChartArea();
Title title6 = new Title(); Title title3 = new Title();
panelFans = new Panel(); panelFans = new Panel();
labelFansResult = new Label(); labelFansResult = new Label();
labelTip = new Label(); labelTip = new Label();
@@ -211,8 +211,8 @@ namespace GHelper
// //
// chartGPU // chartGPU
// //
chartArea4.Name = "ChartArea1"; chartArea1.Name = "ChartArea1";
chartGPU.ChartAreas.Add(chartArea4); chartGPU.ChartAreas.Add(chartArea1);
chartGPU.Dock = DockStyle.Fill; chartGPU.Dock = DockStyle.Fill;
chartGPU.Location = new Point(2, 350); chartGPU.Location = new Point(2, 350);
chartGPU.Margin = new Padding(2, 10, 2, 10); chartGPU.Margin = new Padding(2, 10, 2, 10);
@@ -220,13 +220,13 @@ namespace GHelper
chartGPU.Size = new Size(760, 320); chartGPU.Size = new Size(760, 320);
chartGPU.TabIndex = 17; chartGPU.TabIndex = 17;
chartGPU.Text = "chartGPU"; chartGPU.Text = "chartGPU";
title4.Name = "Title1"; title1.Name = "Title1";
chartGPU.Titles.Add(title4); chartGPU.Titles.Add(title1);
// //
// chartCPU // chartCPU
// //
chartArea5.Name = "ChartArea1"; chartArea2.Name = "ChartArea1";
chartCPU.ChartAreas.Add(chartArea5); chartCPU.ChartAreas.Add(chartArea2);
chartCPU.Dock = DockStyle.Fill; chartCPU.Dock = DockStyle.Fill;
chartCPU.Location = new Point(2, 10); chartCPU.Location = new Point(2, 10);
chartCPU.Margin = new Padding(2, 10, 2, 10); chartCPU.Margin = new Padding(2, 10, 2, 10);
@@ -234,13 +234,13 @@ namespace GHelper
chartCPU.Size = new Size(760, 320); chartCPU.Size = new Size(760, 320);
chartCPU.TabIndex = 14; chartCPU.TabIndex = 14;
chartCPU.Text = "chartCPU"; chartCPU.Text = "chartCPU";
title5.Name = "Title1"; title2.Name = "Title1";
chartCPU.Titles.Add(title5); chartCPU.Titles.Add(title2);
// //
// chartMid // chartMid
// //
chartArea6.Name = "ChartArea3"; chartArea3.Name = "ChartArea3";
chartMid.ChartAreas.Add(chartArea6); chartMid.ChartAreas.Add(chartArea3);
chartMid.Dock = DockStyle.Fill; chartMid.Dock = DockStyle.Fill;
chartMid.Location = new Point(2, 690); chartMid.Location = new Point(2, 690);
chartMid.Margin = new Padding(2, 10, 2, 10); chartMid.Margin = new Padding(2, 10, 2, 10);
@@ -248,8 +248,8 @@ namespace GHelper
chartMid.Size = new Size(760, 322); chartMid.Size = new Size(760, 322);
chartMid.TabIndex = 14; chartMid.TabIndex = 14;
chartMid.Text = "chartMid"; chartMid.Text = "chartMid";
title6.Name = "Title3"; title3.Name = "Title3";
chartMid.Titles.Add(title6); chartMid.Titles.Add(title3);
chartMid.Visible = false; chartMid.Visible = false;
// //
// labelFans // labelFans
@@ -352,7 +352,7 @@ namespace GHelper
labelInfo.Margin = new Padding(4, 0, 4, 0); labelInfo.Margin = new Padding(4, 0, 4, 0);
labelInfo.Name = "labelInfo"; labelInfo.Name = "labelInfo";
labelInfo.Padding = new Padding(5); labelInfo.Padding = new Padding(5);
labelInfo.Size = new Size(523, 92); labelInfo.Size = new Size(523, 149);
labelInfo.TabIndex = 43; labelInfo.TabIndex = 43;
labelInfo.Text = "Experimental Feature"; labelInfo.Text = "Experimental Feature";
// //

View File

@@ -97,9 +97,8 @@ namespace GHelper
trackGPUCore.MouseUp += TrackGPU_MouseUp; trackGPUCore.MouseUp += TrackGPU_MouseUp;
trackGPUMemory.MouseUp += TrackGPU_MouseUp; trackGPUMemory.MouseUp += TrackGPU_MouseUp;
trackGPUBoost.MouseUp += TrackGPU_MouseUp;
trackGPUBoost.MouseUp += TrackGPUBoost_MouseUp; trackGPUTemp.MouseUp += TrackGPU_MouseUp;
trackGPUTemp.MouseUp += TrackGPUBoost_MouseUp;
//labelInfo.MaximumSize = new Size(280, 0); //labelInfo.MaximumSize = new Size(280, 0);
labelInfo.Text = Properties.Strings.PPTExperimental; labelInfo.Text = Properties.Strings.PPTExperimental;
@@ -108,41 +107,22 @@ namespace GHelper
InitFans(); InitFans();
InitPower(); InitPower();
InitBoost(); InitBoost();
InitGPU();
comboBoost.SelectedValueChanged += ComboBoost_Changed; comboBoost.SelectedValueChanged += ComboBoost_Changed;
Shown += Fans_Shown; Shown += Fans_Shown;
InitGPUControl();
} }
private void TrackGPUBoost_MouseUp(object? sender, MouseEventArgs e)
{
Program.config.setConfig("gpu_boost", trackGPUBoost.Value);
Program.config.setConfig("gpu_temp", trackGPUTemp.Value);
Program.settingsForm.SetGPUPower();
}
private void TrackGPU_MouseUp(object? sender, MouseEventArgs e) private void TrackGPU_MouseUp(object? sender, MouseEventArgs e)
{ {
try Program.settingsForm.AutoGPUSettings(true);
{
Program.config.setConfig("gpu_core", trackGPUCore.Value);
Program.config.setConfig("gpu_memory", trackGPUMemory.Value);
int status = nvControl.SetClocks(trackGPUCore.Value, trackGPUMemory.Value);
if (status == -1) Program.RunAsAdmin("gpu");
}
catch (Exception ex)
{
Logger.WriteLine("F:" + ex.ToString());
}
InitGPUControl();
} }
private void InitGPUControl() public void InitGPU()
{ {
if (HardwareControl.GpuControl is not null && HardwareControl.GpuControl.IsNvidia) if (HardwareControl.GpuControl is not null && HardwareControl.GpuControl.IsNvidia)
{ {
@@ -164,8 +144,8 @@ namespace GHelper
trackGPUMemory.Value = Math.Max(Math.Min(memory, NvidiaGpuControl.MaxMemoryOffset), NvidiaGpuControl.MinMemoryOffset); trackGPUMemory.Value = Math.Max(Math.Min(memory, NvidiaGpuControl.MaxMemoryOffset), NvidiaGpuControl.MinMemoryOffset);
labelGPU.Text = gpuTitle; labelGPU.Text = gpuTitle;
int gpu_boost = Program.config.getConfig("gpu_boost"); int gpu_boost = Program.config.getConfigPerf("gpu_boost");
int gpu_temp = Program.config.getConfig("gpu_temp"); int gpu_temp = Program.config.getConfigPerf("gpu_temp");
if (gpu_boost < 0) gpu_boost = ASUSWmi.MaxGPUBoost; if (gpu_boost < 0) gpu_boost = ASUSWmi.MaxGPUBoost;
if (gpu_temp < 0) gpu_temp = ASUSWmi.MaxGPUTemp; if (gpu_temp < 0) gpu_temp = ASUSWmi.MaxGPUTemp;
@@ -198,15 +178,21 @@ namespace GHelper
private void trackGPU_Scroll(object? sender, EventArgs e) private void trackGPU_Scroll(object? sender, EventArgs e)
{ {
if (sender is null) return; if (sender is null) return;
TrackBar track = (TrackBar)sender; TrackBar track = (TrackBar)sender;
track.Value = (int)Math.Round((float)track.Value / 5) * 5; track.Value = (int)Math.Round((float)track.Value / 5) * 5;
Program.config.setConfigPerf("gpu_core", trackGPUCore.Value);
Program.config.setConfigPerf("gpu_memory", trackGPUMemory.Value);
VisualiseGPUSettings(); VisualiseGPUSettings();
} }
private void trackGPUPower_Scroll(object? sender, EventArgs e) private void trackGPUPower_Scroll(object? sender, EventArgs e)
{ {
Program.config.setConfigPerf("gpu_boost", trackGPUBoost.Value);
Program.config.setConfigPerf("gpu_temp", trackGPUTemp.Value);
VisualiseGPUSettings(); VisualiseGPUSettings();
} }
@@ -367,7 +353,7 @@ namespace GHelper
// Yes, that's stupid, but Total slider on 2021 model actually adjusts CPU PPT // Yes, that's stupid, but Total slider on 2021 model actually adjusts CPU PPT
if (!cpuBmode) if (!cpuBmode)
{ {
labelPlatform.Text = "CPU SPPT"; labelPlatform.Text = "CPU PPT";
} }
int limit_total; int limit_total;
@@ -506,20 +492,17 @@ namespace GHelper
checkApplyFans.Checked = false; checkApplyFans.Checked = false;
checkApplyPower.Checked = false; checkApplyPower.Checked = false;
/* Program.config.setConfigPerf("auto_apply", 0);
Program.config.setConfigPerf("auto_apply_power", 0);
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");
trackGPUCore.Value = 0; trackGPUCore.Value = 0;
trackGPUMemory.Value = 0; trackGPUMemory.Value = 0;
trackGPUBoost.Value = ASUSWmi.MaxGPUBoost; trackGPUBoost.Value = ASUSWmi.MaxGPUBoost;
trackGPUTemp.Value = ASUSWmi.MaxGPUTemp; trackGPUTemp.Value = ASUSWmi.MaxGPUTemp;
Program.config.setConfig("gpu_core", ASUSWmi.MaxGPUBoost); Program.settingsForm.AutoGPUSettings(true);
Program.config.setConfig("gpu_memory", ASUSWmi.MaxGPUTemp);
*/
Program.config.setConfigPerf("auto_apply", 0);
Program.config.setConfigPerf("auto_apply_power", 0);
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");
} }
private void ChartCPU_MouseUp(object? sender, MouseEventArgs e) private void ChartCPU_MouseUp(object? sender, MouseEventArgs e)

View File

@@ -4,6 +4,7 @@ using NvAPIWrapper.Native.GPU;
using NvAPIWrapper.Native.GPU.Structures; using NvAPIWrapper.Native.GPU.Structures;
using NvAPIWrapper.Native.Interfaces.GPU; using NvAPIWrapper.Native.Interfaces.GPU;
using System.Diagnostics; using System.Diagnostics;
using System.Management;
using static NvAPIWrapper.Native.GPU.Structures.PerformanceStates20InfoV1; using static NvAPIWrapper.Native.GPU.Structures.PerformanceStates20InfoV1;
namespace GHelper.Gpu; namespace GHelper.Gpu;
@@ -46,7 +47,6 @@ public class NvidiaGpuControl : IGpuControl
} }
public void GetClocks(out int core, out int memory, out string gpu) public void GetClocks(out int core, out int memory, out string gpu)
{ {
PhysicalGPU internalGpu = _internalGpu!; PhysicalGPU internalGpu = _internalGpu!;
@@ -86,7 +86,7 @@ public class NvidiaGpuControl : IGpuControl
var coreClock = new PerformanceStates20ClockEntryV1(PublicClockDomain.Graphics, new PerformanceStates20ParameterDelta(core * 1000)); var coreClock = new PerformanceStates20ClockEntryV1(PublicClockDomain.Graphics, new PerformanceStates20ParameterDelta(core * 1000));
var memoryClock = new PerformanceStates20ClockEntryV1(PublicClockDomain.Memory, new PerformanceStates20ParameterDelta(memory * 1000)); var memoryClock = new PerformanceStates20ClockEntryV1(PublicClockDomain.Memory, new PerformanceStates20ParameterDelta(memory * 1000));
PerformanceStates20ClockEntryV1[] clocks = { coreClock , memoryClock}; PerformanceStates20ClockEntryV1[] clocks = { coreClock, memoryClock };
PerformanceStates20BaseVoltageEntryV1[] voltages = { }; PerformanceStates20BaseVoltageEntryV1[] voltages = { };
PerformanceState20[] performanceStates = { new PerformanceState20(PerformanceStateId.P0_3DPerformance, clocks, voltages) }; PerformanceState20[] performanceStates = { new PerformanceState20(PerformanceStateId.P0_3DPerformance, clocks, voltages) };

View File

@@ -29,6 +29,8 @@ namespace GHelper
private static long lastAuto; private static long lastAuto;
private static long lastTheme; private static long lastTheme;
private static long lastAdmin;
private static PowerLineStatus isPlugged = PowerLineStatus.Unknown; private static PowerLineStatus isPlugged = PowerLineStatus.Unknown;
// The main entry point for the application // The main entry point for the application
@@ -62,7 +64,7 @@ namespace GHelper
} }
Logger.WriteLine("------------"); Logger.WriteLine("------------");
Logger.WriteLine("App launched: " + config.GetModel() + " :" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + (IsUserAdministrator()?"A":"N")); Logger.WriteLine("App launched: " + config.GetModel() + " :" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + (IsUserAdministrator()?"A":""));
Application.EnableVisualStyles(); Application.EnableVisualStyles();
@@ -292,7 +294,7 @@ namespace GHelper
if (action == "gpu") if (action == "gpu")
{ {
HardwareControl.GetNvidiaGpuControl()?.SetClocksFromConfig(); Startup.ReScheduleAdmin();
settingsForm.FansToggle(); settingsForm.FansToggle();
} }
} }
@@ -352,6 +354,10 @@ namespace GHelper
public static void RunAsAdmin(string? param = null) public static void RunAsAdmin(string? param = null)
{ {
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAdmin) < 2000) return;
lastAdmin = DateTimeOffset.Now.ToUnixTimeMilliseconds();
// Check if the current user is an administrator // Check if the current user is an administrator
if (!IsUserAdministrator()) if (!IsUserAdministrator())
{ {

View File

@@ -1,4 +1,5 @@
using CustomControls; using CustomControls;
using GHelper.Gpu;
using Starlight.AnimeMatrix; using Starlight.AnimeMatrix;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
@@ -7,6 +8,7 @@ using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text.Json; using System.Text.Json;
using System.Timers; using System.Timers;
using System.Windows.Forms;
using Tools; using Tools;
namespace GHelper namespace GHelper
@@ -140,7 +142,7 @@ namespace GHelper
int trim = model.LastIndexOf("_"); int trim = model.LastIndexOf("_");
if (trim > 0) model = model.Substring(0, trim); if (trim > 0) model = model.Substring(0, trim);
labelModel.Text = model; labelModel.Text = model+(Program.IsUserAdministrator()?".":"");
TopMost = Program.config.getConfig("topmost") == 1; TopMost = Program.config.getConfig("topmost") == 1;
@@ -946,7 +948,7 @@ namespace GHelper
SetGPUMode(ASUSWmi.GPUModeEco); SetGPUMode(ASUSWmi.GPUModeEco);
} }
public void RefreshSensors(bool force = false) public async void RefreshSensors(bool force = false)
{ {
if (!force && Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastRefresh) < 2000) return; if (!force && Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastRefresh) < 2000) return;
@@ -1043,11 +1045,14 @@ namespace GHelper
} }
public void SetGPUPower() public void AutoGPUSettings(bool launchAsAdmin = false)
{ {
int gpu_boost = Program.config.getConfig("gpu_boost"); int gpu_boost = Program.config.getConfigPerf("gpu_boost");
int gpu_temp = Program.config.getConfig("gpu_temp"); int gpu_temp = Program.config.getConfigPerf("gpu_temp");
int gpu_core = Program.config.getConfigPerf("gpu_core");
int gpu_memory = Program.config.getConfigPerf("gpu_memory");
if (gpu_boost < ASUSWmi.MinGPUBoost || gpu_boost > ASUSWmi.MaxGPUBoost ) return; if (gpu_boost < ASUSWmi.MinGPUBoost || gpu_boost > ASUSWmi.MaxGPUBoost ) return;
if (gpu_temp < ASUSWmi.MinGPUTemp || gpu_temp > ASUSWmi.MaxGPUTemp) return; if (gpu_temp < ASUSWmi.MinGPUTemp || gpu_temp > ASUSWmi.MaxGPUTemp) return;
@@ -1062,6 +1067,23 @@ namespace GHelper
Program.wmi.DeviceSet(ASUSWmi.PPT_GPUC2, gpu_temp, "PowerLimit C2"); Program.wmi.DeviceSet(ASUSWmi.PPT_GPUC2, gpu_temp, "PowerLimit C2");
} }
if (gpu_core == -1 && gpu_memory == -1) return;
if (HardwareControl.GpuControl is not null && HardwareControl.GpuControl.IsNvidia)
{
using NvidiaGpuControl nvControl = (NvidiaGpuControl)HardwareControl.GpuControl;
try
{
int status = nvControl.SetClocks(gpu_core, gpu_memory);
if (launchAsAdmin && status == -1) Program.RunAsAdmin("gpu");
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}
} }
protected void LabelFansResult(string text) protected void LabelFansResult(string text)
@@ -1136,14 +1158,12 @@ namespace GHelper
timer.Stop(); timer.Stop();
timer.Dispose(); timer.Dispose();
SetPower(); SetPower();
SetGPUPower();
}; };
timer.Start(); timer.Start();
} }
else else
{ {
SetPower(); SetPower();
SetGPUPower();
} }
} }
@@ -1201,8 +1221,10 @@ namespace GHelper
} }
AutoFans(); AutoFans();
AutoGPUSettings();
AutoPower(1000); AutoPower(1000);
if (Program.config.getConfigPerfString("scheme") is not null) if (Program.config.getConfigPerfString("scheme") is not null)
NativeMethods.SetPowerScheme(Program.config.getConfigPerfString("scheme")); NativeMethods.SetPowerScheme(Program.config.getConfigPerfString("scheme"));
else else
@@ -1223,6 +1245,7 @@ namespace GHelper
fans.InitFans(); fans.InitFans();
fans.InitPower(); fans.InitPower();
fans.InitBoost(); fans.InitBoost();
fans.InitGPU();
} }
} }
@@ -1425,10 +1448,10 @@ namespace GHelper
labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUChanging + " ..."; labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUChanging + " ...";
Thread t = new Thread(() =>
{
Thread.CurrentThread.IsBackground = true;
Task.Run(async () =>
{
if (eco == 1) if (eco == 1)
{ {
string[] tokill = { "EADesktop", "RadeonSoftware" }; string[] tokill = { "EADesktop", "RadeonSoftware" };
@@ -1438,18 +1461,18 @@ namespace GHelper
Program.wmi.SetGPUEco(eco); Program.wmi.SetGPUEco(eco);
if (eco == 0) await Task.Delay(TimeSpan.FromSeconds(1));
HardwareControl.RecreateGpuControlWithDelay();
Program.settingsForm.BeginInvoke(delegate Program.settingsForm.BeginInvoke(delegate
{ {
Thread.Sleep(500);
InitGPUMode(); InitGPUMode();
AutoScreen(); AutoScreen();
}); });
if (eco == 0)
HardwareControl.RecreateGpuControlWithDelay();
}); });
t.Start();
} }

View File

@@ -14,6 +14,15 @@ public class Startup
return (taskService.RootFolder.AllTasks.Any(t => t.Name == taskName)); return (taskService.RootFolder.AllTasks.Any(t => t.Name == taskName));
} }
public static void ReScheduleAdmin()
{
if (Program.IsUserAdministrator() && IsScheduled())
{
UnSchedule();
Schedule();
}
}
public static void Schedule() public static void Schedule()
{ {