diff --git a/src/controls.cpp b/src/controls.cpp index 82c2a92b2..992fe5466 100644 --- a/src/controls.cpp +++ b/src/controls.cpp @@ -21,6 +21,7 @@ distribution. */ +#include #ifdef _MSC_VER #include #else @@ -37,6 +38,7 @@ #include "asserts.hpp" #include "controls.hpp" +#include "module.hpp" #include "joystick.hpp" #include "multiplayer.hpp" #include "preferences.hpp" @@ -46,11 +48,44 @@ PREF_INT(max_control_history, 1024, "Maximum number of frames to keep control hi namespace controls { - const char** control_names() + void resize_controls_list(){ + // Change num_controls variable to accurately reflect + // the number of current actions + const char** names = control_names(); + + for(int n=0;names[n] != NULL;n++){ + num_controls=n; + } + + // List of SDL keycodes + sdlk = (key_type*) malloc(num_controls*sizeof(key_type)); + if(sdlk == NULL){ + LOG_ERROR("Memory not allocated to sdlk"); + exit(0); + } + sdlk = module::control_keys(); + + + LOG_INFO("NUMBER OF CONTROLS:"); + LOG_INFO(num_controls); + } + + const static char** control_names() { // Null-terminated list of action names - static const char* names[] = { "up", "down", "left", "right", "attack", "jump", "tongue", "sprint", nullptr }; - return names; + //static const char* names[] = { "up", "down", "left", "right", "attack", "jump", "tongue", "sprint", nullptr }; + return module::module_control_names(); + } + + int get_action_index(std::string string){ + const char** names = control_names(); + for(int i=0;names[i] != NULL;i++){ + // Does '==' work for std::string and char* comparison? + if (string == names[i]){ + return i; + } + } + return -1; } namespace { @@ -95,21 +130,10 @@ namespace controls int first_invalid_cycle_var = -1; - // List of SDL keycodes - key_type sdlk[NUM_CONTROLS] = { - SDLK_UP, - SDLK_DOWN, - SDLK_LEFT, - SDLK_RIGHT, - SDLK_d, - SDLK_a, - SDLK_s - }; - CONTROL_ITEM g_mouse_controls[3] = { - NUM_CONTROLS, - NUM_CONTROLS, - NUM_CONTROLS, + num_controls, + num_controls, + num_controls, }; //If any of these keys are held, we ignore other keyboard input. @@ -240,18 +264,22 @@ namespace controls } } + //array of keys which we are ignoring. We ignore keys on the end of a dialog. + //keys will be unignored as soon as they are no longer depressed. - namespace - { - //array of keys which we are ignoring. We ignore keys on the end of a dialog. - //keys will be unignored as soon as they are no longer depressed. - bool key_ignore[NUM_CONTROLS]; + bool* key_ignore = (bool*) malloc(num_controls*sizeof(bool)); + if(key_ignore == NULL){ + LOG_ERROR("Memory not allocated to key_ignore"); + exit(0); + } + for(int i=0;i(highest_confirmed[n]); ++m) { ss.clear(); ss << "CTRL PLAYER " << n << " CYCLE " << m << ": "; - for(int j = 0; j != NUM_CONTROLS; ++j) { + for(int j = 0; j != num_controls; ++j) { ss << (((1 << j)&controls[n][m].keys) ? "1" : "0"); } LOG_INFO(ss.str()); @@ -721,19 +749,19 @@ namespace controls return g_mouse_controls[mouse_button]; } - return NUM_CONTROLS; + return num_controls; } void set_keycode(CONTROL_ITEM item, key_type key) { - if (item < NUM_CONTROLS) { + if (item < num_controls) { sdlk[item] = key; } } key_type get_keycode(CONTROL_ITEM item) { - if (item < NUM_CONTROLS) { + if (item < num_controls) { return sdlk[item]; } return SDLK_UNKNOWN; diff --git a/src/controls.hpp b/src/controls.hpp index 26f2279da..40ca82a27 100644 --- a/src/controls.hpp +++ b/src/controls.hpp @@ -33,7 +33,8 @@ class variant; namespace controls { - enum CONTROL_ITEM { + void resize_controls_list(); +/* enum CONTROL_ITEM { CONTROL_UP, CONTROL_DOWN, CONTROL_LEFT, @@ -41,10 +42,15 @@ namespace controls CONTROL_ATTACK, CONTROL_JUMP, CONTROL_TONGUE, - NUM_CONTROLS, - }; + num_controls, + };*/ + + static key_type * sdlk; + static int num_controls; + typedef int CONTROL_ITEM; - const char** control_names(); + const static char** control_names(); + int get_action_index(std::string string); void set_mouse_to_keycode(CONTROL_ITEM item, int mouse_button); CONTROL_ITEM get_mouse_keycode(int mouse_button); diff --git a/src/controls_dialog.cpp b/src/controls_dialog.cpp index ddd80052e..6e9c68d60 100644 --- a/src/controls_dialog.cpp +++ b/src/controls_dialog.cpp @@ -30,15 +30,16 @@ #include "i18n.hpp" #include "key_button.hpp" #include "screen_handling.hpp" +#include namespace { - gui::KeyButtonPtr KeyButtons[controls::NUM_CONTROLS]; + std::vector KeyButtons(controls::num_controls); void end_dialog(gui::Dialog* d) { using namespace controls; - for(int n = 0; n < NUM_CONTROLS; ++n) { + for(int n = 0; n < num_controls; ++n) { const CONTROL_ITEM item = static_cast(n); set_keycode(item, KeyButtons[item]->get_key()); } @@ -52,7 +53,7 @@ void show_controls_dialog() using namespace controls; const int vw = graphics::GameScreen::get().getVirtualWidth(); const int vh = graphics::GameScreen::get().getVirtualHeight(); - + //HACK: 10 and 4 are the default button padding. Padding should be taken from buttons in KeyButtons list int butt_padx = 10; int butt_pady = 4; @@ -62,7 +63,7 @@ void show_controls_dialog() int butt_width_wp = butt_width + butt_padx; int butt_height_wp = butt_height + butt_pady; - + int sep_y = 50; int height = vh- 20; @@ -74,32 +75,32 @@ void show_controls_dialog() d.setDrawBackgroundFn(draw_last_scene); - for(int n = 0; n < NUM_CONTROLS; ++n) { + for(int n = 0; n < num_controls; ++n) { const CONTROL_ITEM item = static_cast(n); KeyButtons[item] = KeyButtonPtr(new KeyButton(get_keycode(item), BUTTON_SIZE_DOUBLE_RESOLUTION)); KeyButtons[item]->setDim(butt_width, butt_height); } WidgetPtr t_dirs(new GraphicalFontLabel(_("Directions"), "door_label", 2)); - WidgetPtr b_up(KeyButtons[CONTROL_UP]); - WidgetPtr b_down(KeyButtons[CONTROL_DOWN]); - WidgetPtr b_left(KeyButtons[CONTROL_LEFT]); - WidgetPtr b_right(KeyButtons[CONTROL_RIGHT]); + WidgetPtr b_up(KeyButtons[controls::get_action_index("up")]); + WidgetPtr b_down(KeyButtons[controls::get_action_index("down")]); + WidgetPtr b_left(KeyButtons[controls::get_action_index("left")]); + WidgetPtr b_right(KeyButtons[controls::get_action_index("right")]); WidgetPtr t_jump(new GraphicalFontLabel(_("Jump"), "door_label", 2)); - WidgetPtr b_jump(KeyButtons[CONTROL_JUMP]); + WidgetPtr b_jump(KeyButtons[controls::get_action_index("jump")]); WidgetPtr t_tongue(new GraphicalFontLabel(_("Tongue"), "door_label", 2)); - WidgetPtr b_tongue(KeyButtons[CONTROL_TONGUE]); + WidgetPtr b_tongue(KeyButtons[controls::get_action_index("tongue")]); WidgetPtr t_item(new GraphicalFontLabel(_("Item"), "door_label", 2)); - WidgetPtr b_item(KeyButtons[CONTROL_ATTACK]); - + WidgetPtr b_item(KeyButtons[controls::get_action_index("attack")]); + //WidgetPtr b_sprint(KeyButtons[CONTROL_SPRINT]); //WidgetPtr t_sprint(new GraphicalFontLabel(_("Sprint"), "door_label", 2)); WidgetPtr back_button(new Button(WidgetPtr(new GraphicalFontLabel(_("Back"), "door_label", 2)), std::bind(end_dialog, &d), BUTTON_STYLE_DEFAULT, BUTTON_SIZE_DOUBLE_RESOLUTION)); back_button->setDim(230, 60); - + int top_label_height = d.padding(); int top_label_botm_edge = top_label_height+t_dirs->height(); diff --git a/src/dialog.cpp b/src/dialog.cpp index 50fe50088..1d6bb7ac5 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -566,8 +566,8 @@ namespace gui if(!claimed && opened_) { if(ev.type == SDL_KEYDOWN) { - if(ev.key.keysym.sym == controls::get_keycode(controls::CONTROL_ATTACK) - || ev.key.keysym.sym == controls::get_keycode(controls::CONTROL_JUMP)) { + if(ev.key.keysym.sym == controls::get_keycode(controls::get_action_index("attack")) + || ev.key.keysym.sym == controls::get_keycode(controls::get_action_index("jump"))) { doSelectEvent(); } if(ev.key.keysym.sym == SDLK_TAB) { diff --git a/src/dropdown_widget.cpp b/src/dropdown_widget.cpp index 17e8692ef..dded3bbbe 100644 --- a/src/dropdown_widget.cpp +++ b/src/dropdown_widget.cpp @@ -371,8 +371,9 @@ namespace gui if(hasFocus() && dropdown_menu_) { if(event.type == SDL_KEYDOWN - && (event.key.keysym.sym == controls::get_keycode(controls::CONTROL_ATTACK) - || event.key.keysym.sym == controls::get_keycode(controls::CONTROL_JUMP))) { + + && (event.key.keysym.sym == controls::get_keycode(controls::get_action_index("attack")) + || event.key.keysym.sym == controls::get_keycode(controls::get_action_index("jump")))) { claimed = true; dropdown_menu_->setVisible(!dropdown_menu_->visible()); } diff --git a/src/entity.cpp b/src/entity.cpp index ffc84e9f7..8252f1950 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -26,6 +26,7 @@ #include "Canvas.hpp" +#include "controls.hpp" #include "custom_object.hpp" #include "debug_console.hpp" #include "entity.hpp" @@ -65,9 +66,10 @@ Entity::Entity(variant node) setAnchorY(node["anchory"].as_decimal()); } - for(bool& b : controls_) { - b = false; - } + + for (int i=0;i::max()), true_z_(false), tx_(double(x)), ty_(double(y)), tz_(0.0f) { - for(bool& b : controls_) { - b = false; + for(int i=0;i scheduled_commands_; - bool controls_[controls::NUM_CONTROLS]; + std::vector controls_; variant controls_user_; //attached objects are objects which are also drawn with this object. diff --git a/src/formula_constants.cpp b/src/formula_constants.cpp index f0c67e2f7..2fbfbf3dc 100644 --- a/src/formula_constants.cpp +++ b/src/formula_constants.cpp @@ -85,19 +85,19 @@ namespace game_logic } else if(id == "PASSWORD") { return variant(preferences::get_password()); } else if(id == "UP_KEY") { - return variant(gui::KeyButton::getKeyName(controls::get_keycode(controls::CONTROL_UP))); + return variant(gui::KeyButton::getKeyName(controls::get_keycode(controls::get_action_index("up")))); } else if(id == "DOWN_KEY") { - return variant(gui::KeyButton::getKeyName(controls::get_keycode(controls::CONTROL_DOWN))); + return variant(gui::KeyButton::getKeyName(controls::get_keycode(controls::get_action_index("down")))); } else if(id == "LEFT_KEY") { - return variant(gui::KeyButton::getKeyName(controls::get_keycode(controls::CONTROL_LEFT))); + return variant(gui::KeyButton::getKeyName(controls::get_keycode(controls::get_action_index("left")))); } else if(id == "RIGHT_KEY") { - return variant(gui::KeyButton::getKeyName(controls::get_keycode(controls::CONTROL_RIGHT))); + return variant(gui::KeyButton::getKeyName(controls::get_keycode(controls::get_action_index("right")))); } else if(id == "JUMP_KEY") { - return variant(gui::KeyButton::getKeyName(controls::get_keycode(controls::CONTROL_JUMP))); + return variant(gui::KeyButton::getKeyName(controls::get_keycode(controls::get_action_index("jump")))); } else if(id == "TONGUE_KEY") { - return variant(gui::KeyButton::getKeyName(controls::get_keycode(controls::CONTROL_TONGUE))); + return variant(gui::KeyButton::getKeyName(controls::get_keycode(controls::get_action_index("tongue")))); } else if(id == "ATTACK_KEY") { - return variant(gui::KeyButton::getKeyName(controls::get_keycode(controls::CONTROL_ATTACK))); + return variant(gui::KeyButton::getKeyName(controls::get_keycode(controls::get_action_index("attack")))); } else if(id == "LOCALE") { return variant(i18n::get_locale()); } else if(id == "EPSILON") { diff --git a/src/grid_widget.cpp b/src/grid_widget.cpp index 614ae7dde..8f9582046 100644 --- a/src/grid_widget.cpp +++ b/src/grid_widget.cpp @@ -567,8 +567,8 @@ namespace gui selected_row_ = 0; } claimed = true; - } else if(ev.key.keysym.sym == controls::get_keycode(controls::CONTROL_ATTACK) - || ev.key.keysym.sym == controls::get_keycode(controls::CONTROL_JUMP)) { + } else if(ev.key.keysym.sym == controls::get_keycode(controls::get_action_index("attack")) + || ev.key.keysym.sym == controls::get_keycode(controls::get_action_index("jump"))) { if(on_select_) { on_select_(selected_row_); } diff --git a/src/main.cpp b/src/main.cpp index 8f7ee83c9..b37c7bf87 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -270,6 +270,9 @@ namespace argv->insert(argv->begin() + insertion_point, arguments.begin(), arguments.end()); } + + // resize num_controls to represent the actual number of actions + controls::resize_controls_list(); return 0; } diff --git a/src/module.cpp b/src/module.cpp index 24a2057a5..2ce601933 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -21,6 +21,7 @@ distribution. */ +#include #include #include @@ -31,6 +32,7 @@ #include "asserts.hpp" #include "base64.hpp" #include "compress.hpp" +#include "controls.hpp" #include "custom_object_type.hpp" #include "i18n.hpp" #include "filesystem.hpp" @@ -88,9 +90,34 @@ namespace module game_logic::ConstFormulaCallablePtr module_args; - std::string core_module_name; + std::string core_module_name; } + // Ignore the 'controls' section imported from module.cfg for now. I just want the logic working + const char** module_control_names() + { + // Null-terminated list of action names + // TODO: replace with information from frogatto's module.cfg + static const char* names[] = { "jump", "tongue", "item", "sprint", "inventory", "pane-left", "pane-right", nullptr }; + return names; + } + key_type* control_keys() + { + // List of action keys + // TODO: replace with information from frogatto's module.cfg + static key_type keys[] = { + SDLK_a, + SDLK_s, + SDLK_d, + SDLK_LSHIFT, + SDLK_i, + SDLK_q, + SDLK_w + }; + return keys; + } + + void set_core_module_name(const std::string& module_name) { core_module_name = module_name; @@ -522,7 +549,8 @@ namespace module m.actions = an.getKeys().as_list_string(); } - if(v["controls"].has_key("key_bindings")){ + + /*if(v["controls"].has_key("key_bindings")){ const variant& kb = v["controls"]["key_bindings"]; for(auto p : kb.as_map()){ @@ -569,7 +597,7 @@ namespace module m.axes_bindings[p.first.as_string()] = p.second.as_list_string(); } - } + }*/ /*LOG_INFO("KEYS:") for (auto act_keys = begin(m.key_bindings); act_keys != end(m.key_bindings); act_keys++) { diff --git a/src/module.hpp b/src/module.hpp index e59d3640f..4c728b3e3 100644 --- a/src/module.hpp +++ b/src/module.hpp @@ -23,6 +23,7 @@ #pragma once +#include "controls.hpp" #include "filesystem.hpp" #include "formula_callable.hpp" #include "variant.hpp" @@ -41,7 +42,9 @@ namespace module // For importing the input definition from module.cfg typedef std::vector> key_list; - typedef std::map key_binding; + typedef std::vector> keyb_list; + + typedef std::map key_binding; typedef std::map button_binding; typedef std::map> axes_binding; @@ -70,9 +73,10 @@ namespace module axes_binding axes_bindings; std::vector actions; - }; + const char** module_control_names(); + key_type* control_keys(); typedef std::map module_file_map; typedef std::pair module_file_pair; diff --git a/src/playable_custom_object.cpp b/src/playable_custom_object.cpp index 5303662ed..5851160df 100644 --- a/src/playable_custom_object.cpp +++ b/src/playable_custom_object.cpp @@ -149,7 +149,7 @@ bool PlayableCustomObject::onPlatform() const int PlayableCustomObject::walkUpOrDownStairs() const { - return controlStatus(controls::CONTROL_DOWN) - controlStatus(controls::CONTROL_UP); + return controlStatus(controls::get_action_index("down")) - controlStatus(controls::get_action_index("up")); } void PlayableCustomObject::process(Level& lvl) @@ -175,8 +175,8 @@ void PlayableCustomObject::process(Level& lvl) } if(process_controls) { - bool controls[controls::NUM_CONTROLS]; - for(int n = 0; n != controls::NUM_CONTROLS; ++n) { + bool controls[controls::num_controls]; + for(int n = 0; n != controls::num_controls; ++n) { controls[n] = controlStatus(static_cast(n)); } @@ -185,7 +185,7 @@ void PlayableCustomObject::process(Level& lvl) // XX Need to abstract this to read controls and mappings from global game file. static const std::string keys[] = { "up", "down", "left", "right", "attack", "jump", "tongue" }; - for(int n = 0; n != controls::NUM_CONTROLS; ++n) { + for(int n = 0; n != controls::num_controls; ++n) { if(controls[n] != controlStatus(static_cast(n))) { if(controls[n]) { handleEvent("end_ctrl_" + keys[n]); diff --git a/src/player_info.cpp b/src/player_info.cpp index ea03d1969..a3d8305b7 100644 --- a/src/player_info.cpp +++ b/src/player_info.cpp @@ -72,16 +72,17 @@ variant PlayerInfo::write() const void PlayerInfo::readControls(int cycle) { - bool status[controls::NUM_CONTROLS]; + bool status[controls::num_controls]; const std::string* user = nullptr; controls::get_controlStatus(cycle, slot_, status, &user); - if(status[controls::CONTROL_LEFT] && status[controls::CONTROL_RIGHT]) { + //TODO: Fix + /*if(status[controls::get_action_index("left")] && status[controls::get_action_index("right")]) { //if both left and right are held, treat it as if neither are. - status[controls::CONTROL_LEFT] = status[controls::CONTROL_RIGHT] = false; - } + status[controls::get_action_index("left")] = status[controls::get_action_index("right")] = false; + }*/ - for(int n = 0; n != controls::NUM_CONTROLS; ++n) { + for(int n = 0; n != controls::num_controls; ++n) { entity_->setControlStatus(static_cast(n), status[n]); } diff --git a/src/preferences.cpp b/src/preferences.cpp index 005aefb38..6ff3128b8 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -940,22 +940,23 @@ namespace preferences password_ = node["passhash"].as_string_default(""); cookie_ = node.has_key("cookie") ? node["cookie"] : variant(); - controls::set_keycode(controls::CONTROL_UP, static_cast(node["key_up"].as_int(SDLK_UP))); - controls::set_keycode(controls::CONTROL_DOWN, static_cast(node["key_down"].as_int(SDLK_DOWN))); - controls::set_keycode(controls::CONTROL_LEFT, static_cast(node["key_left"].as_int(SDLK_LEFT))); - controls::set_keycode(controls::CONTROL_RIGHT, static_cast(node["key_right"].as_int(SDLK_RIGHT))); - controls::set_keycode(controls::CONTROL_ATTACK, static_cast(node["key_attack"].as_int(SDLK_d))); - controls::set_keycode(controls::CONTROL_JUMP, static_cast(node["key_jump"].as_int(SDLK_a))); - controls::set_keycode(controls::CONTROL_TONGUE, static_cast(node["key_tongue"].as_int(SDLK_s))); - - int ctrl_item = 0; - for(const char** control_name = controls::control_names(); *control_name && ctrl_item != controls::NUM_CONTROLS; ++control_name, ++ctrl_item) { + controls::set_keycode(controls::get_action_index("up"), static_cast(node["key_up"].as_int(SDLK_UP))); + controls::set_keycode(controls::get_action_index("down"), static_cast(node["key_down"].as_int(SDLK_DOWN))); + controls::set_keycode(controls::get_action_index("left"), static_cast(node["key_left"].as_int(SDLK_LEFT))); + controls::set_keycode(controls::get_action_index("right"), static_cast(node["key_right"].as_int(SDLK_RIGHT))); + controls::set_keycode(controls::get_action_index("attack"), static_cast(node["key_attack"].as_int(SDLK_d))); + controls::set_keycode(controls::get_action_index("jump"), static_cast(node["key_jump"].as_int(SDLK_a))); + controls::set_keycode(controls::get_action_index("tongue"), static_cast(node["key_tongue"].as_int(SDLK_s))); + + //TODO: Unbreak + /*int ctrl_item = 0; + for(const char** control_name = controls::control_names(); *control_name && ctrl_item != controls::num_controls; ++control_name, ++ctrl_item) { std::string key = "mouse_"; key += *control_name; if(node.has_key(key)) { controls::set_mouse_to_keycode(static_cast(ctrl_item), node[key].as_int()); } - } + }*/ preferences::set_32bpp_textures_if_kb_memory_at_least(512000); } @@ -971,21 +972,23 @@ namespace preferences node.add("joystick", variant::from_bool(use_joystick_)); node.add("sound_volume", static_cast(sound::get_sound_volume()*1000)); node.add("music_volume", static_cast(sound::get_music_volume()*1000)); - node.add("key_up", controls::get_keycode(controls::CONTROL_UP)); - node.add("key_down", controls::get_keycode(controls::CONTROL_DOWN)); - node.add("key_left", controls::get_keycode(controls::CONTROL_LEFT)); - node.add("key_right", controls::get_keycode(controls::CONTROL_RIGHT)); - node.add("key_attack", controls::get_keycode(controls::CONTROL_ATTACK)); - node.add("key_jump", controls::get_keycode(controls::CONTROL_JUMP)); - node.add("key_tongue", controls::get_keycode(controls::CONTROL_TONGUE)); + node.add("key_up", controls::get_keycode(controls::get_action_index("up"))); + node.add("key_down", controls::get_keycode(controls::get_action_index("down"))); + node.add("key_left", controls::get_keycode(controls::get_action_index("left"))); + node.add("key_right", controls::get_keycode(controls::get_action_index("right"))); + node.add("key_attack", controls::get_keycode(controls::get_action_index("attack"))); + node.add("key_jump", controls::get_keycode(controls::get_action_index("jump"))); + node.add("key_tongue", controls::get_keycode(controls::get_action_index("tongue"))); node.add("show_iphone_controls", variant::from_bool(show_iphone_controls_)); + //TODO: Unbreak + /* for(int n = 1; n <= 3; ++n) { controls::CONTROL_ITEM ctrl = controls::get_mouse_keycode(n); - if(ctrl != controls::NUM_CONTROLS) { + if(ctrl != controls::num_controls) { node.add(std::string("mouse_") + controls::control_names()[ctrl], variant(n)); } - } + }*/ node.add("locale", locale_); node.add("username", variant(get_username())); diff --git a/src/speech_dialog.cpp b/src/speech_dialog.cpp index 24d87a2c4..ae993e69a 100644 --- a/src/speech_dialog.cpp +++ b/src/speech_dialog.cpp @@ -120,13 +120,13 @@ bool SpeechDialog::keyPress(const SDL_Event& event) static int last_mouse = 0; if(text_char_ == num_chars() && options_.empty() == false) { if(event.type == SDL_KEYDOWN) { - if(event.key.keysym.sym == get_keycode(controls::CONTROL_UP)) { + if(event.key.keysym.sym == controls::get_keycode(controls::get_action_index("up"))) { moveUp(); - } else if(event.key.keysym.sym == get_keycode(controls::CONTROL_DOWN)) { + } else if(event.key.keysym.sym == controls::get_keycode(controls::get_action_index("down"))) { moveDown(); } else if(event.key.keysym.sym == SDLK_RETURN || event.key.keysym.sym == SDLK_SPACE || - event.key.keysym.sym == get_keycode(controls::CONTROL_JUMP) || - event.key.keysym.sym == get_keycode(controls::CONTROL_TONGUE)) { + event.key.keysym.sym == controls::get_keycode(controls::get_action_index("jump")) || + event.key.keysym.sym == controls::get_keycode(controls::get_action_index("tongue"))) { return true; } }