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

This commit is contained in:
samcake 2015-10-28 12:15:14 -07:00
parent 57aa89d14f
commit fc15c7cd98
5 changed files with 47 additions and 39 deletions

View file

@ -3,7 +3,6 @@
"channels": [ "channels": [
{ "from": "Standard.LY", "to": "Actions.TranslateZ" }, { "from": "Standard.LY", "to": "Actions.TranslateZ" },
{ "from": "Standard.LX", "to": "Actions.TranslateX" }, { "from": "Standard.LX", "to": "Actions.TranslateX" },
{ "from": "Standard.RX", "width": "Application.InHMD", to": "Actions.StepYaw" },
{ "from": "Standard.RX", "to": "Actions.Yaw" }, { "from": "Standard.RX", "to": "Actions.Yaw" },
{ "from": "Standard.RY", "to": "Actions.Pitch" }, { "from": "Standard.RY", "to": "Actions.Pitch" },

View file

@ -66,6 +66,7 @@
#include <input-plugins/InputPlugin.h> #include <input-plugins/InputPlugin.h>
#include <input-plugins/Joystick.h> // this should probably be removed #include <input-plugins/Joystick.h> // this should probably be removed
#include <controllers/UserInputMapper.h> #include <controllers/UserInputMapper.h>
#include <controllers/StateController.h>
#include <LogHandler.h> #include <LogHandler.h>
#include <MainWindow.h> #include <MainWindow.h>
#include <MessageDialog.h> #include <MessageDialog.h>
@ -143,7 +144,6 @@
#include "ui/UpdateDialog.h" #include "ui/UpdateDialog.h"
#include "Util.h" #include "Util.h"
#include "controllers/StateController.h"
// ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU // ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
// FIXME seems to be broken. // FIXME seems to be broken.
@ -348,36 +348,36 @@ int _keyboardFocusHighlightID{ -1 };
PluginContainer* _pluginContainer; PluginContainer* _pluginContainer;
Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
QApplication(argc, argv), QApplication(argc, argv),
_dependencyManagerIsSetup(setupEssentials(argc, argv)), _dependencyManagerIsSetup(setupEssentials(argc, argv)),
_window(new MainWindow(desktop())), _window(new MainWindow(desktop())),
_toolWindow(NULL), _toolWindow(NULL),
_undoStackScriptingInterface(&_undoStack), _undoStackScriptingInterface(&_undoStack),
_frameCount(0), _frameCount(0),
_fps(60.0f), _fps(60.0f),
_physicsEngine(new PhysicsEngine(Vectors::ZERO)), _physicsEngine(new PhysicsEngine(Vectors::ZERO)),
_entities(true, this, this), _entities(true, this, this),
_entityClipboardRenderer(false, this, this), _entityClipboardRenderer(false, this, this),
_entityClipboard(new EntityTree()), _entityClipboard(new EntityTree()),
_lastQueriedTime(usecTimestampNow()), _lastQueriedTime(usecTimestampNow()),
_mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),
_firstRun("firstRun", true), _firstRun("firstRun", true),
_previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION), _previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION),
_scriptsLocationHandle("scriptsLocation", DESKTOP_LOCATION), _scriptsLocationHandle("scriptsLocation", DESKTOP_LOCATION),
_fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES), _fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES),
_scaleMirror(1.0f), _scaleMirror(1.0f),
_rotateMirror(0.0f), _rotateMirror(0.0f),
_raiseMirror(0.0f), _raiseMirror(0.0f),
_lastMouseMoveWasSimulated(false), _lastMouseMoveWasSimulated(false),
_enableProcessOctreeThread(true), _enableProcessOctreeThread(true),
_runningScriptsWidget(NULL), _runningScriptsWidget(NULL),
_runningScriptsWidgetWasVisible(false), _runningScriptsWidgetWasVisible(false),
_lastNackTime(usecTimestampNow()), _lastNackTime(usecTimestampNow()),
_lastSendDownstreamAudioStats(usecTimestampNow()), _lastSendDownstreamAudioStats(usecTimestampNow()),
_aboutToQuit(false), _aboutToQuit(false),
_notifiedPacketVersionMismatchThisDomain(false), _notifiedPacketVersionMismatchThisDomain(false),
_maxOctreePPS(maxOctreePacketsPerSecond.get()), _maxOctreePPS(maxOctreePacketsPerSecond.get()),
_lastFaceTrackerUpdate(0) _lastFaceTrackerUpdate(0)
{ {
thread()->setObjectName("Main Thread"); 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 { auto InHMDLambda = controller::StateController::ReadLambda([]() -> float {
return (float) qApp->getAvatarUpdater()->isHMDMode(); 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 // Setup the keyboardMouseDevice and the user input mapper with the default bindings
userInputMapper->registerDevice(_keyboardMouseDevice); userInputMapper->registerDevice(_keyboardMouseDevice);
@ -807,6 +808,10 @@ void Application::cleanupBeforeQuit() {
AnimDebugDraw::getInstance().shutdown(); 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) { if (_keyboardFocusHighlightID > 0) {
getOverlays().deleteOverlay(_keyboardFocusHighlightID); getOverlays().deleteOverlay(_keyboardFocusHighlightID);
_keyboardFocusHighlightID = -1; _keyboardFocusHighlightID = -1;
@ -2716,7 +2721,7 @@ void Application::update(float deltaTime) {
auto myAvatar = getMyAvatar(); auto myAvatar = getMyAvatar();
auto userInputMapper = DependencyManager::get<UserInputMapper>(); auto userInputMapper = DependencyManager::get<UserInputMapper>();
userInputMapper->setSensorToWorldMat(myAvatar->getSensorToWorldMatrix()); userInputMapper->setSensorToWorldMat(myAvatar->getSensorToWorldMatrix());
// userInputMapper->update(deltaTime); userInputMapper->update(deltaTime);
bool jointsCaptured = false; bool jointsCaptured = false;
for (auto inputPlugin : PluginManager::getInstance()->getInputPlugins()) { 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 // Transfer the user inputs to the driveKeys
// FIXME can we drop drive keys and just have the avatar read the action states directly? // FIXME can we drop drive keys and just have the avatar read the action states directly?

View file

@ -71,6 +71,10 @@ class FaceTracker;
class MainWindow; class MainWindow;
class AssetUpload; class AssetUpload;
namespace controller {
class StateController;
}
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
static const UINT UWM_IDENTIFY_INSTANCES = static const UINT UWM_IDENTIFY_INSTANCES =
RegisterWindowMessage("UWM_IDENTIFY_INSTANCES_{8AB82783-B74A-4258-955B-8188C22AA0D6}_" + qgetenv("USERNAME")); 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 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 KeyboardMouseDevice* _keyboardMouseDevice{ nullptr }; // Default input device, the good old keyboard mouse and maybe touchpad
AvatarUpdate* _avatarUpdate {nullptr}; AvatarUpdate* _avatarUpdate {nullptr};
SimpleMovingAverage _avatarSimsPerSecond {10}; SimpleMovingAverage _avatarSimsPerSecond {10};

View file

@ -19,7 +19,7 @@
namespace controller { namespace controller {
StateController::StateController() : InputDevice("Application") { StateController::StateController(QString name) : InputDevice(name) {
} }
StateController::~StateController() { StateController::~StateController() {

View file

@ -32,7 +32,7 @@ public:
virtual void update(float deltaTime, bool jointsCaptured) override; virtual void update(float deltaTime, bool jointsCaptured) override;
virtual void focusOutEvent() override; virtual void focusOutEvent() override;
StateController(); StateController(QString name);
virtual ~StateController(); virtual ~StateController();
using ReadLambda = std::function<float()>; using ReadLambda = std::function<float()>;