Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InputRouter.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <SDL.h>
4 #include <vector> // for vector
5 
6 #include "SDL_events.h" // for SDL_Event
7 #include "inexor/network/SharedVar.hpp" // for SharedVar
8 
9 namespace inexor {
10 namespace io {
11 
12 enum
13 {
18 };
19 
20 enum
21 {
25 };
26 
29 {
30  public:
31  InputRouter();
32  virtual ~InputRouter();
33 
35  void keyrepeat(bool on, int mask);
36 
38  void inputgrab();
39 
41  void set_grab_input(bool grab_input);
42 
45  bool interceptkey(int sym);
46 
47  void ignoremousemotion();
48 
50  void checkinput();
51 
52  // BIND MANAGER
53  // check_bind
54  // bool filter_input_layer()
55 
57 
58  private:
59 
61  void pushevent(const SDL_Event &e);
62 
64  bool filterevent(const SDL_Event &event);
65 
69  bool pollevent(SDL_Event &event);
70 
73  void resetmousemotion();
74 
77  void checkmousemotion(int &dx, int &dy);
78 
80  std::vector<SDL_Event> events;
81 
83  bool shouldgrab;
84  bool grabinput;
86 
89 
92 
93 };
94 
97 
98 // Provide global exports
100 
101 }
102 }
Definition: InputRouter.hpp:22
bool interceptkey(int sym)
"abort" key to interrupt updating the masterlist, connecting to a server or computing lightmaps ...
Definition: InputRouter.cpp:92
void keyrepeat(bool on, int mask)
Check if key was pressed repeatedly using bit masking technique.
Definition: InputRouter.cpp:48
SharedVar< int > userelativemouse
Definition: InputRouter.hpp:14
Definition: InputRouter.hpp:15
void pushevent(const SDL_Event &e)
add a new event to event vector
Definition: InputRouter.cpp:256
bool relativemouse
Definition: InputRouter.hpp:56
Definition: InputRouter.hpp:16
bool grabinput
Definition: InputRouter.hpp:84
bool shouldgrab
controlling input devices using Simple DirectMedia Layer
Definition: InputRouter.hpp:83
Forwards input events to the subsystem they are needed.
Definition: InputRouter.hpp:28
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
Definition: glexts.hpp:299
InputRouter input_router
InputRouter singleton.
Definition: InputRouter.cpp:325
Definition: InputRouter.hpp:17
Definition: InputRouter.hpp:24
int textinputmask
text input state is also stored in bit masks
Definition: InputRouter.hpp:91
void checkinput()
Periodically checking for new input.
Definition: InputRouter.cpp:124
void checkmousemotion(int &dx, int &dy)
handle mouse motion coordinates
Definition: InputRouter.cpp:297
void set_grab_input(bool grab_input)
Sets input grab mode for mouse and keyboard.
Definition: InputRouter.cpp:87
virtual ~InputRouter()
Definition: InputRouter.cpp:44
std::vector< SDL_Event > events
global vector for input events
Definition: InputRouter.hpp:80
void inputgrab()
Do grab the input depending on the current grab mode.
Definition: InputRouter.cpp:54
Definition: InputRouter.hpp:23
int keyrepeatmask
key repetition is stored in bit masks
Definition: InputRouter.hpp:88
bool canrelativemouse
Definition: InputRouter.hpp:85
SharedVar wrapper for primitive/immutable objects.
Definition: SharedVar.hpp:55
void ignoremousemotion()
Definition: InputRouter.cpp:117
bool pollevent(SDL_Event &event)
poll and filter all events in the SDL (input) event queue
Definition: InputRouter.cpp:280
bool filterevent(const SDL_Event &event)
filter mouse motion events depending on operating system
Definition: InputRouter.cpp:261
InputRouter()
Definition: InputRouter.cpp:33
void resetmousemotion()
move mouse to screen center
Definition: InputRouter.cpp:289