mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2025-12-06 07:12:01 +01:00
74 lines
2.4 KiB
C#
74 lines
2.4 KiB
C#
using CommonHelpers;
|
|
using PowerControl.Helpers;
|
|
|
|
namespace PowerControl.Options
|
|
{
|
|
public static class FPSLimit
|
|
{
|
|
public static Menu.MenuItemWithOptions Instance = new Menu.MenuItemWithOptions()
|
|
{
|
|
Name = "FPS Limit",
|
|
PersistentKey = "FPSLimit",
|
|
ApplyDelay = 500,
|
|
ResetValue = () => { return "Off"; },
|
|
OptionsValues = delegate ()
|
|
{
|
|
var refreshRate = DisplayResolutionController.GetRefreshRate();
|
|
return new string[]
|
|
{
|
|
(refreshRate / 4).ToString(),
|
|
(refreshRate / 2).ToString(),
|
|
refreshRate.ToString(),
|
|
"Off"
|
|
};
|
|
},
|
|
CurrentValue = delegate ()
|
|
{
|
|
try
|
|
{
|
|
if (!Dependencies.EnsureRTSS(null))
|
|
return "?";
|
|
|
|
RTSS.LoadProfile();
|
|
if (RTSS.GetProfileProperty("FramerateLimit", out int framerate))
|
|
return (framerate == 0) ? "Off" : framerate.ToString();
|
|
return null;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#if DEBUG
|
|
CommonHelpers.Log.TraceException("RTSS", e);
|
|
#endif
|
|
return "?";
|
|
}
|
|
},
|
|
ApplyValue = (selected) =>
|
|
{
|
|
try
|
|
{
|
|
if (!Dependencies.EnsureRTSS(Controller.TitleWithVersion))
|
|
return null;
|
|
|
|
int framerate = 0;
|
|
if (selected != "Off")
|
|
framerate = int.Parse(selected);
|
|
|
|
RTSS.LoadProfile();
|
|
if (!RTSS.SetProfileProperty("FramerateLimit", framerate))
|
|
return null;
|
|
if (!RTSS.GetProfileProperty("FramerateLimit", out framerate))
|
|
return null;
|
|
RTSS.SaveProfile();
|
|
RTSS.UpdateProfiles();
|
|
return (framerate == 0) ? "Off" : framerate.ToString();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
CommonHelpers.Log.TraceException("RTSS", e);
|
|
}
|
|
return null;
|
|
}
|
|
};
|
|
}
|
|
}
|