SLProject  4.3.020
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLInputEventInterface.h
Go to the documentation of this file.
1 /**
2  * \file SLInputEventInterface.h
3  * \brief Convenience interface for posting input events to SLInputManager
4  * \date January 2015
5  * \authors Marc Wacker, Marcus Hudritsch
6  * \copyright http://opensource.org/licenses/GPL-3.0
7  * \remarks Please use clangformat to format the code. See more code style on
8  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
9  */
10 
11 #ifndef SL_INPUTEVENTINTERFACE_H
12 #define SL_INPUTEVENTINTERFACE_H
13 
14 #include <string>
15 #include <SLEnums.h>
16 
17 //-----------------------------------------------------------------------------
18 class SLInputManager;
19 //-----------------------------------------------------------------------------
20 //! Convenience interface for posting input events to an SLInputManager
21 /*! The platform layer receives native events (GLFW, JNI, Objective-C or
22 JavaScript) and forwards them through this interface, which packages each one
23 as an SLInputEvent and queues it on the SLInputManager. The queue is drained
24 during the scene update, so events are never handled on the caller's stack.
25 
26 Every method takes the index of the SLSceneView the event belongs to, which is
27 carried through to the handler so that multiple views can be fed independently. */
29 {
30 public:
31  //! \param inputManager Manager the events are queued on; must outlive this object
33 
34  //! Posts a resize of the scene view to the given width and height in pixels
35  void resize(int sceneViewIndex, int width, int height);
36 
37  //! Posts a request to recompute the screen to framebuffer scale factor
38  /*! Needed on high DPI displays, where the framebuffer is larger than the
39  window in screen coordinates. */
40  void updateScr2fb(int sceneViewIndex);
41 
42  //! Posts a mouse button press at position x, y
43  void mouseDown(int sceneViewIndex, SLMouseButton button, int x, int y, SLKey modifier);
44 
45  //! Posts a mouse movement to position x, y
46  void mouseMove(int sceneViewIndex, int x, int y);
47 
48  //! Posts a mouse button release at position x, y
49  void mouseUp(int sceneViewIndex, SLMouseButton button, int x, int y, SLKey modifier);
50 
51  //! Posts a mouse button double click at position x, y
52  void doubleClick(int sceneViewIndex, SLMouseButton button, int x, int y, SLKey modifier);
53 
54  //! Posts a two finger touch down at the two positions x1, y1 and x2, y2
55  void touch2Down(int sceneViewIndex, int x1, int y1, int x2, int y2);
56 
57  //! Posts a two finger move to the two positions x1, y1 and x2, y2
58  void touch2Move(int sceneViewIndex, int x1, int y1, int x2, int y2);
59 
60  //! Posts a two finger lift off from the two positions x1, y1 and x2, y2
61  void touch2Up(int sceneViewIndex, int x1, int y1, int x2, int y2);
62 
63  //! Posts a mouse wheel movement by pos detents
64  void mouseWheel(int sceneViewIndex, int pos, SLKey modifier);
65 
66  //! Posts a key press, for keys that act as commands
67  void keyPress(int sceneViewIndex, SLKey key, SLKey modifier);
68 
69  //! Posts a key release
70  void keyRelease(int sceneViewIndex, SLKey key, SLKey modifier);
71 
72  //! Posts a translated character, for text entry rather than commands
73  void charInput(int sceneViewIndex, unsigned int character);
74 
75  //! Long touch gesture; accepted but currently ignored
76  void longTouch(int sceneViewIndex, int x, int y) {}
77 
78  //! Posts a request to write a screenshot of the scene view to outputPath
79  void scrCaptureRequest(int sceneViewIndex, std::string outputPath);
80 
81 private:
82  SLInputManager& _inputManager; //!< Manager the events are queued on
83 };
84 //-----------------------------------------------------------------------------
85 #endif
SLMouseButton
Mouse button codes.
Definition: SLEnums.h:98
SLKey
Keyboard key codes enumeration.
Definition: SLEnums.h:16
Convenience interface for posting input events to an SLInputManager.
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.
void mouseDown(int sceneViewIndex, SLMouseButton button, int x, int y, SLKey modifier)
Posts a mouse button press at position x, y.
void keyRelease(int sceneViewIndex, SLKey key, SLKey modifier)
Posts a key release.
void updateScr2fb(int sceneViewIndex)
Posts a request to recompute the screen to framebuffer scale factor.
void mouseMove(int sceneViewIndex, int x, int y)
Posts a mouse movement to position x, y.
void charInput(int sceneViewIndex, unsigned int character)
Posts a translated character, for text entry rather than commands.
void resize(int sceneViewIndex, int width, int height)
Posts a resize of the scene view to the given width and height in pixels.
void mouseWheel(int sceneViewIndex, int pos, SLKey modifier)
Posts a mouse wheel movement by pos detents.
void keyPress(int sceneViewIndex, SLKey key, SLKey modifier)
Posts a key press, for keys that act as commands.
SLInputManager & _inputManager
Manager the events are queued on.
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.
void scrCaptureRequest(int sceneViewIndex, std::string outputPath)
Posts a request to write a screenshot of the scene view to outputPath.
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.
void mouseUp(int sceneViewIndex, SLMouseButton button, int x, int y, SLKey modifier)
Posts a mouse button release at position x, y.
void longTouch(int sceneViewIndex, int x, int y)
Long touch gesture; accepted but currently ignored.
void doubleClick(int sceneViewIndex, SLMouseButton button, int x, int y, SLKey modifier)
Posts a mouse button double click at position x, y.
SLInputEventInterface(SLInputManager &inputManager)
SLInputManager. manages system input and custom input devices.