summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorSanjay Govind <sanjay.govind9@gmail.com>2025-04-23 09:20:43 +1200
committerSanjay Govind <sanjay.govind9@gmail.com>2025-04-24 12:09:41 +1200
commit8bb07bf3c40be4564bb9d478af2eadd8384226e7 (patch)
treeb9be3f818dd58037355ecc641361eb8e170f8811 /Source
parentafee9a56e96766d4622b1694398704e4c8d57b25 (diff)
LibusbDevice: Send wakeup command to Santroller devices
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/IOS/USB/USBScanner.cpp27
-rw-r--r--Source/Core/Core/IOS/USB/USBScanner.h1
2 files changed, 28 insertions, 0 deletions
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<USB::Device> 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<USB::Device> device, DeviceMap* new_devices);