Dragonfly 4.20
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
10namespace df {
11
12const 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.
23namespace Keyboard {
24/// Keys Dragonfly recognizes.
25enum 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 QMARK, LBRACKET, RBRACKET, GRAVE,
35};
36} // end of namespace Keyboard
37
38class EventKeyboard : public Event {
39
40 private:
41 Keyboard::Key m_key_val; ///< Key value.
43
44 public:
46
47 /// Set key in event.
48 virtual void setKey(Keyboard::Key new_key);
49
50 /// Get key from event.
51 virtual Keyboard::Key getKey() const;
52
53 /// Set keyboard event action.
54 virtual void setKeyboardAction(EventKeyboardAction new_action);
55
56 /// Get keyboard event action.
58};
59
60} // end of namespace df
61#endif // __EVENT_KEYBOARD_H__
62
Definition: EventKeyboard.h:38
virtual void setKeyboardAction(EventKeyboardAction new_action)
Set keyboard event action.
virtual void setKey(Keyboard::Key new_key)
Set key in event.
EventKeyboardAction m_keyboard_action
Key action.
Definition: EventKeyboard.h:42
Keyboard::Key m_key_val
Key value.
Definition: EventKeyboard.h:41
virtual Keyboard::Key getKey() const
Get key from event.
virtual EventKeyboardAction getKeyboardAction() const
Get keyboard event action.
Definition: Event.h:15
Key
Keys Dragonfly recognizes.
Definition: EventKeyboard.h:25
An animation for a sprite.
Definition: Animation.h:15
EventKeyboardAction
Types of keyboard actions Dragonfly recognizes.
Definition: EventKeyboard.h:15
@ KEY_DOWN
Is down.
Definition: EventKeyboard.h:19
@ KEY_PRESSED
Was down.
Definition: EventKeyboard.h:17
@ UNDEFINED_KEYBOARD_ACTION
Undefined.
Definition: EventKeyboard.h:16
@ KEY_RELEASED
Was released.
Definition: EventKeyboard.h:18