Skip to content

Commit

Permalink
Override only configurable keys (partially fixes SuperTux#1400)
Browse files Browse the repository at this point in the history
  • Loading branch information
szborows committed May 22, 2020
1 parent c6db5a6 commit da69269
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/control/keyboard_config.cpp
Expand Up @@ -47,6 +47,22 @@ KeyboardConfig::KeyboardConfig() :
m_keymap[SDLK_F1] = Control::CHEAT_MENU;
m_keymap[SDLK_F2] = Control::DEBUG_MENU;
m_keymap[SDLK_BACKSPACE]= Control::REMOVE;

m_configurable_controls = {
Control::UP,
Control::DOWN,
Control::LEFT,
Control::RIGHT,
Control::JUMP,
Control::ACTION,
Control::PEEK_LEFT,
Control::PEEK_RIGHT,
Control::PEEK_UP,
Control::PEEK_DOWN,
Control::CONSOLE,
Control::CHEAT_MENU,
Control::DEBUG_MENU
};
}

void
Expand Down Expand Up @@ -76,7 +92,7 @@ KeyboardConfig::read(const ReaderMapping& keymap_mapping)
map.get("control", control_text);

const boost::optional<Control> maybe_control = Control_from_string(control_text);
if (maybe_control) {
if (maybe_control && m_configurable_controls.count(*maybe_control)) {
bind_key(static_cast<SDL_Keycode>(key), *maybe_control);
} else {
log_warning << "Invalid control '" << control_text << "' in keymap" << std::endl;
Expand Down
2 changes: 2 additions & 0 deletions src/control/keyboard_config.hpp
Expand Up @@ -19,6 +19,7 @@

#include <SDL.h>
#include <map>
#include <set>

#include "control/controller.hpp"

Expand All @@ -41,6 +42,7 @@ class KeyboardConfig final

private:
std::map<SDL_Keycode, Control> m_keymap;
std::set<Control> m_configurable_controls;
bool m_jump_with_up_kbd;

private:
Expand Down

0 comments on commit da69269

Please sign in to comment.