SLProject  4.3.020
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLInputEventInterface Class Reference

Convenience interface for posting input events to an SLInputManager. More...

#include <SLInputEventInterface.h>

Inheritance diagram for SLInputEventInterface:
[legend]

Public Member Functions

 SLInputEventInterface (SLInputManager &inputManager)
 
void resize (int sceneViewIndex, int width, int height)
 Posts a resize of the scene view to the given width and height in pixels. More...
 
void updateScr2fb (int sceneViewIndex)
 Posts a request to recompute the screen to framebuffer scale factor. More...
 
void mouseDown (int sceneViewIndex, SLMouseButton button, int x, int y, SLKey modifier)
 Posts a mouse button press at position x, y. More...
 
void mouseMove (int sceneViewIndex, int x, int y)
 Posts a mouse movement to position x, y. More...
 
void mouseUp (int sceneViewIndex, SLMouseButton button, int x, int y, SLKey modifier)
 Posts a mouse button release at position x, y. More...
 
void doubleClick (int sceneViewIndex, SLMouseButton button, int x, int y, SLKey modifier)
 Posts a mouse button double click at position x, y. More...
 
void touch2Down (int sceneViewIndex, int x1, int y1, int x2, int y2)
 Posts a two finger touch down at the two positions x1, y1 and x2, y2. More...
 
void touch2Move (int sceneViewIndex, int x1, int y1, int x2, int y2)
 Posts a two finger move to the two positions x1, y1 and x2, y2. More...
 
void touch2Up (int sceneViewIndex, int x1, int y1, int x2, int y2)
 Posts a two finger lift off from the two positions x1, y1 and x2, y2. More...
 
void mouseWheel (int sceneViewIndex, int pos, SLKey modifier)
 Posts a mouse wheel movement by pos detents. More...
 
void keyPress (int sceneViewIndex, SLKey key, SLKey modifier)
 Posts a key press, for keys that act as commands. More...
 
void keyRelease (int sceneViewIndex, SLKey key, SLKey modifier)
 Posts a key release. More...
 
void charInput (int sceneViewIndex, unsigned int character)
 Posts a translated character, for text entry rather than commands. More...
 
void longTouch (int sceneViewIndex, int x, int y)
 Long touch gesture; accepted but currently ignored. More...
 
void scrCaptureRequest (int sceneViewIndex, std::string outputPath)
 Posts a request to write a screenshot of the scene view to outputPath. More...
 

Private Attributes

SLInputManager_inputManager
 Manager the events are queued on. More...
 

Detailed Description

Convenience interface for posting input events to an SLInputManager.

The platform layer receives native events (GLFW, JNI, Objective-C or JavaScript) and forwards them through this interface, which packages each one as an SLInputEvent and queues it on the SLInputManager. The queue is drained during the scene update, so events are never handled on the caller's stack.

Every method takes the index of the SLSceneView the event belongs to, which is carried through to the handler so that multiple views can be fed independently.

Definition at line 28 of file SLInputEventInterface.h.

Constructor & Destructor Documentation

◆ SLInputEventInterface()

SLInputEventInterface::SLInputEventInterface ( SLInputManager inputManager)
Parameters
inputManagerManager the events are queued on; must outlive this object

Definition at line 14 of file SLInputEventInterface.cpp.

15  : _inputManager(inputManager)
16 {
17 }
SLInputManager & _inputManager
Manager the events are queued on.

Member Function Documentation

◆ charInput()

void SLInputEventInterface::charInput ( int  sceneViewIndex,
unsigned int  character 
)

Posts a translated character, for text entry rather than commands.

Global event handler for unicode character input.

Definition at line 191 of file SLInputEventInterface.cpp.

193 {
195  e->svIndex = sceneViewIndex;
196  e->character = character;
198 }
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 queueEvent(const SLInputEvent *e)

◆ doubleClick()

void SLInputEventInterface::doubleClick ( int  sceneViewIndex,
SLMouseButton  button,
int  xpos,
int  ypos,
SLKey  modifier 
)

Posts a mouse button double click at position x, y.

Global event handler for double click events.

Definition at line 80 of file SLInputEventInterface.cpp.

85 {
87  e->svIndex = sceneViewIndex;
88  e->button = button;
89  e->x = xpos;
90  e->y = ypos;
91  e->modifier = modifier;
93 }
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

◆ keyPress()

void SLInputEventInterface::keyPress ( int  sceneViewIndex,
SLKey  key,
SLKey  modifier 
)

Posts a key press, for keys that act as commands.

Global event handler for keyboard key press events.

Definition at line 164 of file SLInputEventInterface.cpp.

167 {
169  e->svIndex = sceneViewIndex;
170  e->key = key;
171  e->modifier = modifier;
173 }
Specialized SLInput class for all keypress related input events.
Definition: SLInputEvent.h:67
SLKey modifier
Definition: SLInputEvent.h:70

◆ keyRelease()

void SLInputEventInterface::keyRelease ( int  sceneViewIndex,
SLKey  key,
SLKey  modifier 
)

Posts a key release.

Global event handler for keyboard key release events.

Definition at line 177 of file SLInputEventInterface.cpp.

180 {
182  e->svIndex = sceneViewIndex;
183  e->key = key;
184  e->modifier = modifier;
186 }

◆ longTouch()

