summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControlReference/ControlReference.cpp
diff options
context:
space:
mode:
authorConnor McLaughlin <stenzek@gmail.com>2019-11-11 10:59:49 +1000
committerGitHub <noreply@github.com>2019-11-11 10:59:49 +1000
commit913cb080667302760e42e3a6e2346b6e7c5cb1b6 (patch)
tree66ff102774c387e743c535f5c79a55736e05c3b9 /Source/Core/InputCommon/ControlReference/ControlReference.cpp
parent066012b80d7a149779b4e910dcda3be8ec97f8e3 (diff)
parent85ceb37ccd24acc5ea026583ce3a0f6a4fb26eaa (diff)
Merge pull request #8456 from jordan-woyak/input-gate-race-fix
InputCommon: Make the "input gate" not racy.
Diffstat (limited to 'Source/Core/InputCommon/ControlReference/ControlReference.cpp')
-rw-r--r--Source/Core/InputCommon/ControlReference/ControlReference.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/Source/Core/InputCommon/ControlReference/ControlReference.cpp b/Source/Core/InputCommon/ControlReference/ControlReference.cpp
index af7536547c..b1dd5deee3 100644
--- a/Source/Core/InputCommon/ControlReference/ControlReference.cpp
+++ b/Source/Core/InputCommon/ControlReference/ControlReference.cpp
@@ -4,19 +4,18 @@
#include "InputCommon/ControlReference/ControlReference.h"
-// For InputGateOn()
-// This is a bad layering violation, but it's the cleanest
-// place I could find to put it.
-#include "Core/ConfigManager.h"
-#include "Core/Host.h"
-
using namespace ciface::ExpressionParser;
-bool ControlReference::InputGateOn()
+static thread_local bool tls_input_gate = true;
+
+void ControlReference::SetInputGate(bool enable)
+{
+ tls_input_gate = enable;
+}
+
+bool ControlReference::GetInputGate()
{
- return (SConfig::GetInstance().m_BackgroundInput || Host_RendererHasFocus() ||
- Host_UINeedsControllerState()) &&
- !Host_UIBlocksControllerState();
+ return tls_input_gate;
}
//
@@ -90,7 +89,7 @@ bool OutputReference::IsInput() const
//
ControlState InputReference::State(const ControlState ignore)
{
- if (m_parsed_expression && InputGateOn())
+ if (m_parsed_expression && GetInputGate())
return m_parsed_expression->GetValue() * range;
return 0.0;
}