Compare commits

...

10 Commits
v0.39 ... v0.40

Author SHA1 Message Date
seerge
583cb677d0 Added option to disable screen overdrive 2023-03-27 15:21:52 +02:00
seerge
1888fe7bd9 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-27 14:28:31 +02:00
seerge
089b339e61 Minor tweaks 2023-03-27 14:28:28 +02:00
Serge
cab4a04339 Update README.md 2023-03-27 13:02:14 +02:00
seerge
7ab3b450cd Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-26 19:31:43 +02:00
seerge
ea2dc7b75d Animatrix tweaks 2023-03-26 19:31:41 +02:00
Serge
ccd69a8628 Update README.md 2023-03-26 14:40:12 +02:00
Serge
c1d23159a0 Update debloat.bat 2023-03-26 14:17:53 +02:00
Serge
1c865624e6 Update debloat.bat 2023-03-26 14:06:13 +02:00
seerge
4853c09c2c Added model name, and custom fan+ in profile names 2023-03-25 20:28:27 +01:00
13 changed files with 335 additions and 171 deletions

View File

@@ -1,6 +1,4 @@
using GHelper; using System.Management;
using System.Diagnostics;
using System.Management;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
public class ASUSWmi public class ASUSWmi
@@ -12,6 +10,10 @@ public class ASUSWmi
const uint DSTS = 0x53545344; const uint DSTS = 0x53545344;
const uint DEVS = 0x53564544; const uint DEVS = 0x53564544;
public const uint UniversalControl = 0x00100021;
public const int KB_Light_Up = 0xc4;
public const int KB_Light_Down = 0xc5;
public const uint CPU_Fan = 0x00110013; public const uint CPU_Fan = 0x00110013;
public const uint GPU_Fan = 0x00110014; public const uint GPU_Fan = 0x00110014;
public const uint Mid_Fan = 0x00110031; public const uint Mid_Fan = 0x00110031;
@@ -231,7 +233,7 @@ public class ASUSWmi
return DeviceGetBuffer(DevsGPUFanCurve, fan_mode); return DeviceGetBuffer(DevsGPUFanCurve, fan_mode);
case 2: case 2:
return DeviceGetBuffer(DevsMidFanCurve, fan_mode); return DeviceGetBuffer(DevsMidFanCurve, fan_mode);
default: default:
return DeviceGetBuffer(DevsCPUFanCurve, fan_mode); return DeviceGetBuffer(DevsCPUFanCurve, fan_mode);
} }
@@ -253,28 +255,22 @@ public class ASUSWmi
} }
const int ASUS_WMI_KEYBOARD_POWER_BOOT = 0x03 << 16;
const int ASUS_WMI_KEYBOARD_POWER_AWAKE = 0x0C << 16;
const int ASUS_WMI_KEYBOARD_POWER_SLEEP = 0x30 << 16;
const int ASUS_WMI_KEYBOARD_POWER_SHUTDOWN = 0xC0 << 16;
public void TUFKeyboardPower(bool awake = true, bool boot = false, bool sleep = false, bool shutdown = false) public void TUFKeyboardPower(bool awake = true, bool boot = false, bool sleep = false, bool shutdown = false)
{ {
uint flags; int state = 0xbd;
uint cmd = 1;
flags = 0; if (boot) state = state | ASUS_WMI_KEYBOARD_POWER_BOOT;
if (boot) if (awake) state = state | ASUS_WMI_KEYBOARD_POWER_AWAKE;
flags |= (1 << 1); if (sleep) state = state | ASUS_WMI_KEYBOARD_POWER_SLEEP;
if (awake) if (shutdown) state = state | ASUS_WMI_KEYBOARD_POWER_SHUTDOWN;
flags |= (1 << 3);
if (sleep)
flags |= (1 << 5);
if (shutdown)
flags |= (1 << 7);
byte[] state = new byte[12]; state = state | 0x01 << 8;
state[0] = 0xbd;
state[1] = (byte)((cmd != 0) ? (1 << 2) : 0);
state[2] = (byte)flags;
DeviceSet(TUF_KB, state); DeviceSet(TUF_KB_STATE, state);
Debug.WriteLine(BitConverter.ToString(state));
} }
public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler) public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler)

View File

