From d5a90e273e418d02cfa0f69c8ee3687753df6b53 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 23 Oct 2015 15:56:55 -0700 Subject: [PATCH] fix AnyEndpoint support from JS --- .../src/controllers/UserInputMapper.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libraries/controllers/src/controllers/UserInputMapper.cpp b/libraries/controllers/src/controllers/UserInputMapper.cpp index e924718fca..30fd650eba 100755 --- a/libraries/controllers/src/controllers/UserInputMapper.cpp +++ b/libraries/controllers/src/controllers/UserInputMapper.cpp @@ -217,10 +217,10 @@ public: } virtual float value() override { - float result = 0; + float result = 0.0f; for (auto& child : _children) { float childResult = child->value(); - if (childResult != 0.0f) { + if (childResult != 0.0f && result == 0.0f) { result = childResult; } } @@ -856,6 +856,21 @@ Endpoint::Pointer UserInputMapper::endpointFor(const QScriptValue& endpoint) { return result; } + if (endpoint.isArray()) { + int length = endpoint.property("length").toInteger(); + Endpoint::List children; + for (int i = 0; i < length; i++) { + QScriptValue arrayItem = endpoint.property(i); + Endpoint::Pointer destination = endpointFor(arrayItem); + if (!destination) { + return Endpoint::Pointer(); + } + children.push_back(destination); + } + return std::make_shared(children); + } + + qWarning() << "Unsupported input type " << endpoint.toString(); return Endpoint::Pointer(); }