1
0
mirror of https://github.com/libretro/RetroArch synced 2025-03-18 22:20:57 +00:00

Merge pull request from heuripedes/sdl2-device-ids

(SDL2) Implement joypad vendor/product id detection
This commit is contained in:
Twinaphex 2014-10-02 13:34:01 +02:00
commit 860c690cbf

@ -88,8 +88,12 @@ static void pad_connect(unsigned id)
{ {
sdl_joypad_t *pad = &g_pads[id]; sdl_joypad_t *pad = &g_pads[id];
bool success = false; bool success = false;
int32_t product = 0;
int32_t vendor = 0;
#ifdef HAVE_SDL2 #ifdef HAVE_SDL2
uint16_t *guid = NULL;
if (SDL_IsGameController(id)) if (SDL_IsGameController(id))
{ {
pad->controller = SDL_GameControllerOpen(id); pad->controller = SDL_GameControllerOpen(id);
@ -117,11 +121,22 @@ static void pad_connect(unsigned id)
} }
strlcpy(g_settings.input.device_names[id], pad_name(id), sizeof(g_settings.input.device_names[id])); strlcpy(g_settings.input.device_names[id], pad_name(id), sizeof(g_settings.input.device_names[id]));
/* TODO - implement VID/PID? */
input_config_autoconfigure_joypad(id, pad_name(id),
0, 0, sdl_joypad.ident);
RARCH_LOG("[SDL]: Joypad #%u connected: %s.\n", id, pad_name(id)); #ifdef HAVE_SDL2
guid = (uint16_t*)SDL_JoystickGetGUID(pad->joypad).data;
#ifdef __linux
vendor = guid[2];
product = guid[4];
#elif _WIN32
vendor = guid[0];
product = guid[1];
#endif
#endif
input_config_autoconfigure_joypad(id, pad_name(id),
vendor, product, sdl_joypad.ident);
RARCH_LOG("[SDL]: Joypad #%u (%04x:%04x) connected: %s.\n", id, vendor,
product, pad_name(id));
#ifdef HAVE_SDL2 #ifdef HAVE_SDL2