@@ -1,6 +1,7 @@
// Source thanks to https://github.com/vddCore/Starlight with some adjustments from me // Source thanks to https://github.com/vddCore/Starlight with some adjustments from me
using Starlight.Communication; using Starlight.Communication;
using System.Diagnostics;
using System.Management; using System.Management;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text; using System.Text;
@@ -86,6 +87,7 @@ namespace Starlight.AnimeMatrix
//public int FullRows = 11; //public int FullRows = 11;
//public int FullEvenRows = -1; //public int FullEvenRows = -1;
public int dx = 0;
public int MaxColumns = 34; public int MaxColumns = 34;
private int frameIndex = 0; private int frameIndex = 0;
@@ -102,6 +104,7 @@ namespace Starlight.AnimeMatrix
_model = AnimeType.GA401; _model = AnimeType.GA401;
MaxColumns = 33; MaxColumns = 33;
dx = 0;
//FullRows = 7; //FullRows = 7;
//FullEvenRows = 3; //FullEvenRows = 3;
@@ -211,7 +214,7 @@ namespace Starlight.AnimeMatrix
return 33; return 33;
case 1: case 1:
case 3: case 3:
return 35; // Some rows are padded return 35;
default: default:
return 36 - y / 2; return 36 - y / 2;
} }
@@ -257,7 +260,8 @@ namespace Starlight.AnimeMatrix
if (x >= FirstX(y) && x < Width(y)) if (x >= FirstX(y) && x < Width(y))
{ {
SetLedLinear(RowToLinearAddress(y) - FirstX(y) + x, value); SetLedLinear(RowToLinearAddress(y) - FirstX(y) + x + dx, value);
//Debug.Write((RowToLinearAddress(y) - FirstX(y) + x + dx).ToString() + " ");
} }
} }
@@ -355,7 +359,7 @@ namespace Starlight.AnimeMatrix
public void PresentText(string text, float fontSize = 8F) public void PresentText(string text, float fontSize = 8.5F)
{ {
using (Bitmap bmp = new Bitmap(MaxColumns * 3, MaxRows)) using (Bitmap bmp = new Bitmap(MaxColumns * 3, MaxRows))
{ {
@@ -374,55 +378,55 @@ namespace Starlight.AnimeMatrix
g.DrawString(text, font, Brushes.White, -textSize.Width/2, -textSize.Height / 2); g.DrawString(text, font, Brushes.White, -textSize.Width/2, -textSize.Height / 2);
*/ */
g.DrawString(text, font, Brushes.White, 12, -2); g.DrawString(text, font, Brushes.White, 5, -2);
} }
} }
GenerateFrame(bmp); GenerateFrame(bmp, System.Drawing.Drawing2D.InterpolationMode.Bicubic);
Present(); Present();
} }
} }
public void GenerateFrame(Image image) public void GenerateFrame(Image image, System.Drawing.Drawing2D.InterpolationMode interpolation = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic)
{ {
int width = MaxColumns * 3; int width = MaxColumns * 3;
int height = MaxRows; int height = MaxRows;
int targetWidth = MaxColumns * 2;
float scale; float scale;
using (Bitmap canvas = new Bitmap(width, height)) using (Bitmap bmp = new Bitmap(targetWidth, height))
{ {
scale = Math.Min((float)width / (float)image.Width, (float)height / (float)image.Height); scale = Math.Min((float)width / (float)image.Width, (float)height / (float)image.Height);
using (var graph = Graphics.FromImage(canvas)) using (var graph = Graphics.FromImage(bmp))
{ {
var scaleWidth = (int)(image.Width * scale); var scaleWidth = (float)(image.Width * scale);
var scaleHeight = (int)(image.Height * scale); var scaleHeight = (float)(image.Height * scale);
graph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; graph.InterpolationMode = interpolation;
graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
graph.DrawImage(image, ((int)width - scaleWidth), 0, scaleWidth, scaleHeight); graph.DrawImage(image, (float)Math.Round(targetWidth - scaleWidth * targetWidth / width), 0, (float)Math.Round(scaleWidth * targetWidth / width), scaleHeight);
} }
using (Bitmap bmp = new Bitmap(canvas, MaxColumns * 2, MaxRows)) for (int y = 0; y < bmp.Height; y++)
{ {
for (int y = 0; y < bmp.Height; y++) for (int x = 0; x < bmp.Width; x++)
{ if (x % 2 == y % 2)
for (int x = 0; x < bmp.Width; x++) {
if (x % 2 == y % 2) var pixel = bmp.GetPixel(x, y);
{ var color = (pixel.R + pixel.G + pixel.B) / 3;
var pixel = bmp.GetPixel(x, y); if (color < 10) color = 0;
SetLedPlanar(x / 2, y, (byte)((pixel.R + pixel.G + pixel.B) / 3)); SetLedPlanar(x / 2, y, (byte)color);
} }
}
} }
} }
} }
private void EnsureRowInRange(int row) private void EnsureRowInRange(int row)

View File

@@ -40,8 +40,7 @@ public class AppConfig
} }
public string GetModel()
public bool ContainsModel(string contains)
{ {
if (_model is null) if (_model is null)
{ {
@@ -56,6 +55,12 @@ public class AppConfig
} }
} }
return _model;
}
public bool ContainsModel(string contains)
{
GetModel();
return (_model is not null && _model.Contains(contains)); return (_model is not null && _model.Contains(contains));
} }

View File

