From 20ed6eb90ae6b489738509fbcea4b00d301ee2c8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 25 Apr 2017 16:04:28 +0200 Subject: [PATCH] Start using input_config_get_device_name --- input/drivers/android_input.c | 10 +++------- input/drivers_joypad/android_joypad.c | 5 ++--- input/drivers_joypad/dinput_joypad.c | 5 ++--- input/drivers_joypad/qnx_joypad.c | 3 +-- input/drivers_joypad/xdk_joypad.c | 5 ++--- menu/menu_setting.c | 8 ++++---- 6 files changed, 14 insertions(+), 22 deletions(-) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index c227f41888..85378de615 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -1129,15 +1129,11 @@ static void handle_hotplug(android_input_t *android, productId)) input_config_set_device_name(*port, name_buf); - if (!string_is_empty(name_buf)) - { - settings_t *settings = config_get_ptr(); - strlcpy(settings->input.device_names[*port], - name_buf, sizeof(settings->input.device_names[*port])); - } + input_config_set_device_name(*port, name_buf); - android->pad_states[android->pads_connected].id = id; + android->pad_states[android->pads_connected].id = id; android->pad_states[android->pads_connected].port = *port; + strlcpy(android->pad_states[*port].name, name_buf, sizeof(android->pad_states[*port].name)); diff --git a/input/drivers_joypad/android_joypad.c b/input/drivers_joypad/android_joypad.c index 55e4b15f84..e76ec13a9a 100644 --- a/input/drivers_joypad/android_joypad.c +++ b/input/drivers_joypad/android_joypad.c @@ -15,13 +15,12 @@ * If not, see . */ -#include "../../configuration.h" +#include "../input_config.h" #include "../drivers_keyboard/keyboard_event_android.h" static const char *android_joypad_name(unsigned pad) { - settings_t *settings = config_get_ptr(); - return settings ? settings->input.device_names[pad] : NULL; + return input_config_get_device_name(pad); } static bool android_joypad_init(void *data) diff --git a/input/drivers_joypad/dinput_joypad.c b/input/drivers_joypad/dinput_joypad.c index 22c7b8458e..f0b2d126f9 100644 --- a/input/drivers_joypad/dinput_joypad.c +++ b/input/drivers_joypad/dinput_joypad.c @@ -32,7 +32,6 @@ #include "../input_config.h" #include "../input_joypad_driver.h" #include "../input_keymaps.h" -#include "../../configuration.h" #include "../../verbosity.h" struct dinput_joypad @@ -66,7 +65,6 @@ extern LPDIRECTINPUT8 g_dinput_ctx; static void dinput_joypad_destroy(void) { unsigned i; - settings_t *settings = config_get_ptr(); for (i = 0; i < MAX_USERS; i++) { @@ -80,7 +78,8 @@ static void dinput_joypad_destroy(void) g_pads[i].joy_name = NULL; free(g_pads[i].joy_friendly_name); g_pads[i].joy_friendly_name = NULL; - *settings->input.device_names[i] = '\0'; + + input_config_clear_device_name(i); } g_joypad_cnt = 0; diff --git a/input/drivers_joypad/qnx_joypad.c b/input/drivers_joypad/qnx_joypad.c index 53df4dcc29..7279779e1e 100644 --- a/input/drivers_joypad/qnx_joypad.c +++ b/input/drivers_joypad/qnx_joypad.c @@ -20,8 +20,7 @@ static const char *qnx_joypad_name(unsigned pad) { - settings_t *settings = config_get_ptr(); - return settings ? settings->input.device_names[pad] : NULL; + return input_config_get_device_name(pad); } static bool qnx_joypad_init(void *data) diff --git a/input/drivers_joypad/xdk_joypad.c b/input/drivers_joypad/xdk_joypad.c index 08b46b0884..0ccf538d1b 100644 --- a/input/drivers_joypad/xdk_joypad.c +++ b/input/drivers_joypad/xdk_joypad.c @@ -16,7 +16,7 @@ #include -#include "../../configuration.h" +#include "../input_config.h" #include "../../tasks/tasks_internal.h" static uint64_t pad_state[MAX_PADS]; @@ -38,8 +38,7 @@ static const char* const XBOX_CONTROLLER_NAMES[4] = static const char *xdk_joypad_name(unsigned pad) { - settings_t *settings = config_get_ptr(); - return settings ? settings->input.device_names[pad] : NULL; + return input_config_get_device_name(pad); } static void xdk_joypad_autodetect_add(unsigned autoconf_pad) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 0e7f120c76..30ba390b69 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1304,17 +1304,16 @@ static int setting_action_ok_bind_all(void *data, bool wraparound) static int setting_action_ok_bind_all_save_autoconfig(void *data, bool wraparound) { unsigned index_offset; - settings_t *settings = config_get_ptr(); rarch_setting_t *setting = (rarch_setting_t*)data; const char *name = NULL; (void)wraparound; - if (!settings || !setting) + if (!setting) return -1; index_offset = setting->index_offset; - name = settings->input.device_names[index_offset]; + name = input_config_get_device_name(index_offset); if(!string_is_empty(name) && config_save_autoconf_profile(name, index_offset)) runloop_msg_queue_push( @@ -1323,6 +1322,7 @@ static int setting_action_ok_bind_all_save_autoconfig(void *data, bool wraparoun runloop_msg_queue_push( msg_hash_to_str(MSG_AUTOCONFIG_FILE_ERROR_SAVING), 1, 100, true); + return 0; } @@ -1424,7 +1424,7 @@ static void get_string_representation_bind_device(void * data, char *s, if (map < settings->input.max_users) { - const char *device_name = settings->input.device_names[map]; + const char *device_name = input_config_get_device_name(map); if (!string_is_empty(device_name)) snprintf(s, len,