]> git.localhorst.tv Git - tacos.git/blobdiff - src/app/keymap.hpp
controllable camera
[tacos.git] / src / app / keymap.hpp
diff --git a/src/app/keymap.hpp b/src/app/keymap.hpp
new file mode 100644 (file)
index 0000000..34aa8d9
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef TACOS_APP_KEYMAP_HPP
+#define TACOS_APP_KEYMAP_HPP
+
+#include <SDL.h>
+
+
+namespace tacos {
+
+class Keymap {
+
+public:
+       enum Action {
+               NONE,
+
+               CAMERA_RIGHT,
+               CAMERA_LEFT,
+               CAMERA_UP,
+               CAMERA_DOWN,
+               CAMERA_BACK,
+               CAMERA_FORWARD,
+               CAMERA_NEARER,
+               CAMERA_FARTHER,
+               CAMERA_PITCH_CCW,
+               CAMERA_PITCH_CW,
+               CAMERA_YAW_CCW,
+               CAMERA_YAW_CW,
+
+               EXIT,
+       };
+
+       static constexpr unsigned int MAX_SCANCODE = 0xFF;
+       static constexpr unsigned int NUM_SCANCODES = MAX_SCANCODE + 1;
+
+public:
+       Keymap();
+
+       void Map(SDL_Scancode scancode, Action);
+       Action Lookup(SDL_Scancode scancode) const;
+       Action Lookup(const SDL_Keysym &s) const { return Lookup(s.scancode); }
+       Action Lookup(const SDL_KeyboardEvent &e) const { return Lookup(e.keysym); }
+
+       void LoadDefault();
+
+private:
+       Action codemap[NUM_SCANCODES];
+
+};
+
+}
+
+#endif