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,22 +212,33 @@ public class AsusACPI
} }
} }
public bool IsConnected()
{
return _connected;
}
public AsusACPI() public AsusACPI()
{ {
handle = CreateFile( try
FILE_NAME,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
IntPtr.Zero,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
IntPtr.Zero
);
if (handle == new IntPtr(-1))
{ {
throw new Exception("Can't connect to ACPI"); handle = CreateFile(
FILE_NAME,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
IntPtr.Zero,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
IntPtr.Zero
);
//handle = new IntPtr(-1);
//throw new Exception("ERROR");
_connected = true;
}
catch (Exception ex)
{
Logger.WriteLine($"Can't connect to ACPI: {ex.Message}");
} }
if (AppConfig.IsAdvantageEdition()) MaxTotal = 250; if (AppConfig.IsAdvantageEdition()) MaxTotal = 250;
@@ -390,7 +401,7 @@ public class AsusACPI
byte min = (byte)(curve[8] * 255 / 100); byte min = (byte)(curve[8] * 255 / 100);
byte max = (byte)(curve[15] * 255 / 100); byte max = (byte)(curve[15] * 255 / 100);
byte[] range = { min, max}; byte[] range = { min, max };
int result; int result;
switch (device) switch (device)

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();