blip  0.1
KeyEvent.hpp
Go to the documentation of this file.
1 #ifndef __blip_KeyEvent_hpp
2 #define __blip_KeyEvent_hpp
3 
4 #include <blip/Blip.hpp>
5 #include <blip/InputEvent.hpp>
6 
7 #include <commonc++/Flags.h++>
8 
9 namespace blip {
10 
11 class InputQueue;
12 
17 class KeyEvent : public InputEvent
18 {
19  friend class InputEventQueue;
20 
21  public:
22 
26 
27  // TODO: function Keys F1 to F12, numpad, etc.
28 
35  K_G, K_H, K_I, K_J, K_K, K_L, K_M, K_N, K_O, K_P, K_Q, K_R,
72 
74  virtual ~KeyEvent();
75 
77  Action getAction() const;
78 
80  const ccxx::Flags<int32_t> getFlags() const;
81 
83  KeyCode getKeyCode() const;
84 
88  char getCharacter() const;
89 
91  int32_t getScanCode() const;
92 
97  int32_t getMetaState() const;
98 
100  int getRepeatCount() const;
101 
103  time_ms_t getDownTime() const;
104 
105  virtual time_ms_t getEventTime() const;
106 
108  bool isMetaKeyPressed() const;
109 
111  bool isAltPressed() const;
112 
114  bool isLeftAltPressed() const;
115 
118  bool isRightAltPressed() const;
119 
122  bool isCapsLockPressed() const;
123 
126  bool isControlPressed() const;
127 
131  bool isLeftControlPressed() const;
132 
136  bool isRightControlPressed() const;
137 
139  bool isFunctionPressed() const;
140 
143  bool isNumLockPressed() const;
144 
148  bool isScrollLockPressed() const;
149 
151  bool isShiftPressed() const;
152 
155  bool isLeftShiftPressed() const;
156 
159  bool isRightShiftPressed() const;
160 
162  bool isSymPressed() const;
163 
165  static const uint32_t ALT_MASK;
166 
168  static const uint32_t ALT_LEFT_MASK;
169 
171  static const uint32_t ALT_RIGHT_MASK;
172 
174  static const uint32_t ALT_ANY_MASK;
175 
177  static const uint32_t CAPS_LOCK_MASK;
178 
180  static const uint32_t CTRL_MASK;
181 
183  static const uint32_t CTRL_LEFT_MASK;
184 
186  static const uint32_t CTRL_RIGHT_MASK;
187 
189  static const uint32_t CTRL_ANY_MASK;
190 
192  static const uint32_t FUNCTION_MASK;
193 
195  static const uint32_t META_MASK;
196 
198  static const uint32_t META_LEFT_MASK;
199 
201  static const uint32_t META_RIGHT_MASK;
202 
204  static const uint32_t META_ANY_MASK;
205 
207  static const uint32_t NUM_LOCK_MASK;
208 
210  static const uint32_t SCROLL_LOCK_MASK;
211 
213  static const uint32_t SHIFT_MASK;
214 
216  static const uint32_t SHIFT_LEFT_MASK;
217 
219  static const uint32_t SHIFT_RIGHT_MASK;
220 
222  static const uint32_t SHIFT_ANY_MASK;
223 
225  static const uint32_t SYM_MASK;
226 
227  protected:
228 
230  KeyEvent(AInputEvent* event);
233  private:
234 
235  CCXX_COPY_DECLS(KeyEvent);
236 };
237 
238 } // namespace blip
239 
240 #endif // __blip_KeyEvent_hpp
Definition: KeyEvent.hpp:31
Definition: KeyEvent.hpp:65
Definition: KeyEvent.hpp:45
Definition: KeyEvent.hpp:69
Definition: KeyEvent.hpp:39
Definition: KeyEvent.hpp:31
Definition: KeyEvent.hpp:63
Definition: KeyEvent.hpp:47
Definition: KeyEvent.hpp:64
Definition: KeyEvent.hpp:48
Definition: KeyEvent.hpp:55
Definition: KeyEvent.hpp:36
bool isCapsLockPressed() const
Test if the Caps Lock key was pressed at the time of this event.
Definition: KeyEvent.cpp:251
Definition: KeyEvent.hpp:46
Definition: KeyEvent.hpp:41
Definition: KeyEvent.hpp:35
Definition: KeyEvent.hpp:43
bool isRightControlPressed() const
Test if the right Control key was pressed at the time of this event.
Definition: KeyEvent.cpp:278
static const uint32_t ALT_ANY_MASK
A mask for testing if any Alt key was pressed.
Definition: KeyEvent.hpp:174
Definition: KeyEvent.hpp:46
bool isFunctionPressed() const
Test if the Function key was pressed at the time of this event.
Definition: KeyEvent.cpp:287
Definition: KeyEvent.hpp:60
Definition: KeyEvent.hpp:59
static const uint32_t META_ANY_MASK
A mask for testing if any Meta key was pressed.
Definition: KeyEvent.hpp:204
Definition: KeyEvent.hpp:35
Definition: KeyEvent.hpp:41
Definition: KeyEvent.hpp:36
virtual ~KeyEvent()
Destructor.
Definition: KeyEvent.cpp:49
bool isLeftControlPressed() const
Test if the left Control key was pressed at the time of this event.
Definition: KeyEvent.cpp:269
Definition: KeyEvent.hpp:54
static const uint32_t CTRL_LEFT_MASK
A mask for testing if the left Control key was pressed.
Definition: KeyEvent.hpp:183
Definition: KeyEvent.hpp:66
Definition: KeyEvent.hpp:57
Definition: KeyEvent.hpp:66
bool isScrollLockPressed() const
Test if the Scroll Lock key was pressed at the time of this event.
Definition: KeyEvent.cpp:305
An abstract base class for user input events.
Definition: InputEvent.hpp:17
Definition: KeyEvent.hpp:46
Definition: KeyEvent.hpp:31
Definition: KeyEvent.hpp:51
Definition: KeyEvent.hpp:34
Definition: KeyEvent.hpp:32
Definition: KeyEvent.hpp:68
Definition: KeyEvent.hpp:32
Definition: KeyEvent.hpp:62
Definition: KeyEvent.hpp:59
Definition: KeyEvent.hpp:45
Definition: KeyEvent.hpp:53
int getRepeatCount() const
Get the repeat count for this event.
Definition: KeyEvent.cpp:191
Definition: KeyEvent.hpp:35
Definition: KeyEvent.hpp:68
Definition: KeyEvent.hpp:53
Definition: KeyEvent.hpp:70
Action getAction() const
Get the keypress action for this event.
Definition: KeyEvent.cpp:64
Definition: KeyEvent.hpp:37
Definition: KeyEvent.hpp:69
Definition: KeyEvent.hpp:45
Definition: KeyEvent.hpp:30
Definition: KeyEvent.hpp:48
Definition: KeyEvent.hpp:68
Definition: KeyEvent.hpp:60
Definition: KeyEvent.hpp:57
Definition: KeyEvent.hpp:68
Definition: KeyEvent.hpp:54
Definition: KeyEvent.hpp:71
Definition: KeyEvent.hpp:36
Definition: KeyEvent.hpp:62
Definition: KeyEvent.hpp:53
Definition: KeyEvent.hpp:34
Definition: KeyEvent.hpp:46
Definition: KeyEvent.hpp:67
Definition: KeyEvent.hpp:67
Definition: KeyEvent.hpp:49
Definition: KeyEvent.hpp:42
Definition: KeyEvent.hpp:30
Definition: KeyEvent.hpp:31
Definition: KeyEvent.hpp:35
Definition: KeyEvent.hpp:65
Definition: KeyEvent.hpp:69
bool isControlPressed() const
Test if either Control key was pressed at the time of this event.
Definition: KeyEvent.cpp:260
time_ms_t getDownTime() const
Get the amount of time that the key was held down.
Definition: KeyEvent.cpp:199
Definition: KeyEvent.hpp:65
Definition: KeyEvent.hpp:52
Definition: KeyEvent.hpp:61
Definition: KeyEvent.hpp:31
bool isShiftPressed() const
Test if either Shift key was pressed at the time of this event.
Definition: KeyEvent.cpp:314
Definition: KeyEvent.hpp:38
Action
Keypress actions.
Definition: KeyEvent.hpp:24
Definition: KeyEvent.hpp:60
Definition: KeyEvent.hpp:60
Definition: KeyEvent.hpp:43
Definition: KeyEvent.hpp:56
Definition: KeyEvent.hpp:36
Definition: KeyEvent.hpp:50
Definition: KeyEvent.hpp:53
Definition: KeyEvent.hpp:50
Definition: KeyEvent.hpp:35
Definition: KeyEvent.hpp:42
Definition: KeyEvent.hpp:62
Definition: KeyEvent.hpp:42
Definition: KeyEvent.hpp:36
Definition: KeyEvent.hpp:35
Definition: KeyEvent.hpp:68
Definition: KeyEvent.hpp:61
static const uint32_t FUNCTION_MASK
A mask for testing if the Function key was pressed.
Definition: KeyEvent.hpp:192
Definition: KeyEvent.hpp:35
Definition: KeyEvent.hpp:34
Definition: KeyEvent.hpp:24
Definition: KeyEvent.hpp:40
static const uint32_t META_MASK
A mask for testing if either Meta key was pressed.
Definition: KeyEvent.hpp:195
char getCharacter() const
Get the ASCII character represented by this event.
Definition: KeyEvent.cpp:96
Definition: KeyEvent.hpp:45
Definition: KeyEvent.hpp:44
Definition: KeyEvent.hpp:33
static const uint32_t ALT_RIGHT_MASK
A mask for testing if the right Alt key was pressed.
Definition: KeyEvent.hpp:171
Definition: KeyEvent.hpp:34
Definition: KeyEvent.hpp:50
Definition: KeyEvent.hpp:55
Definition: KeyEvent.hpp:36
Definition: KeyEvent.hpp:35
static const uint32_t ALT_LEFT_MASK
A mask for testing if the left Alt key was pressed.
Definition: KeyEvent.hpp:168
Definition: KeyEvent.hpp:32
Definition: KeyEvent.hpp:49
Definition: KeyEvent.hpp:64
Definition: KeyEvent.hpp:38
Definition: KeyEvent.hpp:51
Definition: KeyEvent.hpp:35
Definition: KeyEvent.hpp:31
Definition: KeyEvent.hpp:40
Definition: KeyEvent.hpp:39
Definition: KeyEvent.hpp:38
Definition: KeyEvent.hpp:55
Definition: KeyEvent.hpp:56
WAV file format details at: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/.
Definition: AccelerometerSensorEvent.cpp:3
Definition: KeyEvent.hpp:34
Definition: KeyEvent.hpp:31
Definition: KeyEvent.hpp:58
static const uint32_t SYM_MASK
A mask for testing if the Sym key was pressed.
Definition: KeyEvent.hpp:225
Definition: KeyEvent.hpp:64
Definition: KeyEvent.hpp:34
static const uint32_t CTRL_MASK
A mask for testing if either Control key was pressed.
Definition: KeyEvent.hpp:180
Definition: KeyEvent.hpp:56
Definition: KeyEvent.hpp:60
Definition: KeyEvent.hpp:37
bool isRightShiftPressed() const
Test if the right Shift key was pressed at the time of this event.
Definition: KeyEvent.cpp:332
bool isMetaKeyPressed() const
Test if any modifier key was pressed at the time of this event.
Definition: KeyEvent.cpp:215
static const uint32_t META_RIGHT_MASK
A mask for testing if the right Meta key was pressed.
Definition: KeyEvent.hpp:201
static const uint32_t META_LEFT_MASK
A mask for testing if the left Meta key was pressed.
Definition: KeyEvent.hpp:198
virtual time_ms_t getEventTime() const
Get the time at which this event occurred.
Definition: KeyEvent.cpp:207
Definition: KeyEvent.hpp:64
Definition: KeyEvent.hpp:53
Definition: KeyEvent.hpp:52
Definition: KeyEvent.hpp:54
Definition: KeyEvent.hpp:48
Definition: KeyEvent.hpp:36
Definition: KeyEvent.hpp:70
Definition: KeyEvent.hpp:55
Definition: KeyEvent.hpp:56
Definition: KeyEvent.hpp:44
Definition: KeyEvent.hpp:40
Definition: KeyEvent.hpp:44
Definition: KeyEvent.hpp:30
Definition: KeyEvent.hpp:38
Definition: KeyEvent.hpp:30
Definition: KeyEvent.hpp:43
bool isLeftAltPressed() const
Test if the left Alt key was pressed at the time of this event.
Definition: KeyEvent.cpp:233
Definition: KeyEvent.hpp:61
Definition: KeyEvent.hpp:38
static const uint32_t CAPS_LOCK_MASK
A mask for testing if the Caps Lock key was pressed.
Definition: KeyEvent.hpp:177
static const uint32_t SHIFT_MASK
A mask for testing if either Shift key was pressed.
Definition: KeyEvent.hpp:213
Definition: KeyEvent.hpp:50
Definition: KeyEvent.hpp:36
Definition: KeyEvent.hpp:54
Definition: KeyEvent.hpp:24
Definition: KeyEvent.hpp:46
Definition: KeyEvent.hpp:38
Definition: KeyEvent.hpp:53
Definition: KeyEvent.hpp:42
Definition: KeyEvent.hpp:70
Definition: KeyEvent.hpp:66
Definition: KeyEvent.hpp:32
Definition: KeyEvent.hpp:49
KeyCode getKeyCode() const
Get the keycode for this event.
Definition: KeyEvent.cpp:87
Definition: KeyEvent.hpp:24
Definition: KeyEvent.hpp:54
Definition: KeyEvent.hpp:30
Definition: KeyEvent.hpp:53
Definition: KeyEvent.hpp:70
Definition: KeyEvent.hpp:57
Definition: KeyEvent.hpp:66
Definition: KeyEvent.hpp:64
Definition: KeyEvent.hpp:39
Definition: KeyEvent.hpp:40
Definition: KeyEvent.hpp:63
Definition: KeyEvent.hpp:52
Definition: KeyEvent.hpp:32
Definition: KeyEvent.hpp:62
Definition: KeyEvent.hpp:31
Definition: KeyEvent.hpp:53
Definition: KeyEvent.hpp:33
Definition: KeyEvent.hpp:40
static const uint32_t ALT_MASK
A mask for testing if either Alt key was pressed.
Definition: KeyEvent.hpp:165
Definition: KeyEvent.hpp:69
static const uint32_t CTRL_ANY_MASK
A mask for testing if any Control key was pressed.
Definition: KeyEvent.hpp:189
Definition: KeyEvent.hpp:65
KeyCode
Key codes.
Definition: KeyEvent.hpp:30
Definition: KeyEvent.hpp:35
const ccxx::Flags< int32_t > getFlags() const
Get the flags associated with this event.
Definition: KeyEvent.cpp:56
Definition: KeyEvent.hpp:67
Definition: KeyEvent.hpp:52
Definition: KeyEvent.hpp:34
Definition: KeyEvent.hpp:36
Definition: KeyEvent.hpp:61
Definition: KeyEvent.hpp:40
static const uint32_t SHIFT_ANY_MASK
A mask for testing if any Shift key was pressed.
Definition: KeyEvent.hpp:222
Definition: KeyEvent.hpp:33
Definition: KeyEvent.hpp:63
A keyboard input event.
Definition: KeyEvent.hpp:17
Definition: KeyEvent.hpp:49
Definition: KeyEvent.hpp:41
Definition: KeyEvent.hpp:51
int32_t getMetaState() const
Get the state of the modifier keys at the time of this event.
Definition: KeyEvent.cpp:183
Definition: KeyEvent.hpp:43
Definition: KeyEvent.hpp:34
Definition: KeyEvent.hpp:31
Definition: KeyEvent.hpp:32
Definition: KeyEvent.hpp:36
Definition: KeyEvent.hpp:39
Definition: KeyEvent.hpp:62
Definition: KeyEvent.hpp:51
Definition: KeyEvent.hpp:37
bool isSymPressed() const
Test if the Sym key was pressed at the time of this event.
Definition: KeyEvent.cpp:341
bool isRightAltPressed() const
Test if the right Alt key was pressed at the time of this event.
Definition: KeyEvent.cpp:242
Definition: KeyEvent.hpp:47
Definition: KeyEvent.hpp:41
Definition: KeyEvent.hpp:71
Definition: KeyEvent.hpp:35
Definition: KeyEvent.hpp:67
Definition: KeyEvent.hpp:66
Definition: KeyEvent.hpp:53
Definition: KeyEvent.hpp:41
bool isAltPressed() const
Test if either Alt key was pressed at the time of this event.
Definition: KeyEvent.cpp:224
Definition: KeyEvent.hpp:59
bool isNumLockPressed() const
Test if the Num Lock key was pressed at the time of this event.
Definition: KeyEvent.cpp:296
static const uint32_t NUM_LOCK_MASK
A mask for testing if the Num Lock key was pressed.
Definition: KeyEvent.hpp:207
Definition: KeyEvent.hpp:37
Definition: KeyEvent.hpp:63
Definition: KeyEvent.hpp:59
Definition: KeyEvent.hpp:35
static const uint32_t SHIFT_LEFT_MASK
A mask for testing if the left Shift key was pressed.
Definition: KeyEvent.hpp:216
Definition: KeyEvent.hpp:25
Definition: KeyEvent.hpp:47
Definition: KeyEvent.hpp:53
Definition: KeyEvent.hpp:71
Definition: KeyEvent.hpp:65
Definition: KeyEvent.hpp:44
Definition: InputEventQueue.hpp:17
Definition: KeyEvent.hpp:48
Definition: KeyEvent.hpp:55
Definition: KeyEvent.hpp:31
Definition: KeyEvent.hpp:37
static const uint32_t SHIFT_RIGHT_MASK
A mask for testing if the right Shift key was pressed.
Definition: KeyEvent.hpp:219
Definition: KeyEvent.hpp:54
Definition: KeyEvent.hpp:63
Definition: KeyEvent.hpp:58
Definition: KeyEvent.hpp:32
Definition: KeyEvent.hpp:57
Definition: KeyEvent.hpp:34
Definition: KeyEvent.hpp:33
Definition: KeyEvent.hpp:70
static const uint32_t SCROLL_LOCK_MASK
A mask for testing if the Scroll Lock key was pressed.
Definition: KeyEvent.hpp:210
Definition: KeyEvent.hpp:51
Definition: KeyEvent.hpp:50
Definition: KeyEvent.hpp:61
bool isLeftShiftPressed() const
Test if the left Shift key was pressed at the time of this event.
Definition: KeyEvent.cpp:323
Definition: KeyEvent.hpp:58
static const uint32_t CTRL_RIGHT_MASK
A mask for testing if the right Control key was pressed.
Definition: KeyEvent.hpp:186
int32_t getScanCode() const
Get the scancode for this event.
Definition: KeyEvent.cpp:175
Definition: KeyEvent.hpp:45
Definition: KeyEvent.hpp:39