History

first cut at wiring up devices and inputs to JS

Brad Hefta-Gaub committed 11 years ago

Commit 37f530f1 parent a5f0b755 files · +38 −6Browse files

Showing the changes to interface/src/scripting/ControllerScriptingInterface.cpp (1 of 5 files). Show all

Unified · Split

interface/src/scripting/ControllerScriptingInterface.cpp+23−1
@@ -111,7 +111,7 @@ void inputPairFromScriptValue(const QScriptValue& object, UserInputMapper::Input · 110 unmodified lines
111 inputPair.second = QString(object.property("inputName").toVariant().toString());111 inputPair.second = QString(object.property("inputName").toVariant().toString());
112}112}
113 113
114void ControllerScriptingInterface::registerControllerTypes(QScriptEngine* engine) {114void ControllerScriptingInterface::registerControllerTypes(ScriptEngine* engine) {
115 qScriptRegisterSequenceMetaType<QVector<UserInputMapper::Action> >(engine);115 qScriptRegisterSequenceMetaType<QVector<UserInputMapper::Action> >(engine);
116 qScriptRegisterSequenceMetaType<QVector<UserInputMapper::InputChannel> >(engine);116 qScriptRegisterSequenceMetaType<QVector<UserInputMapper::InputChannel> >(engine);
117 qScriptRegisterSequenceMetaType<QVector<UserInputMapper::InputPair> >(engine);117 qScriptRegisterSequenceMetaType<QVector<UserInputMapper::InputPair> >(engine);
@@ -119,6 +119,8 @@ void ControllerScriptingInterface::registerControllerTypes(QScriptEngine* engine · 1 unmodified line
119 qScriptRegisterMetaType(engine, inputChannelToScriptValue, inputChannelFromScriptValue);119 qScriptRegisterMetaType(engine, inputChannelToScriptValue, inputChannelFromScriptValue);
120 qScriptRegisterMetaType(engine, inputToScriptValue, inputFromScriptValue);120 qScriptRegisterMetaType(engine, inputToScriptValue, inputFromScriptValue);
121 qScriptRegisterMetaType(engine, inputPairToScriptValue, inputPairFromScriptValue);121 qScriptRegisterMetaType(engine, inputPairToScriptValue, inputPairFromScriptValue);
122
123 wireUpControllers(engine);
122}124}
123 125
124void ControllerScriptingInterface::handleMetaEvent(HFMetaEvent* event) {126void ControllerScriptingInterface::handleMetaEvent(HFMetaEvent* event) {
@@ -381,6 +383,26 @@ glm::vec2 ControllerScriptingInterface::getViewportDimensions() const { · 256 unmodified lines
381 return qApp->getUiSize();383 return qApp->getUiSize();
382}384}
383 385
386void ControllerScriptingInterface::wireUpControllers(ScriptEngine* engine) {
387
388 qDebug() << "------------------- wire up controllers --------------------------";
389 ///_registeredDevices
390
391 auto devices = DependencyManager::get<UserInputMapper>()->getDevices();
392
393 for(const auto& deviceMapping : devices) {
394 auto device = deviceMapping.second.get();
395 qDebug() << device->getName();
396 auto deviceInputs = device->getAvailabeInputs();
397 for (const auto& inputMapping : deviceInputs) {
398 auto input = inputMapping.first;
399 auto inputName = inputMapping.second;
400 qDebug() << device->getName() << "." << inputName << "["<< input.getID() <<"]";
401 }
402 }
403 qDebug() << "------------------- DONE wire up controllers --------------------------";
404}
405
384AbstractInputController* ControllerScriptingInterface::createInputController(const QString& deviceName, const QString& tracker) {406AbstractInputController* ControllerScriptingInterface::createInputController(const QString& deviceName, const QString& tracker) {
385 // This is where we retreive the Device Tracker category and then the sub tracker within it407 // This is where we retreive the Device Tracker category and then the sub tracker within it
386 //TODO C++11 auto icIt = _inputControllers.find(0);408 //TODO C++11 auto icIt = _inputControllers.find(0);