mirror of
https://github.com/libretro/RetroArch
synced 2025-01-17 01:16:25 +00:00
Simplify input_autodetect
This commit is contained in:
parent
be01cae72c
commit
226c6ff41a
@ -442,6 +442,7 @@ static void handle_hotplug(android_input_t *android,
|
||||
char device_name[256], name_buf[256];
|
||||
name_buf[0] = device_name[0] = 0;
|
||||
int vendorId = 0, productId = 0;
|
||||
autoconfig_params_t params = {{0}};
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!settings->input.autodetect_enable)
|
||||
@ -600,10 +601,13 @@ static void handle_hotplug(android_input_t *android,
|
||||
strlcpy(settings->input.device_names[*port],
|
||||
name_buf, sizeof(settings->input.device_names[*port]));
|
||||
|
||||
input_config_autoconfigure_joypad(*port, name_buf,
|
||||
vendorId, productId,
|
||||
android_joypad.ident);
|
||||
RARCH_LOG("Port %d: %s.\n", *port, name_buf);
|
||||
params.idx = *port;
|
||||
strlcpy(params.name, name_buf, sizeof(params.name));
|
||||
params.vid = vendorId;
|
||||
params.pid = productId;
|
||||
strlcpy(params.driver, android_joypad.ident, sizeof(params.driver));
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
*port = android->pads_connected;
|
||||
|
@ -865,13 +865,17 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
||||
if (!is_xinput_pad)
|
||||
#endif
|
||||
{
|
||||
autoconfig_params_t params = {{0}};
|
||||
|
||||
strlcpy(settings->input.device_names[g_joypad_cnt],
|
||||
dinput_joypad_name(g_joypad_cnt),
|
||||
sizeof(settings->input.device_names[g_joypad_cnt]));
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
input_config_autoconfigure_joypad(g_joypad_cnt,
|
||||
dinput_joypad_name(g_joypad_cnt), 0, 0,
|
||||
dinput_joypad.ident);
|
||||
params.idx = g_joypad_cnt;
|
||||
strlcpy(params.name, dinput_joypad_name(g_joypad_cnt), sizeof(params.name));
|
||||
strlcpy(params.driver, dinput_joypad.ident, sizeof(params.driver));
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
enum_iteration_done:
|
||||
|
@ -307,12 +307,17 @@ static void qnx_input_autodetect_gamepad(void *data,
|
||||
|
||||
if (name_buf[0] != '\0')
|
||||
{
|
||||
autoconfig_params_t params = {{0}};
|
||||
|
||||
strlcpy(settings->input.device_names[port],
|
||||
name_buf, sizeof(settings->input.device_names[port]));
|
||||
|
||||
input_config_autoconfigure_joypad(port, name_buf,
|
||||
controller->vid, controller->vid,
|
||||
qnx->joypad);
|
||||
params.idx = port;
|
||||
strlcpy(params.name, name_buf, sizeof(params.name));
|
||||
params.vid = controller->vid;
|
||||
params.pid = controller->pid;
|
||||
strlcpy(params.driver, qnx->joypad, sizeof(params.driver));
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
|
||||
controller->port = port;
|
||||
qnx->port_device[port] = controller;
|
||||
|
@ -26,16 +26,19 @@ static bool android_joypad_init(void)
|
||||
{
|
||||
unsigned autoconf_pad;
|
||||
settings_t *settings = config_get_ptr();
|
||||
autoconfig_params_t params = {{0}};
|
||||
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
|
||||
{
|
||||
strlcpy(settings->input.device_names[autoconf_pad],
|
||||
android_joypad_name(autoconf_pad),
|
||||
sizeof(settings->input.device_names[autoconf_pad]));
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
input_config_autoconfigure_joypad(autoconf_pad,
|
||||
android_joypad_name(autoconf_pad), 0, 0,
|
||||
android_joypad.ident);
|
||||
params.idx = autoconf_pad;
|
||||
strlcpy(params.name, android_joypad_name(autoconf_pad), sizeof(params.name));
|
||||
strlcpy(params.driver, android_joypad.ident, sizeof(params.driver));
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
engine_handle_dpad = engine_handle_dpad_default;
|
||||
|
@ -160,6 +160,7 @@ static void add_device(void* context, IOReturn result,
|
||||
char device_name[PATH_MAX_LENGTH];
|
||||
CFStringRef device_name_ref;
|
||||
CFNumberRef vendorID, productID;
|
||||
autoconfig_params_t params = {{0}};
|
||||
settings_t *settings = config_get_ptr();
|
||||
struct pad_connection* connection = (struct pad_connection*)
|
||||
calloc(1, sizeof(*connection));
|
||||
@ -203,8 +204,13 @@ static void add_device(void* context, IOReturn result,
|
||||
strlcpy(settings->input.device_names[connection->slot],
|
||||
device_name, sizeof(settings->input.device_names));
|
||||
|
||||
input_config_autoconfigure_joypad(connection->slot,
|
||||
device_name, connection->v_id, connection->p_id, apple_hid_joypad.ident);
|
||||
params.idx = connection->slot;
|
||||
strlcpy(params.name, device_name, sizeof(params.name));
|
||||
params.vid = connection->v_id;
|
||||
params.pid = connection->p_id;
|
||||
strlcpy(params.driver, apple_hid_joypad.ident, sizeof(params.driver));
|
||||
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
RARCH_LOG("Port %d: %s.\n", connection->slot, device_name);
|
||||
}
|
||||
|
||||
|
@ -196,6 +196,7 @@ static const char *gx_joypad_name_static(unsigned pad)
|
||||
|
||||
static void handle_hotplug(unsigned port, uint32_t ptype)
|
||||
{
|
||||
autoconfig_params_t params = {{0}};
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
pad_type[port] = ptype;
|
||||
@ -206,16 +207,18 @@ static void handle_hotplug(unsigned port, uint32_t ptype)
|
||||
strlcpy(settings->input.device_names[port],
|
||||
gx_joypad_name(port),
|
||||
sizeof(settings->input.device_names[port]));
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
input_config_autoconfigure_joypad(port,
|
||||
gx_joypad_name(port),
|
||||
0, 0,
|
||||
gx_joypad.ident);
|
||||
params.idx = port;
|
||||
strlcpy(params.name, gx_joypad_name(port), sizeof(params.name));
|
||||
strlcpy(params.driver, gx_joypad.ident, sizeof(params.driver));
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
static bool gx_joypad_init(void)
|
||||
{
|
||||
int autoconf_pad;
|
||||
autoconfig_params_t params = {{0}};
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
SYS_SetResetCallback(reset_cb);
|
||||
@ -241,11 +244,12 @@ static bool gx_joypad_init(void)
|
||||
strlcpy(settings->input.device_names[autoconf_pad],
|
||||
gx_joypad_name_static(autoconf_pad),
|
||||
sizeof(settings->input.device_names[autoconf_pad]));
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
input_config_autoconfigure_joypad(autoconf_pad,
|
||||
gx_joypad_name_static(autoconf_pad),
|
||||
0, 0,
|
||||
gx_joypad.ident);
|
||||
params.idx = autoconf_pad;
|
||||
strlcpy(params.name, gx_joypad_name_static(autoconf_pad), sizeof(params.name));
|
||||
strlcpy(params.driver, gx_joypad.ident, sizeof(params.driver));
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -137,6 +137,7 @@ static void handle_plugged_pad(void)
|
||||
for (i = 0; i < rc; i += event->len + sizeof(struct inotify_event))
|
||||
{
|
||||
unsigned idx;
|
||||
autoconfig_params_t params = {{0}};
|
||||
|
||||
event = (struct inotify_event*)&event_buf[i];
|
||||
|
||||
@ -151,6 +152,7 @@ static void handle_plugged_pad(void)
|
||||
{
|
||||
if (linuxraw_pads[idx].fd >= 0)
|
||||
{
|
||||
|
||||
#ifndef IS_JOYCONFIG
|
||||
if (g_hotplug)
|
||||
{
|
||||
@ -168,7 +170,8 @@ static void handle_plugged_pad(void)
|
||||
*linuxraw_pads[idx].ident = '\0';
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
input_config_autoconfigure_joypad(idx, NULL, 0, 0, NULL);
|
||||
params.idx = idx;
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
}
|
||||
/* Sometimes, device will be created before acess to it is established. */
|
||||
@ -181,8 +184,13 @@ static void handle_plugged_pad(void)
|
||||
ret = linuxraw_joypad_init_pad(path, &linuxraw_pads[idx]);
|
||||
|
||||
if (*linuxraw_pads[idx].ident && ret)
|
||||
{
|
||||
params.idx = idx;
|
||||
strlcpy(params.name, linuxraw_pads[idx].ident, sizeof(params.name));
|
||||
strlcpy(params.driver, linuxraw_joypad.ident, sizeof(params.driver));
|
||||
/* TODO - implement VID/PID? */
|
||||
input_config_autoconfigure_joypad(idx, linuxraw_pads[idx].ident, 0, 0, "linuxraw");
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -227,24 +235,30 @@ static bool linuxraw_joypad_init(void)
|
||||
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];
|
||||
|
||||
if (!pad)
|
||||
continue;
|
||||
|
||||
params.idx = i;
|
||||
|
||||
pad->fd = -1;
|
||||
pad->ident = settings->input.device_names[i];
|
||||
|
||||
snprintf(path, sizeof(path), "/dev/input/js%u", i);
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
if (linuxraw_joypad_init_pad(path, pad))
|
||||
{
|
||||
input_config_autoconfigure_joypad(i, pad->ident, 0, 0, "linuxraw");
|
||||
strlcpy(params.name, pad->ident, sizeof(params.name));
|
||||
strlcpy(params.driver, "linuxraw", sizeof(params.driver));
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
poll_pad(pad);
|
||||
}
|
||||
else
|
||||
input_config_autoconfigure_joypad(i, NULL, 0, 0, NULL);
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
g_notify = inotify_init();
|
||||
|
@ -232,6 +232,7 @@ static bool parport_joypad_init(void)
|
||||
char buf[PARPORT_NUM_BUTTONS * 3 + 1];
|
||||
char pin[3 + 1];
|
||||
settings_t *settings = config_get_ptr();
|
||||
autoconfig_params_t params = {{0}};
|
||||
|
||||
memset(buf, 0, PARPORT_NUM_BUTTONS * 3 + 1);
|
||||
|
||||
@ -245,6 +246,8 @@ static bool parport_joypad_init(void)
|
||||
|
||||
snprintf(path, sizeof(path), "/dev/parport%u", i);
|
||||
|
||||
params.idx = i;
|
||||
|
||||
if (parport_joypad_init_pad(path, pad))
|
||||
{
|
||||
/* If a pin is low on initialization it can either mean
|
||||
@ -285,20 +288,19 @@ static bool parport_joypad_init(void)
|
||||
}
|
||||
}
|
||||
RARCH_WARN("[Joypad]: Pin(s) %son %s were low on init, assuming not connected\n", \
|
||||
buf, path);
|
||||
buf, path);
|
||||
}
|
||||
input_config_autoconfigure_joypad(i, "Generic Parallel Port device", 0, 0, "parport");
|
||||
strlcpy(params.name, "Generic Parallel Port device", sizeof(params.name));
|
||||
strlcpy(params.driver, "parport", sizeof(params.driver));
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_WARN("[Joypad]: All pins low on %s, assuming nothing connected\n", path);
|
||||
destroy_pad(pad);
|
||||
input_config_autoconfigure_joypad(i, NULL, 0, 0, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
input_config_autoconfigure_joypad(i, NULL, 0, 0, NULL);
|
||||
}
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -47,14 +47,16 @@ static bool ps3_joypad_init(void)
|
||||
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
|
||||
{
|
||||
autoconfig_params_t params = {{0}};
|
||||
strlcpy(settings->input.device_names[autoconf_pad],
|
||||
"SixAxis Controller",
|
||||
sizeof(settings->input.device_names[autoconf_pad]));
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
input_config_autoconfigure_joypad(autoconf_pad,
|
||||
ps3_joypad_name(autoconf_pad),
|
||||
0, 0,
|
||||
ps3_joypad.ident);
|
||||
params.idx = autoconf_pad;
|
||||
strlcpy(params.name, ps3_joypad_name(autoconf_pad), sizeof(params.name));
|
||||
strlcpy(params.driver, ps3_joypad.ident, sizeof(params.driver));
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -31,14 +31,17 @@ static bool psp_joypad_init(void)
|
||||
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_PADS; autoconf_pad++)
|
||||
{
|
||||
autoconfig_params_t params = {{0}};
|
||||
|
||||
strlcpy(settings->input.device_names[autoconf_pad],
|
||||
psp_joypad_name(autoconf_pad),
|
||||
sizeof(settings->input.device_names[autoconf_pad]));
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
input_config_autoconfigure_joypad(autoconf_pad,
|
||||
psp_joypad_name(autoconf_pad),
|
||||
0, 0,
|
||||
psp_joypad.ident);
|
||||
params.idx = autoconf_pad;
|
||||
strlcpy(params.name, psp_joypad_name(autoconf_pad), sizeof(params.name));
|
||||
strlcpy(params.driver, psp_joypad.ident, sizeof(params.driver));
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -30,13 +30,16 @@ static bool qnx_joypad_init(void)
|
||||
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
|
||||
{
|
||||
autoconfig_params_t params = {{0}};
|
||||
|
||||
strlcpy(settings->input.device_names[autoconf_pad], "None",
|
||||
sizeof(settings->input.device_names[autoconf_pad]));
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
input_config_autoconfigure_joypad(autoconf_pad,
|
||||
qnx_joypad_name(autoconf_pad),
|
||||
0, 0,
|
||||
qnx_joypad.ident);
|
||||
params.idx = autoconf_pad;
|
||||
strlcpy(params.name, qnx_joypad_name(autoconf_pad), sizeof(params.name));
|
||||
strlcpy(params.driver, qnx_joypad.ident, sizeof(params.driver));
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -93,6 +93,7 @@ static void pad_connect(unsigned id)
|
||||
int32_t product = 0;
|
||||
int32_t vendor = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
autoconfig_params_t params = {{0}};
|
||||
|
||||
#ifdef HAVE_SDL2
|
||||
SDL_JoystickGUID guid;
|
||||
@ -137,8 +138,13 @@ static void pad_connect(unsigned id)
|
||||
product = guid_ptr[1];
|
||||
#endif
|
||||
#endif
|
||||
input_config_autoconfigure_joypad(id, pad_name(id),
|
||||
vendor, product, sdl_joypad.ident);
|
||||
params.idx = id;
|
||||
strlcpy(params.name, pad_name(id), sizeof(params.name));
|
||||
params.vid = vendor;
|
||||
params.pid = product;
|
||||
strlcpy(params.driver, sdl_joypad.ident, sizeof(params.driver));
|
||||
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
|
||||
RARCH_LOG("[SDL]: Joypad #%u (%04x:%04x) connected: %s.\n", id, vendor,
|
||||
product, pad_name(id));
|
||||
|
@ -316,6 +316,7 @@ static int find_vacant_pad(void)
|
||||
static void free_pad(unsigned pad, bool hotplug)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
autoconfig_params_t params = {{0}};
|
||||
|
||||
if (udev_pads[pad].fd >= 0)
|
||||
close(udev_pads[pad].fd);
|
||||
@ -331,9 +332,10 @@ static void free_pad(unsigned pad, bool hotplug)
|
||||
/* Avoid autoconfig spam if we're reiniting driver. */
|
||||
/* TODO - implement VID/PID? */
|
||||
if (hotplug)
|
||||
input_config_autoconfigure_joypad(pad, NULL,
|
||||
0, 0,
|
||||
NULL);
|
||||
{
|
||||
params.idx = pad;
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
}
|
||||
|
||||
static bool add_pad(struct udev_device *dev, unsigned p, int fd, const char *path)
|
||||
@ -348,6 +350,7 @@ static bool add_pad(struct udev_device *dev, unsigned p, int fd, const char *pat
|
||||
unsigned long ffbit[NBITS(FF_MAX)] = {0};
|
||||
unsigned buttons = 0, axes = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
autoconfig_params_t params = {{0}};
|
||||
|
||||
if (ioctl(fd, EVIOCGNAME(sizeof(settings->input.device_names[0])), pad->ident) < 0)
|
||||
{
|
||||
@ -414,7 +417,14 @@ static bool add_pad(struct udev_device *dev, unsigned p, int fd, const char *pat
|
||||
pad->path = strdup(path);
|
||||
|
||||
if (*pad->ident)
|
||||
input_config_autoconfigure_joypad(p, pad->ident, pad->vid, pad->pid, "udev");
|
||||
{
|
||||
params.idx = p;
|
||||
strlcpy(params.name, pad->ident, sizeof(params.name));
|
||||
params.vid = pad->vid;
|
||||
params.pid = pad->pid;
|
||||
strlcpy(params.driver, udev_joypad.ident, sizeof(params.driver));
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
/* Check for rumble features. */
|
||||
if (ioctl(fd, EVIOCGBIT(EV_FF, sizeof(ffbit)), ffbit) >= 0)
|
||||
|
@ -246,15 +246,17 @@ static bool winxinput_joypad_init(void)
|
||||
{
|
||||
if (pad_index_to_xuser_index(autoconf_pad) > -1)
|
||||
{
|
||||
autoconfig_params_t params = {{0}};
|
||||
|
||||
strlcpy(settings->input.device_names[autoconf_pad],
|
||||
winxinput_joypad_name(autoconf_pad),
|
||||
sizeof(settings->input.device_names[autoconf_pad]));
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
input_config_autoconfigure_joypad(autoconf_pad,
|
||||
winxinput_joypad_name(autoconf_pad),
|
||||
0, 0,
|
||||
winxinput_joypad.ident);
|
||||
params.idx = autoconf_pad;
|
||||
strlcpy(params.name, winxinput_joypad_name(autoconf_pad), sizeof(params.name));
|
||||
strlcpy(params.driver, winxinput_joypad.ident, sizeof(params.driver));
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,15 +65,16 @@ static bool xdk_joypad_init(void)
|
||||
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
|
||||
{
|
||||
autoconfig_params_t params = {{0}};
|
||||
strlcpy(settings->input.device_names[autoconf_pad],
|
||||
"XInput Controller",
|
||||
sizeof(settings->input.device_names[autoconf_pad]));
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
input_config_autoconfigure_joypad(autoconf_pad,
|
||||
xdk_joypad_name(autoconf_pad),
|
||||
0, 0,
|
||||
xdk_joypad.ident);
|
||||
params.idx = autoconf_pad;
|
||||
strlcpy(params.name, xdk_joypad_name(autoconf_pad), sizeof(params.name));
|
||||
strlcpy(params.driver, xdk_joypad.ident, sizeof(params.driver));
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -39,8 +39,7 @@ static void input_autoconfigure_joypad_conf(config_file_t *conf,
|
||||
}
|
||||
|
||||
static bool input_try_autoconfigure_joypad_from_conf(config_file_t *conf,
|
||||
unsigned idx, const char *name, const char *drv,
|
||||
int32_t vid, int32_t pid, bool block_osd_spam)
|
||||
autoconfig_params_t *params, bool block_osd_spam)
|
||||
{
|
||||
char ident[PATH_MAX_LENGTH], ident_idx[PATH_MAX_LENGTH];
|
||||
char input_driver[PATH_MAX_LENGTH], msg[PATH_MAX_LENGTH];
|
||||
@ -59,18 +58,18 @@ static bool input_try_autoconfigure_joypad_from_conf(config_file_t *conf,
|
||||
config_get_int(conf, "input_vendor_id", &input_vid);
|
||||
config_get_int(conf, "input_product_id", &input_pid);
|
||||
|
||||
snprintf(ident_idx, sizeof(ident_idx), "%s_p%u", ident, idx);
|
||||
snprintf(ident_idx, sizeof(ident_idx), "%s_p%u", ident, params->idx);
|
||||
|
||||
#if 0
|
||||
RARCH_LOG("ident_idx: %s\n", ident_idx);
|
||||
#endif
|
||||
|
||||
cond_found_idx = !strcmp(ident_idx, name);
|
||||
cond_found_general = !strcmp(ident, name) && !strcmp(drv, input_driver);
|
||||
if ((vid != 0) && (input_vid != 0))
|
||||
cond_found_vid = (vid == input_vid);
|
||||
if ((pid != 0) && (input_pid != 0))
|
||||
cond_found_pid = (pid == input_pid);
|
||||
cond_found_idx = !strcmp(ident_idx, params->name);
|
||||
cond_found_general = !strcmp(ident, params->name) && !strcmp(params->driver, input_driver);
|
||||
if ((params->vid != 0) && (input_vid != 0))
|
||||
cond_found_vid = (params->vid == input_vid);
|
||||
if ((params->pid != 0) && (input_pid != 0))
|
||||
cond_found_pid = (params->pid == input_pid);
|
||||
|
||||
/* If Vendor ID and Product ID matches, we've found our
|
||||
* entry. */
|
||||
@ -86,11 +85,11 @@ static bool input_try_autoconfigure_joypad_from_conf(config_file_t *conf,
|
||||
return false;
|
||||
|
||||
found:
|
||||
settings->input.autoconfigured[idx] = true;
|
||||
input_autoconfigure_joypad_conf(conf, settings->input.autoconf_binds[idx]);
|
||||
settings->input.autoconfigured[params->idx] = true;
|
||||
input_autoconfigure_joypad_conf(conf, settings->input.autoconf_binds[params->idx]);
|
||||
|
||||
snprintf(msg, sizeof(msg), "Joypad port #%u (%s) configured.",
|
||||
idx, name);
|
||||
params->idx, params->name);
|
||||
|
||||
if (!block_osd_spam)
|
||||
rarch_main_msg_queue_push(msg, 0, 60, false);
|
||||
@ -99,9 +98,7 @@ found:
|
||||
return true;
|
||||
}
|
||||
|
||||
void input_config_autoconfigure_joypad(unsigned idx,
|
||||
const char *name, int32_t vid, int32_t pid,
|
||||
const char *drv)
|
||||
void input_config_autoconfigure_joypad(autoconfig_params_t *params)
|
||||
{
|
||||
size_t i;
|
||||
bool internal_only, block_osd_spam;
|
||||
@ -114,18 +111,18 @@ void input_config_autoconfigure_joypad(unsigned idx,
|
||||
/* This will be the case if input driver is reinit.
|
||||
* No reason to spam autoconfigure messages
|
||||
* every time (fine in log). */
|
||||
block_osd_spam = settings->input.autoconfigured[idx] && name;
|
||||
block_osd_spam = settings->input.autoconfigured[params->idx] && params->name;
|
||||
|
||||
for (i = 0; i < RARCH_BIND_LIST_END; i++)
|
||||
{
|
||||
settings->input.autoconf_binds[idx][i].joykey = NO_BTN;
|
||||
settings->input.autoconf_binds[idx][i].joyaxis = AXIS_NONE;
|
||||
settings->input.autoconf_binds[idx][i].joykey_label[0] = '\0';
|
||||
settings->input.autoconf_binds[idx][i].joyaxis_label[0] = '\0';
|
||||
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.autoconfigured[idx] = false;
|
||||
settings->input.autoconfigured[params->idx] = false;
|
||||
|
||||
if (!name)
|
||||
if (!params->name)
|
||||
return;
|
||||
|
||||
/* if false, load from both cfg files and internal */
|
||||
@ -138,7 +135,7 @@ void input_config_autoconfigure_joypad(unsigned idx,
|
||||
config_file_t *conf = (config_file_t*)
|
||||
config_file_new_from_string(input_builtin_autoconfs[i]);
|
||||
bool success = input_try_autoconfigure_joypad_from_conf(conf,
|
||||
idx, name, drv, vid, pid, block_osd_spam);
|
||||
params, block_osd_spam);
|
||||
|
||||
config_file_free(conf);
|
||||
if (success)
|
||||
@ -163,7 +160,7 @@ void input_config_autoconfigure_joypad(unsigned idx,
|
||||
continue;
|
||||
|
||||
success = input_try_autoconfigure_joypad_from_conf(conf,
|
||||
idx, name, drv, vid, pid, block_osd_spam);
|
||||
params, block_osd_spam);
|
||||
config_file_free(conf);
|
||||
if (success)
|
||||
break;
|
||||
|
@ -18,13 +18,21 @@
|
||||
#define _INPUT_AUTODETECT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
|
||||
typedef struct autoconfig_params
|
||||
{
|
||||
char name[PATH_MAX_LENGTH];
|
||||
char driver[PATH_MAX_LENGTH];
|
||||
unsigned idx;
|
||||
int32_t vid;
|
||||
int32_t pid;
|
||||
} autoconfig_params_t;
|
||||
|
||||
const struct retro_keybind *input_get_auto_bind(unsigned port,
|
||||
unsigned id);
|
||||
|
||||
void input_config_autoconfigure_joypad(unsigned idx,
|
||||
const char *name, int32_t vid, int32_t pid,
|
||||
const char *driver);
|
||||
void input_config_autoconfigure_joypad(autoconfig_params_t *params);
|
||||
|
||||
extern const char* const input_builtin_autoconfs[];
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <boolean.h>
|
||||
#include "../input/input_common.h"
|
||||
#include "../input/input_joypad.h"
|
||||
#include "../input/input_autodetect.h"
|
||||
#include "../general.h"
|
||||
#include "../runloop.h"
|
||||
#include <assert.h>
|
||||
@ -447,15 +448,9 @@ static void parse_input(int argc, char *argv[])
|
||||
|
||||
}
|
||||
|
||||
void input_config_autoconfigure_joypad(unsigned index,
|
||||
const char *name, int32_t vid, int32_t pid,
|
||||
const char *driver)
|
||||
void input_config_autoconfigure_joypad(autoconfig_params_t *params)
|
||||
{
|
||||
(void)index;
|
||||
(void)name;
|
||||
(void)vid;
|
||||
(void)pid;
|
||||
(void)driver;
|
||||
(void)params;
|
||||
}
|
||||
|
||||
// Need SDL_main on OSX.
|
||||
|
Loading…
Reference in New Issue
Block a user