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");
}
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 System.Management;
using System.Runtime.InteropServices;
@@ -186,6 +185,7 @@ public class AsusACPI
private static extern bool WaitForSingleObject(IntPtr hHandle, int dwMilliseconds);
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
public void RunListener()
@@ -212,8 +212,14 @@ public class AsusACPI
}
}
public bool IsConnected()
{
return _connected;
}
public AsusACPI()
{
try
{
handle = CreateFile(
FILE_NAME,
@@ -225,9 +231,14 @@ public class AsusACPI
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;

View File

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