From d1546d1dc8fb5cd1bc1bbf7b484d5a5802fdc1c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Thu, 12 Jan 2023 23:01:01 +0100 Subject: [PATCH] PowerControl: Improve handling of `?` settings --- PowerControl/Menu/MenuItemWithOptions.cs | 10 +++++++++- PowerControl/Options/CPUFrequency.cs | 1 + PowerControl/Options/GPUFrequency.cs | 5 ++++- PowerControl/Options/TDP.cs | 4 ++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/PowerControl/Menu/MenuItemWithOptions.cs b/PowerControl/Menu/MenuItemWithOptions.cs index cd12065..5928c34 100644 --- a/PowerControl/Menu/MenuItemWithOptions.cs +++ b/PowerControl/Menu/MenuItemWithOptions.cs @@ -105,7 +105,15 @@ namespace PowerControl.Menu if (ApplyValue != null && SelectedOption != null) { - ActiveOption = ApplyValue(SelectedOption); + try + { + ActiveOption = ApplyValue(SelectedOption); + } + catch (Exception e) + { + CommonHelpers.Log.TraceException("FinalizeSet", Name, e); + Update(); + } if (AfterApply != null && runAfterApply) AfterApply(); diff --git a/PowerControl/Options/CPUFrequency.cs b/PowerControl/Options/CPUFrequency.cs index cfaf91a..466534c 100644 --- a/PowerControl/Options/CPUFrequency.cs +++ b/PowerControl/Options/CPUFrequency.cs @@ -32,6 +32,7 @@ namespace PowerControl.Options switch (selected.ToString()) { + case "?": case "Default": sd.MinCPUClock = 1400; sd.MaxCPUClock = 3500; diff --git a/PowerControl/Options/GPUFrequency.cs b/PowerControl/Options/GPUFrequency.cs index 2ea04ba..3f5cc42 100644 --- a/PowerControl/Options/GPUFrequency.cs +++ b/PowerControl/Options/GPUFrequency.cs @@ -23,6 +23,9 @@ namespace PowerControl.Options "Leave the game if it uses anti-cheat protection.")) return null; + if (selected == "?") + selected = "Default"; + return CommonHelpers.Instance.WithGlobalMutex(200, () => { using (var sd = VangoghGPU.Open()) @@ -30,7 +33,7 @@ namespace PowerControl.Options if (sd is null) return null; - if (selected == "Default") + if (selected == "Default" || selected == "?") { sd.HardMinGfxClock = 200; return selected; diff --git a/PowerControl/Options/TDP.cs b/PowerControl/Options/TDP.cs index 6d85e21..1e6346c 100644 --- a/PowerControl/Options/TDP.cs +++ b/PowerControl/Options/TDP.cs @@ -23,6 +23,10 @@ namespace PowerControl.Options "Leave the game if it uses anti-cheat protection.")) return null; + // If undefined, select max + if (selected == "?") + selected = "15W"; + uint mW = uint.Parse(selected.Replace("W", "")) * 1000; if (VangoghGPU.IsSupported)