diff options
| author | 2020-07-01 12:52:50 -0400 | |
|---|---|---|
| committer | 2020-07-01 12:52:50 -0400 | |
| commit | 34a590e50966341cec5f1874410931decbce284f (patch) | |
| tree | 34fa09874826a5ef21fcb495e0a4cde783592fda | |
| parent | Address feedback regarding increments, const vars, and general cleanup (diff) | |
| download | yuzu-34a590e50966341cec5f1874410931decbce284f.tar.gz yuzu-34a590e50966341cec5f1874410931decbce284f.tar.xz yuzu-34a590e50966341cec5f1874410931decbce284f.zip | |
Reset adapter state on init, fixes errors relating driver hang from unexpected unplug
Diffstat (limited to '')
| -rw-r--r-- | src/input_common/gcadapter/gc_adapter.cpp | 8 | ||||
| -rw-r--r-- | src/input_common/gcadapter/gc_adapter.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/input_common/gcadapter/gc_adapter.cpp b/src/input_common/gcadapter/gc_adapter.cpp index b98b85441..1ddb9cdb4 100644 --- a/src/input_common/gcadapter/gc_adapter.cpp +++ b/src/input_common/gcadapter/gc_adapter.cpp | |||
| @@ -97,6 +97,7 @@ void Adapter::Read() { | |||
| 97 | libusb_interrupt_transfer(usb_adapter_handle, input_endpoint, adapter_payload.data(), | 97 | libusb_interrupt_transfer(usb_adapter_handle, input_endpoint, adapter_payload.data(), |
| 98 | sizeof(adapter_payload), &payload_size_in, 16); | 98 | sizeof(adapter_payload), &payload_size_in, 16); |
| 99 | payload_size_copy = 0; | 99 | payload_size_copy = 0; |
| 100 | // this mutex might be redundant? | ||
| 100 | { | 101 | { |
| 101 | std::lock_guard<std::mutex> lk(s_mutex); | 102 | std::lock_guard<std::mutex> lk(s_mutex); |
| 102 | std::copy(std::begin(adapter_payload), std::end(adapter_payload), | 103 | std::copy(std::begin(adapter_payload), std::end(adapter_payload), |
| @@ -265,10 +266,17 @@ void Adapter::GetGCEndpoint(libusb_device* device) { | |||
| 265 | const libusb_endpoint_descriptor* endpoint = &interface->endpoint[e]; | 266 | const libusb_endpoint_descriptor* endpoint = &interface->endpoint[e]; |
| 266 | if (endpoint->bEndpointAddress & LIBUSB_ENDPOINT_IN) { | 267 | if (endpoint->bEndpointAddress & LIBUSB_ENDPOINT_IN) { |
| 267 | input_endpoint = endpoint->bEndpointAddress; | 268 | input_endpoint = endpoint->bEndpointAddress; |
| 269 | } else { | ||
| 270 | output_endpoint = endpoint->bEndpointAddress; | ||
| 268 | } | 271 | } |
| 269 | } | 272 | } |
| 270 | } | 273 | } |
| 271 | } | 274 | } |
| 275 | // This transfer seems to be responsible for clearing the state of the adapter | ||
| 276 | // Used to clear the "busy" state of when the device is unexpectedly unplugged | ||
| 277 | unsigned char clear_payload = 0x13; | ||
| 278 | libusb_interrupt_transfer(usb_adapter_handle, output_endpoint, &clear_payload, | ||
| 279 | sizeof(clear_payload), nullptr, 16); | ||
| 272 | 280 | ||
| 273 | adapter_thread_running = true; | 281 | adapter_thread_running = true; |
| 274 | current_status = ADAPTER_DETECTED; | 282 | current_status = ADAPTER_DETECTED; |
diff --git a/src/input_common/gcadapter/gc_adapter.h b/src/input_common/gcadapter/gc_adapter.h index 91aa9622b..4a8e2644c 100644 --- a/src/input_common/gcadapter/gc_adapter.h +++ b/src/input_common/gcadapter/gc_adapter.h | |||
| @@ -152,6 +152,7 @@ private: | |||
| 152 | libusb_context* libusb_ctx; | 152 | libusb_context* libusb_ctx; |
| 153 | 153 | ||
| 154 | u8 input_endpoint = 0; | 154 | u8 input_endpoint = 0; |
| 155 | u8 output_endpoint = 0; | ||
| 155 | 156 | ||
| 156 | bool configuring = false; | 157 | bool configuring = false; |
| 157 | 158 | ||