@@ -1,7 +1,5 @@
using HidLibrary; using HidLibrary;
using Microsoft.VisualBasic.ApplicationServices;
using System.Diagnostics; using System.Diagnostics;
using static Starlight.AnimeMatrix.BuiltInAnimation;
namespace GHelper namespace GHelper
{ {
@@ -36,7 +34,7 @@ namespace GHelper
{ {
a |= (uint)n; a |= (uint)n;
} }
return new byte[] {0x5d, 0xbd, 0x01, (byte)(a & 0xff), (byte)((a & 0xff00) >> 8), (byte)((a & 0xff0000) >> 16) }; return new byte[] { 0x5d, 0xbd, 0x01, (byte)(a & 0xff), (byte)((a & 0xff00) >> 8), (byte)((a & 0xff0000) >> 16) };
} }
public static ushort BitOr(this AuraDev19b6 self, AuraDev19b6 rhs) public static ushort BitOr(this AuraDev19b6 self, AuraDev19b6 rhs)
@@ -56,6 +54,7 @@ namespace GHelper
static byte[] MESSAGE_SET = { 0x5d, 0xb5, 0, 0, 0 }; static byte[] MESSAGE_SET = { 0x5d, 0xb5, 0, 0, 0 };
static byte[] MESSAGE_APPLY = { 0x5d, 0xb4 }; static byte[] MESSAGE_APPLY = { 0x5d, 0xb4 };
static int[] deviceIds = { 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0 };
private static int mode = 0; private static int mode = 0;
private static int speed = 1; private static int speed = 1;
@@ -92,7 +91,7 @@ namespace GHelper
{ {
if (GetModes().ContainsKey(value)) if (GetModes().ContainsKey(value))
mode = value; mode = value;
else else
mode = 0; mode = 0;
} }
} }
@@ -145,6 +144,22 @@ namespace GHelper
} }
public static void ApplyBrightness(int brightness)
{
HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
byte[] msg = { 0x5a, 0xba, 0xc5, 0xc4, (byte)brightness };
foreach (HidDevice device in HidDeviceList)
if (device.IsConnected && device.Description.Contains("HID"))
{
device.OpenDevice();
device.Write(msg);
device.CloseDevice();
}
}
public static void ApplyAuraPower(bool awake = true, bool boot = false, bool sleep = false, bool shutdown = false) public static void ApplyAuraPower(bool awake = true, bool boot = false, bool sleep = false, bool shutdown = false)
{ {
@@ -158,7 +173,7 @@ namespace GHelper
if (shutdown) flags.Add(AuraDev19b6.ShutdownKeyb); if (shutdown) flags.Add(AuraDev19b6.ShutdownKeyb);
byte[] msg = AuraDev19b6Extensions.ToBytes(flags.ToArray()); byte[] msg = AuraDev19b6Extensions.ToBytes(flags.ToArray());
Debug.WriteLine(BitConverter.ToString(msg)); Debug.WriteLine(BitConverter.ToString(msg));
foreach (HidDevice device in HidDeviceList) foreach (HidDevice device in HidDeviceList)
@@ -176,10 +191,7 @@ namespace GHelper
public static void ApplyAura() public static void ApplyAura()
{ {
HidDevice[] HidDeviceList; HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
int[] deviceIds = { 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0 };
HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
int _speed; int _speed;

View File

@@ -16,7 +16,7 @@
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly> <ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.39</AssemblyVersion> <AssemblyVersion>0.40</AssemblyVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

163
app/Keyboard.Designer.cs generated
View File

@@ -41,14 +41,19 @@ namespace GHelper
comboM3 = new RComboBox(); comboM3 = new RComboBox();
labelM3 = new Label(); labelM3 = new Label();
groupLight = new GroupBox(); groupLight = new GroupBox();
checkAwake = new CheckBox();
checkBoot = new CheckBox();
checkSleep = new CheckBox();
checkShutdown = new CheckBox();
comboKeyboardSpeed = new RComboBox();
labelSpeed = new Label(); labelSpeed = new Label();
comboKeyboardSpeed = new RComboBox();
checkShutdown = new CheckBox();
checkSleep = new CheckBox();
checkBoot = new CheckBox();
checkAwake = new CheckBox();
groupOther = new GroupBox();
checkKeyboardAuto = new CheckBox();
checkTopmost = new CheckBox();
checkNoOverdrive = new CheckBox();
groupBox1.SuspendLayout(); groupBox1.SuspendLayout();
groupLight.SuspendLayout(); groupLight.SuspendLayout();
groupOther.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
// groupBox1 // groupBox1
@@ -65,7 +70,7 @@ namespace GHelper
groupBox1.Dock = DockStyle.Top; groupBox1.Dock = DockStyle.Top;
groupBox1.Location = new Point(10, 10); groupBox1.Location = new Point(10, 10);
groupBox1.Name = "groupBox1"; groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(751, 242); groupBox1.Size = new Size(756, 242);
groupBox1.TabIndex = 0; groupBox1.TabIndex = 0;
groupBox1.TabStop = false; groupBox1.TabStop = false;
groupBox1.Text = "Key Bindings"; groupBox1.Text = "Key Bindings";
@@ -158,50 +163,19 @@ namespace GHelper
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(751, 304); groupLight.Size = new Size(756, 304);
groupLight.TabIndex = 1; groupLight.TabIndex = 1;
groupLight.TabStop = false; groupLight.TabStop = false;
groupLight.Text = "Keyboard Backlight"; groupLight.Text = "Keyboard Backlight";
// //
// checkAwake // labelSpeed
// //
checkAwake.AutoSize = true; labelSpeed.AutoSize = true;
checkAwake.Location = new Point(25, 59); labelSpeed.Location = new Point(25, 237);
checkAwake.Name = "checkAwake"; labelSpeed.Name = "labelSpeed";
checkAwake.Size = new Size(115, 36); labelSpeed.Size = new Size(198, 32);
checkAwake.TabIndex = 0; labelSpeed.TabIndex = 40;
checkAwake.Text = "Awake"; labelSpeed.Text = "Animation Speed";
checkAwake.UseVisualStyleBackColor = true;
//
// checkBoot
//
checkBoot.AutoSize = true;
checkBoot.Location = new Point(25, 101);
checkBoot.Name = "checkBoot";
checkBoot.Size = new Size(96, 36);
checkBoot.TabIndex = 1;
checkBoot.Text = "Boot";
checkBoot.UseVisualStyleBackColor = true;
//
// checkSleep
//
checkSleep.AutoSize = true;
checkSleep.Location = new Point(25, 143);
checkSleep.Name = "checkSleep";
checkSleep.Size = new Size(105, 36);
checkSleep.TabIndex = 2;
checkSleep.Text = "Sleep";
checkSleep.UseVisualStyleBackColor = true;
//
// checkShutdown
//
checkShutdown.AutoSize = true;
checkShutdown.Location = new Point(25, 185);
checkShutdown.Name = "checkShutdown";
checkShutdown.Size = new Size(154, 36);
checkShutdown.TabIndex = 3;
checkShutdown.Text = "Shutdown";
checkShutdown.UseVisualStyleBackColor = true;
// //
// comboKeyboardSpeed // comboKeyboardSpeed
// //
@@ -219,20 +193,95 @@ namespace GHelper
comboKeyboardSpeed.TabIndex = 39; comboKeyboardSpeed.TabIndex = 39;
comboKeyboardSpeed.TabStop = false; comboKeyboardSpeed.TabStop = false;
// //
// labelSpeed // checkShutdown
// //
labelSpeed.AutoSize = true; checkShutdown.AutoSize = true;
labelSpeed.Location = new Point(25, 237); checkShutdown.Location = new Point(25, 185);
labelSpeed.Name = "labelSpeed"; checkShutdown.Name = "checkShutdown";
labelSpeed.Size = new Size(198, 32); checkShutdown.Size = new Size(154, 36);
labelSpeed.TabIndex = 40; checkShutdown.TabIndex = 3;
labelSpeed.Text = "Animation Speed"; checkShutdown.Text = "Shutdown";
checkShutdown.UseVisualStyleBackColor = true;
//
// checkSleep
//
checkSleep.AutoSize = true;
checkSleep.Location = new Point(25, 143);
checkSleep.Name = "checkSleep";
checkSleep.Size = new Size(105, 36);
checkSleep.TabIndex = 2;
checkSleep.Text = "Sleep";
checkSleep.UseVisualStyleBackColor = true;
//
// checkBoot
//
checkBoot.AutoSize = true;
checkBoot.Location = new Point(25, 101);
checkBoot.Name = "checkBoot";
checkBoot.Size = new Size(96, 36);
checkBoot.TabIndex = 1;
checkBoot.Text = "Boot";
checkBoot.UseVisualStyleBackColor = true;
//
// checkAwake
//
checkAwake.AutoSize = true;
checkAwake.Location = new Point(25, 59);
checkAwake.Name = "checkAwake";
checkAwake.Size = new Size(115, 36);
checkAwake.TabIndex = 0;
checkAwake.Text = "Awake";
checkAwake.UseVisualStyleBackColor = true;
//
// groupOther
//
groupOther.Controls.Add(checkNoOverdrive);
groupOther.Controls.Add(checkKeyboardAuto);
groupOther.Controls.Add(checkTopmost);
groupOther.Dock = DockStyle.Top;
groupOther.Location = new Point(10, 556);
groupOther.Name = "groupOther";
groupOther.Size = new Size(756, 225);
groupOther.TabIndex = 2;
groupOther.TabStop = false;
groupOther.Text = "Other";
//
// checkKeyboardAuto
//
checkKeyboardAuto.AutoSize = true;
checkKeyboardAuto.Location = new Point(25, 51);
checkKeyboardAuto.Name = "checkKeyboardAuto";
checkKeyboardAuto.Size = new Size(712, 36);
checkKeyboardAuto.TabIndex = 2;
checkKeyboardAuto.Text = "Lower backlight brightness on battery and back when plugged";
checkKeyboardAuto.UseVisualStyleBackColor = true;
//
// checkTopmost
//
checkTopmost.AutoSize = true;
checkTopmost.Location = new Point(25, 104);
checkTopmost.Name = "checkTopmost";
checkTopmost.Size = new Size(390, 36);
checkTopmost.TabIndex = 1;
checkTopmost.Text = "Keep app window always on top";
checkTopmost.UseVisualStyleBackColor = true;
//
// checkNoOverdrive
//
checkNoOverdrive.AutoSize = true;
checkNoOverdrive.Location = new Point(25, 156);
checkNoOverdrive.Name = "checkNoOverdrive";
checkNoOverdrive.Size = new Size(307, 36);
checkNoOverdrive.TabIndex = 3;
checkNoOverdrive.Text = "Disable screen overdrive";
checkNoOverdrive.UseVisualStyleBackColor = true;
// //
// Keyboard // Keyboard
// //
AutoScaleDimensions = new SizeF(13F, 32F); AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(771, 858); ClientSize = new Size(776, 858);
Controls.Add(groupOther);
Controls.Add(groupLight); Controls.Add(groupLight);
Controls.Add(groupBox1); Controls.Add(groupBox1);
FormBorderStyle = FormBorderStyle.FixedSingle; FormBorderStyle = FormBorderStyle.FixedSingle;
@@ -243,11 +292,13 @@ namespace GHelper
Padding = new Padding(10); Padding = new Padding(10);
ShowIcon = false; ShowIcon = false;
ShowInTaskbar = false; ShowInTaskbar = false;
Text = "Keyboard"; Text = "Extra Settings";
groupBox1.ResumeLayout(false); groupBox1.ResumeLayout(false);
groupBox1.PerformLayout(); groupBox1.PerformLayout();
groupLight.ResumeLayout(false); groupLight.ResumeLayout(false);
groupLight.PerformLayout(); groupLight.PerformLayout();
groupOther.ResumeLayout(false);
groupOther.PerformLayout();
ResumeLayout(false); ResumeLayout(false);
} }
@@ -270,5 +321,9 @@ namespace GHelper
private CheckBox checkShutdown; private CheckBox checkShutdown;
private Label labelSpeed; private Label labelSpeed;
private RComboBox comboKeyboardSpeed; private RComboBox comboKeyboardSpeed;
private GroupBox groupOther;
private CheckBox checkTopmost;
private CheckBox checkKeyboardAuto;
private CheckBox checkNoOverdrive;
} }
} }

