Compare commits

...

42 Commits
v0.59 ... v0.63

Author SHA1 Message Date
Serge
8590d0301a Merge pull request #391 from seerge/revert-385-windows-power-plan-changes-optional
Revert "Adjustment of Windows Power Overlay is now optional"
2023-05-16 11:39:41 +02:00
Serge
8804d19567 Revert "Adjustment of Windows Power Overlay is now optional" 2023-05-16 11:38:17 +02:00
Serge
57ce0631a3 Merge pull request #385 from IceStormNG/windows-power-plan-changes-optional
Adjustment of Windows Power Overlay is now optional
2023-05-16 11:30:41 +02:00
Carsten Braun
b796f9f9d4 Moved checkbox to 2023-05-16 10:41:02 +02:00
Serge
f39563fcdf Added touchpad toggle for tablet mode on x13/x16 2023-05-15 23:59:21 +02:00
Serge
853d0c231d Auto update 2023-05-15 22:23:16 +02:00
Serge
df3324d641 Auto update 2023-05-15 22:21:41 +02:00
Serge
75c90ee155 Merge branch 'main' of https://github.com/seerge/g-helper 2023-05-15 22:11:29 +02:00
Serge
4015e0a7f7 Added auto-update checker 2023-05-15 22:11:27 +02:00
Carsten Braun
2a82e41894 Adjustment of Windows Power Overlay is now optional 2023-05-15 13:23:20 +02:00
Serge
a5541dfe10 Update README.md 2023-05-14 19:52:02 +02:00
Serge
fd3a139c47 Aura tweaks 2023-05-14 10:28:48 +02:00
Serge
608b8571d4 Fix for turkish keyboard, tweak for default fan curves 2023-05-13 22:13:00 +02:00
Serge
82a39bcfa1 Merge pull request #375 from IceStormNG/animematrix-for-GU604
Supports AniMeMatrix for Zephyrus M16 2023 (GU604)
2023-05-13 18:24:37 +02:00
Carsten Braun
f9ccd92dc6 Supports AniMeMatrix for Zephyrus M16 2023 (GU604) 2023-05-13 18:10:18 +02:00
Serge
1fadc6c31e Hotfix for possible crash 2023-05-13 09:43:26 +02:00
Serge
0b7dd42a5d UI tweak 2023-05-12 17:21:04 +02:00
Serge
51cd700e25 Improved GPU restart 2023-05-12 15:51:57 +02:00
Serge
7484253007 Merge branch 'main' of https://github.com/seerge/g-helper 2023-05-12 14:06:19 +02:00
Serge
f5cf768017 Display workaround 2023-05-12 14:06:15 +02:00
Serge
ca57669596 NV Clocks tweaks 2023-05-11 19:38:53 +02:00
Serge
35f1a3a25b Clock tweak 2023-05-11 11:18:42 +02:00
Serge
b7afe94b8d Merge branch 'main' of https://github.com/seerge/g-helper 2023-05-11 10:52:41 +02:00
Serge
97c97e8e19 Eco tweaks 2023-05-11 10:52:40 +02:00
Serge
ffc5a6f641 Update README.md 2023-05-11 00:40:30 +02:00
Serge
f87e6c5c88 Update README.md 2023-05-11 00:39:07 +02:00
Serge
22f136fe9e Crash fix 2023-05-11 00:35:03 +02:00
Serge
6d85376734 Extra logs 2023-05-10 23:24:54 +02:00
Serge
62512a7c05 Merge branch 'main' of https://github.com/seerge/g-helper 2023-05-10 18:38:51 +02:00
Serge
7a6301328c GPU Restart 2023-05-10 18:38:49 +02:00
Serge
3c6c4d122d Update README.md 2023-05-10 15:31:20 +02:00
Serge
0142c25929 Overclocking logic, added restart-gpu workaround 2023-05-10 14:06:33 +02:00
Serge
27bc7339d8 Merge pull request #351 from marcelomijas/main
Update Spanish translation
2023-05-09 22:11:44 +02:00
Marcelo Moreno
2985fe378c Small fix... 2023-05-09 22:09:36 +02:00
Marcelo Moreno
71daba25a8 Update Spanish translation
Update the Spanish translation file so it has the same fields as the original "Strings.resx", and translated the new items. :)
2023-05-09 22:01:09 +02:00
Serge
16feeb05a1 Clocks fixes 2023-05-09 18:21:07 +02:00
Serge
c69bf65c84 Clocks fixes 2023-05-09 18:02:59 +02:00
Serge
56ea434626 Aura fix 2023-05-09 17:16:10 +02:00
Serge
432508cfc5 GPU settings tweaks 2023-05-09 16:51:15 +02:00
Serge
deb515066d Merge branch 'main' of https://github.com/seerge/g-helper 2023-05-09 16:13:40 +02:00
Serge
ac19a822f7 GPU eco check 2023-05-09 16:13:35 +02:00
Serge
41caaefc97 Improved aura logging 2023-05-09 16:05:57 +02:00
21 changed files with 739 additions and 258 deletions

View File

@@ -1,4 +1,6 @@
using System.Management;
using System.Globalization;
using System.IO.Pipes;
using System.Management;
using System.Runtime.InteropServices;
public class ASUSWmi
@@ -13,6 +15,7 @@ public class ASUSWmi
public const uint UniversalControl = 0x00100021;
public const int KB_Light_Up = 0xc4;
public const int KB_Light_Down = 0xc5;
public const int Touchpad_Toggle = 0x6B;
public const int ChargerMode = 0x0012006C;
@@ -57,6 +60,13 @@ public class ASUSWmi
public const int TUF_KB = 0x00100056;
public const int TUF_KB_STATE = 0x00100057;
public const int TabletState = 0x00060077;
public const int Tablet_Notebook = 0;
public const int Tablet_Tablet = 1;
public const int Tablet_Tent = 2;
public const int Tablet_Rotated = 3;
public const int PerformanceBalanced = 0;
public const int PerformanceTurbo = 1;
public const int PerformanceSilent = 2;
@@ -204,7 +214,7 @@ public class ASUSWmi
byte[] args = new byte[8];
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
byte[] status = CallMethod(DSTS, args);
return BitConverter.ToInt32(status, 0) - 65536;
}
@@ -214,10 +224,24 @@ public class ASUSWmi
byte[] args = new byte[8];
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
BitConverter.GetBytes((uint)Status).CopyTo(args, 4);
return CallMethod(DSTS, args);
}
public int SetGPUEco(int eco)
{
int ecoFlag = DeviceGet(GPUEco);
if (ecoFlag < 0) return -1;
if (ecoFlag == 1 && eco == 0)
return DeviceSet(GPUEco, eco, "GPUEco");
if (ecoFlag == 0 && eco == 1)
return DeviceSet(GPUEco, eco, "GPUEco");
return -1;
}
public int SetFanCurve(int device, byte[] curve)
{
@@ -228,9 +252,7 @@ public class ASUSWmi
int result;
for (int i = 8; i < curve.Length; i++)
{
curve[i] = Math.Max((byte)0, Math.Min((byte)99, curve[i])); // it seems to be a bug, when some old model's bios can go nuts if fan is set to 100%
}
switch (device)
{
@@ -272,6 +294,47 @@ public class ASUSWmi
}
public static bool IsEmptyCurve(byte[] curve) {
return curve.Length != 16 || curve.All(singleByte => singleByte == 0);
}
public static byte[] FixFanCurve(byte[] curve)
{
if (curve.Length != 16) throw new Exception("Incorrect curve");
var points = new Dictionary<byte, byte>();
for (int i = 0; i < 8; i++) points[curve[i]] = curve[i+8];
var pointsFixed = new Dictionary<byte, byte>();
bool fix = false;
int count = 0;
foreach (var pair in points.OrderBy(x => x.Key))
{
if (count == 0 && pair.Key >= 40)
{
fix = true;
pointsFixed.Add(20, 0);
}
if (count != 3 || !fix)
pointsFixed.Add(pair.Key, pair.Value);
count++;
}
count = 0;
foreach (var pair in pointsFixed.OrderBy(x => x.Key))
{
curve[count] =pair.Key;
curve[count+8] = pair.Value;
count++;
}
return curve;
}
public void TUFKeyboardBrightness(int brightness)
{
int param = 0x80 | (brightness & 0x7F);
@@ -321,7 +384,8 @@ public class ASUSWmi
watcher.Scope = new ManagementScope("root\\wmi");
watcher.Query = new WqlEventQuery("SELECT * FROM AsusAtkWmiEvent");
watcher.Start();
} catch
}
catch
{
Logger.WriteLine("Can't connect to ASUS WMI events");
}

View File

