From 67a68c05958e628c57b4fa2b363fd2fe09f9d747 Mon Sep 17 00:00:00 2001 From: radius Date: Mon, 8 Feb 2016 16:06:54 -0500 Subject: [PATCH] save libretro device and analog dpad mode with remap files --- input/input_remapping.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/input/input_remapping.c b/input/input_remapping.c index 40906dfdec..c3265815b0 100644 --- a/input/input_remapping.c +++ b/input/input_remapping.c @@ -34,6 +34,7 @@ bool input_remapping_load_file(void *data, const char *path) unsigned i, j; config_file_t *conf = (config_file_t*)data; settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); if (!conf || string_is_empty(path)) return false; @@ -79,6 +80,34 @@ bool input_remapping_load_file(void *data, const char *path) settings->input.remap_ids[i][RARCH_FIRST_CUSTOM_BIND + j] = key_remap; } + + for (i = 0; i < MAX_USERS; i++) + { + char buf[64] = {0}; + snprintf(buf, sizeof(buf), "input_player%u_joypad_index", i + 1); + CONFIG_GET_INT_BASE(conf, settings, input.joypad_map[i], buf); + + snprintf(buf, sizeof(buf), "input_player%u_analog_dpad_mode", i + 1); + CONFIG_GET_INT_BASE(conf, settings, input.analog_dpad_mode[i], buf); + + if (!global->has_set.libretro_device[i]) + { + snprintf(buf, sizeof(buf), "input_libretro_device_p%u", i + 1); + CONFIG_GET_INT_BASE(conf, settings, input.libretro_device[i], buf); + } + + snprintf(buf, sizeof(buf), "input_player%u_joypad_index", i + 1); + CONFIG_GET_INT_BASE(conf, settings, input.joypad_map[i], buf); + + snprintf(buf, sizeof(buf), "input_player%u_analog_dpad_mode", i + 1); + CONFIG_GET_INT_BASE(conf, settings, input.analog_dpad_mode[i], buf); + + if (!global->has_set.libretro_device[i]) + { + snprintf(buf, sizeof(buf), "input_libretro_device_p%u", i + 1); + CONFIG_GET_INT_BASE(conf, settings, input.libretro_device[i], buf); + } + } } config_file_free(conf); @@ -134,6 +163,16 @@ bool input_remapping_save_file(const char *path) key_strings[j], '_', sizeof(key_ident[j])); config_set_int(conf, key_ident[j], settings->input.remap_ids[i][j]); } + + for (i = 0; i < MAX_USERS; i++) + { + char cfg[64] = {0}; + + snprintf(cfg, sizeof(cfg), "input_libretro_device_p%u", i + 1); + config_set_int(conf, cfg, settings->input.libretro_device[i]); + snprintf(cfg, sizeof(cfg), "input_player%u_analog_dpad_mode", i + 1); + config_set_int(conf, cfg, settings->input.analog_dpad_mode[i]); + } } ret = config_file_write(conf, remap_file);