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
402 }402 }
403}403}
404 404
405static const QString STATE_IN_HMD = "InHMD";
406static const QString STATE_SNAP_TURN = "SnapTurn";
407static const QString STATE_GROUNDED = "Grounded";
408static const QString STATE_NAV_FOCUSED = "NavigationFocused";
409
405bool setupEssentials(int& argc, char** argv) {410bool setupEssentials(int& argc, char** argv) {
406 unsigned int listenPort = 0; // bind to an ephemeral port by default411 unsigned int listenPort = 0; // bind to an ephemeral port by default
407 const char** constArgv = const_cast<const char**>(argv);412 const char** constArgv = const_cast<const char**>(argv);
@@ -471,6 +476,7 @@ bool setupEssentials(int& argc, char** argv) { · 63 unmodified lines
471 DependencyManager::set<InterfaceActionFactory>();476 DependencyManager::set<InterfaceActionFactory>();
472 DependencyManager::set<AudioInjectorManager>();477 DependencyManager::set<AudioInjectorManager>();
473 DependencyManager::set<MessagesClient>();478 DependencyManager::set<MessagesClient>();
479 controller::StateController::setStateVariables({ { STATE_IN_HMD, STATE_SNAP_TURN, STATE_GROUNDED, STATE_NAV_FOCUSED } });
474 DependencyManager::set<UserInputMapper>();480 DependencyManager::set<UserInputMapper>();
475 DependencyManager::set<controller::ScriptingInterface, ControllerScriptingInterface>();481 DependencyManager::set<controller::ScriptingInterface, ControllerScriptingInterface>();
476 DependencyManager::set<InterfaceParentFinder>();482 DependencyManager::set<InterfaceParentFinder>();
@@ -925,6 +931,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 448 unmodified lines
925 } else if (action == controller::toInt(controller::Action::CONTEXT_MENU)) {931 } else if (action == controller::toInt(controller::Action::CONTEXT_MENU)) {
926 auto reticlePosition = getApplicationCompositor().getReticlePosition();932 auto reticlePosition = getApplicationCompositor().getReticlePosition();
927 offscreenUi->toggleMenu(_glWidget->mapFromGlobal(QPoint(reticlePosition.x, reticlePosition.y)));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 } else if (action == controller::toInt(controller::Action::RETICLE_X)) {939 } else if (action == controller::toInt(controller::Action::RETICLE_X)) {
929 auto oldPos = getApplicationCompositor().getReticlePosition();940 auto oldPos = getApplicationCompositor().getReticlePosition();
930 getApplicationCompositor().setReticlePosition({ oldPos.x + state, oldPos.y });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 state951 _applicationStateDevice = userInputMapper->getStateDevice();
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 }));
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 // Setup the keyboardMouseDevice and the user input mapper with the default bindings966 // Setup the keyboardMouseDevice and the user input mapper with the default bindings
960 userInputMapper->registerDevice(_keyboardMouseDevice->getInputDevice());967 userInputMapper->registerDevice(_keyboardMouseDevice->getInputDevice());
961 userInputMapper->loadDefaultMapping(userInputMapper->getStandardDeviceID());
962 968
963 // force the model the look at the correct directory (weird order of operations issue)969 // force the model the look at the correct directory (weird order of operations issue)
964 scriptEngines->setScriptsLocation(scriptEngines->getScriptsLocation());970 scriptEngines->setScriptsLocation(scriptEngines->getScriptsLocation());