@@ -2,6 +2,7 @@
using Starlight.Communication;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Globalization;
using System.Management;
using System.Text;
@@ -61,7 +62,8 @@ namespace Starlight.AnimeMatrix
public enum AnimeType
{
GA401,
GA402
GA402,
GU604
}
@@ -88,6 +90,8 @@ namespace Starlight.AnimeMatrix
//public int FullEvenRows = -1;
public int dx = 0;
//Shifts the whole frame to the left or right to align with the diagonal cut
public int frameShiftX = 0;
public int MaxColumns = 34;
private int frameIndex = 0;
@@ -112,6 +116,16 @@ namespace Starlight.AnimeMatrix
UpdatePageLength = 410;
}
if (model.Contains("GU604"))
{
_model = AnimeType.GU604;
MaxColumns = 39;
MaxRows = 92;
LedCount = 1711;
frameShiftX = -5;
UpdatePageLength = 630;
}
_displayBuffer = new byte[LedCount];
@@ -173,6 +187,9 @@ namespace Starlight.AnimeMatrix
{
return (y + 1) / 2 - 3;
}
case AnimeType.GU604:
return (int)Math.Ceiling(Math.Max(0, y - 9) / 2F);
default:
return (int)Math.Ceiling(Math.Max(0, y - 11) / 2F);
}
@@ -184,6 +201,8 @@ namespace Starlight.AnimeMatrix
{
case AnimeType.GA401:
return 33;
case AnimeType.GU604:
return 39;
default:
return 34;
}
@@ -226,7 +245,7 @@ namespace Starlight.AnimeMatrix
if (!IsRowInRange(y)) return;
if (x >= FirstX(y) && x < Width(y))
SetLedLinear(RowToLinearAddress(y) - FirstX(y) + x + dx, value);
SetLedLinear(RowToLinearAddress(y) - FirstX(y) + x + dx + frameShiftX, value);
}
public void WakeUp()
@@ -325,11 +344,17 @@ namespace Starlight.AnimeMatrix
public void PresentClock()
{
int second = DateTime.Now.Second;
string time;
if (CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern.Contains("H"))
PresentTextDiagonal(DateTime.Now.ToString("H" + ((second % 2 == 0) ? ":" : " ") + "mm"));
time = DateTime.Now.ToString("H" + ((second % 2 == 0) ? ":" : " ") + "mm");
else
PresentTextDiagonal(DateTime.Now.ToString("h" + ((second % 2 == 0) ? ":" : " ") + "mmtt"));
time = DateTime.Now.ToString("h" + ((second % 2 == 0) ? ":" : " ") + "mmtt");
if (_model == AnimeType.GA401)
PresentText(time);
else
PresentTextDiagonal(time);
}
public void PresentText(string text1, string text2 = "")
@@ -341,14 +366,14 @@ namespace Starlight.AnimeMatrix
g.CompositingQuality = CompositingQuality.HighQuality;
g.SmoothingMode = SmoothingMode.AntiAlias;
using (Font font = new Font("Arial", 24F, GraphicsUnit.Pixel))
using (Font font = new Font("Consolas", 24F, FontStyle.Regular, GraphicsUnit.Pixel))
{
SizeF textSize = g.MeasureString(text1, font);
g.DrawString(text1, font, Brushes.White, (MaxColumns * 3 - textSize.Width) + 3, -3);
g.DrawString(text1, font, Brushes.White, (MaxColumns * 3 - textSize.Width) + 3, -4);
}
if (text2.Length > 0)
using (Font font = new Font("Arial", 18F, GraphicsUnit.Pixel))
using (Font font = new Font("Consolas", 18F, GraphicsUnit.Pixel))
{
SizeF textSize = g.MeasureString(text2, font);
g.DrawString(text2, font, Brushes.White, (MaxColumns * 3 - textSize.Width) + 1, 25);
@@ -419,6 +444,24 @@ namespace Starlight.AnimeMatrix
Clear();
InstalledFontCollection installedFontCollection = new InstalledFontCollection();
string familyName;
string familyList = "";
FontFamily[] fontFamilies;
// Get the array of FontFamily objects.
fontFamilies = installedFontCollection.Families;
int count = fontFamilies.Length;
for (int j = 0; j < count; ++j)
{
familyName = fontFamilies[j].Name;
familyList = familyList + familyName;
familyList = familyList + ", ";
}
int maxX = (int)Math.Sqrt(MaxRows * MaxRows + MaxColumns * MaxColumns);
using (Bitmap bmp = new Bitmap(maxX, MaxRows))
@@ -428,10 +471,10 @@ namespace Starlight.AnimeMatrix
g.CompositingQuality = CompositingQuality.HighQuality;
g.SmoothingMode = SmoothingMode.AntiAlias;
using (Font font = new Font("Calibri", 13F, GraphicsUnit.Pixel))
using (Font font = new Font("Consolas", 13F, FontStyle.Regular, GraphicsUnit.Pixel))
{
SizeF textSize = g.MeasureString(text, font);
g.DrawString(text, font, Brushes.White, 4, 0);
g.DrawString(text, font, Brushes.White, 4, 1);
}
}

View File

@@ -1,5 +1,5 @@
using HidLibrary;
using OSD;
using Microsoft.Win32;
using System.Diagnostics;
namespace GHelper
@@ -16,14 +16,10 @@ namespace GHelper
SleepKeyb = 1 << 5,
ShutdownLogo = 1 << 6,
ShutdownKeyb = 1 << 7,
Unknown1 = 1 << 8,
BootBar = 1u << (7 + 2),
AwakeBar = 1u << (7 + 3),
SleepBar = 1u << (7 + 4),
ShutdownBar = 1u << (7 + 5),
Unknown2 = 1 << 13,
Unknown3 = 1 << 14,
Unknown4 = 1 << 15,
BootLid = 1u << (15 + 1),
AwakeLid = 1u << (15 + 2),
SleepLid = 1u << (15 + 3),
@@ -59,7 +55,7 @@ namespace GHelper
static byte[] MESSAGE_SET = { 0x5d, 0xb5, 0, 0, 0 };
static byte[] MESSAGE_APPLY = { 0x5d, 0xb4 };
static int[] deviceIds = { 0x1a30, 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0 };
static int[] deviceIds = { 0x1a30, 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0, 0x18c6 };
private static int mode = 0;
private static int speed = 1;
@@ -165,11 +161,14 @@ namespace GHelper
Color2 = Color.FromArgb(colorCode);
}
private static IEnumerable<HidDevice> GetHidDevices(int[] deviceIds)
private static IEnumerable<HidDevice> GetHidDevices(int[] deviceIds, int minInput = 18)
{
HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
foreach (HidDevice device in HidDeviceList)
if (device.IsConnected && device.Description.ToLower().Contains("hid") && device.Capabilities.FeatureReportByteLength >= 64)
if (device.IsConnected
&& device.Capabilities.FeatureReportByteLength > 0
&& device.Capabilities.InputReportByteLength >= minInput) //
yield return device;
}
@@ -197,15 +196,17 @@ namespace GHelper
{
byte[] msg = { 0x5d, 0xba, 0xc5, 0xc4, (byte)brightness };
foreach (HidDevice device in GetHidDevices(new int[] { 0x19b6 }))
var devices = GetHidDevices(deviceIds);
//Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
foreach (HidDevice device in devices)
{
device.OpenDevice();
device.Write(msg);
Logger.WriteLine("USB-KB " + device.Attributes.ProductHexId + ":" + BitConverter.ToString(msg));
device.CloseDevice();
}
Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
if (Program.config.ContainsModel("TUF"))
Program.wmi.TUFKeyboardBrightness(brightness);
}
@@ -216,29 +217,30 @@ namespace GHelper
byte[] msg = AuraDev19b6Extensions.ToBytes(flags.ToArray());
Debug.WriteLine(BitConverter.ToString(msg));
foreach (HidDevice device in GetHidDevices(new int[] { 0x19b6 }))
var devices = GetHidDevices(deviceIds);
//Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
foreach (HidDevice device in devices)
{
device.OpenDevice();
device.Write(msg);
Logger.WriteLine("USB-KB " + device.Attributes.ProductHexId + ":" + BitConverter.ToString(msg));
device.CloseDevice();
}
Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
//if (Program.config.ContainsModel("TUF"))
if (Program.config.ContainsModel("TUF"))
Program.wmi.TUFKeyboardPower(
flags.Contains(AuraDev19b6.AwakeKeyb),
flags.Contains(AuraDev19b6.BootKeyb),
flags.Contains(AuraDev19b6.SleepKeyb),
flags.Contains(AuraDev19b6.AwakeKeyb),
flags.Contains(AuraDev19b6.BootKeyb),
flags.Contains(AuraDev19b6.SleepKeyb),
flags.Contains(AuraDev19b6.ShutdownKeyb));
}
public static void ApplyXGMLight(bool status)
{
byte value = status? (byte)0x50:(byte)0;
byte value = status ? (byte)0x50 : (byte)0;
var msg = new byte[] { 0x5e, 0xc5, value };
foreach (HidDevice device in GetHidDevices(new int[] { 0x1970 }))
@@ -273,19 +275,46 @@ namespace GHelper
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 : not found");
GetHidDevices(deviceIds, 0);
}
foreach (HidDevice device in devices)
{
device.OpenDevice();
device.Write(msg);
device.Write(MESSAGE_SET);
device.Write(MESSAGE_APPLY);
device.CloseDevice();
Logger.WriteLine("USB-KB " + device.Capabilities.FeatureReportByteLength + "|" + device.Capabilities.InputReportByteLength + device.Description + device.DevicePath + ":" + BitConverter.ToString(msg));
}
if (Program.config.ContainsModel("TUF"))
Program.wmi.TUFKeyboardRGB(Mode, Color1, _speed);
}
public static void SetBacklightOffDelay(int value = 60)
{
try
{
RegistryKey myKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\ASUS\ASUS System Control Interface\AsusOptimization\ASUS Keyboard Hotkeys", true);
if (myKey != null)
{
myKey.SetValue("TurnOffKeybdLight", value, RegistryValueKind.DWord);
myKey.Close();
}
}
catch (Exception ex)
{
Logger.WriteLine(ex.Message);
}
}
}
}

View File

@@ -92,7 +92,7 @@ public static class ControlHelper
}
var chk = control as CheckBox;
if (chk != null && chk.Padding.Left > 5)
if (chk != null && chk.Padding.Right > 5)
{
chk.BackColor = RForm.buttonSecond;
}

