summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2025-05-20 01:13:39 -0500
committerGitHub <noreply@github.com>2025-05-20 01:13:39 -0500
commitfaaf13eaad1a8ac3f31ec63bd2f7c18736324c56 (patch)
treec860b33b6a7cf2edcdc549760ca8d55c5f13d003 /Source
parent2e22a3cf425caae0a3cb52cc4deca7008209955f (diff)
parent8bb07bf3c40be4564bb9d478af2eadd8384226e7 (diff)
Merge pull request #13562 from sanjay900/santroller-support
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);