Android: Fix handling of libretro_path/libretro_directory.

This commit is contained in:
Themaister 2014-06-16 21:50:29 +02:00
parent a392cd9ebd
commit 5530de0fb7
4 changed files with 14 additions and 6 deletions

View File

@ -215,7 +215,7 @@ public final class MainMenuFragment extends PreferenceListFragment implements On
MainMenuFragment.startRetroActivity(
retro,
null,
prefs.getString("libretro_path", ctx.getApplicationInfo().dataDir + "/cores"),
prefs.getString("libretro_path", ctx.getApplicationInfo().dataDir + "/cores/"),
UserPreferences.getDefaultConfigPath(ctx),
Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD),
ctx.getApplicationInfo().dataDir);

View File

@ -42,17 +42,18 @@ public final class UserPreferences
// Native library directory and data directory for this front-end.
final String nativeLibraryDir = ctx.getApplicationInfo().nativeLibraryDir;
final String dataDir = ctx.getApplicationInfo().dataDir;
final String coreDir = dataDir + "/cores/";
// Get libretro name and path
final SharedPreferences prefs = getPreferences(ctx);
final String libretro_path = prefs.getString("libretro_path", nativeLibraryDir);
final String libretro_path = prefs.getString("libretro_path", coreDir);
// Check if global config is being used. Return true upon failure.
final boolean globalConfigEnabled = prefs.getBoolean("global_config_enable", true);
String append_path;
// If we aren't using the global config.
if (!globalConfigEnabled && !libretro_path.equals(nativeLibraryDir))
if (!globalConfigEnabled && !libretro_path.equals(coreDir))
{
String sanitized_name = sanitizeLibretroPath(libretro_path);
append_path = File.separator + sanitized_name + ".cfg";
@ -158,11 +159,13 @@ public final class UserPreferences
Log.i(TAG, "Writing config to: " + path);
final String dataDir = ctx.getApplicationInfo().dataDir;
final String coreDir = dataDir + "/cores/";
final String nativeLibraryDir = ctx.getApplicationInfo().nativeLibraryDir;
final SharedPreferences prefs = getPreferences(ctx);
config.setString("libretro_path", prefs.getString("libretro_path", nativeLibraryDir));
config.setString("libretro_path", prefs.getString("libretro_path", coreDir));
config.setString("libretro_directory", coreDir);
config.setString("rgui_browser_directory", prefs.getString("rgui_browser_directory", ""));
config.setBoolean("audio_rate_control", prefs.getBoolean("audio_rate_control", true));
config.setInt("audio_out_rate", getOptimalSamplingRate(ctx));
@ -217,7 +220,8 @@ public final class UserPreferences
config.setBoolean("video_shader_enable", prefs.getBoolean("video_shader_enable", false) &&
new File(prefs.getString("video_shader", "")).exists());
config.setBoolean("input_overlay_enable", prefs.getBoolean("input_overlay_enable", false));
if (prefs.contains("input_overlay_enable"))
config.setBoolean("input_overlay_enable", prefs.getBoolean("input_overlay_enable", true));
config.setString("input_overlay", prefs.getString("input_overlay", ""));
if (prefs.getBoolean("savefile_directory_enable", false))

View File

@ -1087,6 +1087,7 @@ static void parse_input(int argc, char *argv[])
strlcpy(g_settings.libretro_directory, optarg, sizeof(g_settings.libretro_directory));
g_extern.has_set_libretro = true;
g_extern.has_set_libretro_directory = true;
RARCH_WARN("Using old --libretro behavior. Setting libretro_directory to \"%s\" instead.\n", optarg);
}
else
{

View File

@ -416,8 +416,11 @@ void config_set_defaults(void)
*g_extern.savefile_dir = '\0';
if (!g_extern.has_set_state_path)
*g_extern.savestate_dir = '\0';
*g_settings.libretro_info_path = '\0';
*g_settings.libretro_directory = '\0';
if (!g_extern.has_set_libretro_directory)
*g_settings.libretro_directory = '\0';
*g_settings.core_options_path = '\0';
*g_settings.game_history_path = '\0';
*g_settings.cheat_database = '\0';