summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmeer <aj662@drexel.edu>2020-07-08 19:19:33 +0200
committerAmeer <aj662@drexel.edu>2020-07-08 19:19:33 +0200
commitec13746e4d1adb8567a3d52531ede6f57cde68f7 (patch)
treec21737fcbe948b0002ea76b1346f41ef91e4979b
parentMerge pull request #4243 from CrazyMax/display_version (diff)
downloadyuzu-ec13746e4d1adb8567a3d52531ede6f57cde68f7.tar
yuzu-ec13746e4d1adb8567a3d52531ede6f57cde68f7.tar.gz
yuzu-ec13746e4d1adb8567a3d52531ede6f57cde68f7.tar.bz2
yuzu-ec13746e4d1adb8567a3d52531ede6f57cde68f7.tar.lz
yuzu-ec13746e4d1adb8567a3d52531ede6f57cde68f7.tar.xz
yuzu-ec13746e4d1adb8567a3d52531ede6f57cde68f7.tar.zst
yuzu-ec13746e4d1adb8567a3d52531ede6f57cde68f7.zip
-rw-r--r--src/input_common/gcadapter/gc_adapter.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/input_common/gcadapter/gc_adapter.cpp b/src/input_common/gcadapter/gc_adapter.cpp
index b39d2a3fb..f6e51705b 100644
--- a/src/input_common/gcadapter/gc_adapter.cpp
+++ b/src/input_common/gcadapter/gc_adapter.cpp
@@ -24,9 +24,13 @@ Adapter::Adapter() {
LOG_INFO(Input, "GC Adapter Initialization started");
current_status = NO_ADAPTER_DETECTED;
- libusb_init(&libusb_ctx);
- StartScanThread();
+ const int init_res = libusb_init(&libusb_ctx);
+ if (init_res == LIBUSB_SUCCESS) {
+ StartScanThread();
+ } else {
+ LOG_ERROR(Input, "libusb could not be initialized. failed with error = {}", init_res);
+ }
}
GCPadStatus Adapter::GetPadStatus(int port, const std::array<u8, 37>& adapter_payload) {
@@ -215,6 +219,10 @@ void Adapter::Setup() {
// populate the list of devices, get the count
const std::size_t device_count = libusb_get_device_list(libusb_ctx, &devices);
+ if (device_count < 0) {
+ LOG_ERROR(Input, "libusb_get_device_list failed with error: {}", device_count);
+ return;
+ }
for (std::size_t index = 0; index < device_count; ++index) {
if (CheckDeviceAccess(devices[index])) {
@@ -223,6 +231,7 @@ void Adapter::Setup() {
break;
}
}
+ libusb_free_device_list(devices, 1);
}
bool Adapter::CheckDeviceAccess(libusb_device* device) {
@@ -279,7 +288,13 @@ bool Adapter::CheckDeviceAccess(libusb_device* device) {
void Adapter::GetGCEndpoint(libusb_device* device) {
libusb_config_descriptor* config = nullptr;
- libusb_get_config_descriptor(device, 0, &config);
+ const int config_descriptor_error = libusb_get_config_descriptor(device, 0, &config);
+ if (config_descriptor_error) {
+ LOG_ERROR(Input, "libusb_get_config_descriptor failed with error = {}",
+ config_descriptor_error);
+ return;
+ }
+
for (u8 ic = 0; ic < config->bNumInterfaces; ic++) {
const libusb_interface* interfaceContainer = &config->interface[ic];
for (int i = 0; i < interfaceContainer->num_altsetting; i++) {