mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 00:20:01 +00:00
remap-redux part2: wraparound
This commit is contained in:
parent
59da4b880e
commit
23331aa484
@ -547,11 +547,9 @@ static void menu_action_setting_disp_set_label_input_desc(
|
||||
const char *path,
|
||||
char *s2, size_t len2)
|
||||
{
|
||||
rarch_system_info_t *system = NULL;
|
||||
rarch_system_info_t *system = runloop_get_system_info();
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char* descriptor = NULL;
|
||||
const struct retro_keybind *auto_bind = NULL;
|
||||
const struct retro_keybind *keybind = NULL;
|
||||
|
||||
unsigned btn_idx, user_idx, remap_idx;
|
||||
|
||||
@ -564,8 +562,6 @@ static void menu_action_setting_disp_set_label_input_desc(
|
||||
remap_idx =
|
||||
settings->uints.input_remap_ids[user_idx][btn_idx];
|
||||
|
||||
system = runloop_get_system_info();
|
||||
|
||||
if (!system)
|
||||
return;
|
||||
|
||||
|
@ -93,10 +93,11 @@ static int action_left_cheat(unsigned type, const char *label,
|
||||
static int action_left_input_desc(unsigned type, const char *label,
|
||||
bool wraparound)
|
||||
{
|
||||
unsigned btn_idx, user_idx;
|
||||
rarch_system_info_t *system = runloop_get_system_info();
|
||||
settings_t *settings = config_get_ptr();
|
||||
unsigned btn_idx, user_idx, remap_idx;
|
||||
|
||||
if (!settings)
|
||||
if (!settings || !system)
|
||||
return 0;
|
||||
|
||||
user_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8);
|
||||
@ -104,6 +105,13 @@ static int action_left_input_desc(unsigned type, const char *label,
|
||||
|
||||
if (settings->uints.input_remap_ids[user_idx][btn_idx] > 0)
|
||||
settings->uints.input_remap_ids[user_idx][btn_idx]--;
|
||||
else
|
||||
settings->uints.input_remap_ids[user_idx][btn_idx] = RARCH_FIRST_CUSTOM_BIND;
|
||||
|
||||
/* skip the not used button (unless they are at the end by calling the right desc function recursively */
|
||||
remap_idx = settings->uints.input_remap_ids[user_idx][btn_idx];
|
||||
if (string_is_empty(system->input_desc_btn[user_idx][remap_idx]) && remap_idx < RARCH_FIRST_CUSTOM_BIND)
|
||||
action_left_input_desc(type, label, wraparound);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -145,23 +145,32 @@ int action_right_input_desc_kbd(unsigned type, const char *label,
|
||||
int action_right_input_desc(unsigned type, const char *label,
|
||||
bool wraparound)
|
||||
{
|
||||
|
||||
unsigned btn_idx, user_idx;
|
||||
rarch_system_info_t *system = runloop_get_system_info();
|
||||
settings_t *settings = config_get_ptr();
|
||||
unsigned btn_idx, user_idx, remap_idx;
|
||||
|
||||
if (!settings)
|
||||
if (!settings || !system)
|
||||
return 0;
|
||||
|
||||
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;
|
||||
|
||||
#if 1
|
||||
for (int i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
RARCH_LOG("[remap-debug]: user %d button %d new id %d\n", user_idx, i, settings->uints.input_remap_ids[user_idx][i]);
|
||||
#endif
|
||||
|
||||
if (settings->uints.input_remap_ids[user_idx][btn_idx] < RARCH_FIRST_CUSTOM_BIND)
|
||||
settings->uints.input_remap_ids[user_idx][btn_idx]++;
|
||||
else
|
||||
settings->uints.input_remap_ids[user_idx][btn_idx] = 0;
|
||||
|
||||
/* skip the not used button (unless they are at the end by calling the right desc function recursively */
|
||||
remap_idx = settings->uints.input_remap_ids[user_idx][btn_idx];
|
||||
if (string_is_empty(system->input_desc_btn[user_idx][remap_idx]) && remap_idx < RARCH_FIRST_CUSTOM_BIND)
|
||||
action_right_input_desc(type, label, wraparound);
|
||||
|
||||
#if 0
|
||||
int i = 0;
|
||||
RARCH_LOG("[remap-debug] new descriptor for %d: %s\n", remap_idx, system->input_desc_btn[user_idx][remap_idx]);
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
RARCH_LOG("[remap-debug]: user %d button %d new id %d\n", user_idx, i, settings->uints.input_remap_ids[user_idx][i]);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user