(Input) Implement function pointers 'set_rumble' and 'grab_mouse'

always to prevent conditional checks
This commit is contained in:
twinaphex 2015-03-24 07:51:50 +01:00
parent 3b87f5bb69
commit 30a0e99972
12 changed files with 156 additions and 30 deletions

View File

@ -866,6 +866,23 @@ static const rarch_joypad_driver_t *android_input_get_joypad_driver(void *data)
return android->joypad;
}
static void android_input_grab_mouse(void *data, bool state)
{
(void)data;
(void)state;
}
static bool android_input_set_rumble(void *data, unsigned port,
enum retro_rumble_effect effect, uint16_t strength)
{
(void)data;
(void)port;
(void)effect;
(void)strength;
return false;
}
input_driver_t input_android = {
android_input_init,
android_input_poll,
@ -877,7 +894,7 @@ input_driver_t input_android = {
android_input_get_capabilities,
"android_input",
NULL,
NULL,
android_input_grab_mouse,
android_input_set_rumble,
android_input_get_joypad_driver,
};

View File

@ -112,6 +112,23 @@ static const rarch_joypad_driver_t *gx_input_get_joypad_driver(void *data)
return gx->joypad;
}
static void gx_input_grab_mouse(void *data, bool state)
{
(void)data;
(void)state;
}
static bool gx_input_set_rumble(void *data, unsigned port,
enum retro_rumble_effect effect, uint16_t strength)
{
(void)data;
(void)port;
(void)effect;
(void)strength;
return false;
}
input_driver_t input_gx = {
gx_input_init,
gx_input_poll,
@ -123,7 +140,7 @@ input_driver_t input_gx = {
gx_input_get_capabilities,
"gx",
NULL,
NULL,
gx_input_grab_mouse,
gx_input_set_rumble,
gx_input_get_joypad_driver,
};

View File

@ -265,6 +265,12 @@ static uint64_t linuxraw_get_capabilities(void *data)
return caps;
}
static void linuxraw_grab_mouse(void *data, bool state)
{
(void)data;
(void)state;
}
input_driver_t input_linuxraw = {
linuxraw_input_init,
linuxraw_input_poll,
@ -275,7 +281,7 @@ input_driver_t input_linuxraw = {
NULL,
linuxraw_get_capabilities,
"linuxraw",
NULL,
linuxraw_grab_mouse,
linuxraw_set_rumble,
linuxraw_get_joypad_driver,
};

View File

@ -69,6 +69,23 @@ static bool nullinput_set_sensor_state(void *data,
return false;
}
static void nullinput_grab_mouse(void *data, bool state)
{
(void)data;
(void)state;
}
static bool nullinput_set_rumble(void *data, unsigned port,
enum retro_rumble_effect effect, uint16_t strength)
{
(void)data;
(void)port;
(void)effect;
(void)strength;
return false;
}
input_driver_t input_null = {
nullinput_input_init,
nullinput_input_poll,
@ -79,4 +96,6 @@ input_driver_t input_null = {
NULL,
nullinput_get_capabilities,
"null",
nullinput_grab_mouse,
nullinput_set_rumble,
};

View File

@ -241,6 +241,12 @@ static const rarch_joypad_driver_t *ps3_input_get_joypad_driver(void *data)
return NULL;
}
static void ps3_input_grab_mouse(void *data, bool state)
{
(void)data;
(void)state;
}
input_driver_t input_ps3 = {
ps3_input_init,
ps3_input_poll,
@ -252,7 +258,7 @@ input_driver_t input_ps3 = {
ps3_input_get_capabilities,
"ps3",
NULL,
ps3_input_grab_mouse,
ps3_input_set_rumble,
ps3_input_get_joypad_driver,
};

View File

@ -117,6 +117,23 @@ static const rarch_joypad_driver_t *psp_input_get_joypad_driver(void *data)
return NULL;
}
static void psp_input_grab_mouse(void *data, bool state)
{
(void)data;
(void)state;
}
static bool psp_input_set_rumble(void *data, unsigned port,
enum retro_rumble_effect effect, uint16_t strength)
{
(void)data;
(void)port;
(void)effect;
(void)strength;
return false;
}
input_driver_t input_psp = {
psp_input_initialize,
psp_input_poll,
@ -128,7 +145,7 @@ input_driver_t input_psp = {
psp_input_get_capabilities,
"psp",
NULL,
NULL,
psp_input_grab_mouse,
psp_input_set_mouse,
psp_input_get_joypad_driver,
};

View File

@ -833,6 +833,23 @@ static const rarch_joypad_driver_t *qnx_input_get_joypad_driver(void *data)
return qnx->joypad;
}
static void qnx_input_grab_mouse(void *data, bool state)
{
(void)data;
(void)state;
}
static bool qnx_input_set_rumble(void *data, unsigned port,
enum retro_rumble_effect effect, uint16_t strength)
{
(void)data;
(void)port;
(void)effect;
(void)strength;
return false;
}
input_driver_t input_qnx = {
qnx_input_init,
qnx_input_poll,
@ -843,7 +860,7 @@ input_driver_t input_qnx = {
NULL,
qnx_input_get_capabilities,
"qnx_input",
NULL,
NULL,
qnx_input_grab_mouse,
qnx_input_set_rumble,
qnx_input_get_joypad_driver,
};

View File

@ -188,6 +188,17 @@ static void rwebinput_grab_mouse(void *data, bool state)
(void)state;
}
static bool rwebinput_set_rumble(void *data, unsigned port,
enum retro_rumble_effect effect, uint16_t strength)
{
(void)data;
(void)port;
(void)effect;
(void)strength;
return false;
}
static uint64_t rwebinput_get_capabilities(void *data)
{
uint64_t caps = 0;
@ -211,4 +222,5 @@ input_driver_t input_rwebinput = {
rwebinput_get_capabilities,
"rwebinput",
rwebinput_grab_mouse,
rwebinput_set_rumble,
};

View File

@ -263,9 +263,9 @@ static void sdl_input_free(void *data)
free(data);
}
#ifdef HAVE_SDL2
static void sdl_grab_mouse(void *data, bool state)
{
#ifdef HAVE_SDL2
struct temp{
SDL_Window *w;
};
@ -278,8 +278,8 @@ static void sdl_grab_mouse(void *data, bool state)
/* First member of sdl2_video_t is the window */
SDL_SetWindowGrab(((struct temp*)driver->video_data)->w,
state ? SDL_TRUE : SDL_FALSE);
}
#endif
}
static bool sdl_set_rumble(void *data, unsigned port,
enum retro_rumble_effect effect, uint16_t strength)
@ -391,11 +391,10 @@ input_driver_t input_sdl = {
sdl_get_capabilities,
#ifdef HAVE_SDL2
"sdl2",
sdl_grab_mouse,
#else
"sdl",
NULL,
#endif
sdl_grab_mouse,
sdl_set_rumble,
sdl_get_joypad_driver,
};

