mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-09-08 03:19:09 +01:00
Stop reading loop if error is encountered
This commit is contained in:
parent
c18dc9c707
commit
3f739514e3
1 changed files with 4 additions and 4 deletions
|
@ -95,7 +95,7 @@ void Adapter::Read() {
|
||||||
|
|
||||||
while (adapter_thread_running) {
|
while (adapter_thread_running) {
|
||||||
libusb_interrupt_transfer(usb_adapter_handle, input_endpoint, adapter_payload.data(),
|
libusb_interrupt_transfer(usb_adapter_handle, input_endpoint, adapter_payload.data(),
|
||||||
sizeof(adapter_payload), &payload_size_in, 32);
|
sizeof(adapter_payload), &payload_size_in, 16);
|
||||||
payload_size_copy = 0;
|
payload_size_copy = 0;
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(s_mutex);
|
std::lock_guard<std::mutex> lk(s_mutex);
|
||||||
|
@ -106,9 +106,9 @@ void Adapter::Read() {
|
||||||
|
|
||||||
if (payload_size_copy != sizeof(adapter_payload_copy) ||
|
if (payload_size_copy != sizeof(adapter_payload_copy) ||
|
||||||
adapter_payload_copy[0] != LIBUSB_DT_HID) {
|
adapter_payload_copy[0] != LIBUSB_DT_HID) {
|
||||||
// TODO: It might be worthwhile to Shutdown GC Adapter if we encounter errors here
|
|
||||||
LOG_ERROR(Input, "error reading payload (size: %d, type: %02x)", payload_size_copy,
|
LOG_ERROR(Input, "error reading payload (size: %d, type: %02x)", payload_size_copy,
|
||||||
adapter_payload_copy[0]);
|
adapter_payload_copy[0]);
|
||||||
|
adapter_thread_running = false; // error reading from adapter, stop reading.
|
||||||
} else {
|
} else {
|
||||||
for (int port = 0; port < pads.size(); port++) {
|
for (int port = 0; port < pads.size(); port++) {
|
||||||
pads[port] = GetPadStatus(port, adapter_payload_copy);
|
pads[port] = GetPadStatus(port, adapter_payload_copy);
|
||||||
|
@ -291,14 +291,14 @@ void Adapter::Reset() {
|
||||||
|
|
||||||
if (adapter_thread_running) {
|
if (adapter_thread_running) {
|
||||||
adapter_thread_running = false;
|
adapter_thread_running = false;
|
||||||
adapter_input_thread.join();
|
|
||||||
}
|
}
|
||||||
|
adapter_input_thread.join();
|
||||||
|
|
||||||
adapter_controllers_status.fill(ControllerTypes::None);
|
adapter_controllers_status.fill(ControllerTypes::None);
|
||||||
current_status = NO_ADAPTER_DETECTED;
|
current_status = NO_ADAPTER_DETECTED;
|
||||||
|
|
||||||
if (usb_adapter_handle) {
|
if (usb_adapter_handle) {
|
||||||
libusb_release_interface(usb_adapter_handle, 0);
|
libusb_release_interface(usb_adapter_handle, 1);
|
||||||
libusb_close(usb_adapter_handle);
|
libusb_close(usb_adapter_handle);
|
||||||
usb_adapter_handle = nullptr;
|
usb_adapter_handle = nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue