mirror of
https://github.com/libretro/RetroArch.git
synced 2025-04-02 10:51:52 -04:00
Cleanup input_remapping_load_file/input_remapping_save_file - none
of these huge char arrays were needed, wrong size being passed to snprintf, fill_pathname_join, k loop variable unneeded, etc.
This commit is contained in:
parent
d9cacc0b8c
commit
0087be2a53
1 changed files with 38 additions and 35 deletions
|
@ -4523,7 +4523,7 @@ bool config_replace(bool config_replace_save_on_exit, char *path)
|
||||||
**/
|
**/
|
||||||
bool input_remapping_load_file(void *data, const char *path)
|
bool input_remapping_load_file(void *data, const char *path)
|
||||||
{
|
{
|
||||||
unsigned i, j, k;
|
unsigned i, j;
|
||||||
config_file_t *conf = (config_file_t*)data;
|
config_file_t *conf = (config_file_t*)data;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
global_t *global = global_get_ptr();
|
global_t *global = global_get_ptr();
|
||||||
|
@ -4543,9 +4543,6 @@ bool input_remapping_load_file(void *data, const char *path)
|
||||||
for (i = 0; i < MAX_USERS; i++)
|
for (i = 0; i < MAX_USERS; i++)
|
||||||
{
|
{
|
||||||
char s1[32], s2[32], s3[32];
|
char s1[32], s2[32], s3[32];
|
||||||
char btn_ident[RARCH_FIRST_CUSTOM_BIND][128] = {{0}};
|
|
||||||
char key_ident[RARCH_FIRST_CUSTOM_BIND][128] = {{0}};
|
|
||||||
char stk_ident[8][128] = {{0}};
|
|
||||||
|
|
||||||
old_analog_dpad_mode[i] = settings->uints.input_analog_dpad_mode[i];
|
old_analog_dpad_mode[i] = settings->uints.input_analog_dpad_mode[i];
|
||||||
old_libretro_device[i] = settings->uints.input_libretro_device[i];
|
old_libretro_device[i] = settings->uints.input_libretro_device[i];
|
||||||
|
@ -4566,13 +4563,17 @@ bool input_remapping_load_file(void *data, const char *path)
|
||||||
{
|
{
|
||||||
int btn_remap = -1;
|
int btn_remap = -1;
|
||||||
int key_remap = -1;
|
int key_remap = -1;
|
||||||
|
char btn_ident[128];
|
||||||
|
char key_ident[128];
|
||||||
|
|
||||||
fill_pathname_join_delim(btn_ident[j], s1,
|
btn_ident[0] = key_ident[0] = '\0';
|
||||||
key_string, '_', sizeof(btn_ident[j]));
|
|
||||||
fill_pathname_join_delim(key_ident[j], s2,
|
|
||||||
key_string, '_', sizeof(btn_ident[j]));
|
|
||||||
|
|
||||||
if (config_get_int(conf, btn_ident[j], &btn_remap))
|
fill_pathname_join_delim(btn_ident, s1,
|
||||||
|
key_string, '_', sizeof(btn_ident));
|
||||||
|
fill_pathname_join_delim(key_ident, s2,
|
||||||
|
key_string, '_', sizeof(key_ident));
|
||||||
|
|
||||||
|
if (config_get_int(conf, btn_ident, &btn_remap))
|
||||||
{
|
{
|
||||||
if (btn_remap == -1)
|
if (btn_remap == -1)
|
||||||
btn_remap = RARCH_UNMAPPED;
|
btn_remap = RARCH_UNMAPPED;
|
||||||
|
@ -4581,7 +4582,7 @@ bool input_remapping_load_file(void *data, const char *path)
|
||||||
settings->uints.input_remap_ids[i][j], btn_remap);
|
settings->uints.input_remap_ids[i][j], btn_remap);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config_get_int(conf, key_ident[j], &key_remap))
|
if (!config_get_int(conf, key_ident, &key_remap))
|
||||||
key_remap = RETROK_UNKNOWN;
|
key_remap = RETROK_UNKNOWN;
|
||||||
|
|
||||||
configuration_set_uint(settings,
|
configuration_set_uint(settings,
|
||||||
|
@ -4589,19 +4590,21 @@ bool input_remapping_load_file(void *data, const char *path)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
char stk_ident[128];
|
||||||
int stk_remap = -1;
|
int stk_remap = -1;
|
||||||
k = j - RARCH_FIRST_CUSTOM_BIND;
|
|
||||||
|
|
||||||
fill_pathname_join_delim(stk_ident[k], s3,
|
stk_ident[0] = '\0';
|
||||||
key_string, '$', sizeof(stk_ident[k]));
|
|
||||||
|
|
||||||
snprintf(stk_ident[k],
|
fill_pathname_join_delim(stk_ident, s3,
|
||||||
sizeof(stk_ident[k]),
|
key_string, '$', sizeof(stk_ident));
|
||||||
|
|
||||||
|
snprintf(stk_ident,
|
||||||
|
sizeof(stk_ident),
|
||||||
"%s_%s",
|
"%s_%s",
|
||||||
s3,
|
s3,
|
||||||
key_string);
|
key_string);
|
||||||
|
|
||||||
if (config_get_int(conf, stk_ident[k], &stk_remap))
|
if (config_get_int(conf, stk_ident, &stk_remap))
|
||||||
{
|
{
|
||||||
if (stk_remap == -1)
|
if (stk_remap == -1)
|
||||||
stk_remap = RARCH_UNMAPPED;
|
stk_remap = RARCH_UNMAPPED;
|
||||||
|
@ -4633,7 +4636,7 @@ bool input_remapping_load_file(void *data, const char *path)
|
||||||
bool input_remapping_save_file(const char *path)
|
bool input_remapping_save_file(const char *path)
|
||||||
{
|
{
|
||||||
bool ret;
|
bool ret;
|
||||||
unsigned i, j, k;
|
unsigned i, j;
|
||||||
char buf[PATH_MAX_LENGTH];
|
char buf[PATH_MAX_LENGTH];
|
||||||
char remap_file[PATH_MAX_LENGTH];
|
char remap_file[PATH_MAX_LENGTH];
|
||||||
char key_strings[RARCH_FIRST_CUSTOM_BIND + 8][8] = {
|
char key_strings[RARCH_FIRST_CUSTOM_BIND + 8][8] = {
|
||||||
|
@ -4661,9 +4664,6 @@ bool input_remapping_save_file(const char *path)
|
||||||
for (i = 0; i < max_users; i++)
|
for (i = 0; i < max_users; i++)
|
||||||
{
|
{
|
||||||
char s1[32], s2[32], s3[32];
|
char s1[32], s2[32], s3[32];
|
||||||
char btn_ident[RARCH_FIRST_CUSTOM_BIND][128] = {{0}};
|
|
||||||
char key_ident[RARCH_FIRST_CUSTOM_BIND][128] = {{0}};
|
|
||||||
char stk_ident[8][128] = {{0}};
|
|
||||||
|
|
||||||
s1[0] = '\0';
|
s1[0] = '\0';
|
||||||
s2[0] = '\0';
|
s2[0] = '\0';
|
||||||
|
@ -4681,37 +4681,40 @@ bool input_remapping_save_file(const char *path)
|
||||||
|
|
||||||
if (j < RARCH_FIRST_CUSTOM_BIND)
|
if (j < RARCH_FIRST_CUSTOM_BIND)
|
||||||
{
|
{
|
||||||
fill_pathname_join_delim(btn_ident[j], s1,
|
char btn_ident[128], key_ident[128];
|
||||||
key_string, '_', sizeof(btn_ident[j]));
|
btn_ident[0] = key_ident[0] = '\0';
|
||||||
fill_pathname_join_delim(key_ident[j], s2,
|
fill_pathname_join_delim(btn_ident, s1,
|
||||||
key_string, '_', sizeof(btn_ident[j]));
|
key_string, '_', sizeof(btn_ident));
|
||||||
|
fill_pathname_join_delim(key_ident, s2,
|
||||||
|
key_string, '_', sizeof(key_ident));
|
||||||
|
|
||||||
/* only save values that have been modified */
|
/* only save values that have been modified */
|
||||||
if (remap_id != j && remap_id != RARCH_UNMAPPED)
|
if (remap_id != j && remap_id != RARCH_UNMAPPED)
|
||||||
config_set_int(conf, btn_ident[j],
|
config_set_int(conf, btn_ident,
|
||||||
settings->uints.input_remap_ids[i][j]);
|
settings->uints.input_remap_ids[i][j]);
|
||||||
else if (remap_id != j && remap_id == RARCH_UNMAPPED)
|
else if (remap_id != j && remap_id == RARCH_UNMAPPED)
|
||||||
config_set_int(conf, btn_ident[j], -1);
|
config_set_int(conf, btn_ident, -1);
|
||||||
else
|
else
|
||||||
config_unset(conf, btn_ident[j]);
|
config_unset(conf, btn_ident);
|
||||||
|
|
||||||
if (keymap_id != RETROK_UNKNOWN)
|
if (keymap_id != RETROK_UNKNOWN)
|
||||||
config_set_int(conf, key_ident[j],
|
config_set_int(conf, key_ident,
|
||||||
settings->uints.input_keymapper_ids[i][j]);
|
settings->uints.input_keymapper_ids[i][j]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
k = j - RARCH_FIRST_CUSTOM_BIND;
|
char stk_ident[128];
|
||||||
fill_pathname_join_delim(stk_ident[k], s3,
|
stk_ident[0] = '\0';
|
||||||
key_string, '_', sizeof(stk_ident[k]));
|
fill_pathname_join_delim(stk_ident, s3,
|
||||||
|
key_string, '_', sizeof(stk_ident));
|
||||||
if (remap_id != j && remap_id != RARCH_UNMAPPED)
|
if (remap_id != j && remap_id != RARCH_UNMAPPED)
|
||||||
config_set_int(conf, stk_ident[k],
|
config_set_int(conf, stk_ident,
|
||||||
settings->uints.input_remap_ids[i][j]);
|
settings->uints.input_remap_ids[i][j]);
|
||||||
else if (remap_id != j && remap_id == RARCH_UNMAPPED)
|
else if (remap_id != j && remap_id == RARCH_UNMAPPED)
|
||||||
config_set_int(conf, stk_ident[k],
|
config_set_int(conf, stk_ident,
|
||||||
-1);
|
-1);
|
||||||
else
|
else
|
||||||
config_unset(conf, stk_ident[k]);
|
config_unset(conf, stk_ident);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue