mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 05:43:34 +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;
|
const struct retro_keybind *keybind = NULL;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
unsigned key_id, id, offset;
|
unsigned btn_idx, user_idx;
|
||||||
unsigned remap_id = 0;
|
unsigned remap_id = 0;
|
||||||
|
|
||||||
if (!settings)
|
if (!settings)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
remap_id =
|
remap_id =
|
||||||
settings->uints.input_remap_ids[offset][id];
|
settings->uints.input_remap_ids[user_idx][btn_idx];
|
||||||
|
|
||||||
system = runloop_get_system_info();
|
system = runloop_get_system_info();
|
||||||
|
|
||||||
if (!system)
|
if (!system)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
descriptor = system->input_desc_btn[offset][remap_id];
|
descriptor = system->input_desc_btn[user_idx][remap_id];
|
||||||
|
|
||||||
if (!string_is_empty(descriptor))
|
if (!string_is_empty(descriptor))
|
||||||
strlcpy(s, descriptor, len);
|
strlcpy(s, descriptor, len);
|
||||||
|
@ -90,24 +90,20 @@ static int action_left_cheat(unsigned type, const char *label,
|
|||||||
wraparound);
|
wraparound);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fix-me: incomplete, lacks error checking */
|
|
||||||
static int action_left_input_desc(unsigned type, const char *label,
|
static int action_left_input_desc(unsigned type, const char *label,
|
||||||
bool wraparound)
|
bool wraparound)
|
||||||
{
|
{
|
||||||
|
unsigned btn_idx, user_idx;
|
||||||
unsigned key_id, id, offset;
|
|
||||||
unsigned remap_id = 0;
|
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
if (!settings)
|
if (!settings)
|
||||||
return 0;
|
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[user_idx][btn_idx] > 0)
|
||||||
|
settings->uints.input_remap_ids[user_idx][btn_idx]--;
|
||||||
if (settings->uints.input_remap_ids[offset][id] > 0)
|
|
||||||
settings->uints.input_remap_ids[offset][id]--;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -146,21 +146,17 @@ int action_right_input_desc(unsigned type, const char *label,
|
|||||||
bool wraparound)
|
bool wraparound)
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned key_id, id, offset;
|
unsigned btn_idx, user_idx;
|
||||||
unsigned remap_id = 0;
|
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
if (!settings)
|
if (!settings)
|
||||||
return 0;
|
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[user_idx][btn_idx] < RARCH_FIRST_CUSTOM_BIND)
|
||||||
|
settings->uints.input_remap_ids[user_idx][btn_idx]++;
|
||||||
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);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user