summaryrefslogtreecommitdiff
path: root/src/input_common/drivers/gc_adapter.cpp
diff options
context:
space:
mode:
authorGravatar german772021-10-30 11:20:47 -0500
committerGravatar Narr the Reg2021-11-24 20:30:26 -0600
commitd8e3f2b10bad7e4a0ae09c90c76e8a1927c3d1ab (patch)
tree7221e7d8fe678b874559545d063d56b4a972a5e0 /src/input_common/drivers/gc_adapter.cpp
parentcore/hid: Update structs to 13.1.0 (diff)
downloadyuzu-d8e3f2b10bad7e4a0ae09c90c76e8a1927c3d1ab.tar.gz
yuzu-d8e3f2b10bad7e4a0ae09c90c76e8a1927c3d1ab.tar.xz
yuzu-d8e3f2b10bad7e4a0ae09c90c76e8a1927c3d1ab.zip
input_common: Fix GC adapter initialization
Fix GC controller
Diffstat (limited to 'src/input_common/drivers/gc_adapter.cpp')
-rw-r--r--src/input_common/drivers/gc_adapter.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp
index 25b66f528..62dc28711 100644
--- a/src/input_common/drivers/gc_adapter.cpp
+++ b/src/input_common/drivers/gc_adapter.cpp
@@ -73,7 +73,7 @@ GCAdapter::GCAdapter(const std::string input_engine_) : InputEngine(input_engine
73 if (usb_adapter_handle) { 73 if (usb_adapter_handle) {
74 return; 74 return;
75 } 75 }
76 LOG_INFO(Input, "GC Adapter Initialization started"); 76 LOG_DEBUG(Input, "Initialization started");
77 77
78 libusb_ctx = std::make_unique<LibUSBContext>(); 78 libusb_ctx = std::make_unique<LibUSBContext>();
79 const int init_res = libusb_ctx->InitResult(); 79 const int init_res = libusb_ctx->InitResult();
@@ -90,7 +90,7 @@ GCAdapter::~GCAdapter() {
90} 90}
91 91
92void GCAdapter::AdapterInputThread(std::stop_token stop_token) { 92void GCAdapter::AdapterInputThread(std::stop_token stop_token) {
93 LOG_DEBUG(Input, "GC Adapter input thread started"); 93 LOG_DEBUG(Input, "Input thread started");
94 Common::SetCurrentThreadName("yuzu:input:GCAdapter"); 94 Common::SetCurrentThreadName("yuzu:input:GCAdapter");
95 s32 payload_size{}; 95 s32 payload_size{};
96 AdapterPayload adapter_payload{}; 96 AdapterPayload adapter_payload{};
@@ -120,7 +120,7 @@ bool GCAdapter::IsPayloadCorrect(const AdapterPayload& adapter_payload, s32 payl
120 LOG_DEBUG(Input, "Error reading payload (size: {}, type: {:02x})", payload_size, 120 LOG_DEBUG(Input, "Error reading payload (size: {}, type: {:02x})", payload_size,
121 adapter_payload[0]); 121 adapter_payload[0]);
122 if (input_error_counter++ > 20) { 122 if (input_error_counter++ > 20) {
123 LOG_ERROR(Input, "GC adapter timeout, Is the adapter connected?"); 123 LOG_ERROR(Input, "Timeout, Is the adapter connected?");
124 adapter_input_thread.request_stop(); 124 adapter_input_thread.request_stop();
125 restart_scan_thread = true; 125 restart_scan_thread = true;
126 } 126 }
@@ -263,13 +263,6 @@ bool GCAdapter::Setup() {
263} 263}
264 264
265bool GCAdapter::CheckDeviceAccess() { 265bool GCAdapter::CheckDeviceAccess() {
266 // This fixes payload problems from offbrand GCAdapters
267 const s32 control_transfer_error =
268 libusb_control_transfer(usb_adapter_handle->get(), 0x21, 11, 0x0001, 0, nullptr, 0, 1000);
269 if (control_transfer_error < 0) {
270 LOG_ERROR(Input, "libusb_control_transfer failed with error= {}", control_transfer_error);
271 }
272
273 s32 kernel_driver_error = libusb_kernel_driver_active(usb_adapter_handle->get(), 0); 266 s32 kernel_driver_error = libusb_kernel_driver_active(usb_adapter_handle->get(), 0);
274 if (kernel_driver_error == 1) { 267 if (kernel_driver_error == 1) {
275 kernel_driver_error = libusb_detach_kernel_driver(usb_adapter_handle->get(), 0); 268 kernel_driver_error = libusb_detach_kernel_driver(usb_adapter_handle->get(), 0);
@@ -291,6 +284,13 @@ bool GCAdapter::CheckDeviceAccess() {
291 return false; 284 return false;
292 } 285 }
293 286
287 // This fixes payload problems from offbrand GCAdapters
288 const s32 control_transfer_error =
289 libusb_control_transfer(usb_adapter_handle->get(), 0x21, 11, 0x0001, 0, nullptr, 0, 1000);
290 if (control_transfer_error < 0) {
291 LOG_ERROR(Input, "libusb_control_transfer failed with error= {}", control_transfer_error);
292 }
293
294 return true; 294 return true;
295} 295}
296 296
@@ -370,9 +370,9 @@ void GCAdapter::SendVibrations() {
370 libusb_interrupt_transfer(usb_adapter_handle->get(), output_endpoint, payload.data(), 370 libusb_interrupt_transfer(usb_adapter_handle->get(), output_endpoint, payload.data(),
371 static_cast<s32>(payload.size()), &size, 16); 371 static_cast<s32>(payload.size()), &size, 16);
372 if (err) { 372 if (err) {
373 LOG_DEBUG(Input, "Adapter libusb write failed: {}", libusb_error_name(err)); 373 LOG_DEBUG(Input, "Libusb write failed: {}", libusb_error_name(err));
374 if (output_error_counter++ > 5) { 374 if (output_error_counter++ > 5) {
375 LOG_ERROR(Input, "GC adapter output timeout, Rumble disabled"); 375 LOG_ERROR(Input, "Output timeout, Rumble disabled");
376 rumble_enabled = false; 376 rumble_enabled = false;
377 } 377 }
378 return; 378 return;