mirror of
https://github.com/libretro/RetroArch
synced 2025-01-26 18:35:22 +00:00
Small refactor.
This commit is contained in:
parent
702cf9c804
commit
1bfd9716c5
10
settings.c
10
settings.c
@ -29,6 +29,7 @@
|
||||
#include <ctype.h>
|
||||
|
||||
struct settings g_settings;
|
||||
struct global g_extern;
|
||||
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
static void read_keybinds(config_file_t *conf);
|
||||
@ -184,7 +185,6 @@ static void parse_config_file(void);
|
||||
|
||||
void parse_config(void)
|
||||
{
|
||||
memset(&g_settings, 0, sizeof(struct settings));
|
||||
set_defaults();
|
||||
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
@ -204,7 +204,7 @@ static config_file_t *open_default_config_file(void)
|
||||
const char *appdata = getenv("APPDATA");
|
||||
if (appdata)
|
||||
{
|
||||
char conf_path[strlen(appdata) + strlen("/ssnes.cfg ")];
|
||||
char conf_path[MAXPATHLEN];
|
||||
strlcpy(conf_path, appdata, sizeof(conf_path));
|
||||
strlcat(conf_path, "/ssnes.cfg", sizeof(conf_path));
|
||||
conf = config_file_new(conf_path);
|
||||
@ -214,7 +214,7 @@ static config_file_t *open_default_config_file(void)
|
||||
const char *home = getenv("HOME");
|
||||
if (home)
|
||||
{
|
||||
char conf_path[strlen(home) + strlen("/.ssnes.cfg ")];
|
||||
char conf_path[MAXPATHLEN];
|
||||
strlcpy(conf_path, home, sizeof(conf_path));
|
||||
strlcat(conf_path, "/.ssnes.cfg", sizeof(conf_path));
|
||||
conf = config_file_new(conf_path);
|
||||
@ -229,14 +229,14 @@ static config_file_t *open_default_config_file(void)
|
||||
const char *home = getenv("HOME");
|
||||
if (xdg)
|
||||
{
|
||||
char conf_path[strlen(xdg) + strlen("/ssnes/ssnes.cfg ")];
|
||||
char conf_path[MAXPATHLEN];
|
||||
strlcpy(conf_path, xdg, sizeof(conf_path));
|
||||
strlcat(conf_path, "/ssnes/ssnes.cfg", sizeof(conf_path));
|
||||
conf = config_file_new(conf_path);
|
||||
}
|
||||
else if (home)
|
||||
{
|
||||
char conf_path[strlen(home) + strlen("/.ssnes.cfg ")];
|
||||
char conf_path[MAXPATHLEN];
|
||||
strlcpy(conf_path, home, sizeof(conf_path));
|
||||
strlcat(conf_path, "/.ssnes.cfg", sizeof(conf_path));
|
||||
conf = config_file_new(conf_path);
|
||||
|
20
ssnes.c
20
ssnes.c
@ -49,15 +49,9 @@
|
||||
#include "SDL.h"
|
||||
// OSX seems to really need -lSDLmain,
|
||||
// so we include SDL.h here so it can hack our main.
|
||||
// I had issues including this in Win32 for some reason. :)
|
||||
// We want to use -mconsole in Win32, so we need main().
|
||||
#endif
|
||||
|
||||
struct global g_extern = {
|
||||
.video_active = true,
|
||||
.audio_active = true,
|
||||
.game_type = SSNES_CART_NORMAL,
|
||||
};
|
||||
|
||||
// To avoid continous switching if we hold the button down, we require that the button must go from pressed, unpressed back to pressed to be able to toggle between then.
|
||||
static void set_fast_forward_button(bool new_button_state, bool new_hold_button_state)
|
||||
{
|
||||
@ -1555,9 +1549,20 @@ static void fill_title_buf(void)
|
||||
snprintf(g_extern.title_buf, sizeof(g_extern.title_buf), "SSNES");
|
||||
}
|
||||
|
||||
static void init_state(void)
|
||||
{
|
||||
// Make absolutely sure our big global structs are in-fact zeroed out.
|
||||
memset(&g_extern, 0, sizeof(g_extern));
|
||||
memset(&g_settings, 0, sizeof(g_settings));
|
||||
g_extern.video_active = true;
|
||||
g_extern.audio_active = true;
|
||||
g_extern.game_type = SSNES_CART_NORMAL;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
init_state();
|
||||
|
||||
parse_input(argc, argv);
|
||||
parse_config();
|
||||
init_dlsym();
|
||||
@ -1705,3 +1710,4 @@ error:
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user