From 34fbe980de3eb5fd897bb6afd7b714d82437b2f7 Mon Sep 17 00:00:00 2001 From: Sour Date: Fri, 24 Apr 2020 21:15:46 -0400 Subject: [PATCH] UI: Added shortcut to increase/decrease volume --- Core/SettingTypes.h | 3 +++ UI/Config/PreferencesConfig.cs | 3 +++ UI/Config/Shortcuts/EmulatorShortcut.cs | 3 +++ UI/Dependencies/resources.en.xml | 2 ++ UI/Emulation/ShortcutHandler.cs | 17 +++++++++++++++++ UI/Forms/Config/ctrlEmulatorShortcuts.cs | 5 ++++- 6 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Core/SettingTypes.h b/Core/SettingTypes.h index 289317e..7cb2a4e 100644 --- a/Core/SettingTypes.h +++ b/Core/SettingTypes.h @@ -383,7 +383,10 @@ enum class EmulatorShortcut ToggleOsd, ToggleAlwaysOnTop, ToggleDebugInfo, + ToggleAudio, + IncreaseVolume, + DecreaseVolume, ToggleBgLayer0, ToggleBgLayer1, diff --git a/UI/Config/PreferencesConfig.cs b/UI/Config/PreferencesConfig.cs index faacbfc..0b00413 100644 --- a/UI/Config/PreferencesConfig.cs +++ b/UI/Config/PreferencesConfig.cs @@ -86,6 +86,9 @@ namespace Mesen.GUI.Config ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.DecreaseSpeed, new KeyCombination() { Key1 = InputApi.GetKeyCode("-") })); ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.MaxSpeed, new KeyCombination() { Key1 = InputApi.GetKeyCode("F9") })); + ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.IncreaseVolume, new KeyCombination() { Key1 = InputApi.GetKeyCode("Ctrl"), Key2 = InputApi.GetKeyCode("=") })); + ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.DecreaseVolume, new KeyCombination() { Key1 = InputApi.GetKeyCode("Ctrl"), Key2 = InputApi.GetKeyCode("-") })); + ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.ToggleFps, new KeyCombination() { Key1 = InputApi.GetKeyCode("F10") })); ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.ToggleFullscreen, new KeyCombination() { Key1 = InputApi.GetKeyCode("F11") })); ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.TakeScreenshot, new KeyCombination() { Key1 = InputApi.GetKeyCode("F12") })); diff --git a/UI/Config/Shortcuts/EmulatorShortcut.cs b/UI/Config/Shortcuts/EmulatorShortcut.cs index 315539f..c3b3ec1 100644 --- a/UI/Config/Shortcuts/EmulatorShortcut.cs +++ b/UI/Config/Shortcuts/EmulatorShortcut.cs @@ -61,7 +61,10 @@ namespace Mesen.GUI.Config.Shortcuts ToggleOsd, ToggleAlwaysOnTop, ToggleDebugInfo, + ToggleAudio, + IncreaseVolume, + DecreaseVolume, ToggleBgLayer0, ToggleBgLayer1, diff --git a/UI/Dependencies/resources.en.xml b/UI/Dependencies/resources.en.xml index af77b5f..86da717 100644 --- a/UI/Dependencies/resources.en.xml +++ b/UI/Dependencies/resources.en.xml @@ -778,6 +778,8 @@ Load State Enable/Disable Cheat Codes Enable/Disable Audio + Increase Volume + Decrease Volume Run Single Frame Set Scale 1x diff --git a/UI/Emulation/ShortcutHandler.cs b/UI/Emulation/ShortcutHandler.cs index 3cf4904..22ec119 100644 --- a/UI/Emulation/ShortcutHandler.cs +++ b/UI/Emulation/ShortcutHandler.cs @@ -80,6 +80,9 @@ namespace Mesen.GUI.Emulation case EmulatorShortcut.Exit: frmMain.Instance.Close(); restoreFullscreen = false; break; case EmulatorShortcut.ToggleAudio: ToggleAudio(); break; + case EmulatorShortcut.IncreaseVolume: IncreaseVolume(); break; + case EmulatorShortcut.DecreaseVolume: DecreaseVolume(); break; + case EmulatorShortcut.ToggleFps: ToggleFps(); break; case EmulatorShortcut.ToggleGameTimer: ToggleGameTimer(); break; case EmulatorShortcut.ToggleFrameCounter: ToggleFrameCounter(); break; @@ -324,6 +327,20 @@ namespace Mesen.GUI.Emulation InvertConfigFlag(ref ConfigManager.Config.Audio.EnableAudio); } + private void IncreaseVolume() + { + ConfigManager.Config.Audio.MasterVolume = (uint)Math.Min(100, (int)ConfigManager.Config.Audio.MasterVolume + 10); + ConfigManager.Config.Audio.ApplyConfig(); + ConfigManager.ApplyChanges(); + } + + private void DecreaseVolume() + { + ConfigManager.Config.Audio.MasterVolume = (uint)Math.Max(0, (int)ConfigManager.Config.Audio.MasterVolume - 10); + ConfigManager.Config.Audio.ApplyConfig(); + ConfigManager.ApplyChanges(); + } + private void ToggleFrameCounter() { InvertConfigFlag(ref ConfigManager.Config.Preferences.ShowFrameCounter); diff --git a/UI/Forms/Config/ctrlEmulatorShortcuts.cs b/UI/Forms/Config/ctrlEmulatorShortcuts.cs index 4865671..371e39e 100644 --- a/UI/Forms/Config/ctrlEmulatorShortcuts.cs +++ b/UI/Forms/Config/ctrlEmulatorShortcuts.cs @@ -65,7 +65,6 @@ namespace Mesen.GUI.Forms.Config EmulatorShortcut.ToggleFrameCounter, EmulatorShortcut.ToggleOsd, EmulatorShortcut.ToggleAlwaysOnTop, - EmulatorShortcut.ToggleAudio, EmulatorShortcut.ToggleCheats, EmulatorShortcut.ToggleBgLayer0, @@ -75,6 +74,10 @@ namespace Mesen.GUI.Forms.Config EmulatorShortcut.ToggleSprites, EmulatorShortcut.EnableAllLayers, + EmulatorShortcut.ToggleAudio, + EmulatorShortcut.IncreaseVolume, + EmulatorShortcut.DecreaseVolume, + EmulatorShortcut.MaxSpeed, EmulatorShortcut.IncreaseSpeed, EmulatorShortcut.DecreaseSpeed,