20130320
[gdash.git] / src / gtk / gtkgameinputhandler.cpp
blob38929348f20acbefca7028bba40da037e7127e3f
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 <gtk/gtk.h>
21 #include "gtk/gtkgameinputhandler.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 GTKGameInputHandler::keys_array[] = {
27 { KeyUp, gd_gtk_key_up, &GameInputHandler::up_k },
28 { KeyDown, gd_gtk_key_down, &GameInputHandler::down_k },
29 { KeyLeft, gd_gtk_key_left, &GameInputHandler::left_k },
30 { KeyRight, gd_gtk_key_right, &GameInputHandler::right_k },
31 { KeyFire1, gd_gtk_key_fire_1, &GameInputHandler::fire1_k },
32 { KeyFire2, gd_gtk_key_fire_2, &GameInputHandler::fire2_k },
33 { KeySuicide, gd_gtk_key_suicide, &GameInputHandler::suicide },
34 { KeyFastForward, gd_gtk_key_fast_forward, &GameInputHandler::fast_forward },
35 { KeyStatusBar, gd_gtk_key_status_bar, &GameInputHandler::alternate_status },
36 { KeyRestartLevel, gd_gtk_key_restart_level, &GameInputHandler::restart_level },
40 char const *GTKGameInputHandler::get_key_name_from_keycode(int gfxlib_keycode) {
41 return gdk_keyval_name(gfxlib_keycode);
45 GameInputHandler::KeyAssignment const &GTKGameInputHandler::get_key(Keys keyindex) const {
46 return keys_array[keyindex];