Showing the changes to interface/src/scripting/ControllerScriptingInterface.h (1 of 43 files). Show all
Unified · Split
| @@ -14,15 +14,20 @@ · 13 unmodified lines | ||
| 14 | 14 | |
| 15 | 15 | #include <QtCore/QObject> |
| 16 | 16 | |
| 17 | −#include <input-plugins/UserInputMapper.h> | |
| 17 | +#include <controllers/UserInputMapper.h> | |
| 18 | +#include <controllers/ScriptingInterface.h> | |
| 19 | + | |
| 20 | +#include <HFActionEvent.h> | |
| 21 | +#include <KeyEvent.h> | |
| 22 | +#include <MouseEvent.h> | |
| 23 | +#include <SpatialEvent.h> | |
| 24 | +#include <TouchEvent.h> | |
| 25 | +#include <WheelEvent.h> | |
| 26 | +class ScriptEngine; | |
| 18 | 27 | |
| 19 | −#include <AbstractControllerScriptingInterface.h> | |
| 20 | 28 | class PalmData; |
| 21 | −namespace controller { | |
| 22 | − class NewControllerScriptingInterface; | |
| 23 | −} | |
| 24 | 29 | |
| 25 | −class InputController : public AbstractInputController { | |
| 30 | +class InputController : public controller::InputController { | |
| 26 | 31 | Q_OBJECT |
| 27 | 32 | |
| 28 | 33 | public: |
| @@ -53,30 +58,53 @@ signals: · 24 unmodified lines | ||
| 53 | 58 | |
| 54 | 59 | |
| 55 | 60 | /// handles scripting of input controller commands from JS |
| 56 | −class ControllerScriptingInterface : public AbstractControllerScriptingInterface { | |
| 61 | +class ControllerScriptingInterface : public controller::ScriptingInterface { | |
| 57 | 62 | Q_OBJECT |
| 58 | 63 | |
| 64 | + | |
| 59 | 65 | public: |
| 60 | 66 | ControllerScriptingInterface(); |
| 61 | 67 | ~ControllerScriptingInterface(); |
| 62 | 68 | |
| 69 | + Q_INVOKABLE QVector<UserInputMapper::Action> getAllActions(); | |
| 70 | + | |
| 71 | + Q_INVOKABLE bool addInputChannel(UserInputMapper::InputChannel inputChannel); | |
| 72 | + Q_INVOKABLE bool removeInputChannel(UserInputMapper::InputChannel inputChannel); | |
| 73 | + Q_INVOKABLE QVector<UserInputMapper::InputChannel> getInputChannelsForAction(UserInputMapper::Action action); | |
| 74 | + | |
| 75 | + Q_INVOKABLE QVector<UserInputMapper::InputPair> getAvailableInputs(unsigned int device); | |
| 76 | + Q_INVOKABLE QVector<UserInputMapper::InputChannel> getAllInputsForDevice(unsigned int device); | |
| 77 | + | |
| 78 | + Q_INVOKABLE QString getDeviceName(unsigned int device); | |
| 79 | + | |
| 80 | + Q_INVOKABLE float getActionValue(int action); | |
| 81 | + | |
| 82 | + Q_INVOKABLE void resetDevice(unsigned int device); | |
| 83 | + Q_INVOKABLE void resetAllDeviceBindings(); | |
| 84 | + Q_INVOKABLE int findDevice(QString name); | |
| 85 | + Q_INVOKABLE QVector<QString> getDeviceNames(); | |
| 86 | + | |
| 87 | + Q_INVOKABLE int findAction(QString actionName); | |
| 88 | + Q_INVOKABLE QVector<QString> getActionNames() const; | |
| 89 | + | |
| 90 | + | |
| 63 | 91 | virtual void registerControllerTypes(ScriptEngine* engine); |
| 64 | 92 | |
| 65 | − void emitKeyPressEvent(QKeyEvent* event) { emit keyPressEvent(KeyEvent(*event)); } | |
| 66 | − void emitKeyReleaseEvent(QKeyEvent* event) { emit keyReleaseEvent(KeyEvent(*event)); } | |
| 93 | + void emitKeyPressEvent(QKeyEvent* event); | |
| 94 | + void emitKeyReleaseEvent(QKeyEvent* event); | |
| 67 | 95 | |
| 68 | 96 | void handleMetaEvent(HFMetaEvent* event); |
| 69 | 97 | |
| 70 | − void emitMouseMoveEvent(QMouseEvent* event, unsigned int deviceID = 0) { emit mouseMoveEvent(MouseEvent(*event, deviceID)); } | |
| 71 | − void emitMousePressEvent(QMouseEvent* event, unsigned int deviceID = 0) { emit mousePressEvent(MouseEvent(*event, deviceID)); } | |
| 72 | − void emitMouseDoublePressEvent(QMouseEvent* event, unsigned int deviceID = 0) { emit mouseDoublePressEvent(MouseEvent(*event, deviceID)); } | |
| 73 | − void emitMouseReleaseEvent(QMouseEvent* event, unsigned int deviceID = 0) { emit mouseReleaseEvent(MouseEvent(*event, deviceID)); } | |
| 98 | + void emitMouseMoveEvent(QMouseEvent* event, unsigned int deviceID = 0); | |
| 99 | + void emitMousePressEvent(QMouseEvent* event, unsigned int deviceID = 0); | |
| 100 | + void emitMouseDoublePressEvent(QMouseEvent* event, unsigned int deviceID = 0); | |
| 101 | + void emitMouseReleaseEvent(QMouseEvent* event, unsigned int deviceID = 0); | |
| 74 | 102 | |
| 75 | − void emitTouchBeginEvent(const TouchEvent& event) { emit touchBeginEvent(event); } | |
| 76 | − void emitTouchEndEvent(const TouchEvent& event) { emit touchEndEvent(event); } | |
| 77 | − void emitTouchUpdateEvent(const TouchEvent& event) { emit touchUpdateEvent(event); } | |
| 103 | + void emitTouchBeginEvent(const TouchEvent& event); | |
| 104 | + void emitTouchEndEvent(const TouchEvent& event); | |
| 105 | + void emitTouchUpdateEvent(const TouchEvent& event); | |
| 78 | 106 | |
| 79 | − void emitWheelEvent(QWheelEvent* event) { emit wheelEvent(*event); } | |
| 107 | + void emitWheelEvent(QWheelEvent* event); | |
| 80 | 108 | |
| 81 | 109 | bool isKeyCaptured(QKeyEvent* event) const; |
| 82 | 110 | bool isKeyCaptured(const KeyEvent& event) const; |
| @@ -86,48 +114,10 @@ public: · 3 unmodified lines | ||
| 86 | 114 | bool areActionsCaptured() const { return _actionsCaptured; } |
| 87 | 115 | bool isJoystickCaptured(int joystickIndex) const; |
| 88 | 116 | |
| 89 | − void updateInputControllers(); | |
| 117 | + virtual void update() override; | |
| 90 | 118 | |
| 91 | 119 | public slots: |
| 92 | − Q_INVOKABLE virtual QVector<UserInputMapper::Action> getAllActions(); | |
| 93 | − | |
| 94 | − Q_INVOKABLE virtual bool addInputChannel(UserInputMapper::InputChannel inputChannel); | |
| 95 | − Q_INVOKABLE virtual bool removeInputChannel(UserInputMapper::InputChannel inputChannel); | |
| 96 | − Q_INVOKABLE virtual QVector<UserInputMapper::InputChannel> getInputChannelsForAction(UserInputMapper::Action action); | |
| 97 | − | |
| 98 | − Q_INVOKABLE virtual QVector<UserInputMapper::InputPair> getAvailableInputs(unsigned int device); | |
| 99 | − Q_INVOKABLE virtual QVector<UserInputMapper::InputChannel> getAllInputsForDevice(unsigned int device); | |
| 100 | − | |
| 101 | − Q_INVOKABLE virtual QString getDeviceName(unsigned int device); | |
| 102 | − | |
| 103 | − Q_INVOKABLE virtual float getActionValue(int action); | |
| 104 | 120 | |
| 105 | − Q_INVOKABLE virtual void resetDevice(unsigned int device); | |
| 106 | − Q_INVOKABLE virtual void resetAllDeviceBindings(); | |
| 107 | − Q_INVOKABLE virtual int findDevice(QString name); | |
| 108 | − Q_INVOKABLE virtual QVector<QString> getDeviceNames(); | |
| 109 | − | |
| 110 | − Q_INVOKABLE virtual int findAction(QString actionName); | |
| 111 | − Q_INVOKABLE virtual QVector<QString> getActionNames() const; | |
| 112 | − | |
| 113 | − virtual bool isPrimaryButtonPressed() const; | |
| 114 | − virtual glm::vec2 getPrimaryJoystickPosition() const; | |
| 115 | − | |
| 116 | − virtual int getNumberOfButtons() const; | |
| 117 | − virtual bool isButtonPressed(int buttonIndex) const; | |
| 118 | − | |
| 119 | − virtual int getNumberOfTriggers() const; | |
| 120 | − virtual float getTriggerValue(int triggerIndex) const; | |
| 121 | − | |
| 122 | − virtual int getNumberOfJoysticks() const; | |
| 123 | − virtual glm::vec2 getJoystickPosition(int joystickIndex) const; | |
| 124 | − | |
| 125 | − virtual int getNumberOfSpatialControls() const; | |
| 126 | − virtual glm::vec3 getSpatialControlPosition(int controlIndex) const; | |
| 127 | − virtual glm::vec3 getSpatialControlVelocity(int controlIndex) const; | |
| 128 | − virtual glm::vec3 getSpatialControlNormal(int controlIndex) const; | |
| 129 | − virtual glm::quat getSpatialControlRawRotation(int controlIndex) const; | |
| 130 | − virtual glm::vec3 getSpatialControlRawAngularVelocity(int controlIndex) const; | |
| 131 | 121 | virtual void captureKeyEvents(const KeyEvent& event); |
| 132 | 122 | virtual void releaseKeyEvents(const KeyEvent& event); |
| 133 | 123 | |
| @@ -149,9 +139,31 @@ public slots: · 15 unmodified lines | ||
| 149 | 139 | virtual glm::vec2 getViewportDimensions() const; |
| 150 | 140 | |
| 151 | 141 | /// Factory to create an InputController |
| 152 | − virtual AbstractInputController* createInputController(const QString& deviceName, const QString& tracker); | |
| 142 | + virtual controller::InputController::Pointer createInputController(const QString& deviceName, const QString& tracker); | |
| 143 | + virtual void releaseInputController(controller::InputController::Pointer input); | |
| 144 | + | |
| 145 | +signals: | |
| 146 | + void keyPressEvent(const KeyEvent& event); | |
| 147 | + void keyReleaseEvent(const KeyEvent& event); | |
| 153 | 148 | |
| 154 | − virtual void releaseInputController(AbstractInputController* input); | |
| 149 | + void actionStartEvent(const HFActionEvent& event); | |
| 150 | + void actionEndEvent(const HFActionEvent& event); | |
| 151 | + | |
| 152 | + void backStartEvent(); | |
| 153 | + void backEndEvent(); | |
| 154 | + | |
| 155 | + void mouseMoveEvent(const MouseEvent& event, unsigned int deviceID = 0); | |
| 156 | + void mousePressEvent(const MouseEvent& event, unsigned int deviceID = 0); | |
| 157 | + void mouseDoublePressEvent(const MouseEvent& event, unsigned int deviceID = 0); | |
| 158 | + void mouseReleaseEvent(const MouseEvent& event, unsigned int deviceID = 0); | |
| 159 | + | |
| 160 | + void touchBeginEvent(const TouchEvent& event); | |
| 161 | + void touchEndEvent(const TouchEvent& event); | |
| 162 | + void touchUpdateEvent(const TouchEvent& event); | |
| 163 | + | |
| 164 | + void wheelEvent(const WheelEvent& event); | |
| 165 | + | |
| 166 | + void actionEvent(int action, float state); | |
| 155 | 167 | |
| 156 | 168 | private: |
| 157 | 169 | QString sanatizeName(const QString& name); /// makes a name clean for inclusing in JavaScript |
| @@ -168,12 +180,9 @@ private: · 10 unmodified lines | ||
| 168 | 180 | QMultiMap<int,KeyEvent> _capturedKeys; |
| 169 | 181 | QSet<int> _capturedJoysticks; |
| 170 | 182 | |
| 171 | − typedef std::map< AbstractInputController::Key, AbstractInputController* > InputControllerMap; | |
| 183 | + using InputKey = controller::InputController::Key; | |
| 184 | + using InputControllerMap = std::map<InputKey, controller::InputController::Pointer>; | |
| 172 | 185 | InputControllerMap _inputControllers; |
| 173 | − | |
| 174 | − void wireUpControllers(ScriptEngine* engine); | |
| 175 | − | |
| 176 | − controller::NewControllerScriptingInterface* _newControllerScriptingInterface = nullptr; | |
| 177 | 186 | }; |
| 178 | 187 | |
| 179 | 188 | const int NUMBER_OF_SPATIALCONTROLS_PER_PALM = 2; // the hand and the tip |