View File

@@ -78,8 +78,33 @@ namespace GHelper
checkSleep.CheckedChanged += CheckPower_CheckedChanged; checkSleep.CheckedChanged += CheckPower_CheckedChanged;
checkShutdown.CheckedChanged += CheckPower_CheckedChanged; checkShutdown.CheckedChanged += CheckPower_CheckedChanged;
checkTopmost.Checked = (Program.config.getConfig("topmost") == 1);
checkTopmost.CheckedChanged += CheckTopmost_CheckedChanged; ;
checkKeyboardAuto.Checked = (Program.config.getConfig("keyboard_auto") == 1);
checkKeyboardAuto.CheckedChanged += CheckKeyboardAuto_CheckedChanged;
checkNoOverdrive.Checked = (Program.config.getConfig("no_overdrive") == 1);
checkNoOverdrive.CheckedChanged += CheckNoOverdrive_CheckedChanged;
} }
private void CheckNoOverdrive_CheckedChanged(object? sender, EventArgs e)
{
Program.config.setConfig("no_overdrive", (checkNoOverdrive.Checked ? 1 : 0));
Program.settingsForm.AutoScreen(true);
}
private void CheckKeyboardAuto_CheckedChanged(object? sender, EventArgs e)
{
Program.config.setConfig("keyboard_auto", (checkKeyboardAuto.Checked ? 1 : 0));
}
private void CheckTopmost_CheckedChanged(object? sender, EventArgs e)
{
Program.config.setConfig("topmost", (checkTopmost.Checked ? 1 : 0));
Program.settingsForm.TopMost = checkTopmost.Checked;
}
private void CheckPower_CheckedChanged(object? sender, EventArgs e) private void CheckPower_CheckedChanged(object? sender, EventArgs e)
{ {

View File

@@ -588,7 +588,7 @@ public class NativeMethods
return laptopScreen; return laptopScreen;
} }
public static int GetRefreshRate() public static int GetRefreshRate(bool max = false)
{ {
DEVMODE dm = CreateDevmode(); DEVMODE dm = CreateDevmode();
@@ -598,11 +598,23 @@ public class NativeMethods
if (laptopScreen is null) if (laptopScreen is null)
return -1; return -1;
if (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm)) if (max)
{ {
frequency = dm.dmDisplayFrequency; int i = 0;
while (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen, i, ref dm))
{
if (dm.dmDisplayFrequency > frequency) frequency = dm.dmDisplayFrequency;
i++;
}
} else
{
if (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm))
{
frequency = dm.dmDisplayFrequency;
}
} }
return frequency; return frequency;
} }

