Added support for the Nintendo GameCube adapter, tested on Steam Link hardware
diff --git a/src/hidapi/SDL_hidapi.c b/src/hidapi/SDL_hidapi.c
index c35c44f..f320c76 100644
--- a/src/hidapi/SDL_hidapi.c
+++ b/src/hidapi/SDL_hidapi.c
@@ -535,9 +535,7 @@
struct PLATFORM_hid_device_info *raw_dev;
#endif /* HAVE_PLATFORM_BACKEND */
struct hid_device_info *devs = NULL, *last = NULL, *new_dev;
-#ifdef SDL_LIBUSB_DYNAMIC
SDL_bool bFound;
-#endif
if (SDL_hidapi_wasinit == SDL_FALSE) {
hid_init();
@@ -557,6 +555,10 @@
bFound = SDL_FALSE;
#if HAVE_PLATFORM_BACKEND
for (raw_dev = raw_devs; raw_dev; raw_dev = raw_dev->next) {
+ if (raw_dev->vendor_id == 0x057e && raw_dev->product_id == 0x0337) {
+ /* The GameCube adapter is handled by the USB HIDAPI driver */
+ continue;
+ }
if (usb_dev->vendor_id == raw_dev->vendor_id &&
usb_dev->product_id == raw_dev->product_id &&
(raw_dev->interface_number < 0 || usb_dev->interface_number == raw_dev->interface_number)) {
@@ -585,16 +587,28 @@
#if HAVE_PLATFORM_BACKEND
if (udev_ctx) {
for (raw_dev = raw_devs; raw_dev; raw_dev = raw_dev->next) {
- new_dev = (struct hid_device_info*) SDL_malloc(sizeof(struct hid_device_info));
- PLATFORM_CopyHIDDeviceInfo(raw_dev, new_dev);
- new_dev->next = NULL;
-
- if (last != NULL) {
- last->next = new_dev;
- } else {
- devs = new_dev;
+ bFound = SDL_FALSE;
+ for (new_dev = devs; new_dev; new_dev = new_dev->next) {
+ if (raw_dev->vendor_id == new_dev->vendor_id &&
+ raw_dev->product_id == new_dev->product_id &&
+ raw_dev->interface_number == new_dev->interface_number) {
+ bFound = SDL_TRUE;
+ break;
+ }
}
- last = new_dev;
+
+ if (!bFound) {
+ new_dev = (struct hid_device_info*) SDL_malloc(sizeof(struct hid_device_info));
+ PLATFORM_CopyHIDDeviceInfo(raw_dev, new_dev);
+ new_dev->next = NULL;
+
+ if (last != NULL) {
+ last->next = new_dev;
+ } else {
+ devs = new_dev;
+ }
+ last = new_dev;
+ }
}
PLATFORM_hid_free_enumeration(raw_devs);
}
diff --git a/src/joystick/hidapi/SDL_hidapi_gamecube.c b/src/joystick/hidapi/SDL_hidapi_gamecube.c
index 34648f9..197c2a3 100644
--- a/src/joystick/hidapi/SDL_hidapi_gamecube.c
+++ b/src/joystick/hidapi/SDL_hidapi_gamecube.c
@@ -98,6 +98,9 @@
goto error;
}
+ /* Wait for the adapter to initialize */
+ SDL_Delay(10);
+
/* Add all the applicable joysticks */
while ((size = hid_read_timeout(device->dev, packet, sizeof(packet), 0)) > 0) {
if (size < 37 || packet[0] != 0x21) {
diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c
index 3248769..b9277f9 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -734,11 +734,11 @@
SDL_HIDAPI_devices = device;
}
-#ifdef DEBUG_HIDAPI
- SDL_Log("Added HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, interface %d, usage page 0x%.4x, usage 0x%.4x, driver = %s\n", device->name, device->vendor_id, device->product_id, device->version, device->interface_number, device->usage_page, device->usage, device->driver ? device->driver->hint : "NONE");
-#endif
-
HIDAPI_SetupDeviceDriver(device);
+
+#ifdef DEBUG_HIDAPI
+ SDL_Log("Added HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, interface %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s\n", device->name, device->vendor_id, device->product_id, device->version, device->interface_number, device->usage_page, device->usage, device->path, device->driver ? device->driver->hint : "NONE");
+#endif
}