steam-deck-tools/PowerControl/Options/SteamController.cs
Kamil Trzciński 2ff2864f23 PowerControl: Expose all settings and apply them in order
Since some settings impact others, the application will
apply them in a correct order with a fixed delay.

This additionally exposes all settings, just some of them
are not persisted on create, only on change.
2023-01-10 12:01:33 +01:00

37 lines
1.2 KiB
C#

using CommonHelpers;
namespace PowerControl.Options
{
public static class SteamController
{
public static Menu.MenuItemWithOptions Instance = new Menu.MenuItemWithOptions()
{
Name = "Controller",
PersistentKey = "SteamController",
PersistOnCreate = false,
ApplyDelay = 500,
OptionsValues = delegate ()
{
if (SharedData<SteamControllerSetting>.GetExistingValue(out var value))
return value.SelectableProfiles.SplitWithN();
return null;
},
CurrentValue = delegate ()
{
if (SharedData<SteamControllerSetting>.GetExistingValue(out var value))
return value.CurrentProfile.Length > 0 ? value.CurrentProfile : null;
return null;
},
ApplyValue = (selected) =>
{
if (!SharedData<SteamControllerSetting>.GetExistingValue(out var value))
return null;
value.DesiredProfile = selected;
if (!SharedData<SteamControllerSetting>.SetExistingValue(value))
return null;
return selected;
}
};
}
}