Skip to content

Commit

Permalink
core-specific config files
Browse files Browse the repository at this point in the history
  • Loading branch information
ToadKing committed Jan 1, 2014
1 parent 63302e9 commit 0a91c52
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,12 @@ static bool default_block_config_read = true;
static bool default_block_config_read = false;
#endif

#ifdef RARCH_CONSOLE
static bool default_core_specific_config = true;
#else
static bool default_core_specific_config = false;
#endif

#if defined(ANDROID)
static const char *default_libretro_info_path = "/data/data/com.retroarch/info/";
#elif defined(__QNX__)
Expand Down
5 changes: 5 additions & 0 deletions frontend/frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,12 @@ void main_exit(args_type() args)
menu_free();

if (g_extern.config_save_on_exit && *g_extern.config_path)
{
config_save_file(g_extern.config_path);

if (*g_extern.original_config_path && strcmp(g_extern.config_path, g_extern.original_config_path) != 0)
config_save_file(g_extern.original_config_path);
}
#endif

rarch_main_deinit();
Expand Down
4 changes: 4 additions & 0 deletions general.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ struct settings
bool rgui_show_start_screen;
#endif
bool fps_show;

bool core_specific_config;
};

enum rarch_game_type
Expand Down Expand Up @@ -650,6 +652,8 @@ struct global

bool libretro_no_rom;
bool libretro_dummy;

char original_config_path[PATH_MAX];
};

struct rarch_main_wrap
Expand Down
34 changes: 34 additions & 0 deletions settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ void config_set_defaults(void)
g_settings.video.msg_pos_y = 0.90f;
g_settings.video.aspect_ratio = -1.0f;

g_settings.core_specific_config = default_core_specific_config;

// g_extern
strlcpy(g_extern.savefile_dir, default_paths.sram_dir, sizeof(g_extern.savefile_dir));
g_extern.console.screen.gamma_correction = DEFAULT_GAMMA;
Expand Down Expand Up @@ -443,6 +445,36 @@ void config_load(void)
config_set_defaults();
parse_config_file();
}

if (!*g_extern.original_config_path)
{
path_resolve_realpath(g_extern.config_path, sizeof(g_extern.config_path));
strlcpy(g_extern.original_config_path, g_extern.config_path, sizeof(g_extern.original_config_path));

if (g_settings.core_specific_config && *g_settings.libretro)
{
char new_path[PATH_MAX];

if (*g_settings.rgui_config_directory)
{
path_resolve_realpath(g_settings.rgui_config_directory, sizeof(g_settings.rgui_config_directory));
strlcpy(new_path, g_settings.rgui_config_directory, sizeof(new_path));
}
else
{
strlcpy(new_path, g_extern.config_path, sizeof(new_path));
path_basedir(new_path);
}

fill_pathname_dir(new_path, g_settings.libretro, ".cfg", sizeof(new_path));
strlcpy(g_extern.config_path, new_path, sizeof(g_extern.config_path));

RARCH_LOG("Loading core-specific config from: %s.\n", g_extern.config_path);

if (!config_load_file(g_extern.config_path))
RARCH_WARN("Core-specific config not found, reusing last config.\n");
}
}
}

static config_file_t *open_default_config_file(void)
Expand Down Expand Up @@ -931,6 +963,8 @@ bool config_load_file(const char *path)

config_read_keybinds_conf(conf);

CONFIG_GET_BOOL(core_specific_config, "core_specific_config");

config_file_free(conf);
return true;
}
Expand Down

0 comments on commit 0a91c52

Please sign in to comment.