diff --git a/src/control/keyboard_config.cpp b/src/control/keyboard_config.cpp index 538db90ec31..e808a8373c0 100644 --- a/src/control/keyboard_config.cpp +++ b/src/control/keyboard_config.cpp @@ -52,35 +52,34 @@ KeyboardConfig::KeyboardConfig() : void KeyboardConfig::read(const ReaderMapping& keymap_mapping) { + // backwards compatibility: // keycode values changed between SDL1 and SDL2, so we skip old SDL1 // based values and use the defaults instead on the first read of // the config file bool config_is_sdl2 = false; keymap_mapping.get("sdl2", config_is_sdl2); - if (config_is_sdl2) - { - keymap_mapping.get("jump-with-up", m_jump_with_up_kbd); + if (!config_is_sdl2) + return; - auto iter = keymap_mapping.get_iter(); - while (iter.next()) - { - if (iter.get_key() == "map") - { - int key = -1; - auto map = iter.as_mapping(); - map.get("key", key); - - std::string control_text; - map.get("control", control_text); - - const boost::optional maybe_control = Control_from_string(control_text); - if (!maybe_control) { - log_info << "Invalid control '" << control_text << "' in keymap" << std::endl; - } else { - const Control control = *maybe_control; - m_keymap[static_cast(key)] = control; - } - } + keymap_mapping.get("jump-with-up", m_jump_with_up_kbd); + + auto iter = keymap_mapping.get_iter(); + while (iter.next()) + { + if (iter.get_key() != "map") + continue; + int key = -1; + auto map = iter.as_mapping(); + map.get("key", key); + + std::string control_text; + map.get("control", control_text); + + const boost::optional maybe_control = Control_from_string(control_text); + if (maybe_control) { + bind_key(static_cast(key), *maybe_control); + } else { + log_warning << "Invalid control '" << control_text << "' in keymap" << std::endl; } } }