- Introduce the DeviceTracker class to abstract all the possible devices - Introduce the MotionTracker ( a DeviceTracker ) that contains a transform tree of joints - Add Leapmotion class as a MotionTracker and the support for the Leapmotion sdk in external - Add InputController as the abstraction of a MotionTracker/Joint for Javascript
Showing the changes to interface/src/scripting/ControllerScriptingInterface.h (1 of 33 files). Show all
Unified · Split
| @@ -17,6 +17,38 @@ · 16 unmodified lines | |||
| 17 | #include <AbstractControllerScriptingInterface.h> | 17 | #include <AbstractControllerScriptingInterface.h> |
| 18 | class PalmData; | 18 | class PalmData; |
| 19 | 19 | ||
| 20 | |||
| 21 | class InputController : public AbstractInputController { | ||
| 22 | Q_OBJECT | ||
| 23 | |||
| 24 | public: | ||
| 25 | InputController(int deviceTrackerId, int subTrackerId, QObject* parent = NULL); | ||
| 26 | |||
| 27 | virtual void update(); | ||
| 28 | virtual Key getKey() const; | ||
| 29 | |||
| 30 | public slots: | ||
| 31 | |||
| 32 | virtual bool isActive() const { return _isActive; } | ||
| 33 | virtual glm::vec3 getAbsTranslation() const { return _eventCache.absTranslation; } | ||
| 34 | virtual glm::quat getAbsRotation() const { return _eventCache.absRotation; } | ||
| 35 | virtual glm::vec3 getLocTranslation() const { return _eventCache.locTranslation; } | ||
| 36 | virtual glm::quat getLocRotation() const { return _eventCache.locRotation; } | ||
| 37 | |||
| 38 | private: | ||
| 39 | |||
| 40 | int _deviceTrackerId; | ||
| 41 | int _subTrackerId; | ||
| 42 | |||
| 43 | // cache for the spatial | ||
| 44 | SpatialEvent _eventCache; | ||
| 45 | bool _isActive; | ||
| 46 | |||
| 47 | |||
| 48 | signals: | ||
| 49 | }; | ||
| 50 | |||
| 51 | |||
| 20 | /// handles scripting of input controller commands from JS | 52 | /// handles scripting of input controller commands from JS |
| 21 | class ControllerScriptingInterface : public AbstractControllerScriptingInterface { | 53 | class ControllerScriptingInterface : public AbstractControllerScriptingInterface { |
| 22 | Q_OBJECT | 54 | Q_OBJECT |
| @@ -43,6 +75,10 @@ public: · 20 unmodified lines | |||
| 43 | bool isWheelCaptured() const { return _wheelCaptured; } | 75 | bool isWheelCaptured() const { return _wheelCaptured; } |
| 44 | bool isJoystickCaptured(int joystickIndex) const; | 76 | bool isJoystickCaptured(int joystickIndex) const; |
| 45 | 77 | ||
| 78 | void updateInputControllers(); | ||
| 79 | |||
| 80 | void releaseInputController( AbstractInputController* input ); | ||
| 81 | |||
| 46 | public slots: | 82 | public slots: |
| 47 | virtual bool isPrimaryButtonPressed() const; | 83 | virtual bool isPrimaryButtonPressed() const; |
| 48 | virtual glm::vec2 getPrimaryJoystickPosition() const; | 84 | virtual glm::vec2 getPrimaryJoystickPosition() const; |
| @@ -78,6 +114,8 @@ public slots: · 29 unmodified lines | |||
| 78 | 114 | ||
| 79 | virtual glm::vec2 getViewportDimensions() const; | 115 | virtual glm::vec2 getViewportDimensions() const; |
| 80 | 116 | ||
| 117 | virtual AbstractInputController* createInputController( const QString& category, const QString& tracker ); | ||
| 118 | |||
| 81 | private: | 119 | private: |
| 82 | const PalmData* getPrimaryPalm() const; | 120 | const PalmData* getPrimaryPalm() const; |
| 83 | const PalmData* getPalm(int palmIndex) const; | 121 | const PalmData* getPalm(int palmIndex) const; |
| @@ -89,6 +127,9 @@ private: · 5 unmodified lines | |||
| 89 | bool _wheelCaptured; | 127 | bool _wheelCaptured; |
| 90 | QMultiMap<int,KeyEvent> _capturedKeys; | 128 | QMultiMap<int,KeyEvent> _capturedKeys; |
| 91 | QSet<int> _capturedJoysticks; | 129 | QSet<int> _capturedJoysticks; |
| 130 | |||
| 131 | typedef std::map< AbstractInputController::Key, AbstractInputController* > InputControllerMap; | ||
| 132 | InputControllerMap _inputControllers; | ||
| 92 | }; | 133 | }; |
| 93 | 134 | ||
| 94 | const int NUMBER_OF_SPATIALCONTROLS_PER_PALM = 2; // the hand and the tip | 135 | const int NUMBER_OF_SPATIALCONTROLS_PER_PALM = 2; // the hand and the tip |
| @@ -98,4 +139,5 @@ const int NUMBER_OF_BUTTONS_PER_PALM = 6; · 3 unmodified lines | |||
| 98 | const int PALM_SPATIALCONTROL = 0; | 139 | const int PALM_SPATIALCONTROL = 0; |
| 99 | const int TIP_SPATIALCONTROL = 1; | 140 | const int TIP_SPATIALCONTROL = 1; |
| 100 | 141 | ||
| 142 | |||
| 101 | #endif // hifi_ControllerScriptingInterface_h | 143 | #endif // hifi_ControllerScriptingInterface_h |