ControllerInterface: Input detection improvements.

This commit is contained in:
Jordan Woyak 2019-02-26 19:46:21 -06:00
parent 13b2b93d3d
commit 48b69ca018
7 changed files with 90 additions and 60 deletions

View file

@ -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)