Showing the changes to interface/src/scripting/ControllerScriptingInterface.cpp (1 of 5 files). Show all
Unified · Split
| @@ -383,21 +383,29 @@ glm::vec2 ControllerScriptingInterface::getViewportDimensions() const { · 382 unmodified lines | |||
| 383 | return qApp->getUiSize(); | 383 | return qApp->getUiSize(); |
| 384 | } | 384 | } |
| 385 | 385 | ||
| 386 | QString ControllerScriptingInterface::sanatizeName(const QString& name) { | ||
| 387 | QString cleanName { name }; | ||
| 388 | cleanName.replace(QString(" "), QString("")).replace(QString("."), QString("")).replace(QString("("), QString("")).replace(QString(")"), QString("")); | ||
| 389 | return cleanName; | ||
| 390 | } | ||
| 391 | |||
| 386 | void ControllerScriptingInterface::wireUpControllers(ScriptEngine* engine) { | 392 | void ControllerScriptingInterface::wireUpControllers(ScriptEngine* engine) { |
| 387 | 393 | ||
| 388 | qDebug() << "------------------- wire up controllers --------------------------"; | 394 | qDebug() << "------------------- wire up controllers --------------------------"; |
| 389 | ///_registeredDevices | ||
| 390 | 395 | ||
| 391 | auto devices = DependencyManager::get<UserInputMapper>()->getDevices(); | 396 | auto devices = DependencyManager::get<UserInputMapper>()->getDevices(); |
| 392 | 397 | ||
| 393 | for(const auto& deviceMapping : devices) { | 398 | for(const auto& deviceMapping : devices) { |
| 394 | auto device = deviceMapping.second.get(); | 399 | auto device = deviceMapping.second.get(); |
| 395 | qDebug() << device->getName(); | 400 | auto deviceName = sanatizeName(device->getName()); |
| 396 | auto deviceInputs = device->getAvailabeInputs(); | 401 | auto deviceInputs = device->getAvailabeInputs(); |
| 397 | for (const auto& inputMapping : deviceInputs) { | 402 | for (const auto& inputMapping : deviceInputs) { |
| 398 | auto input = inputMapping.first; | 403 | auto input = inputMapping.first; |
| 399 | auto inputName = inputMapping.second; | 404 | auto inputName = sanatizeName(inputMapping.second); |
| 400 | qDebug() << device->getName() << "." << inputName << "["<< input.getID() <<"]"; | 405 | inputName.replace(QString(" "), QString("")); |
| 406 | QString deviceInputName { "Controller.Hardware." + deviceName + "." + inputName }; | ||
| 407 | engine->registerValue(deviceInputName, input.getID()); | ||
| 408 | qDebug() << deviceInputName << "[" << input.getID() << "]"; | ||
| 401 | } | 409 | } |
| 402 | } | 410 | } |
| 403 | qDebug() << "------------------- DONE wire up controllers --------------------------"; | 411 | qDebug() << "------------------- DONE wire up controllers --------------------------"; |