1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-03 08:48:42 +00:00

remap-redux part 2: cleanup keymapper code

This commit is contained in:
radius 2018-03-31 09:31:52 -05:00
parent db5f3d7a75
commit 51edf47ed2
8 changed files with 32 additions and 13 deletions

View File

@ -14,4 +14,5 @@
"*.in": "c",
"*.rh": "c"
},
"C_Cpp.dimInactiveRegions": false,
}

View File

@ -103,13 +103,14 @@ void input_mapper_poll(input_mapper_t *handle)
memset(handle->keys, 0, sizeof(handle->keys));
i = 0;
for (i = 0; i < 8; i++)
for (i = 0; i < MAX_USERS; i++)
{
for (j = 0; j < RARCH_CUSTOM_BIND_LIST_END; j++)
{
if (j < RETROK_LAST)
{
if (input_state(i, RETRO_DEVICE_JOYPAD, 0, j) && settings->uints.input_keymapper_ids[i][j] != RETROK_UNKNOWN)
if (input_state(i, RETRO_DEVICE_JOYPAD, 0, j) &&
settings->uints.input_keymapper_ids[i][j] != RETROK_UNKNOWN)
{
MAPPER_SET_KEY (handle,
settings->uints.input_keymapper_ids[i][j]);

View File

@ -194,11 +194,16 @@ bool input_remapping_save_file(const char *path)
else
config_unset(conf,key_ident[j]);
if (settings->uints.input_keymapper_ids[i][j] != RETROK_UNKNOWN)
config_set_int(conf, keymapper_ident[j],
settings->uints.input_keymapper_ids[i][j]);
}
else
{
if(settings->uints.input_remap_ids[i][j] != j - RARCH_FIRST_CUSTOM_BIND)
config_set_int(conf, key_ident[j], settings->uints.input_remap_ids[i][j]);
config_set_int(conf, key_ident[j],
settings->uints.input_remap_ids[i][j]);
else
config_unset(conf,key_ident[j]);
}

View File

@ -640,15 +640,16 @@ static void menu_action_setting_disp_set_label_input_desc_kbd(
if (!settings)
return;
offset = type / ((MENU_SETTINGS_INPUT_DESC_KBD_END - (MENU_SETTINGS_INPUT_DESC_KBD_END - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN))) - 1;
offset = type / ((MENU_SETTINGS_INPUT_DESC_KBD_END -
(MENU_SETTINGS_INPUT_DESC_KBD_END -
MENU_SETTINGS_INPUT_DESC_KBD_BEGIN))) - 1;
id = (type / (offset + 1)) - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN;
remap_id =
settings->uints.input_keymapper_ids[offset][id];
RARCH_LOG("o: %d, type: %d, remap_id: %d\n", offset, type, remap_id);
for (key_id = 0; key_id < MENU_SETTINGS_INPUT_DESC_KBD_END - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN; key_id++)
for (key_id = 0; key_id < MENU_SETTINGS_INPUT_DESC_KBD_END -
MENU_SETTINGS_INPUT_DESC_KBD_BEGIN; key_id++)
{
if(remap_id == key_descriptors[key_id].key)
break;

View File

@ -119,13 +119,17 @@ static int action_left_input_desc_kbd(unsigned type, const char *label,
if (!settings)
return 0;
offset = type / ((MENU_SETTINGS_INPUT_DESC_KBD_END - (MENU_SETTINGS_INPUT_DESC_KBD_END - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN))) - 1;
offset = type / ((MENU_SETTINGS_INPUT_DESC_KBD_END -
(MENU_SETTINGS_INPUT_DESC_KBD_END -
MENU_SETTINGS_INPUT_DESC_KBD_BEGIN))) - 1;
id = (type / (offset + 1)) - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN;
remap_id =
settings->uints.input_keymapper_ids[offset][id];
for (key_id = 0; key_id < MENU_SETTINGS_INPUT_DESC_KBD_END - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN; key_id++)
for (key_id = 0; key_id < MENU_SETTINGS_INPUT_DESC_KBD_END -
MENU_SETTINGS_INPUT_DESC_KBD_BEGIN; key_id++)
{
if(remap_id == key_descriptors[key_id].key)
break;

View File

@ -113,13 +113,17 @@ int action_right_input_desc_kbd(unsigned type, const char *label,
if (!settings)
return 0;
offset = type / ((MENU_SETTINGS_INPUT_DESC_KBD_END - (MENU_SETTINGS_INPUT_DESC_KBD_END - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN))) - 1;
offset = type / ((MENU_SETTINGS_INPUT_DESC_KBD_END -
(MENU_SETTINGS_INPUT_DESC_KBD_END -
MENU_SETTINGS_INPUT_DESC_KBD_BEGIN))) - 1;
id = (type / (offset + 1)) - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN;
remap_id =
settings->uints.input_keymapper_ids[offset][id];
for (key_id = 0; key_id < MENU_SETTINGS_INPUT_DESC_KBD_END - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN; key_id++)
for (key_id = 0; key_id < MENU_SETTINGS_INPUT_DESC_KBD_END -
MENU_SETTINGS_INPUT_DESC_KBD_BEGIN; key_id++)
{
if(remap_id == key_descriptors[key_id].key)
break;

View File

@ -439,7 +439,10 @@ static int action_bind_sublabel_remap_sublabel(
if (!settings)
return 0;
offset = type / ((MENU_SETTINGS_INPUT_DESC_KBD_END - (MENU_SETTINGS_INPUT_DESC_KBD_END - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN))) - 1;
offset = type / ((MENU_SETTINGS_INPUT_DESC_KBD_END -
(MENU_SETTINGS_INPUT_DESC_KBD_END -
MENU_SETTINGS_INPUT_DESC_KBD_BEGIN))) - 1;
snprintf(s, len, "User #%d: %s", offset + 1,
input_config_get_device_display_name(offset) ?
input_config_get_device_display_name(offset) :

View File

@ -3276,7 +3276,7 @@ static int menu_displaylist_parse_options_remappings(
settings_t *settings = config_get_ptr();
unsigned device;
for (int i = 0; i < 8; i++)
for (int i = 0; i < MAX_USERS; i++)
{
device = settings->uints.input_libretro_device[i];
device &= RETRO_DEVICE_MASK;