From 1529620c668c3c44b1575e433c594e2b3880b5b2 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 8 May 2015 17:25:55 +0200 Subject: [PATCH] Revert "improve autodetection of input gamepads" --- input/input_autodetect.c | 76 ++++++++++++++----------------------- tools/retroarch-joyconfig.c | 20 ++-------- 2 files changed, 32 insertions(+), 64 deletions(-) diff --git a/input/input_autodetect.c b/input/input_autodetect.c index 4d805c4f06..d19300b865 100644 --- a/input/input_autodetect.c +++ b/input/input_autodetect.c @@ -137,12 +137,31 @@ static void input_autoconfigure_joypad_add( RARCH_LOG("%s\n", msg); } +static int input_autoconfigure_joypad_from_conf( + config_file_t *conf, autoconfig_params_t *params) +{ + int ret = 0; + uint32_t match = 0; + + if (!conf) + return false; + + ret = input_try_autoconfigure_joypad_from_conf(conf, + params, &match); + + if (ret) + input_autoconfigure_joypad_add(conf, params); + + config_file_free(conf); + + return ret; +} + static bool input_autoconfigure_joypad_from_conf_dir( autoconfig_params_t *params) { size_t i; int ret = 0; - config_file_t *best_conf = NULL; settings_t *settings = config_get_ptr(); struct string_list *list = settings ? dir_list_new( settings->input.autoconfig_dir, "cfg", false) : NULL; @@ -153,34 +172,16 @@ static bool input_autoconfigure_joypad_from_conf_dir( for (i = 0; i < list->size; i++) { config_file_t *conf = config_file_new(list->elems[i].data); - unsigned match = 0; - ret = input_try_autoconfigure_joypad_from_conf(conf, params, &match); - if (ret) - { - if (best_conf) config_file_free(best_conf); - best_conf = conf; - if (BIT32_GET(match, AUTODETECT_MATCH_VID) && BIT32_GET(match, AUTODETECT_MATCH_PID)) - { - /* prefect match, no need to look any further */ - break; - } - } - else - { - config_file_free(conf); - } - } + ret = input_autoconfigure_joypad_from_conf(conf, params); + + if (ret == 1) + break; - if (best_conf) - { - input_autoconfigure_joypad_add(best_conf, params); - config_file_free(best_conf); - ret = 1; } string_list_free(list); - return ret != 0 ? true : false; + return ret !=0 ? true : false; } #if defined(HAVE_BUILTIN_AUTOCONFIG) @@ -189,37 +190,16 @@ static bool input_autoconfigure_joypad_from_conf_internal( { size_t i; settings_t *settings = config_get_ptr(); - int ret = 0; - config_file_t *best_conf = NULL; + bool ret = false; /* Load internal autoconfig files */ for (i = 0; input_builtin_autoconfs[i]; i++) { config_file_t *conf = config_file_new_from_string( input_builtin_autoconfs[i]); - unsigned match = 0; - ret = input_try_autoconfigure_joypad_from_conf(conf, params, &match); - if (ret) - { - if (best_conf) config_file_free(best_conf); - best_conf = conf; - if (BIT32_GET(match, AUTODETECT_MATCH_VID) && BIT32_GET(match, AUTODETECT_MATCH_PID)) - { - /* prefect match, no need to look any further */ - break; - } - } - else - { - config_file_free(best_conf); - } - } - if (best_conf != NULL) - { - input_autoconfigure_joypad_add(best_conf, params); - config_file_free(best_conf); - ret = 1; + if ((ret = input_autoconfigure_joypad_from_conf(conf, params))) + break; } if (ret || !*settings->input.autoconfig_dir) diff --git a/tools/retroarch-joyconfig.c b/tools/retroarch-joyconfig.c index 67ac1f016e..c939f204fb 100644 --- a/tools/retroarch-joyconfig.c +++ b/tools/retroarch-joyconfig.c @@ -46,8 +46,6 @@ static char *g_out_path = NULL; static char *g_auto_path = NULL; static char *g_driver = NULL; static unsigned g_meta_level = 0; -static int g_input_vid = 0; -static int g_input_pid = 0; bool rarch_main_verbosity(void) { @@ -143,19 +141,10 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, const char *joypad_name = input_joypad_name(driver, joypad); fprintf(stderr, "Using joypad: %s\n", joypad_name ? joypad_name : "Unknown"); - if (auto_conf) + if (joypad_name && auto_conf) { - if (joypad_name) - { - config_set_string(auto_conf, "input_device", joypad_name); - config_set_string(auto_conf, "input_driver", driver->ident); - } - - if (g_input_vid != 0 && g_input_pid != 0) - { - config_set_int(auto_conf, "input_vendor_id", g_input_vid); - config_set_int(auto_conf, "input_product_id", g_input_pid); - } + config_set_string(auto_conf, "input_device", joypad_name); + config_set_string(auto_conf, "input_driver", driver->ident); } int16_t initial_axes[MAX_AXES] = {0}; @@ -461,8 +450,7 @@ static void parse_input(int argc, char *argv[]) void input_config_autoconfigure_joypad(autoconfig_params_t *params) { - g_input_vid = params->vid; - g_input_pid = params->pid; + (void)params; } // Need SDL_main on OSX.