Set device name when autoconfig connect task fails for all

other input drivers too
This commit is contained in:
twinaphex 2017-01-13 05:00:13 +01:00
parent 455c3f35c9
commit ea3dd6a95b
15 changed files with 93 additions and 66 deletions

View File

@ -888,13 +888,14 @@ static void handle_hotplug(android_input_data_t *android_data,
if (*port < 0) if (*port < 0)
*port = android_data->pads_connected; *port = android_data->pads_connected;
input_autoconfigure_connect( if (!input_autoconfigure_connect(
name_buf, name_buf,
NULL, NULL,
android_joypad.ident, android_joypad.ident,
*port, *port,
vendorId, vendorId,
productId); productId))
input_config_set_device_name(*port, name_buf);
if (!string_is_empty(name_buf)) if (!string_is_empty(name_buf))
{ {

View File

@ -23,10 +23,12 @@
#include <retro_miscellaneous.h> #include <retro_miscellaneous.h>
#include "../connect/joypad_connection.h" #include "../input_config.h"
#include "../input_defines.h" #include "../input_defines.h"
#include "../../tasks/tasks_internal.h"
#include "../input_hid_driver.h" #include "../input_hid_driver.h"
#include "../connect/joypad_connection.h"
#include "../../tasks/tasks_internal.h"
#include "../../verbosity.h" #include "../../verbosity.h"
typedef struct apple_hid typedef struct apple_hid
@ -298,14 +300,15 @@ static void iohidmanager_hid_device_add_autodetect(unsigned idx,
const char *device_name, const char *driver_name, const char *device_name, const char *driver_name,
uint16_t dev_vid, uint16_t dev_pid) uint16_t dev_vid, uint16_t dev_pid)
{ {
input_autoconfigure_connect( if (!input_autoconfigure_connect(
device_name, device_name,
NULL, NULL,
driver_name, driver_name,
idx, idx,
dev_vid, dev_vid,
dev_pid dev_pid
); ))
input_config_set_device_name(idx, device_name);
RARCH_LOG("Port %d: %s.\n", idx, device_name); RARCH_LOG("Port %d: %s.\n", idx, device_name);
} }

View File

@ -141,14 +141,15 @@ static void libusb_hid_device_add_autodetect(unsigned idx,
const char *device_name, const char *driver_name, const char *device_name, const char *driver_name,
uint16_t dev_vid, uint16_t dev_pid) uint16_t dev_vid, uint16_t dev_pid)
{ {
input_autoconfigure_connect( if (!input_autoconfigure_connect(
device_name, device_name,
NULL, NULL,
driver_name, driver_name,
idx, idx,
dev_vid, dev_vid,
dev_pid dev_pid
); ))
input_config_set_device_name(idx, device_name);
} }
static void libusb_get_description(struct libusb_device *device, static void libusb_get_description(struct libusb_device *device,

View File

@ -18,10 +18,13 @@
#include <gccore.h> #include <gccore.h>
#include <rthreads/rthreads.h> #include <rthreads/rthreads.h>
#include "../input_config.h"
#include "../input_defines.h" #include "../input_defines.h"
#include "../connect/joypad_connection.h"
#include "../../tasks/tasks_internal.h"
#include "../input_hid_driver.h" #include "../input_hid_driver.h"
#include "../connect/joypad_connection.h"
#include "../../tasks/tasks_internal.h"
#include "../../verbosity.h" #include "../../verbosity.h"
#define WIIUSB_SC_NONE 0 #define WIIUSB_SC_NONE 0
@ -140,13 +143,14 @@ static void wiiusb_hid_device_add_autodetect(unsigned idx,
const char *device_name, const char *driver_name, const char *device_name, const char *driver_name,
uint16_t dev_vid, uint16_t dev_pid) uint16_t dev_vid, uint16_t dev_pid)
{ {
input_autoconfigure_connect( if (!input_autoconfigure_connect(
device_name, device_name,
NULL, NULL,
driver_name, driver_name,
idx, idx,
dev_vid, dev_vid,
dev_pid); dev_pid))
input_config_set_device_name(idx, device_name);
} }
static void wiiusb_get_description(usb_device_entry *device, static void wiiusb_get_description(usb_device_entry *device,

View File

@ -43,14 +43,15 @@ static const char *ctr_joypad_name(unsigned pad)
static void ctr_joypad_autodetect_add(unsigned autoconf_pad) static void ctr_joypad_autodetect_add(unsigned autoconf_pad)
{ {
input_autoconfigure_connect( if (!input_autoconfigure_connect(
ctr_joypad_name(autoconf_pad), ctr_joypad_name(autoconf_pad),
NULL, NULL,
ctr_joypad.ident, ctr_joypad.ident,
autoconf_pad, autoconf_pad,
0, 0,
0 0
); ))
input_config_set_device_name(autoconf_pad, ctr_joypad_name(autoconf_pad));
} }
static bool ctr_joypad_init(void *data) static bool ctr_joypad_init(void *data)

View File

@ -142,14 +142,17 @@ static void handle_hotplug(unsigned port, uint32_t ptype)
pad_type[port] = ptype; pad_type[port] = ptype;
if (ptype != WPAD_EXP_NOCONTROLLER) if (ptype != WPAD_EXP_NOCONTROLLER)
input_autoconfigure_connect( {
if (!input_autoconfigure_connect(
gx_joypad_name(port), gx_joypad_name(port),
NULL, NULL,
gx_joypad.ident, gx_joypad.ident,
port, port,
0, 0,
0 0
); ))
input_config_set_device_name(port, gx_joypad_name(port));
}
} }
static bool gx_joypad_button(unsigned port, uint16_t key) static bool gx_joypad_button(unsigned port, uint16_t key)

View File

@ -30,8 +30,10 @@
#include <compat/strl.h> #include <compat/strl.h>
#include <string/stdstring.h> #include <string/stdstring.h>
#include "../common/epoll_common.h" #include "../input_config.h"
#include "../input_driver.h" #include "../input_driver.h"
#include "../common/epoll_common.h"
#include "../../configuration.h" #include "../../configuration.h"
#include "../../verbosity.h" #include "../../verbosity.h"
#include "../../tasks/tasks_internal.h" #include "../../tasks/tasks_internal.h"
@ -167,13 +169,14 @@ static void handle_plugged_pad(void)
linuxraw_pads[idx].fd = -1; linuxraw_pads[idx].fd = -1;
*linuxraw_pads[idx].ident = '\0'; *linuxraw_pads[idx].ident = '\0';
input_autoconfigure_connect( if (!input_autoconfigure_connect(
NULL, NULL,
NULL, NULL,
linuxraw_joypad_name(idx), linuxraw_joypad_name(idx),
idx, idx,
0, 0,
0); 0))
input_config_set_device_name(idx, NULL);
} }
} }
/* Sometimes, device will be created before access to it is established. */ /* Sometimes, device will be created before access to it is established. */
@ -188,13 +191,14 @@ static void handle_plugged_pad(void)
if ( !string_is_empty(linuxraw_pads[idx].ident) if ( !string_is_empty(linuxraw_pads[idx].ident)
&& linuxraw_joypad_init_pad(path, &linuxraw_pads[idx])) && linuxraw_joypad_init_pad(path, &linuxraw_pads[idx]))
{ {
input_autoconfigure_connect( if (!input_autoconfigure_connect(
linuxraw_pads[idx].ident, linuxraw_pads[idx].ident,
NULL, NULL,
linuxraw_joypad.ident, linuxraw_joypad.ident,
idx, idx,
0, 0,
0); 0))
input_config_set_device_name(idx, linuxraw_joypad_name(idx));
} }
} }
} }
@ -245,13 +249,14 @@ static bool linuxraw_joypad_init(void *data)
snprintf(path, sizeof(path), "/dev/input/js%u", i); snprintf(path, sizeof(path), "/dev/input/js%u", i);
input_autoconfigure_connect( if (!input_autoconfigure_connect(
pad->ident, pad->ident,
NULL, NULL,
"linuxraw", "linuxraw",
i, i,
0, 0,
0); 0))
input_config_set_device_name(i, pad->ident);
if (linuxraw_joypad_init_pad(path, pad)) if (linuxraw_joypad_init_pad(path, pad))
linuxraw_poll_pad(pad); linuxraw_poll_pad(pad);

