mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
Refactor joypad drivers
This commit is contained in:
parent
721b3039e4
commit
5f08605680
@ -140,18 +140,18 @@ void d3d_input_driver(const char* input_name, const char* joypad_name,
|
||||
* supports joypad only (uwp driver was added later) */
|
||||
if (string_is_equal(input_name, "xinput"))
|
||||
{
|
||||
void *xinput = input_xinput.init(joypad_name);
|
||||
void *xinput = input_driver_init_wrap(&input_xinput, joypad_name);
|
||||
*input = xinput ? (input_driver_t*)&input_xinput : NULL;
|
||||
*input_data = xinput;
|
||||
}
|
||||
else
|
||||
{
|
||||
void *uwp = input_uwp.init(joypad_name);
|
||||
void *uwp = input_driver_init_wrap(&input_uwp, joypad_name);
|
||||
*input = uwp ? (input_driver_t*)&input_uwp : NULL;
|
||||
*input_data = uwp;
|
||||
}
|
||||
#elif defined(_XBOX)
|
||||
void *xinput = input_xinput.init(joypad_name);
|
||||
void *xinput = input_driver_init_wrap(&input_xinput, joypad_name);
|
||||
*input = xinput ? (input_driver_t*)&input_xinput : NULL;
|
||||
*input_data = xinput;
|
||||
#else
|
||||
@ -160,7 +160,7 @@ void d3d_input_driver(const char* input_name, const char* joypad_name,
|
||||
/* winraw only available since XP */
|
||||
if (string_is_equal(input_name, "raw"))
|
||||
{
|
||||
*input_data = input_winraw.init(joypad_name);
|
||||
*input_data = input_driver_init_wrap(&input_winraw, joypad_name);
|
||||
if (*input_data)
|
||||
{
|
||||
*input = &input_winraw;
|
||||
@ -171,7 +171,7 @@ void d3d_input_driver(const char* input_name, const char* joypad_name,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DINPUT
|
||||
*input_data = input_dinput.init(joypad_name);
|
||||
*input_data = input_driver_init_wrap(&input_dinput, joypad_name);
|
||||
*input = *input_data ? &input_dinput : NULL;
|
||||
#endif
|
||||
#endif
|
||||
|
@ -482,7 +482,7 @@ static void* ctr_init(const video_info_t* video,
|
||||
|
||||
if (input && input_data)
|
||||
{
|
||||
ctrinput = input_ctr.init(settings->arrays.input_joypad_driver);
|
||||
ctrinput = input_driver_init_wrap(&input_ctr, settings->arrays.input_joypad_driver);
|
||||
*input = ctrinput ? &input_ctr : NULL;
|
||||
*input_data = ctrinput;
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ static void* gcm_init(const video_info_t* video,
|
||||
|
||||
if (input && input_data)
|
||||
{
|
||||
void *ps3input = input_ps3.init(ps3_joypad.ident);
|
||||
void *ps3input = input_driver_init_wrap(&input_ps3, ps3_joypad.ident);
|
||||
*input = ps3input ? &input_ps3 : NULL;
|
||||
*input_data = ps3input;
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ static void gfx_ctx_gdi_input_driver(
|
||||
/* winraw only available since XP */
|
||||
if (string_is_equal(settings->arrays.input_driver, "raw"))
|
||||
{
|
||||
*input_data = input_winraw.init(settings->arrays.input_driver);
|
||||
*input_data = input_driver_init_wrap(&input_winraw, settings->arrays.input_driver);
|
||||
if (*input_data)
|
||||
{
|
||||
*input = &input_winraw;
|
||||
@ -160,7 +160,7 @@ static void gfx_ctx_gdi_input_driver(
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DINPUT
|
||||
dinput_gdi = input_dinput.init(settings->arrays.input_driver);
|
||||
dinput_gdi = input_driver_init_wrap(&input_dinput, settings->arrays.input_driver);
|
||||
*input = dinput_gdi ? &input_dinput : NULL;
|
||||
#else
|
||||
dinput_gdi = NULL;
|
||||
|
@ -204,7 +204,7 @@ static void *wiiu_gfx_init(const video_info_t *video,
|
||||
|
||||
if (input && input_data)
|
||||
{
|
||||
wiiuinput = input_wiiu.init(input_joypad_driver);
|
||||
wiiuinput = input_driver_init_wrap(&input_wiiu, input_joypad_driver);
|
||||
*input = wiiuinput ? &input_wiiu : NULL;
|
||||
*input_data = wiiuinput;
|
||||
}
|
||||
|
@ -793,7 +793,7 @@ static void *gx_init(const video_info_t *video,
|
||||
if (!gx)
|
||||
return NULL;
|
||||
|
||||
gxinput = input_gx.init(input_joypad_driver);
|
||||
gxinput = input_driver_init_wrap(&input_gx, input_joypad_driver);
|
||||
*input = gxinput ? &input_gx : NULL;
|
||||
*input_data = gxinput;
|
||||
|
||||
|
@ -69,7 +69,7 @@ static void gfx_ctx_network_input_driver(
|
||||
input_driver_t **input, void **input_data)
|
||||
{
|
||||
#ifdef HAVE_UDEV
|
||||
*input_data = input_udev.init(joypad_driver);
|
||||
*input_data = input_driver_init_wrap(&input_udev, joypad_driver);
|
||||
|
||||
if (*input_data)
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ static void *oga_gfx_init(const video_info_t *video,
|
||||
|
||||
if (input && input_data)
|
||||
{
|
||||
void* udev = input_udev.init(settings->arrays.input_joypad_driver);
|
||||
void* udev = input_driver_init_wrap(&input_udev, settings->arrays.input_joypad_driver);
|
||||
if (udev)
|
||||
{
|
||||
*input = &input_udev;
|
||||
|
@ -251,7 +251,7 @@ static void *ps2_gfx_init(const video_info_t *video,
|
||||
if (input && input_data)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
ps2input = input_ps2.init(
|
||||
ps2input = input_driver_init_wrap(&input_ps2,
|
||||
settings->arrays.input_joypad_driver);
|
||||
*input = ps2input ? &input_ps2 : NULL;
|
||||
*input_data = ps2input;
|
||||
|
@ -534,7 +534,7 @@ static void *psp_init(const video_info_t *video,
|
||||
if (input && input_data)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
pspinput = input_psp.init(
|
||||
pspinput = input_driver_init_wrap(&input_psp,
|
||||
settings->arrays.input_joypad_driver);
|
||||
*input = pspinput ? &input_psp : NULL;
|
||||
*input_data = pspinput;
|
||||
|
@ -108,7 +108,8 @@ static void *sdl_dingux_gfx_init(const video_info_t *video,
|
||||
|
||||
if (input && input_data)
|
||||
{
|
||||
void *sdl_input = input_sdl.init(settings->arrays.input_joypad_driver);
|
||||
void *sdl_input = input_driver_init_wrap(&input_sdl,
|
||||
settings->arrays.input_joypad_driver);
|
||||
|
||||
if (sdl_input)
|
||||
{
|
||||
|
@ -300,7 +300,8 @@ static void *sdl_gfx_init(const video_info_t *video,
|
||||
|
||||
if (input && input_data)
|
||||
{
|
||||
void *sdl_input = input_sdl.init(settings->arrays.input_joypad_driver);
|
||||
void *sdl_input = input_driver_init_wrap(&input_sdl,
|
||||
settings->arrays.input_joypad_driver);
|
||||
|
||||
if (sdl_input)
|
||||
{
|
||||
|
@ -221,7 +221,8 @@ static void *sixel_gfx_init(const video_info_t *video,
|
||||
}
|
||||
|
||||
#ifdef HAVE_UDEV
|
||||
*input_data = input_udev.init(settings->arrays.input_driver);
|
||||
*input_data = input_driver_init_wrap(&input_udev,
|
||||
settings->arrays.input_driver);
|
||||
|
||||
if (*input_data)
|
||||
*input = &input_udev;
|
||||
|
@ -210,9 +210,10 @@ static void *switch_init(const video_info_t *video,
|
||||
if (input && input_data)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
switchinput = input_switch.init(settings->arrays.input_joypad_driver);
|
||||
*input = switchinput ? &input_switch : NULL;
|
||||
*input_data = switchinput;
|
||||
switchinput = input_driver_init_wrap(&input_switch,
|
||||
settings->arrays.input_joypad_driver);
|
||||
*input = switchinput ? &input_switch : NULL;
|
||||
*input_data = switchinput;
|
||||
}
|
||||
|
||||
font_driver_init_osd(sw,
|
||||
|
@ -101,7 +101,8 @@ static void *vita2d_gfx_init(const video_info_t *video,
|
||||
if (input && input_data)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
void *pspinput = input_psp.init(settings->arrays.input_joypad_driver);
|
||||
void *pspinput = input_driver_init_wrap(&input_psp,
|
||||
settings->arrays.input_joypad_driver);
|
||||
*input = pspinput ? &input_psp : NULL;
|
||||
*input_data = pspinput;
|
||||
}
|
||||
|
@ -114,9 +114,9 @@ static void *xshm_gfx_init(const video_info_t *video,
|
||||
|
||||
if (input && input_data)
|
||||
{
|
||||
void *xinput = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
xinput = input_x.init(settings->arrays.input_joypad_driver);
|
||||
void *xinput = input_driver_init_wrap(&input_x,
|
||||
settings->arrays.input_joypad_driver);
|
||||
if (xinput)
|
||||
{
|
||||
*input = &input_x;
|
||||
|
@ -858,7 +858,8 @@ static void *xv_init(const video_info_t *video,
|
||||
|
||||
if (input && input_data)
|
||||
{
|
||||
xinput = input_x.init(settings->arrays.input_joypad_driver);
|
||||
xinput = input_driver_init_wrap(&input_x,
|
||||
settings->arrays.input_joypad_driver);
|
||||
if (xinput)
|
||||
{
|
||||
*input = &input_x;
|
||||
|
@ -220,7 +220,7 @@ static void android_gfx_ctx_input_driver(void *data,
|
||||
const char *joypad_name,
|
||||
input_driver_t **input, void **input_data)
|
||||
{
|
||||
void *androidinput = input_android.init(joypad_name);
|
||||
void *androidinput = input_driver_init_wrap(&input_android, joypad_name);
|
||||
|
||||
*input = androidinput ? &input_android : NULL;
|
||||
*input_data = androidinput;
|
||||
|
@ -177,7 +177,7 @@ static void android_gfx_ctx_vk_input_driver(void *data,
|
||||
const char *joypad_name,
|
||||
input_driver_t **input, void **input_data)
|
||||
{
|
||||
void *androidinput = input_android.init(joypad_name);
|
||||
void *androidinput = input_driver_init_wrap(&input_android, joypad_name);
|
||||
|
||||
*input = androidinput ? &input_android : NULL;
|
||||
*input_data = androidinput;
|
||||
|
@ -743,7 +743,7 @@ static void gfx_ctx_drm_input_driver(void *data,
|
||||
#ifdef HAVE_UDEV
|
||||
{
|
||||
/* Try to set it to udev instead */
|
||||
void *udev = input_udev.init(joypad_name);
|
||||
void *udev = input_driver_init_wrap(&input_udev, joypad_name);
|
||||
if (udev)
|
||||
{
|
||||
*input = &input_udev;
|
||||
@ -755,7 +755,7 @@ static void gfx_ctx_drm_input_driver(void *data,
|
||||
#if defined(__linux__) && !defined(ANDROID)
|
||||
{
|
||||
/* Try to set it to linuxraw instead */
|
||||
void *linuxraw = input_linuxraw.init(joypad_name);
|
||||
void *linuxraw = input_driver_init_wrap(&input_linuxraw, joypad_name);
|
||||
if (linuxraw)
|
||||
{
|
||||
*input = &input_linuxraw;
|
||||
|
@ -97,7 +97,7 @@ static void gfx_ctx_go2_drm_input_driver(void *data,
|
||||
{
|
||||
#ifdef HAVE_UDEV
|
||||
/* Try to set it to udev instead */
|
||||
void *udev = input_udev.init(joypad_name);
|
||||
void *udev = input_driver_init_wrap(&input_udev, joypad_name);
|
||||
if (udev)
|
||||
{
|
||||
*input = &input_udev;
|
||||
|
@ -271,7 +271,7 @@ static void gfx_ctx_emscripten_input_driver(void *data,
|
||||
const char *name,
|
||||
input_driver_t **input, void **input_data)
|
||||
{
|
||||
void *rwebinput = input_rwebinput.init(name);
|
||||
void *rwebinput = input_driver_init_wrap(&input_rwebinput, name);
|
||||
|
||||
*input = rwebinput ? &input_rwebinput : NULL;
|
||||
*input_data = rwebinput;
|
||||
|
@ -169,7 +169,7 @@ static void gfx_ctx_khr_display_input_driver(void *data,
|
||||
#ifdef HAVE_UDEV
|
||||
{
|
||||
/* Try to set it to udev instead */
|
||||
void *udev = input_udev.init(joypad_name);
|
||||
void *udev = input_driver_init_wrap(&input_udev, joypad_name);
|
||||
if (udev)
|
||||
{
|
||||
*input = &input_udev;
|
||||
@ -181,7 +181,7 @@ static void gfx_ctx_khr_display_input_driver(void *data,
|
||||
#if defined(__linux__) && !defined(ANDROID)
|
||||
{
|
||||
/* Try to set it to linuxraw instead */
|
||||
void *linuxraw = input_linuxraw.init(joypad_name);
|
||||
void *linuxraw = input_driver_init_wrap(&input_linuxraw, joypad_name);
|
||||
if (linuxraw)
|
||||
{
|
||||
*input = &input_linuxraw;
|
||||
|
@ -288,7 +288,7 @@ static void gfx_ctx_ps3_input_driver(void *data,
|
||||
const char *joypad_name,
|
||||
input_driver_t **input, void **input_data)
|
||||
{
|
||||
void *ps3input = input_ps3.init(joypad_name);
|
||||
void *ps3input = input_driver_init_wrap(&input_ps3, joypad_name);
|
||||
|
||||
*input = ps3input ? &input_ps3 : NULL;
|
||||
*input_data = ps3input;
|
||||
|
@ -306,7 +306,7 @@ static void gfx_ctx_qnx_input_driver(void *data,
|
||||
const char *joypad_name,
|
||||
input_driver_t **input, void **input_data)
|
||||
{
|
||||
void *qnxinput = input_qnx.init(joypad_name);
|
||||
void *qnxinput = input_driver_init_wrap(&input_qnx, joypad_name);
|
||||
|
||||
*input = qnxinput ? &input_qnx : NULL;
|
||||
*input_data = qnxinput;
|
||||
|
@ -213,13 +213,13 @@ static void gfx_ctx_uwp_input_driver(void *data,
|
||||
* supports joypad only (uwp driver was added later) */
|
||||
if (string_is_equal(settings->arrays.input_driver, "xinput"))
|
||||
{
|
||||
void* xinput = input_xinput.init(joypad_name);
|
||||
void* xinput = input_driver_init_wrap(&input_xinput, joypad_name);
|
||||
*input = xinput ? (input_driver_t*)&input_xinput : NULL;
|
||||
*input_data = xinput;
|
||||
}
|
||||
else
|
||||
{
|
||||
void* uwp = input_uwp.init(joypad_name);
|
||||
void* uwp = input_driver_init_wrap(&input_uwp, joypad_name);
|
||||
*input = uwp ? (input_driver_t*)&input_uwp : NULL;
|
||||
*input_data = uwp;
|
||||
}
|
||||
|
@ -271,10 +271,10 @@ static void gfx_ctx_w_vk_input_driver(void *data,
|
||||
/* winraw only available since XP */
|
||||
if (string_is_equal(input_driver, "raw"))
|
||||
{
|
||||
*input_data = input_winraw.init(joypad_name);
|
||||
*input_data = input_driver_init_wrap(&input_winraw, joypad_name);
|
||||
if (*input_data)
|
||||
{
|
||||
*input = &input_winraw;
|
||||
*input = &input_winraw;
|
||||
dinput_vk_wgl = NULL;
|
||||
return;
|
||||
}
|
||||
@ -283,7 +283,7 @@ static void gfx_ctx_w_vk_input_driver(void *data,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DINPUT
|
||||
dinput_vk_wgl = input_dinput.init(joypad_name);
|
||||
dinput_vk_wgl = input_driver_init_wrap(&input_dinput, joypad_name);
|
||||
*input = dinput_vk_wgl ? &input_dinput : NULL;
|
||||
*input_data = dinput_vk_wgl;
|
||||
#endif
|
||||
|
@ -743,6 +743,7 @@ static void gfx_ctx_wl_input_driver(void *data,
|
||||
{
|
||||
*input = &input_wayland;
|
||||
*input_data = &wl->input;
|
||||
input_driver_init_joypads();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -556,6 +556,7 @@ static void gfx_ctx_wl_input_driver(void *data,
|
||||
{
|
||||
*input = &input_wayland;
|
||||
*input_data = &wl->input;
|
||||
input_driver_init_joypads();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -692,7 +692,7 @@ static void gfx_ctx_wgl_input_driver(void *data,
|
||||
/* winraw only available since XP */
|
||||
if (string_is_equal(input_driver, "raw"))
|
||||
{
|
||||
*input_data = input_winraw.init(joypad_name);
|
||||
*input_data = input_driver_init_wrap(&input_winraw, joypad_name);
|
||||
if (*input_data)
|
||||
{
|
||||
*input = &input_winraw;
|
||||
@ -704,7 +704,7 @@ static void gfx_ctx_wgl_input_driver(void *data,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DINPUT
|
||||
dinput_wgl = input_dinput.init(joypad_name);
|
||||
dinput_wgl = input_driver_init_wrap(&input_dinput, joypad_name);
|
||||
*input = dinput_wgl ? &input_dinput : NULL;
|
||||
*input_data = dinput_wgl;
|
||||
#endif
|
||||
|
@ -927,7 +927,7 @@ static void gfx_ctx_x_input_driver(void *data,
|
||||
|
||||
if (string_is_equal(input_driver, "udev"))
|
||||
{
|
||||
*input_data = input_udev.init(joypad_name);
|
||||
*input_data = input_driver_init_wrap(&input_udev, joypad_name);
|
||||
if (*input_data)
|
||||
{
|
||||
*input = &input_udev;
|
||||
@ -936,7 +936,7 @@ static void gfx_ctx_x_input_driver(void *data,
|
||||
}
|
||||
#endif
|
||||
|
||||
x_input = input_x.init(joypad_name);
|
||||
x_input = input_driver_init_wrap(&input_x, joypad_name);
|
||||
*input = x_input ? &input_x : NULL;
|
||||
*input_data = x_input;
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ static void gfx_ctx_x_vk_input_driver(void *data,
|
||||
|
||||
if (string_is_equal(input_driver, "udev"))
|
||||
{
|
||||
*input_data = input_udev.init(joypad_name);
|
||||
*input_data = input_driver_init_wrap(&input_udev.init, joypad_name);
|
||||
if (*input_data)
|
||||
{
|
||||
*input = &input_udev;
|
||||
@ -473,7 +473,7 @@ static void gfx_ctx_x_vk_input_driver(void *data,
|
||||
}
|
||||
#endif
|
||||
|
||||
x_input = input_x.init(joypad_name);
|
||||
x_input = input_driver_init_wrap(&input_x, joypad_name);
|
||||
*input = x_input ? &input_x : NULL;
|
||||
*input_data = x_input;
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ static void gfx_ctx_xegl_input_driver(void *data,
|
||||
const char *joypad_name,
|
||||
input_driver_t **input, void **input_data)
|
||||
{
|
||||
void *xinput = input_x.init(joypad_name);
|
||||
void *xinput = input_driver_init_wrap(&input_x, joypad_name);
|
||||
|
||||
*input = xinput ? &input_x : NULL;
|
||||
*input_data = xinput;
|
||||
|
@ -147,7 +147,6 @@ typedef struct state_device
|
||||
typedef struct android_input
|
||||
{
|
||||
int64_t quick_tap_time;
|
||||
const input_device_driver_t *joypad;
|
||||
state_device_t pad_states[MAX_USERS]; /* int alignment */
|
||||
int mouse_x_delta, mouse_y_delta;
|
||||
int mouse_l, mouse_r, mouse_m, mouse_wu, mouse_wd;
|
||||
@ -543,8 +542,6 @@ static void *android_input_init(const char *joypad_driver)
|
||||
|
||||
android_app->input_alive = true;
|
||||
|
||||
android->joypad = input_joypad_init_driver(joypad_driver, android);
|
||||
|
||||
return android;
|
||||
}
|
||||
|
||||
@ -1313,16 +1310,18 @@ static void android_input_poll_memcpy(android_input_t *android)
|
||||
/* Handle all events. If our activity is in pause state,
|
||||
* block until we're unpaused.
|
||||
*/
|
||||
static void android_input_poll(void *data)
|
||||
static void android_input_poll(void *data, const void *joypad_data)
|
||||
{
|
||||
int ident;
|
||||
struct android_app *android_app = (struct android_app*)g_android;
|
||||
android_input_t *android = (android_input_t*)data;
|
||||
const input_device_driver_t
|
||||
*joypad = (const input_device_driver_t*)joypad_data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
while ((ident =
|
||||
ALooper_pollAll((input_config_binds[0][RARCH_PAUSE_TOGGLE].valid
|
||||
&& input_key_pressed(android->joypad, RARCH_PAUSE_TOGGLE,
|
||||
&& input_key_pressed(joypad, RARCH_PAUSE_TOGGLE,
|
||||
android_keyboard_port_input_pressed(input_config_binds[0],
|
||||
RARCH_PAUSE_TOGGLE)))
|
||||
? -1 : settings->uints.input_block_timeout,
|
||||
@ -1389,7 +1388,10 @@ bool android_run_events(void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int16_t android_input_state(void *data,
|
||||
static int16_t android_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds, unsigned port, unsigned device,
|
||||
unsigned idx, unsigned id)
|
||||
@ -1402,7 +1404,7 @@ static int16_t android_input_state(void *data,
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
{
|
||||
unsigned i;
|
||||
int16_t ret = android->joypad->state(
|
||||
int16_t ret = joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
@ -1420,7 +1422,7 @@ static int16_t android_input_state(void *data,
|
||||
{
|
||||
if (
|
||||
button_is_pressed(
|
||||
android->joypad, joypad_info, binds[port],
|
||||
joypad, joypad_info, binds[port],
|
||||
port, id)
|
||||
|| android_keyboard_port_input_pressed(binds[port], id)
|
||||
)
|
||||
@ -1494,10 +1496,6 @@ static void android_input_free_input(void *data)
|
||||
ASensorManager_destroyEventQueue(android_app->sensorManager,
|
||||
android_app->sensorEventQueue);
|
||||
|
||||
if (android->joypad)
|
||||
android->joypad->destroy();
|
||||
android->joypad = NULL;
|
||||
|
||||
android_app->input_alive = false;
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
@ -1593,26 +1591,20 @@ static float android_input_get_sensor_input(void *data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const input_device_driver_t *android_input_get_joypad_driver(void *data)
|
||||
{
|
||||
android_input_t *android = (android_input_t*)data;
|
||||
if (!android)
|
||||
return NULL;
|
||||
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,
|
||||
static bool android_input_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
android_input_t *android = (android_input_t*)data;
|
||||
if (android)
|
||||
return input_joypad_set_rumble(android->joypad, port, effect, strength);
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad, port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1629,7 +1621,5 @@ input_driver_t input_android = {
|
||||
android_input_grab_mouse,
|
||||
NULL,
|
||||
android_input_set_rumble,
|
||||
android_input_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -46,12 +46,6 @@ static void *cocoa_input_init(const char *joypad_driver)
|
||||
|
||||
input_keymaps_init_keyboard_lut(rarch_key_map_apple_hid);
|
||||
|
||||
apple->joypad = input_joypad_init_driver(joypad_driver, apple);
|
||||
|
||||
#ifdef HAVE_MFI
|
||||
apple->sec_joypad = input_joypad_init_driver("mfi", apple);
|
||||
#endif
|
||||
|
||||
return apple;
|
||||
}
|
||||
|
||||
@ -90,13 +84,6 @@ static void cocoa_input_poll(void *data)
|
||||
&apple->touches[i].full_x,
|
||||
&apple->touches[i].full_y);
|
||||
}
|
||||
|
||||
if (apple->joypad)
|
||||
apple->joypad->poll();
|
||||
#ifdef HAVE_MFI
|
||||
if (apple->sec_joypad)
|
||||
apple->sec_joypad->poll();
|
||||
#endif
|
||||
}
|
||||
|
||||
static int16_t cocoa_mouse_state(cocoa_input_data_t *apple,
|
||||
@ -195,7 +182,10 @@ static int16_t cocoa_pointer_state(cocoa_input_data_t *apple,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t cocoa_input_state(void *data,
|
||||
static int16_t cocoa_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds, unsigned port,
|
||||
unsigned device, unsigned idx, unsigned id)
|
||||
@ -210,10 +200,10 @@ static int16_t cocoa_input_state(void *data,
|
||||
unsigned i;
|
||||
/* Do a bitwise OR to combine both input
|
||||
* states together */
|
||||
int16_t ret = apple->joypad->state(
|
||||
int16_t ret = joypad->state(
|
||||
joypad_info, binds[port], port)
|
||||
#ifdef HAVE_MFI
|
||||
| apple->sec_joypad->state(
|
||||
| sec_joypad->state(
|
||||
joypad_info, binds[port], port)
|
||||
#endif
|
||||
;
|
||||
@ -235,12 +225,12 @@ static int16_t cocoa_input_state(void *data,
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (button_is_pressed(
|
||||
apple->joypad,
|
||||
joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
#ifdef HAVE_MFI
|
||||
else if (button_is_pressed(
|
||||
apple->sec_joypad,
|
||||
sec_joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
#endif
|
||||
@ -274,31 +264,23 @@ static void cocoa_input_free(void *data)
|
||||
if (!apple || !data)
|
||||
return;
|
||||
|
||||
if (apple->joypad)
|
||||
apple->joypad->destroy();
|
||||
|
||||
#ifdef HAVE_MFI
|
||||
if (apple->sec_joypad)
|
||||
apple->sec_joypad->destroy();
|
||||
#endif
|
||||
|
||||
for (i = 0; i < MAX_KEYS; i++)
|
||||
apple_key_state[i] = 0;
|
||||
|
||||
free(apple);
|
||||
}
|
||||
|
||||
static bool cocoa_input_set_rumble(void *data,
|
||||
unsigned port, enum retro_rumble_effect effect, uint16_t strength)
|
||||
static bool cocoa_input_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port, enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
|
||||
|
||||
if (apple && apple->joypad)
|
||||
return input_joypad_set_rumble(apple->joypad,
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad,
|
||||
port, effect, strength);
|
||||
#ifdef HAVE_MFI
|
||||
if (apple && apple->sec_joypad)
|
||||
return input_joypad_set_rumble(apple->sec_joypad,
|
||||
if (sec_joypad)
|
||||
return input_joypad_set_rumble(sec_joypad,
|
||||
port, effect, strength);
|
||||
#endif
|
||||
return false;
|
||||
@ -316,33 +298,6 @@ static uint64_t cocoa_input_get_capabilities(void *data)
|
||||
(1 << RETRO_DEVICE_ANALOG);
|
||||
}
|
||||
|
||||
static void cocoa_input_grab_mouse(void *data, bool state)
|
||||
{
|
||||
/* Dummy for now. Might be useful in the future. */
|
||||
(void)data;
|
||||
(void)state;
|
||||
}
|
||||
|
||||
static const input_device_driver_t *cocoa_input_get_sec_joypad_driver(void *data)
|
||||
{
|
||||
#ifdef HAVE_MFI
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
|
||||
|
||||
if (apple && apple->sec_joypad)
|
||||
return apple->sec_joypad;
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const input_device_driver_t *cocoa_input_get_joypad_driver(void *data)
|
||||
{
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
|
||||
|
||||
if (apple && apple->joypad)
|
||||
return apple->joypad;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
input_driver_t input_cocoa = {
|
||||
cocoa_input_init,
|
||||
cocoa_input_poll,
|
||||
@ -352,10 +307,8 @@ input_driver_t input_cocoa = {
|
||||
NULL,
|
||||
cocoa_input_get_capabilities,
|
||||
"cocoa",
|
||||
cocoa_input_grab_mouse,
|
||||
NULL, /* grab_mouse */
|
||||
NULL,
|
||||
cocoa_input_set_rumble,
|
||||
cocoa_input_get_joypad_driver,
|
||||
cocoa_input_get_sec_joypad_driver,
|
||||
false
|
||||
};
|
||||
|
@ -52,11 +52,6 @@ typedef struct
|
||||
int16_t mouse_wd;
|
||||
int16_t mouse_wl;
|
||||
int16_t mouse_wr;
|
||||
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t *sec_joypad;
|
||||
#endif
|
||||
const input_device_driver_t *joypad;
|
||||
} cocoa_input_data_t;
|
||||
|
||||
#endif
|
||||
|
@ -35,15 +35,10 @@ typedef struct ctr_input
|
||||
const input_device_driver_t *joypad;
|
||||
} ctr_input_t;
|
||||
|
||||
static void ctr_input_poll(void *data)
|
||||
{
|
||||
ctr_input_t *ctr = (ctr_input_t*)data;
|
||||
|
||||
if (ctr->joypad)
|
||||
ctr->joypad->poll();
|
||||
}
|
||||
|
||||
static int16_t ctr_input_state(void *data,
|
||||
static int16_t ctr_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device,
|
||||
@ -58,13 +53,13 @@ static int16_t ctr_input_state(void *data,
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
return ctr->joypad->state(
|
||||
return joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
if (binds[port][id].valid)
|
||||
if (button_is_pressed(
|
||||
ctr->joypad, joypad_info, binds[port], port, id))
|
||||
joypad, joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
@ -78,9 +73,6 @@ static void ctr_input_free_input(void *data)
|
||||
{
|
||||
ctr_input_t *ctr = (ctr_input_t*)data;
|
||||
|
||||
if (ctr && ctr->joypad)
|
||||
ctr->joypad->destroy();
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
@ -90,8 +82,6 @@ static void* ctr_input_init(const char *joypad_driver)
|
||||
if (!ctr)
|
||||
return NULL;
|
||||
|
||||
ctr->joypad = input_joypad_init_driver(joypad_driver, ctr);
|
||||
|
||||
return ctr;
|
||||
}
|
||||
|
||||
@ -102,36 +92,17 @@ static uint64_t ctr_input_get_capabilities(void *data)
|
||||
return (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG);
|
||||
}
|
||||
|
||||
static const input_device_driver_t *ctr_input_get_joypad_driver(void *data)
|
||||
{
|
||||
ctr_input_t *ctr = (ctr_input_t*)data;
|
||||
if (ctr)
|
||||
return ctr->joypad;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void ctr_input_grab_mouse(void *data, bool state)
|
||||
{
|
||||
(void)data;
|
||||
(void)state;
|
||||
}
|
||||
|
||||
static bool ctr_input_set_rumble(void *data, unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength) { return false; }
|
||||
|
||||
input_driver_t input_ctr = {
|
||||
ctr_input_init,
|
||||
ctr_input_poll,
|
||||
NULL, /* poll */
|
||||
ctr_input_state,
|
||||
ctr_input_free_input,
|
||||
NULL,
|
||||
NULL,
|
||||
ctr_input_get_capabilities,
|
||||
"ctr",
|
||||
ctr_input_grab_mouse,
|
||||
NULL,
|
||||
ctr_input_set_rumble,
|
||||
ctr_input_get_joypad_driver,
|
||||
NULL, /* grab_mouse */
|
||||
NULL,
|
||||
NULL, /* set_rumble */
|
||||
false
|
||||
};
|
||||
|
@ -187,8 +187,6 @@ static void *dinput_init(const char *joypad_driver)
|
||||
win32_set_input_userdata(di);
|
||||
#endif
|
||||
|
||||
di->joypad = input_joypad_init_driver(joypad_driver, di);
|
||||
|
||||
return di;
|
||||
}
|
||||
|
||||
@ -280,9 +278,6 @@ static void dinput_poll(void *data)
|
||||
di->mouse_x = point.x;
|
||||
di->mouse_y = point.y;
|
||||
}
|
||||
|
||||
if (di->joypad)
|
||||
di->joypad->poll();
|
||||
}
|
||||
|
||||
static bool dinput_mouse_button_pressed(
|
||||
@ -565,7 +560,10 @@ static int16_t dinput_pointer_state(struct dinput_input *di,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t dinput_input_state(void *data,
|
||||
static int16_t dinput_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds, unsigned port,
|
||||
unsigned device, unsigned idx, unsigned id)
|
||||
@ -585,7 +583,7 @@ static int16_t dinput_input_state(void *data,
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
{
|
||||
unsigned i;
|
||||
int16_t ret = di->joypad->state(
|
||||
int16_t ret = joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
if (settings->uints.input_mouse_index[port] == 0)
|
||||
@ -624,7 +622,7 @@ static int16_t dinput_input_state(void *data,
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (button_is_pressed(
|
||||
di->joypad,
|
||||
joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
else if (binds[port][id].key < RETROK_LAST
|
||||
@ -737,7 +735,7 @@ static int16_t dinput_input_state(void *data,
|
||||
}
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (button_is_pressed(di->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info,
|
||||
binds[port], port, new_id))
|
||||
return 1;
|
||||
@ -923,9 +921,7 @@ bool dinput_handle_message(void *data,
|
||||
|
||||
/* TODO/FIXME: Don't destroy everything, let's just
|
||||
* handle new devices gracefully */
|
||||
if (di->joypad)
|
||||
di->joypad->destroy();
|
||||
di->joypad = input_joypad_init_driver(di->joypad_driver_name, di);
|
||||
joypad_driver_reinit(di, di->joypad_driver_name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -957,8 +953,6 @@ static void dinput_free(void *data)
|
||||
|
||||
/* Prevent a joypad driver to kill our context prematurely. */
|
||||
g_dinput_ctx = NULL;
|
||||
if (di->joypad)
|
||||
di->joypad->destroy();
|
||||
|
||||
#ifndef _XBOX
|
||||
win32_unset_input_userdata();
|
||||
@ -977,6 +971,7 @@ static void dinput_free(void *data)
|
||||
|
||||
if (di->joypad_driver_name)
|
||||
free(di->joypad_driver_name);
|
||||
di->joypad_driver_name = NULL;
|
||||
|
||||
free(di);
|
||||
|
||||
@ -996,23 +991,17 @@ static void dinput_grab_mouse(void *data, bool state)
|
||||
IDirectInputDevice8_Acquire(di->mouse);
|
||||
}
|
||||
|
||||
static bool dinput_set_rumble(void *data, unsigned port,
|
||||
static bool dinput_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
struct dinput_input *di = (struct dinput_input*)data;
|
||||
if (di)
|
||||
return input_joypad_set_rumble(di->joypad, port, effect, strength);
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad, port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
static const input_device_driver_t *dinput_get_joypad_driver(void *data)
|
||||
{
|
||||
struct dinput_input *di = (struct dinput_input*)data;
|
||||
if (!di)
|
||||
return NULL;
|
||||
return di->joypad;
|
||||
}
|
||||
|
||||
static uint64_t dinput_get_capabilities(void *data)
|
||||
{
|
||||
uint64_t caps = 0;
|
||||
@ -1036,11 +1025,8 @@ input_driver_t input_dinput = {
|
||||
NULL,
|
||||
dinput_get_capabilities,
|
||||
"dinput",
|
||||
|
||||
dinput_grab_mouse,
|
||||
NULL,
|
||||
dinput_set_rumble,
|
||||
dinput_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
typedef struct dos_input
|
||||
{
|
||||
const input_device_driver_t *joypad;
|
||||
void *empty;
|
||||
} dos_input_t;
|
||||
|
||||
/* First ports are used to keeping track of gamepad states. Last port is used for keyboard state */
|
||||
@ -62,15 +62,10 @@ static void dos_keyboard_free(void)
|
||||
dos_key_state[i][j] = 0;
|
||||
}
|
||||
|
||||
static void dos_input_poll(void *data)
|
||||
{
|
||||
dos_input_t *dos = (dos_input_t*)data;
|
||||
|
||||
if (dos->joypad)
|
||||
dos->joypad->poll();
|
||||
}
|
||||
|
||||
static int16_t dos_input_state(void *data,
|
||||
static int16_t dos_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device,
|
||||
@ -87,7 +82,7 @@ static int16_t dos_input_state(void *data,
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
{
|
||||
unsigned i;
|
||||
int16_t ret = dos->joypad->state(
|
||||
int16_t ret = joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
@ -108,7 +103,7 @@ static int16_t dos_input_state(void *data,
|
||||
{
|
||||
if (
|
||||
button_is_pressed(
|
||||
dos->joypad, joypad_info, binds[port],
|
||||
joypad, joypad_info, binds[port],
|
||||
port, id)
|
||||
|| dos_keyboard_port_input_pressed(binds[port], id)
|
||||
)
|
||||
@ -129,9 +124,6 @@ static void dos_input_free_input(void *data)
|
||||
{
|
||||
dos_input_t *dos = (dos_input_t*)data;
|
||||
|
||||
if (dos && dos->joypad)
|
||||
dos->joypad->destroy();
|
||||
|
||||
dos_keyboard_free();
|
||||
|
||||
if (data)
|
||||
@ -147,58 +139,25 @@ static void* dos_input_init(const char *joypad_driver)
|
||||
|
||||
input_keymaps_init_keyboard_lut(rarch_key_map_dos);
|
||||
|
||||
dos->joypad = input_joypad_init_driver(joypad_driver, dos);
|
||||
|
||||
return dos;
|
||||
}
|
||||
|
||||
static uint64_t dos_input_get_capabilities(void *data)
|
||||
{
|
||||
uint64_t caps = 0;
|
||||
|
||||
caps |= UINT64_C(1) << RETRO_DEVICE_JOYPAD;
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
||||
static const input_device_driver_t *dos_input_get_joypad_driver(void *data)
|
||||
{
|
||||
dos_input_t *dos = (dos_input_t*)data;
|
||||
if (dos)
|
||||
return dos->joypad;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void dos_input_grab_mouse(void *data, bool state)
|
||||
{
|
||||
(void)data;
|
||||
(void)state;
|
||||
}
|
||||
|
||||
static bool dos_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;
|
||||
return UINT64_C(1) << RETRO_DEVICE_JOYPAD;
|
||||
}
|
||||
|
||||
input_driver_t input_dos = {
|
||||
dos_input_init,
|
||||
dos_input_poll,
|
||||
NULL, /* poll */
|
||||
dos_input_state,
|
||||
dos_input_free_input,
|
||||
NULL,
|
||||
NULL,
|
||||
dos_input_get_capabilities,
|
||||
"dos",
|
||||
dos_input_grab_mouse,
|
||||
NULL,
|
||||
dos_input_set_rumble,
|
||||
dos_input_get_joypad_driver,
|
||||
NULL, /* grab_mouse */
|
||||
NULL,
|
||||
NULL, /* set_rumble */
|
||||
false
|
||||
};
|
||||
|
@ -47,7 +47,6 @@ typedef struct
|
||||
|
||||
typedef struct gx_input
|
||||
{
|
||||
const input_device_driver_t *joypad;
|
||||
#ifdef HW_RVL
|
||||
int mouse_max;
|
||||
gx_input_mouse_t *mouse;
|
||||
@ -55,7 +54,8 @@ typedef struct gx_input
|
||||
} gx_input_t;
|
||||
|
||||
#ifdef HW_RVL
|
||||
static int16_t gx_lightgun_state(gx_input_t *gx, unsigned id, uint16_t joy_idx)
|
||||
static int16_t gx_lightgun_state(gx_input_t *gx,
|
||||
unsigned id, uint16_t joy_idx)
|
||||
{
|
||||
struct video_viewport vp = {0};
|
||||
video_driver_get_viewport_info(&vp);
|
||||
@ -134,7 +134,10 @@ static int16_t gx_mouse_state(gx_input_t *gx, unsigned id, uint16_t joy_idx)
|
||||
}
|
||||
#endif
|
||||
|
||||
static int16_t gx_input_state(void *data,
|
||||
static int16_t gx_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device,
|
||||
@ -149,12 +152,12 @@ static int16_t gx_input_state(void *data,
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
return gx->joypad->state(
|
||||
return joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
if (binds[port][id].valid)
|
||||
if (
|
||||
button_is_pressed(gx->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
break;
|
||||
@ -179,8 +182,6 @@ static void gx_input_free_input(void *data)
|
||||
if (!gx)
|
||||
return;
|
||||
|
||||
if (gx->joypad)
|
||||
gx->joypad->destroy();
|
||||
#ifdef HW_RVL
|
||||
if (gx->mouse)
|
||||
free(gx->mouse);
|
||||
@ -188,27 +189,6 @@ static void gx_input_free_input(void *data)
|
||||
free(gx);
|
||||
}
|
||||
|
||||
#ifdef HW_RVL
|
||||
static inline int gx_count_mouse(gx_input_t *gx)
|
||||
{
|
||||
unsigned i;
|
||||
int count = 0;
|
||||
|
||||
if (gx)
|
||||
{
|
||||
for (i = 0; i < DEFAULT_MAX_PADS; i++)
|
||||
{
|
||||
if (gx->joypad->name(i))
|
||||
{
|
||||
if (string_is_equal(gx->joypad->name(i), "Wiimote Controller"))
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void *gx_input_init(const char *joypad_driver)
|
||||
{
|
||||
@ -223,11 +203,29 @@ static void *gx_input_init(const char *joypad_driver)
|
||||
gx->mouse_max, sizeof(gx_input_mouse_t));
|
||||
#endif
|
||||
|
||||
gx->joypad = input_joypad_init_driver(joypad_driver, gx);
|
||||
return gx;
|
||||
}
|
||||
|
||||
#ifdef HW_RVL
|
||||
static inline int gx_count_mouse(gx_input_t *gx)
|
||||
{
|
||||
unsigned i;
|
||||
int count = 0;
|
||||
|
||||
if (!gx)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < DEFAULT_MAX_PADS; i++)
|
||||
{
|
||||
const char *joypad_name = joypad_driver_name(i);
|
||||
if (!string_is_empty(joypad_name))
|
||||
if (string_is_equal(joypad_name, "Wiimote Controller"))
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static void gx_input_poll_mouse(gx_input_t *gx)
|
||||
{
|
||||
int count = gx_count_mouse(gx);
|
||||
@ -266,25 +264,17 @@ static void gx_input_poll_mouse(gx_input_t *gx)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void gx_input_poll(void *data)
|
||||
static void rvl_input_poll(void *data)
|
||||
{
|
||||
gx_input_t *gx = (gx_input_t*)data;
|
||||
|
||||
if (gx && gx->joypad)
|
||||
{
|
||||
gx->joypad->poll();
|
||||
#ifdef HW_RVL
|
||||
if (gx->mouse)
|
||||
gx_input_poll_mouse(gx);
|
||||
#endif
|
||||
}
|
||||
if (gx && gx->mouse)
|
||||
gx_input_poll_mouse(gx);
|
||||
}
|
||||
#endif
|
||||
|
||||
static uint64_t gx_input_get_capabilities(void *data)
|
||||
{
|
||||
(void)data;
|
||||
#ifdef HW_RVL
|
||||
return (1 << RETRO_DEVICE_JOYPAD) |
|
||||
(1 << RETRO_DEVICE_ANALOG) |
|
||||
@ -296,21 +286,13 @@ static uint64_t gx_input_get_capabilities(void *data)
|
||||
#endif
|
||||
}
|
||||
|
||||
static const input_device_driver_t *gx_input_get_joypad_driver(void *data)
|
||||
{
|
||||
gx_input_t *gx = (gx_input_t*)data;
|
||||
if (!gx)
|
||||
return NULL;
|
||||
return gx->joypad;
|
||||
}
|
||||
|
||||
static void gx_input_grab_mouse(void *data, bool state) { }
|
||||
static bool gx_input_set_rumble(void *data, unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength) { return false; }
|
||||
|
||||
input_driver_t input_gx = {
|
||||
gx_input_init,
|
||||
gx_input_poll,
|
||||
#ifdef HW_RVL
|
||||
rvl_input_poll,
|
||||
#else
|
||||
NULL, /* poll */
|
||||
#endif
|
||||
gx_input_state,
|
||||
gx_input_free_input,
|
||||
NULL,
|
||||
@ -318,10 +300,8 @@ input_driver_t input_gx = {
|
||||
gx_input_get_capabilities,
|
||||
"gx",
|
||||
|
||||
gx_input_grab_mouse,
|
||||
NULL,
|
||||
gx_input_set_rumble,
|
||||
gx_input_get_joypad_driver,
|
||||
NULL, /* grab_mouse */
|
||||
NULL,
|
||||
NULL, /* set_rumble */
|
||||
false
|
||||
};
|
||||
|
@ -37,7 +37,6 @@
|
||||
|
||||
typedef struct linuxraw_input
|
||||
{
|
||||
const input_device_driver_t *joypad;
|
||||
bool state[0x80];
|
||||
} linuxraw_input_t;
|
||||
|
||||
@ -70,8 +69,6 @@ static void *linuxraw_input_init(const char *joypad_driver)
|
||||
|
||||
linux_terminal_claim_stdin();
|
||||
|
||||
linuxraw->joypad = input_joypad_init_driver(joypad_driver, linuxraw);
|
||||
|
||||
return linuxraw;
|
||||
}
|
||||
|
||||
@ -107,7 +104,10 @@ static int16_t linuxraw_analog_pressed(linuxraw_input_t *linuxraw,
|
||||
return pressed_plus + pressed_minus;
|
||||
}
|
||||
|
||||
static int16_t linuxraw_input_state(void *data,
|
||||
static int16_t linuxraw_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds, unsigned port,
|
||||
unsigned device, unsigned idx, unsigned id)
|
||||
@ -120,7 +120,7 @@ static int16_t linuxraw_input_state(void *data,
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
{
|
||||
unsigned i;
|
||||
int16_t ret = linuxraw->joypad->state(
|
||||
int16_t ret = joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
@ -145,7 +145,7 @@ static int16_t linuxraw_input_state(void *data,
|
||||
{
|
||||
if (
|
||||
button_is_pressed(
|
||||
linuxraw->joypad, joypad_info, binds[port],
|
||||
joypad, joypad_info, binds[port],
|
||||
port, id)
|
||||
)
|
||||
return 1;
|
||||
@ -174,28 +174,19 @@ static void linuxraw_input_free(void *data)
|
||||
if (!linuxraw)
|
||||
return;
|
||||
|
||||
if (linuxraw->joypad)
|
||||
linuxraw->joypad->destroy();
|
||||
|
||||
linux_terminal_restore_input();
|
||||
free(data);
|
||||
}
|
||||
|
||||
static bool linuxraw_set_rumble(void *data, unsigned port,
|
||||
static bool linuxraw_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
linuxraw_input_t *linuxraw = (linuxraw_input_t*)data;
|
||||
if (!linuxraw)
|
||||
return false;
|
||||
return input_joypad_set_rumble(linuxraw->joypad, port, effect, strength);
|
||||
}
|
||||
|
||||
static const input_device_driver_t *linuxraw_get_joypad_driver(void *data)
|
||||
{
|
||||
linuxraw_input_t *linuxraw = (linuxraw_input_t*)data;
|
||||
if (!linuxraw)
|
||||
return NULL;
|
||||
return linuxraw->joypad;
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad, port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
static void linuxraw_input_poll(void *data)
|
||||
@ -220,29 +211,17 @@ static void linuxraw_input_poll(void *data)
|
||||
else
|
||||
linuxraw->state[c] = pressed;
|
||||
}
|
||||
|
||||
if (linuxraw->joypad)
|
||||
linuxraw->joypad->poll();
|
||||
}
|
||||
|
||||
static uint64_t linuxraw_get_capabilities(void *data)
|
||||
{
|
||||
uint64_t caps = 0;
|
||||
|
||||
(void)data;
|
||||
|
||||
caps |= (1 << RETRO_DEVICE_JOYPAD);
|
||||
caps |= (1 << RETRO_DEVICE_ANALOG);
|
||||
|
||||
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,
|
||||
@ -252,10 +231,8 @@ input_driver_t input_linuxraw = {
|
||||
NULL,
|
||||
linuxraw_get_capabilities,
|
||||
"linuxraw",
|
||||
linuxraw_grab_mouse,
|
||||
NULL, /* grab_mouse */
|
||||
linux_terminal_grab_stdin,
|
||||
linuxraw_set_rumble,
|
||||
linuxraw_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -28,18 +28,13 @@
|
||||
|
||||
typedef struct ps2_input
|
||||
{
|
||||
const input_device_driver_t *joypad;
|
||||
void *empty;
|
||||
} ps2_input_t;
|
||||
|
||||
static void ps2_input_poll(void *data)
|
||||
{
|
||||
ps2_input_t *ps2 = (ps2_input_t*)data;
|
||||
|
||||
if (ps2 && ps2->joypad)
|
||||
ps2->joypad->poll();
|
||||
}
|
||||
|
||||
static int16_t ps2_input_state(void *data,
|
||||
static int16_t ps2_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device,
|
||||
@ -51,11 +46,11 @@ static int16_t ps2_input_state(void *data,
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
return ps2->joypad->state(
|
||||
return joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
if (binds[port][id].valid)
|
||||
if (button_is_pressed(ps2->joypad, joypad_info, binds[port],
|
||||
if (button_is_pressed(joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
break;
|
||||
@ -70,9 +65,6 @@ static void ps2_input_free_input(void *data)
|
||||
{
|
||||
ps2_input_t *ps2 = (ps2_input_t*)data;
|
||||
|
||||
if (ps2 && ps2->joypad)
|
||||
ps2->joypad->destroy();
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
@ -82,8 +74,6 @@ static void* ps2_input_initialize(const char *joypad_driver)
|
||||
if (!ps2)
|
||||
return NULL;
|
||||
|
||||
ps2->joypad = input_joypad_init_driver(joypad_driver, ps2);
|
||||
|
||||
return ps2;
|
||||
}
|
||||
|
||||
@ -94,44 +84,29 @@ static uint64_t ps2_input_get_capabilities(void *data)
|
||||
return (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG);
|
||||
}
|
||||
|
||||
static const input_device_driver_t *ps2_input_get_joypad_driver(void *data)
|
||||
{
|
||||
ps2_input_t *ps2 = (ps2_input_t*)data;
|
||||
if (ps2)
|
||||
return ps2->joypad;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void ps2_input_grab_mouse(void *data, bool state)
|
||||
{
|
||||
(void)data;
|
||||
(void)state;
|
||||
}
|
||||
|
||||
static bool ps2_input_set_rumble(void *data, unsigned port,
|
||||
static bool ps2_input_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
ps2_input_t *ps2 = (ps2_input_t*)data;
|
||||
|
||||
if (ps2 && ps2->joypad)
|
||||
return input_joypad_set_rumble(ps2->joypad,
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad,
|
||||
port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
input_driver_t input_ps2 = {
|
||||
ps2_input_initialize,
|
||||
ps2_input_poll,
|
||||
NULL, /* poll */
|
||||
ps2_input_state,
|
||||
ps2_input_free_input,
|
||||
NULL,
|
||||
NULL,
|
||||
ps2_input_get_capabilities,
|
||||
"ps2",
|
||||
ps2_input_grab_mouse,
|
||||
NULL, /* grab_mouse */
|
||||
NULL,
|
||||
ps2_input_set_rumble,
|
||||
ps2_input_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -48,19 +48,17 @@ typedef struct ps3_input
|
||||
{
|
||||
#ifdef HAVE_MOUSE
|
||||
unsigned mice_connected;
|
||||
#else
|
||||
void *empty;
|
||||
#endif
|
||||
const input_device_driver_t *joypad;
|
||||
} ps3_input_t;
|
||||
|
||||
static void ps3_input_poll(void *data)
|
||||
{
|
||||
ps3_input_t *ps3 = (ps3_input_t*)data;
|
||||
|
||||
if (ps3 && ps3->joypad)
|
||||
ps3->joypad->poll();
|
||||
|
||||
#ifdef HAVE_MOUSE
|
||||
CellMouseInfo mouse_info;
|
||||
ps3_input_t *ps3 = (ps3_input_t*)data;
|
||||
|
||||
cellMouseGetInfo(&mouse_info);
|
||||
ps3->mice_connected = mouse_info.now_connect;
|
||||
#endif
|
||||
@ -93,7 +91,10 @@ static int16_t ps3_mouse_device_state(ps3_input_t *ps3,
|
||||
}
|
||||
#endif
|
||||
|
||||
static int16_t ps3_input_state(void *data,
|
||||
static int16_t ps3_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device,
|
||||
@ -108,11 +109,11 @@ static int16_t ps3_input_state(void *data,
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
return ps3->joypad->state(
|
||||
return joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
if (binds[port][id].valid)
|
||||
if (button_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
if (button_is_pressed(joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
|
||||
@ -154,9 +155,6 @@ static void ps3_input_free_input(void *data)
|
||||
if (!ps3)
|
||||
return;
|
||||
|
||||
if (ps3->joypad)
|
||||
ps3->joypad->destroy();
|
||||
|
||||
#ifdef HAVE_MOUSE
|
||||
cellMouseEnd();
|
||||
#endif
|
||||
@ -173,8 +171,6 @@ static void* ps3_input_init(const char *joypad_driver)
|
||||
cellMouseInit(MAX_MICE);
|
||||
#endif
|
||||
|
||||
ps3->joypad = input_joypad_init_driver(joypad_driver, ps3);
|
||||
|
||||
return ps3;
|
||||
}
|
||||
|
||||
@ -193,7 +189,6 @@ static bool ps3_input_set_sensor_state(void *data, unsigned port,
|
||||
enum retro_sensor_action action, unsigned event_rate)
|
||||
{
|
||||
CellPadInfo2 pad_info;
|
||||
(void)event_rate;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
@ -201,43 +196,32 @@ static bool ps3_input_set_sensor_state(void *data, unsigned port,
|
||||
cellPadGetInfo2(&pad_info);
|
||||
if ((pad_info.device_capability[port]
|
||||
& CELL_PAD_CAPABILITY_SENSOR_MODE)
|
||||
!= CELL_PAD_CAPABILITY_SENSOR_MODE)
|
||||
return false;
|
||||
|
||||
cellPadSetPortSetting(port, CELL_PAD_SETTING_SENSOR_ON);
|
||||
return true;
|
||||
== CELL_PAD_CAPABILITY_SENSOR_MODE)
|
||||
{
|
||||
cellPadSetPortSetting(port, CELL_PAD_SETTING_SENSOR_ON);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case RETRO_SENSOR_ACCELEROMETER_DISABLE:
|
||||
cellPadSetPortSetting(port, 0);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static bool ps3_input_set_rumble(void *data, unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
ps3_input_t *ps3 = (ps3_input_t*)data;
|
||||
|
||||
if (ps3 && ps3->joypad)
|
||||
return input_joypad_set_rumble(ps3->joypad,
|
||||
port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
static const input_device_driver_t *ps3_input_get_joypad_driver(void *data)
|
||||
static bool ps3_input_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
ps3_input_t *ps3 = (ps3_input_t*)data;
|
||||
if (ps3)
|
||||
return ps3->joypad;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void ps3_input_grab_mouse(void *data, bool state)
|
||||
{
|
||||
(void)data;
|
||||
(void)state;
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad,
|
||||
port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
input_driver_t input_ps3 = {
|
||||
@ -250,10 +234,8 @@ input_driver_t input_ps3 = {
|
||||
ps3_input_get_capabilities,
|
||||
"ps3",
|
||||
|
||||
ps3_input_grab_mouse,
|
||||
NULL, /* grab_mouse */
|
||||
NULL,
|
||||
ps3_input_set_rumble,
|
||||
ps3_input_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -34,18 +34,13 @@
|
||||
|
||||
typedef struct ps4_input
|
||||
{
|
||||
const input_device_driver_t *joypad;
|
||||
void *empty;
|
||||
} ps4_input_t;
|
||||
|
||||
static void ps4_input_poll(void *data)
|
||||
{
|
||||
ps4_input_t *ps4 = (ps4_input_t*)data;
|
||||
|
||||
if (ps4 && ps4->joypad)
|
||||
ps4->joypad->poll();
|
||||
}
|
||||
|
||||
static int16_t ps4_input_state(void *data,
|
||||
static int16_t ps4_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device,
|
||||
@ -57,12 +52,12 @@ static int16_t ps4_input_state(void *data,
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
return ps4->joypad->state(
|
||||
return joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
if (binds[port][id].valid)
|
||||
if (
|
||||
button_is_pressed(ps4->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
break;
|
||||
@ -75,11 +70,6 @@ static int16_t ps4_input_state(void *data,
|
||||
|
||||
static void ps4_input_free_input(void *data)
|
||||
{
|
||||
ps4_input_t *ps4 = (ps4_input_t*)data;
|
||||
|
||||
if (ps4 && ps4->joypad)
|
||||
ps4->joypad->destroy();
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
@ -89,56 +79,37 @@ static void* ps4_input_initialize(const char *joypad_driver)
|
||||
if (!ps4)
|
||||
return NULL;
|
||||
|
||||
ps4->joypad = input_joypad_init_driver(joypad_driver, ps4);
|
||||
|
||||
return ps4;
|
||||
}
|
||||
|
||||
static uint64_t ps4_input_get_capabilities(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
return (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG);
|
||||
}
|
||||
|
||||
static const input_device_driver_t *ps4_input_get_joypad_driver(void *data)
|
||||
{
|
||||
ps4_input_t *ps4 = (ps4_input_t*)data;
|
||||
if (ps4)
|
||||
return ps4->joypad;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void ps4_input_grab_mouse(void *data, bool state)
|
||||
{
|
||||
(void)data;
|
||||
(void)state;
|
||||
}
|
||||
|
||||
static bool ps4_input_set_rumble(void *data, unsigned port,
|
||||
static bool ps4_input_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
ps4_input_t *ps4 = (ps4_input_t*)data;
|
||||
|
||||
if (ps4 && ps4->joypad)
|
||||
return input_joypad_set_rumble(ps4->joypad,
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad,
|
||||
port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
input_driver_t input_ps4 = {
|
||||
ps4_input_initialize,
|
||||
ps4_input_poll,
|
||||
NULL, /* poll */
|
||||
ps4_input_state,
|
||||
ps4_input_free_input,
|
||||
NULL,
|
||||
NULL,
|
||||
ps4_input_get_capabilities,
|
||||
"ps4",
|
||||
ps4_input_grab_mouse,
|
||||
NULL, /* grab_mouse */
|
||||
NULL,
|
||||
ps4_input_set_rumble,
|
||||
ps4_input_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -51,7 +51,6 @@ typedef struct
|
||||
|
||||
typedef struct ps3_input
|
||||
{
|
||||
const input_device_driver_t *joypad;
|
||||
int connected[MAX_KB_PORT_NUM];
|
||||
#ifdef HAVE_MOUSE
|
||||
unsigned mice_connected;
|
||||
@ -89,10 +88,8 @@ static void ps3_input_poll(void *data)
|
||||
ps3_input_t *ps3 = (ps3_input_t*)data;
|
||||
KbData last_kbdata[MAX_KB_PORT_NUM];
|
||||
|
||||
if (ps3 && ps3->joypad)
|
||||
ps3->joypad->poll();
|
||||
|
||||
ioKbGetInfo(&ps3->kbinfo);
|
||||
|
||||
for (i = 0; i < MAX_KB_PORT_NUM; i++)
|
||||
{
|
||||
if (ps3->kbinfo.status[i] && !ps3->connected[i])
|
||||
@ -125,9 +122,11 @@ static void ps3_input_poll(void *data)
|
||||
|
||||
for (j = 0; j < last_kbdata[i].nb_keycode; j++)
|
||||
{
|
||||
int code = last_kbdata[i].keycode[j];
|
||||
unsigned k;
|
||||
int code = last_kbdata[i].keycode[j];
|
||||
int newly_depressed = 1;
|
||||
for (int k = 0; k < MAX_KB_PORT_NUM; i++)
|
||||
|
||||
for (k = 0; k < MAX_KB_PORT_NUM; i++)
|
||||
if (ps3->kbdata[i].keycode[k] == code)
|
||||
{
|
||||
newly_depressed = 0;
|
||||
@ -143,14 +142,19 @@ static void ps3_input_poll(void *data)
|
||||
|
||||
for (j = 0; j < ps3->kbdata[i].nb_keycode; j++)
|
||||
{
|
||||
int code = ps3->kbdata[i].keycode[j];
|
||||
unsigned k;
|
||||
int code = ps3->kbdata[i].keycode[j];
|
||||
int newly_pressed = 1;
|
||||
for (int k = 0; k < MAX_KB_PORT_NUM; i++)
|
||||
|
||||
for (k = 0; k < MAX_KB_PORT_NUM; i++)
|
||||
{
|
||||
if (last_kbdata[i].keycode[k] == code)
|
||||
{
|
||||
newly_pressed = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (newly_pressed)
|
||||
{
|
||||
unsigned keyboardcode = input_keymaps_translate_keysym_to_rk(code);
|
||||
@ -203,7 +207,10 @@ static bool psl1ght_keyboard_port_input_pressed(ps3_input_t *ps3, unsigned id)
|
||||
return false;
|
||||
}
|
||||
|
||||
static int16_t ps3_input_state(void *data,
|
||||
static int16_t ps3_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device,
|
||||
@ -220,14 +227,15 @@ static int16_t ps3_input_state(void *data,
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
{
|
||||
unsigned i;
|
||||
int16_t ret = ps3->joypad->state(
|
||||
int16_t ret = joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
{
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (psl1ght_keyboard_port_input_pressed(ps3, binds[port][i].key))
|
||||
if (psl1ght_keyboard_port_input_pressed(
|
||||
ps3, binds[port][i].key))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
@ -239,7 +247,7 @@ static int16_t ps3_input_state(void *data,
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (
|
||||
button_is_pressed(ps3->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
else if (psl1ght_keyboard_port_input_pressed(
|
||||
@ -283,8 +291,6 @@ static void* ps3_input_init(const char *joypad_driver)
|
||||
ps3_connect_keyboard(ps3, i);
|
||||
}
|
||||
|
||||
ps3->joypad = input_joypad_init_driver(joypad_driver, ps3);
|
||||
|
||||
return ps3;
|
||||
}
|
||||
|
||||
@ -306,23 +312,6 @@ static bool ps3_input_set_sensor_state(void *data, unsigned port,
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ps3_input_set_rumble(void *data, unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength) { return false; }
|
||||
|
||||
static const input_device_driver_t *ps3_input_get_joypad_driver(void *data)
|
||||
{
|
||||
ps3_input_t *ps3 = (ps3_input_t*)data;
|
||||
if (ps3)
|
||||
return ps3->joypad;
|
||||
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,
|
||||
@ -333,11 +322,9 @@ input_driver_t input_ps3 = {
|
||||
ps3_input_get_capabilities,
|
||||
"ps3",
|
||||
|
||||
ps3_input_grab_mouse,
|
||||
NULL,
|
||||
ps3_input_set_rumble,
|
||||
ps3_input_get_joypad_driver,
|
||||
NULL, /* grab_mouse */
|
||||
NULL,
|
||||
NULL, /* set_rumble */
|
||||
false
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,6 @@ uint8_t modifier_lut[VITA_NUM_MODIFIERS][2] =
|
||||
|
||||
typedef struct psp_input
|
||||
{
|
||||
const input_device_driver_t *joypad;
|
||||
#ifdef VITA
|
||||
int keyboard_hid_handle;
|
||||
int mouse_hid_handle;
|
||||
@ -90,10 +89,10 @@ typedef struct psp_input
|
||||
#endif
|
||||
} psp_input_t;
|
||||
|
||||
static void psp_input_poll(void *data)
|
||||
#ifdef VITA
|
||||
static void vita_input_poll(void *data)
|
||||
{
|
||||
psp_input_t *psp = (psp_input_t*)data;
|
||||
#ifdef VITA
|
||||
unsigned int i = 0;
|
||||
int key_sym = 0;
|
||||
unsigned key_code = 0;
|
||||
@ -234,13 +233,8 @@ static void psp_input_poll(void *data)
|
||||
psp->mouse_y = 0;
|
||||
else if (psp->mouse_y > MOUSE_MAX_Y)
|
||||
psp->mouse_y = MOUSE_MAX_Y;
|
||||
#endif
|
||||
|
||||
if (psp && psp->joypad)
|
||||
psp->joypad->poll();
|
||||
}
|
||||
|
||||
#ifdef VITA
|
||||
static int16_t psp_input_mouse_state(
|
||||
psp_input_t *psp, unsigned id, bool screen)
|
||||
{
|
||||
@ -248,31 +242,24 @@ static int16_t psp_input_mouse_state(
|
||||
switch (id)
|
||||
{
|
||||
case RETRO_DEVICE_ID_MOUSE_LEFT:
|
||||
val = psp->mouse_button_left;
|
||||
break;
|
||||
return psp->mouse_button_left;
|
||||
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
||||
val = psp->mouse_button_right;
|
||||
break;
|
||||
return psp->mouse_button_right;
|
||||
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
|
||||
val = psp->mouse_button_middle;
|
||||
break;
|
||||
return psp->mouse_button_middle;
|
||||
case RETRO_DEVICE_ID_MOUSE_X:
|
||||
if (screen)
|
||||
val = psp->mouse_x;
|
||||
else
|
||||
{
|
||||
val = psp->mouse_x_delta;
|
||||
psp->mouse_x_delta = 0; /* flush delta after it has been read */
|
||||
}
|
||||
return psp->mouse_x;
|
||||
|
||||
val = psp->mouse_x_delta;
|
||||
psp->mouse_x_delta = 0; /* flush delta after it has been read */
|
||||
break;
|
||||
case RETRO_DEVICE_ID_MOUSE_Y:
|
||||
if (screen)
|
||||
val = psp->mouse_y;
|
||||
else
|
||||
{
|
||||
val = psp->mouse_y_delta;
|
||||
psp->mouse_y_delta = 0; /* flush delta after it has been read */
|
||||
}
|
||||
return psp->mouse_y;
|
||||
|
||||
val = psp->mouse_y_delta;
|
||||
psp->mouse_y_delta = 0; /* flush delta after it has been read */
|
||||
break;
|
||||
}
|
||||
|
||||
@ -280,7 +267,10 @@ static int16_t psp_input_mouse_state(
|
||||
}
|
||||
#endif
|
||||
|
||||
static int16_t psp_input_state(void *data,
|
||||
static int16_t psp_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device,
|
||||
@ -297,12 +287,12 @@ static int16_t psp_input_state(void *data,
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
return psp->joypad->state(
|
||||
return joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
if (binds[port][id].valid)
|
||||
if (
|
||||
button_is_pressed(psp->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
break;
|
||||
@ -326,11 +316,6 @@ static int16_t psp_input_state(void *data,
|
||||
|
||||
static void psp_input_free_input(void *data)
|
||||
{
|
||||
psp_input_t *psp = (psp_input_t*)data;
|
||||
|
||||
if (psp && psp->joypad)
|
||||
psp->joypad->destroy();
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
@ -356,8 +341,6 @@ static void* psp_input_initialize(const char *joypad_driver)
|
||||
psp->mouse_y = 0;
|
||||
#endif
|
||||
|
||||
psp->joypad = input_joypad_init_driver(joypad_driver, psp);
|
||||
|
||||
return psp;
|
||||
}
|
||||
|
||||
@ -374,27 +357,16 @@ static uint64_t psp_input_get_capabilities(void *data)
|
||||
return caps;
|
||||
}
|
||||
|
||||
static const input_device_driver_t *psp_input_get_joypad_driver(void *data)
|
||||
{
|
||||
psp_input_t *psp = (psp_input_t*)data;
|
||||
if (psp)
|
||||
return psp->joypad;
|
||||
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,
|
||||
static bool psp_input_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
psp_input_t *psp = (psp_input_t*)data;
|
||||
|
||||
if (psp && psp->joypad)
|
||||
return input_joypad_set_rumble(psp->joypad,
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad,
|
||||
port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
@ -477,7 +449,11 @@ static float psp_input_get_sensor_input(void *data,
|
||||
|
||||
input_driver_t input_psp = {
|
||||
psp_input_initialize,
|
||||
psp_input_poll,
|
||||
#ifdef VITA
|
||||
vita_input_poll,
|
||||
#else
|
||||
NULL, /* poll */
|
||||
#endif
|
||||
psp_input_state,
|
||||
psp_input_free_input,
|
||||
#ifdef VITA
|
||||
@ -494,10 +470,8 @@ input_driver_t input_psp = {
|
||||
"psp",
|
||||
#endif
|
||||
|
||||
psp_input_grab_mouse,
|
||||
NULL, /* grab_mouse */
|
||||
NULL,
|
||||
psp_input_set_rumble,
|
||||
psp_input_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -77,8 +77,6 @@ typedef struct qnx_input
|
||||
{
|
||||
uint64_t pad_state[DEFAULT_MAX_PADS];
|
||||
|
||||
const input_device_driver_t *joypad;
|
||||
|
||||
/*
|
||||
* The first pointer_count indices of touch_map will be a valid,
|
||||
* active index in pointer array.
|
||||
@ -245,7 +243,7 @@ static void qnx_input_autodetect_gamepad(qnx_input_t *qnx,
|
||||
input_autoconfigure_connect(
|
||||
name_buf,
|
||||
NULL,
|
||||
qnx->joypad->ident,
|
||||
"qnx",
|
||||
controller->port,
|
||||
*controller->vid,
|
||||
*controller->pid);
|
||||
@ -691,8 +689,6 @@ static void *qnx_input_init(const char *joypad_driver)
|
||||
qnx->touch_map[i] = -1;
|
||||
}
|
||||
|
||||
qnx->joypad = input_joypad_init_driver(joypad_driver, qnx);
|
||||
|
||||
for (i = 0; i < DEFAULT_MAX_PADS; ++i)
|
||||
qnx_init_controller(qnx, &qnx->devices[i]);
|
||||
|
||||
@ -773,7 +769,10 @@ static int16_t qnx_pointer_input_state(qnx_input_t *qnx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t qnx_input_state(void *data,
|
||||
static int16_t qnx_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device, unsigned idx, unsigned id)
|
||||
@ -786,7 +785,7 @@ static int16_t qnx_input_state(void *data,
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
{
|
||||
unsigned i;
|
||||
int16_t ret = qnx->joypad->state(
|
||||
int16_t ret = joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
if (!input_qnx.keyboard_mapping_blocked)
|
||||
@ -809,7 +808,7 @@ static int16_t qnx_input_state(void *data,
|
||||
{
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (button_is_pressed(qnx->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
else if (
|
||||
@ -855,12 +854,6 @@ static uint64_t qnx_input_get_capabilities(void *data)
|
||||
(1 << RETRO_DEVICE_KEYBOARD);
|
||||
}
|
||||
|
||||
static const input_device_driver_t *qnx_input_get_joypad_driver(void *data)
|
||||
{
|
||||
qnx_input_t *qnx = (qnx_input_t*)data;
|
||||
return qnx->joypad;
|
||||
}
|
||||
|
||||
input_driver_t input_qnx = {
|
||||
qnx_input_init,
|
||||
qnx_input_poll,
|
||||
@ -873,7 +866,5 @@ input_driver_t input_qnx = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
qnx_input_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -77,7 +77,6 @@ typedef struct rwebinput_mouse_states
|
||||
typedef struct rwebinput_input
|
||||
{
|
||||
rwebinput_mouse_state_t mouse; /* double alignment */
|
||||
const input_device_driver_t *joypad;
|
||||
rwebinput_keyboard_event_queue_t keyboard; /* ptr alignment */
|
||||
bool keys[RETROK_LAST];
|
||||
} rwebinput_input_t;
|
||||
@ -365,8 +364,6 @@ static void *rwebinput_input_init(const char *joypad_driver)
|
||||
|
||||
input_keymaps_init_keyboard_lut(rarch_key_map_rwebinput);
|
||||
|
||||
rwebinput->joypad = input_joypad_init_driver(joypad_driver, rwebinput);
|
||||
|
||||
return rwebinput;
|
||||
|
||||
error:
|
||||
@ -382,8 +379,9 @@ static bool rwebinput_key_pressed(rwebinput_input_t *rwebinput, int key)
|
||||
return rwebinput->keys[key];
|
||||
}
|
||||
|
||||
static int16_t rwebinput_pointer_device_state(rwebinput_mouse_state_t *mouse,
|
||||
unsigned id, bool screen)
|
||||
static int16_t rwebinput_pointer_device_state(
|
||||
rwebinput_mouse_state_t *mouse,
|
||||
unsigned id, bool screen)
|
||||
{
|
||||
struct video_viewport vp;
|
||||
const int edge_detect = 32700;
|
||||
@ -436,8 +434,9 @@ static int16_t rwebinput_pointer_device_state(rwebinput_mouse_state_t *mouse,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t rwebinput_mouse_state(rwebinput_mouse_state_t *mouse,
|
||||
unsigned id, bool screen)
|
||||
static int16_t rwebinput_mouse_state(
|
||||
rwebinput_mouse_state_t *mouse,
|
||||
unsigned id, bool screen)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
@ -497,9 +496,12 @@ static int16_t rwebinput_is_pressed(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t rwebinput_analog_pressed(rwebinput_input_t *rwebinput,
|
||||
rarch_joypad_info_t *joypad_info, const struct retro_keybind *binds,
|
||||
unsigned idx, unsigned id)
|
||||
static int16_t rwebinput_analog_pressed(
|
||||
rwebinput_input_t *rwebinput,
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
unsigned idx, unsigned id)
|
||||
{
|
||||
int16_t pressed_minus = 0, pressed_plus = 0;
|
||||
unsigned id_minus = 0;
|
||||
@ -512,10 +514,10 @@ static int16_t rwebinput_analog_pressed(rwebinput_input_t *rwebinput,
|
||||
if (binds[id].valid)
|
||||
{
|
||||
if (rwebinput_is_pressed(rwebinput,
|
||||
rwebinput->joypad, joypad_info, binds, idx, id_minus))
|
||||
joypad, joypad_info, binds, idx, id_minus))
|
||||
pressed_minus = -0x7fff;
|
||||
if (rwebinput_is_pressed(rwebinput,
|
||||
rwebinput->joypad, joypad_info, binds, idx, id_plus))
|
||||
joypad, joypad_info, binds, idx, id_plus))
|
||||
pressed_plus = 0x7fff;
|
||||
}
|
||||
}
|
||||
@ -523,7 +525,10 @@ static int16_t rwebinput_analog_pressed(rwebinput_input_t *rwebinput,
|
||||
return pressed_plus + pressed_minus;
|
||||
}
|
||||
|
||||
static int16_t rwebinput_input_state(void *data,
|
||||
static int16_t rwebinput_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device, unsigned idx, unsigned id)
|
||||
@ -542,7 +547,7 @@ static int16_t rwebinput_input_state(void *data,
|
||||
if (binds[port][i].valid)
|
||||
{
|
||||
if (rwebinput_is_pressed(
|
||||
rwebinput, rwebinput->joypad,
|
||||
rwebinput, joypad,
|
||||
joypad_info, binds[port], port, i))
|
||||
ret |= (1 << i);
|
||||
}
|
||||
@ -556,7 +561,7 @@ static int16_t rwebinput_input_state(void *data,
|
||||
{
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (rwebinput_is_pressed(rwebinput, rwebinput->joypad,
|
||||
if (rwebinput_is_pressed(rwebinput, joypad,
|
||||
joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
@ -567,7 +572,7 @@ static int16_t rwebinput_input_state(void *data,
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return rwebinput_analog_pressed(
|
||||
rwebinput, joypad_info, binds[port],
|
||||
rwebinput, joypad, joypad_info, binds[port],
|
||||
idx, id);
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
@ -591,9 +596,6 @@ static void rwebinput_input_free(void *data)
|
||||
|
||||
emscripten_html5_remove_all_event_listeners();
|
||||
|
||||
if (rwebinput->joypad)
|
||||
rwebinput->joypad->destroy();
|
||||
|
||||
free(rwebinput->keyboard.events);
|
||||
free(rwebinput);
|
||||
}
|
||||
@ -664,32 +666,16 @@ static void rwebinput_input_poll(void *data)
|
||||
rwebinput->mouse.scroll_y = rwebinput->mouse.pending_scroll_y;
|
||||
rwebinput->mouse.pending_scroll_x = 0;
|
||||
rwebinput->mouse.pending_scroll_y = 0;
|
||||
|
||||
if (rwebinput->joypad)
|
||||
rwebinput->joypad->poll();
|
||||
}
|
||||
|
||||
static void rwebinput_grab_mouse(void *data, bool state)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
if (state)
|
||||
emscripten_request_pointerlock("#canvas", EM_TRUE);
|
||||
else
|
||||
emscripten_exit_pointerlock();
|
||||
}
|
||||
|
||||
static bool rwebinput_set_rumble(void *data, unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength) { return false; }
|
||||
|
||||
static const input_device_driver_t *rwebinput_get_joypad_driver(void *data)
|
||||
{
|
||||
rwebinput_input_t *rwebinput = (rwebinput_input_t*)data;
|
||||
if (!rwebinput)
|
||||
return NULL;
|
||||
return rwebinput->joypad;
|
||||
}
|
||||
|
||||
static uint64_t rwebinput_get_capabilities(void *data)
|
||||
{
|
||||
uint64_t caps = 0;
|
||||
@ -714,8 +700,6 @@ input_driver_t input_rwebinput = {
|
||||
"rwebinput",
|
||||
rwebinput_grab_mouse,
|
||||
NULL,
|
||||
rwebinput_set_rumble,
|
||||
rwebinput_get_joypad_driver,
|
||||
NULL,
|
||||
NULL, /* set_rumble */
|
||||
false
|
||||
};
|
||||
|
@ -36,7 +36,6 @@
|
||||
|
||||
typedef struct sdl_input
|
||||
{
|
||||
const input_device_driver_t *joypad;
|
||||
int mouse_x, mouse_y;
|
||||
int mouse_abs_x, mouse_abs_y;
|
||||
int mouse_l, mouse_r, mouse_m, mouse_b4, mouse_b5, mouse_wu, mouse_wd, mouse_wl, mouse_wr;
|
||||
@ -50,8 +49,6 @@ static void *sdl_input_init(const char *joypad_driver)
|
||||
|
||||
input_keymaps_init_keyboard_lut(rarch_key_map_sdl);
|
||||
|
||||
sdl->joypad = input_joypad_init_driver(joypad_driver, sdl);
|
||||
|
||||
return sdl;
|
||||
}
|
||||
|
||||
@ -188,7 +185,10 @@ static int16_t sdl_lightgun_device_state(sdl_input_t *sdl, unsigned id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t sdl_input_state(void *data,
|
||||
static int16_t sdl_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device, unsigned idx, unsigned id)
|
||||
@ -201,7 +201,7 @@ static int16_t sdl_input_state(void *data,
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
{
|
||||
unsigned i;
|
||||
int16_t ret = sdl->joypad->state(
|
||||
int16_t ret = joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
@ -219,7 +219,7 @@ static int16_t sdl_input_state(void *data,
|
||||
{
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (button_is_pressed(sdl->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
else if (sdl_key_pressed(binds[port][id].key))
|
||||
@ -272,16 +272,14 @@ static void sdl_input_free(void *data)
|
||||
while (SDL_PollEvent(&event));
|
||||
#endif
|
||||
|
||||
if (sdl->joypad)
|
||||
sdl->joypad->destroy();
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
static void sdl_grab_mouse(void *data, bool state)
|
||||
{
|
||||
#ifdef HAVE_SDL2
|
||||
struct temp{
|
||||
static void sdl2_grab_mouse(void *data, bool state)
|
||||
{
|
||||
struct temp
|
||||
{
|
||||
SDL_Window *w;
|
||||
};
|
||||
|
||||
@ -291,26 +289,20 @@ static void sdl_grab_mouse(void *data, bool state)
|
||||
/* First member of sdl2_video_t is the window */
|
||||
SDL_SetWindowGrab(((struct temp*)video_driver_get_ptr(false))->w,
|
||||
state ? SDL_TRUE : SDL_FALSE);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool sdl_set_rumble(void *data, unsigned port,
|
||||
static bool sdl_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
sdl_input_t *sdl = (sdl_input_t*)data;
|
||||
if (sdl)
|
||||
return input_joypad_set_rumble(sdl->joypad, port, effect, strength);
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad, port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
static const input_device_driver_t *sdl_get_joypad_driver(void *data)
|
||||
{
|
||||
sdl_input_t *sdl = (sdl_input_t*)data;
|
||||
if (!sdl)
|
||||
return NULL;
|
||||
return sdl->joypad;
|
||||
}
|
||||
|
||||
static void sdl_poll_mouse(sdl_input_t *sdl)
|
||||
{
|
||||
Uint8 btn = SDL_GetRelativeMouseState(&sdl->mouse_x, &sdl->mouse_y);
|
||||
@ -330,13 +322,11 @@ static void sdl_poll_mouse(sdl_input_t *sdl)
|
||||
|
||||
static void sdl_input_poll(void *data)
|
||||
{
|
||||
sdl_input_t *sdl = (sdl_input_t*)data;
|
||||
SDL_Event event;
|
||||
sdl_input_t *sdl = (sdl_input_t*)data;
|
||||
|
||||
SDL_PumpEvents();
|
||||
|
||||
if (sdl->joypad)
|
||||
sdl->joypad->poll();
|
||||
sdl_poll_mouse(sdl);
|
||||
|
||||
#ifdef HAVE_SDL2
|
||||
@ -408,13 +398,12 @@ input_driver_t input_sdl = {
|
||||
sdl_get_capabilities,
|
||||
#ifdef HAVE_SDL2
|
||||
"sdl2",
|
||||
sdl2_grab_mouse,
|
||||
#else
|
||||
"sdl",
|
||||
NULL, /* grab_mouse */
|
||||
#endif
|
||||
sdl_grab_mouse,
|
||||
NULL,
|
||||
sdl_set_rumble,
|
||||
sdl_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -92,8 +92,6 @@ typedef struct
|
||||
|
||||
typedef struct switch_input
|
||||
{
|
||||
const input_device_driver_t *joypad;
|
||||
|
||||
#ifdef HAVE_LIBNX
|
||||
/* pointer */
|
||||
bool touch_state[MULTITOUCH_LIMIT];
|
||||
@ -131,6 +129,8 @@ typedef struct switch_input
|
||||
/* sensor handles */
|
||||
uint32_t sixaxis_handles[DEFAULT_MAX_PADS][4];
|
||||
unsigned sixaxis_handles_count[DEFAULT_MAX_PADS];
|
||||
#else
|
||||
void *empty;
|
||||
#endif
|
||||
} switch_input_t;
|
||||
|
||||
@ -147,24 +147,17 @@ static void finish_simulated_mouse_clicks(switch_input_t *sw, uint64_t currentTi
|
||||
/* end of touch mouse function declarations */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBNX
|
||||
static void switch_input_poll(void *data)
|
||||
{
|
||||
#ifdef HAVE_LIBNX
|
||||
MousePosition mouse_pos;
|
||||
uint32_t touch_count;
|
||||
unsigned int i = 0;
|
||||
int keySym = 0;
|
||||
unsigned keyCode = 0;
|
||||
uint16_t mod = 0;
|
||||
uint64_t mouse_current_report = 0;
|
||||
#endif
|
||||
switch_input_t *sw = (switch_input_t*) data;
|
||||
|
||||
if (sw->joypad)
|
||||
sw->joypad->poll();
|
||||
|
||||
#ifdef HAVE_LIBNX
|
||||
touch_count = hidTouchCount();
|
||||
uint32_t touch_count = hidTouchCount();
|
||||
for (i = 0; i < MULTITOUCH_LIMIT; i++)
|
||||
{
|
||||
sw->previous_touch_state[i] = sw->touch_state[i];
|
||||
@ -283,10 +276,8 @@ static void switch_input_poll(void *data)
|
||||
sw->mouse_y = MOUSE_MAX_Y;
|
||||
|
||||
sw->mouse_wheel = mouse_pos.scrollVelocityY;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBNX
|
||||
static int16_t switch_pointer_screen_device_state(switch_input_t *sw,
|
||||
unsigned id, unsigned idx)
|
||||
{
|
||||
@ -394,12 +385,12 @@ static int16_t switch_input_state(void *data,
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
return sw->joypad->state(
|
||||
return joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
if (binds[port][id].valid)
|
||||
if (
|
||||
button_is_pressed(sw->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
break;
|
||||
@ -799,18 +790,15 @@ static void switch_input_free_input(void *data)
|
||||
unsigned i,j;
|
||||
switch_input_t *sw = (switch_input_t*) data;
|
||||
|
||||
if (sw)
|
||||
{
|
||||
if(sw->joypad)
|
||||
sw->joypad->destroy();
|
||||
if (!sw)
|
||||
return;
|
||||
|
||||
for (i = 0; i < DEFAULT_MAX_PADS; i++)
|
||||
if (sw->sixaxis_handles_count[i] > 0)
|
||||
for (j = 0; j < sw->sixaxis_handles_count[i]; j++)
|
||||
hidStopSixAxisSensor(sw->sixaxis_handles[i][j]);
|
||||
for (i = 0; i < DEFAULT_MAX_PADS; i++)
|
||||
if (sw->sixaxis_handles_count[i] > 0)
|
||||
for (j = 0; j < sw->sixaxis_handles_count[i]; j++)
|
||||
hidStopSixAxisSensor(sw->sixaxis_handles[i][j]);
|
||||
|
||||
free(sw);
|
||||
}
|
||||
free(sw);
|
||||
|
||||
#ifdef HAVE_LIBNX
|
||||
hidExit();
|
||||
@ -858,8 +846,6 @@ static void* switch_input_init(const char *joypad_driver)
|
||||
sw->sixaxis_handles_count[i] = 0;
|
||||
#endif
|
||||
|
||||
sw->joypad = input_joypad_init_driver(joypad_driver, sw);
|
||||
|
||||
return sw;
|
||||
}
|
||||
|
||||
@ -876,27 +862,15 @@ static uint64_t switch_input_get_capabilities(void *data)
|
||||
return caps;
|
||||
}
|
||||
|
||||
static const input_device_driver_t *switch_input_get_joypad_driver(void *data)
|
||||
{
|
||||
switch_input_t *sw = (switch_input_t*) data;
|
||||
if (sw)
|
||||
return sw->joypad;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void switch_input_grab_mouse(void *data, bool state)
|
||||
{
|
||||
(void)data;
|
||||
(void)state;
|
||||
}
|
||||
|
||||
static bool switch_input_set_rumble(void *data, unsigned port,
|
||||
static bool switch_input_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
#ifdef HAVE_LIBNX
|
||||
switch_input_t *sw = (switch_input_t*) data;
|
||||
if (sw)
|
||||
return input_joypad_set_rumble(sw->joypad, port, effect, strength);
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad, port, effect, strength);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -995,17 +969,19 @@ static float switch_input_get_sensor_input(void *data,
|
||||
|
||||
input_driver_t input_switch = {
|
||||
switch_input_init,
|
||||
#ifdef HAVE_LIBNX
|
||||
switch_input_poll,
|
||||
#else
|
||||
NULL, /* poll */
|
||||
#endif
|
||||
switch_input_state,
|
||||
switch_input_free_input,
|
||||
switch_input_set_sensor_state,
|
||||
switch_input_get_sensor_input,
|
||||
switch_input_get_capabilities,
|
||||
"switch",
|
||||
switch_input_grab_mouse,
|
||||
NULL, /* grab_mouse */
|
||||
NULL,
|
||||
switch_input_set_rumble,
|
||||
switch_input_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -130,7 +130,6 @@ struct udev_input
|
||||
{
|
||||
struct udev *udev;
|
||||
struct udev_monitor *monitor;
|
||||
const input_device_driver_t *joypad;
|
||||
udev_input_device_t **devices;
|
||||
|
||||
int fd;
|
||||
@ -776,9 +775,6 @@ static void udev_input_poll(void *data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (udev->joypad)
|
||||
udev->joypad->poll();
|
||||
}
|
||||
|
||||
static bool udev_pointer_is_off_window(const udev_input_t *udev)
|
||||
@ -982,6 +978,7 @@ static int16_t udev_pointer_state(udev_input_t *udev,
|
||||
|
||||
static int16_t udev_input_lightgun_state(
|
||||
udev_input_t *udev,
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device, unsigned idx, unsigned id)
|
||||
@ -994,7 +991,7 @@ static int16_t udev_input_lightgun_state(
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
unsigned new_id = id;
|
||||
if (button_is_pressed(udev->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
port, new_id)
|
||||
|| udev_mouse_button_pressed(udev, port,
|
||||
@ -1005,7 +1002,10 @@ static int16_t udev_input_lightgun_state(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t udev_input_state(void *data,
|
||||
static int16_t udev_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device, unsigned idx, unsigned id)
|
||||
@ -1018,7 +1018,7 @@ static int16_t udev_input_state(void *data,
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
{
|
||||
unsigned i;
|
||||
int16_t ret = udev->joypad->state(
|
||||
int16_t ret = joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
@ -1050,7 +1050,7 @@ static int16_t udev_input_state(void *data,
|
||||
{
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (button_is_pressed(udev->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
else if (
|
||||
@ -1099,37 +1099,48 @@ static int16_t udev_input_state(void *data,
|
||||
|
||||
/*buttons*/
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER:
|
||||
return udev_input_lightgun_state(udev, joypad_info,
|
||||
return udev_input_lightgun_state(udev, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_TRIGGER);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_RELOAD:
|
||||
return udev_input_lightgun_state(udev, joypad_info,
|
||||
return udev_input_lightgun_state(udev, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_RELOAD);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_AUX_A:
|
||||
return udev_input_lightgun_state(udev, joypad_info,
|
||||
return udev_input_lightgun_state(udev, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_AUX_A);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_AUX_B:
|
||||
return udev_input_lightgun_state(udev, joypad_info,
|
||||
return udev_input_lightgun_state(udev, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_AUX_B);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_AUX_C:
|
||||
return udev_input_lightgun_state(udev, joypad_info,
|
||||
return udev_input_lightgun_state(udev, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_AUX_C);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_START:
|
||||
return udev_input_lightgun_state(udev, joypad_info,
|
||||
return udev_input_lightgun_state(udev, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_START);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_SELECT:
|
||||
return udev_input_lightgun_state(udev, joypad_info,
|
||||
return udev_input_lightgun_state(udev, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_SELECT);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP:
|
||||
return udev_input_lightgun_state(udev, joypad_info,
|
||||
return udev_input_lightgun_state(udev, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_DPAD_UP);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN:
|
||||
return udev_input_lightgun_state(udev, joypad_info,
|
||||
return udev_input_lightgun_state(udev, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_DPAD_DOWN);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT:
|
||||
return udev_input_lightgun_state(udev, joypad_info,
|
||||
return udev_input_lightgun_state(udev, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_DPAD_LEFT);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT:
|
||||
return udev_input_lightgun_state(udev, joypad_info,
|
||||
return udev_input_lightgun_state(udev, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_DPAD_RIGHT);
|
||||
/*deprecated*/
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_X:
|
||||
@ -1150,7 +1161,7 @@ static int16_t udev_input_state(void *data,
|
||||
if (binds[port][RARCH_LIGHTGUN_START].valid)
|
||||
{
|
||||
unsigned new_id = RARCH_LIGHTGUN_START;
|
||||
if (button_is_pressed(udev->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
port, new_id)
|
||||
|| udev_mouse_button_pressed(udev, port,
|
||||
@ -1174,9 +1185,6 @@ static void udev_input_free(void *data)
|
||||
if (!data || !udev)
|
||||
return;
|
||||
|
||||
if (udev->joypad)
|
||||
udev->joypad->destroy();
|
||||
|
||||
if (udev->fd >= 0)
|
||||
close(udev->fd);
|
||||
|
||||
@ -1321,8 +1329,6 @@ static void *udev_input_init(const char *joypad_driver)
|
||||
RARCH_WARN("[udev]: Full-screen pointer won't be available.\n");
|
||||
#endif
|
||||
|
||||
udev->joypad = input_joypad_init_driver(joypad_driver, udev);
|
||||
|
||||
return udev;
|
||||
|
||||
error:
|
||||
@ -1368,24 +1374,18 @@ static void udev_input_grab_mouse(void *data, bool state)
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool udev_input_set_rumble(void *data, unsigned port,
|
||||
static bool udev_input_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
udev_input_t *udev = (udev_input_t*)data;
|
||||
if (udev && udev->joypad)
|
||||
return input_joypad_set_rumble(udev->joypad,
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad,
|
||||
port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
static const input_device_driver_t *udev_input_get_joypad_driver(void *data)
|
||||
{
|
||||
udev_input_t *udev = (udev_input_t*)data;
|
||||
if (!udev)
|
||||
return NULL;
|
||||
return udev->joypad;
|
||||
}
|
||||
|
||||
input_driver_t input_udev = {
|
||||
udev_input_init,
|
||||
udev_input_poll,
|
||||
@ -1402,7 +1402,5 @@ input_driver_t input_udev = {
|
||||
NULL,
|
||||
#endif
|
||||
udev_input_set_rumble,
|
||||
udev_input_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -31,16 +31,11 @@
|
||||
|
||||
typedef struct uwp_input
|
||||
{
|
||||
const input_device_driver_t *joypad;
|
||||
void *empty;
|
||||
} uwp_input_t;
|
||||
|
||||
static void uwp_input_poll(void *data)
|
||||
{
|
||||
uwp_input_t *uwp = (uwp_input_t*)data;
|
||||
|
||||
if (uwp && uwp->joypad)
|
||||
uwp->joypad->poll();
|
||||
|
||||
uwp_input_next_frame();
|
||||
}
|
||||
|
||||
@ -51,9 +46,6 @@ static void uwp_input_free_input(void *data)
|
||||
if (!uwp)
|
||||
return;
|
||||
|
||||
if (uwp->joypad)
|
||||
uwp->joypad->destroy();
|
||||
|
||||
free(uwp);
|
||||
}
|
||||
|
||||
@ -65,8 +57,6 @@ static void *uwp_input_init(const char *joypad_driver)
|
||||
|
||||
input_keymaps_init_keyboard_lut(rarch_key_map_uwp);
|
||||
|
||||
uwp->joypad = input_joypad_init_driver(joypad_driver, uwp);
|
||||
|
||||
return uwp;
|
||||
}
|
||||
|
||||
@ -83,29 +73,17 @@ static uint64_t uwp_input_get_capabilities(void *data)
|
||||
return caps;
|
||||
}
|
||||
|
||||
static bool uwp_input_set_rumble(void *data, unsigned port,
|
||||
static bool uwp_input_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
struct uwp_input *uwp = (struct uwp_input*)data;
|
||||
if (uwp)
|
||||
return input_joypad_set_rumble(uwp->joypad, port, effect, strength);
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad, port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
static const input_device_driver_t *uwp_input_get_joypad_driver(void *data)
|
||||
{
|
||||
uwp_input_t *uwp = (uwp_input_t*)data;
|
||||
if (!uwp)
|
||||
return NULL;
|
||||
return uwp->joypad;
|
||||
}
|
||||
|
||||
static void uwp_input_grab_mouse(void *data, bool state)
|
||||
{
|
||||
(void)data;
|
||||
(void)state;
|
||||
}
|
||||
|
||||
static int16_t uwp_pressed_analog(uwp_input_t *uwp,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind *binds,
|
||||
@ -134,7 +112,10 @@ static int16_t uwp_pressed_analog(uwp_input_t *uwp,
|
||||
return pressed_plus + pressed_minus;
|
||||
}
|
||||
|
||||
static int16_t uwp_input_state(void *data,
|
||||
static int16_t uwp_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device,
|
||||
@ -148,7 +129,7 @@ static int16_t uwp_input_state(void *data,
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
{
|
||||
unsigned i;
|
||||
int16_t ret = uwp->joypad->state(
|
||||
int16_t ret = joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
if (!input_uwp.keyboard_mapping_blocked)
|
||||
@ -184,7 +165,7 @@ static int16_t uwp_input_state(void *data,
|
||||
{
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (button_is_pressed(uwp->joypad, joypad_info,
|
||||
if (button_is_pressed(joypad, joypad_info,
|
||||
binds[port], port, id))
|
||||
return 1;
|
||||
else if ((binds[port][id].key < RETROK_LAST)
|
||||
@ -228,10 +209,8 @@ input_driver_t input_uwp = {
|
||||
NULL,
|
||||
uwp_input_get_capabilities,
|
||||
"uwp",
|
||||
uwp_input_grab_mouse,
|
||||
NULL, /* grab_mouse */
|
||||
NULL,
|
||||
uwp_input_set_rumble,
|
||||
uwp_input_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -151,9 +151,6 @@ static void input_wl_poll(void *data)
|
||||
wl->mouse.delta_y = 0;
|
||||
}
|
||||
|
||||
if (wl->joypad)
|
||||
wl->joypad->poll();
|
||||
|
||||
input_wl_touch_pool(wl);
|
||||
}
|
||||
|
||||
@ -295,7 +292,10 @@ static int16_t input_wl_touch_state(input_ctx_wayland_data_t *wl,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t input_wl_state(void *data,
|
||||
static int16_t input_wl_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device, unsigned idx, unsigned id)
|
||||
@ -308,7 +308,7 @@ static int16_t input_wl_state(void *data,
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
{
|
||||
unsigned i;
|
||||
int16_t ret = wl->joypad->state(
|
||||
int16_t ret = joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
@ -329,7 +329,8 @@ static int16_t input_wl_state(void *data,
|
||||
{
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (button_is_pressed(wl->joypad, joypad_info, binds[port],
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
else if (BIT_GET(wl->key_state,
|
||||
@ -371,9 +372,7 @@ static void input_wl_free(void *data)
|
||||
input_ctx_wayland_data_t *wl = (input_ctx_wayland_data_t*)data;
|
||||
if (!wl)
|
||||
return;
|
||||
|
||||
if (wl->joypad)
|
||||
wl->joypad->destroy();
|
||||
free(data);
|
||||
}
|
||||
|
||||
bool input_wl_init(void *data, const char *joypad_name)
|
||||
@ -385,11 +384,6 @@ bool input_wl_init(void *data, const char *joypad_name)
|
||||
|
||||
input_keymaps_init_keyboard_lut(rarch_key_map_linux);
|
||||
|
||||
wl->joypad = input_joypad_init_driver(joypad_name, wl);
|
||||
|
||||
if (!wl->joypad)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -412,23 +406,17 @@ static void input_wl_grab_mouse(void *data, bool state)
|
||||
(void)state;
|
||||
}
|
||||
|
||||
static bool input_wl_set_rumble(void *data, unsigned port,
|
||||
static bool input_wl_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
input_ctx_wayland_data_t *wl = (input_ctx_wayland_data_t*)data;
|
||||
if (wl && wl->joypad)
|
||||
return input_joypad_set_rumble(wl->joypad, port, effect, strength);
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad, port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
static const input_device_driver_t *input_wl_get_joypad_driver(void *data)
|
||||
{
|
||||
input_ctx_wayland_data_t *wl = (input_ctx_wayland_data_t*)data;
|
||||
if (!wl)
|
||||
return NULL;
|
||||
return wl->joypad;
|
||||
}
|
||||
|
||||
input_driver_t input_wayland = {
|
||||
NULL,
|
||||
input_wl_poll,
|
||||
@ -441,7 +429,5 @@ input_driver_t input_wayland = {
|
||||
input_wl_grab_mouse,
|
||||
NULL,
|
||||
input_wl_set_rumble,
|
||||
input_wl_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -41,7 +41,7 @@ static bool keyboard_state[RETROK_LAST] = { 0 };
|
||||
|
||||
typedef struct wiiu_input
|
||||
{
|
||||
const input_device_driver_t *joypad;
|
||||
void *empty;
|
||||
} wiiu_input_t;
|
||||
|
||||
static void kb_connection_callback(KBDKeyEvent *key)
|
||||
@ -94,35 +94,32 @@ static void kb_key_callback(KBDKeyEvent *key)
|
||||
hard to get working nicely.
|
||||
*/
|
||||
|
||||
static int16_t wiiu_pointer_device_state(wiiu_input_t* wiiu, unsigned id)
|
||||
static int16_t wiiu_pointer_device_state(
|
||||
wiiu_input_t* wiiu,
|
||||
const input_device_driver_t *joypad,
|
||||
unsigned id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case RETRO_DEVICE_ID_POINTER_PRESSED:
|
||||
{
|
||||
input_bits_t state;
|
||||
wiiu->joypad->get_buttons(0, &state);
|
||||
joypad->get_buttons(0, &state);
|
||||
return BIT256_GET(state, VPAD_BUTTON_TOUCH_BIT) ? 1 : 0;
|
||||
}
|
||||
case RETRO_DEVICE_ID_POINTER_X:
|
||||
return wiiu->joypad->axis(0, 0xFFFF0004UL);
|
||||
return joypad->axis(0, 0xFFFF0004UL);
|
||||
case RETRO_DEVICE_ID_POINTER_Y:
|
||||
return wiiu->joypad->axis(0, 0xFFFF0005UL);
|
||||
return joypad->axis(0, 0xFFFF0005UL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void wiiu_input_poll(void *data)
|
||||
{
|
||||
wiiu_input_t *wiiu = (wiiu_input_t*)data;
|
||||
|
||||
if (wiiu)
|
||||
if (wiiu->joypad)
|
||||
wiiu->joypad->poll();
|
||||
}
|
||||
|
||||
static int16_t wiiu_input_state(void *data,
|
||||
static int16_t wiiu_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device,
|
||||
@ -137,12 +134,12 @@ static int16_t wiiu_input_state(void *data,
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
return wiiu->joypad->state(
|
||||
return joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
if (binds[port][id].valid)
|
||||
return button_is_pressed(
|
||||
wiiu->joypad,
|
||||
joypad,
|
||||
joypad_info, binds[port], port, id);
|
||||
break;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
@ -153,7 +150,7 @@ static int16_t wiiu_input_state(void *data,
|
||||
break;
|
||||
case RETRO_DEVICE_POINTER:
|
||||
case RARCH_DEVICE_POINTER_SCREEN:
|
||||
return wiiu_pointer_device_state(wiiu, id);
|
||||
return wiiu_pointer_device_state(wiiu, joypad, id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -163,9 +160,6 @@ static void wiiu_input_free_input(void *data)
|
||||
{
|
||||
wiiu_input_t *wiiu = (wiiu_input_t*)data;
|
||||
|
||||
if (wiiu && wiiu->joypad)
|
||||
wiiu->joypad->destroy();
|
||||
|
||||
KBDTeardown();
|
||||
|
||||
free(data);
|
||||
@ -182,9 +176,6 @@ static void* wiiu_input_init(const char *joypad_driver)
|
||||
|
||||
input_keymaps_init_keyboard_lut(rarch_key_map_wiiu);
|
||||
|
||||
DEBUG_STR(joypad_driver);
|
||||
wiiu->joypad = input_joypad_init_driver(joypad_driver, wiiu);
|
||||
|
||||
return wiiu;
|
||||
}
|
||||
|
||||
@ -196,36 +187,17 @@ static uint64_t wiiu_input_get_capabilities(void *data)
|
||||
(1 << RETRO_DEVICE_POINTER);
|
||||
}
|
||||
|
||||
static const input_device_driver_t *wiiu_input_get_joypad_driver(void *data)
|
||||
{
|
||||
wiiu_input_t *wiiu = (wiiu_input_t*)data;
|
||||
if (wiiu)
|
||||
return wiiu->joypad;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void wiiu_input_grab_mouse(void *data, bool state)
|
||||
{
|
||||
(void)data;
|
||||
(void)state;
|
||||
}
|
||||
|
||||
static bool wiiu_input_set_rumble(void *data, unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength) { return false; }
|
||||
|
||||
input_driver_t input_wiiu = {
|
||||
wiiu_input_init,
|
||||
wiiu_input_poll,
|
||||
NULL, /* poll */
|
||||
wiiu_input_state,
|
||||
wiiu_input_free_input,
|
||||
NULL,
|
||||
NULL,
|
||||
wiiu_input_get_capabilities,
|
||||
"wiiu",
|
||||
wiiu_input_grab_mouse,
|
||||
NULL,
|
||||
wiiu_input_set_rumble,
|
||||
wiiu_input_get_joypad_driver,
|
||||
NULL, /* grab_mouse */
|
||||
NULL,
|
||||
NULL, /* set_rumble */
|
||||
false
|
||||
};
|
||||
|
@ -39,7 +39,6 @@ typedef struct
|
||||
winraw_keyboard_t keyboard;
|
||||
HWND window;
|
||||
winraw_mouse_t *mice;
|
||||
const input_device_driver_t *joypad;
|
||||
bool mouse_grab;
|
||||
} winraw_input_t;
|
||||
|
||||
@ -510,8 +509,6 @@ static void *winraw_init(const char *joypad_driver)
|
||||
if (!winraw_set_mouse_input(wr->window, false))
|
||||
goto error;
|
||||
|
||||
wr->joypad = input_joypad_init_driver(joypad_driver, wr);
|
||||
|
||||
return wr;
|
||||
|
||||
error:
|
||||
@ -558,14 +555,12 @@ static void winraw_poll(void *d)
|
||||
wr->mice[i].btn_b4 = g_mice[i].btn_b4;
|
||||
wr->mice[i].btn_b5 = g_mice[i].btn_b5;
|
||||
}
|
||||
|
||||
if (wr->joypad)
|
||||
wr->joypad->poll();
|
||||
}
|
||||
|
||||
static int16_t winraw_input_lightgun_state(
|
||||
winraw_input_t *wr,
|
||||
winraw_mouse_t *mouse,
|
||||
const input_device_driver_t *joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device, unsigned idx, unsigned id)
|
||||
@ -582,20 +577,23 @@ static int16_t winraw_input_lightgun_state(
|
||||
[id].mbutton))
|
||||
return 1;
|
||||
return button_is_pressed(
|
||||
wr->joypad, joypad_info, binds[port],
|
||||
joypad, joypad_info, binds[port],
|
||||
port, id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t winraw_input_state(void *d,
|
||||
static int16_t winraw_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device, unsigned idx, unsigned id)
|
||||
{
|
||||
settings_t *settings = NULL;
|
||||
winraw_mouse_t *mouse = NULL;
|
||||
winraw_input_t *wr = (winraw_input_t*)d;
|
||||
winraw_input_t *wr = (winraw_input_t*)data;
|
||||
bool process_mouse =
|
||||
(device == RETRO_DEVICE_JOYPAD)
|
||||
|| (device == RETRO_DEVICE_MOUSE)
|
||||
@ -625,7 +623,7 @@ static int16_t winraw_input_state(void *d,
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
{
|
||||
unsigned i;
|
||||
int16_t ret = wr->joypad->state(
|
||||
int16_t ret = joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
if (mouse)
|
||||
@ -663,7 +661,7 @@ static int16_t winraw_input_state(void *d,
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (button_is_pressed(
|
||||
wr->joypad,
|
||||
joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
else if (
|
||||
@ -704,37 +702,48 @@ static int16_t winraw_input_state(void *d,
|
||||
break;
|
||||
/*buttons*/
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER:
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad_info,
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_TRIGGER);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_RELOAD:
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad_info,
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_RELOAD);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_AUX_A:
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad_info,
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_AUX_A);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_AUX_B:
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad_info,
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_AUX_B);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_AUX_C:
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad_info,
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_AUX_C);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_START:
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad_info,
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_START);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_SELECT:
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad_info,
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_SELECT);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP:
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad_info,
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_DPAD_UP);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN:
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad_info,
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_DPAD_DOWN);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT:
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad_info,
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_DPAD_LEFT);
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT:
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad_info,
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_DPAD_RIGHT);
|
||||
/*deprecated*/
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_X:
|
||||
@ -743,7 +752,8 @@ static int16_t winraw_input_state(void *d,
|
||||
return winraw_deprecated_lightgun_state(wr, mouse, port, id);
|
||||
break;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE:
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad_info,
|
||||
return winraw_input_lightgun_state(wr, mouse, joypad,
|
||||
joypad_info,
|
||||
binds, port, device, idx, RARCH_LIGHTGUN_START);
|
||||
}
|
||||
break;
|
||||
@ -756,8 +766,6 @@ static void winraw_free(void *d)
|
||||
{
|
||||
winraw_input_t *wr = (winraw_input_t*)d;
|
||||
|
||||
if (wr->joypad)
|
||||
wr->joypad->destroy();
|
||||
winraw_set_mouse_input(NULL, false);
|
||||
winraw_set_keyboard_input(NULL);
|
||||
winraw_destroy_window(wr->window);
|
||||
@ -793,19 +801,15 @@ static void winraw_grab_mouse(void *d, bool grab)
|
||||
wr->mouse_grab = grab;
|
||||
}
|
||||
|
||||
static bool winraw_set_rumble(void *d, unsigned port,
|
||||
static bool winraw_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
winraw_input_t *wr = (winraw_input_t*)d;
|
||||
|
||||
return input_joypad_set_rumble(wr->joypad, port, effect, strength);
|
||||
}
|
||||
|
||||
static const input_device_driver_t *winraw_get_joypad_driver(void *d)
|
||||
{
|
||||
winraw_input_t *wr = (winraw_input_t*)d;
|
||||
|
||||
return wr->joypad;
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad, port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
input_driver_t input_winraw = {
|
||||
@ -820,7 +824,5 @@ input_driver_t input_winraw = {
|
||||
winraw_grab_mouse,
|
||||
NULL,
|
||||
winraw_set_rumble,
|
||||
winraw_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -34,8 +34,6 @@
|
||||
|
||||
typedef struct x11_input
|
||||
{
|
||||
const input_device_driver_t *joypad;
|
||||
|
||||
Display *display;
|
||||
Window win;
|
||||
|
||||
@ -66,8 +64,6 @@ static void *x_input_init(const char *joypad_driver)
|
||||
|
||||
input_keymaps_init_keyboard_lut(rarch_key_map_x11);
|
||||
|
||||
x11->joypad = input_joypad_init_driver(joypad_driver, x11);
|
||||
|
||||
return x11;
|
||||
}
|
||||
|
||||
@ -268,7 +264,10 @@ static int16_t x_pointer_state(x11_input_t *x11,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t x_input_state(void *data,
|
||||
static int16_t x_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds, unsigned port,
|
||||
unsigned device, unsigned idx, unsigned id)
|
||||
@ -285,7 +284,7 @@ static int16_t x_input_state(void *data,
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
{
|
||||
unsigned i;
|
||||
int16_t ret = x11->joypad->state(
|
||||
int16_t ret = joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
if (settings->uints.input_mouse_index[port] == 0)
|
||||
@ -321,7 +320,7 @@ static int16_t x_input_state(void *data,
|
||||
{
|
||||
if (binds[port][id].valid)
|
||||
{
|
||||
if (button_is_pressed( x11->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port], port, id))
|
||||
return 1;
|
||||
else if (
|
||||
@ -378,7 +377,7 @@ static int16_t x_input_state(void *data,
|
||||
return 1;
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (button_is_pressed( x11->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
port, new_id))
|
||||
return 1;
|
||||
@ -401,7 +400,7 @@ static int16_t x_input_state(void *data,
|
||||
return 1;
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (button_is_pressed( x11->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
port, new_id))
|
||||
return 1;
|
||||
@ -424,7 +423,7 @@ static int16_t x_input_state(void *data,
|
||||
return 1;
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (button_is_pressed( x11->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
port, new_id))
|
||||
return 1;
|
||||
@ -447,7 +446,7 @@ static int16_t x_input_state(void *data,
|
||||
return 1;
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (button_is_pressed( x11->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
port, new_id))
|
||||
return 1;
|
||||
@ -470,7 +469,7 @@ static int16_t x_input_state(void *data,
|
||||
return 1;
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (button_is_pressed( x11->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
port, new_id))
|
||||
return 1;
|
||||
@ -493,7 +492,7 @@ static int16_t x_input_state(void *data,
|
||||
return 1;
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (button_is_pressed( x11->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
port, new_id))
|
||||
return 1;
|
||||
@ -516,7 +515,7 @@ static int16_t x_input_state(void *data,
|
||||
return 1;
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (button_is_pressed( x11->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
port, new_id))
|
||||
return 1;
|
||||
@ -539,7 +538,7 @@ static int16_t x_input_state(void *data,
|
||||
return 1;
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (button_is_pressed( x11->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
port, new_id))
|
||||
return 1;
|
||||
@ -562,7 +561,7 @@ static int16_t x_input_state(void *data,
|
||||
return 1;
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (button_is_pressed( x11->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
port, new_id))
|
||||
return 1;
|
||||
@ -585,7 +584,7 @@ static int16_t x_input_state(void *data,
|
||||
return 1;
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (button_is_pressed( x11->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
port, new_id))
|
||||
return 1;
|
||||
@ -608,7 +607,7 @@ static int16_t x_input_state(void *data,
|
||||
return 1;
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (button_is_pressed( x11->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
port, new_id))
|
||||
return 1;
|
||||
@ -636,7 +635,7 @@ static int16_t x_input_state(void *data,
|
||||
return 1;
|
||||
if (binds[port][new_id].valid)
|
||||
{
|
||||
if (button_is_pressed( x11->joypad,
|
||||
if (button_is_pressed(joypad,
|
||||
joypad_info, binds[port],
|
||||
port, new_id))
|
||||
return 1;
|
||||
@ -663,9 +662,6 @@ static void x_input_free(void *data)
|
||||
if (!x11)
|
||||
return;
|
||||
|
||||
if (x11->joypad)
|
||||
x11->joypad->destroy();
|
||||
|
||||
free(x11);
|
||||
}
|
||||
|
||||
@ -738,9 +734,6 @@ static void x_input_poll(void *data)
|
||||
memset(x11->state, 0, sizeof(x11->state));
|
||||
|
||||
x_input_poll_mouse(x11, video_has_focus);
|
||||
|
||||
if (x11->joypad)
|
||||
x11->joypad->poll();
|
||||
}
|
||||
|
||||
static void x_grab_mouse(void *data, bool state)
|
||||
@ -750,24 +743,17 @@ static void x_grab_mouse(void *data, bool state)
|
||||
x11->grab_mouse = state;
|
||||
}
|
||||
|
||||
static bool x_set_rumble(void *data, unsigned port,
|
||||
static bool x_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
x11_input_t *x11 = (x11_input_t*)data;
|
||||
if (x11)
|
||||
return input_joypad_set_rumble(x11->joypad, port, effect, strength);
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad, port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
static const input_device_driver_t *x_get_joypad_driver(void *data)
|
||||
{
|
||||
x11_input_t *x11 = (x11_input_t*)data;
|
||||
|
||||
if (!x11)
|
||||
return NULL;
|
||||
return x11->joypad;
|
||||
}
|
||||
|
||||
static uint64_t x_input_get_capabilities(void *data)
|
||||
{
|
||||
uint64_t caps = 0;
|
||||
@ -794,7 +780,5 @@ input_driver_t input_x = {
|
||||
x_grab_mouse,
|
||||
NULL,
|
||||
x_set_rumble,
|
||||
x_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -37,18 +37,13 @@
|
||||
|
||||
typedef struct xdk_input
|
||||
{
|
||||
const input_device_driver_t *joypad;
|
||||
void *empty;
|
||||
} xdk_input_t;
|
||||
|
||||
static void xdk_input_poll(void *data)
|
||||
{
|
||||
xdk_input_t *xdk = (xdk_input_t*)data;
|
||||
|
||||
if (xdk && xdk->joypad)
|
||||
xdk->joypad->poll();
|
||||
}
|
||||
|
||||
static int16_t xdk_input_state(void *data,
|
||||
static int16_t xdk_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device,
|
||||
@ -63,12 +58,12 @@ static int16_t xdk_input_state(void *data,
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
return xdk->joypad->state(
|
||||
return joypad->state(
|
||||
joypad_info, binds[port], port);
|
||||
|
||||
if (binds[port][id].valid)
|
||||
if (
|
||||
button_is_pressed(xdk->joypad, joypad_info, binds[port],
|
||||
button_is_pressed(joypad, joypad_info, binds[port],
|
||||
port, id))
|
||||
return 1;
|
||||
break;
|
||||
@ -86,9 +81,6 @@ static void xdk_input_free_input(void *data)
|
||||
if (!xdk)
|
||||
return;
|
||||
|
||||
if (xdk->joypad)
|
||||
xdk->joypad->destroy();
|
||||
|
||||
free(xdk);
|
||||
}
|
||||
|
||||
@ -98,57 +90,39 @@ static void *xdk_input_init(const char *joypad_driver)
|
||||
if (!xdk)
|
||||
return NULL;
|
||||
|
||||
xdk->joypad = input_joypad_init_driver(joypad_driver, xdk);
|
||||
|
||||
return xdk;
|
||||
}
|
||||
|
||||
static uint64_t xdk_input_get_capabilities(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
return (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG);
|
||||
}
|
||||
|
||||
/* FIXME - are we sure about treating low frequency motor as the
|
||||
* "strong" motor? Does it apply for Xbox too? */
|
||||
|
||||
static bool xdk_input_set_rumble(void *data, unsigned port,
|
||||
static bool xdk_input_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
xdk_input_t *xdk = (xdk_input_t*)data;
|
||||
if (xdk)
|
||||
return input_joypad_set_rumble(xdk->joypad, port, effect, strength);
|
||||
if (joypad)
|
||||
return input_joypad_set_rumble(joypad, port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
static const input_device_driver_t *xdk_input_get_joypad_driver(void *data)
|
||||
{
|
||||
xdk_input_t *xdk = (xdk_input_t*)data;
|
||||
if (!xdk)
|
||||
return NULL;
|
||||
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,
|
||||
NULL, /* poll */
|
||||
xdk_input_state,
|
||||
xdk_input_free_input,
|
||||
NULL,
|
||||
NULL,
|
||||
xdk_input_get_capabilities,
|
||||
"xinput",
|
||||
xdk_input_grab_mouse,
|
||||
NULL, /* grab_mouse */
|
||||
NULL,
|
||||
xdk_input_set_rumble,
|
||||
xdk_input_get_joypad_driver,
|
||||
NULL,
|
||||
false
|
||||
};
|
||||
|
@ -61,7 +61,10 @@ static void xenon360_input_poll(void *data)
|
||||
}
|
||||
}
|
||||
|
||||
static int16_t xenon360_input_state(void *data,
|
||||
static int16_t xenon360_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
bool port, unsigned device,
|
||||
@ -109,7 +112,7 @@ static int16_t xenon360_input_state(void *data,
|
||||
|
||||
static void xenon360_input_free_input(void *data)
|
||||
{
|
||||
(void)data;
|
||||
free(data);
|
||||
}
|
||||
|
||||
static void* xenon360_input_init(const char *joypad_driver)
|
||||
@ -119,25 +122,7 @@ static void* xenon360_input_init(const char *joypad_driver)
|
||||
|
||||
static uint64_t xenon360_input_get_capabilities(void *data)
|
||||
{
|
||||
uint64_t caps = 0;
|
||||
|
||||
caps |= (1 << RETRO_DEVICE_JOYPAD);
|
||||
|
||||
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) { return false; }
|
||||
|
||||
static const input_device_driver_t *xenon360_get_joypad_driver(void *data)
|
||||
{
|
||||
return NULL;
|
||||
return (1 << RETRO_DEVICE_JOYPAD);
|
||||
}
|
||||
|
||||
input_driver_t input_xenon360 = {
|
||||
@ -150,10 +135,8 @@ input_driver_t input_xenon360 = {
|
||||
NULL,
|
||||
xenon360_input_get_capabilities,
|
||||
"xenon360",
|
||||
xenon360_input_grab_mouse,
|
||||
NULL,
|
||||
xenon360_input_set_rumble,
|
||||
xenon360_get_joypad_driver,
|
||||
NULL, /* grab_mouse */
|
||||
NULL,
|
||||
NULL, /* set_rumble */
|
||||
false
|
||||
};
|
||||
|
@ -181,6 +181,8 @@ struct input_driver
|
||||
* Analog values have same range as a signed 16-bit integer.
|
||||
*/
|
||||
int16_t (*input_state)(void *data,
|
||||
const input_device_driver_t *joypad_data,
|
||||
const input_device_driver_t *sec_joypad_data,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **retro_keybinds,
|
||||
unsigned port, unsigned device, unsigned index, unsigned id);
|
||||
@ -196,10 +198,11 @@ struct input_driver
|
||||
|
||||
void (*grab_mouse)(void *data, bool state);
|
||||
bool (*grab_stdin)(void *data);
|
||||
bool (*set_rumble)(void *data, unsigned port,
|
||||
bool (*set_rumble)(
|
||||
const input_device_driver_t *joypad_data,
|
||||
const input_device_driver_t *sec_joypad_data,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t state);
|
||||
const input_device_driver_t *(*get_joypad_driver)(void *data);
|
||||
const input_device_driver_t *(*get_sec_joypad_driver)(void *data);
|
||||
bool keyboard_mapping_blocked;
|
||||
};
|
||||
|
||||
|
317
retroarch.c
317
retroarch.c
@ -676,10 +676,13 @@ static const gfx_ctx_driver_t *gfx_ctx_gl_drivers[] = {
|
||||
|
||||
static void *input_null_init(const char *joypad_driver) { return (void*)-1; }
|
||||
static void input_null_poll(void *data) { }
|
||||
static int16_t input_null_input_state(void *data,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **retro_keybinds,
|
||||
unsigned port, unsigned device, unsigned index, unsigned id) { return 0; }
|
||||
static int16_t input_null_input_state(
|
||||
void *data,
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
rarch_joypad_info_t *joypad_info,
|
||||
const struct retro_keybind **retro_keybinds,
|
||||
unsigned port, unsigned device, unsigned index, unsigned id) { return 0; }
|
||||
static void input_null_free(void *data) { }
|
||||
static bool input_null_set_sensor_state(void *data, unsigned port,
|
||||
enum retro_sensor_action action, unsigned rate) { return false; }
|
||||
@ -687,10 +690,11 @@ static float input_null_get_sensor_input(void *data, unsigned port, unsigned id)
|
||||
static uint64_t input_null_get_capabilities(void *data) { return 0; }
|
||||
static void input_null_grab_mouse(void *data, bool state) { }
|
||||
static bool input_null_grab_stdin(void *data) { return false; }
|
||||
static bool input_null_set_rumble(void *data, unsigned port,
|
||||
static bool input_null_set_rumble(
|
||||
const input_device_driver_t *joypad,
|
||||
const input_device_driver_t *sec_joypad,
|
||||
unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t state) { return false; }
|
||||
static const input_device_driver_t *input_null_get_joypad_driver(void *data) { return NULL; }
|
||||
static const input_device_driver_t *input_null_get_sec_joypad_driver(void *data) { return NULL; }
|
||||
|
||||
static input_driver_t input_null = {
|
||||
input_null_init,
|
||||
@ -704,8 +708,6 @@ static input_driver_t input_null = {
|
||||
input_null_grab_mouse,
|
||||
input_null_grab_stdin,
|
||||
input_null_set_rumble,
|
||||
input_null_get_joypad_driver,
|
||||
input_null_get_sec_joypad_driver,
|
||||
false,
|
||||
};
|
||||
|
||||
@ -2135,6 +2137,7 @@ struct rarch_state
|
||||
core_info_state_t core_info_st; /* ptr alignment */
|
||||
rarch_system_info_t runloop_system; /* ptr alignment */
|
||||
struct retro_hw_render_callback hw_render; /* ptr alignment */
|
||||
const input_device_driver_t *joypad; /* ptr alignment */
|
||||
#ifdef HAVE_BSV_MOVIE
|
||||
bsv_movie_t *bsv_movie_state_handle; /* ptr alignment */
|
||||
#endif
|
||||
@ -2798,7 +2801,6 @@ static void retro_frame_null(const void *data, unsigned width,
|
||||
static void retro_run_null(void);
|
||||
static void retro_input_poll_null(void);
|
||||
|
||||
static const input_device_driver_t *input_driver_get_sec_joypad_driver(void);
|
||||
static uint64_t input_driver_get_capabilities(void);
|
||||
|
||||
static void uninit_libretro_symbols(
|
||||
@ -3531,10 +3533,12 @@ static void menu_input_key_bind_poll_bind_get_rested_axes(
|
||||
struct menu_bind_state *state)
|
||||
{
|
||||
unsigned a;
|
||||
const input_device_driver_t *joypad =
|
||||
p_rarch->current_input->get_joypad_driver(p_rarch->current_input_data);
|
||||
const input_device_driver_t *sec_joypad =
|
||||
input_driver_get_sec_joypad_driver();
|
||||
const input_device_driver_t *joypad = p_rarch->joypad;
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t *sec_joypad = p_rarch->sec_joypad;
|
||||
#else
|
||||
const input_device_driver_t *sec_joypad = NULL;
|
||||
#endif
|
||||
unsigned port = state->port;
|
||||
|
||||
if (!joypad)
|
||||
@ -3614,14 +3618,12 @@ static void menu_input_key_bind_poll_bind_state(
|
||||
input_driver_t *current_input = p_rarch->current_input;
|
||||
void *input_data = p_rarch->current_input_data;
|
||||
unsigned port = state->port;
|
||||
const input_device_driver_t *joypad = NULL;
|
||||
const input_device_driver_t *sec_joypad =
|
||||
input_driver_get_sec_joypad_driver();
|
||||
|
||||
if ( current_input
|
||||
&& current_input->get_joypad_driver)
|
||||
joypad =
|
||||
current_input->get_joypad_driver(input_data);
|
||||
const input_device_driver_t *joypad = p_rarch->joypad;
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t *sec_joypad = p_rarch->sec_joypad;
|
||||
#else
|
||||
const input_device_driver_t *sec_joypad = NULL;
|
||||
#endif
|
||||
|
||||
memset(state->state, 0, sizeof(state->state));
|
||||
|
||||
@ -3636,10 +3638,13 @@ static void menu_input_key_bind_poll_bind_state(
|
||||
|
||||
state->skip =
|
||||
timed_out ||
|
||||
current_input->input_state(input_data,
|
||||
&joypad_info,
|
||||
NULL,
|
||||
0, RETRO_DEVICE_KEYBOARD, 0, RETROK_RETURN);
|
||||
current_input->input_state(
|
||||
input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
&joypad_info,
|
||||
NULL,
|
||||
0, RETRO_DEVICE_KEYBOARD, 0, RETROK_RETURN);
|
||||
|
||||
menu_input_key_bind_poll_bind_state_internal(
|
||||
joypad, state, port, timed_out);
|
||||
@ -15617,11 +15622,24 @@ static void command_event_reinit(struct rarch_state *p_rarch,
|
||||
bool adaptive_vsync = settings->bools.video_adaptive_vsync;
|
||||
unsigned swap_interval = settings->uints.video_swap_interval;
|
||||
#endif
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t *sec_joypad = p_rarch->sec_joypad;
|
||||
#else
|
||||
const input_device_driver_t *sec_joypad = NULL;
|
||||
#endif
|
||||
|
||||
video_driver_reinit(flags);
|
||||
/* Poll input to avoid possibly stale data to corrupt things. */
|
||||
if (p_rarch->current_input && p_rarch->current_input->poll)
|
||||
{
|
||||
if (p_rarch->joypad->poll)
|
||||
p_rarch->joypad->poll();
|
||||
#ifdef HAVE_MFI
|
||||
if (p_rarch->sec_joypad->poll)
|
||||
p_rarch->sec_joypad->poll();
|
||||
#endif
|
||||
p_rarch->current_input->poll(p_rarch->current_input_data);
|
||||
}
|
||||
command_event(CMD_EVENT_GAME_FOCUS_TOGGLE, (void*)(intptr_t)-1);
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
@ -23377,6 +23395,11 @@ static void input_poll_overlay(
|
||||
settings_t *settings = p_rarch->configuration_settings;
|
||||
bool input_overlay_show_physical_inputs = settings->bools.input_overlay_show_physical_inputs;
|
||||
unsigned input_overlay_show_physical_inputs_port = settings->uints.input_overlay_show_physical_inputs_port;
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t *sec_joypad = p_rarch->sec_joypad;
|
||||
#else
|
||||
const input_device_driver_t *sec_joypad = NULL;
|
||||
#endif
|
||||
|
||||
if (!ol_state)
|
||||
return;
|
||||
@ -23393,16 +23416,28 @@ static void input_poll_overlay(
|
||||
RARCH_DEVICE_POINTER_SCREEN : RETRO_DEVICE_POINTER;
|
||||
|
||||
for (i = 0;
|
||||
input_ptr->input_state(input_data, &joypad_info,
|
||||
input_ptr->input_state(
|
||||
input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
&joypad_info,
|
||||
NULL,
|
||||
0, device, i, RETRO_DEVICE_ID_POINTER_PRESSED);
|
||||
i++)
|
||||
{
|
||||
input_overlay_state_t polled_data;
|
||||
int16_t x = input_ptr->input_state(input_data, &joypad_info,
|
||||
int16_t x = input_ptr->input_state(
|
||||
input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
&joypad_info,
|
||||
NULL,
|
||||
0, device, i, RETRO_DEVICE_ID_POINTER_X);
|
||||
int16_t y = input_ptr->input_state(input_data, &joypad_info,
|
||||
int16_t y = input_ptr->input_state(
|
||||
input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
&joypad_info,
|
||||
NULL,
|
||||
0, device, i, RETRO_DEVICE_ID_POINTER_Y);
|
||||
|
||||
@ -23712,19 +23747,47 @@ const char* config_get_input_driver_options(void)
|
||||
bool input_driver_set_rumble_state(unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
if (!p_rarch->current_input || !p_rarch->current_input->set_rumble)
|
||||
return false;
|
||||
return p_rarch->current_input->set_rumble(p_rarch->current_input_data,
|
||||
port, effect, strength);
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
if (p_rarch->current_input && p_rarch->current_input->set_rumble)
|
||||
{
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t *sec_joypad = p_rarch->sec_joypad;
|
||||
#else
|
||||
const input_device_driver_t *sec_joypad = NULL;
|
||||
#endif
|
||||
return p_rarch->current_input->set_rumble(p_rarch->joypad,
|
||||
sec_joypad,
|
||||
port, effect, strength);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static const input_device_driver_t *input_driver_get_sec_joypad_driver(void)
|
||||
const char *joypad_driver_name(unsigned i)
|
||||
{
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
if (!p_rarch->current_input || !p_rarch->current_input->get_sec_joypad_driver)
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
if (!p_rarch || !p_rarch->joypad || !p_rarch->joypad->name)
|
||||
return NULL;
|
||||
return p_rarch->current_input->get_sec_joypad_driver(p_rarch->current_input_data);
|
||||
return p_rarch->joypad->name(i);
|
||||
}
|
||||
|
||||
void joypad_driver_reinit(void *data, const char *joypad_driver_name)
|
||||
{
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
if (!p_rarch)
|
||||
return;
|
||||
|
||||
if (p_rarch->joypad)
|
||||
p_rarch->joypad->destroy();
|
||||
p_rarch->joypad = NULL;
|
||||
#ifdef HAVE_MFI
|
||||
if (p_rarch->sec_joypad)
|
||||
p_rarch->sec_joypad->destroy();
|
||||
p_rarch->sec_joypad = NULL;
|
||||
#endif
|
||||
p_rarch->joypad = input_joypad_init_driver(joypad_driver_name, data);
|
||||
#ifdef HAVE_MFI
|
||||
p_rarch->sec_joypad = input_joypad_init_driver("mfi", data);
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint64_t input_driver_get_capabilities(void)
|
||||
@ -23776,12 +23839,25 @@ static void input_driver_poll(void)
|
||||
rarch_joypad_info_t joypad_info[MAX_USERS];
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
settings_t *settings = p_rarch->configuration_settings;
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t
|
||||
*sec_joypad = p_rarch->sec_joypad;
|
||||
#else
|
||||
const input_device_driver_t
|
||||
*sec_joypad = NULL;
|
||||
#endif
|
||||
#ifdef HAVE_OVERLAY
|
||||
float input_overlay_opacity = settings->floats.input_overlay_opacity;
|
||||
#endif
|
||||
bool input_remap_binds_enable = settings->bools.input_remap_binds_enable;
|
||||
uint8_t max_users = (uint8_t)p_rarch->input_driver_max_users;
|
||||
|
||||
if (p_rarch->joypad->poll)
|
||||
p_rarch->joypad->poll();
|
||||
#ifdef HAVE_MFI
|
||||
if (p_rarch->sec_joypad->poll)
|
||||
p_rarch->sec_joypad->poll();
|
||||
#endif
|
||||
p_rarch->current_input->poll(p_rarch->current_input_data);
|
||||
|
||||
p_rarch->input_driver_turbo_btns.count++;
|
||||
@ -23800,8 +23876,13 @@ static void input_driver_poll(void)
|
||||
if (!p_rarch->libretro_input_binds[i][RARCH_TURBO_ENABLE].valid)
|
||||
continue;
|
||||
|
||||
p_rarch->input_driver_turbo_btns.frame_enable[i] = p_rarch->current_input->input_state(
|
||||
p_rarch->current_input_data, &joypad_info[i], p_rarch->libretro_input_binds,
|
||||
p_rarch->input_driver_turbo_btns.frame_enable[i] =
|
||||
p_rarch->current_input->input_state(
|
||||
p_rarch->current_input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
&joypad_info[i],
|
||||
p_rarch->libretro_input_binds,
|
||||
(unsigned)i, RETRO_DEVICE_JOYPAD, 0, RARCH_TURBO_ENABLE);
|
||||
}
|
||||
|
||||
@ -23825,7 +23906,7 @@ static void input_driver_poll(void)
|
||||
#endif
|
||||
input_mapper_t *handle = p_rarch->input_driver_mapper;
|
||||
const input_device_driver_t *joypad_driver
|
||||
= p_rarch->current_input->get_joypad_driver(p_rarch->current_input_data);
|
||||
= p_rarch->joypad;
|
||||
|
||||
memset(handle->keys, 0, sizeof(handle->keys));
|
||||
|
||||
@ -23849,6 +23930,8 @@ static void input_driver_poll(void)
|
||||
unsigned k, j;
|
||||
int16_t ret = p_rarch->current_input->input_state(
|
||||
p_rarch->current_input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
&joypad_info[i],
|
||||
p_rarch->libretro_input_binds,
|
||||
(unsigned)i, RETRO_DEVICE_JOYPAD,
|
||||
@ -24512,6 +24595,13 @@ static int16_t input_state(unsigned port, unsigned device,
|
||||
settings_t *settings = p_rarch->configuration_settings;
|
||||
int16_t result = 0;
|
||||
int16_t ret = 0;
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t
|
||||
*sec_joypad = p_rarch->sec_joypad;
|
||||
#else
|
||||
const input_device_driver_t
|
||||
*sec_joypad = NULL;
|
||||
#endif
|
||||
|
||||
joypad_info.axis_threshold = p_rarch->input_driver_axis_threshold;
|
||||
joypad_info.joy_idx = settings->uints.input_joypad_map[port];
|
||||
@ -24535,17 +24625,21 @@ static int16_t input_state(unsigned port, unsigned device,
|
||||
|
||||
device &= RETRO_DEVICE_MASK;
|
||||
ret = p_rarch->current_input->input_state(
|
||||
p_rarch->current_input_data, &joypad_info,
|
||||
p_rarch->current_input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
&joypad_info,
|
||||
p_rarch->libretro_input_binds, port, device, idx, id);
|
||||
|
||||
if ( (device == RETRO_DEVICE_ANALOG) &&
|
||||
(ret == 0))
|
||||
{
|
||||
const input_device_driver_t *joypad =
|
||||
p_rarch->current_input->get_joypad_driver(
|
||||
p_rarch->current_input_data);
|
||||
const input_device_driver_t *sec_joypad =
|
||||
input_driver_get_sec_joypad_driver();
|
||||
const input_device_driver_t *joypad = p_rarch->joypad;
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t *sec_joypad = p_rarch->sec_joypad;
|
||||
#else
|
||||
const input_device_driver_t *sec_joypad = NULL;
|
||||
#endif
|
||||
if (p_rarch->libretro_input_binds[port])
|
||||
{
|
||||
if (idx == RETRO_DEVICE_INDEX_ANALOG_BUTTON)
|
||||
@ -24697,6 +24791,13 @@ static int16_t menu_input_read_mouse_hw(
|
||||
rarch_joypad_info_t joypad_info;
|
||||
unsigned type = 0;
|
||||
unsigned device = RETRO_DEVICE_MOUSE;
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t
|
||||
*sec_joypad = p_rarch->sec_joypad;
|
||||
#else
|
||||
const input_device_driver_t
|
||||
*sec_joypad = NULL;
|
||||
#endif
|
||||
|
||||
joypad_info.joy_idx = 0;
|
||||
joypad_info.auto_binds = NULL;
|
||||
@ -24733,7 +24834,10 @@ static int16_t menu_input_read_mouse_hw(
|
||||
}
|
||||
|
||||
return p_rarch->current_input->input_state(
|
||||
p_rarch->current_input_data, &joypad_info,
|
||||
p_rarch->current_input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
&joypad_info,
|
||||
NULL, 0, device, 0, type);
|
||||
}
|
||||
|
||||
@ -24882,6 +24986,13 @@ static void menu_input_get_touchscreen_hw_state(
|
||||
static bool last_cancel_pressed = false;
|
||||
bool overlay_active = false;
|
||||
bool pointer_enabled = settings->bools.menu_pointer_enable;
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t
|
||||
*sec_joypad = p_rarch->sec_joypad;
|
||||
#else
|
||||
const input_device_driver_t
|
||||
*sec_joypad = NULL;
|
||||
#endif
|
||||
|
||||
/* Easiest to set inactive by default, and toggle
|
||||
* when input is detected */
|
||||
@ -24920,7 +25031,10 @@ static void menu_input_get_touchscreen_hw_state(
|
||||
|
||||
/* X pos */
|
||||
pointer_x = p_rarch->current_input->input_state(
|
||||
p_rarch->current_input_data, &joypad_info, binds,
|
||||
p_rarch->current_input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
&joypad_info, binds,
|
||||
0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_X);
|
||||
hw_state->x = ((pointer_x + 0x7fff) * (int)fb_width) / 0xFFFF;
|
||||
|
||||
@ -24944,7 +25058,10 @@ static void menu_input_get_touchscreen_hw_state(
|
||||
|
||||
/* Y pos */
|
||||
pointer_y = p_rarch->current_input->input_state(
|
||||
p_rarch->current_input_data, &joypad_info, binds,
|
||||
p_rarch->current_input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
&joypad_info, binds,
|
||||
0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_Y);
|
||||
hw_state->y = ((pointer_y + 0x7fff) * (int)fb_height) / 0xFFFF;
|
||||
|
||||
@ -24964,7 +25081,10 @@ static void menu_input_get_touchscreen_hw_state(
|
||||
/* Select (touch screen contact)
|
||||
* Note that releasing select also counts as activity */
|
||||
hw_state->select_pressed = (bool)p_rarch->current_input->input_state(
|
||||
p_rarch->current_input_data, &joypad_info, binds,
|
||||
p_rarch->current_input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
&joypad_info, binds,
|
||||
0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_PRESSED);
|
||||
if (hw_state->select_pressed || (hw_state->select_pressed != last_select_pressed))
|
||||
hw_state->active = true;
|
||||
@ -24973,7 +25093,10 @@ static void menu_input_get_touchscreen_hw_state(
|
||||
/* Cancel (touch screen 'back' - don't know what is this, but whatever...)
|
||||
* Note that releasing cancel also counts as activity */
|
||||
hw_state->cancel_pressed = (bool)p_rarch->current_input->input_state(
|
||||
p_rarch->current_input_data, &joypad_info, binds,
|
||||
p_rarch->current_input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
&joypad_info, binds,
|
||||
0, pointer_device, 0, RARCH_DEVICE_ID_POINTER_BACK);
|
||||
if (hw_state->cancel_pressed || (hw_state->cancel_pressed != last_cancel_pressed))
|
||||
hw_state->active = true;
|
||||
@ -26216,11 +26339,21 @@ static void input_keys_pressed(
|
||||
rarch_joypad_info_t *joypad_info)
|
||||
{
|
||||
unsigned i;
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t
|
||||
*sec_joypad = p_rarch->sec_joypad;
|
||||
#else
|
||||
const input_device_driver_t
|
||||
*sec_joypad = NULL;
|
||||
#endif
|
||||
|
||||
if (CHECK_INPUT_DRIVER_BLOCK_HOTKEY(binds_norm, binds_auto))
|
||||
{
|
||||
if ( p_rarch->current_input->input_state(
|
||||
p_rarch->current_input_data, joypad_info,
|
||||
p_rarch->current_input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
joypad_info,
|
||||
&binds[port], port, RETRO_DEVICE_JOYPAD, 0,
|
||||
RARCH_ENABLE_HOTKEY))
|
||||
{
|
||||
@ -26251,6 +26384,8 @@ static void input_keys_pressed(
|
||||
{
|
||||
if (p_rarch->current_input->input_state(
|
||||
p_rarch->current_input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
joypad_info,
|
||||
&binds[port], port,
|
||||
RETRO_DEVICE_JOYPAD, 0, RARCH_GAME_FOCUS_TOGGLE))
|
||||
@ -26274,6 +26409,8 @@ static void input_keys_pressed(
|
||||
{
|
||||
int16_t ret = p_rarch->current_input->input_state(
|
||||
p_rarch->current_input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
joypad_info, &binds[port], port, RETRO_DEVICE_JOYPAD, 0,
|
||||
RETRO_DEVICE_ID_JOYPAD_MASK);
|
||||
|
||||
@ -26308,7 +26445,10 @@ static void input_keys_pressed(
|
||||
{
|
||||
bool bit_pressed = binds[port][i].valid
|
||||
&& p_rarch->current_input->input_state(
|
||||
p_rarch->current_input_data, joypad_info,
|
||||
p_rarch->current_input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
joypad_info,
|
||||
&binds[port], port, RETRO_DEVICE_JOYPAD, 0, i);
|
||||
if ( bit_pressed
|
||||
|| BIT64_GET(lifecycle_state, i)
|
||||
@ -26326,13 +26466,41 @@ void *input_driver_get_data(void)
|
||||
return p_rarch->current_input_data;
|
||||
}
|
||||
|
||||
void input_driver_init_joypads(void)
|
||||
{
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
settings_t *settings = p_rarch->configuration_settings;
|
||||
p_rarch->joypad = input_joypad_init_driver(
|
||||
settings->arrays.input_joypad_driver,
|
||||
p_rarch->current_input_data);
|
||||
#ifdef HAVE_MFI
|
||||
p_rarch->sec_joypad = input_joypad_init_driver(
|
||||
"mfi",
|
||||
p_rarch->current_input_data);
|
||||
#endif
|
||||
}
|
||||
|
||||
void *input_driver_init_wrap(input_driver_t *input, const char *name)
|
||||
{
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
void *ret = NULL;
|
||||
if (!input)
|
||||
return NULL;
|
||||
if ((ret = input->init(name)))
|
||||
{
|
||||
input_driver_init_joypads();
|
||||
return ret;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool input_driver_init(struct rarch_state *p_rarch)
|
||||
{
|
||||
if (p_rarch->current_input)
|
||||
{
|
||||
settings_t *settings = p_rarch->configuration_settings;
|
||||
p_rarch->current_input_data = p_rarch->current_input->init(
|
||||
settings->arrays.input_joypad_driver);
|
||||
p_rarch->current_input_data = input_driver_init_wrap(
|
||||
p_rarch->current_input, settings->arrays.input_joypad_driver);
|
||||
}
|
||||
|
||||
return (p_rarch->current_input_data != NULL);
|
||||
@ -26885,6 +27053,13 @@ static bool input_mouse_button_raw(
|
||||
{
|
||||
rarch_joypad_info_t joypad_info;
|
||||
settings_t *settings = p_rarch->configuration_settings;
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t
|
||||
*sec_joypad = p_rarch->sec_joypad;
|
||||
#else
|
||||
const input_device_driver_t
|
||||
*sec_joypad = NULL;
|
||||
#endif
|
||||
|
||||
/*ignore axes*/
|
||||
if (id == RETRO_DEVICE_ID_MOUSE_X || id == RETRO_DEVICE_ID_MOUSE_Y)
|
||||
@ -26896,8 +27071,14 @@ static bool input_mouse_button_raw(
|
||||
|
||||
if ( p_rarch->current_input
|
||||
&& p_rarch->current_input->input_state)
|
||||
return p_rarch->current_input->input_state(p_rarch->current_input_data,
|
||||
&joypad_info, p_rarch->libretro_input_binds, port, RETRO_DEVICE_MOUSE, 0, id);
|
||||
return p_rarch->current_input->input_state(
|
||||
p_rarch->current_input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
&joypad_info,
|
||||
p_rarch->libretro_input_binds,
|
||||
port,
|
||||
RETRO_DEVICE_MOUSE, 0, id);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@ -31343,6 +31524,7 @@ static void video_driver_init_input(input_driver_t *tmp)
|
||||
RARCH_ERR("[Video]: Cannot initialize input driver. Exiting ...\n");
|
||||
retroarch_fail(1, "video_driver_init_input()");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -31433,7 +31615,17 @@ static void video_driver_free_internal(void)
|
||||
if (p_rarch->current_input)
|
||||
{
|
||||
if (p_rarch->current_input->free)
|
||||
{
|
||||
p_rarch->current_input->free(p_rarch->current_input_data);
|
||||
if (p_rarch->joypad)
|
||||
p_rarch->joypad->destroy();
|
||||
#ifdef HAVE_MFI
|
||||
if (p_rarch->sec_joypad)
|
||||
p_rarch->sec_joypad->destroy();
|
||||
p_rarch->sec_joypad = NULL;
|
||||
#endif
|
||||
p_rarch->joypad = NULL;
|
||||
}
|
||||
p_rarch->current_input->keyboard_mapping_blocked = false;
|
||||
}
|
||||
p_rarch->current_input_data = NULL;
|
||||
@ -38608,6 +38800,13 @@ static enum runloop_state runloop_check_state(
|
||||
#else
|
||||
bool menu_input_active = false;
|
||||
#endif
|
||||
#ifdef HAVE_MFI
|
||||
const input_device_driver_t
|
||||
*sec_joypad = p_rarch->sec_joypad;
|
||||
#else
|
||||
const input_device_driver_t
|
||||
*sec_joypad = NULL;
|
||||
#endif
|
||||
|
||||
joypad_info.joy_idx = settings->uints.input_joypad_map[port];
|
||||
joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
|
||||
@ -38708,6 +38907,8 @@ static enum runloop_state runloop_check_state(
|
||||
{
|
||||
if (p_rarch->current_input->input_state(
|
||||
p_rarch->current_input_data,
|
||||
p_rarch->joypad,
|
||||
sec_joypad,
|
||||
&joypad_info, &binds, port,
|
||||
RETRO_DEVICE_KEYBOARD, 0, ids[i][0]))
|
||||
BIT256_SET_PTR(¤t_bits, ids[i][1]);
|
||||
|
@ -1983,6 +1983,13 @@ bool is_input_keyboard_display_on(void);
|
||||
bool input_key_pressed(const void *data,
|
||||
int key, bool keyboard_pressed);
|
||||
|
||||
const char *joypad_driver_name(unsigned i);
|
||||
void joypad_driver_reinit(void *data, const char *joypad_driver_name);
|
||||
|
||||
void input_driver_init_joypads(void);
|
||||
|
||||
void *input_driver_init_wrap(input_driver_t *input, const char *name);
|
||||
|
||||
/* creates folder and core options stub file for subsequent runs */
|
||||
bool create_folder_and_core_options(void);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user