|
@@ -955,6 +955,57 @@ HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *device)
|
|
|
return wrapper->backend->hid_error(wrapper->device);
|
|
|
}
|
|
|
|
|
|
+/* This is needed to enable input for Nyko and EVORETRO GameCube adaptors */
|
|
|
+void SDL_EnableGameCubeAdaptors(void)
|
|
|
+{
|
|
|
+#ifdef SDL_LIBUSB_DYNAMIC
|
|
|
+ libusb_context *usb_context = NULL;
|
|
|
+ libusb_device **devs = NULL;
|
|
|
+ libusb_device_handle *handle = NULL;
|
|
|
+ struct libusb_device_descriptor desc;
|
|
|
+ ssize_t i, num_devs;
|
|
|
+ int kernel_detached = 0;
|
|
|
+
|
|
|
+ if (libusb_init(&usb_context) == 0) {
|
|
|
+ num_devs = libusb_get_device_list(usb_context, &devs);
|
|
|
+ for (i = 0; i < num_devs; ++i) {
|
|
|
+ if (libusb_get_device_descriptor(devs[i], &desc) != 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (desc.idVendor != 0x057e || desc.idProduct != 0x0337) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (libusb_open(devs[i], &handle) != 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (libusb_kernel_driver_active(handle, 0)) {
|
|
|
+ if (libusb_detach_kernel_driver(handle, 0) == 0) {
|
|
|
+ kernel_detached = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (libusb_claim_interface(handle, 0) == 0) {
|
|
|
+ libusb_control_transfer(handle, 0x21, 11, 0x0001, 0, NULL, 0, 1000);
|
|
|
+ libusb_release_interface(handle, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (kernel_detached) {
|
|
|
+ libusb_attach_kernel_driver(handle, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ libusb_close(handle);
|
|
|
+ }
|
|
|
+
|
|
|
+ libusb_free_device_list(devs, 1);
|
|
|
+
|
|
|
+ libusb_exit(usb_context);
|
|
|
+ }
|
|
|
+#endif /* SDL_LIBUSB_DYNAMIC */
|
|
|
+}
|
|
|
+
|
|
|
#endif /* SDL_JOYSTICK_HIDAPI */
|
|
|
|
|
|
/* vi: set sts=4 ts=4 sw=4 expandtab: */
|