From 7a90ea2752de2fe5c7ba62c0432ae25f4e5bce3b Mon Sep 17 00:00:00 2001 From: master0fdisaster <38867833+master0fdisaster@users.noreply.github.com> Date: Tue, 5 Jun 2018 23:34:28 +0200 Subject: [PATCH] Add OSD message for Volume Hotkeys This pr adds an OnScreenDisplay message when you use the Volume hotkeys. Just to have visual feedback. --- Source/Core/DolphinQt2/HotkeyScheduler.cpp | 29 ++++++++++++++-------- Source/Core/DolphinWX/Frame.cpp | 24 +++++++++++++----- Source/Core/VideoCommon/RenderBase.cpp | 4 +++ Source/Core/VideoCommon/RenderBase.h | 3 ++- 4 files changed, 43 insertions(+), 17 deletions(-) diff --git a/Source/Core/DolphinQt2/HotkeyScheduler.cpp b/Source/Core/DolphinQt2/HotkeyScheduler.cpp index 65fb24bbc0..91812fd6ba 100644 --- a/Source/Core/DolphinQt2/HotkeyScheduler.cpp +++ b/Source/Core/DolphinQt2/HotkeyScheduler.cpp @@ -200,16 +200,6 @@ void HotkeyScheduler::Run() if (IsHotkey(HK_READ_ONLY_MODE)) emit ToggleReadOnlyMode(); - // Volume - if (IsHotkey(HK_VOLUME_DOWN)) - settings.DecreaseVolume(3); - - if (IsHotkey(HK_VOLUME_UP)) - settings.IncreaseVolume(3); - - if (IsHotkey(HK_VOLUME_TOGGLE_MUTE)) - AudioCommon::ToggleMuteVolume(); - // Wiimote if (SConfig::GetInstance().m_bt_passthrough_enabled) { @@ -251,6 +241,25 @@ void HotkeyScheduler::Run() g_renderer->ShowOSDMessage(message); }; + // Volume + if (IsHotkey(HK_VOLUME_DOWN)) + { + show_msg(OSDMessage::VolumeChanged); + settings.DecreaseVolume(3); + } + + if (IsHotkey(HK_VOLUME_UP)) + { + show_msg(OSDMessage::VolumeChanged); + settings.IncreaseVolume(3); + } + + if (IsHotkey(HK_VOLUME_TOGGLE_MUTE)) + { + show_msg(OSDMessage::VolumeChanged); + AudioCommon::ToggleMuteVolume(); + } + // Graphics const auto efb_scale = Config::Get(Config::GFX_EFB_SCALE); diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 8ae15c848d..7ab572075a 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -1324,12 +1324,6 @@ void CFrame::ParseHotkeys() Core::SaveScreenShot(); if (IsHotkey(HK_EXIT)) wxPostEvent(this, wxCommandEvent(wxEVT_MENU, wxID_EXIT)); - if (IsHotkey(HK_VOLUME_DOWN)) - AudioCommon::DecreaseVolume(3); - if (IsHotkey(HK_VOLUME_UP)) - AudioCommon::IncreaseVolume(3); - if (IsHotkey(HK_VOLUME_TOGGLE_MUTE)) - AudioCommon::ToggleMuteVolume(); if (SConfig::GetInstance().m_bt_passthrough_enabled) { @@ -1423,6 +1417,24 @@ void CFrame::ParseHotkeys() g_renderer->ShowOSDMessage(message); }; + if (IsHotkey(HK_VOLUME_DOWN)) + { + show_msg(OSDMessage::VolumeChanged); + AudioCommon::DecreaseVolume(3); + } + + if (IsHotkey(HK_VOLUME_UP)) + { + show_msg(OSDMessage::VolumeChanged); + AudioCommon::IncreaseVolume(3); + } + + if (IsHotkey(HK_VOLUME_TOGGLE_MUTE)) + { + show_msg(OSDMessage::VolumeChanged); + AudioCommon::ToggleMuteVolume(); + } + if (IsHotkey(HK_INCREASE_IR)) { show_msg(OSDMessage::IRChanged); diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 97ca4c1696..98addff6b2 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -329,6 +329,9 @@ void Renderer::DrawDebugText() ar_text = "Auto"; break; } + const std::string audio_text = SConfig::GetInstance().m_IsMuted ? + "Muted" : + std::to_string(SConfig::GetInstance().m_Volume) + "%"; const char* const efbcopy_text = g_ActiveConfig.bSkipEFBCopyToRam ? "to Texture" : "to RAM"; const char* const xfbcopy_text = g_ActiveConfig.bSkipXFBCopyToRam ? "to Texture" : "to RAM"; @@ -345,6 +348,7 @@ void Renderer::DrawDebugText() std::lround(SConfig::GetInstance().m_EmulationSpeed * 100.f)), std::string("Copy XFB: ") + xfbcopy_text + (g_ActiveConfig.bImmediateXFB ? " (Immediate)" : ""), + "Volume: " + audio_text, }; enum diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index 62642d0e77..e5861d00c9 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -62,7 +62,8 @@ enum class OSDMessage : s32 EFBCopyToggled = 3, FogToggled = 4, SpeedChanged = 5, - XFBChanged = 6 + XFBChanged = 6, + VolumeChanged = 7, }; // Renderer really isn't a very good name for this class - it's more like "Misc".