194
app/Extra.Designer.cs generated
View File

@@ -44,6 +44,8 @@ namespace GHelper
labelM3 = new Label();
groupLight = new GroupBox();
panelBacklightExtra = new Panel();
numericBacklightTime = new NumericUpDown();
labelBacklightTimeout = new Label();
labelBrightness = new Label();
trackBrightness = new TrackBar();
labelSpeed = new Label();
@@ -72,14 +74,15 @@ namespace GHelper
checkSleepLid = new CheckBox();
checkShutdownLid = new CheckBox();
groupOther = new GroupBox();
checkKeyboardAuto = new CheckBox();
checkUSBC = new CheckBox();
checkNoOverdrive = new CheckBox();
checkKeyboardAuto = new CheckBox();
checkTopmost = new CheckBox();
groupBindings.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureHelp).BeginInit();
groupLight.SuspendLayout();
panelBacklightExtra.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericBacklightTime).BeginInit();
((System.ComponentModel.ISupportInitialize)trackBrightness).BeginInit();
panelXMG.SuspendLayout();
tableBacklight.SuspendLayout();
@@ -101,7 +104,7 @@ namespace GHelper
groupBindings.Dock = DockStyle.Top;
groupBindings.Location = new Point(10, 10);
groupBindings.Name = "groupBindings";
groupBindings.Size = new Size(848, 242);
groupBindings.Size = new Size(954, 242);
groupBindings.TabIndex = 0;
groupBindings.TabStop = false;
groupBindings.Text = "Key Bindings";
@@ -111,7 +114,7 @@ namespace GHelper
pictureHelp.BackgroundImage = Resources.icons8_help_64;
pictureHelp.BackgroundImageLayout = ImageLayout.Zoom;
pictureHelp.Cursor = Cursors.Hand;
pictureHelp.Location = new Point(744, 57);
pictureHelp.Location = new Point(884, 58);
pictureHelp.Name = "pictureHelp";
pictureHelp.Size = new Size(32, 32);
pictureHelp.TabIndex = 9;
@@ -122,7 +125,7 @@ namespace GHelper
textFNF4.Location = new Point(415, 176);
textFNF4.Name = "textFNF4";
textFNF4.PlaceholderText = "action";
textFNF4.Size = new Size(320, 39);
textFNF4.Size = new Size(448, 39);
textFNF4.TabIndex = 8;
//
// comboFNF4
@@ -149,7 +152,7 @@ namespace GHelper
textM4.Location = new Point(415, 113);
textM4.Name = "textM4";
textM4.PlaceholderText = "action";
textM4.Size = new Size(320, 39);
textM4.Size = new Size(448, 39);
textM4.TabIndex = 5;
//
// textM3
@@ -157,7 +160,7 @@ namespace GHelper
textM3.Location = new Point(415, 54);
textM3.Name = "textM3";
textM3.PlaceholderText = "notepad /p \"file.txt\"";
textM3.Size = new Size(320, 39);
textM3.Size = new Size(448, 39);
textM3.TabIndex = 4;
//
// comboM4
@@ -209,14 +212,15 @@ namespace GHelper
groupLight.Dock = DockStyle.Top;
groupLight.Location = new Point(10, 252);
groupLight.Name = "groupLight";
groupLight.Size = new Size(848, 475);
groupLight.Size = new Size(954, 516);
groupLight.TabIndex = 1;
groupLight.TabStop = false;
groupLight.Text = "Keyboard Backlight";
//
// panelBacklightExtra
//
panelBacklightExtra.AutoSize = true;
panelBacklightExtra.Controls.Add(numericBacklightTime);
panelBacklightExtra.Controls.Add(labelBacklightTimeout);
panelBacklightExtra.Controls.Add(labelBrightness);
panelBacklightExtra.Controls.Add(trackBrightness);
panelBacklightExtra.Controls.Add(labelSpeed);
@@ -224,9 +228,25 @@ namespace GHelper
panelBacklightExtra.Dock = DockStyle.Top;
panelBacklightExtra.Location = new Point(3, 319);
panelBacklightExtra.Name = "panelBacklightExtra";
panelBacklightExtra.Size = new Size(842, 153);
panelBacklightExtra.Size = new Size(948, 194);
panelBacklightExtra.TabIndex = 43;
//
// numericBacklightTime
//
numericBacklightTime.Location = new Point(477, 131);
numericBacklightTime.Maximum = new decimal(new int[] { 3600, 0, 0, 0 });
numericBacklightTime.Name = "numericBacklightTime";
numericBacklightTime.Size = new Size(240, 39);
numericBacklightTime.TabIndex = 47;
//
// labelBacklightTimeout
//
labelBacklightTimeout.Location = new Point(13, 133);
labelBacklightTimeout.Name = "labelBacklightTimeout";
labelBacklightTimeout.Size = new Size(489, 45);
labelBacklightTimeout.TabIndex = 46;
labelBacklightTimeout.Text = "Seconds to turn off backlight on battery";
//
// labelBrightness
//
labelBrightness.Location = new Point(13, 76);
@@ -237,6 +257,7 @@ namespace GHelper
//
// trackBrightness
//
trackBrightness.LargeChange = 1;
trackBrightness.Location = new Point(216, 60);
trackBrightness.Maximum = 3;
trackBrightness.Name = "trackBrightness";
@@ -276,7 +297,7 @@ namespace GHelper
panelXMG.Dock = DockStyle.Top;
panelXMG.Location = new Point(3, 261);
panelXMG.Name = "panelXMG";
panelXMG.Size = new Size(842, 58);
panelXMG.Size = new Size(948, 58);
panelXMG.TabIndex = 42;
//
// checkXMG
@@ -328,243 +349,254 @@ namespace GHelper
tableBacklight.RowStyles.Add(new RowStyle());
tableBacklight.RowStyles.Add(new RowStyle());
tableBacklight.RowStyles.Add(new RowStyle());
tableBacklight.Size = new Size(842, 226);
tableBacklight.Size = new Size(948, 226);
tableBacklight.TabIndex = 41;
//
// labelBacklight
//
labelBacklight.AutoSize = true;
labelBacklight.Dock = DockStyle.Fill;
labelBacklight.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelBacklight.Location = new Point(3, 0);
labelBacklight.Name = "labelBacklight";
labelBacklight.Padding = new Padding(10, 5, 5, 5);
labelBacklight.Size = new Size(139, 42);
labelBacklight.Size = new Size(231, 42);
labelBacklight.TabIndex = 6;
labelBacklight.Text = "Keyboard";
//
// checkAwake
//
checkAwake.AutoSize = true;
checkAwake.Dock = DockStyle.Fill;
checkAwake.Location = new Point(3, 45);
checkAwake.Name = "checkAwake";
checkAwake.Padding = new Padding(15, 2, 5, 2);
checkAwake.Size = new Size(135, 40);
checkAwake.Size = new Size(231, 40);
checkAwake.TabIndex = 1;
checkAwake.Text = Strings.Awake;
checkAwake.UseVisualStyleBackColor = true;
//
// checkBoot
//
checkBoot.AutoSize = true;
checkBoot.Dock = DockStyle.Fill;
checkBoot.Location = new Point(3, 91);
checkBoot.Name = "checkBoot";
checkBoot.Padding = new Padding(15, 2, 5, 2);
checkBoot.Size = new Size(116, 40);
checkBoot.Size = new Size(231, 40);
checkBoot.TabIndex = 2;
checkBoot.Text = Strings.Boot;
checkBoot.UseVisualStyleBackColor = true;
//
// checkSleep
//
checkSleep.AutoSize = true;
checkSleep.Dock = DockStyle.Fill;
checkSleep.Location = new Point(3, 137);
checkSleep.Name = "checkSleep";
checkSleep.Padding = new Padding(15, 2, 5, 2);
checkSleep.Size = new Size(125, 40);
checkSleep.Size = new Size(231, 40);
checkSleep.TabIndex = 3;
checkSleep.Text = Strings.Sleep;
checkSleep.Text = "Sleep";
checkSleep.UseVisualStyleBackColor = true;
//
// checkShutdown
//
checkShutdown.AutoSize = true;
checkShutdown.Dock = DockStyle.Fill;
checkShutdown.Location = new Point(3, 183);
checkShutdown.Name = "checkShutdown";
checkShutdown.Padding = new Padding(15, 2, 5, 2);
checkShutdown.Size = new Size(174, 40);
checkShutdown.Size = new Size(231, 40);
checkShutdown.TabIndex = 4;
checkShutdown.Text = Strings.Shutdown;
checkShutdown.UseVisualStyleBackColor = true;
//
// labelBacklightLogo
//
labelBacklightLogo.AutoSize = true;
labelBacklightLogo.Dock = DockStyle.Fill;
labelBacklightLogo.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelBacklightLogo.Location = new Point(213, 0);
labelBacklightLogo.Location = new Point(240, 0);
labelBacklightLogo.Name = "labelBacklightLogo";
labelBacklightLogo.Padding = new Padding(10, 5, 5, 5);
labelBacklightLogo.Size = new Size(86, 42);
labelBacklightLogo.Size = new Size(231, 42);
labelBacklightLogo.TabIndex = 21;
labelBacklightLogo.Text = "Logo";
//
// checkAwakeLogo
//
checkAwakeLogo.AutoSize = true;
checkAwakeLogo.Location = new Point(213, 45);
checkAwakeLogo.Dock = DockStyle.Fill;
checkAwakeLogo.Location = new Point(240, 45);
checkAwakeLogo.Name = "checkAwakeLogo";
checkAwakeLogo.Padding = new Padding(15, 2, 5, 2);
checkAwakeLogo.Size = new Size(135, 40);
checkAwakeLogo.Size = new Size(231, 40);
checkAwakeLogo.TabIndex = 17;
checkAwakeLogo.Text = Strings.Awake;
checkAwakeLogo.UseVisualStyleBackColor = true;
//
// checkBootLogo
//
checkBootLogo.AutoSize = true;
checkBootLogo.Location = new Point(213, 91);
checkBootLogo.Dock = DockStyle.Fill;
checkBootLogo.Location = new Point(240, 91);
checkBootLogo.Name = "checkBootLogo";
checkBootLogo.Padding = new Padding(15, 2, 5, 2);
checkBootLogo.Size = new Size(116, 40);
checkBootLogo.Size = new Size(231, 40);
checkBootLogo.TabIndex = 18;
checkBootLogo.Text = Strings.Boot;
checkBootLogo.UseVisualStyleBackColor = true;
//
// checkSleepLogo
//
checkSleepLogo.AutoSize = true;
checkSleepLogo.Location = new Point(213, 137);
checkSleepLogo.Dock = DockStyle.Fill;
checkSleepLogo.Location = new Point(240, 137);
checkSleepLogo.Name = "checkSleepLogo";
checkSleepLogo.Padding = new Padding(15, 2, 5, 2);
checkSleepLogo.Size = new Size(125, 40);
checkSleepLogo.Size = new Size(231, 40);
checkSleepLogo.TabIndex = 19;
checkSleepLogo.Text = Strings.Sleep;
checkSleepLogo.UseVisualStyleBackColor = true;
//
// checkShutdownLogo
//
checkShutdownLogo.AutoSize = true;
checkShutdownLogo.Location = new Point(213, 183);
checkShutdownLogo.Dock = DockStyle.Fill;
checkShutdownLogo.Location = new Point(240, 183);
checkShutdownLogo.Name = "checkShutdownLogo";
checkShutdownLogo.Padding = new Padding(15, 2, 5, 2);
checkShutdownLogo.Size = new Size(174, 40);
checkShutdownLogo.Size = new Size(231, 40);
checkShutdownLogo.TabIndex = 20;
checkShutdownLogo.Text = Strings.Shutdown;
checkShutdownLogo.UseVisualStyleBackColor = true;
//
// labelBacklightBar
//
labelBacklightBar.AutoSize = true;
labelBacklightBar.Dock = DockStyle.Fill;
labelBacklightBar.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelBacklightBar.Location = new Point(423, 0);
labelBacklightBar.Location = new Point(477, 0);
labelBacklightBar.Name = "labelBacklightBar";
labelBacklightBar.Padding = new Padding(10, 5, 5, 5);
labelBacklightBar.Size = new Size(124, 42);
labelBacklightBar.Size = new Size(231, 42);
labelBacklightBar.TabIndex = 11;
labelBacklightBar.Text = "Lightbar";
//
// checkAwakeBar
//
checkAwakeBar.AutoSize = true;
checkAwakeBar.Location = new Point(423, 45);
checkAwakeBar.Dock = DockStyle.Fill;
checkAwakeBar.Location = new Point(477, 45);
checkAwakeBar.Name = "checkAwakeBar";
checkAwakeBar.Padding = new Padding(15, 2, 5, 2);
checkAwakeBar.Size = new Size(135, 40);
checkAwakeBar.Size = new Size(231, 40);
checkAwakeBar.TabIndex = 7;
checkAwakeBar.Text = Strings.Awake;
checkAwakeBar.UseVisualStyleBackColor = true;
//
// checkBootBar
//
checkBootBar.AutoSize = true;
checkBootBar.Location = new Point(423, 91);
checkBootBar.Dock = DockStyle.Fill;
checkBootBar.Location = new Point(477, 91);
checkBootBar.Name = "checkBootBar";
checkBootBar.Padding = new Padding(15, 2, 5, 2);
checkBootBar.Size = new Size(116, 40);
checkBootBar.Size = new Size(231, 40);
checkBootBar.TabIndex = 8;
checkBootBar.Text = Strings.Boot;
checkBootBar.UseVisualStyleBackColor = true;
//
// checkSleepBar
//
checkSleepBar.AutoSize = true;
checkSleepBar.Location = new Point(423, 137);
checkSleepBar.Dock = DockStyle.Fill;
checkSleepBar.Location = new Point(477, 137);
checkSleepBar.Name = "checkSleepBar";
checkSleepBar.Padding = new Padding(15, 2, 5, 2);
checkSleepBar.Size = new Size(125, 40);
checkSleepBar.Size = new Size(231, 40);
checkSleepBar.TabIndex = 9;
checkSleepBar.Text = Strings.Sleep;
checkSleepBar.UseVisualStyleBackColor = true;
//
// checkShutdownBar
//
checkShutdownBar.AutoSize = true;
checkShutdownBar.Location = new Point(423, 183);
checkShutdownBar.Dock = DockStyle.Fill;
checkShutdownBar.Location = new Point(477, 183);
checkShutdownBar.Name = "checkShutdownBar";
checkShutdownBar.Padding = new Padding(15, 2, 5, 2);
checkShutdownBar.Size = new Size(174, 40);
checkShutdownBar.Size = new Size(231, 40);
checkShutdownBar.TabIndex = 10;
checkShutdownBar.Text = Strings.Shutdown;
checkShutdownBar.UseVisualStyleBackColor = true;
//
// labelBacklightLid
//
labelBacklightLid.AutoSize = true;
labelBacklightLid.Dock = DockStyle.Fill;
labelBacklightLid.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelBacklightLid.Location = new Point(633, 0);
labelBacklightLid.Location = new Point(714, 0);
labelBacklightLid.Name = "labelBacklightLid";
labelBacklightLid.Padding = new Padding(10, 5, 5, 5);
labelBacklightLid.Size = new Size(63, 42);
labelBacklightLid.Size = new Size(231, 42);
labelBacklightLid.TabIndex = 16;
labelBacklightLid.Text = "Lid";
//
// checkAwakeLid
//
checkAwakeLid.AutoSize = true;
checkAwakeLid.Location = new Point(633, 45);
checkAwakeLid.Dock = DockStyle.Fill;
checkAwakeLid.Location = new Point(714, 45);
checkAwakeLid.Name = "checkAwakeLid";
checkAwakeLid.Padding = new Padding(15, 2, 5, 2);
checkAwakeLid.Size = new Size(135, 40);
checkAwakeLid.Size = new Size(231, 40);
checkAwakeLid.TabIndex = 12;
checkAwakeLid.Text = Strings.Awake;
checkAwakeLid.UseVisualStyleBackColor = true;
//
// checkBootLid
//
checkBootLid.AutoSize = true;
checkBootLid.Location = new Point(633, 91);
checkBootLid.Dock = DockStyle.Fill;
checkBootLid.Location = new Point(714, 91);
checkBootLid.Name = "checkBootLid";
checkBootLid.Padding = new Padding(15, 2, 5, 2);
checkBootLid.Size = new Size(116, 40);
checkBootLid.Size = new Size(231, 40);
checkBootLid.TabIndex = 13;
checkBootLid.Text = Strings.Boot;
checkBootLid.UseVisualStyleBackColor = true;
//
// checkSleepLid
//
checkSleepLid.AutoSize = true;
checkSleepLid.Location = new Point(633, 137);
checkSleepLid.Dock = DockStyle.Fill;
checkSleepLid.Location = new Point(714, 137);
checkSleepLid.Name = "checkSleepLid";
checkSleepLid.Padding = new Padding(15, 2, 5, 2);
checkSleepLid.Size = new Size(125, 40);
checkSleepLid.Size = new Size(231, 40);
checkSleepLid.TabIndex = 14;
checkSleepLid.Text = Strings.Sleep;
checkSleepLid.UseVisualStyleBackColor = true;
//
// checkShutdownLid
//
checkShutdownLid.AutoSize = true;
checkShutdownLid.Location = new Point(633, 183);
checkShutdownLid.Dock = DockStyle.Fill;
checkShutdownLid.Location = new Point(714, 183);
checkShutdownLid.Name = "checkShutdownLid";
checkShutdownLid.Padding = new Padding(15, 2, 5, 2);
checkShutdownLid.Size = new Size(174, 40);
checkShutdownLid.Size = new Size(231, 40);
checkShutdownLid.TabIndex = 15;
checkShutdownLid.Text = Strings.Shutdown;
checkShutdownLid.UseVisualStyleBackColor = true;
//
// groupOther
//
groupOther.Controls.Add(checkKeyboardAuto);
groupOther.Controls.Add(checkUSBC);
groupOther.Controls.Add(checkNoOverdrive);
groupOther.Controls.Add(checkKeyboardAuto);
groupOther.Controls.Add(checkTopmost);
groupOther.Dock = DockStyle.Top;
groupOther.Location = new Point(10, 727);
groupOther.Location = new Point(10, 768);
groupOther.Name = "groupOther";
groupOther.Size = new Size(848, 293);
groupOther.Size = new Size(954, 276);
groupOther.TabIndex = 2;
groupOther.TabStop = false;
groupOther.Text = "Other";
//
// checkKeyboardAuto
//
checkKeyboardAuto.AutoSize = true;
checkKeyboardAuto.Location = new Point(25, 53);
checkKeyboardAuto.MaximumSize = new Size(780, 0);
checkKeyboardAuto.Name = "checkKeyboardAuto";
checkKeyboardAuto.Size = new Size(712, 36);
checkKeyboardAuto.TabIndex = 46;
checkKeyboardAuto.Text = Strings.KeyboardAuto;
checkKeyboardAuto.UseVisualStyleBackColor = true;
//
// checkUSBC
//
checkUSBC.AutoSize = true;
@@ -585,17 +617,6 @@ namespace GHelper
checkNoOverdrive.Text = Strings.DisableOverdrive;
checkNoOverdrive.UseVisualStyleBackColor = true;
//
// checkKeyboardAuto
//
checkKeyboardAuto.AutoSize = true;
checkKeyboardAuto.Location = new Point(25, 52);
checkKeyboardAuto.MaximumSize = new Size(780, 0);
checkKeyboardAuto.Name = "checkKeyboardAuto";
checkKeyboardAuto.Size = new Size(712, 36);
checkKeyboardAuto.TabIndex = 2;
checkKeyboardAuto.Text = Strings.KeyboardAuto;
checkKeyboardAuto.UseVisualStyleBackColor = true;
//
// checkTopmost
//
checkTopmost.AutoSize = true;
@@ -610,7 +631,9 @@ namespace GHelper
//
AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(868, 1011);
AutoSize = true;
AutoSizeMode = AutoSizeMode.GrowAndShrink;
ClientSize = new Size(974, 1059);
Controls.Add(groupOther);
Controls.Add(groupLight);
Controls.Add(groupBindings);
@@ -618,6 +641,7 @@ namespace GHelper
MaximizeBox = false;
MdiChildrenMinimizedAnchorBottom = false;
MinimizeBox = false;
MinimumSize = new Size(1000, 0);
Name = "Extra";
Padding = new Padding(10);
ShowIcon = false;
@@ -630,11 +654,11 @@ namespace GHelper
groupLight.PerformLayout();
panelBacklightExtra.ResumeLayout(false);
panelBacklightExtra.PerformLayout();
((System.ComponentModel.ISupportInitialize)numericBacklightTime).EndInit();
((System.ComponentModel.ISupportInitialize)trackBrightness).EndInit();
panelXMG.ResumeLayout(false);
panelXMG.PerformLayout();
tableBacklight.ResumeLayout(false);
tableBacklight.PerformLayout();
groupOther.ResumeLayout(false);
groupOther.PerformLayout();
ResumeLayout(false);
@@ -656,7 +680,6 @@ namespace GHelper
private GroupBox groupLight;
private GroupBox groupOther;
private CheckBox checkTopmost;
private CheckBox checkKeyboardAuto;
private CheckBox checkNoOverdrive;
private PictureBox pictureHelp;
private CheckBox checkUSBC;
@@ -688,5 +711,8 @@ namespace GHelper
private RComboBox comboKeyboardSpeed;
private Panel panelXMG;
private CheckBox checkXMG;
private Label labelBacklightTimeout;
private NumericUpDown numericBacklightTime;
private CheckBox checkKeyboardAuto;
}
}

