From 85ceb37ccd24acc5ea026583ce3a0f6a4fb26eaa Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Wed, 6 Nov 2019 15:59:36 -0600 Subject: InputCommon: Make the "input gate" not racey. --- .../ControlReference/ControlReference.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'Source/Core/InputCommon/ControlReference/ControlReference.cpp') 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; } -- cgit v1.2.3