From d7ad2f1d71532d37477ed1bd3eb94dc67ed98032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Fri, 18 Nov 2022 16:14:29 +0100 Subject: [PATCH] Shortcut to reset to default --- PowerControl/Controller.cs | 14 ++++++++++++++ PowerControl/Menu.cs | 32 ++++++++++++++++++++++++++++---- PowerControl/MenuStack.cs | 3 +++ README.md | 6 +++++- RELEASE.md | 1 + 5 files changed, 51 insertions(+), 5 deletions(-) diff --git a/PowerControl/Controller.cs b/PowerControl/Controller.cs index 068a93c..0ceb803 100644 --- a/PowerControl/Controller.cs +++ b/PowerControl/Controller.cs @@ -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 diff --git a/PowerControl/Menu.cs b/PowerControl/Menu.cs index f1fe30a..4e2ea48 100644 --- a/PowerControl/Menu.cs +++ b/PowerControl/Menu.cs @@ -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) diff --git a/PowerControl/MenuStack.cs b/PowerControl/MenuStack.cs index 126a43d..77343af 100644 --- a/PowerControl/MenuStack.cs +++ b/PowerControl/MenuStack.cs @@ -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; diff --git a/README.md b/README.md index 3eecb33..00ad798 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/RELEASE.md b/RELEASE.md index fe72398..1f1722e 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -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).