mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 00:39:53 +00:00
Refactor input_autoconfigure_connect - don't return
value - set input device name upon failure implicitly
This commit is contained in:
parent
67c70de8f3
commit
0257e01bee
@ -1244,16 +1244,13 @@ static void handle_hotplug(android_input_t *android,
|
||||
if (*port < 0)
|
||||
*port = android->pads_connected;
|
||||
|
||||
if (!input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
name_buf,
|
||||
NULL,
|
||||
android_joypad.ident,
|
||||
*port,
|
||||
vendorId,
|
||||
productId))
|
||||
input_config_set_device_name(*port, name_buf);
|
||||
|
||||
input_config_set_device_name(*port, name_buf);
|
||||
productId);
|
||||
|
||||
android->pad_states[android->pads_connected].id = id;
|
||||
android->pad_states[android->pads_connected].port = *port;
|
||||
|
@ -549,15 +549,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)
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
device_name,
|
||||
NULL,
|
||||
driver_name,
|
||||
idx,
|
||||
dev_vid,
|
||||
dev_pid
|
||||
))
|
||||
input_config_set_device_name(idx, device_name);
|
||||
);
|
||||
|
||||
RARCH_LOG("Port %d: %s.\n", idx, device_name);
|
||||
}
|
||||
|
@ -148,15 +148,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)
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
device_name,
|
||||
NULL,
|
||||
driver_name,
|
||||
idx,
|
||||
dev_vid,
|
||||
dev_pid
|
||||
))
|
||||
input_config_set_device_name(idx, device_name);
|
||||
);
|
||||
}
|
||||
|
||||
static void libusb_get_description(struct libusb_device *device,
|
||||
|
@ -143,14 +143,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)
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
device_name,
|
||||
NULL,
|
||||
driver_name,
|
||||
idx,
|
||||
dev_vid,
|
||||
dev_pid))
|
||||
input_config_set_device_name(idx, device_name);
|
||||
dev_pid);
|
||||
}
|
||||
|
||||
static void wiiusb_get_description(usb_device_entry *device,
|
||||
|
@ -42,15 +42,14 @@ static const char *ctr_joypad_name(unsigned pad)
|
||||
|
||||
static void ctr_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
ctr_joypad_name(autoconf_pad),
|
||||
NULL,
|
||||
ctr_joypad.ident,
|
||||
autoconf_pad,
|
||||
0,
|
||||
0
|
||||
))
|
||||
input_config_set_device_name(autoconf_pad, ctr_joypad_name(autoconf_pad));
|
||||
input_autoconfigure_connect(
|
||||
ctr_joypad_name(autoconf_pad),
|
||||
NULL,
|
||||
ctr_joypad.ident,
|
||||
autoconf_pad,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
static bool ctr_joypad_init(void *data)
|
||||
|
@ -376,14 +376,13 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
||||
if (!is_xinput_pad)
|
||||
#endif
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
dinput_joypad_name(g_joypad_cnt),
|
||||
dinput_joypad_friendly_name(g_joypad_cnt),
|
||||
dinput_joypad.ident,
|
||||
g_joypad_cnt,
|
||||
dinput_joypad_vid(g_joypad_cnt),
|
||||
dinput_joypad_pid(g_joypad_cnt)))
|
||||
input_config_set_device_name(g_joypad_cnt, dinput_joypad_name(g_joypad_cnt));
|
||||
input_autoconfigure_connect(
|
||||
dinput_joypad_name(g_joypad_cnt),
|
||||
dinput_joypad_friendly_name(g_joypad_cnt),
|
||||
dinput_joypad.ident,
|
||||
g_joypad_cnt,
|
||||
dinput_joypad_vid(g_joypad_cnt),
|
||||
dinput_joypad_pid(g_joypad_cnt));
|
||||
}
|
||||
|
||||
#ifdef HAVE_XINPUT
|
||||
|
@ -151,15 +151,14 @@ static const char *dos_joypad_name(unsigned pad)
|
||||
|
||||
static void dos_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
dos_joypad_name(autoconf_pad),
|
||||
NULL,
|
||||
dos_joypad.ident,
|
||||
autoconf_pad,
|
||||
0,
|
||||
0
|
||||
))
|
||||
input_config_set_device_name(autoconf_pad, dos_joypad_name(autoconf_pad));
|
||||
);
|
||||
}
|
||||
|
||||
static bool dos_joypad_init(void *data)
|
||||
|
@ -142,17 +142,14 @@ static void handle_hotplug(unsigned port, uint32_t ptype)
|
||||
pad_type[port] = ptype;
|
||||
|
||||
if (ptype != WPAD_EXP_NOCONTROLLER)
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
gx_joypad_name(port),
|
||||
NULL,
|
||||
gx_joypad.ident,
|
||||
port,
|
||||
0,
|
||||
0
|
||||
))
|
||||
input_config_set_device_name(port, gx_joypad_name(port));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
static bool gx_joypad_button(unsigned port, uint16_t key)
|
||||
|
@ -191,14 +191,13 @@ retry:
|
||||
linuxraw_pads[idx].fd = -1;
|
||||
*linuxraw_pads[idx].ident = '\0';
|
||||
|
||||
if (!input_autoconfigure_connect(
|
||||
NULL,
|
||||
NULL,
|
||||
linuxraw_joypad_name(idx),
|
||||
idx,
|
||||
0,
|
||||
0))
|
||||
input_config_set_device_name(idx, NULL);
|
||||
input_autoconfigure_connect(
|
||||
NULL,
|
||||
NULL,
|
||||
linuxraw_joypad_name(idx),
|
||||
idx,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
}
|
||||
/* Sometimes, device will be created before
|
||||
@ -213,17 +212,13 @@ retry:
|
||||
|
||||
if ( !string_is_empty(linuxraw_pads[idx].ident)
|
||||
&& linuxraw_joypad_init_pad(path, &linuxraw_pads[idx]))
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
linuxraw_pads[idx].ident,
|
||||
NULL,
|
||||
linuxraw_joypad.ident,
|
||||
idx,
|
||||
0,
|
||||
0))
|
||||
input_config_set_device_name(idx,
|
||||
linuxraw_joypad_name(idx));
|
||||
}
|
||||
input_autoconfigure_connect(
|
||||
linuxraw_pads[idx].ident,
|
||||
NULL,
|
||||
linuxraw_joypad.ident,
|
||||
idx,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -255,14 +250,13 @@ static bool linuxraw_joypad_init(void *data)
|
||||
|
||||
snprintf(path, sizeof(path), "/dev/input/js%u", i);
|
||||
|
||||
if (!input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
pad->ident,
|
||||
NULL,
|
||||
"linuxraw",
|
||||
i,
|
||||
0,
|
||||
0))
|
||||
input_config_set_device_name(i, pad->ident);
|
||||
0);
|
||||
|
||||
if (linuxraw_joypad_init_pad(path, pad))
|
||||
linuxraw_poll_pad(pad);
|
||||
|
@ -295,9 +295,7 @@ static void apple_gamecontroller_joypad_disconnect(GCController* controller)
|
||||
|
||||
static void mfi_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
{
|
||||
if ( !input_autoconfigure_connect("mFi Controller", NULL, mfi_joypad.ident, autoconf_pad, 0, 0) ) {
|
||||
input_config_set_device(autoconf_pad, "mFi Controller");
|
||||
}
|
||||
input_autoconfigure_connect("mFi Controller", NULL, mfi_joypad.ident, autoconf_pad, 0, 0);
|
||||
}
|
||||
|
||||
bool apple_gamecontroller_joypad_init(void *data)
|
||||
|
@ -305,15 +305,14 @@ static bool parport_joypad_init(void *data)
|
||||
}
|
||||
}
|
||||
|
||||
if (!input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
"Generic Parallel Port device",
|
||||
NULL,
|
||||
"parport",
|
||||
i,
|
||||
0,
|
||||
0
|
||||
))
|
||||
input_config_set_device_name(i, "Generic Parallel Port device");
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -66,14 +66,12 @@ static bool ps2_joypad_init(void *data)
|
||||
|
||||
for (port = 0; port < PS2_MAX_PADS; port++)
|
||||
{
|
||||
bool auto_configure = input_autoconfigure_connect( ps2_joypad_name(port),
|
||||
NULL,
|
||||
ps2_joypad.ident,
|
||||
port,
|
||||
0,
|
||||
0);
|
||||
if (!auto_configure)
|
||||
input_config_set_device_name(port, ps2_joypad_name(port));
|
||||
input_autoconfigure_connect( ps2_joypad_name(port),
|
||||
NULL,
|
||||
ps2_joypad.ident,
|
||||
port,
|
||||
0,
|
||||
0);
|
||||
|
||||
/* Port 0 -> Connector 1, Port 1 -> Connector 2 */
|
||||
if((ret = padPortOpen(port, PS2_PAD_SLOT, padBuf[port])) == 0)
|
||||
|
@ -40,15 +40,14 @@ static const char *ps3_joypad_name(unsigned pad)
|
||||
|
||||
static void ps3_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
ps3_joypad_name(autoconf_pad),
|
||||
NULL,
|
||||
ps3_joypad.ident,
|
||||
autoconf_pad,
|
||||
0,
|
||||
0
|
||||
))
|
||||
input_config_set_device_name(autoconf_pad, ps3_joypad_name(autoconf_pad));
|
||||
input_autoconfigure_connect(
|
||||
ps3_joypad_name(autoconf_pad),
|
||||
NULL,
|
||||
ps3_joypad.ident,
|
||||
autoconf_pad,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
static bool ps3_joypad_init(void *data)
|
||||
|
@ -112,15 +112,13 @@ static bool ps4_joypad_init(void *data)
|
||||
ds_joypad_states[num_players].userId = userId;
|
||||
RARCH_LOG("NEW PAD: num_players %x \n", num_players);
|
||||
|
||||
bool auto_configure = input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
ps4_joypad_name(num_players),
|
||||
NULL,
|
||||
ps4_joypad.ident,
|
||||
num_players,
|
||||
0,
|
||||
0);
|
||||
if (!auto_configure)
|
||||
input_config_set_device_name(num_players, ps4_joypad_name(num_players));
|
||||
num_players++;
|
||||
}
|
||||
}
|
||||
|
@ -101,17 +101,14 @@ static bool psp_joypad_init(void *data)
|
||||
#endif
|
||||
|
||||
for (i = 0; i < players_count; i++)
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
psp_joypad_name(i),
|
||||
NULL,
|
||||
psp_joypad.ident,
|
||||
i,
|
||||
0,
|
||||
0
|
||||
))
|
||||
input_config_set_device_name(i, psp_joypad_name(i));
|
||||
}
|
||||
input_autoconfigure_connect(
|
||||
psp_joypad_name(i),
|
||||
NULL,
|
||||
psp_joypad.ident,
|
||||
i,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -211,17 +208,14 @@ static void psp_joypad_poll(void)
|
||||
|
||||
if (old_ctrl_info.port[player + 1] == SCE_CTRL_TYPE_UNPAIRED &&
|
||||
curr_ctrl_info.port[player + 1] != SCE_CTRL_TYPE_UNPAIRED)
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
psp_joypad_name(player),
|
||||
NULL,
|
||||
psp_joypad.ident,
|
||||
player,
|
||||
0,
|
||||
0
|
||||
))
|
||||
input_config_set_device_name(player, psp_joypad_name(player));
|
||||
}
|
||||
input_autoconfigure_connect(
|
||||
psp_joypad_name(player),
|
||||
NULL,
|
||||
psp_joypad.ident,
|
||||
player,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
memcpy(&old_ctrl_info, &curr_ctrl_info, sizeof(SceCtrlPortInfo));
|
||||
}
|
||||
|
@ -30,17 +30,14 @@ static bool qnx_joypad_init(void *data)
|
||||
(void)data;
|
||||
|
||||
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
qnx_joypad_name(autoconf_pad),
|
||||
NULL,
|
||||
qnx_joypad.ident,
|
||||
autoconf_pad,
|
||||
0,
|
||||
0
|
||||
))
|
||||
input_config_set_device_name(autoconf_pad, qnx_joypad_name(autoconf_pad));
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -48,22 +48,16 @@ static EM_BOOL rwebpad_gamepad_cb(int event_type,
|
||||
}
|
||||
|
||||
if (event_type == EMSCRIPTEN_EVENT_GAMEPADCONNECTED)
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
gamepad_event->id, /* name */
|
||||
NULL, /* display name */
|
||||
rwebpad_joypad.ident, /* driver */
|
||||
gamepad_event->index, /* idx */
|
||||
vid, /* vid */
|
||||
pid)) /* pid */
|
||||
input_config_set_device_name(gamepad_event->index,
|
||||
gamepad_event->id);
|
||||
}
|
||||
pid); /* pid */
|
||||
else if (event_type == EMSCRIPTEN_EVENT_GAMEPADDISCONNECTED)
|
||||
{
|
||||
input_autoconfigure_disconnect(gamepad_event->index,
|
||||
rwebpad_joypad.ident);
|
||||
}
|
||||
|
||||
return EM_TRUE;
|
||||
}
|
||||
|
@ -145,14 +145,13 @@ static void sdl_pad_connect(unsigned id)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (!input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
sdl_joypad_name(id),
|
||||
NULL,
|
||||
sdl_joypad.ident,
|
||||
id,
|
||||
vendor,
|
||||
product))
|
||||
input_config_set_device_name(id, sdl_joypad_name(id));
|
||||
product);
|
||||
|
||||
RARCH_LOG("[SDL]: Device #%u (%04x:%04x) connected: %s.\n", id, vendor,
|
||||
product, sdl_joypad_name(id));
|
||||
|
@ -49,15 +49,13 @@ static const char *switch_joypad_name(unsigned pad)
|
||||
|
||||
static void switch_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
switch_joypad_name(autoconf_pad), /* name */
|
||||
NULL, /* display name */
|
||||
switch_joypad.ident, /* driver */
|
||||
autoconf_pad, /* idx */
|
||||
0, /* vid */
|
||||
0)) /* pid */
|
||||
input_config_set_device_name(autoconf_pad,
|
||||
switch_joypad_name(autoconf_pad));
|
||||
0); /* pid */
|
||||
}
|
||||
|
||||
static bool switch_joypad_init(void *data)
|
||||
|
@ -239,14 +239,13 @@ static int udev_add_pad(struct udev_device *dev, unsigned p, int fd, const char
|
||||
|
||||
if (!string_is_empty(pad->ident))
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
pad->ident,
|
||||
NULL,
|
||||
udev_joypad.ident,
|
||||
p,
|
||||
pad->vid,
|
||||
pad->pid))
|
||||
input_config_set_device_name(p, pad->ident);
|
||||
pad->pid);
|
||||
|
||||
ret = 1;
|
||||
}
|
||||
|
@ -46,14 +46,13 @@ static const char *xdk_joypad_name(unsigned pad)
|
||||
|
||||
static void xdk_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
{
|
||||
if (!input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
xdk_joypad_name(autoconf_pad),
|
||||
NULL,
|
||||
xdk_joypad.ident,
|
||||
autoconf_pad,
|
||||
0,
|
||||
0))
|
||||
input_config_set_device_name(autoconf_pad, xdk_joypad_name(autoconf_pad));
|
||||
0);
|
||||
}
|
||||
|
||||
static bool xdk_joypad_init(void *data)
|
||||
|
@ -342,14 +342,13 @@ static bool xinput_joypad_init(void *data)
|
||||
vid, pid, dinput_index, xinput_joypad_name(j), j);
|
||||
#endif
|
||||
|
||||
if (!input_autoconfigure_connect(
|
||||
input_autoconfigure_connect(
|
||||
xinput_joypad_name(j),
|
||||
NULL,
|
||||
xinput_joypad.ident,
|
||||
j,
|
||||
vid,
|
||||
pid))
|
||||
input_config_set_device_name(j, xinput_joypad_name(j));
|
||||
pid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9544,9 +9544,8 @@ void input_pad_connect(unsigned port, input_device_driver_t *driver)
|
||||
|
||||
fire_connection_listener(port, driver);
|
||||
|
||||
if (!input_autoconfigure_connect(driver->name(port), NULL, driver->ident,
|
||||
port, 0, 0))
|
||||
input_config_set_device_name(port, driver->name(port));
|
||||
input_autoconfigure_connect(driver->name(port), NULL, driver->ident,
|
||||
port, 0, 0);
|
||||
}
|
||||
|
||||
#ifdef HAVE_HID
|
||||
|
@ -971,7 +971,7 @@ unsigned input_autoconfigure_get_device_name_index(unsigned i)
|
||||
return input_device_name_index[i];
|
||||
}
|
||||
|
||||
bool input_autoconfigure_connect(
|
||||
void input_autoconfigure_connect(
|
||||
const char *name,
|
||||
const char *display_name,
|
||||
const char *driver,
|
||||
@ -987,7 +987,18 @@ bool input_autoconfigure_connect(
|
||||
bool autodetect_enable = settings ? settings->bools.input_autodetect_enable : false;
|
||||
|
||||
if (!task || !state || !autodetect_enable)
|
||||
goto error;
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
input_autoconfigure_params_free(state);
|
||||
free(state);
|
||||
}
|
||||
if (task)
|
||||
free(task);
|
||||
|
||||
input_config_set_device_name(idx, name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string_is_empty(name))
|
||||
state->name = strdup(name);
|
||||
@ -1004,7 +1015,7 @@ bool input_autoconfigure_connect(
|
||||
input_autoconfigure_override_handler(state);
|
||||
|
||||
if (!string_is_empty(state->name))
|
||||
input_config_set_device_name(state->idx, state->name);
|
||||
input_config_set_device_name(state->idx, state->name);
|
||||
input_config_set_pid(state->idx, state->pid);
|
||||
input_config_set_vid(state->idx, state->vid);
|
||||
|
||||
@ -1013,10 +1024,10 @@ bool input_autoconfigure_connect(
|
||||
input_autoconf_binds[state->idx][i].joykey = NO_BTN;
|
||||
input_autoconf_binds[state->idx][i].joyaxis = AXIS_NONE;
|
||||
if (
|
||||
!string_is_empty(input_autoconf_binds[state->idx][i].joykey_label))
|
||||
!string_is_empty(input_autoconf_binds[state->idx][i].joykey_label))
|
||||
free(input_autoconf_binds[state->idx][i].joykey_label);
|
||||
if (
|
||||
!string_is_empty(input_autoconf_binds[state->idx][i].joyaxis_label))
|
||||
!string_is_empty(input_autoconf_binds[state->idx][i].joyaxis_label))
|
||||
free(input_autoconf_binds[state->idx][i].joyaxis_label);
|
||||
input_autoconf_binds[state->idx][i].joykey_label = NULL;
|
||||
input_autoconf_binds[state->idx][i].joyaxis_label = NULL;
|
||||
@ -1028,17 +1039,4 @@ bool input_autoconfigure_connect(
|
||||
task->handler = input_autoconfigure_connect_handler;
|
||||
|
||||
task_queue_push(task);
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
if (state)
|
||||
{
|
||||
input_autoconfigure_params_free(state);
|
||||
free(state);
|
||||
}
|
||||
if (task)
|
||||
free(task);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ unsigned input_autoconfigure_get_device_name_index(unsigned i);
|
||||
|
||||
void input_autoconfigure_reset(void);
|
||||
|
||||
bool input_autoconfigure_connect(
|
||||
void input_autoconfigure_connect(
|
||||
const char *name,
|
||||
const char *display_name,
|
||||
const char *driver,
|
||||
|
Loading…
x
Reference in New Issue
Block a user