View File

@@ -186,7 +186,18 @@ namespace GHelper
checkXMG.Checked = !(Program.config.getConfig("xmg_light") == 0);
checkXMG.CheckedChanged += CheckXMG_CheckedChanged;
int kb_timeout = Program.config.getConfig("keyboard_light_tiomeout");
numericBacklightTime.Value = (kb_timeout >= 0) ? kb_timeout : 60;
numericBacklightTime.ValueChanged += NumericBacklightTime_ValueChanged;
}
private void NumericBacklightTime_ValueChanged(object? sender, EventArgs e)
{
Program.RunAsAdmin("extra");
Program.config.setConfig("keyboard_light_tiomeout", (int)numericBacklightTime.Value);
Aura.SetBacklightOffDelay((int)numericBacklightTime.Value);
}
private void CheckXMG_CheckedChanged(object? sender, EventArgs e)
@@ -272,11 +283,6 @@ namespace GHelper
if (checkSleepLogo.Checked) flags.Add(AuraDev19b6.SleepLogo);
if (checkShutdownLogo.Checked) flags.Add(AuraDev19b6.ShutdownLogo);
flags.Add(AuraDev19b6.Unknown1);
flags.Add(AuraDev19b6.Unknown2);
flags.Add(AuraDev19b6.Unknown3);
flags.Add(AuraDev19b6.Unknown4);
Aura.ApplyAuraPower(flags);
}

