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
|
||||
|
||||
Reference in New Issue
Block a user