mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-04-04 22:07:40 +00:00
PowerControl: All options accept String
This commit is contained in:
parent
29e373d169
commit
81d4be30ce
17 changed files with 120 additions and 125 deletions
|
|
@ -5,17 +5,16 @@ namespace PowerControl.Options
|
|||
public static Menu.MenuItemWithOptions Instance = new Menu.MenuItemWithOptions()
|
||||
{
|
||||
Name = "Brightness",
|
||||
Options = { 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100 },
|
||||
Options = { "0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100" },
|
||||
CycleOptions = false,
|
||||
CurrentValue = delegate ()
|
||||
{
|
||||
return Helpers.WindowsSettingsBrightnessController.Get(5.0);
|
||||
return Helpers.WindowsSettingsBrightnessController.Get(5.0).ToString();
|
||||
},
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
Helpers.WindowsSettingsBrightnessController.Set((int)selected);
|
||||
|
||||
return Helpers.WindowsSettingsBrightnessController.Get(5.0);
|
||||
Helpers.WindowsSettingsBrightnessController.Set(int.Parse(selected));
|
||||
return Helpers.WindowsSettingsBrightnessController.Get(5.0).ToString();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace PowerControl.Options
|
|||
ActiveOption = "?",
|
||||
Visible = VangoghGPU.IsSupported,
|
||||
ResetValue = () => { return "Default"; },
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
if (!Settings.Default.AckAntiCheat(
|
||||
Controller.TitleWithVersion,
|
||||
|
|
@ -21,7 +21,7 @@ namespace PowerControl.Options
|
|||
)
|
||||
return null;
|
||||
|
||||
return CommonHelpers.Instance.WithGlobalMutex<object>(200, () =>
|
||||
return CommonHelpers.Instance.WithGlobalMutex<string>(200, () =>
|
||||
{
|
||||
using (var sd = VangoghGPU.Open())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,9 +13,12 @@ namespace PowerControl.Options
|
|||
OptionsValues = delegate ()
|
||||
{
|
||||
var refreshRate = DisplayResolutionController.GetRefreshRate();
|
||||
return new object[]
|
||||
return new string[]
|
||||
{
|
||||
refreshRate / 4, refreshRate / 2, refreshRate, "Off"
|
||||
(refreshRate / 4).ToString(),
|
||||
(refreshRate / 2).ToString(),
|
||||
refreshRate.ToString(),
|
||||
"Off"
|
||||
};
|
||||
},
|
||||
CurrentValue = delegate ()
|
||||
|
|
@ -24,18 +27,18 @@ namespace PowerControl.Options
|
|||
{
|
||||
RTSS.LoadProfile();
|
||||
if (RTSS.GetProfileProperty("FramerateLimit", out int framerate))
|
||||
return (framerate == 0) ? "Off" : framerate;
|
||||
return (framerate == 0) ? "Off" : framerate.ToString();
|
||||
}
|
||||
catch { }
|
||||
return null;
|
||||
},
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
int framerate = 0;
|
||||
if (selected != null && selected.ToString() != "Off")
|
||||
framerate = (int)selected;
|
||||
if (selected != "Off")
|
||||
framerate = int.Parse(selected);
|
||||
|
||||
RTSS.LoadProfile();
|
||||
if (!RTSS.SetProfileProperty("FramerateLimit", framerate))
|
||||
|
|
@ -44,7 +47,7 @@ namespace PowerControl.Options
|
|||
return null;
|
||||
RTSS.SaveProfile();
|
||||
RTSS.UpdateProfiles();
|
||||
return (framerate == 0) ? "Off" : framerate;
|
||||
return (framerate == 0) ? "Off" : framerate.ToString();
|
||||
}
|
||||
catch { }
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -10,19 +10,19 @@ namespace PowerControl.Options
|
|||
ApplyDelay = 500,
|
||||
OptionsValues = delegate ()
|
||||
{
|
||||
return Enum.GetValues<FanMode>().Select(item => (object)item).ToArray();
|
||||
return Enum.GetNames<FanMode>();
|
||||
},
|
||||
CurrentValue = delegate ()
|
||||
{
|
||||
if (SharedData<FanModeSetting>.GetExistingValue(out var value))
|
||||
return value.Current;
|
||||
return value.Current.ToString();
|
||||
return null;
|
||||
},
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
if (!SharedData<FanModeSetting>.GetExistingValue(out var value))
|
||||
return null;
|
||||
value.Desired = (FanMode)selected;
|
||||
value.Desired = Enum.Parse<FanMode>(selected);
|
||||
if (!SharedData<FanModeSetting>.SetExistingValue(value))
|
||||
return null;
|
||||
return selected;
|
||||
|
|
|
|||
|
|
@ -8,19 +8,19 @@ namespace PowerControl.Options
|
|||
{
|
||||
Name = "Colors",
|
||||
ApplyDelay = 1000,
|
||||
Options = Enum.GetValues<DCE.Mode>().Cast<object>().ToList(),
|
||||
Options = Enum.GetNames<DCE.Mode>(),
|
||||
CurrentValue = delegate ()
|
||||
{
|
||||
return DCE.Current;
|
||||
return DCE.Current.ToString();
|
||||
},
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
if (DCE.Current is null)
|
||||
return null;
|
||||
|
||||
DCE.Current = (DCE.Mode)selected;
|
||||
DCE.Current = Enum.Parse<DCE.Mode>(selected);
|
||||
RadeonSoftware.Kill();
|
||||
return DCE.Current;
|
||||
return DCE.Current.ToString();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace PowerControl.Options
|
|||
Visible = VangoghGPU.IsSupported,
|
||||
ActiveOption = "?",
|
||||
ResetValue = () => { return "Default"; },
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
if (!Settings.Default.AckAntiCheat(
|
||||
Controller.TitleWithVersion,
|
||||
|
|
@ -21,20 +21,20 @@ namespace PowerControl.Options
|
|||
)
|
||||
return null;
|
||||
|
||||
return CommonHelpers.Instance.WithGlobalMutex<object>(200, () =>
|
||||
return CommonHelpers.Instance.WithGlobalMutex<string>(200, () =>
|
||||
{
|
||||
using (var sd = VangoghGPU.Open())
|
||||
{
|
||||
if (sd is null)
|
||||
return null;
|
||||
|
||||
if (selected.ToString() == "Default")
|
||||
if (selected == "Default")
|
||||
{
|
||||
sd.HardMinGfxClock = 200;
|
||||
return selected;
|
||||
}
|
||||
|
||||
sd.HardMinGfxClock = uint.Parse(selected.ToString()?.Replace("MHz", "") ?? "200");
|
||||
sd.HardMinGfxClock = uint.Parse(selected.Replace("MHz", ""));
|
||||
return selected;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,24 +8,24 @@ namespace PowerControl.Options
|
|||
{
|
||||
Name = "GPU Scaling",
|
||||
ApplyDelay = 1000,
|
||||
Options = Enum.GetValues<GPUScaling.ScalingMode>().Cast<object>().Prepend("Off").ToArray(),
|
||||
Options = Enum.GetNames<GPUScaling.ScalingMode>().Prepend("Off").ToArray(),
|
||||
CurrentValue = delegate ()
|
||||
{
|
||||
if (!GPUScaling.IsSupported)
|
||||
return null;
|
||||
if (!GPUScaling.Enabled)
|
||||
return "Off";
|
||||
return GPUScaling.Mode;
|
||||
return GPUScaling.Mode.ToString();
|
||||
},
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
if (!GPUScaling.IsSupported)
|
||||
return null;
|
||||
|
||||
if (selected is GPUScaling.ScalingMode)
|
||||
GPUScaling.Mode = (GPUScaling.ScalingMode)selected;
|
||||
else
|
||||
if (selected == "Off")
|
||||
GPUScaling.Enabled = false;
|
||||
else
|
||||
GPUScaling.Mode = Enum.Parse<GPUScaling.ScalingMode>(selected);
|
||||
|
||||
// Since the RadeonSoftware will try to revert values
|
||||
RadeonSoftware.Kill();
|
||||
|
|
@ -37,7 +37,7 @@ namespace PowerControl.Options
|
|||
|
||||
if (!GPUScaling.Enabled)
|
||||
return "Off";
|
||||
return GPUScaling.Mode;
|
||||
return GPUScaling.Mode.ToString();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,19 +10,19 @@ namespace PowerControl.Options
|
|||
ApplyDelay = 500,
|
||||
OptionsValues = delegate ()
|
||||
{
|
||||
return Enum.GetValues<OverlayEnabled>().Select(item => (object)item).ToArray();
|
||||
return Enum.GetNames<OverlayEnabled>();
|
||||
},
|
||||
CurrentValue = delegate ()
|
||||
{
|
||||
if (SharedData<OverlayModeSetting>.GetExistingValue(out var value))
|
||||
return value.CurrentEnabled;
|
||||
return value.CurrentEnabled.ToString();
|
||||
return null;
|
||||
},
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
if (!SharedData<OverlayModeSetting>.GetExistingValue(out var value))
|
||||
return null;
|
||||
value.DesiredEnabled = (OverlayEnabled)selected;
|
||||
value.DesiredEnabled = Enum.Parse<OverlayEnabled>(selected);
|
||||
if (!SharedData<OverlayModeSetting>.SetExistingValue(value))
|
||||
return null;
|
||||
return selected;
|
||||
|
|
@ -35,19 +35,19 @@ namespace PowerControl.Options
|
|||
ApplyDelay = 500,
|
||||
OptionsValues = delegate ()
|
||||
{
|
||||
return Enum.GetValues<OverlayMode>().Select(item => (object)item).ToArray();
|
||||
return Enum.GetNames<OverlayMode>();
|
||||
},
|
||||
CurrentValue = delegate ()
|
||||
{
|
||||
if (SharedData<OverlayModeSetting>.GetExistingValue(out var value))
|
||||
return value.Current;
|
||||
return value.Current.ToString();
|
||||
return null;
|
||||
},
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
if (!SharedData<OverlayModeSetting>.GetExistingValue(out var value))
|
||||
return null;
|
||||
value.Desired = (OverlayMode)selected;
|
||||
value.Desired = Enum.Parse<OverlayMode>(selected);
|
||||
if (!SharedData<OverlayModeSetting>.SetExistingValue(value))
|
||||
return null;
|
||||
return selected;
|
||||
|
|
@ -60,19 +60,19 @@ namespace PowerControl.Options
|
|||
ApplyDelay = 500,
|
||||
OptionsValues = delegate ()
|
||||
{
|
||||
return Enum.GetValues<KernelDriversLoaded>().Select(item => (object)item).ToArray();
|
||||
return Enum.GetNames<KernelDriversLoaded>();
|
||||
},
|
||||
CurrentValue = delegate ()
|
||||
{
|
||||
if (SharedData<OverlayModeSetting>.GetExistingValue(out var value))
|
||||
return value.KernelDriversLoaded;
|
||||
return value.KernelDriversLoaded.ToString();
|
||||
return null;
|
||||
},
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
if (!SharedData<OverlayModeSetting>.GetExistingValue(out var value))
|
||||
return null;
|
||||
value.DesiredKernelDriversLoaded = (KernelDriversLoaded)selected;
|
||||
value.DesiredKernelDriversLoaded = Enum.Parse<KernelDriversLoaded>(selected);
|
||||
if (!SharedData<OverlayModeSetting>.SetExistingValue(value))
|
||||
return null;
|
||||
return selected;
|
||||
|
|
|
|||
|
|
@ -9,25 +9,25 @@ namespace PowerControl.Options
|
|||
{
|
||||
Name = "Refresh Rate",
|
||||
ApplyDelay = 1000,
|
||||
ResetValue = () => { return DisplayResolutionController.GetRefreshRates().Max(); },
|
||||
ResetValue = () => { return DisplayResolutionController.GetRefreshRates().Max().ToString(); },
|
||||
OptionsValues = delegate ()
|
||||
{
|
||||
var refreshRates = DisplayResolutionController.GetRefreshRates();
|
||||
if (refreshRates.Count() > 1)
|
||||
return refreshRates.Select(item => (object)item).ToArray();
|
||||
return refreshRates.Select(item => item.ToString()).ToArray();
|
||||
return null;
|
||||
},
|
||||
CurrentValue = delegate ()
|
||||
{
|
||||
return DisplayResolutionController.GetRefreshRate();
|
||||
return DisplayResolutionController.GetRefreshRate().ToString();
|
||||
},
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
DisplayResolutionController.SetRefreshRate((int)selected);
|
||||
DisplayResolutionController.SetRefreshRate(int.Parse(selected));
|
||||
// force reset and refresh of FPS limit
|
||||
FPSLimit.Instance.Reset();
|
||||
FPSLimit.Instance.Update();
|
||||
return DisplayResolutionController.GetRefreshRate();
|
||||
return DisplayResolutionController.GetRefreshRate().ToString();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,30 +13,31 @@ namespace PowerControl.Options
|
|||
{
|
||||
if (!GPUScaling.SafeResolutionChange && !Settings.Default.EnableExperimentalFeatures)
|
||||
return null;
|
||||
return DisplayResolutionController.GetAllResolutions().Last();
|
||||
return DisplayResolutionController.GetAllResolutions().Last().ToString();
|
||||
},
|
||||
OptionsValues = delegate ()
|
||||
{
|
||||
var resolutions = DisplayResolutionController.GetAllResolutions();
|
||||
if (resolutions.Count() > 1)
|
||||
return resolutions.Select(item => (object)item).ToArray();
|
||||
return resolutions.Select(item => item.ToString()).ToArray();
|
||||
return null;
|
||||
},
|
||||
CurrentValue = delegate ()
|
||||
{
|
||||
if (!GPUScaling.SafeResolutionChange && !Settings.Default.EnableExperimentalFeatures)
|
||||
return null;
|
||||
return DisplayResolutionController.GetResolution();
|
||||
return DisplayResolutionController.GetResolution().ToString();
|
||||
},
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
DisplayResolutionController.SetResolution((DisplayResolutionController.DisplayResolution)selected);
|
||||
var selectedResolution = new DisplayResolutionController.DisplayResolution(selected);
|
||||
DisplayResolutionController.SetResolution(selectedResolution);
|
||||
// force refresh Refresh Rate
|
||||
RefreshRate.Instance.Update();
|
||||
// force reset and refresh of FPS limit
|
||||
FPSLimit.Instance.Reset();
|
||||
FPSLimit.Instance.Update();
|
||||
return DisplayResolutionController.GetResolution();
|
||||
return DisplayResolutionController.GetResolution().ToString();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace PowerControl.Options
|
|||
|
||||
return ProcessorCores.IsUsingSMT(processId) ? "Yes" : "No";
|
||||
},
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
if (!RTSS.IsOSDForeground(out var processId))
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace PowerControl.Options
|
|||
return null;
|
||||
return value.Value ? "On" : "Off";
|
||||
},
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
ImageSharpening.Enabled = (string)selected == "On";
|
||||
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ namespace PowerControl.Options
|
|||
return value.CurrentProfile.Length > 0 ? value.CurrentProfile : null;
|
||||
return null;
|
||||
},
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
if (!SharedData<SteamControllerSetting>.GetExistingValue(out var value))
|
||||
return null;
|
||||
value.DesiredProfile = (String)selected;
|
||||
value.DesiredProfile = selected;
|
||||
if (!SharedData<SteamControllerSetting>.SetExistingValue(value))
|
||||
return null;
|
||||
return selected;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace PowerControl.Options
|
|||
ApplyDelay = 1000,
|
||||
ResetValue = () => { return "15W"; },
|
||||
ActiveOption = "?",
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
if (!Settings.Default.AckAntiCheat(
|
||||
Controller.TitleWithVersion,
|
||||
|
|
@ -21,15 +21,11 @@ namespace PowerControl.Options
|
|||
)
|
||||
return null;
|
||||
|
||||
var selectedText = selected.ToString();
|
||||
if (selectedText is null)
|
||||
return null;
|
||||
|
||||
uint mW = uint.Parse(selectedText.Replace("W", "")) * 1000;
|
||||
uint mW = uint.Parse(selected.Replace("W", "")) * 1000;
|
||||
|
||||
if (VangoghGPU.IsSupported)
|
||||
{
|
||||
return CommonHelpers.Instance.WithGlobalMutex<object>(200, () =>
|
||||
return CommonHelpers.Instance.WithGlobalMutex<string>(200, () =>
|
||||
{
|
||||
using (var sd = VangoghGPU.Open())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,21 +5,21 @@ namespace PowerControl.Options
|
|||
public static Menu.MenuItemWithOptions Instance = new Menu.MenuItemWithOptions()
|
||||
{
|
||||
Name = "Volume",
|
||||
Options = { 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100 },
|
||||
Options = { "0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100" },
|
||||
CycleOptions = false,
|
||||
CurrentValue = delegate ()
|
||||
{
|
||||
try { return Helpers.AudioManager.GetMasterVolume(5.0); }
|
||||
try { return Helpers.AudioManager.GetMasterVolume(5.0).ToString(); }
|
||||
catch (Exception) { return null; }
|
||||
},
|
||||
ApplyValue = delegate (object selected)
|
||||
ApplyValue = (selected) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Helpers.AudioManager.SetMasterVolumeMute(false);
|
||||
Helpers.AudioManager.SetMasterVolume((int)selected);
|
||||
Helpers.AudioManager.SetMasterVolume(int.Parse(selected));
|
||||
|
||||
return Helpers.AudioManager.GetMasterVolume(5.0);
|
||||
return Helpers.AudioManager.GetMasterVolume(5.0).ToString();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue