History

Adding the ApplicationStateDevice to the APplication class and add one entry ythere

samcake committed 11 years ago

Commit fc15c7c1 parent 57aa89d5 files · +47 −39Browse files

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

Unified · Split

interface/src/Application.cpp+40−36
@@ -66,6 +66,7 @@ · 65 unmodified lines
6666 #include <input-plugins/InputPlugin.h>
6767 #include <input-plugins/Joystick.h> // this should probably be removed
6868 #include <controllers/UserInputMapper.h>
69+#include <controllers/StateController.h>
6970 #include <LogHandler.h>
7071 #include <MainWindow.h>
7172 #include <MessageDialog.h>
@@ -143,7 +144,6 @@ · 71 unmodified lines
143144 #include "ui/UpdateDialog.h"
144145 #include "Util.h"
145146
146−#include "controllers/StateController.h"
147147
148148 // ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
149149 // FIXME seems to be broken.
@@ -348,36 +348,36 @@ int _keyboardFocusHighlightID{ -1 }; · 198 unmodified lines
348348 PluginContainer* _pluginContainer;
349349
350350 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)
381381 {
382382 thread()->setObjectName("Main Thread");
383383
@@ -635,13 +635,14 @@ _lastFaceTrackerUpdate(0) · 251 unmodified lines
635635 }
636636 });
637637
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");
639640 auto InHMDLambda = controller::StateController::ReadLambda([]() -> float {
640641 return (float) qApp->getAvatarUpdater()->isHMDMode();
641642 });
642− _stateController.addInputVariant("InHMD", InHMDLambda);
643+ _applicationStateDevice->addInputVariant("InHMD", InHMDLambda);
643644
644− userInputMapper->registerDevice(&_stateController);
645+ userInputMapper->registerDevice(_applicationStateDevice);
645646
646647 // Setup the keyboardMouseDevice and the user input mapper with the default bindings
647648 userInputMapper->registerDevice(_keyboardMouseDevice);
@@ -807,6 +808,10 @@ void Application::cleanupBeforeQuit() { · 159 unmodified lines
807808
808809 AnimDebugDraw::getInstance().shutdown();
809810
811+ // FIXME: once we move to shared pointer for the INputDevice we shoud remove this naked delete:
812+ delete _applicationStateDevice;
813+ _applicationStateDevice = nullptr;
814+
810815 if (_keyboardFocusHighlightID > 0) {
811816 getOverlays().deleteOverlay(_keyboardFocusHighlightID);
812817 _keyboardFocusHighlightID = -1;
@@ -2716,7 +2721,7 @@ void Application::update(float deltaTime) { · 1903 unmodified lines
27162721 auto myAvatar = getMyAvatar();
27172722 auto userInputMapper = DependencyManager::get<UserInputMapper>();
27182723 userInputMapper->setSensorToWorldMat(myAvatar->getSensorToWorldMatrix());
2719− // userInputMapper->update(deltaTime);
2724+ userInputMapper->update(deltaTime);
27202725
27212726 bool jointsCaptured = false;
27222727 for (auto inputPlugin : PluginManager::getInstance()->getInputPlugins()) {
@@ -2727,7 +2732,6 @@ void Application::update(float deltaTime) { · 4 unmodified lines
27272732 }
27282733 }
27292734 }
2730− userInputMapper->update(deltaTime);
27312735
27322736 // Transfer the user inputs to the driveKeys
27332737 // FIXME can we drop drive keys and just have the avatar read the action states directly?

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t