diff --git a/Source/Core/Core/IOS/USB/USBScanner.cpp b/Source/Core/Core/IOS/USB/USBScanner.cpp index 8a8ef2da0b..d96b3c825b 100644 --- a/Source/Core/Core/IOS/USB/USBScanner.cpp +++ b/Source/Core/Core/IOS/USB/USBScanner.cpp @@ -150,6 +150,10 @@ bool USBScanner::AddNewDevices(DeviceMap* new_devices) const const int ret = m_context.GetDeviceList([&](libusb_device* device) { libusb_device_descriptor descriptor; libusb_get_device_descriptor(device, &descriptor); + if (descriptor.idVendor == 0x1209 && descriptor.idProduct == 0x2882) + { + WakeupSantrollerDevice(device); + } if (!whitelist.contains({descriptor.idVendor, descriptor.idProduct})) return true; @@ -179,6 +183,29 @@ void USBScanner::AddEmulatedDevices(DeviceMap* new_devices) } } +void USBScanner::WakeupSantrollerDevice(libusb_device* device) +{ +#ifdef __LIBUSB__ + // Santroller devices emulate various instruments for multiple consoles. + // On an actual console, santroller detects the console based on how it communicates + // with usb devices. Since the underlying operating system is doing that here, the + // check doesn't work, so we need to send a special command to make the device + // jump to wii emulation mode. + libusb_device_handle* lusb_handle; + if (libusb_open(device, &lusb_handle) == LIBUSB_SUCCESS) + { +#ifdef __linux__ + libusb_set_auto_detach_kernel_driver(lusb_handle, true); + libusb_claim_interface(lusb_handle, 2); +#endif + libusb_control_transfer( + lusb_handle, +LIBUSB_ENDPOINT_IN | +LIBUSB_REQUEST_TYPE_CLASS | +LIBUSB_RECIPIENT_INTERFACE, + 0x01, 0x03f2, 2, nullptr, 0x11, 5000); + libusb_close(lusb_handle); + } +#endif +} + void USBScanner::AddDevice(std::unique_ptr device, DeviceMap* new_devices) { (*new_devices)[device->GetId()] = std::move(device); diff --git a/Source/Core/Core/IOS/USB/USBScanner.h b/Source/Core/Core/IOS/USB/USBScanner.h index 60445cb67f..dc850a2bf0 100644 --- a/Source/Core/Core/IOS/USB/USBScanner.h +++ b/Source/Core/Core/IOS/USB/USBScanner.h @@ -41,6 +41,7 @@ private: bool UpdateDevices(); bool AddNewDevices(DeviceMap* new_devices) const; + static void WakeupSantrollerDevice(libusb_device* device); static void AddEmulatedDevices(DeviceMap* new_devices); static void AddDevice(std::unique_ptr device, DeviceMap* new_devices);