View File

@@ -32,6 +32,15 @@ namespace GHelper
// The main entry point for the application // The main entry point for the application
public static void Main() public static void Main()
{ {
if (Process.GetProcesses().Count(p => p.ProcessName == "GHelper") > 1)
{
MessageBox.Show("G-Helper is already running. Check system tray for an icon.", "App already running", MessageBoxButtons.OK);
Application.Exit();
return;
}
try try
{ {
wmi = new ASUSWmi(); wmi = new ASUSWmi();
@@ -111,27 +120,22 @@ namespace GHelper
public static void SetAutoModes(bool wait = false) public static void SetAutoModes()
{ {
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 2000) return; if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 2000) return;
lastAuto = DateTimeOffset.Now.ToUnixTimeMilliseconds(); lastAuto = DateTimeOffset.Now.ToUnixTimeMilliseconds();
isPlugged = SystemInformation.PowerStatus.PowerLineStatus; isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
Logger.WriteLine("AutoSetting for " + isPlugged.ToString()); Logger.WriteLine("AutoSetting for " + isPlugged.ToString());
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit")); settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
settingsForm.AutoPerformance();
settingsForm.AutoPerformance(isPlugged); bool switched = settingsForm.AutoGPUMode();
if (!switched) settingsForm.AutoScreen();
// waiting a bit before turning off dGPU settingsForm.SetMatrix();
// if (wait && isPlugged != PowerLineStatus.Online) Thread.Sleep(3000);
bool switched = settingsForm.AutoGPUMode(isPlugged);
if (!switched) settingsForm.AutoScreen(isPlugged);
settingsForm.SetMatrix(isPlugged);
} }
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e) private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
@@ -139,7 +143,8 @@ namespace GHelper
if (SystemInformation.PowerStatus.PowerLineStatus == isPlugged) return; if (SystemInformation.PowerStatus.PowerLineStatus == isPlugged) return;
Logger.WriteLine("Windows - Power Mode Changed"); Logger.WriteLine("Windows - Power Mode Changed");
SetAutoModes(true); settingsForm.AutoKeyboard();
SetAutoModes();
} }

View File

