mirror of
https://github.com/libretro/RetroArch
synced 2025-03-30 16:20:27 +00:00
Rewrite task_autodetect.c
This commit is contained in:
parent
6faabfeebf
commit
103042de96
@ -642,7 +642,6 @@ static void handle_hotplug(android_input_data_t *android_data,
|
||||
char device_name[256];
|
||||
char device_model[256];
|
||||
char name_buf[256];
|
||||
autoconfig_params_t params;
|
||||
int vendorId = 0;
|
||||
int productId = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
@ -890,15 +889,13 @@ static void handle_hotplug(android_input_data_t *android_data,
|
||||
if (*port < 0)
|
||||
*port = android_data->pads_connected;
|
||||
|
||||
strlcpy(params.name, name_buf, sizeof(params.name));
|
||||
|
||||
params.idx = *port;
|
||||
params.vid = vendorId;
|
||||
params.pid = productId;
|
||||
params.display_name[0] = '\0';
|
||||
|
||||
strlcpy(params.driver, android_joypad.ident, sizeof(params.driver));
|
||||
input_autoconfigure_connect(¶ms);
|
||||
input_autoconfigure_connect(
|
||||
name_buf,
|
||||
NULL,
|
||||
android_joypad.ident,
|
||||
*port,
|
||||
vendorId,
|
||||
productId);
|
||||
|
||||
if (!string_is_empty(name_buf))
|
||||
{
|
||||
|
@ -207,19 +207,15 @@ static void qnx_input_autodetect_gamepad(qnx_input_t *qnx,
|
||||
|
||||
if (!string_is_empty(name_buf))
|
||||
{
|
||||
autoconfig_params_t params = {{0}};
|
||||
input_autoconfigure_connect(
|
||||
name_buf,
|
||||
NULL,
|
||||
qnx->joypad->ident,
|
||||
port,
|
||||
*controller->vid,
|
||||
*controller->pid);
|
||||
|
||||
strlcpy(params.name, name_buf, sizeof(params.name));
|
||||
|
||||
params.idx = port;
|
||||
params.vid = *controller->vid;
|
||||
params.pid = *controller->pid;
|
||||
|
||||
strlcpy(params.driver, qnx->joypad->ident, sizeof(params.driver));
|
||||
|
||||
input_autoconfigure_connect(¶ms);
|
||||
|
||||
controller->port = port;
|
||||
controller->port = port;
|
||||
qnx->port_device[port] = controller;
|
||||
qnx->pads_connected++;
|
||||
}
|
||||
|
@ -298,17 +298,14 @@ static void iohidmanager_hid_device_add_autodetect(unsigned idx,
|
||||
const char *device_name, const char *driver_name,
|
||||
uint16_t dev_vid, uint16_t dev_pid)
|
||||
{
|
||||
autoconfig_params_t params;
|
||||
|
||||
params.idx = idx;
|
||||
params.vid = dev_vid;
|
||||
params.pid = dev_pid;
|
||||
params.display_name[0] = '\0';
|
||||
|
||||
strlcpy(params.name, device_name, sizeof(params.name));
|
||||
strlcpy(params.driver, driver_name, sizeof(params.driver));
|
||||
|
||||
input_autoconfigure_connect(¶ms);
|
||||
input_autoconfigure_connect(
|
||||
device_name,
|
||||
NULL,
|
||||
driver_name,
|
||||
idx,
|
||||
dev_vid,
|
||||
dev_pid
|
||||
);
|
||||
|
||||
RARCH_LOG("Port %d: %s.\n", idx, device_name);
|
||||
}
|
||||
|
@ -141,17 +141,14 @@ static void libusb_hid_device_add_autodetect(unsigned idx,
|
||||
const char *device_name, const char *driver_name,
|
||||
uint16_t dev_vid, uint16_t dev_pid)
|
||||
{
|
||||
autoconfig_params_t params;
|
||||
|
||||
params.idx = idx;
|
||||
params.vid = dev_vid;
|
||||
params.pid = dev_pid;
|
||||
params.display_name[0] = '\0';
|
||||
|
||||
strlcpy(params.name, device_name, sizeof(params.name));
|
||||
strlcpy(params.driver, driver_name, sizeof(params.driver));
|
||||
|
||||
input_autoconfigure_connect(¶ms);
|
||||
input_autoconfigure_connect(
|
||||
device_name,
|
||||
NULL,
|
||||
driver_name,
|
||||
idx,
|
||||
dev_vid,
|
||||
dev_pid
|
||||
);
|
||||
}
|
||||
|
||||
static void libusb_get_description(struct libusb_device *device,
|
||||
|
@ -140,21 +140,13 @@ static void wiiusb_hid_device_add_autodetect(unsigned idx,
|
||||
const char *device_name, const char *driver_name,
|
||||
uint16_t dev_vid, uint16_t dev_pid)
|
||||
{
|
||||
autoconfig_params_t params;
|
||||
|
||||
params.idx = idx;
|
||||
params.vid = dev_vid;
|
||||
params.pid = dev_pid;
|
||||
params.display_name[0] = '\0';
|
||||
params.name[0] = '\0';
|
||||
params.driver[0] = '\0';
|
||||
|
||||
if (!string_is_empty(device_name))
|
||||
strlcpy(params.name, device_name, sizeof(params.name));
|
||||
if (!string_is_empty(driver_name))
|
||||
strlcpy(params.driver, driver_name, sizeof(params.driver));
|
||||
|
||||
input_autoconfigure_connect(¶ms);
|
||||
input_autoconfigure_connect(
|
||||
device_name,
|
||||
NULL,
|
||||
driver_name,
|
||||
idx,
|
||||
dev_vid,
|
||||
dev_pid);
|
||||
}
|
||||
|
||||
static void wiiusb_get_description(usb_device_entry *device,
|
||||
|
@ -45,18 +45,14 @@ static const char *ctr_joypad_name(unsigned pad)
|
||||
|
||||
static void ctr_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
{
|
||||
autoconfig_params_t params;
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
params.idx = autoconf_pad;
|
||||
params.vid = 0;
|
||||
params.pid = 0;
|
||||
params.display_name[0] = '\0';
|
||||
|
||||
strlcpy(params.name, ctr_joypad_name(autoconf_pad), sizeof(params.name));
|
||||
strlcpy(params.driver, ctr_joypad.ident, sizeof(params.driver));
|
||||
|
||||
input_autoconfigure_connect(¶ms);
|
||||
input_autoconfigure_connect(
|
||||
ctr_joypad_name(autoconf_pad),
|
||||
NULL,
|
||||
ctr_joypad.ident,
|
||||
autoconf_pad,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
static bool ctr_joypad_init(void *data)
|
||||
|
@ -264,23 +264,13 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
||||
if (!is_xinput_pad)
|
||||
#endif
|
||||
{
|
||||
autoconfig_params_t params;
|
||||
|
||||
strlcpy(params.name,
|
||||
input_autoconfigure_connect(
|
||||
dinput_joypad_name(g_joypad_cnt),
|
||||
sizeof(params.name));
|
||||
strlcpy(params.display_name,
|
||||
dinput_joypad_friendly_name(g_joypad_cnt),
|
||||
sizeof(params.driver));
|
||||
strlcpy(params.driver,
|
||||
dinput_joypad.ident,
|
||||
sizeof(params.driver));
|
||||
|
||||
params.idx = g_joypad_cnt;
|
||||
params.vid = dinput_joypad_vid(g_joypad_cnt);
|
||||
params.pid = dinput_joypad_pid(g_joypad_cnt);
|
||||
|
||||
input_autoconfigure_connect(¶ms);
|
||||
g_joypad_cnt,
|
||||
dinput_joypad_vid(g_joypad_cnt),
|
||||
dinput_joypad_pid(g_joypad_cnt));
|
||||
}
|
||||
|
||||
#ifdef HAVE_XINPUT
|
||||
|
@ -143,18 +143,14 @@ static void handle_hotplug(unsigned port, uint32_t ptype)
|
||||
pad_type[port] = ptype;
|
||||
|
||||
if (ptype != WPAD_EXP_NOCONTROLLER)
|
||||
{
|
||||
autoconfig_params_t params;
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
params.idx = port;
|
||||
params.vid = 0;
|
||||
params.pid = 0;
|
||||
params.display_name[0] = '\0';
|
||||
strlcpy(params.name, gx_joypad_name(port), sizeof(params.name));
|
||||
strlcpy(params.driver, gx_joypad.ident, sizeof(params.driver));
|
||||
input_autoconfigure_connect(¶ms);
|
||||
}
|
||||
input_autoconfigure_connect(
|
||||
gx_joypad_name(port),
|
||||
NULL,
|
||||
gx_joypad.ident,
|
||||
port,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
static bool gx_joypad_button(unsigned port, uint16_t key)
|
||||
|
@ -118,6 +118,14 @@ error:
|
||||
return false;
|
||||
}
|
||||
|
||||
static const char *linuxraw_joypad_name(unsigned pad)
|
||||
{
|
||||
if (pad >= MAX_USERS || string_is_empty(linuxraw_pads[pad].ident))
|
||||
return NULL;
|
||||
|
||||
return linuxraw_pads[pad].ident;
|
||||
}
|
||||
|
||||
static void handle_plugged_pad(void)
|
||||
{
|
||||
int i, rc;
|
||||
@ -136,7 +144,6 @@ static void handle_plugged_pad(void)
|
||||
for (i = 0; i < rc; i += event->len + sizeof(struct inotify_event))
|
||||
{
|
||||
unsigned idx;
|
||||
autoconfig_params_t params;
|
||||
|
||||
event = (struct inotify_event*)&event_buf[i];
|
||||
|
||||
@ -147,12 +154,6 @@ static void handle_plugged_pad(void)
|
||||
if (idx >= MAX_USERS)
|
||||
continue;
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
params.display_name[0] = '\0';
|
||||
params.vid = 0;
|
||||
params.pid = 0;
|
||||
params.idx = idx;
|
||||
|
||||
if (event->mask & IN_DELETE)
|
||||
{
|
||||
if (linuxraw_pads[idx].fd >= 0)
|
||||
@ -166,8 +167,13 @@ static void handle_plugged_pad(void)
|
||||
linuxraw_pads[idx].fd = -1;
|
||||
*linuxraw_pads[idx].ident = '\0';
|
||||
|
||||
|
||||
input_autoconfigure_connect(¶ms);
|
||||
input_autoconfigure_connect(
|
||||
NULL,
|
||||
NULL,
|
||||
linuxraw_joypad_name(idx),
|
||||
idx,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
}
|
||||
/* Sometimes, device will be created before access to it is established. */
|
||||
@ -182,10 +188,13 @@ static void handle_plugged_pad(void)
|
||||
if ( !string_is_empty(linuxraw_pads[idx].ident)
|
||||
&& linuxraw_joypad_init_pad(path, &linuxraw_pads[idx]))
|
||||
{
|
||||
strlcpy(params.name, linuxraw_pads[idx].ident, sizeof(params.name));
|
||||
strlcpy(params.driver, linuxraw_joypad.ident, sizeof(params.driver));
|
||||
|
||||
input_autoconfigure_connect(¶ms);
|
||||
input_autoconfigure_connect(
|
||||
linuxraw_pads[idx].ident,
|
||||
NULL,
|
||||
linuxraw_joypad.ident,
|
||||
idx,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -226,29 +235,26 @@ static bool linuxraw_joypad_init(void *data)
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
{
|
||||
char path[PATH_MAX_LENGTH];
|
||||
autoconfig_params_t params = {{0}};
|
||||
struct linuxraw_joypad *pad = (struct linuxraw_joypad*)&linuxraw_pads[i];
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
path[0] = '\0';
|
||||
|
||||
params.idx = i;
|
||||
pad->fd = -1;
|
||||
pad->ident = settings->input.device_names[i];
|
||||
|
||||
snprintf(path, sizeof(path), "/dev/input/js%u", i);
|
||||
|
||||
if (linuxraw_joypad_init_pad(path, pad))
|
||||
{
|
||||
strlcpy(params.name, pad->ident, sizeof(params.name));
|
||||
strlcpy(params.driver, "linuxraw", sizeof(params.driver));
|
||||
input_autoconfigure_connect(
|
||||
pad->ident,
|
||||
NULL,
|
||||
"linuxraw",
|
||||
i,
|
||||
0,
|
||||
0);
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
input_autoconfigure_connect(¶ms);
|
||||
if (linuxraw_joypad_init_pad(path, pad))
|
||||
linuxraw_poll_pad(pad);
|
||||
}
|
||||
else
|
||||
input_autoconfigure_connect(¶ms);
|
||||
}
|
||||
|
||||
linuxraw_inotify = inotify_init();
|
||||
@ -337,13 +343,6 @@ static bool linuxraw_joypad_query_pad(unsigned pad)
|
||||
return pad < MAX_USERS && linuxraw_pads[pad].fd >= 0;
|
||||
}
|
||||
|
||||
static const char *linuxraw_joypad_name(unsigned pad)
|
||||
{
|
||||
if (pad >= MAX_USERS || string_is_empty(linuxraw_pads[pad].ident))
|
||||
return NULL;
|
||||
|
||||
return linuxraw_pads[pad].ident;
|
||||
}
|
||||
|
||||
input_device_driver_t linuxraw_joypad = {
|
||||
linuxraw_joypad_init,
|
||||
|
@ -232,7 +232,6 @@ static void parport_free_pad(struct parport_joypad *pad)
|
||||
static bool parport_joypad_init(void *data)
|
||||
{
|
||||
unsigned i, j;
|
||||
autoconfig_params_t params;
|
||||
bool found_enabled_button = false;
|
||||
bool found_disabled_button = false;
|
||||
char buf[PARPORT_NUM_BUTTONS * 3 + 1] = {0};
|
||||
@ -253,11 +252,6 @@ static bool parport_joypad_init(void *data)
|
||||
|
||||
snprintf(path, sizeof(path), "/dev/parport%u", i);
|
||||
|
||||
params.idx = i;
|
||||
params.display_name[0] = '\0';
|
||||
params.vid = 0;
|
||||
params.pid = 0;
|
||||
|
||||
if (parport_joypad_init_pad(path, pad))
|
||||
{
|
||||
/* If a pin is low on initialization it can either mean
|
||||
@ -300,8 +294,6 @@ static bool parport_joypad_init(void *data)
|
||||
RARCH_WARN("[Joypad]: Pin(s) %son %s were low on init, assuming not connected\n", \
|
||||
buf, path);
|
||||
}
|
||||
strlcpy(params.name, "Generic Parallel Port device", sizeof(params.name));
|
||||
strlcpy(params.driver, "parport", sizeof(params.driver));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -310,7 +302,14 @@ static bool parport_joypad_init(void *data)
|
||||
}
|
||||
}
|
||||
|
||||
input_autoconfigure_connect(¶ms);
|
||||
input_autoconfigure_connect(
|
||||
"Generic Parallel Port device",
|
||||
NULL,
|
||||
"parport",
|
||||
i,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -42,18 +42,14 @@ static const char *ps3_joypad_name(unsigned pad)
|
||||
|
||||
static void ps3_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
{
|
||||
autoconfig_params_t params;
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
params.idx = autoconf_pad;
|
||||
params.display_name[0] = '\0';
|
||||
params.vid = 0;
|
||||
params.pid = 0;
|
||||
|
||||
strlcpy(params.name, ps3_joypad_name(autoconf_pad), sizeof(params.name));
|
||||
strlcpy(params.driver, ps3_joypad.ident, sizeof(params.driver));
|
||||
|
||||
input_autoconfigure_connect(¶ms);
|
||||
input_autoconfigure_connect(
|
||||
ps3_joypad_name(autoconf_pad),
|
||||
NULL,
|
||||
ps3_joypad.ident,
|
||||
autoconf_pad,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
static bool ps3_joypad_init(void *data)
|
||||
|
@ -72,18 +72,14 @@ static const char *psp_joypad_name(unsigned pad)
|
||||
|
||||
static void psp_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
{
|
||||
autoconfig_params_t params;
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
params.idx = autoconf_pad;
|
||||
params.display_name[0] = '\0';
|
||||
params.vid = 0;
|
||||
params.pid = 0;
|
||||
|
||||
strlcpy(params.name, psp_joypad_name(autoconf_pad), sizeof(params.name));
|
||||
strlcpy(params.driver, psp_joypad.ident, sizeof(params.driver));
|
||||
|
||||
input_autoconfigure_connect(¶ms);
|
||||
input_autoconfigure_connect(
|
||||
psp_joypad_name(autoconf_pad),
|
||||
NULL<
|
||||
psp_joypad.ident,
|
||||
autoconf_pad,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
static bool psp_joypad_init(void *data)
|
||||
|
@ -32,20 +32,14 @@ static bool qnx_joypad_init(void *data)
|
||||
(void)data;
|
||||
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
|
||||
{
|
||||
autoconfig_params_t params;
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
params.idx = autoconf_pad;
|
||||
params.vid = 0;
|
||||
params.pid = 0;
|
||||
params.display_name[0] = '\0';
|
||||
|
||||
strlcpy(params.name, qnx_joypad_name(autoconf_pad), sizeof(params.name));
|
||||
strlcpy(params.driver, qnx_joypad.ident, sizeof(params.driver));
|
||||
|
||||
input_autoconfigure_connect(¶ms);
|
||||
}
|
||||
input_autoconfigure_connect(
|
||||
qnx_joypad_name(autoconf_pad),
|
||||
NULL,
|
||||
qnx_joypad.ident,
|
||||
autoconf_pad,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -94,7 +94,6 @@ static int16_t sdl_pad_get_axis(sdl_joypad_t *pad, unsigned axis)
|
||||
|
||||
static void sdl_pad_connect(unsigned id)
|
||||
{
|
||||
autoconfig_params_t params;
|
||||
sdl_joypad_t *pad = (sdl_joypad_t*)&sdl_pads[id];
|
||||
bool success = false;
|
||||
int32_t product = 0;
|
||||
@ -141,15 +140,14 @@ static void sdl_pad_connect(unsigned id)
|
||||
product = guid_ptr[1];
|
||||
#endif
|
||||
#endif
|
||||
strlcpy(params.name, sdl_pad_name(id), sizeof(params.name));
|
||||
strlcpy(params.driver, sdl_joypad.ident, sizeof(params.driver));
|
||||
|
||||
params.idx = id;
|
||||
params.vid = vendor;
|
||||
params.pid = product;
|
||||
params.display_name[0] = '\0';
|
||||
|
||||
input_autoconfigure_connect(¶ms);
|
||||
input_autoconfigure_connect(
|
||||
sdl_pad_name(id),
|
||||
NULL,
|
||||
sdl_joypad.ident,
|
||||
id,
|
||||
vendor,
|
||||
product);
|
||||
|
||||
RARCH_LOG("[SDL]: Device #%u (%04x:%04x) connected: %s.\n", id, vendor,
|
||||
product, sdl_pad_name(id));
|
||||
|
@ -202,7 +202,6 @@ static int udev_add_pad(struct udev_device *dev, unsigned p, int fd, const char
|
||||
{
|
||||
int i;
|
||||
struct stat st;
|
||||
autoconfig_params_t params;
|
||||
int ret = 0;
|
||||
const char *buf = NULL;
|
||||
unsigned buttons = 0;
|
||||
@ -281,16 +280,13 @@ static int udev_add_pad(struct udev_device *dev, unsigned p, int fd, const char
|
||||
|
||||
if (!string_is_empty(pad->ident))
|
||||
{
|
||||
strlcpy(params.name, pad->ident, sizeof(params.name));
|
||||
|
||||
params.display_name[0] = '\0';
|
||||
params.idx = p;
|
||||
params.vid = pad->vid;
|
||||
params.pid = pad->pid;
|
||||
|
||||
strlcpy(params.driver, udev_joypad.ident,
|
||||
sizeof(params.driver));
|
||||
input_autoconfigure_connect(¶ms);
|
||||
input_autoconfigure_connect(
|
||||
pad->ident,
|
||||
NULL,
|
||||
udev_joypad.ident,
|
||||
p,
|
||||
pad->vid,
|
||||
pad->pid);
|
||||
|
||||
ret = 1;
|
||||
}
|
||||
|
@ -47,18 +47,14 @@ static const char *wiiu_joypad_name(unsigned pad)
|
||||
|
||||
static void wiiu_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
{
|
||||
autoconfig_params_t params;
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
params.idx = autoconf_pad;
|
||||
params.display_name[0] = '\0';
|
||||
params.vid = 0;
|
||||
params.pid = 0;
|
||||
|
||||
strlcpy(params.name, wiiu_joypad_name(autoconf_pad), sizeof(params.name));
|
||||
strlcpy(params.driver, wiiu_joypad.ident, sizeof(params.driver));
|
||||
|
||||
input_autoconfigure_connect(¶ms);
|
||||
input_autoconfigure_connect(
|
||||
wiiu_joypad_name(autoconf_pad),
|
||||
NULL,
|
||||
wiiu_joypad.ident,
|
||||
autoconf_pad,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
static bool wiiu_joypad_button(unsigned port_num, uint16_t key)
|
||||
|
@ -44,18 +44,13 @@ static const char *xdk_joypad_name(unsigned pad)
|
||||
|
||||
static void xdk_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
{
|
||||
autoconfig_params_t params;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
params.idx = autoconf_pad;
|
||||
params.vid = 0;
|
||||
params.pid = 0;
|
||||
params.display_name[0] = '\0';
|
||||
|
||||
strlcpy(params.name, xdk_joypad_name(autoconf_pad), sizeof(params.name));
|
||||
strlcpy(params.driver, xdk_joypad.ident, sizeof(params.driver));
|
||||
input_autoconfigure_connect(¶ms);
|
||||
input_autoconfigure_connect(
|
||||
xdk_joypad_name(autoconf_pad),
|
||||
NULL,
|
||||
xdk_joypad.ident,
|
||||
autoconf_pad,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
|
||||
static bool xdk_joypad_init(void *data)
|
||||
|
@ -267,19 +267,13 @@ static bool xinput_joypad_init(void *data)
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
|
||||
{
|
||||
if (pad_index_to_xuser_index(autoconf_pad) > -1)
|
||||
{
|
||||
autoconfig_params_t params;
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
params.idx = autoconf_pad;
|
||||
params.display_name[0] = '\0';
|
||||
params.vid = 0;
|
||||
params.pid = 0;
|
||||
|
||||
strlcpy(params.name, xinput_joypad_name(autoconf_pad), sizeof(params.name));
|
||||
strlcpy(params.driver, xinput_joypad.ident, sizeof(params.driver));
|
||||
input_autoconfigure_connect(¶ms);
|
||||
}
|
||||
input_autoconfigure_connect(
|
||||
xinput_joypad_name(autoconf_pad),
|
||||
NULL,
|
||||
xinput_joypad.ident,
|
||||
autoconf_pad,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -38,6 +38,16 @@ typedef struct autoconfig_disconnect
|
||||
char msg[255];
|
||||
} autoconfig_disconnect_t;
|
||||
|
||||
typedef struct autoconfig_params
|
||||
{
|
||||
char name[255];
|
||||
char driver[255];
|
||||
char display_name[255];
|
||||
unsigned idx;
|
||||
int32_t vid;
|
||||
int32_t pid;
|
||||
} autoconfig_params_t;
|
||||
|
||||
/* Adds an index for devices with the same name,
|
||||
* so they can be identified in the GUI. */
|
||||
static void input_autoconfigure_joypad_reindex_devices(void)
|
||||
@ -373,7 +383,13 @@ error:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool input_autoconfigure_connect(autoconfig_params_t *params)
|
||||
bool input_autoconfigure_connect(
|
||||
const char *name,
|
||||
const char *display_name,
|
||||
const char *driver,
|
||||
unsigned idx,
|
||||
unsigned vid,
|
||||
unsigned pid)
|
||||
{
|
||||
unsigned i;
|
||||
retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task));
|
||||
@ -383,20 +399,28 @@ bool input_autoconfigure_connect(autoconfig_params_t *params)
|
||||
if (!task || !state || !settings->input.autodetect_enable)
|
||||
goto error;
|
||||
|
||||
strlcpy(state->name, params->name, sizeof(state->name));
|
||||
if (!string_is_empty(display_name))
|
||||
strlcpy(state->display_name, display_name,
|
||||
sizeof(state->display_name));
|
||||
|
||||
if (!string_is_empty(name))
|
||||
strlcpy(state->name, name, sizeof(state->name));
|
||||
|
||||
if (!string_is_empty(driver))
|
||||
strlcpy(state->driver, driver, sizeof(state->driver));
|
||||
|
||||
state->idx = idx;
|
||||
state->vid = vid;
|
||||
state->pid = pid;
|
||||
|
||||
for (i = 0; i < RARCH_BIND_LIST_END; i++)
|
||||
{
|
||||
settings->input.autoconf_binds[params->idx][i].joykey = NO_BTN;
|
||||
settings->input.autoconf_binds[params->idx][i].joyaxis = AXIS_NONE;
|
||||
settings->input.autoconf_binds[params->idx][i].joykey_label[0] = '\0';
|
||||
settings->input.autoconf_binds[params->idx][i].joyaxis_label[0] = '\0';
|
||||
settings->input.autoconf_binds[state->idx][i].joykey = NO_BTN;
|
||||
settings->input.autoconf_binds[state->idx][i].joyaxis = AXIS_NONE;
|
||||
settings->input.autoconf_binds[state->idx][i].joykey_label[0] = '\0';
|
||||
settings->input.autoconf_binds[state->idx][i].joyaxis_label[0] = '\0';
|
||||
}
|
||||
settings->input.autoconfigured[params->idx] = false;
|
||||
|
||||
state->idx = params->idx;
|
||||
state->vid = params->vid;
|
||||
state->pid = params->pid;
|
||||
settings->input.autoconfigured[state->idx] = false;
|
||||
|
||||
task->state = state;
|
||||
task->handler = input_autoconfigure_connect_handler;
|
||||
|
@ -82,16 +82,6 @@ typedef struct nbio_handle
|
||||
char path[4096];
|
||||
} nbio_handle_t;
|
||||
|
||||
typedef struct autoconfig_params
|
||||
{
|
||||
char name[255];
|
||||
char driver[255];
|
||||
char display_name[255];
|
||||
unsigned idx;
|
||||
int32_t vid;
|
||||
int32_t pid;
|
||||
} autoconfig_params_t;
|
||||
|
||||
#ifdef HAVE_NETWORKING
|
||||
typedef struct
|
||||
{
|
||||
@ -171,7 +161,13 @@ void *savefile_ptr_get(void);
|
||||
|
||||
void path_init_savefile_new(void);
|
||||
|
||||
bool input_autoconfigure_connect(autoconfig_params_t *params);
|
||||
bool input_autoconfigure_connect(
|
||||
const char *name,
|
||||
const char *display_name,
|
||||
const char *driver,
|
||||
unsigned idx,
|
||||
unsigned vid,
|
||||
unsigned pid);
|
||||
|
||||
bool input_autoconfigure_disconnect(unsigned i, const char *ident);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user