From dcfaf665cd456029bd35a9b284529467b24f9067 Mon Sep 17 00:00:00 2001 From: seerge Date: Sun, 2 Apr 2023 22:50:13 +0200 Subject: [PATCH] Force GPU mode --- app/Program.cs | 12 ++++++++++-- app/Settings.cs | 36 +++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/app/Program.cs b/app/Program.cs index 57ebdf096..d9bd5f95d 100644 --- a/app/Program.cs +++ b/app/Program.cs @@ -67,7 +67,6 @@ public static void Main() wmi.SubscribeToEvents(WatcherEventArrived); - settingsForm.InitGPUMode(); settingsForm.InitAura(); settingsForm.InitMatrix(); @@ -79,6 +78,10 @@ public static void Main() SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged; + // Subscribing for monitor power on events + var settingGuid = new NativeMethods.PowerSettingGuid(); + unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(ds, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE); + if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\')) { @@ -129,7 +132,12 @@ public static void SetAutoModes() settingsForm.AutoPerformance(); bool switched = settingsForm.AutoGPUMode(); - if (!switched) settingsForm.AutoScreen(); + + if (!switched) + { + settingsForm.InitGPUMode(); + settingsForm.AutoScreen(); + } settingsForm.AutoKeyboard(); settingsForm.SetMatrix(); diff --git a/app/Settings.cs b/app/Settings.cs index 2b7930b87..6a067f0a6 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -120,10 +120,6 @@ public SettingsForm() aTimer = new System.Timers.Timer(1000); aTimer.Elapsed += OnTimedEvent; - // Subscribing for monitor power on events - var settingGuid = new NativeMethods.PowerSettingGuid(); - Program.unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(Handle, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE); - SetVersionLabel("Version: " + Assembly.GetExecutingAssembly().GetName().Version); string model = Program.config.GetModel(); @@ -1049,7 +1045,11 @@ public bool AutoGPUMode() var Plugged = SystemInformation.PowerStatus.PowerLineStatus; bool GpuAuto = Program.config.getConfig("gpu_auto") == 1; - if (!GpuAuto) return false; + bool ForceGPU = Program.config.ContainsModel("503"); + + int GpuMode = Program.config.getConfig("gpu_mode"); + + if (!GpuAuto && !ForceGPU) return false; int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco); int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux); @@ -1058,16 +1058,18 @@ public bool AutoGPUMode() return false; else { - if (eco == 1 && Plugged == PowerLineStatus.Online) // Eco going Standard on plugged - { - SetEcoGPU(0); - return true; - } - else if (eco == 0 && Plugged != PowerLineStatus.Online) // Standard going Eco on plugged - { - SetEcoGPU(1); - return true; - } + if (eco == 1) + if ((GpuAuto && Plugged == PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeStandard)) + { + SetEcoGPU(0); + return true; + } + if (eco == 0) + if ((GpuAuto && Plugged != PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeEco)) + { + SetEcoGPU(1); + return true; + } } return false; @@ -1096,8 +1098,8 @@ public int InitGPUMode() int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco); int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux); - //Logger.WriteLine("Eco flag : " + eco); - //Logger.WriteLine("Mux flag : " + mux); + Logger.WriteLine("Eco flag : " + eco); + Logger.WriteLine("Mux flag : " + mux); int GpuMode;