summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/GCAdapter.cpp
diff options
context:
space:
mode:
authornyanpasu64 <nyanpasu64@tuta.io>2023-06-18 14:28:26 -0700
committernyanpasu64 <nyanpasu64@tuta.io>2023-07-05 20:38:22 -0700
commit559a16da4999c1159bb4d594a969f13e77100a1c (patch)
treea228ea390b1d0d81ff4957204f79ebfdc8239c3f /Source/Core/InputCommon/GCAdapter.cpp
parentafb5eff42685a0b5f2a91ed64237aaf7e2aa9468 (diff)
Reset GC adapter upon IO error after sleep-wake
Fixes GC adapter breaking on sleep-wake on Linux and burning a full CPU core. This is cleaner than alternative approaches.
Diffstat (limited to 'Source/Core/InputCommon/GCAdapter.cpp')
-rw-r--r--Source/Core/InputCommon/GCAdapter.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/Source/Core/InputCommon/GCAdapter.cpp b/Source/Core/InputCommon/GCAdapter.cpp
index cacb73bc79..6088256a55 100644
--- a/Source/Core/InputCommon/GCAdapter.cpp
+++ b/Source/Core/InputCommon/GCAdapter.cpp
@@ -203,9 +203,8 @@ static void ReadThreadFunc()
std::array<u8, CONTROLER_INPUT_PAYLOAD_EXPECTED_SIZE> input_buffer;
int payload_size = 0;
- const int error =
- libusb_interrupt_transfer(s_handle, s_endpoint_in, input_buffer.data(),
- int(input_buffer.size()), &payload_size, USB_TIMEOUT_MS);
+ int error = libusb_interrupt_transfer(s_handle, s_endpoint_in, input_buffer.data(),
+ int(input_buffer.size()), &payload_size, USB_TIMEOUT_MS);
if (error != LIBUSB_SUCCESS)
{
ERROR_LOG_FMT(CONTROLLERINTERFACE, "Read: libusb_interrupt_transfer failed: {}",
@@ -213,7 +212,16 @@ static void ReadThreadFunc()
}
if (error == LIBUSB_ERROR_IO)
{
- break;
+ // s_read_adapter_thread_running is cleared by the joiner, not the stopper.
+
+ // Reset the device, which may trigger a replug.
+ error = libusb_reset_device(s_handle);
+ ERROR_LOG_FMT(CONTROLLERINTERFACE, "Read: libusb_reset_device: {}",
+ LibusbUtils::ErrorWrap(error));
+ if (error != 0)
+ {
+ break;
+ }
}
ProcessInputPayload(input_buffer.data(), payload_size);