mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-21 00:05:30 +00:00
Use EVIOCGID's ioctl to get vendor/product id, #6325
The current code get the USB vendor/product controller, in case of bluetooth connection this means that you get the bluetooth dongle ids instead of gamepads. This is not fine as we match gamepads using their product and vendor ids. Credits go to SDL which helped me to figure out this issue. http://hg.libsdl.org/SDL/file/f7c6b974d5af/src/joystick/linux/SDL_sysjoystick.c#l208
This commit is contained in:
parent
cf7785d784
commit
e99049a8ff
@ -151,6 +151,7 @@ static int udev_add_pad(struct udev_device *dev, unsigned p, int fd, const char
|
||||
unsigned axes = 0;
|
||||
struct udev_device *parent = NULL;
|
||||
struct udev_joypad *pad = (struct udev_joypad*)&udev_pads[p];
|
||||
struct input_id inputid = {0};
|
||||
unsigned long keybit[NBITS(KEY_MAX)] = {0};
|
||||
unsigned long absbit[NBITS(ABS_MAX)] = {0};
|
||||
unsigned long ffbit[NBITS(FF_MAX)] = {0};
|
||||
@ -163,16 +164,12 @@ static int udev_add_pad(struct udev_device *dev, unsigned p, int fd, const char
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Don't worry about unref'ing the parent. */
|
||||
parent = udev_device_get_parent_with_subsystem_devtype(dev, "usb", "usb_device");
|
||||
|
||||
pad->vid = pad->pid = 0;
|
||||
|
||||
if ((buf = udev_device_get_sysattr_value(parent, "idVendor")) != NULL)
|
||||
pad->vid = strtol(buf, NULL, 16);
|
||||
|
||||
if ((buf = udev_device_get_sysattr_value(parent, "idProduct")) != NULL)
|
||||
pad->pid = strtol(buf, NULL, 16);
|
||||
if (ioctl(fd, EVIOCGID, &inputid) >= 0) {
|
||||
pad->vid = inputid.vendor;
|
||||
pad->pid = inputid.product;
|
||||
}
|
||||
|
||||
RARCH_LOG("[udev]: Plugged pad: %s (%u:%u) on port #%u.\n",
|
||||
pad->ident, pad->vid, pad->pid, p);
|
||||
|
Loading…
x
Reference in New Issue
Block a user