From f7b94e5f66ae1cb9cfe3c8ae88504efcb4596a08 Mon Sep 17 00:00:00 2001 From: radius Date: Mon, 2 Apr 2018 20:27:51 -0500 Subject: [PATCH] remap-redux part2: clean up gamepad mapper callbacks --- menu/cbs/menu_cbs_get_value.c | 11 +++++------ menu/cbs/menu_cbs_left.c | 14 +++++--------- menu/cbs/menu_cbs_right.c | 14 +++++--------- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index e19a4db51f..489da78c4d 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -553,25 +553,24 @@ static void menu_action_setting_disp_set_label_input_desc( const struct retro_keybind *keybind = NULL; settings_t *settings = config_get_ptr(); - unsigned key_id, id, offset; + unsigned btn_idx, user_idx; unsigned remap_id = 0; if (!settings) return; - offset = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8); - - id = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * offset; + user_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8); + btn_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * user_idx; remap_id = - settings->uints.input_remap_ids[offset][id]; + settings->uints.input_remap_ids[user_idx][btn_idx]; system = runloop_get_system_info(); if (!system) return; - descriptor = system->input_desc_btn[offset][remap_id]; + descriptor = system->input_desc_btn[user_idx][remap_id]; if (!string_is_empty(descriptor)) strlcpy(s, descriptor, len); diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index f27952c779..a4015d1c6d 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -90,24 +90,20 @@ static int action_left_cheat(unsigned type, const char *label, wraparound); } -/* fix-me: incomplete, lacks error checking */ static int action_left_input_desc(unsigned type, const char *label, bool wraparound) { - - unsigned key_id, id, offset; - unsigned remap_id = 0; + unsigned btn_idx, user_idx; settings_t *settings = config_get_ptr(); if (!settings) return 0; - offset = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8); + user_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8); + btn_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * user_idx; - id = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * offset; - - if (settings->uints.input_remap_ids[offset][id] > 0) - settings->uints.input_remap_ids[offset][id]--; + if (settings->uints.input_remap_ids[user_idx][btn_idx] > 0) + settings->uints.input_remap_ids[user_idx][btn_idx]--; return 0; } diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 9dd8e1fd40..44141a1b05 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -146,21 +146,17 @@ int action_right_input_desc(unsigned type, const char *label, bool wraparound) { - unsigned key_id, id, offset; - unsigned remap_id = 0; + unsigned btn_idx, user_idx; settings_t *settings = config_get_ptr(); if (!settings) return 0; - offset = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8); + user_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8); + btn_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * user_idx; - id = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * offset; - - if (settings->uints.input_remap_ids[offset][id] < RARCH_FIRST_CUSTOM_BIND) - settings->uints.input_remap_ids[offset][id]++; - - RARCH_LOG("o:%u t:%u i:%u r:%u\n", offset, type, id, remap_id); + if (settings->uints.input_remap_ids[user_idx][btn_idx] < RARCH_FIRST_CUSTOM_BIND) + settings->uints.input_remap_ids[user_idx][btn_idx]++; return 0; }