View File

@@ -15,6 +15,8 @@ namespace GHelper
static int MinRPM, MaxRPM;
const int fansMax = 100;
NvidiaGpuControl? nvControl = null;
public Fans()
@@ -107,7 +109,7 @@ namespace GHelper
InitFans();
InitPower();
InitBoost();
InitGPU();
InitGPU(true);
comboBoost.SelectedValueChanged += ComboBoost_Changed;
@@ -119,10 +121,11 @@ namespace GHelper
private void TrackGPU_MouseUp(object? sender, MouseEventArgs e)
{
Program.settingsForm.AutoGPUSettings(true);
Program.settingsForm.SetGPUPower();
Program.settingsForm.SetGPUClocks(true);
}
public void InitGPU()
public void InitGPU(bool readClocks = false)
{
if (HardwareControl.GpuControl is not null && HardwareControl.GpuControl.IsNvidia)
{
@@ -138,17 +141,32 @@ namespace GHelper
{
panelGPU.Visible = true;
nvControl.GetClocks(out int core, out int memory, out string gpuTitle);
trackGPUCore.Value = Math.Max(Math.Min(core, NvidiaGpuControl.MaxCoreOffset), NvidiaGpuControl.MinCoreOffset);
trackGPUMemory.Value = Math.Max(Math.Min(memory, NvidiaGpuControl.MaxMemoryOffset), NvidiaGpuControl.MinMemoryOffset);
labelGPU.Text = gpuTitle;
int gpu_boost = Program.config.getConfigPerf("gpu_boost");
int gpu_temp = Program.config.getConfigPerf("gpu_temp");
int core = Program.config.getConfigPerf("gpu_core");
int memory = Program.config.getConfigPerf("gpu_memory");
if (gpu_boost < 0) gpu_boost = ASUSWmi.MaxGPUBoost;
if (gpu_temp < 0) gpu_temp = ASUSWmi.MaxGPUTemp;
if (core == -1) core = 0;
if (memory == -1) memory = 0;
//if (readClocks)
//{
int status = nvControl.GetClocks(out int current_core, out int current_memory);
if (status != -1)
{
core = current_core;
memory = current_memory;
}
labelGPU.Text = nvControl.FullName;
//}
trackGPUCore.Value = Math.Max(Math.Min(core, NvidiaGpuControl.MaxCoreOffset), NvidiaGpuControl.MinCoreOffset);
trackGPUMemory.Value = Math.Max(Math.Min(memory, NvidiaGpuControl.MaxMemoryOffset), NvidiaGpuControl.MinMemoryOffset);
trackGPUBoost.Value = Math.Max(Math.Min(gpu_boost, ASUSWmi.MaxGPUBoost), ASUSWmi.MinGPUBoost);
trackGPUTemp.Value = Math.Max(Math.Min(gpu_temp, ASUSWmi.MaxGPUTemp), ASUSWmi.MinGPUTemp);
@@ -225,7 +243,7 @@ namespace GHelper
chart.ChartAreas[0].AxisX.Interval = 10;
chart.ChartAreas[0].AxisY.Minimum = 0;
chart.ChartAreas[0].AxisY.Maximum = 100;
chart.ChartAreas[0].AxisY.Maximum = fansMax;
chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", 7F);
@@ -234,10 +252,10 @@ namespace GHelper
chart.ChartAreas[0].AxisX.LineColor = chartGrid;
chart.ChartAreas[0].AxisY.LineColor = chartGrid;
for (int i = 0; i <= 90; i += 10)
for (int i = 0; i <= fansMax-10; i += 10)
chart.ChartAreas[0].AxisY.CustomLabels.Add(i - 2, i + 2, ChartPercToRPM(i));
chart.ChartAreas[0].AxisY.CustomLabels.Add(98, 102, Properties.Strings.RPM);
chart.ChartAreas[0].AxisY.CustomLabels.Add(fansMax-2, fansMax+2, Properties.Strings.RPM);
chart.ChartAreas[0].AxisY.Interval = 10;
@@ -444,11 +462,16 @@ namespace GHelper
int mode = Program.config.getConfig("performance_mode");
byte[] curve = Program.config.getFanConfig(device);
if (def == 1 || curve.Length != 16)
if (def == 1 || ASUSWmi.IsEmptyCurve(curve))
{
curve = Program.wmi.GetFanCurve(device, mode);
if (ASUSWmi.IsEmptyCurve(curve))
curve = Program.config.getDefaultCurve(device);
if (curve.Length != 16 || curve.All(singleByte => singleByte == 0))
curve = Program.config.getDefaultCurve(device);
curve = ASUSWmi.FixFanCurve(curve);
}
//Debug.WriteLine(BitConverter.ToString(curve));
@@ -502,7 +525,14 @@ namespace GHelper
trackGPUBoost.Value = ASUSWmi.MaxGPUBoost;
trackGPUTemp.Value = ASUSWmi.MaxGPUTemp;
Program.settingsForm.AutoGPUSettings(true);
Program.config.setConfigPerf("gpu_boost", trackGPUBoost.Value);
Program.config.setConfigPerf("gpu_temp", trackGPUTemp.Value);
Program.config.setConfigPerf("gpu_core", trackGPUCore.Value);
Program.config.setConfigPerf("gpu_memory", trackGPUMemory.Value);
VisualiseGPUSettings();
Program.settingsForm.SetGPUClocks(true);
Program.settingsForm.SetGPUPower();
}
private void ChartCPU_MouseUp(object? sender, MouseEventArgs e)
@@ -554,7 +584,7 @@ namespace GHelper
if (dx > 100) dx = 100;
if (dy < 0) dy = 0;
if (dy > 100) dy = 100;
if (dy > fansMax) dy = fansMax;
dymin = (dx - 65) * 1.2;

View File

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

View File

@@ -11,7 +11,7 @@ public class AmdGpuControl : IGpuControl {
public bool IsNvidia => false;
public string FullName => _internalDiscreteAdapter!.AdapterName;
public AmdGpuControl() {
if (!Adl2.Load())
return;

View File

@@ -3,6 +3,7 @@
public interface IGpuControl : IDisposable {
bool IsNvidia { get; }
bool IsValid { get; }
public string FullName { get; }
int? GetCurrentTemperature();
int? GetGpuUse();
}

View File

@@ -1,9 +1,12 @@
using NvAPIWrapper.GPU;
using NvAPIWrapper.Native;
using NvAPIWrapper.Native.Delegates;
using NvAPIWrapper.Native.GPU;
using NvAPIWrapper.Native.GPU.Structures;
using NvAPIWrapper.Native.Interfaces.GPU;
using System;
using System.Diagnostics;
using System.Management;
using static NvAPIWrapper.Native.GPU.Structures.PerformanceStates20InfoV1;
namespace GHelper.Gpu;
@@ -28,6 +31,8 @@ public class NvidiaGpuControl : IGpuControl
public bool IsNvidia => IsValid;
public string FullName => _internalGpu!.FullName;
public int? GetCurrentTemperature()
{
if (!IsValid)
@@ -46,25 +51,83 @@ public class NvidiaGpuControl : IGpuControl
}
public void GetClocks(out int core, out int memory, out string gpu)
public int GetClocks(out int core, out int memory)
{
PhysicalGPU internalGpu = _internalGpu!;
gpu = internalGpu.FullName;
//Logger.WriteLine(internalGpu.FullName);
//Logger.WriteLine(internalGpu.ArchitectInformation.ToString());
Logger.WriteLine(internalGpu.FullName);
Logger.WriteLine(internalGpu.ArchitectInformation.ToString());
try
{
IPerformanceStates20Info states = GPUApi.GetPerformanceStates20(internalGpu.Handle);
core = states.Clocks[PerformanceStateId.P0_3DPerformance][0].FrequencyDeltaInkHz.DeltaValue / 1000;
memory = states.Clocks[PerformanceStateId.P0_3DPerformance][1].FrequencyDeltaInkHz.DeltaValue / 1000;
Logger.WriteLine($"GET GPU CLOCKS: {core}, {memory}");
return 0;
IPerformanceStates20Info states = GPUApi.GetPerformanceStates20(internalGpu.Handle);
} catch (Exception ex)
{
Logger.WriteLine("GET GPU CLOCKS:" + ex.Message);
core = memory = 0;
return -1;
}
//Logger.WriteLine("IPerformanceStates20Info type : " + states.GetType());
}
core = states.Clocks[PerformanceStateId.P0_3DPerformance][0].FrequencyDeltaInkHz.DeltaValue / 1000;
memory = states.Clocks[PerformanceStateId.P0_3DPerformance][1].FrequencyDeltaInkHz.DeltaValue / 1000;
private static void RunCMD(string name, string args)
{
var cmd = new Process();
cmd.StartInfo.UseShellExecute = false;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
cmd.StartInfo.FileName = name;
cmd.StartInfo.Arguments = args;
cmd.Start();
Logger.WriteLine(cmd.StandardOutput.ReadToEnd());
cmd.WaitForExit();
}
Logger.WriteLine($"GET GPU Clock offsets : {core}, {memory}");
public bool RestartGPUPnP()
{
if (!IsValid) return false;
try
{
PhysicalGPU internalGpu = _internalGpu!;
var pnpDeviceId = internalGpu.BusInformation.PCIIdentifiers.ToString();
Logger.WriteLine("Device ID:" + pnpDeviceId);
RunCMD("pnputil", $"/disable-device /deviceid \"{pnpDeviceId}\"");
Thread.Sleep(3000);
RunCMD("pnputil", $"/enable-device /deviceid \"{pnpDeviceId}\"");
Thread.Sleep(2000);
return true;
}
catch (Exception ex)
{
Logger.WriteLine(ex.ToString());
return false;
}
}
public bool RestartGPU()
{
try
{
string script = @"$device = Get-PnpDevice | Where-Object { $_.FriendlyName -imatch 'NVIDIA' -and $_.Class -eq 'Display' }; Disable-PnpDevice $device.InstanceId -Confirm:$false; Start-Sleep -Seconds 3; Enable-PnpDevice $device.InstanceId -Confirm:$false";
Logger.WriteLine(script);
RunCMD("powershell", script);
//Thread.Sleep(2000);
return true;
}
catch (Exception ex )
{
Logger.WriteLine(ex.ToString());
return false;
}
}
public int SetClocksFromConfig()
@@ -86,7 +149,7 @@ public class NvidiaGpuControl : IGpuControl
var coreClock = new PerformanceStates20ClockEntryV1(PublicClockDomain.Graphics, new PerformanceStates20ParameterDelta(core * 1000));
var memoryClock = new PerformanceStates20ClockEntryV1(PublicClockDomain.Memory, new PerformanceStates20ParameterDelta(memory * 1000));
PerformanceStates20ClockEntryV1[] clocks = { coreClock , memoryClock};
PerformanceStates20ClockEntryV1[] clocks = { coreClock, memoryClock };
PerformanceStates20BaseVoltageEntryV1[] voltages = { };
PerformanceState20[] performanceStates = { new PerformanceState20(PerformanceStateId.P0_3DPerformance, clocks, voltages) };
@@ -95,12 +158,12 @@ public class NvidiaGpuControl : IGpuControl
try
{
Logger.WriteLine($"SET GPU CLOCKS: {core}, {memory}");
GPUApi.SetPerformanceStates20(internalGpu.Handle, overclock);
Logger.WriteLine($"SET GPU Clock offsets : {core}, {memory}");
}
catch (Exception ex)
{
Logger.WriteLine(ex.Message);
Logger.WriteLine("SET GPU CLOCKS: "+ex.Message);
return -1;
}

View File

@@ -51,6 +51,7 @@ public static class HardwareControl
try
{
int? gpuUse = GpuControl?.GetGpuUse();
Logger.WriteLine("GPU usage: " + GpuControl?.FullName + " " + gpuUse + "%");
if (gpuUse is not null) return (int)gpuUse;
}
catch (Exception ex)
@@ -81,9 +82,9 @@ public static class HardwareControl
cpuTemp = ct.NextValue() - 273;
}
}
catch
catch (Exception ex)
{
Debug.WriteLine("Failed reading CPU temp");
Debug.WriteLine("Failed reading CPU temp :" + ex.Message);
}
try
@@ -94,8 +95,7 @@ public static class HardwareControl
catch (Exception ex)
{
gpuTemp = -1;
Debug.WriteLine("Failed reading GPU temp");
Debug.WriteLine(ex.ToString());
Debug.WriteLine("Failed reading GPU temp :" + ex.Message);
}
if (gpuTemp is null || gpuTemp < 0)
@@ -114,7 +114,7 @@ public static class HardwareControl
}
}
public static bool IsUsedGPU(int threshold = 20)
public static bool IsUsedGPU(int threshold = 10)
{
if (GetGpuUse() > threshold)
{
@@ -133,7 +133,7 @@ public static class HardwareControl
return null;
}
public static void RecreateGpuControlWithDelay(int delay = 3)
public static void RecreateGpuControlWithDelay(int delay = 5)
{
// Re-enabling the discrete GPU takes a bit of time,
// so a simple workaround is to refresh again after that happens

View File

@@ -647,12 +647,14 @@ public class NativeMethods
//Logger.WriteLine(screen.DeviceName);
count++;
}
if (displayNum > 0 && count == 0) laptopScreen = defaultDevice;
}
catch (Exception ex)
{
Logger.WriteLine(ex.ToString());
Logger.WriteLine("Can't detect internal screen");
//laptopScreen = Screen.PrimaryScreen.DeviceName;
laptopScreen = Screen.PrimaryScreen.DeviceName;
}
@@ -761,6 +763,7 @@ public class NativeMethods
{
PowerSetActiveScheme(IntPtr.Zero, new Guid(scheme));
PowerSetActiveOverlayScheme(new Guid(scheme));
Logger.WriteLine(scheme);
}
public static void SetPowerScheme(int mode)

