IOS: Check if libusb can be used instead of asserting
This prevents panic alerts from showing up three times when starting Wii emulation whenever libusb could not be initialized. The user has already seen a warning at startup -- no need to warn them 3 more times.
This commit is contained in:
parent
d244597b42
commit
f5a3aac8e1
|
@ -61,8 +61,6 @@ BluetoothReal::BluetoothReal(u32 device_id, const std::string& device_name)
|
|||
: BluetoothBase(device_id, device_name)
|
||||
{
|
||||
m_libusb_context = LibusbContext::Get();
|
||||
_assert_msg_(IOS_WIIMOTE, m_libusb_context, "Failed to init libusb.");
|
||||
|
||||
LoadLinkKeys();
|
||||
}
|
||||
|
||||
|
@ -84,6 +82,9 @@ BluetoothReal::~BluetoothReal()
|
|||
|
||||
ReturnCode BluetoothReal::Open(const OpenRequest& request)
|
||||
{
|
||||
if (!m_libusb_context)
|
||||
return IPC_EACCES;
|
||||
|
||||
libusb_device** list;
|
||||
const ssize_t cnt = libusb_get_device_list(m_libusb_context.get(), &list);
|
||||
_dbg_assert_msg_(IOS, cnt > 0, "Couldn't get device list");
|
||||
|
|
|
@ -32,7 +32,6 @@ USBHost::USBHost(u32 device_id, const std::string& device_name) : Device(device_
|
|||
{
|
||||
#ifdef __LIBUSB__
|
||||
m_libusb_context = LibusbContext::Get();
|
||||
_assert_msg_(IOS_USB, m_libusb_context, "Failed to init libusb.");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -117,11 +116,14 @@ bool USBHost::AddNewDevices(std::set<u64>& new_devices, DeviceChangeHooks& hooks
|
|||
const bool always_add_hooks)
|
||||
{
|
||||
#ifdef __LIBUSB__
|
||||
if (m_libusb_context)
|
||||
{
|
||||
libusb_device** list;
|
||||
const ssize_t count = libusb_get_device_list(m_libusb_context.get(), &list);
|
||||
if (count < 0)
|
||||
{
|
||||
WARN_LOG(IOS_USB, "Failed to get device list: %s", libusb_error_name(static_cast<int>(count)));
|
||||
WARN_LOG(IOS_USB, "Failed to get device list: %s",
|
||||
libusb_error_name(static_cast<int>(count)));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -130,7 +132,8 @@ bool USBHost::AddNewDevices(std::set<u64>& new_devices, DeviceChangeHooks& hooks
|
|||
libusb_device* device = list[i];
|
||||
libusb_device_descriptor descriptor;
|
||||
libusb_get_device_descriptor(device, &descriptor);
|
||||
if (!SConfig::GetInstance().IsUSBDeviceWhitelisted({descriptor.idVendor, descriptor.idProduct}))
|
||||
if (!SConfig::GetInstance().IsUSBDeviceWhitelisted(
|
||||
{descriptor.idVendor, descriptor.idProduct}))
|
||||
continue;
|
||||
|
||||
auto usb_device = std::make_unique<USB::LibusbDevice>(device, descriptor);
|
||||
|
@ -142,6 +145,7 @@ bool USBHost::AddNewDevices(std::set<u64>& new_devices, DeviceChangeHooks& hooks
|
|||
hooks.emplace(GetDeviceById(id), ChangeEvent::Inserted);
|
||||
}
|
||||
libusb_free_device_list(list, 1);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
@ -195,7 +199,7 @@ void USBHost::StartThreads()
|
|||
}
|
||||
|
||||
#ifdef __LIBUSB__
|
||||
if (!m_event_thread_running.IsSet())
|
||||
if (m_libusb_context && !m_event_thread_running.IsSet())
|
||||
{
|
||||
m_event_thread_running.Set();
|
||||
m_event_thread = std::thread([this] {
|
||||
|
|
Loading…
Reference in New Issue