History

Merge pull request #7605 from jherico/route_log_errors

Fixing logging errors on initial load of controller routes

Brad Hefta-Gaub committed 10 years ago

Commit 5287c172 parents 3d94558 4c78c0b9 files · +105 −52Browse files

Showing the changes to interface/src/Application.cpp (1 of 9 files). Show all

Unified · Split

interface/src/Application.cpp+24−18
@@ -402,6 +402,11 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 401 unmodified lines
402402 }
403403 }
404404
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+
405410 bool setupEssentials(int& argc, char** argv) {
406411 unsigned int listenPort = 0; // bind to an ephemeral port by default
407412 const char** constArgv = const_cast<const char**>(argv);
@@ -471,6 +476,7 @@ bool setupEssentials(int& argc, char** argv) { · 63 unmodified lines
471476 DependencyManager::set<InterfaceActionFactory>();
472477 DependencyManager::set<AudioInjectorManager>();
473478 DependencyManager::set<MessagesClient>();
479+ controller::StateController::setStateVariables({ { STATE_IN_HMD, STATE_SNAP_TURN, STATE_GROUNDED, STATE_NAV_FOCUSED } });
474480 DependencyManager::set<UserInputMapper>();
475481 DependencyManager::set<controller::ScriptingInterface, ControllerScriptingInterface>();
476482 DependencyManager::set<InterfaceParentFinder>();
@@ -925,6 +931,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 448 unmodified lines
925931 } else if (action == controller::toInt(controller::Action::CONTEXT_MENU)) {
926932 auto reticlePosition = getApplicationCompositor().getReticlePosition();
927933 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+ }
928939 } else if (action == controller::toInt(controller::Action::RETICLE_X)) {
929940 auto oldPos = getApplicationCompositor().getReticlePosition();
930941 getApplicationCompositor().setReticlePosition({ oldPos.x + state, oldPos.y });
@@ -937,28 +948,23 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 6 unmodified lines
937948 }
938949 });
939950
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();
956952
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+ });
958965
959966 // Setup the keyboardMouseDevice and the user input mapper with the default bindings
960967 userInputMapper->registerDevice(_keyboardMouseDevice->getInputDevice());
961− userInputMapper->loadDefaultMapping(userInputMapper->getStandardDeviceID());
962968
963969 // force the model the look at the correct directory (weird order of operations issue)
964970 scriptEngines->setScriptsLocation(scriptEngines->getScriptsLocation());