summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon
diff options
context:
space:
mode:
authorTilka <tilkax@gmail.com>2020-02-10 00:47:30 +0000
committerGitHub <noreply@github.com>2020-02-10 00:47:30 +0000
commit01d69ba81a0a6ece04befa6cf5f14f14c65792e7 (patch)
tree1a06894cfecd34832e6679c331d393992520c4f8 /Source/Core/InputCommon
parentc598772052c71de9e1b1a23a3dad2d7810b1c2ea (diff)
parent53f2e275afc07af7db19c1a53d74383b95ae6253 (diff)
Merge pull request #8624 from jordan-woyak/setting-expression-input-gate
InputCommon: Only update setting expressions when the input gate is enabled.
Diffstat (limited to 'Source/Core/InputCommon')
-rw-r--r--Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h b/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h
index c7298391f4..f049ddc565 100644
--- a/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h
+++ b/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h
@@ -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 @@ private:
}
// 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;