@@ -40,6 +40,7 @@ namespace GHelper
pictureMatrix = new PictureBox(); pictureMatrix = new PictureBox();
labelMatrix = new Label(); labelMatrix = new Label();
panelBattery = new Panel(); panelBattery = new Panel();
labelModel = new Label();
labelVersion = new Label(); labelVersion = new Label();
labelBattery = new Label(); labelBattery = new Label();
pictureBattery = new PictureBox(); pictureBattery = new PictureBox();
@@ -236,6 +237,7 @@ namespace GHelper
// //
panelBattery.AutoSize = true; panelBattery.AutoSize = true;
panelBattery.AutoSizeMode = AutoSizeMode.GrowAndShrink; panelBattery.AutoSizeMode = AutoSizeMode.GrowAndShrink;
panelBattery.Controls.Add(labelModel);
panelBattery.Controls.Add(labelVersion); panelBattery.Controls.Add(labelVersion);
panelBattery.Controls.Add(labelBattery); panelBattery.Controls.Add(labelBattery);
panelBattery.Controls.Add(pictureBattery); panelBattery.Controls.Add(pictureBattery);
@@ -246,15 +248,27 @@ namespace GHelper
panelBattery.Margin = new Padding(8); panelBattery.Margin = new Padding(8);
panelBattery.Name = "panelBattery"; panelBattery.Name = "panelBattery";
panelBattery.Padding = new Padding(0, 0, 0, 12); panelBattery.Padding = new Padding(0, 0, 0, 12);
panelBattery.Size = new Size(810, 158); panelBattery.Size = new Size(810, 163);
panelBattery.TabIndex = 34; panelBattery.TabIndex = 34;
// //
// labelModel
//
labelModel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
labelModel.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
labelModel.ForeColor = SystemColors.ControlDark;
labelModel.Location = new Point(291, 119);
labelModel.Margin = new Padding(8, 0, 8, 0);
labelModel.Name = "labelModel";
labelModel.Size = new Size(492, 32);
labelModel.TabIndex = 38;
labelModel.TextAlign = ContentAlignment.TopRight;
//
// labelVersion // labelVersion
// //
labelVersion.AutoSize = true; labelVersion.AutoSize = true;
labelVersion.Font = new Font("Segoe UI", 9F, FontStyle.Underline, GraphicsUnit.Point); labelVersion.Font = new Font("Segoe UI", 9F, FontStyle.Underline, GraphicsUnit.Point);
labelVersion.ForeColor = SystemColors.ControlDark; labelVersion.ForeColor = SystemColors.ControlDark;
labelVersion.Location = new Point(25, 109); labelVersion.Location = new Point(25, 119);
labelVersion.Margin = new Padding(8, 0, 8, 0); labelVersion.Margin = new Padding(8, 0, 8, 0);
labelVersion.Name = "labelVersion"; labelVersion.Name = "labelVersion";
labelVersion.Size = new Size(44, 32); labelVersion.Size = new Size(44, 32);
@@ -316,7 +330,7 @@ namespace GHelper
panelFooter.Controls.Add(buttonQuit); panelFooter.Controls.Add(buttonQuit);
panelFooter.Controls.Add(checkStartup); panelFooter.Controls.Add(checkStartup);
panelFooter.Dock = DockStyle.Top; panelFooter.Dock = DockStyle.Top;
panelFooter.Location = new Point(10, 1084); panelFooter.Location = new Point(10, 1089);
panelFooter.Margin = new Padding(8); panelFooter.Margin = new Padding(8);
panelFooter.Name = "panelFooter"; panelFooter.Name = "panelFooter";
panelFooter.Padding = new Padding(0, 0, 0, 10); panelFooter.Padding = new Padding(0, 0, 0, 10);
@@ -1103,5 +1117,6 @@ namespace GHelper
private RButton buttonKeyboardColor; private RButton buttonKeyboardColor;
private RButton buttonFans; private RButton buttonFans;
private Label labelMidFan; private Label labelMidFan;
private Label labelModel;
} }
} }

View File

