diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2019-02-26 19:46:21 -0600 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2019-03-03 18:36:16 -0600 |
| commit | 48b69ca01841ba724049895a83d8d88ec95d66de (patch) | |
| tree | 43fda39dfdccc0999afdb0aaa4e2ab1fd5874c39 /Source/Core/InputCommon/ControlReference/ExpressionParser.cpp | |
| parent | 13b2b93d3d12e4c8491ed82c63d52a24a4849476 (diff) | |
ControllerInterface: Input detection improvements.
Diffstat (limited to 'Source/Core/InputCommon/ControlReference/ExpressionParser.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControlReference/ExpressionParser.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp index ba3f78170d..a73b1c94cf 100644 --- a/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp +++ b/Source/Core/InputCommon/ControlReference/ExpressionParser.cpp @@ -217,7 +217,19 @@ public: std::shared_ptr<Device> m_device; explicit ControlExpression(ControlQualifier qualifier_) : qualifier(qualifier_) {} - ControlState GetValue() const override { return control ? control->ToInput()->GetState() : 0.0; } + ControlState GetValue() const override + { + if (!control) + return 0.0; + + // Note: Inputs may return negative values in situations where opposing directions are + // activated. We clamp off the negative values here. + + // FYI: Clamping values greater than 1.0 is purposely not done to support unbounded values in + // the future. (e.g. raw accelerometer/gyro data) + + return std::max(0.0, control->ToInput()->GetState()); + } void SetValue(ControlState value) override { if (control) |
