SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLInputEventInterface.cpp
Go to the documentation of this file.
1 /**
2  * \file SLInputEventInterface.cpp
3  * \date January 2015
4  * \authors Marc Wacker, Marcus Hudritsch
5  * \copyright http://opensource.org/licenses/GPL-3.0
6  * \remarks Please use clangformat to format the code. See more code style on
7  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
8 */
9 
10 #include <SLInputEventInterface.h>
11 #include <SLInputManager.h>
12 
13 //-----------------------------------------------------------------------------
15  : _inputManager(inputManager)
16 {
17 }
18 //-----------------------------------------------------------------------------
19 /*! Global resize function that must be called whenever the OpenGL frame
20 changes it's size.
21 */
22 void SLInputEventInterface::resize(int sceneViewIndex, int width, int height)
23 {
25  e->svIndex = sceneViewIndex;
26  e->width = width;
27  e->height = height;
29 }
30 //-----------------------------------------------------------------------------
31 /*! Global event handler for mouse button down events.
32  */
33 void SLInputEventInterface::mouseDown(int sceneViewIndex,
34  SLMouseButton button,
35  int xpos,
36  int ypos,
37  SLKey modifier)
38 {
40  e->svIndex = sceneViewIndex;
41  e->button = button;
42  e->x = xpos;
43  e->y = ypos;
44  e->modifier = modifier;
46 }
47 //-----------------------------------------------------------------------------
48 /*! Global event handler for mouse move events.
49  */
50 void SLInputEventInterface::mouseMove(int sceneViewIndex,
51  int x,
52  int y)
53 {
55  e->svIndex = sceneViewIndex;
56  e->x = x;
57  e->y = y;
59 }
60 //-----------------------------------------------------------------------------
61 /*! Global event handler for mouse button up events.
62  */
63 void SLInputEventInterface::mouseUp(int sceneViewIndex,
64  SLMouseButton button,
65  int xpos,
66  int ypos,
67  SLKey modifier)
68 {
70  e->svIndex = sceneViewIndex;
71  e->button = button;
72  e->x = xpos;
73  e->y = ypos;
74  e->modifier = modifier;
76 }
77 //-----------------------------------------------------------------------------
78 /*! Global event handler for double click events.
79  */
80 void SLInputEventInterface::doubleClick(int sceneViewIndex,
81  SLMouseButton button,
82  int xpos,
83  int ypos,
84  SLKey modifier)
85 {
87  e->svIndex = sceneViewIndex;
88  e->button = button;
89  e->x = xpos;
90  e->y = ypos;
91  e->modifier = modifier;
93 }
94 //-----------------------------------------------------------------------------
95 /*! Global event handler for the two finger touch down events of touchscreen
96 devices.
97 */
98 void SLInputEventInterface::touch2Down(int sceneViewIndex,
99  int xpos1,
100  int ypos1,
101  int xpos2,
102  int ypos2)
103 {
105  e->svIndex = sceneViewIndex;
106  e->x1 = xpos1;
107  e->y1 = ypos1;
108  e->x2 = xpos2;
109  e->y2 = ypos2;
110 
112 }
113 //-----------------------------------------------------------------------------
114 /*! Global event handler for the two finger move events of touchscreen devices.
115  */
116 void SLInputEventInterface::touch2Move(int sceneViewIndex,
117  int xpos1,
118  int ypos1,
119  int xpos2,
120  int ypos2)
121 {
123  e->svIndex = sceneViewIndex;
124  e->x1 = xpos1;
125  e->y1 = ypos1;
126  e->x2 = xpos2;
127  e->y2 = ypos2;
129 }
130 //-----------------------------------------------------------------------------
131 /*! Global event handler for the two finger touch up events of touchscreen
132 devices.
133 */
134 void SLInputEventInterface::touch2Up(int sceneViewIndex,
135  int xpos1,
136  int ypos1,
137  int xpos2,
138  int ypos2)
139 {
141  e->svIndex = sceneViewIndex;
142  e->x1 = xpos1;
143  e->y1 = ypos1;
144  e->x2 = xpos2;
145  e->y2 = ypos2;
147 }
148 //-----------------------------------------------------------------------------
149 /*! Global event handler for mouse wheel events.
150  */
151 void SLInputEventInterface::mouseWheel(int sceneViewIndex,
152  int pos,
153  SLKey modifier)
154 {
156  e->svIndex = sceneViewIndex;
157  e->y = pos;
158  e->modifier = modifier;
160 }
161 //-----------------------------------------------------------------------------
162 /*! Global event handler for keyboard key press events.
163  */
164 void SLInputEventInterface::keyPress(int sceneViewIndex,
165  SLKey key,
166  SLKey modifier)
167 {
169  e->svIndex = sceneViewIndex;
170  e->key = key;
171  e->modifier = modifier;
173 }
174 //-----------------------------------------------------------------------------
175 /*! Global event handler for keyboard key release events.
176  */
177 void SLInputEventInterface::keyRelease(int sceneViewIndex,
178  SLKey key,
179  SLKey modifier)
180 {
182  e->svIndex = sceneViewIndex;
183  e->key = key;
184  e->modifier = modifier;
186 }
187 
188 //-----------------------------------------------------------------------------
189 /*! Global event handler for unicode character input.
190  */
191 void SLInputEventInterface::charInput(int sceneViewIndex,
192  unsigned int character)
193 {
195  e->svIndex = sceneViewIndex;
196  e->character = character;
198 }
199 //-----------------------------------------------------------------------------
200 /*! Global event handler to trigger a screenshot
201  */
202 void SLInputEventInterface::scrCaptureRequest(int sceneViewIndex, std::string outputPath)
203 {
205  e->svIndex = sceneViewIndex;
206  e->path = outputPath;
208 }
SLMouseButton
Mouse button codes.
Definition: SLEnums.h:98
SLKey
Keyboard key codes enumeration.
Definition: SLEnums.h:16
Specialized SLInput class for unicode character input.
Definition: SLInputEvent.h:116
SLint svIndex
index of the receiving scene view for this event
Definition: SLInputEvent.h:46
void touch2Move(int sceneViewIndex, int x1, int y1, int x2, int y2)
void mouseDown(int sceneViewIndex, SLMouseButton button, int x, int y, SLKey modifier)
void keyRelease(int sceneViewIndex, SLKey key, SLKey modifier)
void mouseMove(int sceneViewIndex, int x, int y)
void charInput(int sceneViewIndex, unsigned int character)
void resize(int sceneViewIndex, int width, int height)
void mouseWheel(int sceneViewIndex, int pos, SLKey modifier)
void keyPress(int sceneViewIndex, SLKey key, SLKey modifier)
SLInputManager & _inputManager
void touch2Down(int sceneViewIndex, int x1, int y1, int x2, int y2)
void scrCaptureRequest(int sceneViewIndex, std::string outputPath)
void touch2Up(int sceneViewIndex, int x1, int y1, int x2, int y2)
void mouseUp(int sceneViewIndex, SLMouseButton button, int x, int y, SLKey modifier)
void doubleClick(int sceneViewIndex, SLMouseButton button, int x, int y, SLKey modifier)
SLInputEventInterface(SLInputManager &inputManager)
SLInputManager. manages system input and custom input devices.
void queueEvent(const SLInputEvent *e)
Specialized SLInput class for all keypress related input events.
Definition: SLInputEvent.h:67
SLKey modifier
Definition: SLInputEvent.h:70
Specialized SLInput class for all mouse related input events.
Definition: SLInputEvent.h:54
SLKey modifier
Definition: SLInputEvent.h:59
SLMouseButton button
Definition: SLInputEvent.h:58
Specialized SLInput class for window resize events.
Definition: SLInputEvent.h:101
Specialized SLInput class to trigger a screen capture.
Definition: SLInputEvent.h:126
Specialized SLInput class for touch related input events.
Definition: SLInputEvent.h:78