Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all
Unified · Split
| @@ -66,6 +66,7 @@ · 65 unmodified lines | ||
| 66 | 66 | #include <input-plugins/InputPlugin.h> |
| 67 | 67 | #include <input-plugins/Joystick.h> // this should probably be removed |
| 68 | 68 | #include <controllers/UserInputMapper.h> |
| 69 | +#include <controllers/StateController.h> | |
| 69 | 70 | #include <LogHandler.h> |
| 70 | 71 | #include <MainWindow.h> |
| 71 | 72 | #include <MessageDialog.h> |
| @@ -143,7 +144,6 @@ · 71 unmodified lines | ||
| 143 | 144 | #include "ui/UpdateDialog.h" |
| 144 | 145 | #include "Util.h" |
| 145 | 146 | |
| 146 | −#include "controllers/StateController.h" | |
| 147 | 147 | |
| 148 | 148 | // ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU |
| 149 | 149 | // FIXME seems to be broken. |
| @@ -348,36 +348,36 @@ int _keyboardFocusHighlightID{ -1 }; · 198 unmodified lines | ||
| 348 | 348 | PluginContainer* _pluginContainer; |
| 349 | 349 | |
| 350 | 350 | Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : |
| 351 | −QApplication(argc, argv), | |
| 352 | −_dependencyManagerIsSetup(setupEssentials(argc, argv)), | |
| 353 | −_window(new MainWindow(desktop())), | |
| 354 | −_toolWindow(NULL), | |
| 355 | −_undoStackScriptingInterface(&_undoStack), | |
| 356 | −_frameCount(0), | |
| 357 | −_fps(60.0f), | |
| 358 | −_physicsEngine(new PhysicsEngine(Vectors::ZERO)), | |
| 359 | −_entities(true, this, this), | |
| 360 | −_entityClipboardRenderer(false, this, this), | |
| 361 | −_entityClipboard(new EntityTree()), | |
| 362 | −_lastQueriedTime(usecTimestampNow()), | |
| 363 | −_mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), | |
| 364 | −_firstRun("firstRun", true), | |
| 365 | −_previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION), | |
| 366 | −_scriptsLocationHandle("scriptsLocation", DESKTOP_LOCATION), | |
| 367 | −_fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES), | |
| 368 | −_scaleMirror(1.0f), | |
| 369 | −_rotateMirror(0.0f), | |
| 370 | −_raiseMirror(0.0f), | |
| 371 | −_lastMouseMoveWasSimulated(false), | |
| 372 | −_enableProcessOctreeThread(true), | |
| 373 | −_runningScriptsWidget(NULL), | |
| 374 | −_runningScriptsWidgetWasVisible(false), | |
| 375 | −_lastNackTime(usecTimestampNow()), | |
| 376 | −_lastSendDownstreamAudioStats(usecTimestampNow()), | |
| 377 | −_aboutToQuit(false), | |
| 378 | −_notifiedPacketVersionMismatchThisDomain(false), | |
| 379 | −_maxOctreePPS(maxOctreePacketsPerSecond.get()), | |
| 380 | −_lastFaceTrackerUpdate(0) | |
| 351 | + QApplication(argc, argv), | |
| 352 | + _dependencyManagerIsSetup(setupEssentials(argc, argv)), | |
| 353 | + _window(new MainWindow(desktop())), | |
| 354 | + _toolWindow(NULL), | |
| 355 | + _undoStackScriptingInterface(&_undoStack), | |
| 356 | + _frameCount(0), | |
| 357 | + _fps(60.0f), | |
| 358 | + _physicsEngine(new PhysicsEngine(Vectors::ZERO)), | |
| 359 | + _entities(true, this, this), | |
| 360 | + _entityClipboardRenderer(false, this, this), | |
| 361 | + _entityClipboard(new EntityTree()), | |
| 362 | + _lastQueriedTime(usecTimestampNow()), | |
| 363 | + _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), | |
| 364 | + _firstRun("firstRun", true), | |
| 365 | + _previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION), | |
| 366 | + _scriptsLocationHandle("scriptsLocation", DESKTOP_LOCATION), | |
| 367 | + _fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES), | |
| 368 | + _scaleMirror(1.0f), | |
| 369 | + _rotateMirror(0.0f), | |
| 370 | + _raiseMirror(0.0f), | |
| 371 | + _lastMouseMoveWasSimulated(false), | |
| 372 | + _enableProcessOctreeThread(true), | |
| 373 | + _runningScriptsWidget(NULL), | |
| 374 | + _runningScriptsWidgetWasVisible(false), | |
| 375 | + _lastNackTime(usecTimestampNow()), | |
| 376 | + _lastSendDownstreamAudioStats(usecTimestampNow()), | |
| 377 | + _aboutToQuit(false), | |
| 378 | + _notifiedPacketVersionMismatchThisDomain(false), | |
| 379 | + _maxOctreePPS(maxOctreePacketsPerSecond.get()), | |
| 380 | + _lastFaceTrackerUpdate(0) | |
| 381 | 381 | { |
| 382 | 382 | thread()->setObjectName("Main Thread"); |
| 383 | 383 | |
| @@ -635,13 +635,14 @@ _lastFaceTrackerUpdate(0) · 251 unmodified lines | ||
| 635 | 635 | } |
| 636 | 636 | }); |
| 637 | 637 | |
| 638 | − static controller::StateController _stateController; | |
| 638 | + // A new controllerInput device used to reflect current values from the application state | |
| 639 | + _applicationStateDevice = new controller::StateController("Application"); | |
| 639 | 640 | auto InHMDLambda = controller::StateController::ReadLambda([]() -> float { |
| 640 | 641 | return (float) qApp->getAvatarUpdater()->isHMDMode(); |
| 641 | 642 | }); |
| 642 | − _stateController.addInputVariant("InHMD", InHMDLambda); | |
| 643 | + _applicationStateDevice->addInputVariant("InHMD", InHMDLambda); | |
| 643 | 644 | |
| 644 | − userInputMapper->registerDevice(&_stateController); | |
| 645 | + userInputMapper->registerDevice(_applicationStateDevice); | |
| 645 | 646 | |
| 646 | 647 | // Setup the keyboardMouseDevice and the user input mapper with the default bindings |
| 647 | 648 | userInputMapper->registerDevice(_keyboardMouseDevice); |
| @@ -807,6 +808,10 @@ void Application::cleanupBeforeQuit() { · 159 unmodified lines | ||
| 807 | 808 | |
| 808 | 809 | AnimDebugDraw::getInstance().shutdown(); |
| 809 | 810 | |
| 811 | + // FIXME: once we move to shared pointer for the INputDevice we shoud remove this naked delete: | |
| 812 | + delete _applicationStateDevice; | |
| 813 | + _applicationStateDevice = nullptr; | |
| 814 | + | |
| 810 | 815 | if (_keyboardFocusHighlightID > 0) { |
| 811 | 816 | getOverlays().deleteOverlay(_keyboardFocusHighlightID); |
| 812 | 817 | _keyboardFocusHighlightID = -1; |
| @@ -2716,7 +2721,7 @@ void Application::update(float deltaTime) { · 1903 unmodified lines | ||
| 2716 | 2721 | auto myAvatar = getMyAvatar(); |
| 2717 | 2722 | auto userInputMapper = DependencyManager::get<UserInputMapper>(); |
| 2718 | 2723 | userInputMapper->setSensorToWorldMat(myAvatar->getSensorToWorldMatrix()); |
| 2719 | − // userInputMapper->update(deltaTime); | |
| 2724 | + userInputMapper->update(deltaTime); | |
| 2720 | 2725 | |
| 2721 | 2726 | bool jointsCaptured = false; |
| 2722 | 2727 | for (auto inputPlugin : PluginManager::getInstance()->getInputPlugins()) { |
| @@ -2727,7 +2732,6 @@ void Application::update(float deltaTime) { · 4 unmodified lines | ||
| 2727 | 2732 | } |
| 2728 | 2733 | } |
| 2729 | 2734 | } |
| 2730 | − userInputMapper->update(deltaTime); | |
| 2731 | 2735 | |
| 2732 | 2736 | // Transfer the user inputs to the driveKeys |
| 2733 | 2737 | // FIXME can we drop drive keys and just have the avatar read the action states directly? |