View File

@ -302,14 +302,15 @@ static bool parport_joypad_init(void *data)
} }
} }
input_autoconfigure_connect( if (!input_autoconfigure_connect(
"Generic Parallel Port device", "Generic Parallel Port device",
NULL, NULL,
"parport", "parport",
i, i,
0, 0,
0 0
); ))
input_config_set_device_name(i, "Generic Parallel Port device");
} }
return true; return true;

View File

@ -40,14 +40,15 @@ static const char *ps3_joypad_name(unsigned pad)
static void ps3_joypad_autodetect_add(unsigned autoconf_pad) static void ps3_joypad_autodetect_add(unsigned autoconf_pad)
{ {
input_autoconfigure_connect( if (!input_autoconfigure_connect(
ps3_joypad_name(autoconf_pad), ps3_joypad_name(autoconf_pad),
NULL, NULL,
ps3_joypad.ident, ps3_joypad.ident,
autoconf_pad, autoconf_pad,
0, 0,
0 0
); ))
input_config_set_device_name(autoconf_pad, ps3_joypad_name(autoconf_pad));
} }
static bool ps3_joypad_init(void *data) static bool ps3_joypad_init(void *data)

View File

@ -72,14 +72,15 @@ static const char *psp_joypad_name(unsigned pad)
static void psp_joypad_autodetect_add(unsigned autoconf_pad) static void psp_joypad_autodetect_add(unsigned autoconf_pad)
{ {
input_autoconfigure_connect( if (!input_autoconfigure_connect(
psp_joypad_name(autoconf_pad), psp_joypad_name(autoconf_pad),
NULL, NULL,
psp_joypad.ident, psp_joypad.ident,
autoconf_pad, autoconf_pad,
0, 0,
0 0
); ))
input_config_set_device_name(autoconf_pad, psp_joypad_name(autoconf_pad));
} }
static bool psp_joypad_init(void *data) static bool psp_joypad_init(void *data)

