Fixes... Add driver ident and remove some config.h deps.

This commit is contained in:
Themaister 2010-12-29 20:05:57 +01:00
parent 80d98f765e
commit fc126942e9
12 changed files with 63 additions and 13 deletions

View File

@ -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"
};

View File

@ -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"
};

View File

@ -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"
};

View File

@ -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"
};

View File

@ -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"
};

View File

@ -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;

View File

@ -21,6 +21,31 @@
#include <stdio.h>
#include <string.h>
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

View File

@ -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;

View File

@ -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);

View File

@ -18,7 +18,6 @@
#define GL_GLEXT_PROTOTYPES
#include "driver.h"
#include "config.h"
#include <GL/glfw.h>
#include <GL/glext.h>
#include <stdint.h>
@ -26,6 +25,7 @@
#include <stdio.h>
#include <sys/time.h>
#include <string.h>
#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"
};

View File

@ -1,6 +1,6 @@
#include "general.h"
#include "conf/config_file.h"
#include "config.h"
#include "config.h.def"
#include <assert.h>
#include <string.h>

View File

@ -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.