mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-24 21:50:44 +00:00
Refactor of driver function hooks
This commit is contained in:
parent
8a3a7572b4
commit
966cc93b5e
@ -231,7 +231,7 @@ static void setup_keycode_lut(void)
|
||||
keycode_lut[AKEYCODE_F9] = (1ULL << RARCH_MUTE);
|
||||
}
|
||||
|
||||
static void *android_input_initialize(void)
|
||||
static void *android_input_init(void)
|
||||
{
|
||||
pads_connected = 0;
|
||||
|
||||
@ -388,17 +388,17 @@ static bool android_input_key_pressed(void *data, int key)
|
||||
return false;
|
||||
}
|
||||
|
||||
static void android_input_free(void *data)
|
||||
static void android_input_free_input(void *data)
|
||||
{
|
||||
(void)data;
|
||||
}
|
||||
|
||||
const input_driver_t input_android = {
|
||||
android_input_initialize,
|
||||
android_input_init,
|
||||
android_input_poll,
|
||||
android_input_state,
|
||||
android_input_key_pressed,
|
||||
android_input_free,
|
||||
android_input_free_input,
|
||||
"android_input",
|
||||
};
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
#define context_swap_interval_func(var) eglSwapInterval(g_egl_dpy, var)
|
||||
#define context_has_focus_func() (true)
|
||||
#define context_check_window_func(quit, resize, width, height, frame_count) gfx_ctx_check_window(quit, resize, width, height, frame_count)
|
||||
#define context_set_video_mode_func(width, height, force_16bit, fullscreen) gfx_ctx_set_video_mode(width, height, force_16bit, fullscreen)
|
||||
#define context_set_video_mode_func(width, height, fullscreen) gfx_ctx_set_video_mode(width, height, fullscreen)
|
||||
#define context_input_driver_func(input, input_data) gl->ctx_driver->input_driver(input, input_data)
|
||||
#endif
|
||||
|
||||
|
124
driver_funcs.h
124
driver_funcs.h
@ -94,137 +94,79 @@ static inline bool input_key_pressed_func(int key)
|
||||
VIDEO
|
||||
============================================================ */
|
||||
|
||||
#define CONCAT2(A, B) A##B
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) /* GL */
|
||||
#define video_init_func(video_info, input, input_data) gl_init(video_info, input, input_data)
|
||||
#define video_frame_func(data, width, height, pitch, msg) \
|
||||
gl_frame(driver.video_data, data, width, height, pitch, msg)
|
||||
#define video_set_nonblock_state_func(state) driver.video->set_nonblock_state(driver.video_data, state)
|
||||
#define video_alive_func() gl_alive(driver.video_data)
|
||||
#define video_focus_func() gl_focus(driver.video_data)
|
||||
#define video_xml_shader_func(path) driver.video->xml_shader(driver.video_data, path)
|
||||
#define video_free_func() gl_free(driver.video_data)
|
||||
#define video_set_rotation_func(rotation) gl_set_rotation(driver.video_data, rotation)
|
||||
#define MAKENAME_VIDEO(A) CONCAT2(gl, A)
|
||||
|
||||
#define video_set_aspect_ratio_func(aspectratio_idx) gfx_ctx_set_aspect_ratio(driver.video_data, aspectratio_idx)
|
||||
#define video_stop_func() gl_stop()
|
||||
#define video_start_func() gl_start()
|
||||
#define video_set_shader_func(type, path) gl_set_shader(driver.video_data, type, path)
|
||||
|
||||
#define gfx_ctx_window_has_focus() (true)
|
||||
|
||||
#elif defined(_XBOX) && (defined(HAVE_D3D8) || defined(HAVE_D3D9)) /* D3D */
|
||||
#define MAKENAME_VIDEO(A) CONCAT2(xdk_d3d, A)
|
||||
|
||||
#define video_init_func(video_info, input, input_data) xdk_d3d_init(video_info, input, input_data)
|
||||
#define video_frame_func(data, width, height, pitch, msg) \
|
||||
xdk_d3d_frame(driver.video_data, data, width, height, pitch, msg)
|
||||
#define video_set_nonblock_state_func(state) driver.video->set_nonblock_state(driver.video_data, state)
|
||||
#define video_alive_func() xdk_d3d_alive(driver.video_data)
|
||||
#define video_focus_func() xdk_d3d_focus(driver.video_data)
|
||||
#define video_xml_shader_func(path) driver.video->xml_shader(driver.video_data, path)
|
||||
#define video_free_func() xdk_d3d_free(driver.video_data)
|
||||
#define video_set_rotation_func(rotation) xdk_d3d_set_rotation(driver.video_data, rotation)
|
||||
#define video_set_aspect_ratio_func(aspectratio_idx) gfx_ctx_set_aspect_ratio(driver.video_data, aspectratio_idx)
|
||||
#define video_stop_func() xdk_d3d_stop()
|
||||
#define video_start_func() xdk_d3d_start()
|
||||
|
||||
#define gfx_ctx_window_has_focus() (true)
|
||||
|
||||
#elif defined(GEKKO) /* Gamecube, Wii */
|
||||
#define MAKENAME_VIDEO(A) CONCAT2(gx, A)
|
||||
|
||||
#define video_init_func(video_info, input, input_data) gx_init(video_info, input, input_data)
|
||||
#define video_frame_func(data, width, height, pitch, msg) \
|
||||
gx_frame(driver.video_data, data, width, height, pitch, msg)
|
||||
#define video_set_nonblock_state_func(state) gx_set_nonblock_state(driver.video_data, state)
|
||||
#define video_alive_func() gx_alive(driver.video_data)
|
||||
#define video_focus_func() gx_focus(driver.video_data)
|
||||
#define video_xml_shader_func(path) driver.video->xml_shader(driver.video_data, path)
|
||||
#define video_free_func() gx_free(driver.video_data)
|
||||
#define video_set_rotation_func(orientation) gx_set_rotation(driver.video_data, orientation)
|
||||
#define video_set_aspect_ratio_func(aspectratio_idx) gx_set_aspect_ratio(driver.video_data, aspectratio_idx)
|
||||
#define video_stop_func() gx_stop()
|
||||
#define video_start_func() gx_start()
|
||||
#define video_viewport_size_func(width, height) ((void)0)
|
||||
#define video_viewport_info_func(info) ((void)0)
|
||||
#define video_read_viewport_func(buffer) (false)
|
||||
|
||||
#elif defined(PSP) /* PSP1 */
|
||||
#define video_init_func(video_info, input, input_data) psp_gfx_init(video_info, input, input_data)
|
||||
#define video_frame_func(data, width, height, pitch, msg) \
|
||||
psp_gfx_frame(driver.video_data, data, width, height, pitch, msg)
|
||||
#define video_set_nonblock_state_func(state) psp_gfx_set_nonblock_state(driver.video_data, state)
|
||||
#define video_alive_func() psp_gfx_alive(driver.video_data)
|
||||
#define video_focus_func() psp_gfx_focus(driver.video_data)
|
||||
#define video_xml_shader_func(path) driver.video->xml_shader(driver.video_data, path)
|
||||
#define video_free_func() psp_gfx_free(driver.video_data)
|
||||
#define video_set_rotation_func(orientation) (true)
|
||||
#define MAKENAME_VIDEO(A) CONCAT2(psp, A)
|
||||
#define video_set_aspect_ratio_func(aspectratio_idx) (true)
|
||||
#define video_stop_func() psp_gfx_stop()
|
||||
#define video_start_func() psp_gfx_start()
|
||||
|
||||
#else /* NULL */
|
||||
#define video_init_func(video_info, input, input_data) null_gfx_init(video_info, input, input_data)
|
||||
#define video_frame_func(data, width, height, pitch, msg) \
|
||||
null_gfx_frame(driver.video_data, data, width, height, pitch, msg)
|
||||
#define video_set_nonblock_state_func(state) null_gfx_set_nonblock_state(driver.video_data, state)
|
||||
#define video_alive_func() null_gfx_alive(driver.video_data)
|
||||
#define video_focus_func() null_gfx_focus(driver.video_data)
|
||||
#define video_xml_shader_func(path) driver.video->xml_shader(driver.video_data, path)
|
||||
#define video_free_func() null_gfx_free(driver.video_data)
|
||||
#define video_set_rotation_func(orientation) (true)
|
||||
#define MAKENAME_VIDEO(A) CONCAT2(nullvideo, A)
|
||||
|
||||
#define video_set_aspect_ratio_func(aspectratio_idx) (true)
|
||||
#define video_stop_func() null_gfx_stop()
|
||||
#define video_start_func() null_gfx_start()
|
||||
|
||||
#endif
|
||||
|
||||
#define video_init_func(video_info, input, input_data) MAKENAME_VIDEO(_init)(video_info, input, input_data)
|
||||
#define video_frame_func(data, width, height, pitch, msg) \
|
||||
MAKENAME_VIDEO(_frame)(driver.video_data, data, width, height, pitch, msg)
|
||||
#define video_alive_func() MAKENAME_VIDEO(_alive)(driver.video_data)
|
||||
#define video_focus_func() MAKENAME_VIDEO(_focus)(driver.video_data)
|
||||
#define video_free_func() MAKENAME_VIDEO(_free)(driver.video_data)
|
||||
#define video_set_nonblock_state_func(state) MAKENAME_VIDEO(_set_nonblock_state)(driver.video_data, state)
|
||||
#define video_set_rotation_func(rotation) MAKENAME_VIDEO(_set_rotation)(driver.video_data, rotation)
|
||||
#define video_stop_func() MAKENAME_VIDEO(_stop)()
|
||||
#define video_start_func() MAKENAME_VIDEO(_start)()
|
||||
#define video_set_shader_func(type, path) MAKENAME_VIDEO(_set_shader)(driver.video_data, type, path)
|
||||
#define video_xml_shader_func(path) driver.video->xml_shader(driver.video_data, path)
|
||||
|
||||
/*============================================================
|
||||
INPUT
|
||||
============================================================ */
|
||||
|
||||
#if defined(_XBOX) && (defined(HAVE_D3D8) || defined(HAVE_D3D9)) /* D3D */
|
||||
|
||||
#define input_init_func() xinput_input_init()
|
||||
#define input_poll_func() xinput_input_poll(driver.input_data)
|
||||
#define input_input_state_func(retro_keybinds, port, device, index, id) \
|
||||
xinput_input_state(driver.input_data, retro_keybinds, port, device, index, id)
|
||||
#define input_key_pressed_func(key) xinput_input_key_pressed(driver.input_data, key)
|
||||
#define input_free_func() xinput_input_free_input(driver.input_data)
|
||||
|
||||
#elif defined(GEKKO) /* Gamecube, Wii */
|
||||
|
||||
#define input_init_func() gx_input_initialize()
|
||||
#define input_poll_func() gx_input_poll(driver.input_data)
|
||||
#define input_input_state_func(retro_keybinds, port, device, index, id) \
|
||||
gx_input_state(driver.input_data, retro_keybinds, port, device, index, id)
|
||||
#define input_key_pressed_func(key) gx_key_pressed(driver.input_data, key)
|
||||
#define input_free_func() gx_free_input(driver.input_data)
|
||||
#define MAKENAME_INPUT(A) CONCAT2(gx, A)
|
||||
#define gfx_ctx_window_has_focus() (true)
|
||||
|
||||
#elif defined(__CELLOS_LV2__) /* PS3 */
|
||||
#define input_init_func() ps3_input_initialize()
|
||||
#define input_poll_func() ps3_input_poll(driver.input_data)
|
||||
#define input_input_state_func(retro_keybinds, port, device, index, id) \
|
||||
ps3_input_state(driver.input_data, retro_keybinds, port, device, index, id)
|
||||
#define input_key_pressed_func(key) ps3_key_pressed(driver.input_data, key)
|
||||
#define input_free_func() ps3_free_input(driver.input_data)
|
||||
|
||||
#define MAKENAME_INPUT(A) CONCAT2(ps3, A)
|
||||
#elif defined(ANDROID) /* ANDROID */
|
||||
#define input_init_func() android_input_initialize()
|
||||
#define input_poll_func() android_input_poll(driver.input_data)
|
||||
#define input_input_state_func(retro_keybinds, port, device, index, id) \
|
||||
android_input_state(driver.input_data, retro_keybinds, port, device, index, id)
|
||||
#define input_key_pressed_func(key) android_input_key_pressed(driver.input_data, key)
|
||||
#define input_free_func() android_input_free(driver.input_data)
|
||||
#define MAKENAME_INPUT(A) CONCAT2(android, A)
|
||||
#else
|
||||
#define MAKENAME_INPUT(A) CONCAT2(nullinput, A)
|
||||
#endif
|
||||
|
||||
#define input_init_func() null_input_init()
|
||||
#define input_poll_func() null_input_poll(driver.input_data)
|
||||
#define input_input_state_func(retro_keybinds, port, device, index, id) \
|
||||
null_input_state(driver.input_data, retro_keybinds, port, device, index, id)
|
||||
#define input_key_pressed_func(key) null_input_key_pressed(driver.input_data, key)
|
||||
#define input_free_func() null_input_free(driver.input_data)
|
||||
#define gfx_ctx_window_has_focus() (true)
|
||||
|
||||
#endif
|
||||
#define input_init_func() MAKENAME_INPUT(_input_init)()
|
||||
#define input_poll_func() MAKENAME_INPUT(_input_poll)(driver.input_data)
|
||||
#define input_input_state_func(retro_keybinds, port, device, index, id) \
|
||||
MAKENAME_INPUT(_input_state)(driver.input_data, retro_keybinds, port, device, index, id)
|
||||
#define input_key_pressed_func(key) MAKENAME_INPUT(_input_key_pressed)(driver.input_data, key)
|
||||
#define input_free_func() MAKENAME_INPUT(_input_free_input)(driver.input_data)
|
||||
|
||||
#endif
|
||||
|
||||
|
32
input/null.c
32
input/null.c
@ -16,17 +16,17 @@
|
||||
#include "../general.h"
|
||||
#include "../driver.h"
|
||||
|
||||
static void *null_input_init(void)
|
||||
static void *nullinput_input_init(void)
|
||||
{
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
static void null_input_poll(void *data)
|
||||
static void nullinput_input_poll(void *data)
|
||||
{
|
||||
(void)data;
|
||||
}
|
||||
|
||||
static int16_t null_input_state(void *data, const struct retro_keybind **retro_keybinds, unsigned port, unsigned device, unsigned index, unsigned id)
|
||||
static int16_t nullinput_input_state(void *data, const struct retro_keybind **retro_keybinds, unsigned port, unsigned device, unsigned index, unsigned id)
|
||||
{
|
||||
(void)data;
|
||||
(void)retro_keybinds;
|
||||
@ -38,7 +38,7 @@ static int16_t null_input_state(void *data, const struct retro_keybind **retro_k
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool null_input_key_pressed(void *data, int key)
|
||||
static bool nullinput_input_key_pressed(void *data, int key)
|
||||
{
|
||||
(void)data;
|
||||
(void)key;
|
||||
@ -46,38 +46,38 @@ static bool null_input_key_pressed(void *data, int key)
|
||||
return false;
|
||||
}
|
||||
|
||||
static void null_input_free(void *data)
|
||||
static void nullinput_input_free_input(void *data)
|
||||
{
|
||||
(void)data;
|
||||
}
|
||||
|
||||
#ifdef RARCH_CONSOLE
|
||||
static void null_set_default_keybind_lut(unsigned device, unsigned port)
|
||||
static void nullinput_set_default_keybind_lut(unsigned device, unsigned port)
|
||||
{
|
||||
(void)device;
|
||||
(void)port;
|
||||
}
|
||||
|
||||
static void null_set_analog_dpad_mapping(unsigned device, unsigned map_dpad_enum, unsigned controller_id)
|
||||
static void nullinput_set_analog_dpad_mapping(unsigned device, unsigned map_dpad_enum, unsigned controller_id)
|
||||
{
|
||||
(void)device;
|
||||
(void)map_dpad_enum;
|
||||
(void)controller_id;
|
||||
}
|
||||
|
||||
static void null_input_post_init(void) {}
|
||||
static void nullinput_input_post_init(void) {}
|
||||
#endif
|
||||
|
||||
const input_driver_t input_null = {
|
||||
null_input_init,
|
||||
null_input_poll,
|
||||
null_input_state,
|
||||
null_input_key_pressed,
|
||||
null_input_free,
|
||||
nullinput_input_init,
|
||||
nullinput_input_poll,
|
||||
nullinput_input_state,
|
||||
nullinput_input_key_pressed,
|
||||
nullinput_input_free_input,
|
||||
#ifdef RARCH_CONSOLE
|
||||
null_set_default_keybind_lut,
|
||||
null_set_analog_dpad_mapping,
|
||||
null_input_post_init,
|
||||
nullinput_set_default_keybind_lut,
|
||||
nullinput_set_analog_dpad_mapping,
|
||||
nullinput_input_post_init,
|
||||
2,
|
||||
#endif
|
||||
"null",
|
||||
|
@ -400,13 +400,13 @@ static void ps3_input_set_analog_dpad_mapping(unsigned device, unsigned map_dpad
|
||||
}
|
||||
}
|
||||
|
||||
static void ps3_free_input(void *data)
|
||||
static void ps3_input_free_input(void *data)
|
||||
{
|
||||
(void)data;
|
||||
//cellPadEnd();
|
||||
}
|
||||
|
||||
static void* ps3_input_initialize(void)
|
||||
static void* ps3_input_init(void)
|
||||
{
|
||||
cellPadInit(MAX_PADS);
|
||||
#ifdef HAVE_MOUSE
|
||||
@ -423,7 +423,7 @@ static void ps3_input_post_init(void)
|
||||
ps3_input_set_analog_dpad_mapping(STUB_DEVICE, g_settings.input.dpad_emulation[i], i);
|
||||
}
|
||||
|
||||
static bool ps3_key_pressed(void *data, int key)
|
||||
static bool ps3_input_key_pressed(void *data, int key)
|
||||
{
|
||||
(void)data;
|
||||
#ifdef HAVE_OPENGL
|
||||
@ -502,11 +502,11 @@ static void ps3_set_default_keybind_lut(unsigned device, unsigned port)
|
||||
}
|
||||
|
||||
const input_driver_t input_ps3 = {
|
||||
.init = ps3_input_initialize,
|
||||
.init = ps3_input_init,
|
||||
.poll = ps3_input_poll,
|
||||
.input_state = ps3_input_state,
|
||||
.key_pressed = ps3_key_pressed,
|
||||
.free = ps3_free_input,
|
||||
.key_pressed = ps3_input_key_pressed,
|
||||
.free = ps3_input_free_input,
|
||||
.set_default_keybind_lut = ps3_set_default_keybind_lut,
|
||||
.set_analog_dpad_mapping = ps3_input_set_analog_dpad_mapping,
|
||||
.post_init = ps3_input_post_init,
|
||||
|
@ -79,7 +79,7 @@ static void init_texture(void *data, const video_info_t *video)
|
||||
vid->rgb32 = video->rgb32;
|
||||
}
|
||||
|
||||
static void *psp_gfx_init(const video_info_t *video,
|
||||
static void *psp_init(const video_info_t *video,
|
||||
const input_driver_t **input, void **input_data)
|
||||
{
|
||||
*input = NULL;
|
||||
@ -112,7 +112,7 @@ error:
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
static bool psp_gfx_frame(void *data, const void *frame,
|
||||
static bool psp_frame(void *data, const void *frame,
|
||||
unsigned width, unsigned height, unsigned pitch, const char *msg)
|
||||
{
|
||||
(void)width;
|
||||
@ -153,25 +153,25 @@ static bool psp_gfx_frame(void *data, const void *frame,
|
||||
return true;
|
||||
}
|
||||
|
||||
static void psp_gfx_set_nonblock_state(void *data, bool toggle)
|
||||
static void psp_set_nonblock_state(void *data, bool toggle)
|
||||
{
|
||||
(void)data;
|
||||
(void)toggle;
|
||||
}
|
||||
|
||||
static bool psp_gfx_alive(void *data)
|
||||
static bool psp_alive(void *data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool psp_gfx_focus(void *data)
|
||||
static bool psp_focus(void *data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void psp_gfx_free(void *data)
|
||||
static void psp_free(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
@ -179,25 +179,33 @@ static void psp_gfx_free(void *data)
|
||||
}
|
||||
|
||||
#ifdef RARCH_CONSOLE
|
||||
static void psp_gfx_start(void) {}
|
||||
static void psp_gfx_restart(void) {}
|
||||
static void psp_gfx_stop(void) {}
|
||||
static void psp_start(void) {}
|
||||
static void psp_restart(void) {}
|
||||
static void psp_stop(void) {}
|
||||
#endif
|
||||
|
||||
static void psp_set_rotation(void *data, unsigned rotation)
|
||||
{
|
||||
}
|
||||
|
||||
const video_driver_t video_psp1 = {
|
||||
psp_gfx_init,
|
||||
psp_gfx_frame,
|
||||
psp_gfx_set_nonblock_state,
|
||||
psp_gfx_alive,
|
||||
psp_gfx_focus,
|
||||
psp_init,
|
||||
psp_frame,
|
||||
psp_set_nonblock_state,
|
||||
psp_alive,
|
||||
psp_focus,
|
||||
NULL,
|
||||
psp_gfx_free,
|
||||
psp_free,
|
||||
"psp1",
|
||||
|
||||
#ifdef RARCH_CONSOLE
|
||||
psp_gfx_start,
|
||||
psp_gfx_stop,
|
||||
psp_gfx_restart,
|
||||
psp_start,
|
||||
psp_stop,
|
||||
psp_restart,
|
||||
NULL,
|
||||
NULL,
|
||||
#endif
|
||||
|
||||
psp_set_rotation,
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user