View File

@ -31,14 +31,17 @@ static bool qnx_joypad_init(void *data)
(void)data; (void)data;
for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++) for (autoconf_pad = 0; autoconf_pad < MAX_USERS; autoconf_pad++)
input_autoconfigure_connect( {
if (!input_autoconfigure_connect(
qnx_joypad_name(autoconf_pad), qnx_joypad_name(autoconf_pad),
NULL, NULL,
qnx_joypad.ident, qnx_joypad.ident,
autoconf_pad, autoconf_pad,
0, 0,
0 0
); ))
input_config_set_device_name(autoconf_pad, qnx_joypad_name(autoconf_pad));
}
return true; return true;
} }

View File

@ -20,7 +20,9 @@
#include "SDL.h" #include "SDL.h"
#include "../input_config.h"
#include "../input_driver.h" #include "../input_driver.h"
#include "../../tasks/tasks_internal.h" #include "../../tasks/tasks_internal.h"
#include "../../verbosity.h" #include "../../verbosity.h"
@ -51,14 +53,17 @@ static sdl_joypad_t sdl_pads[MAX_USERS];
static bool g_has_haptic; static bool g_has_haptic;
#endif #endif
static const char* sdl_pad_name(unsigned id) static const char *sdl_joypad_name(unsigned pad)
{ {
if (pad >= MAX_USERS)
return NULL;
#ifdef HAVE_SDL2 #ifdef HAVE_SDL2
if (sdl_pads[id].controller) if (sdl_pads[pad].controller)
return SDL_GameControllerNameForIndex(id); return SDL_GameControllerNameForIndex(pad);
return SDL_JoystickNameForIndex(id); return SDL_JoystickNameForIndex(pad);
#else #else
return SDL_JoystickName(id); return SDL_JoystickName(pad);
#endif #endif
} }
@ -140,16 +145,17 @@ static void sdl_pad_connect(unsigned id)
#endif #endif
#endif #endif
input_autoconfigure_connect( if (!input_autoconfigure_connect(
sdl_pad_name(id), sdl_joypad_name(id),
NULL, NULL,
sdl_joypad.ident, sdl_joypad.ident,
id, id,
vendor, vendor,
product); product))
input_config_set_device_name(id, sdl_joypad_name(id));
RARCH_LOG("[SDL]: Device #%u (%04x:%04x) connected: %s.\n", id, vendor, RARCH_LOG("[SDL]: Device #%u (%04x:%04x) connected: %s.\n", id, vendor,
product, sdl_pad_name(id)); product, sdl_joypad_name(id));
#ifdef HAVE_SDL2 #ifdef HAVE_SDL2
@ -438,14 +444,6 @@ static bool sdl_joypad_query_pad(unsigned pad)
return pad < MAX_USERS && sdl_pads[pad].joypad; return pad < MAX_USERS && sdl_pads[pad].joypad;
} }
static const char *sdl_joypad_name(unsigned pad)
{
if (pad >= MAX_USERS)
return NULL;
return sdl_pad_name(pad);
}
input_device_driver_t sdl_joypad = { input_device_driver_t sdl_joypad = {
sdl_joypad_init, sdl_joypad_init,
sdl_joypad_query_pad, sdl_joypad_query_pad,

View File

@ -31,9 +31,11 @@
#include <compat/strl.h> #include <compat/strl.h>
#include <string/stdstring.h> #include <string/stdstring.h>
#include "../../tasks/tasks_internal.h" #include "../input_config.h"
#include "../input_driver.h" #include "../input_driver.h"
#include "../../tasks/tasks_internal.h"
#include "../common/udev_common.h" #include "../common/udev_common.h"
#include "../../configuration.h" #include "../../configuration.h"
@ -280,13 +282,14 @@ static int udev_add_pad(struct udev_device *dev, unsigned p, int fd, const char
if (!string_is_empty(pad->ident)) if (!string_is_empty(pad->ident))
{ {
input_autoconfigure_connect( if (!input_autoconfigure_connect(
pad->ident, pad->ident,
NULL, NULL,
udev_joypad.ident, udev_joypad.ident,
p, p,
pad->vid, pad->vid,
pad->pid); pad->pid))
input_config_set_device_name(p, pad->ident);
ret = 1; ret = 1;
} }

View File

@ -45,14 +45,15 @@ static const char *wiiu_joypad_name(unsigned pad)
static void wiiu_joypad_autodetect_add(unsigned autoconf_pad) static void wiiu_joypad_autodetect_add(unsigned autoconf_pad)
{ {
input_autoconfigure_connect( if (!input_autoconfigure_connect(
wiiu_joypad_name(autoconf_pad), wiiu_joypad_name(autoconf_pad),
NULL, NULL,
wiiu_joypad.ident, wiiu_joypad.ident,
autoconf_pad, autoconf_pad,
0, 0,
0 0
); ))
input_config_set_device_name(autoconf_pad, wiiu_joypad_name(autoconf_pad));
} }
static bool wiiu_joypad_button(unsigned port_num, uint16_t key) static bool wiiu_joypad_button(unsigned port_num, uint16_t key)

View File

@ -44,13 +44,14 @@ static const char *xdk_joypad_name(unsigned pad)
static void xdk_joypad_autodetect_add(unsigned autoconf_pad) static void xdk_joypad_autodetect_add(unsigned autoconf_pad)
{ {
input_autoconfigure_connect( if (!input_autoconfigure_connect(
xdk_joypad_name(autoconf_pad), xdk_joypad_name(autoconf_pad),
NULL, NULL,
xdk_joypad.ident, xdk_joypad.ident,
autoconf_pad, autoconf_pad,
0, 0,
0); 0))
input_config_set_device_name(autoconf_pad, xdk_joypad_name(autoconf_pad));
} }
static bool xdk_joypad_init(void *data) static bool xdk_joypad_init(void *data)