Compare commits

..

15 Commits
v0.93 ... v0.95

Author SHA1 Message Date
Serge
bb5aeba9e7 Fix for GA402XI 2023-07-05 17:15:47 +02:00
Serge
2d4e794084 Added option to disable tablet mode switch in config 2023-07-05 14:55:52 +02:00
Serge
5f1c926527 Keyboard listener retry 2023-07-04 23:07:55 +02:00
Serge
dc40b317f8 Default temp limit 2023-07-04 16:47:44 +02:00
Serge
db595d54f6 Init Limit 2023-07-04 10:56:24 +02:00
Serge
2c317d9a18 More logs 2023-07-03 21:11:03 +02:00
Serge
1e26696eb6 Merge branch 'main' of https://github.com/seerge/g-helper 2023-07-03 20:56:16 +02:00
Serge
feff220a9b Adjust power modes only when needed 2023-07-03 20:56:14 +02:00
Serge
a05c47a05c Update README.md 2023-07-03 20:55:23 +02:00
Serge
5b08bfbe92 Merge branch 'main' of https://github.com/seerge/g-helper 2023-07-03 18:18:48 +02:00
Serge
606f43380b Minor fixes 2023-07-03 18:18:46 +02:00
Serge
657e09adb0 Update README.md 2023-07-02 21:48:59 +02:00
Serge
188c566097 Update SECURITY.md 2023-07-01 23:07:04 +02:00
Serge
828a1cd13c Update README.md 2023-07-01 20:16:12 +02:00
Serge
c69d3b7c1c Update README.md 2023-07-01 13:48:58 +02:00
18 changed files with 162 additions and 94 deletions

4
.github/SECURITY.md vendored
View File

@@ -4,8 +4,8 @@
| Version | Supported |
| ------- | ------------------ |
| 0.25+ | :white_check_mark: |
| < 0.24 | :x: |
| 0.89+ | :white_check_mark: |
| < 0.89 | :x: |
## Reporting a Vulnerability

View File

@@ -1,6 +1,6 @@
// Source thanks to https://github.com/vddCore/Starlight with some adjustments from me
using Starlight.Communication;
using GHelper.AnimeMatrix.Communication;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Globalization;

View File

