From a3e235e886284c09b7cdb34613320e944646bc2b Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Tue, 6 Jun 2023 10:59:49 +0200 Subject: [PATCH] Added PPT fix for M16, G17 (2023) and F15 (2022) --- app/GHelper.csproj | 2 +- app/Settings.cs | 31 ++++++++++++++++++++---------- app/Slider.cs | 2 +- app/Updates.cs | 47 ++++++++++++++++++++++++++-------------------- 4 files changed, 50 insertions(+), 32 deletions(-) diff --git a/app/GHelper.csproj b/app/GHelper.csproj index 9170ec4b..151bc1c3 100644 --- a/app/GHelper.csproj +++ b/app/GHelper.csproj @@ -16,7 +16,7 @@ AnyCPU False True - 0.79 + 0.80 diff --git a/app/Settings.cs b/app/Settings.cs index 1bd6afe2..57177851 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -1191,19 +1191,30 @@ namespace GHelper public void AutoPower(int delay = 0) { - // fix for misbehaving bios PPTs on G513 - if (AppConfig.ContainsModel("G513") && AppConfig.getConfigPerf("auto_apply") != 1) - { - AutoFans(true); - delay = 500; - } - customPower = 0; - bool applyPower = AppConfig.getConfigPerf("auto_apply_power") == 1; - bool applyGPU = true; + bool applyPower = (AppConfig.getConfigPerf("auto_apply_power") == 1); + //bool applyGPU = true; + + if (applyPower) + { + // fix for misbehaving bios PPTs on G513 + if (AppConfig.ContainsModel("G513") && AppConfig.getConfigPerf("auto_apply") != 1) + { + AutoFans(true); + delay = 500; + } + + // Fix for models that don't support PPT settings in all modes + if (AppConfig.ContainsModel("GU603") || AppConfig.ContainsModel("GU604") || AppConfig.ContainsModel("FX517") || AppConfig.ContainsModel("G733")) + { + Program.acpi.DeviceSet(AsusACPI.PerformanceMode, AsusACPI.PerformanceManual, "CustomMode"); + if (AppConfig.getConfigPerf("auto_apply") != 1) AutoFans(true); + delay = 500; + } + + } - //if (applyPower) Program.acpi.DeviceSet(AsusACPI.PerformanceMode, AsusACPI.PerformanceManual, "CustomMode"); if (delay > 0) { diff --git a/app/Slider.cs b/app/Slider.cs index 062e1e28..203a615f 100644 --- a/app/Slider.cs +++ b/app/Slider.cs @@ -106,7 +106,7 @@ namespace WinFormsSliderBar private void RecalculateParameters() { _radius = 0.4F * ClientSize.Height; - _barSize = new SizeF(ClientSize.Width - 4 * _radius, ClientSize.Height * 0.15F); + _barSize = new SizeF(ClientSize.Width - 2 * _radius, ClientSize.Height * 0.15F); _barPos = new PointF(_radius, (ClientSize.Height - _barSize.Height) / 2); _thumbPos = new PointF( _barSize.Width / (Max - Min) * (Value - Min) + _barPos.X, diff --git a/app/Updates.cs b/app/Updates.cs index 450c2ccf..464e1fba 100644 --- a/app/Updates.cs +++ b/app/Updates.cs @@ -44,34 +44,41 @@ namespace GHelper } private Dictionary GetDeviceVersions() { - ManagementObjectSearcher objSearcher = new ManagementObjectSearcher("Select * from Win32_PnPSignedDriver"); - ManagementObjectCollection objCollection = objSearcher.Get(); - Dictionary list = new(); - - foreach (ManagementObject obj in objCollection) + using (ManagementObjectSearcher objSearcher = new ManagementObjectSearcher("Select * from Win32_PnPSignedDriver")) { - if (obj["DeviceID"] is not null && obj["DriverVersion"] is not null) - list[obj["DeviceID"].ToString()] = obj["DriverVersion"].ToString(); - } + using (ManagementObjectCollection objCollection = objSearcher.Get()) + { + Dictionary list = new(); - return list; + foreach (ManagementObject obj in objCollection) + { + if (obj["DeviceID"] is not null && obj["DriverVersion"] is not null) + list[obj["DeviceID"].ToString()] = obj["DriverVersion"].ToString(); + } + + return list; + } + } } private string GetBiosVersion() { - ManagementObjectSearcher objSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS"); - ManagementObjectCollection objCollection = objSearcher.Get(); - - foreach (ManagementObject obj in objCollection) - if (obj["SMBIOSBIOSVersion"] is not null) + using (ManagementObjectSearcher objSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS")) + { + using (ManagementObjectCollection objCollection = objSearcher.Get()) { - var bios = obj["SMBIOSBIOSVersion"].ToString(); - int trim = bios.LastIndexOf("."); - if (trim > 0) return bios.Substring(trim + 1); - else return bios; - } + foreach (ManagementObject obj in objCollection) + if (obj["SMBIOSBIOSVersion"] is not null) + { + var bios = obj["SMBIOSBIOSVersion"].ToString(); + int trim = bios.LastIndexOf("."); + if (trim > 0) return bios.Substring(trim + 1); + else return bios; + } - return ""; + return ""; + } + } } public async void DriversAsync(string url, int type, TableLayoutPanel table)