void SLInputEventInterface::longTouch ( int  sceneViewIndex,
int  x,
int  y 
)
inline

Long touch gesture; accepted but currently ignored.

Definition at line 76 of file SLInputEventInterface.h.

76 {}

◆ mouseDown()

void SLInputEventInterface::mouseDown ( int  sceneViewIndex,
SLMouseButton  button,
int  xpos,
int  ypos,
SLKey  modifier 
)

Posts a mouse button press at position x, y.

Global event handler for mouse button down events.

Definition at line 33 of file SLInputEventInterface.cpp.

38 {
40  e->svIndex = sceneViewIndex;
41  e->button = button;
42  e->x = xpos;
43  e->y = ypos;
44  e->modifier = modifier;
46 }

◆ mouseMove()

void SLInputEventInterface::mouseMove ( int  sceneViewIndex,
int  x,
int  y 
)

Posts a mouse movement to position x, y.

Global event handler for mouse move events.

Definition at line 50 of file SLInputEventInterface.cpp.

53 {
55  e->svIndex = sceneViewIndex;
56  e->x = x;
57  e->y = y;
59 }

◆ mouseUp()

void SLInputEventInterface::mouseUp ( int  sceneViewIndex,
SLMouseButton  button,
int  xpos,
int  ypos,
SLKey  modifier 
)

Posts a mouse button release at position x, y.

Global event handler for mouse button up events.

Definition at line 63 of file SLInputEventInterface.cpp.

68 {
70  e->svIndex = sceneViewIndex;
71  e->button = button;
72  e->x = xpos;
73  e->y = ypos;
74  e->modifier = modifier;
76 }

◆ mouseWheel()

void SLInputEventInterface::mouseWheel ( int  sceneViewIndex,
int  pos,
SLKey  modifier 
)

Posts a mouse wheel movement by pos detents.

Global event handler for mouse wheel events.

Definition at line 151 of file SLInputEventInterface.cpp.

154 {
156  e->svIndex = sceneViewIndex;
157  e->y = pos;
158  e->modifier = modifier;
160 }

◆ resize()

void SLInputEventInterface::resize ( int  sceneViewIndex,
int  width,
int  height 
)

Posts a resize of the scene view to the given width and height in pixels.

Global resize function that must be called whenever the OpenGL frame changes it's size.

Definition at line 22 of file SLInputEventInterface.cpp.

23 {
25  e->svIndex = sceneViewIndex;
26  e->width = width;
27  e->height = height;
29 }
Specialized SLInput class for window resize events.
Definition: SLInputEvent.h:101

◆ scrCaptureRequest()

void SLInputEventInterface::scrCaptureRequest ( int  sceneViewIndex,
std::string  outputPath 
)

Posts a request to write a screenshot of the scene view to outputPath.

Global event handler to trigger a screenshot

Definition at line 202 of file SLInputEventInterface.cpp.

203 {
205  e->svIndex = sceneViewIndex;
206  e->path = outputPath;
208 }
Specialized SLInput class to trigger a screen capture.
Definition: SLInputEvent.h:126

◆ touch2Down()

void SLInputEventInterface::touch2Down ( int  sceneViewIndex,
int  xpos1,
int  ypos1,
int  xpos2,
int  ypos2 
)

Posts a two finger touch down at the two positions x1, y1 and x2, y2.

Global event handler for the two finger touch down events of touchscreen devices.

Definition at line 98 of file SLInputEventInterface.cpp.

103 {
105  e->svIndex = sceneViewIndex;
106  e->x1 = xpos1;
107  e->y1 = ypos1;
108  e->x2 = xpos2;
109  e->y2 = ypos2;
110 
112 }
Specialized SLInput class for touch related input events.
Definition: SLInputEvent.h:78

◆ touch2Move()

void SLInputEventInterface::touch2Move ( int  sceneViewIndex,
int  xpos1,
int  ypos1,
int  xpos2,
int  ypos2 
)

Posts a two finger move to the two positions x1, y1 and x2, y2.

Global event handler for the two finger move events of touchscreen devices.

Definition at line 116 of file SLInputEventInterface.cpp.

121 {
123  e->svIndex = sceneViewIndex;
124  e->x1 = xpos1;
125  e->y1 = ypos1;
126  e->x2 = xpos2;
127  e->y2 = ypos2;
129 }

◆ touch2Up()

void SLInputEventInterface::touch2Up ( int  sceneViewIndex,
int  xpos1,
int  ypos1,
int  xpos2,
int  ypos2 
)

Posts a two finger lift off from the two positions x1, y1 and x2, y2.

Global event handler for the two finger touch up events of touchscreen devices.

Definition at line 134 of file SLInputEventInterface.cpp.

139 {
141  e->svIndex = sceneViewIndex;
142  e->x1 = xpos1;
143  e->y1 = ypos1;
144  e->x2 = xpos2;
145  e->y2 = ypos2;
147 }

◆ updateScr2fb()

void SLInputEventInterface::updateScr2fb ( int  sceneViewIndex)

Posts a request to recompute the screen to framebuffer scale factor.

Needed on high DPI displays, where the framebuffer is larger than the window in screen coordinates.

Member Data Documentation

◆ _inputManager

SLInputManager& SLInputEventInterface::_inputManager
private

Manager the events are queued on.

Definition at line 82 of file SLInputEventInterface.h.


The documentation for this class was generated from the following files: