From 61350b3d989d07c77f9b9e58d47c4263294158ee Mon Sep 17 00:00:00 2001 From: spycrab Date: Mon, 18 Mar 2019 17:30:33 +0100 Subject: [PATCH] Core/Host: Allow frontends to block inputs --- Source/Android/jni/MainAndroid.cpp | 4 ++++ Source/Core/Core/Host.h | 1 + Source/Core/DolphinNoGUI/MainNoGUI.cpp | 5 +++++ Source/Core/DolphinQt/Host.cpp | 6 ++++++ .../Core/InputCommon/ControlReference/ControlReference.cpp | 5 +++-- Source/UnitTests/StubHost.cpp | 4 ++++ 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index bb148f6578..ebb062ee8e 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -94,6 +94,10 @@ void Host_NotifyMapLoaded() void Host_RefreshDSPDebuggerWindow() { } +bool Host_UIBlocksControllerState() +{ + return false; +} void Host_Message(HostMessageID id) { diff --git a/Source/Core/Core/Host.h b/Source/Core/Core/Host.h index 3777d375f5..0bea7769d5 100644 --- a/Source/Core/Core/Host.h +++ b/Source/Core/Core/Host.h @@ -33,6 +33,7 @@ enum class HostMessageID }; bool Host_UINeedsControllerState(); +bool Host_UIBlocksControllerState(); bool Host_RendererHasFocus(); bool Host_RendererIsFullscreen(); void Host_Message(HostMessageID id); diff --git a/Source/Core/DolphinNoGUI/MainNoGUI.cpp b/Source/Core/DolphinNoGUI/MainNoGUI.cpp index c5ec03430f..e4096d8501 100644 --- a/Source/Core/DolphinNoGUI/MainNoGUI.cpp +++ b/Source/Core/DolphinNoGUI/MainNoGUI.cpp @@ -52,6 +52,11 @@ void Host_RefreshDSPDebuggerWindow() { } +bool Host_UIBlocksControllerState() +{ + return false; +} + static Common::Event s_update_main_frame_event; void Host_Message(HostMessageID id) { diff --git a/Source/Core/DolphinQt/Host.cpp b/Source/Core/DolphinQt/Host.cpp index c4d3711eda..63f03e3074 100644 --- a/Source/Core/DolphinQt/Host.cpp +++ b/Source/Core/DolphinQt/Host.cpp @@ -151,6 +151,12 @@ bool Host_UINeedsControllerState() { return Settings::Instance().IsControllerStateNeeded(); } + +bool Host_UIBlocksControllerState() +{ + return ImGui::GetCurrentContext() && ImGui::GetIO().WantCaptureKeyboard; +} + void Host_RefreshDSPDebuggerWindow() { } diff --git a/Source/Core/InputCommon/ControlReference/ControlReference.cpp b/Source/Core/InputCommon/ControlReference/ControlReference.cpp index 1f392c4e3a..cfc6fa658e 100644 --- a/Source/Core/InputCommon/ControlReference/ControlReference.cpp +++ b/Source/Core/InputCommon/ControlReference/ControlReference.cpp @@ -14,8 +14,9 @@ using namespace ciface::ExpressionParser; bool ControlReference::InputGateOn() { - return SConfig::GetInstance().m_BackgroundInput || Host_RendererHasFocus() || - Host_UINeedsControllerState(); + return (SConfig::GetInstance().m_BackgroundInput || Host_RendererHasFocus() || + Host_UINeedsControllerState()) && + !Host_UIBlocksControllerState(); } // diff --git a/Source/UnitTests/StubHost.cpp b/Source/UnitTests/StubHost.cpp index 62a332e59b..fd062be732 100644 --- a/Source/UnitTests/StubHost.cpp +++ b/Source/UnitTests/StubHost.cpp @@ -35,6 +35,10 @@ bool Host_UINeedsControllerState() { return false; } +bool Host_UIBlocksControllerState() +{ + return false; +} bool Host_RendererHasFocus() { return false;