]> git.localhorst.tv Git - tacos.git/blob - src/app/keymap.hpp
controllable camera
[tacos.git] / src / app / keymap.hpp
1 #ifndef TACOS_APP_KEYMAP_HPP
2 #define TACOS_APP_KEYMAP_HPP
3
4 #include <SDL.h>
5
6
7 namespace tacos {
8
9 class Keymap {
10
11 public:
12         enum Action {
13                 NONE,
14
15                 CAMERA_RIGHT,
16                 CAMERA_LEFT,
17                 CAMERA_UP,
18                 CAMERA_DOWN,
19                 CAMERA_BACK,
20                 CAMERA_FORWARD,
21                 CAMERA_NEARER,
22                 CAMERA_FARTHER,
23                 CAMERA_PITCH_CCW,
24                 CAMERA_PITCH_CW,
25                 CAMERA_YAW_CCW,
26                 CAMERA_YAW_CW,
27
28                 EXIT,
29         };
30
31         static constexpr unsigned int MAX_SCANCODE = 0xFF;
32         static constexpr unsigned int NUM_SCANCODES = MAX_SCANCODE + 1;
33
34 public:
35         Keymap();
36
37         void Map(SDL_Scancode scancode, Action);
38         Action Lookup(SDL_Scancode scancode) const;
39         Action Lookup(const SDL_Keysym &s) const { return Lookup(s.scancode); }
40         Action Lookup(const SDL_KeyboardEvent &e) const { return Lookup(e.keysym); }
41
42         void LoadDefault();
43
44 private:
45         Action codemap[NUM_SCANCODES];
46
47 };
48
49 }
50
51 #endif