fix AnyEndpoint support from JS

This commit is contained in:
Brad Hefta-Gaub 2015-10-23 15:56:55 -07:00
parent 7e3192d0f6
commit d5a90e273e

View file

@ -217,10 +217,10 @@ public:
} }
virtual float value() override { virtual float value() override {
float result = 0; float result = 0.0f;
for (auto& child : _children) { for (auto& child : _children) {
float childResult = child->value(); float childResult = child->value();
if (childResult != 0.0f) { if (childResult != 0.0f && result == 0.0f) {
result = childResult; result = childResult;
} }
} }
@ -856,6 +856,21 @@ Endpoint::Pointer UserInputMapper::endpointFor(const QScriptValue& endpoint) {
return result; 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<AnyEndpoint>(children);
}
qWarning() << "Unsupported input type " << endpoint.toString(); qWarning() << "Unsupported input type " << endpoint.toString();
return Endpoint::Pointer(); return Endpoint::Pointer();
} }