@@ -2,6 +2,7 @@
using Starlight.AnimeMatrix; using Starlight.AnimeMatrix;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Text.Json; using System.Text.Json;
using System.Timers; using System.Timers;
@@ -121,18 +122,27 @@ namespace GHelper
aTimer = new System.Timers.Timer(500); aTimer = new System.Timers.Timer(500);
aTimer.Elapsed += OnTimedEvent; aTimer.Elapsed += OnTimedEvent;
SetVersionLabel("Version: " + Assembly.GetExecutingAssembly().GetName().Version);
Thread t = new Thread(() =>
{
CheckForUpdatesAsync();
});
t.Start();
t.Join();
// Subscribing for monitor power on events // Subscribing for monitor power on events
var settingGuid = new NativeMethods.PowerSettingGuid(); var settingGuid = new NativeMethods.PowerSettingGuid();
Program.unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(Handle, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE); Program.unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(Handle, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE);
SetVersionLabel("Version: " + Assembly.GetExecutingAssembly().GetName().Version);
string model = Program.config.GetModel();
int trim = model.LastIndexOf("_");
if (trim > 0) model = model.Substring(0, trim);
labelModel.Text = model;
this.TopMost = Program.config.getConfig("topmost") == 1;
Task.Run(async () =>
{
await Task.Delay(TimeSpan.FromSeconds(5));
CheckForUpdatesAsync();
});
} }
@@ -156,8 +166,6 @@ namespace GHelper
var tag = config.GetProperty("tag_name").ToString().Replace("v", ""); var tag = config.GetProperty("tag_name").ToString().Replace("v", "");
var url = config.GetProperty("assets")[0].GetProperty("browser_download_url").ToString(); var url = config.GetProperty("assets")[0].GetProperty("browser_download_url").ToString();
Thread.Sleep(5000);
var gitVersion = new Version(tag); var gitVersion = new Version(tag);
var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString()); var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString());
@@ -196,7 +204,7 @@ namespace GHelper
private void Button120Hz_MouseHover(object? sender, EventArgs e) private void Button120Hz_MouseHover(object? sender, EventArgs e)
{ {
labelTipScreen.Text = "Max refresh rate + screen overdrive for lower latency"; labelTipScreen.Text = "Max refresh rate for lower latency";
} }
private void Button60Hz_MouseHover(object? sender, EventArgs e) private void Button60Hz_MouseHover(object? sender, EventArgs e)
@@ -244,14 +252,14 @@ namespace GHelper
{ {
Program.config.setConfig("gpu_auto", (Program.config.getConfig("gpu_auto") == 1) ? 0 : 1); Program.config.setConfig("gpu_auto", (Program.config.getConfig("gpu_auto") == 1) ? 0 : 1);
VisualiseGPUMode(); VisualiseGPUMode();
AutoGPUMode(SystemInformation.PowerStatus.PowerLineStatus); AutoGPUMode();
} }
private void ButtonScreenAuto_Click(object? sender, EventArgs e) private void ButtonScreenAuto_Click(object? sender, EventArgs e)
{ {
Program.config.setConfig("screen_auto", 1); Program.config.setConfig("screen_auto", 1);
InitScreen(); InitScreen();
AutoScreen(SystemInformation.PowerStatus.PowerLineStatus); AutoScreen();
} }
protected override void WndProc(ref Message m) protected override void WndProc(ref Message m)
@@ -267,6 +275,7 @@ namespace GHelper
{ {
case 0: case 0:
Logger.WriteLine("Monitor Power Off"); Logger.WriteLine("Monitor Power Off");
SetBatteryChargeLimit(Program.config.getConfig("charge_limit"));
break; break;
case 1: case 1:
Logger.WriteLine("Monitor Power On"); Logger.WriteLine("Monitor Power On");
@@ -449,7 +458,7 @@ namespace GHelper
SetMatrix(); SetMatrix();
} }
public void SetMatrix(PowerLineStatus Plugged = PowerLineStatus.Online) public void SetMatrix()
{ {
if (mat is null) return; if (mat is null) return;
@@ -472,7 +481,7 @@ namespace GHelper
mat.SetProvider(); mat.SetProvider();
if (brightness == 0 || (auto && Plugged != PowerLineStatus.Online)) if (brightness == 0 || (auto && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online))
{ {
mat.SetDisplayState(false); mat.SetDisplayState(false);
} }
@@ -506,7 +515,7 @@ namespace GHelper
private void LabelCPUFan_Click(object? sender, EventArgs e) private void LabelCPUFan_Click(object? sender, EventArgs e)
{ {
Program.config.setConfig("fan_rpm", (Program.config.getConfig("fan_rpm") == 1) ? 0 : 1); Program.config.setConfig("fan_rpm", (Program.config.getConfig("fan_rpm") == 1) ? 0 : 1);
RefreshSensors(); RefreshSensors(true);
} }
private void PictureColor2_Click(object? sender, EventArgs e) private void PictureColor2_Click(object? sender, EventArgs e)
@@ -681,8 +690,7 @@ namespace GHelper
if (frequency >= 1000) if (frequency >= 1000)
{ {
frequency = Program.config.getConfig("max_frequency"); frequency = NativeMethods.GetRefreshRate(true);
if (frequency <= 60) frequency = 120;
} }
if (frequency > 0) if (frequency > 0)
@@ -692,8 +700,12 @@ namespace GHelper
} }
if (overdrive >= 0) if (overdrive >= 0)
{
if (Program.config.getConfig("no_overdrive") == 1) overdrive = 0;
Program.wmi.DeviceSet(ASUSWmi.ScreenOverdrive, overdrive); Program.wmi.DeviceSet(ASUSWmi.ScreenOverdrive, overdrive);
}
if (miniled >= 0) if (miniled >= 0)
{ {
Program.wmi.DeviceSet(ASUSWmi.ScreenMiniled, miniled); Program.wmi.DeviceSet(ASUSWmi.ScreenMiniled, miniled);
@@ -708,11 +720,13 @@ namespace GHelper
{ {
int frequency = NativeMethods.GetRefreshRate(); int frequency = NativeMethods.GetRefreshRate();
int maxFrequency = Program.config.getConfig("max_frequency"); int maxFrequency = NativeMethods.GetRefreshRate(true);
bool screenAuto = (Program.config.getConfig("screen_auto") == 1); bool screenAuto = (Program.config.getConfig("screen_auto") == 1);
bool overdriveSetting = (Program.config.getConfig("no_overdrive") != 1);
int overdrive = Program.wmi.DeviceGet(ASUSWmi.ScreenOverdrive); int overdrive = Program.wmi.DeviceGet(ASUSWmi.ScreenOverdrive);
int miniled = Program.wmi.DeviceGet(ASUSWmi.ScreenMiniled); int miniled = Program.wmi.DeviceGet(ASUSWmi.ScreenMiniled);
bool screenEnabled = (frequency >= 0); bool screenEnabled = (frequency >= 0);
@@ -738,18 +752,14 @@ namespace GHelper
{ {
button60Hz.Activated = true; button60Hz.Activated = true;
} }
else else if (frequency > 60)
{ {
if (frequency > 60)
maxFrequency = frequency;
Program.config.setConfig("max_frequency", maxFrequency);
button120Hz.Activated = true; button120Hz.Activated = true;
} }
if (maxFrequency > 60) if (maxFrequency > 60)
{ {
button120Hz.Text = maxFrequency.ToString() + "Hz + OD"; button120Hz.Text = maxFrequency.ToString() + "Hz" + (overdriveSetting ? " + OD" : "");
} }
if (miniled >= 0) if (miniled >= 0)
@@ -808,10 +818,10 @@ namespace GHelper
return " Fan: " + Math.Min(Math.Round(fan / 0.6), 100).ToString() + "%"; // relatively to 6000 rpm return " Fan: " + Math.Min(Math.Round(fan / 0.6), 100).ToString() + "%"; // relatively to 6000 rpm
} }
private static void RefreshSensors() private static void RefreshSensors(bool force = false)
{ {
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastRefresh) < 2000) return; if (!force && Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastRefresh) < 2000) return;
lastRefresh = DateTimeOffset.Now.ToUnixTimeMilliseconds(); lastRefresh = DateTimeOffset.Now.ToUnixTimeMilliseconds();
string cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan)); string cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan));
@@ -902,6 +912,12 @@ namespace GHelper
if (Program.config.getConfig("mid_fan") == 1) if (Program.config.getConfig("mid_fan") == 1)
Program.wmi.SetFanCurve(2, Program.config.getFanConfig(2)); Program.wmi.SetFanCurve(2, Program.config.getFanConfig(2));
labelPerf.Text = "Performance Mode+";
} else
{
labelPerf.Text = "Performance Mode";
} }
if (Program.config.getConfigPerf("auto_apply_power") == 1) if (Program.config.getConfigPerf("auto_apply_power") == 1)
@@ -987,8 +1003,23 @@ namespace GHelper
SetPerformanceMode(Program.config.getConfig("performance_mode") + 1, true); SetPerformanceMode(Program.config.getConfig("performance_mode") + 1, true);
} }
public void AutoPerformance(PowerLineStatus Plugged = PowerLineStatus.Online)
public void AutoKeyboard()
{ {
if (Program.config.getConfig("keyboard_auto") != 1) return;
if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online)
Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Up);
else
Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Down);
}
public void AutoPerformance()
{
var Plugged = SystemInformation.PowerStatus.PowerLineStatus;
int mode = Program.config.getConfig("performance_" + (int)Plugged); int mode = Program.config.getConfig("performance_" + (int)Plugged);
if (mode != -1) if (mode != -1)
SetPerformanceMode(mode, true); SetPerformanceMode(mode, true);
@@ -997,11 +1028,11 @@ namespace GHelper
} }
public void AutoScreen(PowerLineStatus Plugged = PowerLineStatus.Online) public void AutoScreen(bool force = false)
{ {
if (Program.config.getConfig("screen_auto") != 1) return; if (!force && Program.config.getConfig("screen_auto") != 1) return;
if (Plugged == PowerLineStatus.Online) if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online)
SetScreen(1000, 1); SetScreen(1000, 1);
else else
SetScreen(60, 0); SetScreen(60, 0);
@@ -1009,9 +1040,11 @@ namespace GHelper
} }
public bool AutoGPUMode(PowerLineStatus Plugged = PowerLineStatus.Online) public bool AutoGPUMode()
{ {
var Plugged = SystemInformation.PowerStatus.PowerLineStatus;
bool GpuAuto = Program.config.getConfig("gpu_auto") == 1; bool GpuAuto = Program.config.getConfig("gpu_auto") == 1;
if (!GpuAuto) return false; if (!GpuAuto) return false;
@@ -1116,7 +1149,7 @@ namespace GHelper
InitGPUMode(); InitGPUMode();
HardwareMonitor.RecreateGpuTemperatureProviderWithDelay(); HardwareMonitor.RecreateGpuTemperatureProviderWithDelay();
Thread.Sleep(500); Thread.Sleep(500);
AutoScreen(SystemInformation.PowerStatus.PowerLineStatus); AutoScreen();
}); });
}); });

