From 8a862bf20e9cb4754ebf614485e4b541be12651b Mon Sep 17 00:00:00 2001 From: sonninnos <45124675+sonninnos@users.noreply.github.com> Date: Sun, 18 Jun 2023 09:09:34 +0300 Subject: [PATCH] Keyboard mapping bit fix (#15392) --- input/input_driver.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index 6f7d21572f7..3e2c5b9b6f4 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -4222,6 +4222,7 @@ void config_read_keybinds_conf(void *data) unsigned i; input_driver_state_t *input_st = &input_driver_st; config_file_t *conf = (config_file_t*)data; + bool key_store[RETROK_LAST] = {0}; if (!conf) return; @@ -4255,15 +4256,19 @@ void config_read_keybinds_conf(void *data) fill_pathname_join_delim(str, prefix, btn, '_', sizeof(str)); - /* Clear old mapping bit */ - BIT512_CLEAR_PTR(&input_st->keyboard_mapping_bits, bind->key); + /* Clear old mapping bit unless just recently set */ + if (!key_store[bind->key]) + input_keyboard_mapping_bits(0, bind->key); entry = config_get_entry(conf, str); if (entry && !string_is_empty(entry->value)) bind->key = input_config_translate_str_to_rk( entry->value); - /* Store mapping bit */ - BIT512_SET_PTR(&input_st->keyboard_mapping_bits, bind->key); + + /* Store new mapping bit and remember it for a while + * so that next clear leaves the new key alone */ + input_keyboard_mapping_bits(1, bind->key); + key_store[bind->key] = true; input_config_parse_joy_button (str, conf, prefix, btn, bind); input_config_parse_joy_axis (str, conf, prefix, btn, bind);