Skip to content
Permalink
Browse files
Merge pull request #8624 from jordan-woyak/setting-expression-input-gate
InputCommon: Only update setting expressions when the input gate is enabled.
  • Loading branch information
Tilka committed Feb 10, 2020
2 parents c598772 + 53f2e27 commit 01d69ba
Showing 1 changed file with 8 additions and 5 deletions.
@@ -158,10 +158,13 @@ class SettingValue
public:
ValueType GetValue() const
{
if (IsSimpleValue())
return m_value;
else
return m_input.GetState<ValueType>();
// Only update dynamic values when the input gate is enabled.
// Otherwise settings will all change to 0 when window focus is lost.
// This is very undesirable for things like battery level or attached extension.
if (!IsSimpleValue() && ControlReference::GetInputGate())
m_value = m_input.GetState<ValueType>();

return m_value;
}

bool IsSimpleValue() const { return m_input.GetExpression().empty(); }
@@ -176,7 +179,7 @@ class SettingValue
}

// Values are R/W by both UI and CPU threads.
std::atomic<ValueType> m_value = {};
mutable std::atomic<ValueType> m_value = {};

// Unfortunately InputReference's state grabbing is non-const requiring mutable here.
mutable InputReference m_input;

0 comments on commit 01d69ba

Please sign in to comment.