History

reorganize files in interface directory

ZappoMan committed 12 years ago

Commit a56b7e31 parent 98041b144 files · +21 −19Browse files

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

Unified · Split

interface/src/scripting/ControllerScriptingInterface.h+99−0
@@ -0,0 +1,99 @@
1
2//
3// ControllerScriptingInterface.h
4// hifi
5//
6// Created by Brad Hefta-Gaub on 12/17/13
7// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
8//
9
10#ifndef __hifi__ControllerScriptingInterface__
11#define __hifi__ControllerScriptingInterface__
12
13#include <QtCore/QObject>
14
15#include <AbstractControllerScriptingInterface.h>
16class PalmData;
17
18/// handles scripting of input controller commands from JS
19class ControllerScriptingInterface : public AbstractControllerScriptingInterface {
20 Q_OBJECT
21
22public:
23 ControllerScriptingInterface();
24 void emitKeyPressEvent(QKeyEvent* event) { emit keyPressEvent(KeyEvent(*event)); }
25 void emitKeyReleaseEvent(QKeyEvent* event) { emit keyReleaseEvent(KeyEvent(*event)); }
26
27 void emitMouseMoveEvent(QMouseEvent* event) { emit mouseMoveEvent(MouseEvent(*event)); }
28 void emitMousePressEvent(QMouseEvent* event) { emit mousePressEvent(MouseEvent(*event)); }
29 void emitMouseReleaseEvent(QMouseEvent* event) { emit mouseReleaseEvent(MouseEvent(*event)); }
30
31 void emitTouchBeginEvent(const TouchEvent& event) { emit touchBeginEvent(event); }
32 void emitTouchEndEvent(const TouchEvent& event) { emit touchEndEvent(event); }
33 void emitTouchUpdateEvent(const TouchEvent& event) { emit touchUpdateEvent(event); }
34
35 void emitWheelEvent(QWheelEvent* event) { emit wheelEvent(*event); }
36
37 bool isKeyCaptured(QKeyEvent* event) const;
38 bool isKeyCaptured(const KeyEvent& event) const;
39 bool isMouseCaptured() const { return _mouseCaptured; }
40 bool isTouchCaptured() const { return _touchCaptured; }
41 bool isWheelCaptured() const { return _wheelCaptured; }
42 bool isJoystickCaptured(int joystickIndex) const;
43
44public slots:
45 virtual bool isPrimaryButtonPressed() const;
46 virtual glm::vec2 getPrimaryJoystickPosition() const;
47
48 virtual int getNumberOfButtons() const;
49 virtual bool isButtonPressed(int buttonIndex) const;
50
51 virtual int getNumberOfTriggers() const;
52 virtual float getTriggerValue(int triggerIndex) const;
53
54 virtual int getNumberOfJoysticks() const;
55 virtual glm::vec2 getJoystickPosition(int joystickIndex) const;
56
57 virtual int getNumberOfSpatialControls() const;
58 virtual glm::vec3 getSpatialControlPosition(int controlIndex) const;
59 virtual glm::vec3 getSpatialControlVelocity(int controlIndex) const;
60 virtual glm::vec3 getSpatialControlNormal(int controlIndex) const;
61 virtual glm::quat getSpatialControlRawRotation(int controlIndex) const;
62 virtual void captureKeyEvents(const KeyEvent& event);
63 virtual void releaseKeyEvents(const KeyEvent& event);
64
65 virtual void captureMouseEvents() { _mouseCaptured = true; }
66 virtual void releaseMouseEvents() { _mouseCaptured = false; }
67
68 virtual void captureTouchEvents() { _touchCaptured = true; }
69 virtual void releaseTouchEvents() { _touchCaptured = false; }
70
71 virtual void captureWheelEvents() { _wheelCaptured = true; }
72 virtual void releaseWheelEvents() { _wheelCaptured = false; }
73
74 virtual void captureJoystick(int joystickIndex);
75 virtual void releaseJoystick(int joystickIndex);
76
77 virtual glm::vec2 getViewportDimensions() const;
78
79private:
80 const PalmData* getPrimaryPalm() const;
81 const PalmData* getPalm(int palmIndex) const;
82 int getNumberOfActivePalms() const;
83 const PalmData* getActivePalm(int palmIndex) const;
84
85 bool _mouseCaptured;
86 bool _touchCaptured;
87 bool _wheelCaptured;
88 QMultiMap<int,KeyEvent> _capturedKeys;
89 QSet<int> _capturedJoysticks;
90};
91
92const int NUMBER_OF_SPATIALCONTROLS_PER_PALM = 2; // the hand and the tip
93const int NUMBER_OF_JOYSTICKS_PER_PALM = 1;
94const int NUMBER_OF_TRIGGERS_PER_PALM = 1;
95const int NUMBER_OF_BUTTONS_PER_PALM = 6;
96const int PALM_SPATIALCONTROL = 0;
97const int TIP_SPATIALCONTROL = 1;
98
99#endif /* defined(__hifi__ControllerScriptingInterface__) */