]> git.localhorst.tv Git - l2e.git/blob - src/app/Input.h
use sdl utility functions for debug drawing
[l2e.git] / src / app / Input.h
1 /*
2  * Input.h
3  *
4  *  Created on: Aug 6, 2012
5  *      Author: holy
6  */
7
8 #ifndef APP_INPUT_H_
9 #define APP_INPUT_H_
10
11 #include <SDL.h>
12 #include <map>
13
14 namespace app {
15
16 class Input {
17
18 public:
19         enum Button {
20                 PAD_UP = 0x0001,
21                 PAD_RIGHT = 0x0002,
22                 PAD_DOWN = 0x0004,
23                 PAD_LEFT = 0x0008,
24                 ACTION_A = 0x0010,
25                 ACTION_B = 0x0020,
26                 ACTION_X = 0x0040,
27                 ACTION_Y = 0x0080,
28                 START = 0x0100,
29                 SELECT = 0x0200,
30                 SHOULDER_RIGHT = 0x0400,
31                 SHOULDER_LEFT = 0x0800,
32
33                 DEBUG_1 = 0x1000,
34                 DEBUG_2 = 0x2000,
35                 DEBUG_3 = 0x4000,
36                 DEBUG_4 = 0x8000,
37         };
38
39 public:
40         Input();
41
42 public:
43         bool IsDown(int b) const {
44                 return down & b;
45         }
46         bool JustPressed(int b) const {
47                 return pressed & b;
48         }
49         bool JustReleased(int b) const {
50                 return released & b;
51         }
52
53 public:
54         void ResetInteractiveState() {
55                 pressed = 0;
56                 released = 0;
57         }
58         void HandleKeyboardEvent(const SDL_KeyboardEvent &);
59
60 public:
61         void MapKey(SDLKey k, Button b) {
62                 mapping[k] = b;
63         }
64
65 private:
66         std::map<SDLKey, Button> mapping;
67         Uint16 down;
68         Uint16 pressed;
69         Uint16 released;
70
71 };
72
73 }
74
75 #endif /* APP_INPUT_H_ */