mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-26 21:45:39 +01:00
Address comments for better clarity/signed dev count
This commit is contained in:
parent
ec13746e4d
commit
3c7a115afe
@ -215,23 +215,27 @@ void Adapter::Setup() {
|
|||||||
adapter_controllers_status.fill(ControllerTypes::None);
|
adapter_controllers_status.fill(ControllerTypes::None);
|
||||||
|
|
||||||
// pointer to list of connected usb devices
|
// pointer to list of connected usb devices
|
||||||
libusb_device** devices;
|
libusb_device** devices{};
|
||||||
|
|
||||||
// populate the list of devices, get the count
|
// populate the list of devices, get the count
|
||||||
const std::size_t device_count = libusb_get_device_list(libusb_ctx, &devices);
|
const ssize_t device_count = libusb_get_device_list(libusb_ctx, &devices);
|
||||||
if (device_count < 0) {
|
if (device_count < 0) {
|
||||||
LOG_ERROR(Input, "libusb_get_device_list failed with error: {}", device_count);
|
LOG_ERROR(Input, "libusb_get_device_list failed with error: {}", device_count);
|
||||||
|
detect_thread_running = false; // Stop the loop constantly checking for gc adapter
|
||||||
|
// TODO: For hotplug+gc adapter checkbox implementation, revert this.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::size_t index = 0; index < device_count; ++index) {
|
if (devices != nullptr) {
|
||||||
if (CheckDeviceAccess(devices[index])) {
|
for (std::size_t index = 0; index < device_count; ++index) {
|
||||||
// GC Adapter found and accessible, registering it
|
if (CheckDeviceAccess(devices[index])) {
|
||||||
GetGCEndpoint(devices[index]);
|
// GC Adapter found and accessible, registering it
|
||||||
break;
|
GetGCEndpoint(devices[index]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
libusb_free_device_list(devices, 1);
|
||||||
}
|
}
|
||||||
libusb_free_device_list(devices, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Adapter::CheckDeviceAccess(libusb_device* device) {
|
bool Adapter::CheckDeviceAccess(libusb_device* device) {
|
||||||
@ -288,10 +292,10 @@ bool Adapter::CheckDeviceAccess(libusb_device* device) {
|
|||||||
|
|
||||||
void Adapter::GetGCEndpoint(libusb_device* device) {
|
void Adapter::GetGCEndpoint(libusb_device* device) {
|
||||||
libusb_config_descriptor* config = nullptr;
|
libusb_config_descriptor* config = nullptr;
|
||||||
const int config_descriptor_error = libusb_get_config_descriptor(device, 0, &config);
|
const int config_descriptor_return = libusb_get_config_descriptor(device, 0, &config);
|
||||||
if (config_descriptor_error) {
|
if (config_descriptor_return != LIBUSB_SUCCESS) {
|
||||||
LOG_ERROR(Input, "libusb_get_config_descriptor failed with error = {}",
|
LOG_ERROR(Input, "libusb_get_config_descriptor failed with error = {}",
|
||||||
config_descriptor_error);
|
config_descriptor_return);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user