mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 09:40:06 +00:00
(settings.c) Declare variables at top of function
This commit is contained in:
parent
e0f1696b04
commit
dcf3f23211
41
settings.c
41
settings.c
@ -847,6 +847,10 @@ static void parse_config_file(void)
|
|||||||
bool config_load_file(const char *path, bool set_defaults)
|
bool config_load_file(const char *path, bool set_defaults)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
char *save, tmp_str[PATH_MAX];
|
||||||
|
char tmp_append_path[PATH_MAX]; /* Don't destroy append_config_path. */
|
||||||
|
const char *extra_path;
|
||||||
|
unsigned msg_color = 0;
|
||||||
config_file_t *conf = NULL;
|
config_file_t *conf = NULL;
|
||||||
|
|
||||||
if (path)
|
if (path)
|
||||||
@ -858,21 +862,21 @@ bool config_load_file(const char *path, bool set_defaults)
|
|||||||
else
|
else
|
||||||
conf = open_default_config_file();
|
conf = open_default_config_file();
|
||||||
|
|
||||||
if (conf == NULL)
|
if (!conf)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (set_defaults)
|
if (set_defaults)
|
||||||
config_set_defaults();
|
config_set_defaults();
|
||||||
|
|
||||||
char *save;
|
|
||||||
char tmp_append_path[PATH_MAX]; /* Don't destroy append_config_path. */
|
|
||||||
strlcpy(tmp_append_path, g_extern.append_config_path,
|
strlcpy(tmp_append_path, g_extern.append_config_path,
|
||||||
sizeof(tmp_append_path));
|
sizeof(tmp_append_path));
|
||||||
const char *extra_path = strtok_r(tmp_append_path, ",", &save);
|
extra_path = strtok_r(tmp_append_path, ",", &save);
|
||||||
|
|
||||||
while (extra_path)
|
while (extra_path)
|
||||||
{
|
{
|
||||||
|
bool ret = false;
|
||||||
RARCH_LOG("Appending config \"%s\"\n", extra_path);
|
RARCH_LOG("Appending config \"%s\"\n", extra_path);
|
||||||
bool ret = config_append_file(conf, extra_path);
|
ret = config_append_file(conf, extra_path);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
RARCH_ERR("Failed to append config \"%s\"\n", extra_path);
|
RARCH_ERR("Failed to append config \"%s\"\n", extra_path);
|
||||||
extra_path = strtok_r(NULL, ";", &save);
|
extra_path = strtok_r(NULL, ";", &save);
|
||||||
@ -885,7 +889,6 @@ bool config_load_file(const char *path, bool set_defaults)
|
|||||||
RARCH_LOG_OUTPUT("=== Config end ===\n");
|
RARCH_LOG_OUTPUT("=== Config end ===\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
char tmp_str[PATH_MAX];
|
|
||||||
|
|
||||||
CONFIG_GET_FLOAT(video.scale, "video_scale");
|
CONFIG_GET_FLOAT(video.scale, "video_scale");
|
||||||
CONFIG_GET_INT(video.fullscreen_x, "video_fullscreen_x");
|
CONFIG_GET_INT(video.fullscreen_x, "video_fullscreen_x");
|
||||||
@ -976,7 +979,6 @@ bool config_load_file(const char *path, bool set_defaults)
|
|||||||
CONFIG_GET_INT_EXTERN(console.screen.viewports.custom_vp.height,
|
CONFIG_GET_INT_EXTERN(console.screen.viewports.custom_vp.height,
|
||||||
"custom_viewport_height");
|
"custom_viewport_height");
|
||||||
|
|
||||||
unsigned msg_color = 0;
|
|
||||||
if (config_get_hex(conf, "video_message_color", &msg_color))
|
if (config_get_hex(conf, "video_message_color", &msg_color))
|
||||||
{
|
{
|
||||||
g_settings.video.msg_color_r = ((msg_color >> 16) & 0xff) / 255.0f;
|
g_settings.video.msg_color_r = ((msg_color >> 16) & 0xff) / 255.0f;
|
||||||
@ -1285,7 +1287,9 @@ static void read_keybinds_player(config_file_t *conf, unsigned player)
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; input_config_bind_map[i].valid; i++)
|
for (i = 0; input_config_bind_map[i].valid; i++)
|
||||||
{
|
{
|
||||||
struct retro_keybind *bind = &g_settings.input.binds[player][i];
|
struct retro_keybind *bind = (struct retro_keybind*)
|
||||||
|
&g_settings.input.binds[player][i];
|
||||||
|
|
||||||
if (!bind->valid)
|
if (!bind->valid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -1304,21 +1308,23 @@ static void config_read_keybinds_conf(config_file_t *conf)
|
|||||||
|
|
||||||
bool config_read_keybinds(const char *path)
|
bool config_read_keybinds(const char *path)
|
||||||
{
|
{
|
||||||
config_file_t *conf = config_file_new(path);
|
config_file_t *conf = (config_file_t*)config_file_new(path);
|
||||||
|
|
||||||
if (!conf)
|
if (!conf)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
config_read_keybinds_conf(conf);
|
config_read_keybinds_conf(conf);
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void save_keybind_key(config_file_t *conf, const char *prefix,
|
static void save_keybind_key(config_file_t *conf, const char *prefix,
|
||||||
const char *base, const struct retro_keybind *bind)
|
const char *base, const struct retro_keybind *bind)
|
||||||
{
|
{
|
||||||
char key[64];
|
char key[64], btn[64];
|
||||||
snprintf(key, sizeof(key), "%s_%s", prefix, base);
|
|
||||||
|
|
||||||
char btn[64];
|
snprintf(key, sizeof(key), "%s_%s", prefix, base);
|
||||||
input_translate_rk_to_str(bind->key, btn, sizeof(btn));
|
input_translate_rk_to_str(bind->key, btn, sizeof(btn));
|
||||||
config_set_string(conf, key, btn);
|
config_set_string(conf, key, btn);
|
||||||
}
|
}
|
||||||
@ -1326,6 +1332,7 @@ static void save_keybind_key(config_file_t *conf, const char *prefix,
|
|||||||
static void save_keybind_hat(config_file_t *conf, const char *key,
|
static void save_keybind_hat(config_file_t *conf, const char *key,
|
||||||
const struct retro_keybind *bind)
|
const struct retro_keybind *bind)
|
||||||
{
|
{
|
||||||
|
char config[16];
|
||||||
unsigned hat = GET_HAT(bind->joykey);
|
unsigned hat = GET_HAT(bind->joykey);
|
||||||
const char *dir = NULL;
|
const char *dir = NULL;
|
||||||
|
|
||||||
@ -1351,7 +1358,6 @@ static void save_keybind_hat(config_file_t *conf, const char *key,
|
|||||||
rarch_assert(0);
|
rarch_assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
char config[16];
|
|
||||||
snprintf(config, sizeof(config), "h%u%s", hat, dir);
|
snprintf(config, sizeof(config), "h%u%s", hat, dir);
|
||||||
config_set_string(conf, key, config);
|
config_set_string(conf, key, config);
|
||||||
}
|
}
|
||||||
@ -1374,11 +1380,11 @@ static void save_keybind_axis(config_file_t *conf, const char *prefix,
|
|||||||
const char *base, const struct retro_keybind *bind)
|
const char *base, const struct retro_keybind *bind)
|
||||||
{
|
{
|
||||||
char key[64];
|
char key[64];
|
||||||
snprintf(key, sizeof(key), "%s_%s_axis", prefix, base);
|
|
||||||
|
|
||||||
unsigned axis = 0;
|
unsigned axis = 0;
|
||||||
char dir = '\0';
|
char dir = '\0';
|
||||||
|
|
||||||
|
snprintf(key, sizeof(key), "%s_%s_axis", prefix, base);
|
||||||
|
|
||||||
if (bind->joyaxis == AXIS_NONE)
|
if (bind->joyaxis == AXIS_NONE)
|
||||||
config_set_string(conf, key, "nul");
|
config_set_string(conf, key, "nul");
|
||||||
else if (AXIS_NEG_GET(bind->joyaxis) != AXIS_DIR_NONE)
|
else if (AXIS_NEG_GET(bind->joyaxis) != AXIS_DIR_NONE)
|
||||||
@ -1427,9 +1433,12 @@ static void save_keybinds_player(config_file_t *conf, unsigned player)
|
|||||||
bool config_save_file(const char *path)
|
bool config_save_file(const char *path)
|
||||||
{
|
{
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
|
bool ret = false;
|
||||||
config_file_t *conf = config_file_new(path);
|
config_file_t *conf = config_file_new(path);
|
||||||
|
|
||||||
if (!conf)
|
if (!conf)
|
||||||
conf = config_file_new(NULL);
|
conf = config_file_new(NULL);
|
||||||
|
|
||||||
if (!conf)
|
if (!conf)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1657,7 +1666,7 @@ bool config_save_file(const char *path)
|
|||||||
config_set_bool(conf, "log_verbosity", g_extern.verbosity);
|
config_set_bool(conf, "log_verbosity", g_extern.verbosity);
|
||||||
config_set_bool(conf, "perfcnt_enable", g_extern.perfcnt_enable);
|
config_set_bool(conf, "perfcnt_enable", g_extern.perfcnt_enable);
|
||||||
|
|
||||||
bool ret = config_file_write(conf, path);
|
ret = config_file_write(conf, path);
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user