mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-29 18:54:34 +00:00
Fixed initializing EVORETRO GameCube adapters
The HID device needs to be closed while enabling input reports over USB
This commit is contained in:
@@ -1619,60 +1619,3 @@ void SDL_hid_ble_scan(bool active)
|
||||
hid_ble_scan(active);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_ENABLE_GAMECUBE_ADAPTORS
|
||||
// This is needed to enable input for Nyko and EVORETRO GameCube adaptors
|
||||
void SDL_EnableGameCubeAdaptors(void)
|
||||
{
|
||||
#ifdef HAVE_LIBUSB
|
||||
libusb_context *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_ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (libusb_ctx->init(&context) == 0) {
|
||||
num_devs = libusb_ctx->get_device_list(context, &devs);
|
||||
for (i = 0; i < num_devs; ++i) {
|
||||
if (libusb_ctx->get_device_descriptor(devs[i], &desc) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (desc.idVendor != 0x057e || desc.idProduct != 0x0337) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (libusb_ctx->open(devs[i], &handle) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (libusb_ctx->kernel_driver_active(handle, 0)) {
|
||||
if (libusb_ctx->detach_kernel_driver(handle, 0) == 0) {
|
||||
kernel_detached = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (libusb_ctx->claim_interface(handle, 0) == 0) {
|
||||
libusb_ctx->control_transfer(handle, 0x21, 11, 0x0001, 0, NULL, 0, 1000);
|
||||
libusb_ctx->release_interface(handle, 0);
|
||||
}
|
||||
|
||||
if (kernel_detached) {
|
||||
libusb_ctx->attach_kernel_driver(handle, 0);
|
||||
}
|
||||
|
||||
libusb_ctx->close(handle);
|
||||
}
|
||||
|
||||
libusb_ctx->free_device_list(devs, 1);
|
||||
|
||||
libusb_ctx->exit(context);
|
||||
}
|
||||
#endif // HAVE_LIBUSB
|
||||
}
|
||||
#endif // HAVE_ENABLE_GAMECUBE_ADAPTORS
|
||||
|
||||
@@ -24,12 +24,3 @@
|
||||
/* Return true if the HIDAPI should ignore a device during enumeration */
|
||||
extern bool SDL_HIDAPI_ShouldIgnoreDevice(int bus_type, Uint16 vendor_id, Uint16 product_id, Uint16 usage_page, Uint16 usage);
|
||||
|
||||
#ifdef SDL_JOYSTICK_HIDAPI
|
||||
#ifdef HAVE_LIBUSB
|
||||
#define HAVE_ENABLE_GAMECUBE_ADAPTORS
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ENABLE_GAMECUBE_ADAPTORS
|
||||
extern void SDL_EnableGameCubeAdaptors(void);
|
||||
#endif
|
||||
#endif /* SDL_JOYSTICK_HIDAPI */
|
||||
|
||||
Reference in New Issue
Block a user