diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2019-11-06 15:59:36 -0600 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2019-11-06 16:31:02 -0600 |
| commit | 85ceb37ccd24acc5ea026583ce3a0f6a4fb26eaa (patch) | |
| tree | 1a4d9a86fdcd36a3c1273502af576bcb30449db1 /Source/Core/InputCommon/ControlReference | |
| parent | 93d7b3d15962a3393cf2971e14c4acf54d90cecd (diff) | |
InputCommon: Make the "input gate" not racey.
Diffstat (limited to 'Source/Core/InputCommon/ControlReference')
| -rw-r--r-- | Source/Core/InputCommon/ControlReference/ControlReference.cpp | 21 | ||||
| -rw-r--r-- | Source/Core/InputCommon/ControlReference/ControlReference.h | 4 |
2 files changed, 13 insertions, 12 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; } diff --git a/Source/Core/InputCommon/ControlReference/ControlReference.h b/Source/Core/InputCommon/ControlReference/ControlReference.h index 3f2c205501..539c7f4927 100644 --- a/Source/Core/InputCommon/ControlReference/ControlReference.h +++ b/Source/Core/InputCommon/ControlReference/ControlReference.h @@ -22,7 +22,9 @@ class ControlReference { public: - static bool InputGateOn(); + // Note: this is per thread. + static void SetInputGate(bool enable); + static bool GetInputGate(); virtual ~ControlReference(); virtual ControlState State(const ControlState state = 0) = 0; |