View File

@@ -7,11 +7,13 @@ sc STOP ASUSSystemAnalysis
sc STOP ASUSSystemDiagnosis sc STOP ASUSSystemDiagnosis
sc STOP ArmouryCrateControlInterface sc STOP ArmouryCrateControlInterface
sc DELETE AsusAppService sc config AsusAppService start= disabled
sc DELETE ASUSLinkNear sc config ASUSLinkNear start= disabled
sc DELETE ASUSLinkRemote sc config ASUSLinkRemote start= disabled
sc DELETE ASUSSoftwareManager sc config ASUSSoftwareManager start= disabled
sc DELETE ASUSSwitch sc config ASUSSwitch start= disabled
sc DELETE ASUSSystemAnalysis sc config ASUSSystemAnalysis start= disabled
sc DELETE ASUSSystemDiagnosis sc config ASUSSystemDiagnosis start= disabled
sc DELETE ArmouryCrateControlInterface sc config ArmouryCrateControlInterface start= disabled
set /p asd="Hit enter to finish"

View File

@@ -1,8 +1,8 @@
# [G-Helper (GHelper)](https://github.com/seerge/g-helper) # [G-Helper (GHelper)](https://github.com/seerge/g-helper)
[![Github all releases](https://img.shields.io/github/downloads/seerge/g-helper/total.svg)](https://GitHub.com/seerge/g-helper/releases/) [![GitHub release](https://img.shields.io/github/release/seerge/g-helper.svg)](https://GitHub.com/seerge/g-helper/releases/) [![GitHub stars](https://img.shields.io/github/stars/seerge/g-helper.svg?style=social&label=Star&maxAge=2592000)](https://GitHub.com/seerge/g-helper/stargazers/) [![Github all releases](https://img.shields.io/github/downloads/seerge/g-helper/total.svg)](https://GitHub.com/seerge/g-helper/releases/) [![GitHub release](https://img.shields.io/github/release/seerge/g-helper.svg)](https://GitHub.com/seerge/g-helper/releases/) [![GitHub stars](https://img.shields.io/github/stars/seerge/g-helper.svg?style=social&label=Star)](https://GitHub.com/seerge/g-helper/stargazers/)
## Open source Armoury Crate alternative for Asus laptops such as ROG Zephyrus G14, G15, Flow X13, Flow X16, and other models ## Open source Armoury Crate alternative for Asus laptops such as ROG Zephyrus G14, G15, Flow X13, Flow X16, TUF and other models
A small utility that allows you to do almost everything you could do with Armoury Crate but without extra bloat and unnecessary services. A small utility that allows you to do almost everything you could do with Armoury Crate but without extra bloat and unnecessary services.