mirror of
https://github.com/libretro/RetroArch
synced 2025-03-05 19:13:45 +00:00
Pass handle to input driver to joypad driver's init function
This commit is contained in:
parent
bafda714a1
commit
660641f328
@ -438,7 +438,7 @@ static void *android_input_init(void)
|
||||
return NULL;
|
||||
|
||||
android->pads_connected = 0;
|
||||
android->joypad = input_joypad_init_driver(settings->input.joypad_driver);
|
||||
android->joypad = input_joypad_init_driver(settings->input.joypad_driver, android);
|
||||
|
||||
frontend_android_get_version_sdk(&sdk);
|
||||
|
||||
|
@ -238,7 +238,7 @@ static void *cocoa_input_init(void)
|
||||
|
||||
input_keymaps_init_keyboard_lut(rarch_key_map_apple_hid);
|
||||
|
||||
apple->joypad = input_joypad_init_driver(settings->input.joypad_driver);
|
||||
apple->joypad = input_joypad_init_driver(settings->input.joypad_driver, apple);
|
||||
|
||||
return apple;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ static void* ctr_input_initialize(void)
|
||||
if (!ctr)
|
||||
return NULL;
|
||||
|
||||
ctr->joypad = input_joypad_init_driver(settings->input.joypad_driver);
|
||||
ctr->joypad = input_joypad_init_driver(settings->input.joypad_driver, ctr);
|
||||
|
||||
return ctr;
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ static void *dinput_init(void)
|
||||
}
|
||||
|
||||
input_keymaps_init_keyboard_lut(rarch_key_map_dinput);
|
||||
di->joypad = input_joypad_init_driver(settings->input.joypad_driver);
|
||||
di->joypad = input_joypad_init_driver(settings->input.joypad_driver, di);
|
||||
|
||||
return di;
|
||||
}
|
||||
@ -576,7 +576,7 @@ bool dinput_handle_message(void *dinput, UINT message, WPARAM wParam, LPARAM lPa
|
||||
{
|
||||
if (di->joypad)
|
||||
di->joypad->destroy();
|
||||
di->joypad = input_joypad_init_driver(settings->input.joypad_driver);
|
||||
di->joypad = input_joypad_init_driver(settings->input.joypad_driver, di);
|
||||
break;
|
||||
}
|
||||
case WM_MOUSEWHEEL:
|
||||
|
@ -75,7 +75,7 @@ static void *gx_input_init(void)
|
||||
if (!gx)
|
||||
return NULL;
|
||||
|
||||
gx->joypad = input_joypad_init_driver(settings->input.joypad_driver);
|
||||
gx->joypad = input_joypad_init_driver(settings->input.joypad_driver, gx);
|
||||
|
||||
return gx;
|
||||
}
|
||||
|
@ -116,7 +116,8 @@ static void *linuxraw_input_init(void)
|
||||
|
||||
atexit(linuxraw_reset_kbmd);
|
||||
|
||||
linuxraw->joypad = input_joypad_init_driver(settings->input.joypad_driver);
|
||||
linuxraw->joypad = input_joypad_init_driver(
|
||||
settings->input.joypad_driver, linuxraw);
|
||||
input_keymaps_init_keyboard_lut(rarch_key_map_linux);
|
||||
|
||||
/* We need to disable use of stdin command interface if
|
||||
|
@ -161,7 +161,7 @@ static void* ps3_input_init(void)
|
||||
if (!ps3)
|
||||
return NULL;
|
||||
|
||||
ps3->joypad = input_joypad_init_driver(settings->input.joypad_driver);
|
||||
ps3->joypad = input_joypad_init_driver(settings->input.joypad_driver, ps3);
|
||||
|
||||
if (ps3->joypad)
|
||||
ps3->joypad->init();
|
||||
|
@ -87,7 +87,8 @@ static void* psp_input_initialize(void)
|
||||
if (!psp)
|
||||
return NULL;
|
||||
|
||||
psp->joypad = input_joypad_init_driver(settings->input.joypad_driver);
|
||||
psp->joypad = input_joypad_init_driver(
|
||||
settings->input.joypad_driver, psp);
|
||||
|
||||
return psp;
|
||||
}
|
||||
|
@ -646,7 +646,7 @@ static void *qnx_input_init(void)
|
||||
}
|
||||
|
||||
qnx->joypad = input_joypad_init_driver(
|
||||
settings->input.joypad_driver);
|
||||
settings->input.joypad_driver, qnx);
|
||||
|
||||
for (i = 0; i < MAX_PADS; ++i)
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ static void *sdl_input_init(void)
|
||||
if (!sdl)
|
||||
return NULL;
|
||||
|
||||
sdl->joypad = input_joypad_init_driver(settings->input.joypad_driver);
|
||||
sdl->joypad = input_joypad_init_driver(settings->input.joypad_driver, sdl);
|
||||
|
||||
RARCH_LOG("[SDL]: Input driver initialized.\n");
|
||||
return sdl;
|
||||
|
@ -816,7 +816,7 @@ static void *udev_input_init(void)
|
||||
if (!udev->num_devices)
|
||||
RARCH_WARN("[udev]: Couldn't open any keyboard, mouse or touchpad. Are permissions set correctly for /dev/input/event*?\n");
|
||||
|
||||
udev->joypad = input_joypad_init_driver(settings->input.joypad_driver);
|
||||
udev->joypad = input_joypad_init_driver(settings->input.joypad_driver, udev);
|
||||
input_keymaps_init_keyboard_lut(rarch_key_map_linux);
|
||||
|
||||
disable_terminal_input();
|
||||
|
@ -64,7 +64,7 @@ static void *x_input_init(void)
|
||||
x11->display = (Display*)driver->video_display;
|
||||
x11->win = (Window)driver->video_window;
|
||||
|
||||
x11->joypad = input_joypad_init_driver(settings->input.joypad_driver);
|
||||
x11->joypad = input_joypad_init_driver(settings->input.joypad_driver, x11);
|
||||
input_keymaps_init_keyboard_lut(rarch_key_map_x11);
|
||||
|
||||
return x11;
|
||||
|
@ -80,7 +80,7 @@ static void *xdk_input_init(void)
|
||||
if (!xdk)
|
||||
return NULL;
|
||||
|
||||
xdk->joypad = input_joypad_init_driver(settings->input.joypad_driver);
|
||||
xdk->joypad = input_joypad_init_driver(settings->input.joypad_driver, xdk);
|
||||
|
||||
return xdk;
|
||||
}
|
||||
|
@ -22,12 +22,14 @@ static const char *android_joypad_name(unsigned pad)
|
||||
return settings ? settings->input.device_names[pad] : NULL;
|
||||
}
|
||||
|
||||
static bool android_joypad_init(void)
|
||||
static bool android_joypad_init(void *data)
|
||||
{
|
||||
unsigned autoconf_pad;
|
||||
settings_t *settings = config_get_ptr();
|
||||
autoconfig_params_t params = {{0}};
|
||||
|
||||
(void)data;
|
||||
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
|
||||
{
|
||||
strlcpy(settings->input.device_names[autoconf_pad],
|
||||
|
@ -51,10 +51,12 @@ static void ctr_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
static bool ctr_joypad_init(void)
|
||||
static bool ctr_joypad_init(void *data)
|
||||
{
|
||||
ctr_joypad_autodetect_add(0);
|
||||
|
||||
(void)data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -240,10 +240,12 @@ enum_iteration_done:
|
||||
return DIENUM_CONTINUE;
|
||||
}
|
||||
|
||||
static bool dinput_joypad_init(void)
|
||||
static bool dinput_joypad_init(void *data)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
(void)data;
|
||||
|
||||
if (!dinput_init_context())
|
||||
return false;
|
||||
|
||||
|
@ -558,13 +558,15 @@ static void gx_joypad_poll(void)
|
||||
*lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);
|
||||
}
|
||||
|
||||
static bool gx_joypad_init(void)
|
||||
static bool gx_joypad_init(void *data)
|
||||
{
|
||||
SYS_SetResetCallback(reset_cb);
|
||||
#ifdef HW_RVL
|
||||
SYS_SetPowerCallback(power_callback);
|
||||
#endif
|
||||
|
||||
(void)data;
|
||||
|
||||
PAD_Init();
|
||||
#ifdef HW_RVL
|
||||
WPADInit();
|
||||
|
@ -21,12 +21,14 @@
|
||||
|
||||
static const hid_driver_t *generic_hid;
|
||||
|
||||
static bool hid_joypad_init(void)
|
||||
static bool hid_joypad_init(void *data)
|
||||
{
|
||||
generic_hid = input_hid_init_first();
|
||||
if (!generic_hid)
|
||||
return false;
|
||||
|
||||
(void)data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ static void linuxraw_joypad_setup_notify(void)
|
||||
inotify_add_watch(g_notify, "/dev/input", IN_DELETE | IN_CREATE | IN_ATTRIB);
|
||||
}
|
||||
|
||||
static bool linuxraw_joypad_init(void)
|
||||
static bool linuxraw_joypad_init(void *data)
|
||||
{
|
||||
unsigned i;
|
||||
settings_t *settings = config_get_ptr();
|
||||
@ -226,6 +226,8 @@ static bool linuxraw_joypad_init(void)
|
||||
if (g_epoll < 0)
|
||||
return false;
|
||||
|
||||
(void)data;
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
{
|
||||
char path[PATH_MAX_LENGTH];
|
||||
|
@ -25,8 +25,9 @@ static const char *null_joypad_name(unsigned pad)
|
||||
return "null";
|
||||
}
|
||||
|
||||
static bool null_joypad_init(void)
|
||||
static bool null_joypad_init(void *data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ static void parport_free_pad(struct parport_joypad *pad)
|
||||
pad->fd = -1;
|
||||
}
|
||||
|
||||
static bool parport_joypad_init(void)
|
||||
static bool parport_joypad_init(void *data)
|
||||
{
|
||||
unsigned i, j;
|
||||
bool found_enabled_button;
|
||||
@ -233,6 +233,8 @@ static bool parport_joypad_init(void)
|
||||
settings_t *settings = config_get_ptr();
|
||||
autoconfig_params_t params = {{0}};
|
||||
|
||||
(void)data;
|
||||
|
||||
memset(buf, 0, PARPORT_NUM_BUTTONS * 3 + 1);
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
|
@ -53,8 +53,10 @@ static void ps3_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
static bool ps3_joypad_init(void)
|
||||
static bool ps3_joypad_init(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
cellPadInit(MAX_PADS);
|
||||
|
||||
return true;
|
||||
|
@ -40,8 +40,10 @@ static void psp_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
static bool psp_joypad_init(void)
|
||||
static bool psp_joypad_init(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
psp_joypad_autodetect_add(0);
|
||||
|
||||
return true;
|
||||
|
@ -23,11 +23,13 @@ static const char *qnx_joypad_name(unsigned pad)
|
||||
return settings ? settings->input.device_names[pad] : NULL;
|
||||
}
|
||||
|
||||
static bool qnx_joypad_init(void)
|
||||
static bool qnx_joypad_init(void *data)
|
||||
{
|
||||
unsigned autoconf_pad;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
(void)data;
|
||||
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
|
||||
{
|
||||
autoconfig_params_t params = {{0}};
|
||||
|
@ -227,10 +227,12 @@ static void sdl_joypad_destroy(void)
|
||||
memset(sdl_pads, 0, sizeof(sdl_pads));
|
||||
}
|
||||
|
||||
static bool sdl_joypad_init(void)
|
||||
static bool sdl_joypad_init(void *data)
|
||||
{
|
||||
unsigned i, num_sticks;
|
||||
|
||||
(void)data;
|
||||
|
||||
if (SDL_WasInit(0) == 0)
|
||||
{
|
||||
if (SDL_Init(g_subsystem) < 0)
|
||||
|
@ -503,7 +503,7 @@ static void udev_joypad_destroy(void)
|
||||
g_udev = NULL;
|
||||
}
|
||||
|
||||
static bool udev_joypad_init(void)
|
||||
static bool udev_joypad_init(void *data)
|
||||
{
|
||||
unsigned i;
|
||||
struct udev_list_entry *devs = NULL;
|
||||
@ -511,6 +511,8 @@ static bool udev_joypad_init(void)
|
||||
struct udev_enumerate *enumerate = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
(void)data;
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
{
|
||||
udev_pads[i].fd = -1;
|
||||
|
@ -55,7 +55,7 @@ static void xdk_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
static bool xdk_joypad_init(void)
|
||||
static bool xdk_joypad_init(void *data)
|
||||
{
|
||||
#ifdef _XBOX1
|
||||
XInitDevices(0, NULL);
|
||||
@ -65,6 +65,7 @@ static bool xdk_joypad_init(void)
|
||||
xdk_joypad_autodetect_add(autoconf_pad);
|
||||
#endif
|
||||
|
||||
(void)data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -150,13 +150,15 @@ const char *xinput_joypad_name(unsigned pad)
|
||||
return XBOX_CONTROLLER_NAMES[xuser];
|
||||
}
|
||||
|
||||
static bool xinput_joypad_init(void)
|
||||
static bool xinput_joypad_init(void *data)
|
||||
{
|
||||
unsigned i, autoconf_pad;
|
||||
XINPUT_STATE dummy_state;
|
||||
const char *version = "1.4";
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
(void)data;
|
||||
|
||||
g_xinput_dll = NULL;
|
||||
|
||||
/* Find the correct path to load the DLL from.
|
||||
|
@ -152,16 +152,16 @@ const char* config_get_joypad_driver_options(void)
|
||||
*
|
||||
* Returns: joypad driver if found, otherwise NULL.
|
||||
**/
|
||||
const input_device_driver_t *input_joypad_init_driver(const char *ident)
|
||||
const input_device_driver_t *input_joypad_init_driver(const char *ident, void *data)
|
||||
{
|
||||
unsigned i;
|
||||
if (!ident || !*ident)
|
||||
return input_joypad_init_first();
|
||||
return input_joypad_init_first(data);
|
||||
|
||||
for (i = 0; joypad_drivers[i]; i++)
|
||||
{
|
||||
if (strcmp(ident, joypad_drivers[i]->ident) == 0
|
||||
&& joypad_drivers[i]->init())
|
||||
&& joypad_drivers[i]->init(data))
|
||||
{
|
||||
RARCH_LOG("Found joypad driver: \"%s\".\n",
|
||||
joypad_drivers[i]->ident);
|
||||
@ -169,7 +169,7 @@ const input_device_driver_t *input_joypad_init_driver(const char *ident)
|
||||
}
|
||||
}
|
||||
|
||||
return input_joypad_init_first();
|
||||
return input_joypad_init_first(data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -179,13 +179,13 @@ const input_device_driver_t *input_joypad_init_driver(const char *ident)
|
||||
*
|
||||
* Returns: joypad driver if found, otherwise NULL.
|
||||
**/
|
||||
const input_device_driver_t *input_joypad_init_first(void)
|
||||
const input_device_driver_t *input_joypad_init_first(void *data)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; joypad_drivers[i]; i++)
|
||||
{
|
||||
if (joypad_drivers[i]->init())
|
||||
if (joypad_drivers[i]->init(data))
|
||||
{
|
||||
RARCH_LOG("Found joypad driver: \"%s\".\n",
|
||||
joypad_drivers[i]->ident);
|
||||
|
@ -31,7 +31,7 @@ enum retro_rumble_effect;
|
||||
|
||||
struct rarch_joypad_driver
|
||||
{
|
||||
bool (*init)(void);
|
||||
bool (*init)(void *data);
|
||||
bool (*query_pad)(unsigned);
|
||||
void (*destroy)(void);
|
||||
bool (*button)(unsigned, uint16_t);
|
||||
@ -98,7 +98,7 @@ const char* config_get_joypad_driver_options(void);
|
||||
*
|
||||
* Returns: joypad driver if found, otherwise NULL.
|
||||
**/
|
||||
const input_device_driver_t *input_joypad_init_driver(const char *ident);
|
||||
const input_device_driver_t *input_joypad_init_driver(const char *ident, void *data);
|
||||
|
||||
/**
|
||||
* input_joypad_init_first:
|
||||
@ -107,7 +107,7 @@ const input_device_driver_t *input_joypad_init_driver(const char *ident);
|
||||
*
|
||||
* Returns: joypad driver if found, otherwise NULL.
|
||||
**/
|
||||
const input_device_driver_t *input_joypad_init_first(void);
|
||||
const input_device_driver_t *input_joypad_init_first(void *data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf,
|
||||
int player, int joypad)
|
||||
{
|
||||
int i, timeout_cnt;
|
||||
const input_device_driver_t *driver = input_joypad_init_driver(g_driver);
|
||||
const input_device_driver_t *driver = input_joypad_init_driver(g_driver, NULL);
|
||||
if (!driver)
|
||||
{
|
||||
fprintf(stderr, "Cannot find any valid input driver.\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user