]> git.localhorst.tv Git - l2e.git/blob - src/app/Input.cpp
added initializer lists to Hero and Monster models
[l2e.git] / src / app / Input.cpp
1 /*
2  * Input.cpp
3  *
4  *  Created on: Aug 6, 2012
5  *      Author: holy
6  */
7
8 #include "Input.h"
9
10 using std::map;
11
12 namespace app {
13
14 Input::Input()
15 : down(0)
16 , pressed(0)
17 , released(0) {
18
19 }
20
21
22 void Input::HandleKeyboardEvent(const SDL_KeyboardEvent &e) {
23         map<SDLKey, Button>::const_iterator key(mapping.find(e.keysym.sym));
24         if (key == mapping.end()) return;
25
26         Button button(key->second);
27         if (e.state == SDL_PRESSED) {
28                 down |= button;
29                 pressed |= button;
30         } else {
31                 down &= ~button;
32                 released |= button;
33         }
34 }
35
36 }