Shortcut to reset to default

This commit is contained in:
Kamil Trzciński 2022-11-18 16:14:29 +01:00
parent b672c4e9c3
commit d7ad2f1d71
5 changed files with 51 additions and 5 deletions

View file

@ -248,6 +248,20 @@ namespace PowerControl
else
return; // otherwise it did not yet trigger
// Reset sequence: 3 dots + L4|R4|L5|R5
if (input.buttons0 == (ushort)SDCButton0.BTN_L5 &&
input.buttons1 == (byte)SDCButton1.BTN_R5 &&
input.buttons2 == 0 &&
input.buttons3 == 0 &&
input.buttons4 == (byte)(SDCButton4.BTN_L4 | SDCButton4.BTN_R4) &&
input.buttons5 == (byte)SDCButton5.BTN_QUICK_ACCESS)
{
rootMenu.Show();
rootMenu.Reset();
notifyIcon.ShowBalloonTip(3000, TitleWithVersion, "Settings were reset to default.", ToolTipIcon.Info);
return;
}
if ((input.buttons5 & (byte)SDCButton5.BTN_QUICK_ACCESS) == 0 || !isForeground())
{
// schedule next repeat far in the future

View file

@ -41,6 +41,7 @@ namespace PowerControl
public abstract void CreateMenu(ToolStripItemCollection collection);
public abstract void Update();
public abstract void Reset();
public abstract void SelectNext();
public abstract void SelectPrev();
@ -73,6 +74,10 @@ namespace PowerControl
public override void Update()
{
}
public override void Reset()
{
}
}
public class MenuItemWithOptions : MenuItem
@ -89,6 +94,7 @@ namespace PowerControl
public CurrentValueDelegate CurrentValue { get; set; }
public OptionsValueDelegate OptionsValues { get; set; }
public ApplyValueDelegate ApplyValue { get; set; }
public CurrentValueDelegate ResetValue { get; set; }
private System.Windows.Forms.Timer delayTimer;
private ToolStripMenuItem toolStripItem;
@ -98,6 +104,19 @@ namespace PowerControl
this.Selectable = true;
}
public override void Reset()
{
if (ResetValue == null)
return;
var resetOption = ResetValue();
if (resetOption == null || resetOption.Equals(ActiveOption))
return;
SelectedOption = resetOption;
onApply();
}
public override void Update()
{
if (CurrentValue != null)
@ -288,16 +307,21 @@ namespace PowerControl
public override void CreateMenu(ToolStripItemCollection collection)
{
foreach(var item in Items)
{
item.CreateMenu(collection);
}
}
public override void Update()
{
foreach (var item in Items)
{
item.Update();
}
}
public override void Reset()
{
foreach (var item in Items)
item.Reset();
if (VisibleChanged != null)
VisibleChanged();
}
public override string Render(MenuItem parentSelected)

View file

@ -53,6 +53,7 @@ namespace PowerControl
{
Name = "Refresh Rate",
ApplyDelay = 1000,
ResetValue = () => { return Helpers.PhysicalMonitorBrightnessController.GetRefreshRates().Max(); },
OptionsValues = delegate()
{
return Helpers.PhysicalMonitorBrightnessController.GetRefreshRates().Select(item => (object)item).ToArray();
@ -72,6 +73,7 @@ namespace PowerControl
{
Name = "FPS Limit",
ApplyDelay = 500,
ResetValue = () => { return "Off"; },
OptionsValues = delegate()
{
var refreshRate = Helpers.PhysicalMonitorBrightnessController.GetRefreshRate();
@ -121,6 +123,7 @@ namespace PowerControl
Name = "TDP",
Options = { "Auto", "3W", "4W", "5W", "6W", "7W", "8W", "10W", "12W", "15W" },
ApplyDelay = 1000,
ResetValue = () => { return "Auto"; },
ApplyValue = delegate(object selected)
{
int mW = 15000;

View file

@ -101,9 +101,13 @@ It will only work in OSD mode when rendering graphics.
The notification setting is always available.
- SteamDeck Controller: press and hold Quick Access (3 dots), and then DPad Left, Rigth, Up, Down.
- Keyboard: `Ctrl+Win+Numpad2` (Down), `Ctrl+Win+Numpad4` (Left), `Ctrl+Win+Numpad6` (Right), `Ctrl+Win+Numpad8` (Up)
Additional shortcuts:
- Control Volume: use Volume Up and Down
- Control Brightness: press and hold Quick Access (3 dots), and then Volume Up and Down
- Keyboard: `Ctrl+Win+Numpad2` (Down), `Ctrl+Win+Numpad4` (Left), `Ctrl+Win+Numpad6` (Right), `Ctrl+Win+Numpad8` (Up)
- Press `3 dots + L4 + R4 + L5 + R5` to reset (TDP, Refresh Rate, FPS limit) to default
### 3.2. SWICD configuration

View file

@ -12,5 +12,6 @@
- Swap icons of PerformanceOverlay and PowerControl
- Improve FanControl UI
- Make increments for Brightness and Volume in 5 (fixed)
- Press `3 dots + L4 + R4 + L5 + R5` to reset (TDP, Refresh Rate, FPS limit) to default
If you found it useful buy me [Ko-fi](https://ko-fi.com/ayufan).