View File

@@ -0,0 +1,38 @@
using System.Text.RegularExpressions;
using System.Text;
namespace GHelper
{
public static class OptimizationService
{
public static void SetChargeLimit (int newValue)
{
// Set the path to the .ini file
string path = @"C:\ProgramData\ASUS\ASUS System Control Interface\ASUSOptimization\Customization.ini";
// Make a backup copy of the INI file
string backupPath = path + ".bak";
File.Copy(path, backupPath, true);
string fileContents = File.ReadAllText(path, Encoding.Unicode);
// Find the section [BatteryHealthCharging]
string sectionPattern = @"\[BatteryHealthCharging\]\s*(version=\d+)?\s+value=(\d+)";
Match sectionMatch = Regex.Match(fileContents, sectionPattern);
if (sectionMatch.Success)
{
// Replace the value with the new value
string oldValueString = sectionMatch.Groups[2].Value;
int oldValue = int.Parse(oldValueString);
string newSection = sectionMatch.Value.Replace($"value={oldValue}", $"value={newValue}");
// Replace the section in the file contents
fileContents = fileContents.Replace(sectionMatch.Value, newSection);
File.WriteAllText(path, fileContents, Encoding.Unicode);
}
}
}
}

View File

@@ -1,4 +1,3 @@
using GHelper.Gpu;
using Microsoft.Win32;
using System.Diagnostics;
using System.Globalization;
@@ -43,7 +42,7 @@ namespace GHelper
Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture;
Debug.WriteLine(CultureInfo.CurrentUICulture);
//Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("zh");
//Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("es");
CheckProcesses();
@@ -64,7 +63,7 @@ namespace GHelper
}
Logger.WriteLine("------------");
Logger.WriteLine("App launched: " + config.GetModel() + " :" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + (IsUserAdministrator()?"A":""));
Logger.WriteLine("App launched: " + config.GetModel() + " :" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + (IsUserAdministrator() ? "A" : ""));
Application.EnableVisualStyles();
@@ -253,6 +252,23 @@ namespace GHelper
}
}
static void TabletMode()
{
bool touchpadState, tabletState;
using (var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad\Status", false))
{
touchpadState = (key?.GetValue("Enabled")?.ToString() == "1");
}
tabletState = wmi.DeviceGet(ASUSWmi.TabletState) > 0;
Logger.WriteLine("Tablet: " + tabletState + " Touchpad: " + touchpadState);
if ((tabletState && touchpadState) || (!tabletState && !touchpadState))
wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.Touchpad_Toggle, "Touchpad");
}
static void WatcherEventArrived(object sender, EventArrivedEventArgs e)
{
@@ -278,6 +294,10 @@ namespace GHelper
case 179: // FN+F4
KeyProcess("fnf4");
return;
case 189: // Tablet mode
TabletMode();
return;
}
@@ -291,16 +311,19 @@ namespace GHelper
{
settingsForm.Show();
settingsForm.Activate();
settingsForm.VisualiseGPUMode();
if (action == "gpu")
switch (action)
{
Startup.ReScheduleAdmin();
settingsForm.FansToggle();
case "gpu":
Startup.ReScheduleAdmin();
settingsForm.FansToggle();
break;
case "gpurestart":
settingsForm.RestartGPU(false);
break;
}
}
settingsForm.VisualiseGPUMode();
}
static void TrayIcon_MouseClick(object? sender, MouseEventArgs e)
@@ -368,7 +391,7 @@ namespace GHelper
startInfo.Arguments = param;
startInfo.Verb = "runas";
Process.Start(startInfo);
//Application.Exit();
Application.Exit();
}
}
}