@@ -1,9 +1,8 @@
// Source thanks to https://github.com/vddCore/Starlight :)
using Starlight.Communication.Platform;
using System.Configuration;
using GHelper.AnimeMatrix.Communication.Platform;
namespace Starlight.Communication
namespace GHelper.AnimeMatrix.Communication
{
public abstract class Device : IDisposable
{

View File

@@ -1,6 +1,6 @@
// Source thanks to https://github.com/vddCore/Starlight :)
namespace Starlight.Communication
namespace GHelper.AnimeMatrix.Communication
{
public abstract class Packet
{

View File

@@ -1,4 +1,4 @@
namespace Starlight.Communication.Platform
namespace GHelper.AnimeMatrix.Communication.Platform
{
internal abstract class UsbProvider : IDisposable
{
@@ -13,7 +13,7 @@ namespace Starlight.Communication.Platform
public abstract void Set(byte[] data);
public abstract byte[] Get(byte[] data);
public abstract void Dispose();
}
}

View File

@@ -1,14 +1,14 @@
using System.ComponentModel;
using HidSharp;
namespace Starlight.Communication.Platform
namespace GHelper.AnimeMatrix.Communication.Platform
{
internal class WindowsUsbProvider : UsbProvider
{
protected HidDevice HidDevice { get; }
protected HidStream HidStream { get; }
public WindowsUsbProvider(ushort vendorId, ushort productId, int maxFeatureReportLength)
public WindowsUsbProvider(ushort vendorId, ushort productId, int maxFeatureReportLength)
: base(vendorId, productId)
{
try
@@ -43,7 +43,7 @@ namespace Starlight.Communication.Platform
{
var outData = new byte[data.Length];
Array.Copy(data, outData, data.Length);
WrapException(() =>
{
HidStream.GetFeature(outData);
@@ -57,7 +57,7 @@ namespace Starlight.Communication.Platform
{
HidStream.Dispose();
}
private void WrapException(Action action)
{
try

View File

@@ -106,7 +106,7 @@ public class AsusACPI
public const int GPUModeStandard = 1;
public const int GPUModeUltimate = 2;
public static int MaxTotal => AppConfig.ContainsModel("G513QY") ? 250 : 150;
public static int MaxTotal => AppConfig.ContainsModel("13QY") ? 250 : 150;
public const int MinTotal = 5;
public const int DefaultTotal = 125;
@@ -396,7 +396,7 @@ public class AsusACPI
if (count == 0 && pair.Key >= 40)
{
fix = true;
pointsFixed.Add(20, 0);
pointsFixed.Add(30, 0);
}
if (count != 3 || !fix)

View File

@@ -0,0 +1,33 @@
using GHelper.Helpers;
using System.Diagnostics;
namespace GHelper.Battery
{
internal class BatteryControl
{
public static void SetBatteryChargeLimit(int limit = -1)
{
if (limit < 0) limit = AppConfig.Get("charge_limit");
if (limit < 40 || limit > 100) return;
Program.settingsForm.VisualiseBattery(limit);
Program.acpi.DeviceSet(AsusACPI.BatteryLimit, limit, "BatteryLimit");
try
{
OptimizationService.SetChargeLimit(limit);
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
AppConfig.Set("charge_limit", limit);
}
}
}

View File

@@ -267,32 +267,33 @@ namespace GHelper
int igpuUV = Math.Max(trackUViGPU.Minimum, Math.Min(trackUViGPU.Maximum, AppConfig.GetMode("igpu_uv", 0)));
int temp = AppConfig.GetMode("cpu_temp");
if (temp < trackTemp.Minimum || temp > trackTemp.Maximum) temp = 96;
if (temp < RyzenControl.MinTemp || temp > RyzenControl.MaxTemp) temp = RyzenControl.MaxTemp;
checkApplyUV.Enabled = checkApplyUV.Checked = AppConfig.IsMode("auto_uv");
trackUV.Value = cpuUV;
labelUV.Text = trackUV.Value.ToString();
trackUViGPU.Value = igpuUV;
labelUViGPU.Text = trackUViGPU.Value.ToString();
trackTemp.Value = temp;
labelTemp.Text = trackTemp.Value.ToString() + "°C";
VisualiseAdvanced();
buttonAdvanced.Visible = RyzenControl.IsAMD();
}
private void VisualiseAdvanced()
{
labelUV.Text = trackUV.Value.ToString();
labelUViGPU.Text = trackUViGPU.Value.ToString();
labelTemp.Text = (trackTemp.Value < RyzenControl.MaxTemp) ? trackTemp.Value.ToString() + "°C" : "Default";
}
private void AdvancedScroll()
{
AppConfig.SetMode("auto_uv", 0);
checkApplyUV.Enabled = checkApplyUV.Checked = false;
labelUV.Text = trackUV.Value.ToString();
labelUViGPU.Text = trackUViGPU.Value.ToString();
labelTemp.Text = trackTemp.Value.ToString() + "°C";
VisualiseAdvanced();
AppConfig.SetMode("cpu_temp", trackTemp.Value);
AppConfig.SetMode("cpu_uv", trackUV.Value);
@@ -839,10 +840,9 @@ namespace GHelper
AppConfig.SetMode("auto_apply", 0);
AppConfig.SetMode("auto_apply_power", 0);
trackUV.Value = 0;
trackUViGPU.Value = 0;
trackTemp.Value = 96;
trackUV.Value = RyzenControl.MaxCPUUV;
trackUViGPU.Value = RyzenControl.MaxIGPUUV;
trackTemp.Value = RyzenControl.MaxTemp;
AdvancedScroll();
AppConfig.SetMode("cpu_temp", -1);
@@ -931,7 +931,7 @@ namespace GHelper
if (dy < 0) dy = 0;
if (dy > fansMax) dy = fansMax;
dymin = (dx - 65) * 1.2;
dymin = (dx - 70) * 1.2;
if (dy < dymin) dy = dymin;

View File

@@ -16,7 +16,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.93</AssemblyVersion>
<AssemblyVersion>0.95</AssemblyVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@@ -12,7 +12,7 @@ namespace GHelper.Input
public class InputDispatcher
{
System.Timers.Timer timer = new System.Timers.Timer(1000);
public bool backlightActivity = true;
public static bool backlightActivity = true;
public static Keys keyProfile = Keys.F5;
public static Keys keyApp = Keys.F12;
@@ -342,6 +342,8 @@ namespace GHelper.Input
public static void TabletMode()
{
if (AppConfig.Is("disable_tablet")) return;
bool touchpadState = GetTouchpadState();
bool tabletState = Program.acpi.DeviceGet(AsusACPI.TabletState) > 0;

View File

@@ -10,7 +10,20 @@ namespace GHelper.Input
public KeyboardListener(Action<int> KeyHandler)
{
HidDevice? input = AsusUSB.GetDevice();
if (input == null) return;
// Fallback
if (input == null)
{
AsusUSB.Init();
Thread.Sleep(1000);
input = AsusUSB.GetDevice();
}
if (input == null)
{
Logger.WriteLine($"Input device not found");
return;
}
Logger.WriteLine($"Input: {input.DevicePath}");

View File

@@ -1,4 +1,5 @@
using GHelper.Gpu.NVidia;
using GHelper.Battery;
using GHelper.Gpu.NVidia;
using GHelper.Helpers;
using Ryzen;
@@ -88,6 +89,8 @@ namespace GHelper.Mode
PowerNative.SetCPUBoost(AppConfig.GetMode("auto_boost"));
}
//BatteryControl.SetBatteryChargeLimit();
/*
if (NativeMethods.PowerGetEffectiveOverlayScheme(out Guid activeScheme) == 0)
{
@@ -168,6 +171,11 @@ namespace GHelper.Mode
AppConfig.ContainsModel("G733");
}
private static bool IsFanRequired()
{
return AppConfig.ContainsModel("GA402XI") || AppConfig.ContainsModel("G513");
}
public void AutoPower(int delay = 0)
{
@@ -179,8 +187,8 @@ namespace GHelper.Mode
if (applyPower)
{
// force fan curve for misbehaving bios PPTs on G513
if (AppConfig.ContainsModel("G513") && !applyFans)
// force fan curve for misbehaving bios PPTs on some models
if (!applyFans && IsFanRequired())
{
delay = 500;
AutoFans(true);
@@ -249,10 +257,18 @@ namespace GHelper.Mode
if (ProcessHelper.IsUserAdministrator())
{
SendCommand.set_stapm_limit((uint)limit_total * 1000);
SendCommand.set_stapm2_limit((uint)limit_total * 1000);
SendCommand.set_slow_limit((uint)limit_total * 1000);
SendCommand.set_fast_limit((uint)limit_total * 1000);
var stapmResult = SendCommand.set_stapm_limit((uint)limit_total * 1000);
Logger.WriteLine($"STAPM: {limit_total} {stapmResult}");
var stapmResult2 = SendCommand.set_stapm2_limit((uint)limit_total * 1000);
Logger.WriteLine($"STAPM2: {limit_total} {stapmResult2}");
var slowResult = SendCommand.set_slow_limit((uint)limit_total * 1000);
Logger.WriteLine($"SLOW: {limit_total} {slowResult}");
var fastResult = SendCommand.set_fast_limit((uint)limit_total * 1000);
Logger.WriteLine($"FAST: {limit_total} {fastResult}");
customPower = limit_total;
}
else if (launchAsAdmin)
@@ -331,7 +347,7 @@ namespace GHelper.Mode
public void SetCPUTemp(int? cpuTemp, bool log = true)
{
if (cpuTemp >= RyzenControl.MinTemp && cpuTemp <= RyzenControl.MaxTemp)
if (cpuTemp >= RyzenControl.MinTemp && cpuTemp < RyzenControl.MaxTemp)
{
var resultCPU = SendCommand.set_tctl_temp((uint)cpuTemp);
if (log) Logger.WriteLine($"CPU Temp: {cpuTemp} {resultCPU}");

View File

@@ -122,21 +122,27 @@ namespace GHelper.Mode
public static void SetPowerScheme(string scheme)
{
List<string> overlays = new() {
"00000000-0000-0000-0000-000000000000",
"ded574b5-45a0-4f42-8737-46345c09c238",
"961cc777-2547-4f9d-8174-7d86181b8a7a",
"3af9B8d9-7c97-431d-ad78-34a8bfea439f"
};
"00000000-0000-0000-0000-000000000000",
"ded574b5-45a0-4f42-8737-46345c09c238",
"961cc777-2547-4f9d-8174-7d86181b8a7a",
"3af9B8d9-7c97-431d-ad78-34a8bfea439f"
};
Guid guidScheme = new Guid(scheme);
if (overlays.Contains(scheme))
{
PowerSetActiveOverlayScheme(new Guid(scheme));
Logger.WriteLine("Power mode:" + scheme);
uint status = PowerGetEffectiveOverlayScheme(out Guid activeScheme);
if (status != 0 || activeScheme != guidScheme)
{
PowerSetActiveOverlayScheme(guidScheme);
Logger.WriteLine("Power mode: " + scheme);
}
}
else
{
PowerSetActiveScheme(IntPtr.Zero, new Guid(scheme));
Logger.WriteLine("Power plan:" + scheme);
PowerSetActiveScheme(IntPtr.Zero, guidScheme);
Logger.WriteLine("Power plan: " + scheme);
}
@@ -147,13 +153,13 @@ namespace GHelper.Mode
switch (mode)
{
case 0: // balanced
PowerSetActiveOverlayScheme(new Guid("00000000-0000-0000-0000-000000000000"));
SetPowerScheme("00000000-0000-0000-0000-000000000000");
break;
case 1: // turbo
PowerSetActiveOverlayScheme(new Guid("ded574b5-45a0-4f42-8737-46345c09c238"));
SetPowerScheme("ded574b5-45a0-4f42-8737-46345c09c238");
break;
case 2: //silent
PowerSetActiveOverlayScheme(new Guid("961cc777-2547-4f9d-8174-7d86181b8a7a"));
SetPowerScheme("961cc777-2547-4f9d-8174-7d86181b8a7a");
break;
}
}

View File

@@ -1,15 +1,15 @@
using GHelper.Battery;
using GHelper.Display;
using GHelper.Gpu;
using GHelper.Helpers;
using GHelper.Input;
using GHelper.Mode;
using GHelper.Display;
using Microsoft.Win32;
using Ryzen;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using static NativeMethods;
using GHelper.AutoUpdate;
namespace GHelper
{
@@ -157,7 +157,6 @@ namespace GHelper
inputDispatcher.Init();
settingsForm.SetBatteryChargeLimit(AppConfig.Get("charge_limit"));
modeControl.AutoPerformance(powerChanged);
bool switched = gpuControl.AutoGPUMode();
@@ -168,6 +167,8 @@ namespace GHelper
screenControl.AutoScreen();
}
BatteryControl.SetBatteryChargeLimit();
settingsForm.AutoKeyboard();
settingsForm.matrix.SetMatrix();
}
@@ -219,7 +220,7 @@ namespace GHelper
case "uv":
Startup.ReScheduleAdmin();
settingsForm.FansToggle(2);
modeControl.SetRyzen();
modeControl.SetRyzen();
break;
}
}

View File

@@ -26,18 +26,19 @@ namespace Ryzen
//STAMP Limit
public static void set_stapm_limit(uint value)
public static Smu.Status? set_stapm_limit(uint value)
{
RyzenAccess.Initialize();
uint[] Args = new uint[6];
Args[0] = value;
Smu.Status? result = null;
switch (FAMID)
{
case 0:
case 1:
case 2:
RyzenAccess.SendMp1(0x1a, ref Args);
result = RyzenAccess.SendMp1(0x1a, ref Args);
break;
case 3:
case 5:
@@ -46,20 +47,24 @@ namespace Ryzen
case 9:
case 11:
RyzenAccess.SendMp1(0x14, ref Args);
RyzenAccess.SendPsmu(0x31, ref Args);
result = RyzenAccess.SendPsmu(0x31, ref Args);
break;
default:
break;
}
RyzenAccess.Deinitialize();
return result;
}
//STAMP2 Limit
public static void set_stapm2_limit(uint value)
public static Smu.Status? set_stapm2_limit(uint value)
{
RyzenAccess.Initialize();
uint[] Args = new uint[6];
Args[0] = value;
Smu.Status? result = null;
switch (FAMID)
{
@@ -69,26 +74,29 @@ namespace Ryzen
case 8:
case 9:
case 11:
RyzenAccess.SendPsmu(0x31, ref Args);
result = RyzenAccess.SendPsmu(0x31, ref Args);
break;
default:
break;
}
RyzenAccess.Deinitialize();
return result;
}
//Fast Limit
public static void set_fast_limit(uint value)
public static Smu.Status? set_fast_limit(uint value)
{
RyzenAccess.Initialize();
uint[] Args = new uint[6];
Args[0] = value;
Smu.Status? result = null;
switch (FAMID)
{
case 0:
case 1:
case 2:
RyzenAccess.SendMp1(0x1b, ref Args);
result = RyzenAccess.SendMp1(0x1b, ref Args);
break;
case 3:
case 5:
@@ -96,27 +104,29 @@ namespace Ryzen
case 8:
case 9:
case 11:
RyzenAccess.SendMp1(0x15, ref Args);
result = RyzenAccess.SendMp1(0x15, ref Args);
break;
default:
break;
}
RyzenAccess.Deinitialize();
return result;
}
//Slow Limit
public static void set_slow_limit(uint value)
public static Smu.Status? set_slow_limit(uint value)
{
RyzenAccess.Initialize();
uint[] Args = new uint[6];
Args[0] = value;
Smu.Status? result = null;
switch (FAMID)
{
case 0:
case 1:
case 2:
RyzenAccess.SendMp1(0x1c, ref Args);
result = RyzenAccess.SendMp1(0x1c, ref Args);
break;
case 3:
case 5:
@@ -124,12 +134,13 @@ namespace Ryzen
case 8:
case 9:
case 11:
RyzenAccess.SendMp1(0x16, ref Args);
result = RyzenAccess.SendMp1(0x16, ref Args);
break;
default:
break;
}
RyzenAccess.Deinitialize();
return result;
}
//Slow time

View File

@@ -1,5 +1,6 @@
using GHelper.AnimeMatrix;
using GHelper.AutoUpdate;
using GHelper.Battery;
using GHelper.Display;
using GHelper.Gpu;
using GHelper.Helpers;
@@ -331,7 +332,7 @@ namespace GHelper
private void SliderBattery_ValueChanged(object? sender, EventArgs e)
{
SetBatteryChargeLimit(sliderBattery.Value);
BatteryControl.SetBatteryChargeLimit(sliderBattery.Value);
}
@@ -1010,29 +1011,10 @@ namespace GHelper
but.BackColor = but.Enabled ? Color.FromArgb(255, but.BackColor) : Color.FromArgb(100, but.BackColor);
}
public void SetBatteryChargeLimit(int limit)
public void VisualiseBattery(int limit)
{
if (limit < 40 || limit > 100) return;
//Debug.WriteLine(limit);
labelBatteryTitle.Text = Properties.Strings.BatteryChargeLimit + ": " + limit.ToString() + "%";
sliderBattery.Value = limit;
Program.acpi.DeviceSet(AsusACPI.BatteryLimit, limit, "BatteryLimit");
try
{
OptimizationService.SetChargeLimit(limit);
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
AppConfig.Set("charge_limit", limit);
}

View File

@@ -94,14 +94,14 @@ Click on them
#### I don't see a GPU temperature in G-helper
Most probably either you are using Eco / Optimized mode and your dGPU is simply off, or your windows has put the dGPU into sleep (to preserve power). In this situations G-helper won't be able to reach your GPU and get readings
#### It says, that app is already running
#### I don't see app after starting it
Please check system tray for a (G) icon. By default windows is keen to hide all icons, so you may need to click ^ to see them all. I would advise to right click on Task Bar select Task Bar Settings -> Other System Tray icons -> Mark G-Helper to be always ON.
#### App crash or doesn't work properly what should I do ?
Open "Event Viewer" from start menu, go to Windows Logs -> Application and check for recent Errors mentioning G-Helper. If you see one - please post a [new issue](https://github.com/seerge/g-helper/issues) with all details from this error.
#### Battery charge limiter is not working
Open application log.text from ``%AppData%\GHelper``. If you see something like ``BatteryLimit = 60 : OK`` there with your selected limit - App has done everything it could to set a limit. It could be that MyASUS or other Asus services are overwriting this limit after. You may want to stop them by clicking "Stop" in Asus Services section (under Extra).
It could be that Asus services are overwriting this limit after. You may want to stop them by clicking "Stop" in Asus Services section (under Extra).
#### Can I use MyASUS app along with G-Helper?
You can, the only problem is that MyASUS may override the battery charge limit that you set before. My advice in such a situation would be to set the same limit (i.e. 80%) in both MyASUS and G-Helper.
@@ -127,8 +127,11 @@ Open app, and uncheck and check again "run on startup". If it still doesn't help
#### How do I uninstall G-helper?
G-helper is a single exe, and it doesn't install anything in the system. To remove it - you can simply delete exe :) If you have applied any custom fan profiles or PPTs - before removing I would recommend selecting your favorite performance mode (for example balanced) and clicking "Factory defaults" under Fans + Power.
#### I have G14 2023 and my GPU refuses to disable/enable
It seem to be an issue in older BIOS versions. As [users report](https://github.com/seerge/g-helper/issues/680) - latest BIOS 310 (installable via myasus / g-helper -> updates) resolves all issues :) So please update.
#### How do I do a hardware reset on a laptop?
This is not related to g-helper anyhow, but all Asus laptops have an option to do a hardware reset that can be handy sometimes. It doesn't touch your data in any way, but resets all main hardware-related things (enables your dGPU, wakes up wifi/bt adapter if it hanged by some reason, etc). To do this reset : Turn OFF laptop. Press and hold "power" button for 30-40 seconds. Then boot normally (it will take a bit longer to boot)
All Asus laptops have an option to do a hardware reset that can be handy sometimes. It doesn't touch your data, but resets all main hardware-related things (enables your dGPU, wakes up wifi/bt adapter if it hanged by some reason, etc). Turn OFF laptop. Press and hold "power" button for 30-40 seconds. Then boot normally (it will take a bit longer to boot)
#### What is G-helper ?
G-Helper is a lightweight Armoury Crate alternative for Asus laptops. A small utility that allows you to do almost everything you could do with Armoury Crate but without extra bloat and unnecessary services.
@@ -144,9 +147,9 @@ G-Helper is a lightweight Armoury Crate alternative for Asus laptops. A small ut
----------------
### How to install
### How to run
1. Download latest release from [**Releases Page**](https://github.com/seerge/g-helper/releases)
1. Download [**latest release**](https://github.com/seerge/g-helper/releases/latest/download/GHelper.zip)
2. Unzip to a folder of your choice _(don't run exe from zip directly, as windows will put it into temp folder and delete after)_
3. Run **GHelper.exe**
@@ -177,6 +180,8 @@ I don't have a Microsoft certificate to sign the app yet, so if you get a warnin
## Power user settings
_GENERAL NOTE: "Power user" settings require some config edits. Before making any changes to ``config.json`` - quit G-Helper. Make your changes. Run G-Helper again._
### Manual app language setting
By default app will use your windows language setting. But you can set language manually (if it supported of course)