TDME2  1.9.200
GUIKeyboardEvent.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <tdme/tdme.h>
6 
7 /**
8  * GUI keyboard event
9  * @author Andreas Drewke
10  */
12 {
13 public:
14 
15  static constexpr int32_t KEYCODE_TAB { KEYBOARD_KEYCODE_TAB };
16  static constexpr int32_t KEYCODE_BACKSPACE { KEYBOARD_KEYCODE_BACKSPACE };
17  static constexpr int32_t KEYCODE_RETURN { KEYBOARD_KEYCODE_RETURN };
18  static constexpr int32_t KEYCODE_DELETE { KEYBOARD_KEYCODE_DELETE };
19  static constexpr int32_t KEYCODE_SPACE { KEYBOARD_KEYCODE_SPACE };
20  static constexpr int32_t KEYCODE_LEFT { KEYBOARD_KEYCODE_LEFT };
21  static constexpr int32_t KEYCODE_UP { KEYBOARD_KEYCODE_UP };
22  static constexpr int32_t KEYCODE_RIGHT { KEYBOARD_KEYCODE_RIGHT };
23  static constexpr int32_t KEYCODE_DOWN { KEYBOARD_KEYCODE_DOWN };
24  static constexpr int32_t KEYCODE_PAGE_UP { KEYBOARD_KEYCODE_PAGE_UP };
25  static constexpr int32_t KEYCODE_PAGE_DOWN { KEYBOARD_KEYCODE_PAGE_DOWN };
26  static constexpr int32_t KEYCODE_POS1 { KEYBOARD_KEYCODE_POS1 };
27  static constexpr int32_t KEYCODE_END { KEYBOARD_KEYCODE_END };
28  static constexpr int32_t KEYCODE_ESCAPE { KEYBOARD_KEYCODE_ESCAPE };
29  static constexpr int32_t KEYCODE_F1 { KEYBOARD_KEYCODE_F1 };
30  static constexpr int32_t KEYCODE_F2 { KEYBOARD_KEYCODE_F2 };
31  static constexpr int32_t KEYCODE_F3 { KEYBOARD_KEYCODE_F3 };
32  static constexpr int32_t KEYCODE_F4 { KEYBOARD_KEYCODE_F4 };
33  static constexpr int32_t KEYCODE_F5 { KEYBOARD_KEYCODE_F5 };
34  static constexpr int32_t KEYCODE_F6 { KEYBOARD_KEYCODE_F6 };
35  static constexpr int32_t KEYCODE_F7 { KEYBOARD_KEYCODE_F7 };
36  static constexpr int32_t KEYCODE_F8 { KEYBOARD_KEYCODE_F8 };
37  static constexpr int32_t KEYCODE_F9 { KEYBOARD_KEYCODE_F9 };
38  static constexpr int32_t KEYCODE_F10 { KEYBOARD_KEYCODE_F10 };
39  static constexpr int32_t KEYCODE_F11 { KEYBOARD_KEYCODE_F11 };
40  static constexpr int32_t KEYCODE_F12 { KEYBOARD_KEYCODE_F12 };
41  static constexpr int32_t KEYCODE_LEFT_ALT { KEYBOARD_KEYCODE_LEFT_ALT };
42  static constexpr int32_t KEYCODE_LEFT_CONTROL { KEYBOARD_KEYCODE_LEFT_CTRL };
43  static constexpr int32_t KEYCODE_LEFT_SHIFT { KEYBOARD_KEYCODE_LEFT_SHIFT };
44  static constexpr int32_t KEYCODE_RIGHT_ALT { KEYBOARD_KEYCODE_RIGHT_ALT };
45  static constexpr int32_t KEYCODE_RIGHT_CONTROL { KEYBOARD_KEYCODE_RIGHT_CTRL };
46  static constexpr int32_t KEYCODE_RIGHT_SHIFT { KEYBOARD_KEYCODE_RIGHT_SHIFT };
47 
53  };
54 
55 private:
56  int64_t time { -1LL };
58  int32_t keyCode { -1 };
59  int32_t keyChar { -1 };
60  bool metaDown { false };
61  bool controlDown { false };
62  bool altDown { false };
63  bool shiftDown { false };
64  bool repeat { false };
65  bool processed { false };
66 
67 public:
68  /**
69  * Constructor
70  */
71  inline GUIKeyboardEvent() {
72  }
73 
74  /**
75  * Destructor
76  */
77  inline ~GUIKeyboardEvent() {
78  }
79 
80  /**
81  * @return time in milliseconds
82  */
83  inline int64_t getTime() const {
84  return time;
85  }
86 
87  /**
88  * Time in milliseconds
89  * @param time time
90  */
91  inline void setTime(int64_t time) {
92  this->time = time;
93  }
94 
95  /**
96  * @return type
97  */
98  inline GUIKeyboardEventType getType() const {
99  return type;
100  }
101 
102  /**
103  * Set type
104  * @param type type
105  */
107  this->type = type;
108  }
109 
110  /**
111  * @return key code
112  */
113  inline int32_t getKeyCode() const {
114  return keyCode;
115  }
116 
117  /**
118  * Set key code
119  * @param code code
120  */
121  inline void setKeyCode(int32_t code) {
122  this->keyCode = code;
123  }
124 
125  /**
126  * @return key char
127  */
128  inline int32_t getKeyChar() const {
129  return keyChar;
130  }
131 
132  /**
133  * Set key char
134  * @param keyChar key char
135  */
136  inline void setKeyChar(int32_t keyChar) {
137  this->keyChar = keyChar;
138  }
139 
140  /**
141  * @return is meta down
142  */
143  inline bool isMetaDown() const {
144  return metaDown;
145  }
146 
147  /**
148  * Set meta down
149  * @param metaDown meta down
150  */
151  inline void setMetaDown(bool metaDown) {
152  this->metaDown = metaDown;
153  }
154 
155  /**
156  * @return control down
157  */
158  inline bool isControlDown() const {
159  return controlDown;
160  }
161 
162  /**
163  * Set control down
164  * @param controlDown control down
165  */
166  inline void setControlDown(bool controlDown) {
167  this->controlDown = controlDown;
168  }
169 
170  /**
171  * @return is alt down
172  */
173  inline bool isAltDown() const {
174  return altDown;
175  }
176 
177  /**
178  * Set alt down
179  * @param altDown alt down
180  */
181  inline void setAltDown(bool altDown) {
182  this->altDown = altDown;
183  }
184 
185  /**
186  * @return is shift down
187  */
188  inline bool isShiftDown() const {
189  return shiftDown;
190  }
191 
192  /**
193  * Set shift down
194  * @param shiftDown shiftDown
195  */
196  inline void setShiftDown(bool shiftDown) {
197  this->shiftDown = shiftDown;
198  }
199 
200  /**
201  * @return is repeat
202  */
203  inline bool isRepeat() const {
204  return repeat;
205  }
206 
207  /**
208  * Set repeat
209  * @param repeat repeat event
210  */
211  inline void setRepeat(bool repeat) {
212  this->repeat = repeat;
213  }
214 
215  /**
216  * @return event has been processed already
217  */
218  inline bool isProcessed() const {
219  return processed;
220  }
221 
222  /**
223  * Set event processed
224  * @param processed processed
225  */
226  inline void setProcessed(bool processed) {
227  this->processed = processed;
228  }
229 
230 };
#define KEYBOARD_KEYCODE_POS1
#define KEYBOARD_KEYCODE_RIGHT_CTRL
#define KEYBOARD_KEYCODE_PAGE_DOWN
#define KEYBOARD_KEYCODE_DELETE
#define KEYBOARD_KEYCODE_LEFT
#define KEYBOARD_KEYCODE_F10
#define KEYBOARD_KEYCODE_LEFT_CTRL
#define KEYBOARD_KEYCODE_F6
#define KEYBOARD_KEYCODE_TAB
#define KEYBOARD_KEYCODE_F12
#define KEYBOARD_KEYCODE_LEFT_SHIFT
#define KEYBOARD_KEYCODE_F5
#define KEYBOARD_KEYCODE_F9
#define KEYBOARD_KEYCODE_LEFT_ALT
#define KEYBOARD_KEYCODE_F2
#define KEYBOARD_KEYCODE_F3
#define KEYBOARD_KEYCODE_F7
#define KEYBOARD_KEYCODE_RIGHT
#define KEYBOARD_KEYCODE_SPACE
#define KEYBOARD_KEYCODE_F4
#define KEYBOARD_KEYCODE_PAGE_UP
#define KEYBOARD_KEYCODE_ESCAPE
#define KEYBOARD_KEYCODE_DOWN
#define KEYBOARD_KEYCODE_RIGHT_ALT
#define KEYBOARD_KEYCODE_F8
#define KEYBOARD_KEYCODE_RETURN
#define KEYBOARD_KEYCODE_RIGHT_SHIFT
#define KEYBOARD_KEYCODE_F11
#define KEYBOARD_KEYCODE_END
#define KEYBOARD_KEYCODE_UP
#define KEYBOARD_KEYCODE_F1
#define KEYBOARD_KEYCODE_BACKSPACE
static constexpr int32_t KEYCODE_PAGE_UP
static constexpr int32_t KEYCODE_F12
static constexpr int32_t KEYCODE_TAB
static constexpr int32_t KEYCODE_ESCAPE
static constexpr int32_t KEYCODE_F9
static constexpr int32_t KEYCODE_PAGE_DOWN
static constexpr int32_t KEYCODE_F6
static constexpr int32_t KEYCODE_POS1
static constexpr int32_t KEYCODE_F7
static constexpr int32_t KEYCODE_LEFT
void setKeyCode(int32_t code)
Set key code.
void setAltDown(bool altDown)
Set alt down.
static constexpr int32_t KEYCODE_LEFT_CONTROL
static constexpr int32_t KEYCODE_F5
void setProcessed(bool processed)
Set event processed.
void setType(GUIKeyboardEventType type)
Set type.
void setControlDown(bool controlDown)
Set control down.
static constexpr int32_t KEYCODE_RETURN
static constexpr int32_t KEYCODE_RIGHT_ALT
static constexpr int32_t KEYCODE_DOWN
GUIKeyboardEventType getType() const
static constexpr int32_t KEYCODE_LEFT_ALT
void setKeyChar(int32_t keyChar)
Set key char.
static constexpr int32_t KEYCODE_SPACE
static constexpr int32_t KEYCODE_F10
void setTime(int64_t time)
Time in milliseconds.
static constexpr int32_t KEYCODE_END
static constexpr int32_t KEYCODE_BACKSPACE
void setMetaDown(bool metaDown)
Set meta down.
void setRepeat(bool repeat)
Set repeat.
static constexpr int32_t KEYCODE_DELETE
static constexpr int32_t KEYCODE_UP
static constexpr int32_t KEYCODE_LEFT_SHIFT
static constexpr int32_t KEYCODE_RIGHT
static constexpr int32_t KEYCODE_F2
static constexpr int32_t KEYCODE_F3
void setShiftDown(bool shiftDown)
Set shift down.
static constexpr int32_t KEYCODE_F4
static constexpr int32_t KEYCODE_RIGHT_SHIFT
static constexpr int32_t KEYCODE_F1
static constexpr int32_t KEYCODE_F8
static constexpr int32_t KEYCODE_RIGHT_CONTROL
static constexpr int32_t KEYCODE_F11