From ebeb87ba62d7c6b0b82e3fc6bfd69ccc42e38553 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 12 Oct 2015 11:21:40 -0700 Subject: [PATCH 1/3] test --- libraries/input-plugins/src/input-plugins/StandardController.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/input-plugins/src/input-plugins/StandardController.h b/libraries/input-plugins/src/input-plugins/StandardController.h index fa660e15b8..7e0e163358 100644 --- a/libraries/input-plugins/src/input-plugins/StandardController.h +++ b/libraries/input-plugins/src/input-plugins/StandardController.h @@ -21,6 +21,7 @@ typedef std::shared_ptr StandardControllerPointer; +// small change class StandardController : public QObject, public InputDevice { Q_OBJECT Q_PROPERTY(QString name READ getName) From f860ca923ef84a47cd93c25daf4e5ed2d367e121 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 12 Oct 2015 16:01:26 -0700 Subject: [PATCH 2/3] revert small hack --- libraries/input-plugins/src/input-plugins/StandardController.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/input-plugins/src/input-plugins/StandardController.h b/libraries/input-plugins/src/input-plugins/StandardController.h index 7e0e163358..fa660e15b8 100644 --- a/libraries/input-plugins/src/input-plugins/StandardController.h +++ b/libraries/input-plugins/src/input-plugins/StandardController.h @@ -21,7 +21,6 @@ typedef std::shared_ptr StandardControllerPointer; -// small change class StandardController : public QObject, public InputDevice { Q_OBJECT Q_PROPERTY(QString name READ getName) From 9a9bdbbc4462d78769f08ce2f58241e5a98b7b65 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 12 Oct 2015 17:59:58 -0700 Subject: [PATCH 3/3] hack in mappings to interface --- .../example/scripts/controllerScriptingExamples.js | 14 ++++++++++++++ .../src/scripting/ControllerScriptingInterface.cpp | 12 ++++++++++++ .../src/scripting/ControllerScriptingInterface.h | 7 ++++++- .../src/input-plugins/InputPlugin.cpp | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/examples/example/scripts/controllerScriptingExamples.js b/examples/example/scripts/controllerScriptingExamples.js index 6db7b38705..e678ff26eb 100644 --- a/examples/example/scripts/controllerScriptingExamples.js +++ b/examples/example/scripts/controllerScriptingExamples.js @@ -12,6 +12,20 @@ // Assumes you only have the default keyboard connected + +var hydra = Controller.Hardware.Hydra2; +if (hydra !== undefined) { + print("-----------------------------------"); + var mapping = NewControllers.newMapping("Default"); + var standard = Controller.Standard; + print("standard:" + standard); + mapping.from(hydra.LeftButton1).to(standard.A); + mapping.from(hydra.LeftButton2).to(standard.B); + mapping.from(hydra.LeftButton3).to(standard.X); + NewControllers.enableMapping("Default"); + print("-----------------------------------"); +} + Object.keys(Controller.Standard).forEach(function (input) { print("Controller.Standard." + input + ":" + Controller.Standard[input]); }); diff --git a/interface/src/scripting/ControllerScriptingInterface.cpp b/interface/src/scripting/ControllerScriptingInterface.cpp index 9bdf8d1a4a..54aa72da6b 100644 --- a/interface/src/scripting/ControllerScriptingInterface.cpp +++ b/interface/src/scripting/ControllerScriptingInterface.cpp @@ -14,6 +14,8 @@ #include #include +#include + #include "Application.h" #include "devices/MotionTracker.h" #include "ControllerScriptingInterface.h" @@ -31,6 +33,11 @@ ControllerScriptingInterface::ControllerScriptingInterface() : } +ControllerScriptingInterface::~ControllerScriptingInterface() { + delete _newControllerScriptingInterface; +} + + static int actionMetaTypeId = qRegisterMetaType(); static int inputChannelMetaTypeId = qRegisterMetaType(); static int inputMetaTypeId = qRegisterMetaType(); @@ -121,6 +128,11 @@ void ControllerScriptingInterface::registerControllerTypes(ScriptEngine* engine) qScriptRegisterMetaType(engine, inputPairToScriptValue, inputPairFromScriptValue); wireUpControllers(engine); + + // hack in the new controller scripting interface... + _newControllerScriptingInterface = new controller::NewControllerScriptingInterface(); + engine->registerGlobalObject("NewControllers", _newControllerScriptingInterface); + } void ControllerScriptingInterface::handleMetaEvent(HFMetaEvent* event) { diff --git a/interface/src/scripting/ControllerScriptingInterface.h b/interface/src/scripting/ControllerScriptingInterface.h index aa0526accb..dfe87043cd 100644 --- a/interface/src/scripting/ControllerScriptingInterface.h +++ b/interface/src/scripting/ControllerScriptingInterface.h @@ -18,6 +18,9 @@ #include class PalmData; +namespace controller { + class NewControllerScriptingInterface; +} class InputController : public AbstractInputController { Q_OBJECT @@ -55,7 +58,8 @@ class ControllerScriptingInterface : public AbstractControllerScriptingInterface public: ControllerScriptingInterface(); - + ~ControllerScriptingInterface(); + virtual void registerControllerTypes(ScriptEngine* engine); void emitKeyPressEvent(QKeyEvent* event) { emit keyPressEvent(KeyEvent(*event)); } @@ -169,6 +173,7 @@ private: void wireUpControllers(ScriptEngine* engine); + controller::NewControllerScriptingInterface* _newControllerScriptingInterface = nullptr; }; const int NUMBER_OF_SPATIALCONTROLS_PER_PALM = 2; // the hand and the tip diff --git a/libraries/input-plugins/src/input-plugins/InputPlugin.cpp b/libraries/input-plugins/src/input-plugins/InputPlugin.cpp index b52dd3f658..2b16d905f5 100644 --- a/libraries/input-plugins/src/input-plugins/InputPlugin.cpp +++ b/libraries/input-plugins/src/input-plugins/InputPlugin.cpp @@ -22,7 +22,7 @@ InputPluginList getInputPlugins() { InputPlugin* PLUGIN_POOL[] = { new KeyboardMouseDevice(), new SDL2Manager(), - //new SixenseManager(), + new SixenseManager(), //new ViveControllerManager(), nullptr };