From b717828cf0465df9a49a0370834319c1ded7da66 Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 16 Jul 2015 01:45:49 -0500 Subject: [PATCH 1/3] fix setting and clearing system directory when using content dir --- command_event.c | 4 ++-- configuration.c | 4 ++++ configuration.h | 1 + dynamic.c | 7 +++++++ frontend/frontend.c | 4 ++-- retroarch.c | 21 +++++++++++---------- 6 files changed, 27 insertions(+), 14 deletions(-) diff --git a/command_event.c b/command_event.c index 184ed3ed5b..813c7e36e0 100644 --- a/command_event.c +++ b/command_event.c @@ -548,8 +548,8 @@ static void event_deinit_core(bool reinit) strlcpy(global->savestate_dir,orig_savestate_dir,sizeof(global->savestate_dir)); /* restore system directory if it was set to */ - if(orig_system_dir_empty) - strlcpy(settings->system_directory,"",sizeof(settings->system_directory)); + if(settings->system_in_content_dir) + settings->system_directory[0] = '\0'; /* auto overrides: reload the original config */ if(global->overrides_active) diff --git a/configuration.c b/configuration.c index 96a3ef2879..f74903a087 100644 --- a/configuration.c +++ b/configuration.c @@ -1714,10 +1714,14 @@ static bool config_load_file(const char *path, bool set_defaults) { RARCH_WARN("system_directory is not set in config. Assuming system directory is same folder as game: \"%s\".\n", settings->system_directory); + settings->system_in_content_dir = true; } if (!strcmp(settings->system_directory, "default")) + { *settings->system_directory = '\0'; + settings->system_in_content_dir = true; + } config_read_keybinds_conf(conf); diff --git a/configuration.h b/configuration.h index bcaa6dc5cc..08f14ddd06 100644 --- a/configuration.h +++ b/configuration.h @@ -303,6 +303,7 @@ typedef struct settings char resampler_directory[PATH_MAX_LENGTH]; char screenshot_directory[PATH_MAX_LENGTH]; char system_directory[PATH_MAX_LENGTH]; + bool system_in_content_dir; char extraction_directory[PATH_MAX_LENGTH]; char playlist_directory[PATH_MAX_LENGTH]; diff --git a/dynamic.c b/dynamic.c index 946f76e170..cb1d3a9fbc 100644 --- a/dynamic.c +++ b/dynamic.c @@ -751,8 +751,15 @@ bool rarch_environment_cb(unsigned cmd, void *data) break; case RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY: + if (!settings->system_directory || settings->system_directory[0] == '\0') + { + RARCH_WARN("SYSTEM DIR is empty, fill assume CONTENT DIR %s\n",global->fullpath); + fill_pathname_basedir(settings->system_directory, global->fullpath, + sizeof(settings->system_directory)); + } *(const char**)data = *settings->system_directory ? settings->system_directory : NULL; + RARCH_LOG("Environ SYSTEM_DIRECTORY: \"%s\".\n", settings->system_directory); break; diff --git a/frontend/frontend.c b/frontend/frontend.c index 09704c8ef0..462312b346 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -48,8 +48,8 @@ void main_exit_save_config(void) strlcpy(global->savestate_dir,orig_savestate_dir,sizeof(global->savestate_dir)); /* restore system directory if it was set to */ - if(orig_system_dir_empty) - strlcpy(settings->system_directory,"",sizeof(settings->system_directory)); + if(settings->system_in_content_dir) + settings->system_directory[0] = '\0'; /* Save last core-specific config to the default config location, * needed on consoles for core switching and reusing last good diff --git a/retroarch.c b/retroarch.c index b2ec0b47a0..a967c43d0c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -61,7 +61,6 @@ char orig_savestate_dir[PATH_MAX_LENGTH]; char orig_savefile_dir[PATH_MAX_LENGTH]; -bool orig_system_dir_empty = false; /* Descriptive names for options without short variant. Please keep the name in sync with the option name. Order does not matter. */ @@ -314,11 +313,12 @@ static void set_special_paths(char **argv, unsigned num_content) /* If this is already set, * do not overwrite it as this was initialized before in * a menu or otherwise. */ - if (settings->system_directory[0] == '\0') - orig_system_dir_empty = true; - if (!*settings->system_directory) + if (!settings->system_directory || settings->system_directory[0] == '\0') + { + RARCH_WARN("SYSTEM DIR is empty, assume CONTENT DIR %s\n",argv[0]); fill_pathname_basedir(settings->system_directory, argv[0], sizeof(settings->system_directory)); + } } void set_paths_redirect(const char *path) @@ -429,12 +429,13 @@ void rarch_set_paths(const char *path) /* If this is already set, do not overwrite it * as this was initialized before in a menu or otherwise. */ - if (*settings->system_directory) - return; - if (settings->system_directory[0] == '\0') - orig_system_dir_empty = true; - fill_pathname_basedir(settings->system_directory, path, - sizeof(settings->system_directory)); + if (!settings->system_directory || settings->system_directory[0] == '\0') + { + RARCH_WARN("SYSTEM DIR is empty, fill assume CONTENT DIR %s\n",path); + fill_pathname_basedir(settings->system_directory, path, + sizeof(settings->system_directory)); + } + } From ca682d38eb5887f03acf706643663c284a99f941 Mon Sep 17 00:00:00 2001 From: fr500 Date: Thu, 16 Jul 2015 03:22:28 -0400 Subject: [PATCH 2/3] better shield portable hack --- input/drivers/android_input.c | 24 +++++++++++++++--------- input/input_autodetect.c | 7 ++++--- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 6f2188a4df..b206c67c9a 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -629,6 +629,21 @@ static void handle_hotplug(android_input_t *android, else if (strstr(device_name, "SideWinder")) strlcpy(name_buf, "SideWinder Classic", sizeof(name_buf)); } + else if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.01")) + { + /* Built-in shield contrlleris always user 1. FIXME: This is kinda ugly. + * We really need to find a way to detect useless input devices + * like gpio-keys in a general way. + */ + *port = 0; + strlcpy(name_buf, device_name, sizeof(name_buf)); + } + else if (strstr(device_name, "Virtual") || strstr(device_name, "gpio") && strstr(android->pad_states[0].name,"NVIDIA Corporation NVIDIA Controller v01.01")) + { + /* If built-in shield controller is detected bind the virtual and gpio devices to the same port*/ + *port = 0; + strlcpy(name_buf, "NVIDIA Corporation NVIDIA Controller v01.01", sizeof(name_buf)); + } else if ( strstr(device_name, "PLAYSTATION(R)3") || strstr(device_name, "Dualshock3") || @@ -637,15 +652,6 @@ static void handle_hotplug(android_input_t *android, strlcpy(name_buf, "PlayStation3", sizeof(name_buf)); else if (strstr(device_name, "MOGA")) strlcpy(name_buf, "Moga IME", sizeof(name_buf)); - else if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.01")) - { - /* Shield is always user 1. FIXME: This is kinda ugly. - * We really need to find a way to detect useless input devices - * like gpio-keys in a general way. - */ - *port = 0; - strlcpy(name_buf, device_name, sizeof(name_buf)); - } else if (device_name[0] != '\0') strlcpy(name_buf, device_name, sizeof(name_buf)); diff --git a/input/input_autodetect.c b/input/input_autodetect.c index c0f4a06b53..5b18919395 100644 --- a/input/input_autodetect.c +++ b/input/input_autodetect.c @@ -120,7 +120,7 @@ static void input_autoconfigure_joypad_add( /* This will be the case if input driver is reinitialized. * No reason to spam autoconfigure messages every time. */ bool block_osd_spam = settings && - settings->input.autoconfigured[params->idx] && *params->name; + settings->input.autoconfigured[params->idx] && *params->name; if (!settings) return; @@ -136,8 +136,9 @@ static void input_autoconfigure_joypad_add( snprintf(msg, sizeof(msg), "%s configured in port #%u.", params->name, params->idx); - if (!block_osd_spam) - rarch_main_msg_queue_push(msg, 0, 60, false); + if (!block_osd_spam) + rarch_main_msg_queue_push(msg, 0, 60, false); + RARCH_LOG("%s\n", msg); } From 2a1f2b81c213a40f4c84fe6dec59d026cbc28bed Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 16 Jul 2015 02:22:48 -0500 Subject: [PATCH 3/3] disable per-core states with savestates --- retroarch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroarch.c b/retroarch.c index a967c43d0c..7ece42289c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -355,7 +355,7 @@ void set_paths_redirect(const char *path) } /* per-core states: append the library_name to the save location */ - if (settings->sort_savestates_enable) + if (settings->sort_savestates_enable && global->savefile_dir[0] != '\0') { strlcpy(orig_savestate_dir, global->savestate_dir,