mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
XGM Fixes
This commit is contained in:
@@ -353,10 +353,14 @@ public class AsusACPI
|
||||
|
||||
}
|
||||
|
||||
public static bool IsInvalidCurve(byte[] curve)
|
||||
{
|
||||
return curve.Length != 16 || IsEmptyCurve(curve);
|
||||
}
|
||||
|
||||
public static bool IsEmptyCurve(byte[] curve)
|
||||
{
|
||||
return curve.Length != 16 || curve.All(singleByte => singleByte == 0);
|
||||
return curve.All(singleByte => singleByte == 0);
|
||||
}
|
||||
|
||||
public static byte[] FixFanCurve(byte[] curve)
|
||||
@@ -397,6 +401,7 @@ public class AsusACPI
|
||||
|
||||
public bool IsXGConnected()
|
||||
{
|
||||
//return true;
|
||||
return DeviceGet(GPUXGConnected) == 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -288,13 +288,16 @@ namespace GHelper
|
||||
public static int SetXGM(byte[] msg)
|
||||
{
|
||||
|
||||
Logger.WriteLine("XGM Payload :" + BitConverter.ToString(msg));
|
||||
//Logger.WriteLine("XGM Payload :" + BitConverter.ToString(msg));
|
||||
|
||||
var payload = new byte[300];
|
||||
Array.Copy(msg, payload, msg.Length);
|
||||
|
||||
foreach (HidDevice device in GetHidDevices(new int[] { 0x1970 }, 0))
|
||||
{
|
||||
device.OpenDevice();
|
||||
Logger.WriteLine("XGM " + device.Attributes.ProductHexId + device.Capabilities.FeatureReportByteLength + ":" + BitConverter.ToString(msg));
|
||||
device.WriteFeatureData(msg);
|
||||
Logger.WriteLine("XGM " + device.Attributes.ProductHexId + "|" + device.Capabilities.FeatureReportByteLength + ":" + BitConverter.ToString(msg));
|
||||
device.WriteFeatureData(payload);
|
||||
device.CloseDevice();
|
||||
return 1;
|
||||
}
|
||||
@@ -316,7 +319,7 @@ namespace GHelper
|
||||
public static int SetXGMFan(byte[] curve)
|
||||
{
|
||||
|
||||
if (AsusACPI.IsEmptyCurve(curve)) return -1;
|
||||
if (AsusACPI.IsInvalidCurve(curve)) return -1;
|
||||
|
||||
byte[] msg = new byte[19];
|
||||
Array.Copy(new byte[] { 0x5e, 0xd1, 0x01 }, msg, 3);
|
||||
|
||||
@@ -30,11 +30,6 @@ namespace CustomControls
|
||||
|
||||
public bool darkTheme = false;
|
||||
|
||||
public RForm()
|
||||
{
|
||||
DoubleBuffered = true;
|
||||
}
|
||||
|
||||
public static void InitColors(bool darkTheme)
|
||||
{
|
||||
if (darkTheme)
|
||||
|
||||
@@ -507,11 +507,11 @@ namespace GHelper
|
||||
int mode = AppConfig.getConfig("performance_mode");
|
||||
byte[] curve = AppConfig.getFanConfig(device);
|
||||
|
||||
if (reset || AsusACPI.IsEmptyCurve(curve))
|
||||
if (reset || AsusACPI.IsInvalidCurve(curve))
|
||||
{
|
||||
curve = Program.acpi.GetFanCurve(device, mode);
|
||||
|
||||
if (AsusACPI.IsEmptyCurve(curve))
|
||||
if (AsusACPI.IsInvalidCurve(curve))
|
||||
curve = AppConfig.getDefaultCurve(device);
|
||||
|
||||
curve = AsusACPI.FixFanCurve(curve);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<AssemblyVersion>0.65</AssemblyVersion>
|
||||
<AssemblyVersion>0.66</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
||||
@@ -6,13 +6,13 @@ using Tools;
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
public class EventDispatcher
|
||||
public class InputDispatcher
|
||||
{
|
||||
|
||||
private static bool isOptimizationRunning = OptimizationService.IsRunning();
|
||||
private static nint windowHandle;
|
||||
|
||||
public EventDispatcher(nint handle)
|
||||
public InputDispatcher(nint handle)
|
||||
{
|
||||
|
||||
windowHandle = handle;
|
||||
@@ -30,7 +30,7 @@ namespace GHelper
|
||||
private static long lastTheme;
|
||||
private static long lastAdmin;
|
||||
|
||||
public static EventDispatcher eventDispatcher;
|
||||
public static InputDispatcher inputDispatcher;
|
||||
|
||||
private static PowerLineStatus isPlugged = PowerLineStatus.Unknown;
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace GHelper
|
||||
|
||||
trayIcon.MouseClick += TrayIcon_MouseClick;
|
||||
|
||||
eventDispatcher = new EventDispatcher(ds);
|
||||
inputDispatcher = new InputDispatcher(ds);
|
||||
|
||||
settingsForm.InitAura();
|
||||
settingsForm.InitMatrix();
|
||||
@@ -92,7 +92,6 @@ namespace GHelper
|
||||
unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(ds, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||
|
||||
|
||||
|
||||
if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\') || action.Length > 0)
|
||||
{
|
||||
SettingsToggle(action);
|
||||
|
||||
@@ -115,6 +115,9 @@ namespace GHelper
|
||||
buttonUltimate.MouseMove += ButtonUltimate_MouseHover;
|
||||
buttonUltimate.MouseLeave += ButtonGPU_MouseLeave;
|
||||
|
||||
tableGPU.MouseMove += ButtonXGM_MouseMove;
|
||||
tableGPU.MouseLeave += ButtonGPU_MouseLeave;
|
||||
|
||||
buttonXGM.Click += ButtonXGM_Click;
|
||||
|
||||
buttonScreenAuto.MouseMove += ButtonScreenAuto_MouseHover;
|
||||
@@ -266,19 +269,40 @@ namespace GHelper
|
||||
|
||||
private void ButtonXGM_Click(object? sender, EventArgs e)
|
||||
{
|
||||
if (Program.acpi.DeviceGet(AsusACPI.GPUXG) == 1)
|
||||
{
|
||||
Program.acpi.DeviceSet(AsusACPI.GPUXG, 0, "GPU XGM");
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.acpi.DeviceSet(AsusACPI.GPUXG, 1, "GPU XGM");
|
||||
|
||||
if (AppConfig.getConfigPerf("auto_apply") == 1)
|
||||
AsusUSB.SetXGMFan(AppConfig.getFanConfig(AsusFan.XGM));
|
||||
}
|
||||
|
||||
InitXGM();
|
||||
Task.Run(async () =>
|
||||
{
|
||||
BeginInvoke(delegate
|
||||
{
|
||||
ButtonEnabled(buttonOptimized, false);
|
||||
ButtonEnabled(buttonEco, false);
|
||||
ButtonEnabled(buttonStandard, false);
|
||||
ButtonEnabled(buttonUltimate, false);
|
||||
ButtonEnabled(buttonXGM, false);
|
||||
});
|
||||
|
||||
if (Program.acpi.DeviceGet(AsusACPI.GPUXG) == 1)
|
||||
{
|
||||
Program.acpi.DeviceSet(AsusACPI.GPUXG, 0, "GPU XGM");
|
||||
await Task.Delay(TimeSpan.FromSeconds(15));
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.acpi.DeviceSet(AsusACPI.GPUXG, 1, "GPU XGM");
|
||||
await Task.Delay(TimeSpan.FromSeconds(15));
|
||||
|
||||
if (AppConfig.getConfigPerf("auto_apply") == 1)
|
||||
AsusUSB.SetXGMFan(AppConfig.getFanConfig(AsusFan.XGM));
|
||||
}
|
||||
|
||||
BeginInvoke(delegate
|
||||
{
|
||||
InitGPUMode();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void SliderBattery_ValueChanged(object? sender, EventArgs e)
|
||||
@@ -440,6 +464,18 @@ namespace GHelper
|
||||
labelTipGPU.Text = "";
|
||||
}
|
||||
|
||||
private void ButtonXGM_MouseMove(object? sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender is null) return;
|
||||
TableLayoutPanel table = (TableLayoutPanel)sender;
|
||||
|
||||
if (!buttonXGM.Visible) return;
|
||||
|
||||
labelTipGPU.Text = buttonXGM.Bounds.Contains(table.PointToClient(Cursor.Position)) ?
|
||||
"XGMobile toggle works only in Standard mode" : "";
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ButtonOptimized_Click(object? sender, EventArgs e)
|
||||
{
|
||||
@@ -1331,8 +1367,13 @@ namespace GHelper
|
||||
|
||||
public void InitXGM()
|
||||
{
|
||||
|
||||
buttonXGM.Enabled = buttonXGM.Visible = Program.acpi.IsXGConnected();
|
||||
buttonXGM.Activated = (Program.acpi.DeviceGet(AsusACPI.GPUXG) == 1);
|
||||
|
||||
int activated = Program.acpi.DeviceGet(AsusACPI.GPUXG);
|
||||
if (activated < 0) return;
|
||||
|
||||
buttonXGM.Activated = (activated == 1);
|
||||
|
||||
if (buttonXGM.Activated)
|
||||
{
|
||||
@@ -1340,6 +1381,12 @@ namespace GHelper
|
||||
ButtonEnabled(buttonEco, false);
|
||||
ButtonEnabled(buttonStandard, false);
|
||||
ButtonEnabled(buttonUltimate, false);
|
||||
} else
|
||||
{
|
||||
ButtonEnabled(buttonOptimized, true);
|
||||
ButtonEnabled(buttonEco, true);
|
||||
ButtonEnabled(buttonStandard, true);
|
||||
ButtonEnabled(buttonUltimate, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1431,6 +1478,7 @@ namespace GHelper
|
||||
ButtonEnabled(buttonEco, false);
|
||||
ButtonEnabled(buttonStandard, false);
|
||||
ButtonEnabled(buttonUltimate, false);
|
||||
ButtonEnabled(buttonXGM, false);
|
||||
|
||||
labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUChanging + " ...";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user