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