]> git.localhorst.tv Git - l2e.git/blob - Input.cpp
ad5bdf7767dd1befef37d23d6eddeec0acf77a7e
[l2e.git] / Input.cpp
1 #include "Input.h"
2
3 using std::map;
4
5 namespace app {
6
7 Input::Input()
8 : down(0)
9 , pressed(0)
10 , released(0) {
11
12 }
13
14
15 void Input::HandleKeyboardEvent(const SDL_KeyboardEvent &e) {
16         map<SDLKey, Button>::const_iterator key(mapping.find(e.keysym.sym));
17         if (key == mapping.end()) return;
18
19         Button button(key->second);
20         if (e.state == SDL_PRESSED) {
21                 down |= button;
22                 pressed |= button;
23         } else {
24                 down &= ~button;
25                 released |= button;
26         }
27 }
28
29 }