Removed ACPI requirement for non-asus models https://github.com/seerge/g-helper/issues/1676

This commit is contained in:
Serge
2023-12-03 12:17:07 +01:00
parent 013c83fd60
commit 84c7fdb3bf
3 changed files with 41 additions and 27 deletions

View File

@@ -451,4 +451,8 @@ public static class AppConfig
return ContainsModel("FA507"); return ContainsModel("FA507");
} }
public static bool IsASUS()
{
return ContainsModel("ROG") || ContainsModel("TUF") || ContainsModel("Vivobook") || ContainsModel("Zenbook");
}
} }

View File

@@ -1,5 +1,4 @@
using FftSharp; using GHelper;
using GHelper;
using GHelper.USB; using GHelper.USB;
using System.Management; using System.Management;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -186,6 +185,7 @@ public class AsusACPI
private static extern bool WaitForSingleObject(IntPtr hHandle, int dwMilliseconds); private static extern bool WaitForSingleObject(IntPtr hHandle, int dwMilliseconds);
private IntPtr eventHandle; private IntPtr eventHandle;
private bool _connected = false;
// still works only with asus optimization service on , if someone knows how to get ACPI events from asus without that - let me know // still works only with asus optimization service on , if someone knows how to get ACPI events from asus without that - let me know
public void RunListener() public void RunListener()
@@ -212,8 +212,14 @@ public class AsusACPI
} }
} }
public bool IsConnected()
{
return _connected;
}
public AsusACPI() public AsusACPI()
{
try
{ {
handle = CreateFile( handle = CreateFile(
FILE_NAME, FILE_NAME,
@@ -225,9 +231,14 @@ public class AsusACPI
IntPtr.Zero IntPtr.Zero
); );
if (handle == new IntPtr(-1)) //handle = new IntPtr(-1);
//throw new Exception("ERROR");
_connected = true;
}
catch (Exception ex)
{ {
throw new Exception("Can't connect to ACPI"); Logger.WriteLine($"Can't connect to ACPI: {ex.Message}");
} }
if (AppConfig.IsAdvantageEdition()) MaxTotal = 250; if (AppConfig.IsAdvantageEdition()) MaxTotal = 250;

View File

@@ -64,11 +64,12 @@ namespace GHelper
ProcessHelper.CheckAlreadyRunning(); ProcessHelper.CheckAlreadyRunning();
try Logger.WriteLine("------------");
{ Logger.WriteLine("App launched: " + AppConfig.GetModel() + " :" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + CultureInfo.CurrentUICulture + (ProcessHelper.IsUserAdministrator() ? "." : ""));
acpi = new AsusACPI(); acpi = new AsusACPI();
}
catch if (!acpi.IsConnected() && AppConfig.IsASUS())
{ {
DialogResult dialogResult = MessageBox.Show(Properties.Strings.ACPIError, Properties.Strings.StartupError, MessageBoxButtons.YesNo); DialogResult dialogResult = MessageBox.Show(Properties.Strings.ACPIError, Properties.Strings.StartupError, MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
@@ -80,9 +81,6 @@ namespace GHelper
return; return;
} }
Logger.WriteLine("------------");
Logger.WriteLine("App launched: " + AppConfig.GetModel() + " :" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + CultureInfo.CurrentUICulture + (ProcessHelper.IsUserAdministrator() ? "." : ""));
Application.EnableVisualStyles(); Application.EnableVisualStyles();
HardwareControl.RecreateGpuControl(); HardwareControl.RecreateGpuControl();
@@ -154,6 +152,7 @@ namespace GHelper
} }
private static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e) private static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
{ {
gpuControl.StandardModeFix(); gpuControl.StandardModeFix();