diff --git a/audio/alsa.c b/audio/alsa.c index 5dece09311..4e6145141e 100644 --- a/audio/alsa.c +++ b/audio/alsa.c @@ -190,7 +190,8 @@ const audio_driver_t audio_alsa = { .stop = __alsa_stop, .start = __alsa_start, .set_nonblock_state = __alsa_set_nonblock_state, - .free = __alsa_free + .free = __alsa_free, + .ident = "alsa" }; diff --git a/audio/openal.c b/audio/openal.c index 75826541e7..431acba814 100644 --- a/audio/openal.c +++ b/audio/openal.c @@ -233,7 +233,8 @@ const audio_driver_t audio_openal = { .stop = __al_stop, .start = __al_start, .set_nonblock_state = __al_set_nonblock_state, - .free = __al_free + .free = __al_free, + .ident = "openal" }; diff --git a/audio/oss.c b/audio/oss.c index b12ddebad1..bf451905e6 100644 --- a/audio/oss.c +++ b/audio/oss.c @@ -136,7 +136,8 @@ const audio_driver_t audio_oss = { .stop = __oss_stop, .start = __oss_start, .set_nonblock_state = __oss_set_nonblock_state, - .free = __oss_free + .free = __oss_free, + .ident = "oss" }; diff --git a/audio/roar.c b/audio/roar.c index db94f0768b..89ab744560 100644 --- a/audio/roar.c +++ b/audio/roar.c @@ -107,7 +107,8 @@ const audio_driver_t audio_roar = { .stop = __roar_stop, .start = __roar_start, .set_nonblock_state = __roar_set_nonblock_state, - .free = __roar_free + .free = __roar_free, + .ident = "roar" }; diff --git a/audio/rsound.c b/audio/rsound.c index 181f0859c8..08040c2e65 100644 --- a/audio/rsound.c +++ b/audio/rsound.c @@ -135,7 +135,8 @@ const audio_driver_t audio_rsound = { .stop = __rsd_stop, .start = __rsd_start, .set_nonblock_state = __rsd_set_nonblock_state, - .free = __rsd_free + .free = __rsd_free, + .ident = "rsound" }; diff --git a/config.h.def b/config.h.def index 859daec4bb..1fd2557d1d 100644 --- a/config.h.def +++ b/config.h.def @@ -53,7 +53,7 @@ static const float xscale = 3.0; // Real x res = 296 * xscale static const float yscale = 3.0; // Real y res = 224 * yscale // Fullscreen -#define START_FULLSCREEN false; // To start in Fullscreen or not +static const bool fullscreen = false; // To start in Fullscreen or not static const unsigned fullscreen_x = 1280; static const unsigned fullscreen_y = 720; diff --git a/driver.c b/driver.c index 746b6e9a4f..159de9737c 100644 --- a/driver.c +++ b/driver.c @@ -21,6 +21,31 @@ #include #include +static audio_driver_t audio_drivers[] = { +#ifdef HAVE_ALSA + &audio_alsa, +#endif +#ifdef HAVE_OSS + &audio_oss, +#endif +#ifdef HAVE_RSOUND + &audio_rsound, +#endif +#ifdef HAVE_AL + &audio_openal, +#endif +#ifdef HAVE_ROAR + &audio_roar, +#endif +}; + +static video_driver_t video_drivers[] = { +#ifdef HAVE_GL + &video_gl, +#endif +}; + + void init_drivers(void) { init_video_input(); @@ -142,6 +167,9 @@ void uninit_video_input(void) driver.input->free(driver.input_data); } +driver_t driver; + +#if 0 driver_t driver = { #if VIDEO_DRIVER == VIDEO_GL .video = &video_gl, @@ -163,4 +191,5 @@ driver_t driver = { #error "Define a valid audio driver in config.h" #endif }; +#endif diff --git a/driver.h b/driver.h index b17417012b..651dd3cf9b 100644 --- a/driver.h +++ b/driver.h @@ -54,14 +54,19 @@ typedef struct audio_driver bool (*start)(void* data); void (*set_nonblock_state)(void* data, bool toggle); // Should we care about blocking in audio thread? Fast forwarding. void (*free)(void* data); + const char *ident; } audio_driver_t; +#define AXIS_NEG_GET(x) ((x >> 16) & 0xFFFF) +#define AXIS_POS_GET(x) (x & 0xFFFF) +#define AXIS_NONE ((uint32_t)0xFFFFFFFFU) typedef struct input_driver { void* (*init)(void); void (*poll)(void* data); int16_t (*input_state)(void* data, const struct snes_keybind **snes_keybinds, bool port, unsigned device, unsigned index, unsigned id); void (*free)(void* data); + const char *ident; } input_driver_t; typedef struct video_driver @@ -71,6 +76,7 @@ typedef struct video_driver bool (*frame)(void* data, const uint16_t* frame, int width, int height, int pitch); void (*set_nonblock_state)(void* data, bool toggle); // Should we care about syncing to vblank? Fast forwarding. void (*free)(void* data); + const char *ident; } video_driver_t; diff --git a/general.h b/general.h index de00116756..bd8ab93893 100644 --- a/general.h +++ b/general.h @@ -31,6 +31,7 @@ struct settings { struct { + char driver[32]; float xscale; float yscale; bool fullscreen; @@ -45,6 +46,7 @@ struct settings struct { + char driver[32]; bool enable; unsigned out_rate; unsigned in_rate; @@ -56,10 +58,12 @@ struct settings struct { + char driver[32]; struct snes_keybind binds[MAX_PLAYERS][MAX_BINDS]; int save_state_key; int load_state_key; int toggle_fullscreen_key; + float axis_threshold; } input; }; @@ -73,6 +77,7 @@ struct global FILE *rom_file; char savefile_name_srm[256]; char cg_shader_path[256]; + char config_path[256]; }; void parse_config(void); diff --git a/gfx/gl.c b/gfx/gl.c index e261223f37..93e46b6aa5 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -18,7 +18,6 @@ #define GL_GLEXT_PROTOTYPES #include "driver.h" -#include "config.h" #include #include #include @@ -26,6 +25,7 @@ #include #include #include +#include "general.h" #ifdef HAVE_CG @@ -122,9 +122,9 @@ static bool glfw_is_pressed(int port_num, const struct snes_keybind *key, unsign if (key->joyaxis != AXIS_NONE) { - if (AXIS_NEG_GET(key->joyaxis) < joypad_axes[port_num] && axes[AXIS_NEG_GET(key->joyaxis)] <= -AXIS_THRESHOLD) + if (AXIS_NEG_GET(key->joyaxis) < joypad_axes[port_num] && axes[AXIS_NEG_GET(key->joyaxis)] <= -g_settings.input.axis_threshold) return true; - if (AXIS_POS_GET(key->joyaxis) < joypad_axes[port_num] && axes[AXIS_POS_GET(key->joyaxis)] >= AXIS_THRESHOLD) + if (AXIS_POS_GET(key->joyaxis) < joypad_axes[port_num] && axes[AXIS_POS_GET(key->joyaxis)] >= g_settings.input.axis_threshold) return true; } return false; @@ -174,7 +174,8 @@ static void glfw_free_input(void *data) static const input_driver_t input_glfw = { .poll = glfw_input_poll, .input_state = glfw_input_state, - .free = glfw_free_input + .free = glfw_free_input, + .ident = "glfw" }; static void GLFWCALL resize(int width, int height) @@ -446,7 +447,8 @@ const video_driver_t video_gl = { .init = gl_init, .frame = gl_frame, .set_nonblock_state = gl_set_nonblock_state, - .free = gl_free + .free = gl_free, + .ident = "glfw" }; diff --git a/settings.c b/settings.c index f430f8b031..bbefc338bd 100644 --- a/settings.c +++ b/settings.c @@ -1,6 +1,6 @@ #include "general.h" #include "conf/config_file.h" -#include "config.h" +#include "config.h.def" #include #include diff --git a/ssnes.c b/ssnes.c index 7be025a850..c5d1cde3f8 100644 --- a/ssnes.c +++ b/ssnes.c @@ -34,7 +34,10 @@ struct global g_extern = { .video_active = true, - .audio_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.