View File

@@ -825,6 +825,15 @@ namespace GHelper.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Something is using dGPU and preventing Eco mode. Restart dGPU in device manager? * Please proceed on your own risk..
/// </summary>
internal static string RestartGPU {
get {
return ResourceManager.GetString("RestartGPU", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to RPM.
/// </summary>

View File

@@ -270,6 +270,9 @@
<data name="GPUModeUltimate" xml:space="preserve">
<value>Exclusivo dGPU</value>
</data>
<data name="GPUSettings" xml:space="preserve">
<value>Ajustes de GPU</value>
</data>
<data name="KeyBindings" xml:space="preserve">
<value>Atajos de teclado</value>
</data>
@@ -288,6 +291,15 @@
<data name="LaptopScreen" xml:space="preserve">
<value>Pantalla del portátil</value>
</data>
<data name="Lid" xml:space="preserve">
<value>Tapa</value>
</data>
<data name="Lightbar" xml:space="preserve">
<value>Barra de luz</value>
</data>
<data name="Logo" xml:space="preserve">
<value>Logo</value>
</data>
<data name="MatrixBanner" xml:space="preserve">
<value>Banner binario</value>
</data>
@@ -388,7 +400,7 @@
<value>Alternar Aura</value>
</data>
<data name="ToggleMiniled" xml:space="preserve">
<value>Alternar Miniled (si es compatible)</value>
<value>Alternar Miniled (si comp.)</value>
</data>
<data name="ToggleScreen" xml:space="preserve">
<value>Alternar pantalla</value>

View File

@@ -372,6 +372,9 @@
<data name="Quit" xml:space="preserve">
<value>Quit</value>
</data>
<data name="RestartGPU" xml:space="preserve">
<value>Something is using dGPU and preventing Eco mode. Restart dGPU in device manager? * Please proceed on your own risk.</value>
</data>
<data name="RPM" xml:space="preserve">
<value>RPM</value>
</data>

View File

@@ -267,24 +267,25 @@ namespace GHelper
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.Location = new Point(380, 119);
labelModel.Margin = new Padding(8, 0, 8, 0);
labelModel.Name = "labelModel";
labelModel.Size = new Size(492, 32);
labelModel.Size = new Size(400, 32);
labelModel.TabIndex = 38;
labelModel.TextAlign = ContentAlignment.TopRight;
//
// labelVersion
//
labelVersion.AutoSize = true;
labelVersion.AutoSize = false;
labelVersion.Font = new Font("Segoe UI", 9F, FontStyle.Underline, GraphicsUnit.Point);
labelVersion.ForeColor = SystemColors.ControlDark;
labelVersion.Location = new Point(25, 119);
labelVersion.Margin = new Padding(8, 0, 8, 0);
labelVersion.Name = "labelVersion";
labelVersion.Size = new Size(44, 32);
labelVersion.Size = new Size(300, 32);
labelVersion.TabIndex = 37;
labelVersion.Text = "v.0";
labelVersion.Cursor = Cursors.Hand;
//
// labelBattery
//

View File

@@ -1,14 +1,12 @@
using CustomControls;
using GHelper.Gpu;
using Starlight.AnimeMatrix;
using System;
using System.Diagnostics;
using System.Drawing.Imaging;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Timers;
using System.Windows.Forms;
using Tools;
namespace GHelper
@@ -142,7 +140,7 @@ namespace GHelper
int trim = model.LastIndexOf("_");
if (trim > 0) model = model.Substring(0, trim);
labelModel.Text = model+(Program.IsUserAdministrator()?".":"");
labelModel.Text = model + (Program.IsUserAdministrator() ? "." : "");
TopMost = Program.config.getConfig("topmost") == 1;
@@ -161,7 +159,7 @@ namespace GHelper
contextMenuStrip.Items.Clear();
Padding padding = new Padding(5, 5, 5, 5);
Padding padding = new Padding(15, 5, 5, 5);
/*
TableLayoutPanel[] tables = { tablePerf, tableGPU };
@@ -248,7 +246,7 @@ namespace GHelper
quit.Margin = padding;
contextMenuStrip.Items.Add(quit);
contextMenuStrip.ShowCheckMargin = true;
//contextMenuStrip.ShowCheckMargin = true;
contextMenuStrip.RenderMode = ToolStripRenderMode.System;
if (CheckSystemDarkModeStatus())
@@ -297,10 +295,20 @@ namespace GHelper
var gitVersion = new Version(tag);
var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString());
//appVersion = new Version("0.50.0.0");
if (gitVersion.CompareTo(appVersion) > 0)
{
SetVersionLabel(Properties.Strings.DownloadUpdate + ": " + tag, url);
if (Program.config.getConfigString("skip_version") != tag)
{
DialogResult dialogResult = MessageBox.Show(Properties.Strings.DownloadUpdate + ": G-Helper " + tag + "?", "Update", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
AutoUpdate(url);
else
Program.config.setConfig("skip_version", tag);
}
}
else
{
@@ -317,6 +325,57 @@ namespace GHelper
}
void SetVersionLabel(string label, string url = null)
{
BeginInvoke(delegate
{
labelVersion.Text = label;
if (url is not null)
{
this.versionUrl = url;
labelVersion.ForeColor = Color.Red;
}
});
}
public async void AutoUpdate(string requestUri)
{
Uri uri = new Uri(requestUri);
string zipName = Path.GetFileName(uri.LocalPath);
string exeLocation = Application.ExecutablePath;
string exeDir = Path.GetDirectoryName(exeLocation);
string zipLocation = exeDir + "\\" + zipName;
using (WebClient client = new WebClient())
{
client.DownloadFile(uri, zipLocation);
}
var cmd = new Process();
cmd.StartInfo.UseShellExecute = false;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.FileName = "powershell";
cmd.StartInfo.Arguments = $"Start-Sleep -Seconds 1; Expand-Archive {zipLocation} -DestinationPath {exeDir} -Force; {exeLocation}";
cmd.Start();
Debug.WriteLine(requestUri);
Debug.WriteLine(zipLocation);
Application.Exit();
return;
}
private void LabelVersion_Click(object? sender, EventArgs e)
{
Process.Start(new ProcessStartInfo(versionUrl) { UseShellExecute = true });
}
private static void TrayIcon_MouseMove(object? sender, MouseEventArgs e)
{
Program.settingsForm.RefreshSensors();
@@ -422,22 +481,8 @@ namespace GHelper
}
void SetVersionLabel(string label, string url = null)
{
labelVersion.Text = label;
if (url is not null)
{
this.versionUrl = url;
labelVersion.ForeColor = Color.Red;
}
}
private void LabelVersion_Click(object? sender, EventArgs e)
{
Process.Start(new ProcessStartInfo(versionUrl) { UseShellExecute = true });
}
private void CheckStartup_CheckedChanged(object? sender, EventArgs e)
{
@@ -948,7 +993,7 @@ namespace GHelper
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;
@@ -1045,16 +1090,48 @@ namespace GHelper
}
public void AutoGPUSettings(bool launchAsAdmin = false)
public void SetGPUClocks(bool launchAsAdmin = true)
{
int gpu_core = Program.config.getConfigPerf("gpu_core");
int gpu_memory = Program.config.getConfigPerf("gpu_memory");
if (gpu_core == -1 && gpu_memory == -1) return;
//if ((gpu_core > -5 && gpu_core < 5) && (gpu_memory > -5 && gpu_memory < 5)) launchAsAdmin = false;
if (Program.wmi.DeviceGet(ASUSWmi.GPUEco) == 1) return;
if (HardwareControl.GpuControl is null) return;
if (!HardwareControl.GpuControl!.IsNvidia) return;
using NvidiaGpuControl nvControl = (NvidiaGpuControl)HardwareControl.GpuControl;
try
{
int getStatus = nvControl.GetClocks(out int current_core, out int current_memory);
if (getStatus != -1)
{
if (Math.Abs(gpu_core - current_core) < 5 && Math.Abs(gpu_memory - current_memory) < 5) return;
}
int setStatus = nvControl.SetClocks(gpu_core, gpu_memory);
if (launchAsAdmin && setStatus == -1) Program.RunAsAdmin("gpu");
}
catch (Exception ex)
{
Logger.WriteLine(ex.ToString());
}
}
public void SetGPUPower()
{
int gpu_boost = Program.config.getConfigPerf("gpu_boost");
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 (Program.wmi.DeviceGet(ASUSWmi.PPT_GPUC0) >= 0)
@@ -1067,23 +1144,6 @@ namespace GHelper
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)
@@ -1148,24 +1208,25 @@ namespace GHelper
customPower = 0;
if (Program.config.getConfigPerf("auto_apply_power") == 1)
{
if (delay > 0)
{
var timer = new System.Timers.Timer(1000);
timer.Elapsed += delegate
{
timer.Stop();
timer.Dispose();
SetPower();
};
timer.Start();
}
else
{
SetPower();
}
bool applyPower = Program.config.getConfigPerf("auto_apply_power") == 1;
bool applyGPU = true;
if (delay > 0)
{
var timer = new System.Timers.Timer(delay);
timer.Elapsed += delegate
{
timer.Stop();
timer.Dispose();
if (applyPower) SetPower();
SetGPUPower();
};
timer.Start();
}
else
{
if (applyPower) SetPower();
SetGPUPower();
}
}
@@ -1220,8 +1281,9 @@ namespace GHelper
}
}
SetGPUClocks();
AutoFans();
AutoGPUSettings();
AutoPower(1000);
@@ -1295,9 +1357,10 @@ namespace GHelper
SetScreen(1000, 1);
else
SetScreen(60, 0);
} else
}
else
{
SetScreen(overdrive : Program.config.getConfig("overdrive"));
SetScreen(overdrive: Program.config.getConfig("overdrive"));
}
@@ -1336,7 +1399,7 @@ namespace GHelper
if (eco == 1)
if ((GpuAuto && IsPlugged()) || (ForceGPU && GpuMode == ASUSWmi.GPUModeStandard))
{
SetEcoGPU(0);
SetGPUEco(0);
return true;
}
if (eco == 0)
@@ -1349,7 +1412,7 @@ namespace GHelper
if (dialogResult == DialogResult.No) return false;
}
SetEcoGPU(1);
SetGPUEco(1);
return true;
}
}
@@ -1360,15 +1423,16 @@ namespace GHelper
public bool ReEnableGPU()
{
if (Screen.AllScreens.Length <= 1) return false;
if (Program.config.getConfig("gpu_reenable") != 1) return false;
if (Screen.AllScreens.Length <= 1) return false;
Logger.WriteLine("Re-enabling gpu for 503 model");
Thread.Sleep(1000);
SetEcoGPU(1);
SetGPUEco(1);
Thread.Sleep(1000);
SetEcoGPU(0);
SetGPUEco(0);
return true;
}
@@ -1436,8 +1500,47 @@ namespace GHelper
}
public void RestartGPU(bool confirm = true)
{
if (HardwareControl.GpuControl is null) return;
if (!HardwareControl.GpuControl!.IsNvidia) return;
public void SetEcoGPU(int eco)
if (confirm)
{
DialogResult dialogResult = MessageBox.Show(Properties.Strings.RestartGPU, Properties.Strings.EcoMode, MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.No) return;
}
Program.RunAsAdmin("gpurestart");
if (!Program.IsUserAdministrator()) return;
Logger.WriteLine("Trying to restart dGPU");
Task.Run(async () =>
{
Program.settingsForm.BeginInvoke(delegate
{
labelTipGPU.Text = "Restarting GPU ...";
ButtonEnabled(buttonOptimized, false);
ButtonEnabled(buttonEco, false);
ButtonEnabled(buttonStandard, false);
ButtonEnabled(buttonUltimate, false);
});
var nvControl = (NvidiaGpuControl)HardwareControl.GpuControl;
bool status = nvControl.RestartGPU();
Program.settingsForm.BeginInvoke(delegate
{
labelTipGPU.Text = status ? "GPU Restarted, you can try Eco mode again" : "Failed to restart GPU";
InitGPUMode();
});
});
}
public void SetGPUEco(int eco, bool hardWay = false)
{
ButtonEnabled(buttonOptimized, false);
@@ -1447,10 +1550,11 @@ namespace GHelper
labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUChanging + " ...";
Task.Run(async () =>
{
int status;
if (eco == 1)
{
string[] tokill = { "EADesktop", "RadeonSoftware" };
@@ -1458,9 +1562,15 @@ namespace GHelper
foreach (var process in Process.GetProcessesByName(kill)) process.Kill();
}
Program.wmi.DeviceSet(ASUSWmi.GPUEco, eco, "GPUEco");
//if (eco == 1) status = 0; else
status = Program.wmi.SetGPUEco(eco);
await Task.Delay(TimeSpan.FromSeconds(1));
if (status == 0 && eco == 1 && hardWay)
{
RestartGPU();
}
await Task.Delay(TimeSpan.FromMilliseconds(500));
Program.settingsForm.BeginInvoke(delegate
{
InitGPUMode();
@@ -1468,7 +1578,11 @@ namespace GHelper
});
if (eco == 0)
HardwareControl.RecreateGpuControlWithDelay();
{
await Task.Delay(TimeSpan.FromMilliseconds(3000));
HardwareControl.RecreateGpuControl();
SetGPUClocks(false);
}
});
@@ -1514,13 +1628,13 @@ namespace GHelper
else if (GPUMode == ASUSWmi.GPUModeEco)
{
VisualiseGPUMode(GPUMode);
SetEcoGPU(1);
SetGPUEco(1, true);
changed = true;
}
else if (GPUMode == ASUSWmi.GPUModeStandard)
{
VisualiseGPUMode(GPUMode);
SetEcoGPU(0);
SetGPUEco(0);
changed = true;
}
@@ -1626,6 +1740,15 @@ namespace GHelper
sliderBattery.Value = limit;
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit, "BatteryLimit");
try
{
OptimizationService.SetChargeLimit(limit);
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
Program.config.setConfig("charge_limit", limit);
}

View File

@@ -94,11 +94,16 @@ Most probably either you are using Eco / Optimized mode and your dGPU is simply
#### It says, that app is already running
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 doesn't start / or crashes, what should I do ?
#### App doesn't 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 right click and save this [debloat.bat](https://raw.githubusercontent.com/seerge/g-helper/main/debloat.bat) and then right-click Run it As Admin. It will stop not mandatory asus services.
What you can also try is to open ``C:\ProgramData\ASUS\ASUS System Control Interface\ASUSOptimization\Customization.ini`` and find following section from that file : ``[BatteryHealthCharging] ... value=100`` and either delete it or put same value as you use in G-helper.
#### Can I use MyASUS app along with G-Helper?
Sure, 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.
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.
#### How do I set Mute Microphone to M3?
This function is handled by Asus Optimization Service (therefore G-helper doesn't interfere and doesn't touch this function). Make sure that this service is up and running
@@ -140,10 +145,12 @@ It's a lightweight Armoury Crate alternative for Asus laptops. A small utility t
- I recommend keeping "Asus Optimization Service" running, as it keeps basic laptop hotkeys such as screen or keyboard brightness adjustment working.
- Optionally(!) you can disable / remove unnecessary services by running [this debloat bat file](https://raw.githubusercontent.com/seerge/g-helper/main/debloat.bat) as admin. To restore services - run [this bloat bat file](https://raw.githubusercontent.com/seerge/g-helper/main/bloat.bat) instead.
- Optionally(!) you can disable / remove unnecessary services. Ruight click and save [debloat.bat](https://raw.githubusercontent.com/seerge/g-helper/main/debloat.bat). Then right click and Run it as Admin. To restore services - save and run [bloat.bat](https://raw.githubusercontent.com/seerge/g-helper/main/bloat.bat) instead.
- It's not recommended to use an app in combination with Armoury Crate services, because they adjust the same settings. You can [uninstall it using it's own uninstall tool](https://dlcdnets.asus.com/pub/ASUS/mb/14Utilities/Armoury_Crate_Uninstall_Tool.zip?model=armoury%20crate). Just in case, you can always install it back later.
- Also, it's not recommended to have "ASUS Smart Display Control" app running, as it will try to change refresh rates and fight with g-helper for the same function. You can safely uninstall it.
-------------------------------
Designed and developed for Asus Zephyrus G14 2022 (with AMD Radeon iGPU and dGPU). But could and should potentially work for G14 of 2021 and 2020, G15, X FLOW, and other ROG models for relevant and supported features.