From 423fe969d3318bad098eafee782b95f2cdfd74f5 Mon Sep 17 00:00:00 2001 From: Themaister Date: Wed, 29 Dec 2010 21:12:56 +0100 Subject: [PATCH] should get default Cg path... --- config.h.def | 1 - gfx/gl.c | 4 ++-- settings.c | 13 ++++++++++++- ssnes.c | 15 +++++++++------ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/config.h.def b/config.h.def index 22b95663c6..f61d7d2a8f 100644 --- a/config.h.def +++ b/config.h.def @@ -65,7 +65,6 @@ static const bool video_smooth = true; // Path to custom Cg shader. If using custom shaders, it is recommended to disable video_smooth. #ifdef HAVE_CG -extern char cg_shader_path[]; #define DEFAULT_CG_SHADER "hqflt/cg/quad.cg" #endif diff --git a/gfx/gl.c b/gfx/gl.c index 93e46b6aa5..96c482bb1a 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -409,8 +409,8 @@ static void* gl_init(video_info_t *video, const input_driver_t **input) } cgGLSetOptimalOptions(gl->cgFProf); cgGLSetOptimalOptions(gl->cgVProf); - gl->cgFPrg = cgCreateProgramFromFile(gl->cgCtx, CG_SOURCE, cg_shader_path, gl->cgFProf, "main_fragment", 0); - gl->cgVPrg = cgCreateProgramFromFile(gl->cgCtx, CG_SOURCE, cg_shader_path, gl->cgVProf, "main_vertex", 0); + gl->cgFPrg = cgCreateProgramFromFile(gl->cgCtx, CG_SOURCE, g_settings.video.cg_shader_path, gl->cgFProf, "main_fragment", 0); + gl->cgVPrg = cgCreateProgramFromFile(gl->cgCtx, CG_SOURCE, g_settings.video.cg_shader_path, gl->cgVProf, "main_vertex", 0); if (gl->cgFPrg == NULL || gl->cgVPrg == NULL) { CGerror err = cgGetError(); diff --git a/settings.c b/settings.c index 089369f0ed..d0012c603f 100644 --- a/settings.c +++ b/settings.c @@ -57,7 +57,7 @@ static void set_defaults(void) g_settings.video.smooth = video_smooth; g_settings.video.force_aspect = force_aspect; #if HAVE_CG - strncpy(g_settings.video.cg_shader_path, cg_shader_path, sizeof(g_settings.video.cg_shader_path) - 1); + strncpy(g_settings.video.cg_shader_path, DEFAULT_CG_SHADER, sizeof(g_settings.video.cg_shader_path) - 1); #endif strncpy(g_settings.video.video_filter, "foo", sizeof(g_settings.video.video_filter) - 1); @@ -78,6 +78,7 @@ static void set_defaults(void) g_settings.input.save_state_key = SAVE_STATE_KEY; g_settings.input.load_state_key = LOAD_STATE_KEY; g_settings.input.toggle_fullscreen_key = TOGGLE_FULLSCREEN; + g_settings.input.axis_threshold = AXIS_THRESHOLD; } void parse_config(void) @@ -149,6 +150,10 @@ void parse_config(void) free(tmp_str); } + // Input Settings. + if (config_get_double(conf, "input_axis_threshold", &tmp_double)) + g_settings.input.axis_threshold = tmp_double; + // Audio settings. if (config_get_bool(conf, "audio_enable", &tmp_bool)) g_settings.audio.enable = tmp_bool; @@ -191,6 +196,12 @@ void parse_config(void) free(tmp_str); } + if (config_get_string(conf, "video_cg_shader_path", &tmp_str)) + { + strncpy(g_settings.video.cg_shader_path, tmp_str, sizeof(g_settings.video.cg_shader_path) - 1); + free(tmp_str); + } + // TODO: Keybinds. config_file_free(conf); diff --git a/ssnes.c b/ssnes.c index c5d1cde3f8..7a8b5650ad 100644 --- a/ssnes.c +++ b/ssnes.c @@ -35,9 +35,6 @@ struct global g_extern = { .video_active = true, .audio_active = true, -#if HAVE_CG - .cg_shader_path = DEFAULT_CG_SHADER -#endif }; // 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. @@ -202,6 +199,7 @@ static void print_help(void) puts("Usage: ssnes [rom file] [-h/--help | -s/--save]"); puts("\t-h/--help: Show this help message"); puts("\t-s/--save: Path for save file (*.srm). Required when rom is input from stdin"); + puts("\t-c/--config: Path for config file. Defaults to $XDG_CONFIG_HOME/ssnes"); #ifdef HAVE_CG puts("\t-f/--shader: Path to Cg shader. Will be compiled at runtime.\n"); #endif @@ -220,6 +218,7 @@ static void parse_input(int argc, char *argv[]) { "help", 0, NULL, 'h' }, { "save", 1, NULL, 's' }, { "verbose", 0, NULL, 'v' }, + { "config", 0, NULL, 'c' }, #ifdef HAVE_CG { "shader", 1, NULL, 'f' }, #endif @@ -228,9 +227,9 @@ static void parse_input(int argc, char *argv[]) int option_index = 0; #ifdef HAVE_CG - char optstring[] = "hs:vf:"; + char optstring[] = "hs:vf:c:"; #else - char optstring[] = "hs:v"; + char optstring[] = "hs:vc:"; #endif for(;;) { @@ -260,6 +259,10 @@ static void parse_input(int argc, char *argv[]) g_extern.verbose = true; break; + case 'c': + strncpy(g_extern.config_path, optarg, sizeof(g_extern.config_path) - 1); + break; + case '?': print_help(); exit(1); @@ -304,8 +307,8 @@ static void parse_input(int argc, char *argv[]) int main(int argc, char *argv[]) { snes_init(); - parse_input(argc, argv); parse_config(); + parse_input(argc, argv); void *rom_buf; ssize_t rom_len = 0;