diff --git a/configuration.c b/configuration.c index 4439a078c3..0f8375761b 100644 --- a/configuration.c +++ b/configuration.c @@ -1131,11 +1131,9 @@ static void config_set_defaults(void) for (i = 0; i < MAX_USERS; i++) { - global_t *global = global_get_ptr(); - settings->input.joypad_map[i] = i; settings->input.analog_dpad_mode[i] = ANALOG_DPAD_NONE; - if (!global->has_set.libretro_device[i]) + if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &i)) settings->input.libretro_device[i] = RETRO_DEVICE_JOYPAD; } @@ -1874,7 +1872,7 @@ static bool config_load_file(const char *path, bool set_defaults, 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]) + if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_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); diff --git a/input/input_remapping.c b/input/input_remapping.c index 93cd7bf43c..6624e879d3 100644 --- a/input/input_remapping.c +++ b/input/input_remapping.c @@ -21,6 +21,7 @@ #include "input_remapping.h" #include "../configuration.h" #include "../paths.h" +#include "../retroarch.h" #include "../runloop.h" /** @@ -36,7 +37,6 @@ 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; @@ -88,7 +88,7 @@ bool input_remapping_load_file(void *data, const char *path) 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]) + if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_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); diff --git a/retroarch.c b/retroarch.c index 60f1112ba5..8b8aa1b270 100644 --- a/retroarch.c +++ b/retroarch.c @@ -393,9 +393,11 @@ static void retroarch_print_help(const char *arg0) static void retroarch_parse_input(int argc, char *argv[]) { const char *optstring = NULL; - global_t *global = global_get_ptr(); - settings_t *settings = config_get_ptr(); bool explicit_menu = false; + settings_t *settings = config_get_ptr(); +#ifdef HAVE_NETWORKING + global_t *global = global_get_ptr(); +#endif const struct option opts[] = { #ifdef HAVE_DYNAMIC @@ -519,6 +521,7 @@ static void retroarch_parse_input(int argc, char *argv[]) case 'd': { + unsigned new_port; unsigned id = 0; struct string_list *list = string_split(optarg, ":"); @@ -537,12 +540,17 @@ static void retroarch_parse_input(int argc, char *argv[]) retroarch_print_help(argv[0]); retroarch_fail(1, "retroarch_parse_input()"); } - settings->input.libretro_device[port - 1] = id; - global->has_set.libretro_device[port - 1] = true; + new_port = port -1; + settings->input.libretro_device[new_port] = id; + + retroarch_override_setting_set( + RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &new_port); break; } case 'A': + { + unsigned new_port; port = strtol(optarg, NULL, 0); if (port < 1 || port > MAX_USERS) { @@ -550,8 +558,12 @@ static void retroarch_parse_input(int argc, char *argv[]) retroarch_print_help(argv[0]); retroarch_fail(1, "retroarch_parse_input()"); } - settings->input.libretro_device[port - 1] = RETRO_DEVICE_ANALOG; - global->has_set.libretro_device[port - 1] = true; + new_port = port - 1; + + settings->input.libretro_device[new_port] = RETRO_DEVICE_ANALOG; + retroarch_override_setting_set( + RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &new_port); + } break; case 's': @@ -577,16 +589,21 @@ static void retroarch_parse_input(int argc, char *argv[]) break; case 'N': - port = strtol(optarg, NULL, 0); - if (port < 1 || port > MAX_USERS) { - RARCH_ERR("%s\n", - msg_hash_to_str(MSG_VALUE_DISCONNECT_DEVICE_FROM_A_VALID_PORT)); - retroarch_print_help(argv[0]); - retroarch_fail(1, "retroarch_parse_input()"); + unsigned new_port; + port = strtol(optarg, NULL, 0); + if (port < 1 || port > MAX_USERS) + { + RARCH_ERR("%s\n", + msg_hash_to_str(MSG_VALUE_DISCONNECT_DEVICE_FROM_A_VALID_PORT)); + retroarch_print_help(argv[0]); + retroarch_fail(1, "retroarch_parse_input()"); + } + new_port = port - 1; + settings->input.libretro_device[port - 1] = RETRO_DEVICE_NONE; + retroarch_override_setting_set( + RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &new_port); } - settings->input.libretro_device[port - 1] = RETRO_DEVICE_NONE; - global->has_set.libretro_device[port - 1] = true; break; case 'c': diff --git a/runloop.h b/runloop.h index f44b070a24..b70d925d5f 100644 --- a/runloop.h +++ b/runloop.h @@ -136,11 +136,6 @@ typedef struct rarch_resolution typedef struct global { - struct - { - bool libretro_device[MAX_USERS]; - } has_set; - #ifdef HAVE_NETWORKING /* Netplay. */ struct