Dragonfly  4.3
A text-based game engine
EventKeyboard.h
1 ///
2 /// A "keyboard" event
3 ///
4 
5 #ifndef __EVENT_KEYBOARD_H__
6 #define __EVENT_KEYBOARD_H__
7 
8 #include "Event.h"
9 
10 namespace df {
11 
12 const std::string KEYBOARD_EVENT = "df::keyboard";
13 
14 /// Types of keyboard actions Dragonfly recognizes.
16  UNDEFINED_KEYBOARD_ACTION = -1, ///< Undefined
17  KEY_PRESSED, ///< Was down
18  KEY_RELEASED, ///< Was released
19  KEY_DOWN, ///< Is down
20 };
21 
22 /// Keyboard namespace.
23 namespace Keyboard {
24 /// Keys Dragonfly recognizes.
25 enum Key {
26  UNDEFINED_KEY = -1,
27  SPACE, RETURN, ESCAPE, TAB, LEFTARROW, RIGHTARROW, UPARROW, DOWNARROW,
28  PAUSE, MINUS, PLUS, TILDE, PERIOD, COMMA, SLASH,
29  EQUAL, BACKSLASH, MULTIPLY, QUOTE, SEMICOLON,
30  LEFTCONTROL, RIGHTCONTROL,
31  LEFTSHIFT, RIGHTSHIFT, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
32  A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
33  NUM1, NUM2, NUM3, NUM4, NUM5, NUM6, NUM7, NUM8, NUM9, NUM0, BACKSPACE,
34 };
35 } // end of namespace Keyboard
36 
37 class EventKeyboard : public Event {
38 
39  private:
40  Keyboard::Key m_key_val; ///< Key value.
42 
43  public:
44  EventKeyboard();
45 
46  /// Set key in event.
47  void setKey(Keyboard::Key new_key);
48 
49  /// Get key from event.
50  Keyboard::Key getKey() const;
51 
52  /// Set keyboard event action.
53  void setKeyboardAction(EventKeyboardAction new_action);
54 
55  /// Get keyboard event action.
56  EventKeyboardAction getKeyboardAction() const;
57 };
58 
59 } // end of namespace df
60 #endif // __EVENT_KEYBOARD_H__
Is down.
Definition: EventKeyboard.h:19
EventKeyboardAction m_keyboard_action
Key action.
Definition: EventKeyboard.h:41
Definition: Event.h:15
A 2-d bounding box.
Definition: Box.h:10
Key
Keys Dragonfly recognizes.
Definition: EventKeyboard.h:25
EventKeyboardAction
Types of keyboard actions Dragonfly recognizes.
Definition: EventKeyboard.h:15
Was released.
Definition: EventKeyboard.h:18
Was down.
Definition: EventKeyboard.h:17
Undefined.
Definition: EventKeyboard.h:16
Keyboard::Key m_key_val
Key value.
Definition: EventKeyboard.h:40
Definition: EventKeyboard.h:37