| Fling Engine 0.00.1 Fling Engine is a game engine written in Vulkan

Key.h
Go to the documentation of this file.
1 #pragma once
2
3 #include "KeyState.h"
4 #include "FlingTypes.h"
5 #include <string>
6
7 namespace Fling
8 {
9 class Key
10 {
11 private:
13 std::string m_Name;
14
16 KeyState m_State;
17
19 UINT32 m_KeyCode;
20
21 public:
22
23 explicit Key(const std::string& t_Name, UINT32 t_KeyCode)
24 : m_Name(t_Name)
25 , m_State(KeyState::UP)
26 , m_KeyCode(t_KeyCode)
27 {}
28
29 ~Key() = default;
30
32 void SetState(KeyState t_NewState){ m_State = t_NewState; }
33 inline KeyState GetState () const { return m_State; }
34 inline UINT32 GetCode () const { return m_KeyCode; }
35
36 inline const std::string& GetName() const { return m_Name; }
37
38 inline bool IsPressed() const { return m_State == KeyState::DOWN; }
39 inline bool IsUp() const { return m_State == KeyState::UP; }
40
41 };
42
43
44 struct KeyNames
45 {
46 /* The unknown key */
47 static std::string FL_KEY_UNKNOWN;
48
49 /* Printable keys */
50 static std::string FL_KEY_SPACE;
51 static std::string FL_KEY_APOSTROPHE; /* ' */
52 static std::string FL_KEY_COMMA; /* , */
53 static std::string FL_KEY_MINUS; /* - */
54 static std::string FL_KEY_PERIOD; /* . */
55 static std::string FL_KEY_SLASH; /* / */
56 static std::string FL_KEY_0;
57 static std::string FL_KEY_1;
58 static std::string FL_KEY_2;
59 static std::string FL_KEY_3;
60 static std::string FL_KEY_4;
61 static std::string FL_KEY_5;
62 static std::string FL_KEY_6;
63 static std::string FL_KEY_7;
64 static std::string FL_KEY_8;
65 static std::string FL_KEY_9;
66 static std::string FL_KEY_SEMICOLON; /* ; */
67 static std::string FL_KEY_EQUAL; /* = */
68 static std::string FL_KEY_A;
69 static std::string FL_KEY_B;
70 static std::string FL_KEY_C;
71 static std::string FL_KEY_D;
72 static std::string FL_KEY_E;
73 static std::string FL_KEY_F;
74 static std::string FL_KEY_G;
75 static std::string FL_KEY_H;
76 static std::string FL_KEY_I;
77 static std::string FL_KEY_J;
78 static std::string FL_KEY_K;
79 static std::string FL_KEY_L;
80 static std::string FL_KEY_M;
81 static std::string FL_KEY_N;
82 static std::string FL_KEY_O;
83 static std::string FL_KEY_P;
84 static std::string FL_KEY_Q;
85 static std::string FL_KEY_R;
86 static std::string FL_KEY_S;
87 static std::string FL_KEY_T;
88 static std::string FL_KEY_U;
89 static std::string FL_KEY_V;
90 static std::string FL_KEY_W;
91 static std::string FL_KEY_X;
92 static std::string FL_KEY_Y;
93 static std::string FL_KEY_Z;
94 static std::string FL_KEY_LEFT_BRACKET; /* [ */
95 static std::string FL_KEY_BACKSLASH; /* \ */
96 static std::string FL_KEY_RIGHT_BRACKET; /* ] */
97 static std::string FL_KEY_GRAVE_ACCENT; /* ` */
98 static std::string FL_KEY_WORLD_1; /* non-US #1 */
99 static std::string FL_KEY_WORLD_2; /* non-US #2 */
100
101 /* Function keys */
102 static std::string FL_KEY_ESCAPE;
103 static std::string FL_KEY_ENTER;
104 static std::string FL_KEY_TAB;
105 static std::string FL_KEY_BACKSPACE;
106 static std::string FL_KEY_INSERT;
107 static std::string FL_KEY_DELETE;
108 static std::string FL_KEY_RIGHT;
109 static std::string FL_KEY_LEFT;
110 static std::string FL_KEY_DOWN;
111 static std::string FL_KEY_UP;
112 static std::string FL_KEY_PAGE_UP;
113 static std::string FL_KEY_PAGE_DOWN;
114 static std::string FL_KEY_HOME;
115 static std::string FL_KEY_END;
116 static std::string FL_KEY_CAPS_LOCK;
117 static std::string FL_KEY_SCROLL_LOCK;
118 static std::string FL_KEY_NUM_LOCK;
119 static std::string FL_KEY_PRINT_SCREEN;
120 static std::string FL_KEY_PAUSE;
121 static std::string FL_KEY_F1;
122 static std::string FL_KEY_F2;
123 static std::string FL_KEY_F3;
124 static std::string FL_KEY_F4;
125 static std::string FL_KEY_F5;
126 static std::string FL_KEY_F6;
127 static std::string FL_KEY_F7;
128 static std::string FL_KEY_F8;
129 static std::string FL_KEY_F9;
130 static std::string FL_KEY_F10;
131 static std::string FL_KEY_F11;
132 static std::string FL_KEY_F12;
133 static std::string FL_KEY_F13;
134 static std::string FL_KEY_F14;
135 static std::string FL_KEY_F15;
136 static std::string FL_KEY_F16;
137 static std::string FL_KEY_F17;
138 static std::string FL_KEY_F18;
139 static std::string FL_KEY_F19;
140 static std::string FL_KEY_F20;
141 static std::string FL_KEY_F21;
142 static std::string FL_KEY_F22;
143 static std::string FL_KEY_F23;
144 static std::string FL_KEY_F24;
145 static std::string FL_KEY_F25;
146 static std::string FL_KEY_KP_0;
147 static std::string FL_KEY_KP_1;
148 static std::string FL_KEY_KP_2;
149 static std::string FL_KEY_KP_3;
150 static std::string FL_KEY_KP_4;
151 static std::string FL_KEY_KP_5;
152 static std::string FL_KEY_KP_6;
153 static std::string FL_KEY_KP_7;
154 static std::string FL_KEY_KP_8;
155 static std::string FL_KEY_KP_9;
156 static std::string FL_KEY_KP_DECIMAL;
157 static std::string FL_KEY_KP_DIVIDE;
158 static std::string FL_KEY_KP_MULTIPLY;
159 static std::string FL_KEY_KP_SUBTRACT;
160 static std::string FL_KEY_KP_ADD;
161 static std::string FL_KEY_KP_ENTER;
162 static std::string FL_KEY_KP_EQUAL;
163 static std::string FL_KEY_LEFT_SHIFT;
164 static std::string FL_KEY_LEFT_CONTROL;
165 static std::string FL_KEY_LEFT_ALT;
166 static std::string FL_KEY_LEFT_SUPER;
167 static std::string FL_KEY_RIGHT_SHIFT;
168 static std::string FL_KEY_RIGHT_CONTROL;
169 static std::string FL_KEY_RIGHT_ALT;
170 static std::string FL_KEY_RIGHT_SUPER;
171 static std::string FL_KEY_MENU;
172
173 static std::string FL_MOUSE_BUTTON_1;
174 static std::string FL_MOUSE_BUTTON_2;
175 static std::string FL_MOUSE_BUTTON_3;
176 static std::string FL_MOUSE_BUTTON_4;
177 static std::string FL_MOUSE_BUTTON_5;
178 static std::string FL_MOUSE_BUTTON_6;
179 static std::string FL_MOUSE_BUTTON_7;
180 static std::string FL_MOUSE_BUTTON_8;
181 };
182
183
184 } // namespace Fling
Fling::KeyNames::FL_KEY_R
static std::string FL_KEY_R
Definition: Key.h:85
Fling::KeyNames::FL_KEY_SLASH
static std::string FL_KEY_SLASH
Definition: Key.h:55
Fling::KeyNames::FL_KEY_MINUS
static std::string FL_KEY_MINUS
Definition: Key.h:53
Fling::KeyNames::FL_KEY_NUM_LOCK
static std::string FL_KEY_NUM_LOCK
Definition: Key.h:118
Fling::KeyNames::FL_KEY_PAGE_DOWN
static std::string FL_KEY_PAGE_DOWN
Definition: Key.h:113
Fling::KeyNames::FL_KEY_F16
static std::string FL_KEY_F16
Definition: Key.h:136
Fling::KeyNames::FL_KEY_F22
static std::string FL_KEY_F22
Definition: Key.h:142
Fling::KeyNames::FL_KEY_N
static std::string FL_KEY_N
Definition: Key.h:81
Fling::KeyNames::FL_KEY_Z
static std::string FL_KEY_Z
Definition: Key.h:93
Fling::KeyNames::FL_MOUSE_BUTTON_3
static std::string FL_MOUSE_BUTTON_3
Definition: Key.h:175
Fling::KeyNames::FL_KEY_F24
static std::string FL_KEY_F24
Definition: Key.h:144
Fling::KeyNames::FL_KEY_F12
static std::string FL_KEY_F12
Definition: Key.h:132
Fling::KeyNames::FL_KEY_PERIOD
static std::string FL_KEY_PERIOD
Definition: Key.h:54
Fling::KeyNames::FL_KEY_F2
static std::string FL_KEY_F2
Definition: Key.h:122
Fling::KeyNames::FL_KEY_7
static std::string FL_KEY_7
Definition: Key.h:63
Fling::KeyNames::FL_KEY_8
static std::string FL_KEY_8
Definition: Key.h:64
Fling::KeyNames::FL_MOUSE_BUTTON_5
static std::string FL_MOUSE_BUTTON_5
Definition: Key.h:177
Fling::Key::Key
Key(const std::string &t_Name, UINT32 t_KeyCode)
Definition: Key.h:23
Fling::KeyNames::FL_KEY_2
static std::string FL_KEY_2
Definition: Key.h:58
Fling::Key::m_Name
std::string m_Name
Name of this key binding.
Definition: Key.h:13
Fling::KeyNames::FL_KEY_KP_8
static std::string FL_KEY_KP_8
Definition: Key.h:154
Fling::KeyNames::FL_KEY_CAPS_LOCK
static std::string FL_KEY_CAPS_LOCK
Definition: Key.h:116
Fling::KeyNames::FL_MOUSE_BUTTON_4
static std::string FL_MOUSE_BUTTON_4
Definition: Key.h:176
Fling::KeyNames::FL_MOUSE_BUTTON_7
static std::string FL_MOUSE_BUTTON_7
Definition: Key.h:179
Fling::KeyNames::FL_KEY_KP_0
static std::string FL_KEY_KP_0
Definition: Key.h:146
Fling::Key::GetState
KeyState GetState() const
Definition: Key.h:33
Fling::KeyNames::FL_KEY_F25
static std::string FL_KEY_F25
Definition: Key.h:145
Fling::KeyNames::FL_KEY_F5
static std::string FL_KEY_F5
Definition: Key.h:125
Fling::KeyNames::FL_KEY_0
static std::string FL_KEY_0
Definition: Key.h:56
Fling::Key::IsUp
bool IsUp() const
Definition: Key.h:39
Fling::Key::~Key
~Key()=default
Fling::KeyNames::FL_KEY_KP_5
static std::string FL_KEY_KP_5
Definition: Key.h:151
Fling::KeyNames::FL_KEY_F17
static std::string FL_KEY_F17
Definition: Key.h:137
Fling::Key::m_State
KeyState m_State
The current state of this key.
Definition: Key.h:16
Fling::KeyNames::FL_KEY_D
static std::string FL_KEY_D
Definition: Key.h:71
Fling::KeyNames::FL_KEY_HOME
static std::string FL_KEY_HOME
Definition: Key.h:114
Fling::KeyNames::FL_KEY_F18
static std::string FL_KEY_F18
Definition: Key.h:138
Fling::KeyNames::FL_KEY_H
static std::string FL_KEY_H
Definition: Key.h:75
Fling::KeyNames::FL_KEY_K
static std::string FL_KEY_K
Definition: Key.h:78
Fling::KeyNames::FL_KEY_PRINT_SCREEN
static std::string FL_KEY_PRINT_SCREEN
Definition: Key.h:119
Fling::KeyNames::FL_KEY_KP_DIVIDE
static std::string FL_KEY_KP_DIVIDE
Definition: Key.h:157
Fling::KeyNames::FL_KEY_A
static std::string FL_KEY_A
Definition: Key.h:68
Fling::KeyNames::FL_KEY_I
static std::string FL_KEY_I
Definition: Key.h:76
Fling::KeyNames::FL_KEY_S
static std::string FL_KEY_S
Definition: Key.h:86
Fling::KeyNames::FL_KEY_T
static std::string FL_KEY_T
Definition: Key.h:87
Fling::KeyNames::FL_KEY_KP_ENTER
static std::string FL_KEY_KP_ENTER
Definition: Key.h:161
Fling::KeyNames::FL_KEY_WORLD_2
static std::string FL_KEY_WORLD_2
Definition: Key.h:99
Fling::KeyNames::FL_KEY_L
static std::string FL_KEY_L
Definition: Key.h:79
Fling::KeyNames::FL_KEY_B
static std::string FL_KEY_B
Definition: Key.h:69
Fling::KeyNames::FL_KEY_6
static std::string FL_KEY_6
Definition: Key.h:62
Fling::KeyNames
Definition: Key.h:44
Fling::Key::GetCode
UINT32 GetCode() const
Definition: Key.h:34
Fling::KeyNames::FL_MOUSE_BUTTON_6
static std::string FL_MOUSE_BUTTON_6
Definition: Key.h:178
Fling::KeyNames::FL_KEY_KP_4
static std::string FL_KEY_KP_4
Definition: Key.h:150
Fling::KeyNames::FL_KEY_KP_3
static std::string FL_KEY_KP_3
Definition: Key.h:149
Fling::KeyNames::FL_KEY_F10
static std::string FL_KEY_F10
Definition: Key.h:130
Fling::KeyNames::FL_KEY_RIGHT
static std::string FL_KEY_RIGHT
Definition: Key.h:108
Fling::KeyNames::FL_KEY_Q
static std::string FL_KEY_Q
Definition: Key.h:84
Fling::KeyNames::FL_KEY_9
static std::string FL_KEY_9
Definition: Key.h:65
Fling::KeyNames::FL_KEY_F4
static std::string FL_KEY_F4
Definition: Key.h:124
Fling::KeyNames::FL_KEY_END
static std::string FL_KEY_END
Definition: Key.h:115
Fling::KeyNames::FL_KEY_3
static std::string FL_KEY_3
Definition: Key.h:59
Fling::KeyNames::FL_KEY_F14
static std::string FL_KEY_F14
Definition: Key.h:134
Fling::KeyNames::FL_KEY_BACKSPACE
static std::string FL_KEY_BACKSPACE
Definition: Key.h:105
Fling::KeyNames::FL_KEY_SCROLL_LOCK
static std::string FL_KEY_SCROLL_LOCK
Definition: Key.h:117
Fling::Key::m_KeyCode
UINT32 m_KeyCode
The key code that is mapped to this key to the current platform.
Definition: Key.h:19
Fling::KeyNames::FL_KEY_LEFT_BRACKET
static std::string FL_KEY_LEFT_BRACKET
Definition: Key.h:94
Fling::KeyNames::FL_KEY_TAB
static std::string FL_KEY_TAB
Definition: Key.h:104
Fling::KeyNames::FL_KEY_COMMA
static std::string FL_KEY_COMMA
Definition: Key.h:52
Fling::KeyNames::FL_KEY_KP_9
static std::string FL_KEY_KP_9
Definition: Key.h:155
Fling::Key::GetName
const std::string & GetName() const
Definition: Key.h:36
Fling::KeyNames::FL_MOUSE_BUTTON_8
static std::string FL_MOUSE_BUTTON_8
Definition: Key.h:180
Fling::KeyNames::FL_KEY_F9
static std::string FL_KEY_F9
Definition: Key.h:129
Fling::KeyNames::FL_KEY_LEFT_SUPER
static std::string FL_KEY_LEFT_SUPER
Definition: Key.h:166
Fling::KeyNames::FL_KEY_RIGHT_ALT
static std::string FL_KEY_RIGHT_ALT
Definition: Key.h:169
Fling::KeyNames::FL_KEY_O
static std::string FL_KEY_O
Definition: Key.h:82
Fling::KeyNames::FL_KEY_V
static std::string FL_KEY_V
Definition: Key.h:89
Fling::KeyNames::FL_KEY_1
static std::string FL_KEY_1
Definition: Key.h:57
Fling::KeyNames::FL_KEY_E
static std::string FL_KEY_E
Definition: Key.h:72
Fling::KeyNames::FL_KEY_W
static std::string FL_KEY_W
Definition: Key.h:90
Fling::KeyNames::FL_MOUSE_BUTTON_1
static std::string FL_MOUSE_BUTTON_1
Definition: Key.h:173
Fling::KeyNames::FL_KEY_F7
static std::string FL_KEY_F7
Definition: Key.h:127
Fling::KeyNames::FL_KEY_M
static std::string FL_KEY_M
Definition: Key.h:80
Fling::KeyNames::FL_KEY_GRAVE_ACCENT
static std::string FL_KEY_GRAVE_ACCENT
Definition: Key.h:97
Fling::KeyNames::FL_KEY_F15
static std::string FL_KEY_F15
Definition: Key.h:135
Fling::KeyNames::FL_KEY_UNKNOWN
static std::string FL_KEY_UNKNOWN
Definition: Key.h:47
Fling::KeyNames::FL_KEY_WORLD_1
static std::string FL_KEY_WORLD_1
Definition: Key.h:98
Fling::KeyNames::FL_KEY_PAGE_UP
static std::string FL_KEY_PAGE_UP
Definition: Key.h:112
Fling::KeyNames::FL_KEY_P
static std::string FL_KEY_P
Definition: Key.h:83
Fling::KeyNames::FL_KEY_LEFT_SHIFT
static std::string FL_KEY_LEFT_SHIFT
Definition: Key.h:163
Fling::KeyNames::FL_KEY_KP_EQUAL
static std::string FL_KEY_KP_EQUAL
Definition: Key.h:162
Fling::KeyNames::FL_KEY_ENTER
static std::string FL_KEY_ENTER
Definition: Key.h:103
Fling::KeyNames::FL_KEY_KP_1
static std::string FL_KEY_KP_1
Definition: Key.h:147
Fling::KeyNames::FL_KEY_F23
static std::string FL_KEY_F23
Definition: Key.h:143
Fling::KeyNames::FL_KEY_KP_DECIMAL
static std::string FL_KEY_KP_DECIMAL
Definition: Key.h:156
Fling::KeyNames::FL_KEY_MENU
static std::string FL_KEY_MENU
Definition: Key.h:171
Fling::KeyNames::FL_KEY_RIGHT_BRACKET
static std::string FL_KEY_RIGHT_BRACKET
Definition: Key.h:96
Fling::KeyNames::FL_KEY_KP_SUBTRACT
static std::string FL_KEY_KP_SUBTRACT
Definition: Key.h:159
Fling::KeyNames::FL_KEY_INSERT
static std::string FL_KEY_INSERT
Definition: Key.h:106
Fling::KeyNames::FL_KEY_KP_ADD
static std::string FL_KEY_KP_ADD
Definition: Key.h:160
Fling::KeyNames::FL_KEY_F13
static std::string FL_KEY_F13
Definition: Key.h:133
Fling::KeyNames::FL_KEY_LEFT_ALT
static std::string FL_KEY_LEFT_ALT
Definition: Key.h:165
Fling::KeyNames::FL_KEY_LEFT
static std::string FL_KEY_LEFT
Definition: Key.h:109
Fling::KeyNames::FL_KEY_APOSTROPHE
static std::string FL_KEY_APOSTROPHE
Definition: Key.h:51
Fling::KeyNames::FL_KEY_C
static std::string FL_KEY_C
Definition: Key.h:70
Fling::KeyNames::FL_KEY_BACKSLASH
static std::string FL_KEY_BACKSLASH
Definition: Key.h:95
Fling::KeyNames::FL_KEY_F6
static std::string FL_KEY_F6
Definition: Key.h:126
Fling::KeyNames::FL_KEY_U
static std::string FL_KEY_U
Definition: Key.h:88
Fling::KeyNames::FL_KEY_KP_7
static std::string FL_KEY_KP_7
Definition: Key.h:153
Fling::KeyNames::FL_KEY_5
static std::string FL_KEY_5
Definition: Key.h:61
Fling::KeyNames::FL_KEY_RIGHT_CONTROL
static std::string FL_KEY_RIGHT_CONTROL
Definition: Key.h:168
Fling::KeyNames::FL_MOUSE_BUTTON_2
static std::string FL_MOUSE_BUTTON_2
Definition: Key.h:174
Fling::KeyNames::FL_KEY_PAUSE
static std::string FL_KEY_PAUSE
Definition: Key.h:120
Fling::KeyNames::FL_KEY_X
static std::string FL_KEY_X
Definition: Key.h:91
Fling::KeyState::DOWN
Fling::KeyNames::FL_KEY_4
static std::string FL_KEY_4
Definition: Key.h:60
Fling::Key
Definition: Key.h:9
Fling::KeyNames::FL_KEY_Y
static std::string FL_KEY_Y
Definition: Key.h:92
Fling::KeyNames::FL_KEY_G
static std::string FL_KEY_G
Definition: Key.h:74
Fling::KeyNames::FL_KEY_KP_2
static std::string FL_KEY_KP_2
Definition: Key.h:148
Fling::KeyNames::FL_KEY_F21
static std::string FL_KEY_F21
Definition: Key.h:141
Fling::KeyNames::FL_KEY_KP_6
static std::string FL_KEY_KP_6
Definition: Key.h:152
Fling::KeyNames::FL_KEY_EQUAL
static std::string FL_KEY_EQUAL
Definition: Key.h:67
Fling::KeyNames::FL_KEY_F3
static std::string FL_KEY_F3
Definition: Key.h:123
Fling::KeyNames::FL_KEY_SEMICOLON
static std::string FL_KEY_SEMICOLON
Definition: Key.h:66
Fling::KeyNames::FL_KEY_RIGHT_SHIFT
static std::string FL_KEY_RIGHT_SHIFT
Definition: Key.h:167
Fling::KeyNames::FL_KEY_F8
static std::string FL_KEY_F8
Definition: Key.h:128
Fling::KeyNames::FL_KEY_F19
static std::string FL_KEY_F19
Definition: Key.h:139
Fling::KeyState::UP
Fling::Key::SetState
void SetState(KeyState t_NewState)
Set the state of this key.
Definition: Key.h:32
Fling::KeyState
KeyState
Definition: KeyState.h:7
Fling::KeyNames::FL_KEY_LEFT_CONTROL
static std::string FL_KEY_LEFT_CONTROL
Definition: Key.h:164
Fling::KeyNames::FL_KEY_DELETE
static std::string FL_KEY_DELETE
Definition: Key.h:107
Fling::KeyNames::FL_KEY_F11
static std::string FL_KEY_F11
Definition: Key.h:131
UINT32
uint32_t UINT32
Definition: FlingTypes.h:13
Fling::KeyNames::FL_KEY_F
static std::string FL_KEY_F
Definition: Key.h:73
Fling::KeyNames::FL_KEY_KP_MULTIPLY
static std::string FL_KEY_KP_MULTIPLY
Definition: Key.h:158
Fling::KeyNames::FL_KEY_F1
static std::string FL_KEY_F1
Definition: Key.h:121
Fling
Definition: Engine.h:29
KeyState.h
Fling::KeyNames::FL_KEY_ESCAPE
static std::string FL_KEY_ESCAPE
Definition: Key.h:102
Fling::KeyNames::FL_KEY_J
static std::string FL_KEY_J
Definition: Key.h:77
FlingTypes.h
Fling::KeyNames::FL_KEY_DOWN
static std::string FL_KEY_DOWN
Definition: Key.h:110
Fling::KeyNames::FL_KEY_UP
static std::string FL_KEY_UP
Definition: Key.h:111
Fling::KeyNames::FL_KEY_SPACE
static std::string FL_KEY_SPACE
Definition: Key.h:50
Fling::Key::IsPressed
bool IsPressed() const
Definition: Key.h:38
Fling::KeyNames::FL_KEY_RIGHT_SUPER
static std::string FL_KEY_RIGHT_SUPER
Definition: Key.h:170
Fling::KeyNames::FL_KEY_F20
static std::string FL_KEY_F20
Definition: Key.h:140