View File

@ -145,6 +145,12 @@ static const rarch_joypad_driver_t *xdk_input_get_joypad_driver(void *data)
return xdk->joypad;
}
static void xdk_input_grab_mouse(void *data, bool state)
{
(void)data;
(void)state;
}
input_driver_t input_xinput = {
xdk_input_init,
xdk_input_poll,
@ -155,8 +161,7 @@ input_driver_t input_xinput = {
NULL,
xdk_input_get_capabilities,
"xinput",
NULL,
xdk_input_grab_mouse,
xdk_input_set_rumble,
xdk_input_get_joypad_driver,
};

View File

@ -102,6 +102,23 @@ static uint64_t xenon360_get_capabilities(void *data)
return caps;
}
static void xenon360_input_grab_mouse(void *data, bool state)
{
(void)data;
(void)state;
}
static bool xenon360_input_set_rumble(void *data, unsigned port,
enum retro_rumble_effect effect, uint16_t strength)
{
(void)data;
(void)port;
(void)effect;
(void)strength;
return false;
}
input_driver_t input_xenon360 = {
xenon360_input_init,
xenon360_input_poll,
@ -113,4 +130,6 @@ input_driver_t input_xenon360 = {
NULL,
xenon360_input_get_capabilities,
"xenon360",
xenon360_input_grab_mouse,
xenon360_input_set_rumble,
};

View File

@ -181,7 +181,7 @@ bool input_driver_set_rumble_state(unsigned port,
enum retro_rumble_effect effect, uint16_t strength)
{
driver_t *driver = driver_get_ptr();
if (driver->input && driver->input_data && driver->input->set_rumble)
if (driver->input && driver->input_data)
return driver->input->set_rumble(driver->input_data,
port, effect, strength);
return false;
@ -219,9 +219,7 @@ int16_t input_driver_state(const struct retro_keybind **retro_keybinds,
unsigned port, unsigned device, unsigned index, unsigned id)
{
driver_t *driver = driver_get_ptr();
if (driver->input
&& driver->input_data
&& driver->input->input_state)
if (driver->input && driver->input_data)
return driver->input->input_state(driver->input_data, retro_keybinds,
port, device, index, id);
return 0;
@ -230,9 +228,7 @@ int16_t input_driver_state(const struct retro_keybind **retro_keybinds,
void input_driver_poll(void)
{
driver_t *driver = driver_get_ptr();
if (driver->input
&& driver->input_data
&& driver->input->poll)
if (driver->input && driver->input_data)
driver->input->poll(driver->input_data);
}
@ -240,9 +236,7 @@ bool input_driver_key_pressed(int key)
{
driver_t *driver = driver_get_ptr();
if (driver
&& driver->input
&& driver->input->key_pressed)
if (driver && driver->input)
return driver->input->key_pressed(driver->input_data, key);
return false;
}
@ -262,7 +256,7 @@ uint64_t input_driver_get_capabilities(void)
{
driver_t *driver = driver_get_ptr();
if (driver && driver->input && driver->input->get_capabilities)
if (driver && driver->input)
return driver->input->get_capabilities(driver->input_data);
return 0;
}
@ -271,9 +265,7 @@ bool input_driver_grab_mouse(bool state)
{
driver_t *driver = driver_get_ptr();
if (driver
&& driver->input
&& driver->input->grab_mouse)
if (driver && driver->input)
{
driver->input->grab_mouse(driver->input_data, state);
return true;