Radium Engine
1.5.20
Loading...
Searching...
No Matches
Keyboard.cpp
1
#include <Gui/Utils/Keyboard.hpp>
2
3
#include <map>
4
5
namespace
Ra
{
6
namespace
Gui {
7
std::map<int, bool>
g_keypresses;
8
9
// store the last key pressed, still pressed.
10
int
g_activeKey = -1;
11
12
void
keyPressed(
int
code ) {
13
g_keypresses[code] =
true
;
14
g_activeKey = code;
15
}
16
17
void
keyReleased(
int
code ) {
18
g_keypresses[code] =
false
;
19
if
( code == g_activeKey ) g_activeKey = -1;
20
}
21
22
bool
isKeyPressed(
int
code ) {
23
// Default constructed bool is false, so this should be enough
24
return
g_keypresses[code];
25
}
26
27
int
activeKey() {
28
return
g_activeKey;
29
}
30
31
void
releaseAllKeys() {
32
for
(
auto
& k : g_keypresses ) {
33
k.second =
false
;
34
}
35
g_activeKey = -1;
36
}
37
38
}
// namespace Gui
39
}
// namespace Ra
std::map
Ra
hepler function to manage enum as underlying types in VariableSet
Definition
Cage.cpp:3
src
Gui
Utils
Keyboard.cpp
Generated by
1.12.0