From 2492eb867832f75f78fa83a5aaa5ce9a94f231b1 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 13 Sep 2020 20:21:05 +1000 Subject: [PATCH] FrontendCommon: Add a hotkey to reload post processing --- src/frontend-common/common_host_interface.cpp | 17 +++++++++++++++++ src/frontend-common/common_host_interface.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index e76dc1f99..c4fccc3f0 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -1438,6 +1438,12 @@ void CommonHostInterface::RegisterGraphicsHotkeys() if (!pressed) ModifyResolutionScale(-1); }); + + RegisterHotkey(StaticString("Graphics"), StaticString("ReloadPostProcessingShaders"), + StaticString(TRANSLATABLE("Hotkeys", "Reload Post Processing Shaders")), [this](bool pressed) { + if (!pressed) + ReloadPostProcessingShaders(); + }); } void CommonHostInterface::RegisterSaveStateHotkeys() @@ -2265,6 +2271,17 @@ void CommonHostInterface::ApplyCheatCode(u32 index) } } +void CommonHostInterface::ReloadPostProcessingShaders() +{ + if (!m_display) + return; + + if (!m_display->SetPostProcessingChain(g_settings.display_post_process_chain)) + AddOSDMessage(TranslateStdString("OSDMessage", "Failed to load post processing shader chain."), 20.0f); + else + AddOSDMessage(TranslateStdString("OSDMessage", "Post processing shaders reloaded."), 10.0f); +} + #ifdef WITH_DISCORD_PRESENCE void CommonHostInterface::SetDiscordPresenceEnabled(bool enabled) diff --git a/src/frontend-common/common_host_interface.h b/src/frontend-common/common_host_interface.h index ec3662005..0ef73a733 100644 --- a/src/frontend-common/common_host_interface.h +++ b/src/frontend-common/common_host_interface.h @@ -166,6 +166,9 @@ public: /// Immediately applies the specified cheat code. void ApplyCheatCode(u32 index); + /// Reloads post processing shaders with the current configuration. + void ReloadPostProcessingShaders(); + protected: enum : u32 {