Fixing logging errors on initial load of controller routes
Showing the changes to interface/src/Application.cpp (1 of 9 files). Show all
Unified · Split
| @@ -402,6 +402,11 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 401 unmodified lines | ||
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | +static const QString STATE_IN_HMD = "InHMD"; | |
| 406 | +static const QString STATE_SNAP_TURN = "SnapTurn"; | |
| 407 | +static const QString STATE_GROUNDED = "Grounded"; | |
| 408 | +static const QString STATE_NAV_FOCUSED = "NavigationFocused"; | |
| 409 | + | |
| 405 | 410 | bool setupEssentials(int& argc, char** argv) { |
| 406 | 411 | unsigned int listenPort = 0; // bind to an ephemeral port by default |
| 407 | 412 | const char** constArgv = const_cast<const char**>(argv); |
| @@ -471,6 +476,7 @@ bool setupEssentials(int& argc, char** argv) { · 63 unmodified lines | ||
| 471 | 476 | DependencyManager::set<InterfaceActionFactory>(); |
| 472 | 477 | DependencyManager::set<AudioInjectorManager>(); |
| 473 | 478 | DependencyManager::set<MessagesClient>(); |
| 479 | + controller::StateController::setStateVariables({ { STATE_IN_HMD, STATE_SNAP_TURN, STATE_GROUNDED, STATE_NAV_FOCUSED } }); | |
| 474 | 480 | DependencyManager::set<UserInputMapper>(); |
| 475 | 481 | DependencyManager::set<controller::ScriptingInterface, ControllerScriptingInterface>(); |
| 476 | 482 | DependencyManager::set<InterfaceParentFinder>(); |
| @@ -925,6 +931,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 448 unmodified lines | ||
| 925 | 931 | } else if (action == controller::toInt(controller::Action::CONTEXT_MENU)) { |
| 926 | 932 | auto reticlePosition = getApplicationCompositor().getReticlePosition(); |
| 927 | 933 | offscreenUi->toggleMenu(_glWidget->mapFromGlobal(QPoint(reticlePosition.x, reticlePosition.y))); |
| 934 | + } else if (action == controller::toInt(controller::Action::UI_NAV_SELECT)) { | |
| 935 | + if (!offscreenUi->navigationFocused()) { | |
| 936 | + auto reticlePosition = getApplicationCompositor().getReticlePosition(); | |
| 937 | + offscreenUi->toggleMenu(_glWidget->mapFromGlobal(QPoint(reticlePosition.x, reticlePosition.y))); | |
| 938 | + } | |
| 928 | 939 | } else if (action == controller::toInt(controller::Action::RETICLE_X)) { |
| 929 | 940 | auto oldPos = getApplicationCompositor().getReticlePosition(); |
| 930 | 941 | getApplicationCompositor().setReticlePosition({ oldPos.x + state, oldPos.y }); |
| @@ -937,28 +948,23 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 6 unmodified lines | ||
| 937 | 948 | } |
| 938 | 949 | }); |
| 939 | 950 | |
| 940 | − // A new controllerInput device used to reflect current values from the application state | |
| 941 | − _applicationStateDevice = std::make_shared<controller::StateController>(); | |
| 942 | − | |
| 943 | − _applicationStateDevice->addInputVariant(QString("InHMD"), controller::StateController::ReadLambda([]() -> float { | |
| 944 | − return (float)qApp->isHMDMode(); | |
| 945 | − })); | |
| 946 | − _applicationStateDevice->addInputVariant(QString("SnapTurn"), controller::StateController::ReadLambda([]() -> float { | |
| 947 | − return (float)qApp->getMyAvatar()->getSnapTurn(); | |
| 948 | − })); | |
| 949 | − _applicationStateDevice->addInputVariant(QString("Grounded"), controller::StateController::ReadLambda([]() -> float { | |
| 950 | − return (float)qApp->getMyAvatar()->getCharacterController()->onGround(); | |
| 951 | − })); | |
| 952 | − _applicationStateDevice->addInputVariant(QString("NavigationFocused"), controller::StateController::ReadLambda([]() -> float { | |
| 953 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 954 | − return offscreenUi->navigationFocused() ? 1.0 : 0.0; | |
| 955 | − })); | |
| 951 | + _applicationStateDevice = userInputMapper->getStateDevice(); | |
| 956 | 952 | |
| 957 | − userInputMapper->registerDevice(_applicationStateDevice); | |
| 953 | + _applicationStateDevice->setInputVariant(STATE_IN_HMD, []() -> float { | |
| 954 | + return qApp->isHMDMode() ? 1 : 0; | |
| 955 | + }); | |
| 956 | + _applicationStateDevice->setInputVariant(STATE_SNAP_TURN, []() -> float { | |
| 957 | + return qApp->getMyAvatar()->getSnapTurn() ? 1 : 0; | |
| 958 | + }); | |
| 959 | + _applicationStateDevice->setInputVariant(STATE_GROUNDED, []() -> float { | |
| 960 | + return qApp->getMyAvatar()->getCharacterController()->onGround() ? 1 : 0; | |
| 961 | + }); | |
| 962 | + _applicationStateDevice->setInputVariant(STATE_NAV_FOCUSED, []() -> float { | |
| 963 | + return DependencyManager::get<OffscreenUi>()->navigationFocused() ? 1 : 0; | |
| 964 | + }); | |
| 958 | 965 | |
| 959 | 966 | // Setup the keyboardMouseDevice and the user input mapper with the default bindings |
| 960 | 967 | userInputMapper->registerDevice(_keyboardMouseDevice->getInputDevice()); |
| 961 | − userInputMapper->loadDefaultMapping(userInputMapper->getStandardDeviceID()); | |
| 962 | 968 | |
| 963 | 969 | // force the model the look at the correct directory (weird order of operations issue) |
| 964 | 970 | scriptEngines->setScriptsLocation(scriptEngines->getScriptsLocation()); |