Snes exorcism

This commit is contained in:
Twinaphex 2012-07-07 17:19:32 +02:00
parent 2fd12edfb6
commit c3d40d0f5a
20 changed files with 65 additions and 65 deletions

View File

@ -35,7 +35,7 @@ static void xenon360_input_poll(void *data)
}
}
static int16_t xenon360_input_state(void *data, const struct snes_keybind **binds,
static int16_t xenon360_input_state(void *data, const struct retro_keybind **binds,
bool port, unsigned device,
unsigned index, unsigned id)
{

View File

@ -31,7 +31,7 @@ struct autosave
sthread_t *thread;
void *buffer;
const void *snes_buffer;
const void *retro_buffer;
const char *path;
size_t bufsize;
unsigned interval;
@ -46,9 +46,9 @@ static void autosave_thread(void *data)
while (!save->quit)
{
autosave_lock(save);
bool differ = memcmp(save->buffer, save->snes_buffer, save->bufsize) != 0;
bool differ = memcmp(save->buffer, save->retro_buffer, save->bufsize) != 0;
if (differ)
memcpy(save->buffer, save->snes_buffer, save->bufsize);
memcpy(save->buffer, save->retro_buffer, save->bufsize);
autosave_unlock(save);
if (differ)
@ -92,14 +92,14 @@ autosave_t *autosave_new(const char *path, const void *data, size_t size, unsign
handle->interval = interval;
handle->path = path;
handle->buffer = malloc(size);
handle->snes_buffer = data;
handle->retro_buffer = data;
if (!handle->buffer)
{
free(handle);
return NULL;
}
memcpy(handle->buffer, handle->snes_buffer, handle->bufsize);
memcpy(handle->buffer, handle->retro_buffer, handle->bufsize);
handle->lock = slock_new();
handle->cond_lock = slock_new();

View File

@ -310,7 +310,7 @@ static const float axis_threshold = 0.5;
// SDL sometimes reverses the axes for some odd reason, but hey. :D
// Player 1
static const struct snes_keybind snes_keybinds_1[] = {
static const struct retro_keybind retro_keybinds_1[] = {
// SNES button | keyboard key | js btn | js axis |
{ true, RETRO_DEVICE_ID_JOYPAD_B, SK_z, NO_BTN, AXIS_NONE },
{ true, RETRO_DEVICE_ID_JOYPAD_Y, SK_a, NO_BTN, AXIS_NONE },
@ -366,7 +366,7 @@ static const struct snes_keybind snes_keybinds_1[] = {
};
// Player 2-5
static const struct snes_keybind snes_keybinds_rest[] = {
static const struct retro_keybind retro_keybinds_rest[] = {
{ true, RETRO_DEVICE_ID_JOYPAD_B, SK_UNKNOWN, NO_BTN, AXIS_NONE },
{ true, RETRO_DEVICE_ID_JOYPAD_Y, SK_UNKNOWN, NO_BTN, AXIS_NONE },
{ true, RETRO_DEVICE_ID_JOYPAD_SELECT, SK_UNKNOWN, NO_BTN, AXIS_NONE },

View File

@ -92,7 +92,7 @@ enum // RetroArch specific bind IDs.
RARCH_BIND_LIST_END_NULL
};
struct snes_keybind
struct retro_keybind
{
bool valid;
int id;
@ -156,7 +156,7 @@ typedef struct input_driver
{
void *(*init)(void);
void (*poll)(void *data);
int16_t (*input_state)(void *data, const struct snes_keybind **snes_keybinds, unsigned port, unsigned device, unsigned index, unsigned id);
int16_t (*input_state)(void *data, const struct retro_keybind **retro_keybinds, unsigned port, unsigned device, unsigned index, unsigned id);
bool (*key_pressed)(void *data, int key);
void (*free)(void *data);
const char *ident;
@ -282,8 +282,8 @@ extern const input_driver_t input_null;
#define input_init_func() driver.input->init()
#define input_poll_func() driver.input->poll(driver.input_data)
#define input_input_state_func(snes_keybinds, port, device, index, id) \
driver.input->input_state(driver.input_data, snes_keybinds, port, device, index, id)
#define input_input_state_func(retro_keybinds, port, device, index, id) \
driver.input->input_state(driver.input_data, retro_keybinds, port, device, index, id)
#define input_free_func() driver.input->free(driver.input_data)
static inline bool input_key_pressed_func(int key)

View File

@ -154,7 +154,7 @@ struct settings
struct
{
char driver[32];
struct snes_keybind binds[MAX_PLAYERS][RARCH_BIND_LIST_END];
struct retro_keybind binds[MAX_PLAYERS][RARCH_BIND_LIST_END];
float axis_threshold;
int joypad_map[MAX_PLAYERS];
#ifdef RARCH_CONSOLE

View File

@ -57,7 +57,7 @@ static void input_ext_poll(void *data)
ext->driver->poll(ext->handle);
}
static int16_t input_ext_input_state(void *data, const struct snes_keybind **snes_keybinds, unsigned port, unsigned device, unsigned index, unsigned id)
static int16_t input_ext_input_state(void *data, const struct retro_keybind **retro_keybinds, unsigned port, unsigned device, unsigned index, unsigned id)
{
input_ext_t *ext = (input_ext_t*)data;
@ -65,7 +65,7 @@ static int16_t input_ext_input_state(void *data, const struct snes_keybind **sne
if (id < RARCH_BIND_LIST_END)
{
const struct snes_keybind *rarch_bind = &snes_keybinds[player - 1][id];
const struct retro_keybind *rarch_bind = &retro_keybinds[player - 1][id];
if (!rarch_bind->valid)
return 0;
@ -86,7 +86,7 @@ static bool input_ext_key_pressed(void *data, int key)
if (key >= 0 && key < RARCH_BIND_LIST_END)
{
const struct snes_keybind *rarch_bind = &g_settings.input.binds[0][key];
const struct retro_keybind *rarch_bind = &g_settings.input.binds[0][key];
if (!rarch_bind->valid)
return false;

View File

@ -68,7 +68,7 @@ static PyObject *py_read_input(PyObject *self, PyObject *args)
if (player > MAX_PLAYERS || player < 1 || key >= RARCH_FIRST_META_KEY)
return NULL;
static const struct snes_keybind *binds[MAX_PLAYERS] = {
static const struct retro_keybind *binds[MAX_PLAYERS] = {
g_settings.input.binds[0],
g_settings.input.binds[1],
g_settings.input.binds[2],

View File

@ -228,7 +228,7 @@ static void update_input(state_tracker_t *tracker)
};
// Only bind for up to two players for now.
static const struct snes_keybind *binds[2] = {
static const struct retro_keybind *binds[2] = {
g_settings.input.binds[0],
g_settings.input.binds[1],
};

View File

@ -190,7 +190,7 @@ static bool dinput_joykey_pressed(sdl_dinput_t *di, unsigned port_num, uint16_t
return false;
}
int16_t sdl_dinput_axis(sdl_dinput_t *di, unsigned port_num, const struct snes_keybind *key)
int16_t sdl_dinput_axis(sdl_dinput_t *di, unsigned port_num, const struct retro_keybind *key)
{
uint32_t joyaxis = key->joyaxis;
@ -235,7 +235,7 @@ int16_t sdl_dinput_axis(sdl_dinput_t *di, unsigned port_num, const struct snes_k
return val;
}
static bool dinput_joyaxis_pressed(sdl_dinput_t *di, unsigned port_num, const struct snes_keybind *key)
static bool dinput_joyaxis_pressed(sdl_dinput_t *di, unsigned port_num, const struct retro_keybind *key)
{
if (key->joyaxis == AXIS_NONE)
return false;
@ -246,7 +246,7 @@ static bool dinput_joyaxis_pressed(sdl_dinput_t *di, unsigned port_num, const st
return abs(val) > min;
}
bool sdl_dinput_pressed(sdl_dinput_t *di, unsigned port_num, const struct snes_keybind *key)
bool sdl_dinput_pressed(sdl_dinput_t *di, unsigned port_num, const struct retro_keybind *key)
{
if (di->joypad[port_num] == NULL)
return false;

View File

@ -231,11 +231,11 @@ static bool linuxraw_key_pressed(linuxraw_input_t *linuxraw, int key)
return linuxraw->state[keysym_lut[key]];
}
static bool linuxraw_is_pressed(linuxraw_input_t *linuxraw, const struct snes_keybind *binds, unsigned id)
static bool linuxraw_is_pressed(linuxraw_input_t *linuxraw, const struct retro_keybind *binds, unsigned id)
{
if (id < RARCH_BIND_LIST_END)
{
const struct snes_keybind *bind = &binds[id];
const struct retro_keybind *bind = &binds[id];
return bind->valid && linuxraw_key_pressed(linuxraw, binds[id].key);
}
else
@ -249,7 +249,7 @@ static bool linuxraw_bind_button_pressed(void *data, int key)
input_sdl.key_pressed(linuxraw->sdl, key);
}
static int16_t linuxraw_input_state(void *data, const struct snes_keybind **binds, unsigned port, unsigned device, unsigned index, unsigned id)
static int16_t linuxraw_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned index, unsigned id)
{
linuxraw_input_t *linuxraw = (linuxraw_input_t*)data;

View File

@ -26,10 +26,10 @@ static void null_input_poll(void *data)
(void)data;
}
static int16_t null_input_state(void *data, const struct snes_keybind **snes_keybinds, unsigned port, unsigned device, unsigned index, unsigned id)
static int16_t null_input_state(void *data, const struct retro_keybind **retro_keybinds, unsigned port, unsigned device, unsigned index, unsigned id)
{
(void)data;
(void)snes_keybinds;
(void)retro_keybinds;
(void)port;
(void)device;
(void)index;

View File

@ -38,10 +38,10 @@ sdl_dinput_t *sdl_dinput_init(void);
void sdl_dinput_free(sdl_dinput_t *di);
bool sdl_dinput_pressed(sdl_dinput_t *di, unsigned port_num,
const struct snes_keybind *key);
const struct retro_keybind *key);
int16_t sdl_dinput_axis(sdl_dinput_t *di, unsigned port_num,
const struct snes_keybind *key);
const struct retro_keybind *key);
void sdl_dinput_poll(sdl_dinput_t *di);

View File

@ -258,7 +258,7 @@ static bool sdl_axis_pressed(sdl_input_t *sdl, unsigned port_num, uint32_t joyax
}
#endif
static bool sdl_is_pressed(sdl_input_t *sdl, unsigned port_num, const struct snes_keybind *key)
static bool sdl_is_pressed(sdl_input_t *sdl, unsigned port_num, const struct retro_keybind *key)
{
if (sdl->use_keyboard && sdl_key_pressed(key->key))
return true;
@ -279,23 +279,23 @@ static bool sdl_is_pressed(sdl_input_t *sdl, unsigned port_num, const struct sne
static bool sdl_bind_button_pressed(void *data, int key)
{
const struct snes_keybind *binds = g_settings.input.binds[0];
const struct retro_keybind *binds = g_settings.input.binds[0];
if (key >= 0 && key < RARCH_BIND_LIST_END)
{
const struct snes_keybind *bind = &binds[key];
const struct retro_keybind *bind = &binds[key];
return sdl_is_pressed((sdl_input_t*)data, 0, bind);
}
else
return false;
}
static int16_t sdl_joypad_device_state(sdl_input_t *sdl, const struct snes_keybind **binds_,
static int16_t sdl_joypad_device_state(sdl_input_t *sdl, const struct retro_keybind **binds_,
unsigned port_num, unsigned id)
{
const struct snes_keybind *binds = binds_[port_num];
const struct retro_keybind *binds = binds_[port_num];
if (id < RARCH_BIND_LIST_END)
{
const struct snes_keybind *bind = &binds[id];
const struct retro_keybind *bind = &binds[id];
return bind->valid ? (sdl_is_pressed(sdl, port_num, bind) ? 1 : 0) : 0;
}
else
@ -329,10 +329,10 @@ static void conv_analog_id_to_bind_id(unsigned index, unsigned id,
}
}
static int16_t sdl_analog_device_state(sdl_input_t *sdl, const struct snes_keybind **binds_,
static int16_t sdl_analog_device_state(sdl_input_t *sdl, const struct retro_keybind **binds_,
unsigned port_num, unsigned index, unsigned id)
{
const struct snes_keybind *binds = binds_[port_num];
const struct retro_keybind *binds = binds_[port_num];
if (id >= RARCH_BIND_LIST_END)
return 0;
@ -340,8 +340,8 @@ static int16_t sdl_analog_device_state(sdl_input_t *sdl, const struct snes_keybi
unsigned id_plus = 0;
conv_analog_id_to_bind_id(index, id, &id_minus, &id_plus);
const struct snes_keybind *bind_minus = &binds[id_minus];
const struct snes_keybind *bind_plus = &binds[id_plus];
const struct retro_keybind *bind_minus = &binds[id_minus];
const struct retro_keybind *bind_plus = &binds[id_plus];
if (!bind_minus->valid || !bind_plus->valid)
return 0;
@ -405,7 +405,7 @@ static int16_t sdl_lightgun_device_state(sdl_input_t *sdl, unsigned id)
}
}
static int16_t sdl_input_state(void *data_, const struct snes_keybind **binds, unsigned port, unsigned device, unsigned index, unsigned id)
static int16_t sdl_input_state(void *data_, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned index, unsigned id)
{
sdl_input_t *data = (sdl_input_t*)data_;
switch (device)

View File

@ -169,11 +169,11 @@ static bool x_key_pressed(x11_input_t *x11, int key)
return ret;
}
static bool x_is_pressed(x11_input_t *x11, const struct snes_keybind *binds, unsigned id)
static bool x_is_pressed(x11_input_t *x11, const struct retro_keybind *binds, unsigned id)
{
if (id < RARCH_BIND_LIST_END)
{
const struct snes_keybind *bind = &binds[id];
const struct retro_keybind *bind = &binds[id];
return bind->valid && x_key_pressed(x11, binds[id].key);
}
else
@ -187,7 +187,7 @@ static bool x_bind_button_pressed(void *data, int key)
input_sdl.key_pressed(x11->sdl, key);
}
static int16_t x_input_state(void *data, const struct snes_keybind **binds, unsigned port, unsigned device, unsigned index, unsigned id)
static int16_t x_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned index, unsigned id)
{
x11_input_t *x11 = (x11_input_t*)data;

View File

@ -54,7 +54,7 @@ static void xinput2_input_poll(void *data)
}
}
static int16_t xinput2_input_state(void *data, const struct snes_keybind **binds,
static int16_t xinput2_input_state(void *data, const struct retro_keybind **binds,
unsigned port, unsigned device,
unsigned index, unsigned id)
{

View File

@ -53,9 +53,9 @@ void netplay_free(netplay_t *handle);
// On regular netplay, flip who controls player 1 and 2.
void netplay_flip_players(netplay_t *handle);
// Call this before running snes_run()
// Call this before running retro_run()
void netplay_pre_frame(netplay_t *handle);
// Call this after running snes_run()
// Call this after running retro_run()
void netplay_post_frame(netplay_t *handle);
#endif

View File

@ -174,7 +174,7 @@ static int16_t ps3_mouse_device_state(void *data, unsigned player, unsigned id)
#endif
static int16_t ps3_input_state(void *data, const struct snes_keybind **binds,
static int16_t ps3_input_state(void *data, const struct retro_keybind **binds,
unsigned port, unsigned device,
unsigned index, unsigned id)
{

View File

@ -449,7 +449,7 @@ static int16_t input_state(unsigned port, unsigned device, unsigned index, unsig
}
#endif
static const struct snes_keybind *binds[MAX_PLAYERS] = {
static const struct retro_keybind *binds[MAX_PLAYERS] = {
g_settings.input.binds[0],
g_settings.input.binds[1],
g_settings.input.binds[2],

View File

@ -203,11 +203,11 @@ void config_set_defaults(void)
g_settings.network_cmd_enable = network_cmd_enable;
g_settings.network_cmd_port = network_cmd_port;
rarch_assert(sizeof(g_settings.input.binds[0]) >= sizeof(snes_keybinds_1));
rarch_assert(sizeof(g_settings.input.binds[1]) >= sizeof(snes_keybinds_rest));
memcpy(g_settings.input.binds[0], snes_keybinds_1, sizeof(snes_keybinds_1));
rarch_assert(sizeof(g_settings.input.binds[0]) >= sizeof(retro_keybinds_1));
rarch_assert(sizeof(g_settings.input.binds[1]) >= sizeof(retro_keybinds_rest));
memcpy(g_settings.input.binds[0], retro_keybinds_1, sizeof(retro_keybinds_1));
for (unsigned i = 1; i < MAX_PLAYERS; i++)
memcpy(g_settings.input.binds[i], snes_keybinds_rest, sizeof(snes_keybinds_rest));
memcpy(g_settings.input.binds[i], retro_keybinds_rest, sizeof(retro_keybinds_rest));
// Verify that binds are in proper order.
for (int i = 0; i < MAX_PLAYERS; i++)
@ -522,7 +522,7 @@ struct bind_map
const char *key;
const char *btn;
const char *axis;
int snes_key;
int retro_key;
};
#define DECLARE_BIND(x, bind) { true, "input_" #x, "input_" #x "_btn", "input_" #x "_axis", bind }
@ -671,9 +671,9 @@ static const struct key_map sk_map[] = {
{ "nul", SK_UNKNOWN },
};
static struct snes_keybind *find_snes_bind(unsigned port, int id)
static struct retro_keybind *find_retro_bind(unsigned port, int id)
{
struct snes_keybind *binds = g_settings.input.binds[port];
struct retro_keybind *binds = g_settings.input.binds[port];
return binds[id].valid ? &binds[id] : NULL;
}
@ -696,7 +696,7 @@ static int find_sk_key(const char *str)
return find_sk_bind(str);
}
static void read_keybinds_keyboard(config_file_t *conf, unsigned player, unsigned index, struct snes_keybind *bind)
static void read_keybinds_keyboard(config_file_t *conf, unsigned player, unsigned index, struct retro_keybind *bind)
{
char tmp[64];
@ -710,7 +710,7 @@ static void read_keybinds_keyboard(config_file_t *conf, unsigned player, unsigne
}
}
static void parse_hat(struct snes_keybind *bind, const char *str)
static void parse_hat(struct retro_keybind *bind, const char *str)
{
if (!isdigit(*str))
return;
@ -738,7 +738,7 @@ static void parse_hat(struct snes_keybind *bind, const char *str)
bind->joykey = HAT_MAP(hat, hat_dir);
}
static void read_keybinds_button(config_file_t *conf, unsigned player, unsigned index, struct snes_keybind *bind)
static void read_keybinds_button(config_file_t *conf, unsigned player, unsigned index, struct retro_keybind *bind)
{
char tmp[64];
if (bind_maps[player][index].btn &&
@ -757,7 +757,7 @@ static void read_keybinds_button(config_file_t *conf, unsigned player, unsigned
}
}
static void read_keybinds_axis(config_file_t *conf, unsigned player, unsigned index, struct snes_keybind *bind)
static void read_keybinds_axis(config_file_t *conf, unsigned player, unsigned index, struct retro_keybind *bind)
{
char tmp[64];
if (bind_maps[player][index].axis &&
@ -781,7 +781,7 @@ static void read_keybinds_player(config_file_t *conf, unsigned player)
{
for (unsigned i = 0; bind_maps[player][i].valid; i++)
{
struct snes_keybind *bind = find_snes_bind(player, bind_maps[player][i].snes_key);
struct retro_keybind *bind = find_retro_bind(player, bind_maps[player][i].retro_key);
rarch_assert(bind);
read_keybinds_keyboard(conf, player, i, bind);
@ -807,7 +807,7 @@ bool config_read_keybinds(const char *path)
}
static void save_keybind_key(config_file_t *conf,
const struct bind_map *map, const struct snes_keybind *bind)
const struct bind_map *map, const struct retro_keybind *bind)
{
char ascii[2] = {0};
const char *btn = ascii;
@ -831,7 +831,7 @@ static void save_keybind_key(config_file_t *conf,
#ifndef RARCH_CONSOLE
static void save_keybind_hat(config_file_t *conf,
const struct bind_map *map, const struct snes_keybind *bind)
const struct bind_map *map, const struct retro_keybind *bind)
{
unsigned hat = GET_HAT(bind->joykey);
const char *dir = NULL;
@ -865,7 +865,7 @@ static void save_keybind_hat(config_file_t *conf,
#endif
static void save_keybind_joykey(config_file_t *conf,
const struct bind_map *map, const struct snes_keybind *bind)
const struct bind_map *map, const struct retro_keybind *bind)
{
if (bind->joykey == NO_BTN)
config_set_string(conf, map->btn, "nul");
@ -878,7 +878,7 @@ static void save_keybind_joykey(config_file_t *conf,
}
static void save_keybind_axis(config_file_t *conf,
const struct bind_map *map, const struct snes_keybind *bind)
const struct bind_map *map, const struct retro_keybind *bind)
{
unsigned axis = 0;
char dir = '\0';
@ -902,7 +902,7 @@ static void save_keybind_axis(config_file_t *conf,
}
static void save_keybind(config_file_t *conf,
const struct bind_map *map, const struct snes_keybind *bind)
const struct bind_map *map, const struct retro_keybind *bind)
{
if (!map->valid)
return;

View File

@ -32,7 +32,7 @@ static bool wpad_state[5][RARCH_FIRST_META_KEY]; /* Wii Classic pads */
static bool g_quit;
static int16_t wii_input_state(void *data, const struct snes_keybind **binds,
static int16_t wii_input_state(void *data, const struct retro_keybind **binds,
unsigned port, unsigned device,
unsigned index, unsigned id)
{