+#include "keymap.hpp"
+
+#include <stdexcept>
+
+
+namespace tacos {
+
+Keymap::Keymap()
+: codemap{ NONE } {
+
+}
+
+void Keymap::Map(SDL_Scancode scancode, Action action) {
+ if (scancode > MAX_SCANCODE) {
+ throw std::runtime_error("cannot map out of bounds scancode");
+ }
+ codemap[scancode] = action;
+}
+
+Keymap::Action Keymap::Lookup(SDL_Scancode scancode) const {
+ if (scancode < NUM_SCANCODES) {
+ return codemap[scancode];
+ } else {
+ return NONE;
+ }
+}
+
+void Keymap::LoadDefault() {
+ Map(SDL_SCANCODE_ESCAPE, EXIT);
+ Map(SDL_SCANCODE_W, CAMERA_FORWARD);
+ Map(SDL_SCANCODE_S, CAMERA_BACK);
+ Map(SDL_SCANCODE_A, CAMERA_LEFT);
+ Map(SDL_SCANCODE_D, CAMERA_RIGHT);
+ Map(SDL_SCANCODE_Q, CAMERA_YAW_CW);
+ Map(SDL_SCANCODE_E, CAMERA_YAW_CCW);
+ Map(SDL_SCANCODE_INSERT, CAMERA_PITCH_CCW);
+ Map(SDL_SCANCODE_DELETE, CAMERA_PITCH_CW);
+ Map(SDL_SCANCODE_HOME, CAMERA_UP);
+ Map(SDL_SCANCODE_END, CAMERA_DOWN);
+ Map(SDL_SCANCODE_PAGEUP, CAMERA_NEARER);
+ Map(SDL_SCANCODE_PAGEDOWN, CAMERA_FARTHER);
+}
+
+}