mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 00:20:01 +00:00
remap-redux part2: clean up gamepad mapper callbacks
This commit is contained in:
parent
be2c648596
commit
f7b94e5f66
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user