History

Support for LeapMotion and worklist 19734

- 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

samcake committed 12 years ago

Commit 3ce455a1 parent fe0374333 files · +7810 −197Browse files

Showing the changes to interface/src/scripting/ControllerScriptingInterface.h (1 of 33 files). Show all

Unified · Split

interface/src/scripting/ControllerScriptingInterface.h+42−0
@@ -17,6 +17,38 @@ · 16 unmodified lines
1717 #include <AbstractControllerScriptingInterface.h>
1818 class PalmData;
1919
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+
2052 /// handles scripting of input controller commands from JS
2153 class ControllerScriptingInterface : public AbstractControllerScriptingInterface {
2254 Q_OBJECT
@@ -43,6 +75,10 @@ public: · 20 unmodified lines
4375 bool isWheelCaptured() const { return _wheelCaptured; }
4476 bool isJoystickCaptured(int joystickIndex) const;
4577
78+ void updateInputControllers();
79+
80+ void releaseInputController( AbstractInputController* input );
81+
4682 public slots:
4783 virtual bool isPrimaryButtonPressed() const;
4884 virtual glm::vec2 getPrimaryJoystickPosition() const;
@@ -78,6 +114,8 @@ public slots: · 29 unmodified lines
78114
79115 virtual glm::vec2 getViewportDimensions() const;
80116
117+ virtual AbstractInputController* createInputController( const QString& category, const QString& tracker );
118+
81119 private:
82120 const PalmData* getPrimaryPalm() const;
83121 const PalmData* getPalm(int palmIndex) const;
@@ -89,6 +127,9 @@ private: · 5 unmodified lines
89127 bool _wheelCaptured;
90128 QMultiMap<int,KeyEvent> _capturedKeys;
91129 QSet<int> _capturedJoysticks;
130+
131+ typedef std::map< AbstractInputController::Key, AbstractInputController* > InputControllerMap;
132+ InputControllerMap _inputControllers;
92133 };
93134
94135 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
98139 const int PALM_SPATIALCONTROL = 0;
99140 const int TIP_SPATIALCONTROL = 1;
100141
142+
101143 #endif // hifi_ControllerScriptingInterface_h

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