mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-04-21 06:03:52 +00:00
PowerControl: Allow user to configure selectable TDP, CPU and GPU from PowerControl.dll.ini
This commit is contained in:
parent
bec6b3538e
commit
6240ee4c46
5 changed files with 168 additions and 49 deletions
|
|
@ -5,16 +5,40 @@ namespace PowerControl.Options
|
|||
{
|
||||
public static class CPUFrequency
|
||||
{
|
||||
public const string SoftMin = "SoftMin";
|
||||
public const string SoftMax = "SoftMax";
|
||||
|
||||
public const int DefaultMin = 1400;
|
||||
public const int DefaultMax = 3500;
|
||||
|
||||
public static PersistedOptions UserOptions()
|
||||
{
|
||||
var options = new PersistedOptions("CPUFrequency");
|
||||
|
||||
if (options.GetOptions().Count() == 0)
|
||||
{
|
||||
options.SetOptions(new PersistedOptions.Option[]
|
||||
{
|
||||
options.ForOption("Default").Set(SoftMin, DefaultMin).Set(SoftMax, DefaultMax),
|
||||
options.ForOption("Power-Save").Set(SoftMin, 1400).Set(SoftMax, 1800),
|
||||
options.ForOption("Balanced").Set(SoftMin, 2200).Set(SoftMax, 2800),
|
||||
options.ForOption("Max").Set(SoftMin, 3000).Set(SoftMax, 3500),
|
||||
});
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
public static Menu.MenuItemWithOptions Instance = new Menu.MenuItemWithOptions()
|
||||
{
|
||||
Name = "CPU",
|
||||
PersistentKey = "CPUFrequency",
|
||||
PersistOnCreate = false,
|
||||
Options = { "Default", "Power-Save", "Balanced", "Max" },
|
||||
OptionsValues = () => { return UserOptions().GetOptions(); },
|
||||
ApplyDelay = 1000,
|
||||
ActiveOption = "?",
|
||||
Visible = VangoghGPU.IsSupported,
|
||||
ResetValue = () => { return "Default"; },
|
||||
ResetValue = () => { return UserOptions().GetOptions().FirstOrDefault("Default"); },
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
if (!AntiCheatSettings.Default.AckAntiCheat(
|
||||
|
|
@ -23,6 +47,13 @@ namespace PowerControl.Options
|
|||
"Leave the game if it uses anti-cheat protection."))
|
||||
return null;
|
||||
|
||||
var selectedOption = UserOptions().ForOption(selected);
|
||||
if (!selectedOption.Exist)
|
||||
return null;
|
||||
|
||||
var softMin = selectedOption.Get(SoftMin, DefaultMin);
|
||||
var softMax = selectedOption.Get(SoftMax, DefaultMax);
|
||||
|
||||
return CommonHelpers.Instance.WithGlobalMutex<string>(200, () =>
|
||||
{
|
||||
using (var sd = VangoghGPU.Open())
|
||||
|
|
@ -30,32 +61,8 @@ namespace PowerControl.Options
|
|||
if (sd is null)
|
||||
return null;
|
||||
|
||||
switch (selected.ToString())
|
||||
{
|
||||
case "?":
|
||||
case "Default":
|
||||
sd.MinCPUClock = 1400;
|
||||
sd.MaxCPUClock = 3500;
|
||||
break;
|
||||
|
||||
case "Power-Save":
|
||||
sd.MinCPUClock = 1400;
|
||||
sd.MaxCPUClock = 1800;
|
||||
break;
|
||||
|
||||
case "Balanced":
|
||||
sd.MinCPUClock = 2200;
|
||||
sd.MaxCPUClock = 2800;
|
||||
break;
|
||||
|
||||
case "Max":
|
||||
sd.MinCPUClock = 3000;
|
||||
sd.MaxCPUClock = 3500;
|
||||
break;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
sd.MinCPUClock = (uint)softMin;
|
||||
sd.MaxCPUClock = (uint)softMax;
|
||||
return selected;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue