From 8f908f987779a33a7f13b6d7e32d8892567fa03f Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 29 Oct 2015 12:08:11 -0700 Subject: [PATCH 1/5] Adding the stepYaw to the Standard mapping --- interface/resources/controllers/standard.json | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/resources/controllers/standard.json b/interface/resources/controllers/standard.json index 8ba9056076..4fe6dba923 100644 --- a/interface/resources/controllers/standard.json +++ b/interface/resources/controllers/standard.json @@ -3,6 +3,7 @@ "channels": [ { "from": "Standard.LY", "to": "Actions.TranslateZ" }, { "from": "Standard.LX", "to": "Actions.TranslateX" }, + { "from": "Standard.RX", "when": "Application.InHMD", "to": "Actions.StepYaw" }, { "from": "Standard.RX", "to": "Actions.Yaw" }, { "from": "Standard.RY", "to": "Actions.Pitch" }, From e902e5e97a725f569ab7cc344373c8197b5d8ca2 Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 29 Oct 2015 13:05:29 -0700 Subject: [PATCH 2/5] Introduce the concept of loading the default Mapping --- interface/src/Application.cpp | 2 ++ .../src/controllers/UserInputMapper.cpp | 23 +++++++++++++++++++ .../src/controllers/UserInputMapper.h | 1 + 3 files changed, 26 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4e4b4010f0..7d2929d31e 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -648,6 +648,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : userInputMapper->registerDevice(_keyboardMouseDevice); + userInputMapper->loadDefaultMapping(userInputMapper->getStandardDeviceID()); + // check first run... if (_firstRun.get()) { qCDebug(interfaceapp) << "This is a first run..."; diff --git a/libraries/controllers/src/controllers/UserInputMapper.cpp b/libraries/controllers/src/controllers/UserInputMapper.cpp index 64a2a54ef4..736fa30d37 100755 --- a/libraries/controllers/src/controllers/UserInputMapper.cpp +++ b/libraries/controllers/src/controllers/UserInputMapper.cpp @@ -129,6 +129,27 @@ void UserInputMapper::removeDevice(int deviceID) { } +void UserInputMapper::loadDefaultMapping(uint16 deviceID) { + Locker locker(_lock); + auto proxyEntry = _registeredDevices.find(deviceID); + if (_registeredDevices.end() == proxyEntry) { + qCWarning(controllers) << "Unknown deviceID " << deviceID; + return; + } + + + auto mapping = loadMapping(proxyEntry->second->getDefaultMappingConfig()); + if (mapping) { + auto prevMapping = _mappingsByDevice[deviceID]; + disableMapping(prevMapping); + + _mappingsByDevice[deviceID] = mapping; + enableMapping(mapping); + } + + emit hardwareChanged(); +} + InputDevice::Pointer UserInputMapper::getDevice(const Input& input) { Locker locker(_lock); auto device = _registeredDevices.find(input.getDevice()); @@ -711,6 +732,8 @@ Mapping::Pointer UserInputMapper::loadMapping(const QString& jsonFile) { return parseMapping(json); } + + static const QString JSON_NAME = QStringLiteral("name"); static const QString JSON_CHANNELS = QStringLiteral("channels"); static const QString JSON_CHANNEL_FROM = QStringLiteral("from"); diff --git a/libraries/controllers/src/controllers/UserInputMapper.h b/libraries/controllers/src/controllers/UserInputMapper.h index 884e303fc6..a32c3f3649 100644 --- a/libraries/controllers/src/controllers/UserInputMapper.h +++ b/libraries/controllers/src/controllers/UserInputMapper.h @@ -108,6 +108,7 @@ namespace controller { MappingPointer parseMapping(const QString& json); MappingPointer loadMapping(const QString& jsonFile); + void loadDefaultMapping(uint16 deviceID); void enableMapping(const QString& mappingName, bool enable = true); float getValue(const Input& input) const; Pose getPose(const Input& input) const; From d73eafddd1a0e2511446463fc7e0190349c0e8bd Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 29 Oct 2015 13:48:16 -0700 Subject: [PATCH 3/5] COmfort mode working with the COntroller system observing the menu state --- interface/resources/controllers/standard.json | 2 +- interface/src/Application.cpp | 11 +++++++---- .../controllers/src/controllers/StateController.cpp | 4 ++++ .../controllers/src/controllers/StateController.h | 3 +++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/interface/resources/controllers/standard.json b/interface/resources/controllers/standard.json index 4fe6dba923..5483da925d 100644 --- a/interface/resources/controllers/standard.json +++ b/interface/resources/controllers/standard.json @@ -3,7 +3,7 @@ "channels": [ { "from": "Standard.LY", "to": "Actions.TranslateZ" }, { "from": "Standard.LX", "to": "Actions.TranslateX" }, - { "from": "Standard.RX", "when": "Application.InHMD", "to": "Actions.StepYaw" }, + { "from": "Standard.RX", "when": [ "Application.InHMD", "Application.ComfortMode" ], "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 7d2929d31e..118d34230c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -637,10 +637,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : // A new controllerInput device used to reflect current values from the application state _applicationStateDevice = std::make_shared(); - auto InHMDLambda = controller::StateController::ReadLambda([]() -> float { - return (float) qApp->getAvatarUpdater()->isHMDMode(); - }); - _applicationStateDevice->addInputVariant("InHMD", InHMDLambda); + + _applicationStateDevice->addInputVariant("InHMD", controller::StateController::ReadLambda([]() -> float { + return (float)qApp->getAvatarUpdater()->isHMDMode(); + })); + _applicationStateDevice->addInputVariant("ComfortMode", controller::StateController::ReadLambda([]() -> float { + return (float)Menu::getInstance()->isOptionChecked(MenuOption::ComfortMode); + })); userInputMapper->registerDevice(_applicationStateDevice); diff --git a/libraries/controllers/src/controllers/StateController.cpp b/libraries/controllers/src/controllers/StateController.cpp index efe7a064fc..9d2f3baf86 100644 --- a/libraries/controllers/src/controllers/StateController.cpp +++ b/libraries/controllers/src/controllers/StateController.cpp @@ -43,4 +43,8 @@ Input::NamedVector StateController::getAvailableInputs() const { return availableInputs; } +EndpointPointer StateController::createEndpoint(const Input& input) const { + return std::make_shared(_namedReadLambdas[input.getChannel()].second); +} + } \ No newline at end of file diff --git a/libraries/controllers/src/controllers/StateController.h b/libraries/controllers/src/controllers/StateController.h index d664c6b8d0..7a4c386c5e 100644 --- a/libraries/controllers/src/controllers/StateController.h +++ b/libraries/controllers/src/controllers/StateController.h @@ -39,6 +39,9 @@ public: void addInputVariant(QString name, ReadLambda& lambda); + virtual EndpointPointer createEndpoint(const Input& input) const override; + + protected: QVector _namedReadLambdas; }; From f72146c35d224bffedea7a6d28195966173d14a1 Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 29 Oct 2015 14:17:52 -0700 Subject: [PATCH 4/5] FIxing the mac build --- interface/src/Application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 118d34230c..7f4b5a3c3d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -638,10 +638,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : // A new controllerInput device used to reflect current values from the application state _applicationStateDevice = std::make_shared(); - _applicationStateDevice->addInputVariant("InHMD", controller::StateController::ReadLambda([]() -> float { + _applicationStateDevice->addInputVariant(QString("InHMD"), controller::StateController::ReadLambda([]() -> float { return (float)qApp->getAvatarUpdater()->isHMDMode(); })); - _applicationStateDevice->addInputVariant("ComfortMode", controller::StateController::ReadLambda([]() -> float { + _applicationStateDevice->addInputVariant(QString("ComfortMode"), controller::StateController::ReadLambda([]() -> float { return (float)Menu::getInstance()->isOptionChecked(MenuOption::ComfortMode); })); From c1e00ca08c81fb1e3391e10f3e4e670dd6645680 Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 29 Oct 2015 14:30:51 -0700 Subject: [PATCH 5/5] FIxing the mac build again ? --- libraries/controllers/src/controllers/StateController.cpp | 2 +- libraries/controllers/src/controllers/StateController.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/controllers/src/controllers/StateController.cpp b/libraries/controllers/src/controllers/StateController.cpp index 9d2f3baf86..6f89c6365c 100644 --- a/libraries/controllers/src/controllers/StateController.cpp +++ b/libraries/controllers/src/controllers/StateController.cpp @@ -29,7 +29,7 @@ void StateController::update(float deltaTime, bool jointsCaptured) {} void StateController::focusOutEvent() {} -void StateController::addInputVariant(QString name, ReadLambda& lambda) { +void StateController::addInputVariant(QString name, ReadLambda lambda) { _namedReadLambdas.push_back(NamedReadLambda(name, lambda)); } diff --git a/libraries/controllers/src/controllers/StateController.h b/libraries/controllers/src/controllers/StateController.h index 7a4c386c5e..12f3e8b2f1 100644 --- a/libraries/controllers/src/controllers/StateController.h +++ b/libraries/controllers/src/controllers/StateController.h @@ -37,7 +37,7 @@ public: using ReadLambda = std::function; using NamedReadLambda = QPair; - void addInputVariant(QString name, ReadLambda& lambda); + void addInputVariant(QString name, ReadLambda lambda); virtual EndpointPointer createEndpoint(const Input& input) const override;