13 void Keymap::Map(SDL_Scancode scancode, Action action) {
14 if (scancode > MAX_SCANCODE) {
15 throw std::runtime_error("cannot map out of bounds scancode");
17 codemap[scancode] = action;
20 Keymap::Action Keymap::Lookup(SDL_Scancode scancode) const {
21 if (scancode < NUM_SCANCODES) {
22 return codemap[scancode];
28 void Keymap::LoadDefault() {
29 Map(SDL_SCANCODE_ESCAPE, EXIT);
30 Map(SDL_SCANCODE_W, CAMERA_FORWARD);
31 Map(SDL_SCANCODE_S, CAMERA_BACK);
32 Map(SDL_SCANCODE_A, CAMERA_LEFT);
33 Map(SDL_SCANCODE_D, CAMERA_RIGHT);
34 Map(SDL_SCANCODE_Q, CAMERA_YAW_CW);
35 Map(SDL_SCANCODE_E, CAMERA_YAW_CCW);
36 Map(SDL_SCANCODE_INSERT, CAMERA_PITCH_CCW);
37 Map(SDL_SCANCODE_DELETE, CAMERA_PITCH_CW);
38 Map(SDL_SCANCODE_HOME, CAMERA_UP);
39 Map(SDL_SCANCODE_END, CAMERA_DOWN);
40 Map(SDL_SCANCODE_PAGEUP, CAMERA_NEARER);
41 Map(SDL_SCANCODE_PAGEDOWN, CAMERA_FARTHER);