From fc15c7cd98f147f0b7c410904ff460bf26f6a2aa Mon Sep 17 00:00:00 2001 From: samcake Date: Wed, 28 Oct 2015 12:15:14 -0700 Subject: [PATCH] Adding the ApplicationStateDevice to the APplication class and add one entry ythere --- interface/resources/controllers/standard.json | 1 - interface/src/Application.cpp | 76 ++++++++++--------- interface/src/Application.h | 5 ++ .../src/controllers/StateController.cpp | 2 +- .../src/controllers/StateController.h | 2 +- 5 files changed, 47 insertions(+), 39 deletions(-) diff --git a/interface/resources/controllers/standard.json b/interface/resources/controllers/standard.json index 7b18641636..4ef0a1b90f 100644 --- a/interface/resources/controllers/standard.json +++ b/interface/resources/controllers/standard.json @@ -3,7 +3,6 @@ "channels": [ { "from": "Standard.LY", "to": "Actions.TranslateZ" }, { "from": "Standard.LX", "to": "Actions.TranslateX" }, - { "from": "Standard.RX", "width": "Application.InHMD", to": "Actions.StepYaw" }, { "from": "Standard.RX", "to": "Actions.Yaw" }, { "from": "Standard.RY", "to": "Actions.Pitch" }, diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9c7c152f03..d47c2b547e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -66,6 +66,7 @@ #include #include // this should probably be removed #include +#include #include #include #include @@ -143,7 +144,6 @@ #include "ui/UpdateDialog.h" #include "Util.h" -#include "controllers/StateController.h" // ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU // FIXME seems to be broken. @@ -348,36 +348,36 @@ int _keyboardFocusHighlightID{ -1 }; PluginContainer* _pluginContainer; Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : -QApplication(argc, argv), -_dependencyManagerIsSetup(setupEssentials(argc, argv)), -_window(new MainWindow(desktop())), -_toolWindow(NULL), -_undoStackScriptingInterface(&_undoStack), -_frameCount(0), -_fps(60.0f), -_physicsEngine(new PhysicsEngine(Vectors::ZERO)), -_entities(true, this, this), -_entityClipboardRenderer(false, this, this), -_entityClipboard(new EntityTree()), -_lastQueriedTime(usecTimestampNow()), -_mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), -_firstRun("firstRun", true), -_previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION), -_scriptsLocationHandle("scriptsLocation", DESKTOP_LOCATION), -_fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES), -_scaleMirror(1.0f), -_rotateMirror(0.0f), -_raiseMirror(0.0f), -_lastMouseMoveWasSimulated(false), -_enableProcessOctreeThread(true), -_runningScriptsWidget(NULL), -_runningScriptsWidgetWasVisible(false), -_lastNackTime(usecTimestampNow()), -_lastSendDownstreamAudioStats(usecTimestampNow()), -_aboutToQuit(false), -_notifiedPacketVersionMismatchThisDomain(false), -_maxOctreePPS(maxOctreePacketsPerSecond.get()), -_lastFaceTrackerUpdate(0) + QApplication(argc, argv), + _dependencyManagerIsSetup(setupEssentials(argc, argv)), + _window(new MainWindow(desktop())), + _toolWindow(NULL), + _undoStackScriptingInterface(&_undoStack), + _frameCount(0), + _fps(60.0f), + _physicsEngine(new PhysicsEngine(Vectors::ZERO)), + _entities(true, this, this), + _entityClipboardRenderer(false, this, this), + _entityClipboard(new EntityTree()), + _lastQueriedTime(usecTimestampNow()), + _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), + _firstRun("firstRun", true), + _previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION), + _scriptsLocationHandle("scriptsLocation", DESKTOP_LOCATION), + _fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES), + _scaleMirror(1.0f), + _rotateMirror(0.0f), + _raiseMirror(0.0f), + _lastMouseMoveWasSimulated(false), + _enableProcessOctreeThread(true), + _runningScriptsWidget(NULL), + _runningScriptsWidgetWasVisible(false), + _lastNackTime(usecTimestampNow()), + _lastSendDownstreamAudioStats(usecTimestampNow()), + _aboutToQuit(false), + _notifiedPacketVersionMismatchThisDomain(false), + _maxOctreePPS(maxOctreePacketsPerSecond.get()), + _lastFaceTrackerUpdate(0) { thread()->setObjectName("Main Thread"); @@ -635,13 +635,14 @@ _lastFaceTrackerUpdate(0) } }); - static controller::StateController _stateController; + // A new controllerInput device used to reflect current values from the application state + _applicationStateDevice = new controller::StateController("Application"); auto InHMDLambda = controller::StateController::ReadLambda([]() -> float { return (float) qApp->getAvatarUpdater()->isHMDMode(); }); - _stateController.addInputVariant("InHMD", InHMDLambda); + _applicationStateDevice->addInputVariant("InHMD", InHMDLambda); - userInputMapper->registerDevice(&_stateController); + userInputMapper->registerDevice(_applicationStateDevice); // Setup the keyboardMouseDevice and the user input mapper with the default bindings userInputMapper->registerDevice(_keyboardMouseDevice); @@ -807,6 +808,10 @@ void Application::cleanupBeforeQuit() { AnimDebugDraw::getInstance().shutdown(); + // FIXME: once we move to shared pointer for the INputDevice we shoud remove this naked delete: + delete _applicationStateDevice; + _applicationStateDevice = nullptr; + if (_keyboardFocusHighlightID > 0) { getOverlays().deleteOverlay(_keyboardFocusHighlightID); _keyboardFocusHighlightID = -1; @@ -2716,7 +2721,7 @@ void Application::update(float deltaTime) { auto myAvatar = getMyAvatar(); auto userInputMapper = DependencyManager::get(); userInputMapper->setSensorToWorldMat(myAvatar->getSensorToWorldMatrix()); - // userInputMapper->update(deltaTime); + userInputMapper->update(deltaTime); bool jointsCaptured = false; for (auto inputPlugin : PluginManager::getInstance()->getInputPlugins()) { @@ -2727,7 +2732,6 @@ void Application::update(float deltaTime) { } } } - userInputMapper->update(deltaTime); // Transfer the user inputs to the driveKeys // FIXME can we drop drive keys and just have the avatar read the action states directly? diff --git a/interface/src/Application.h b/interface/src/Application.h index 301eb3b262..50a39bd2eb 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -71,6 +71,10 @@ class FaceTracker; class MainWindow; class AssetUpload; +namespace controller { + class StateController; +} + #ifdef Q_OS_WIN static const UINT UWM_IDENTIFY_INSTANCES = RegisterWindowMessage("UWM_IDENTIFY_INSTANCES_{8AB82783-B74A-4258-955B-8188C22AA0D6}_" + qgetenv("USERNAME")); @@ -442,6 +446,7 @@ private: OctreeQuery _octreeQuery; // NodeData derived class for querying octee cells from octree servers + controller::StateController* _applicationStateDevice{ nullptr }; // Default ApplicationDevice reflecting the state of different properties of the session KeyboardMouseDevice* _keyboardMouseDevice{ nullptr }; // Default input device, the good old keyboard mouse and maybe touchpad AvatarUpdate* _avatarUpdate {nullptr}; SimpleMovingAverage _avatarSimsPerSecond {10}; diff --git a/libraries/controllers/src/controllers/StateController.cpp b/libraries/controllers/src/controllers/StateController.cpp index 93985fe8e3..ef735422db 100644 --- a/libraries/controllers/src/controllers/StateController.cpp +++ b/libraries/controllers/src/controllers/StateController.cpp @@ -19,7 +19,7 @@ namespace controller { -StateController::StateController() : InputDevice("Application") { +StateController::StateController(QString name) : InputDevice(name) { } StateController::~StateController() { diff --git a/libraries/controllers/src/controllers/StateController.h b/libraries/controllers/src/controllers/StateController.h index f17b31f64b..afd0456b5a 100644 --- a/libraries/controllers/src/controllers/StateController.h +++ b/libraries/controllers/src/controllers/StateController.h @@ -32,7 +32,7 @@ public: virtual void update(float deltaTime, bool jointsCaptured) override; virtual void focusOutEvent() override; - StateController(); + StateController(QString name); virtual ~StateController(); using ReadLambda = std::function;