diff --git a/conf/config_file.c b/conf/config_file.c index 3b6c398645..a4c550b9a2 100644 --- a/conf/config_file.c +++ b/conf/config_file.c @@ -427,7 +427,12 @@ bool config_get_float(config_file_t *conf, const char *key, float *in) { if (strcmp(key, list->key) == 0) { +#ifdef __cplusplus + // strtof() is C99/POSIX. *in = (float)strtod(list->value, NULL); +#else + *in = strtof(list->value, NULL); +#endif return true; } list = list->next; @@ -612,6 +617,13 @@ void config_set_double(config_file_t *conf, const char *key, double val) config_set_string(conf, key, buf); } +void config_set_float(config_file_t *conf, const char *key, float val) +{ + char buf[128]; + snprintf(buf, sizeof(buf), "%f", val); + config_set_string(conf, key, buf); +} + void config_set_int(config_file_t *conf, const char *key, int val) { char buf[128]; diff --git a/conf/config_file.h b/conf/config_file.h index e8b6eb1d3a..5b021effa3 100644 --- a/conf/config_file.h +++ b/conf/config_file.h @@ -69,6 +69,7 @@ bool config_get_bool(config_file_t *conf, const char *entry, bool *in); // Setters. Similar to the getters. Will not write to entry if the entry // was obtained from an #include. void config_set_double(config_file_t *conf, const char *entry, double value); +void config_set_float(config_file_t *conf, const char *entry, float value); void config_set_int(config_file_t *conf, const char *entry, int val); void config_set_char(config_file_t *conf, const char *entry, char val); void config_set_string(config_file_t *conf, const char *entry, const char *val); diff --git a/conf/config_file_macros.h b/conf/config_file_macros.h index 3fcd7ef127..05695fc71a 100644 --- a/conf/config_file_macros.h +++ b/conf/config_file_macros.h @@ -33,9 +33,9 @@ base.var = tmp; \ } while(0) -#define CONFIG_GET_DOUBLE_BASE(conf, base, var, key) do { \ - double tmp; \ - if (config_get_double(conf, key, &tmp)) \ +#define CONFIG_GET_FLOAT_BASE(conf, base, var, key) do { \ + float tmp; \ + if (config_get_float(conf, key, &tmp)) \ base.var = tmp; \ } while(0) @@ -44,18 +44,18 @@ #define CONFIG_GET_BOOL(var, key) CONFIG_GET_BOOL_BASE(conf, g_settings, var, key) #define CONFIG_GET_INT(var, key) CONFIG_GET_INT_BASE(conf, g_settings, var, key) -#define CONFIG_GET_DOUBLE(var, key) CONFIG_GET_DOUBLE_BASE(conf, g_settings, var, key) +#define CONFIG_GET_FLOAT(var, key) CONFIG_GET_FLOAT_BASE(conf, g_settings, var, key) #define CONFIG_GET_STRING(var, key) CONFIG_GET_STRING_BASE(conf, g_settings, var, key) #define CONFIG_GET_BOOL_EXTERN(var, key) CONFIG_GET_BOOL_BASE(conf, g_extern, var, key) #define CONFIG_GET_INT_EXTERN(var, key) CONFIG_GET_INT_BASE(conf, g_extern, var, key) -#define CONFIG_GET_DOUBLE_EXTERN(var, key) CONFIG_GET_DOUBLE_BASE(conf, g_extern, var, key) +#define CONFIG_GET_FLOAT_EXTERN(var, key) CONFIG_GET_FLOAT_BASE(conf, g_extern, var, key) #define CONFIG_GET_STRING_EXTERN(var, key) CONFIG_GET_STRING_BASE(conf, g_extern, var, key) #ifdef SSNES_CONSOLE #define CONFIG_GET_BOOL_CONSOLE(var, key) CONFIG_GET_BOOL_BASE(conf, g_console, var, key) #define CONFIG_GET_INT_CONSOLE(var, key) CONFIG_GET_INT_BASE(conf, g_console, var, key) -#define CONFIG_GET_DOUBLE_CONSOLE(var, key) CONFIG_GET_DOUBLE_BASE(conf, g_console, var, key) +#define CONFIG_GET_FLOAT_CONSOLE(var, key) CONFIG_GET_FLOAT_BASE(conf, g_console, var, key) #define CONFIG_GET_STRING_CONSOLE(var, key) CONFIG_GET_STRING_BASE(conf, g_console, var, key) #endif diff --git a/ps3/main.c b/ps3/main.c index 2b4c0cbdd1..e0b7c66619 100644 --- a/ps3/main.c +++ b/ps3/main.c @@ -133,8 +133,8 @@ static void init_settings(void) CONFIG_GET_BOOL(rewind_enable, "rewind_enable"); CONFIG_GET_STRING(video.cg_shader_path, "video_cg_shader"); CONFIG_GET_STRING(video.second_pass_shader, "video_second_pass_shader"); - CONFIG_GET_DOUBLE(video.fbo_scale_x, "video_fbo_scale_x"); - CONFIG_GET_DOUBLE(video.fbo_scale_y, "video_fbo_scale_y"); + CONFIG_GET_FLOAT(video.fbo_scale_x, "video_fbo_scale_x"); + CONFIG_GET_FLOAT(video.fbo_scale_y, "video_fbo_scale_y"); CONFIG_GET_BOOL(video.render_to_texture, "video_render_to_texture"); CONFIG_GET_BOOL(video.second_pass_smooth, "video_second_pass_smooth"); CONFIG_GET_BOOL(video.smooth, "video_smooth"); diff --git a/settings.c b/settings.c index 756072acb2..2d93b82d23 100644 --- a/settings.c +++ b/settings.c @@ -341,8 +341,8 @@ bool config_load_file(const char *path) char tmp_str[PATH_MAX]; - CONFIG_GET_DOUBLE(video.xscale, "video_xscale"); - CONFIG_GET_DOUBLE(video.yscale, "video_yscale"); + CONFIG_GET_FLOAT(video.xscale, "video_xscale"); + CONFIG_GET_FLOAT(video.yscale, "video_yscale"); CONFIG_GET_INT(video.fullscreen_x, "video_fullscreen_x"); CONFIG_GET_INT(video.fullscreen_y, "video_fullscreen_y"); @@ -355,15 +355,15 @@ bool config_load_file(const char *path) CONFIG_GET_BOOL(video.smooth, "video_smooth"); CONFIG_GET_BOOL(video.force_aspect, "video_force_aspect"); CONFIG_GET_BOOL(video.crop_overscan, "video_crop_overscan"); - CONFIG_GET_DOUBLE(video.aspect_ratio, "video_aspect_ratio"); - CONFIG_GET_DOUBLE(video.refresh_rate, "video_refresh_rate"); + CONFIG_GET_FLOAT(video.aspect_ratio, "video_aspect_ratio"); + CONFIG_GET_FLOAT(video.refresh_rate, "video_refresh_rate"); CONFIG_GET_STRING(video.cg_shader_path, "video_cg_shader"); CONFIG_GET_STRING(video.bsnes_shader_path, "video_bsnes_shader"); CONFIG_GET_STRING(video.second_pass_shader, "video_second_pass_shader"); CONFIG_GET_BOOL(video.render_to_texture, "video_render_to_texture"); - CONFIG_GET_DOUBLE(video.fbo_scale_x, "video_fbo_scale_x"); - CONFIG_GET_DOUBLE(video.fbo_scale_y, "video_fbo_scale_y"); + CONFIG_GET_FLOAT(video.fbo_scale_x, "video_fbo_scale_x"); + CONFIG_GET_FLOAT(video.fbo_scale_y, "video_fbo_scale_y"); CONFIG_GET_BOOL(video.second_pass_smooth, "video_second_pass_smooth"); #ifdef HAVE_FREETYPE @@ -371,8 +371,8 @@ bool config_load_file(const char *path) CONFIG_GET_INT(video.font_size, "video_font_size"); CONFIG_GET_BOOL(video.font_enable, "video_font_enable"); CONFIG_GET_BOOL(video.font_scale, "video_font_scale"); - CONFIG_GET_DOUBLE(video.msg_pos_x, "video_message_pos_x"); - CONFIG_GET_DOUBLE(video.msg_pos_y, "video_message_pos_y"); + CONFIG_GET_FLOAT(video.msg_pos_x, "video_message_pos_x"); + CONFIG_GET_FLOAT(video.msg_pos_y, "video_message_pos_y"); unsigned msg_color; if (config_get_hex(conf, "video_message_color", &msg_color)) @@ -410,7 +410,7 @@ bool config_load_file(const char *path) CONFIG_GET_STRING(video.shader_dir, "video_shader_dir"); #endif - CONFIG_GET_DOUBLE(input.axis_threshold, "input_axis_threshold"); + CONFIG_GET_FLOAT(input.axis_threshold, "input_axis_threshold"); CONFIG_GET_BOOL(input.netplay_client_swap_input, "netplay_client_swap_input"); CONFIG_GET_INT(input.joypad_map[0], "input_player1_joypad_index"); CONFIG_GET_INT(input.joypad_map[1], "input_player2_joypad_index"); @@ -421,7 +421,7 @@ bool config_load_file(const char *path) // Audio settings. CONFIG_GET_BOOL(audio.enable, "audio_enable"); CONFIG_GET_INT(audio.out_rate, "audio_out_rate"); - CONFIG_GET_DOUBLE(audio.rate_step, "audio_rate_step"); + CONFIG_GET_FLOAT(audio.rate_step, "audio_rate_step"); CONFIG_GET_STRING(audio.device, "audio_device"); CONFIG_GET_INT(audio.latency, "audio_latency"); CONFIG_GET_BOOL(audio.sync, "audio_sync");