20130313
[gdash.git] / src / sdl / sdlgameinputhandler.cpp
blob003eb6c0169f61a1d917542a8ffe1069c37806c6
1 /*
2 * Copyright (c) 2007-2013, Czirkos Zoltan http://code.google.com/p/gdash/
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include "config.h"
19 #include <SDL.h>
21 #include "sdl/sdlgameinputhandler.hpp"
22 #include "settings.hpp"
24 /* This should be in the same order as the enum, so that can be used
25 * as an index */
26 GameInputHandler::KeyAssignment SDLGameInputHandler::keys_array[] = {
27 { KeyUp, gd_sdl_key_up, &GameInputHandler::up_k },
28 { KeyDown, gd_sdl_key_down, &GameInputHandler::down_k },
29 { KeyLeft, gd_sdl_key_left, &GameInputHandler::left_k },
30 { KeyRight, gd_sdl_key_right, &GameInputHandler::right_k },
31 { KeyFire1, gd_sdl_key_fire_1, &GameInputHandler::fire1_k },
32 { KeyFire2, gd_sdl_key_fire_2, &GameInputHandler::fire2_k },
33 { KeySuicide, gd_sdl_key_suicide, &GameInputHandler::suicide },
34 { KeyFastForward, gd_sdl_key_fast_forward, &GameInputHandler::fast_forward },
35 { KeyStatusBar, gd_sdl_key_status_bar, &GameInputHandler::alternate_status },
36 { KeyRestartLevel, gd_sdl_key_restart_level, &GameInputHandler::restart_level },
40 char const *SDLGameInputHandler::get_key_name_from_keycode(int gfxlib_keycode) {
41 return SDL_GetKeyName(SDLKey(gfxlib_keycode));
45 GameInputHandler::KeyAssignment const &SDLGameInputHandler::get_key(Keys keyindex) const {
46 return keys_array[keyindex];