Make serial optional to find USB devices
If no serial is provided, then list all available USB devices (which can
be open and having a serial).
PR <https://github.com/Genymobile/scrcpy/pull/2974>
@@ -53,12 +53,15 @@ accept_device(libusb_device *device, const char *serial,
return false;
}
+ if (serial) {
+ // Filter by serial
bool matches = !strcmp(serial, device_serial);
if (!matches) {
free(device_serial);
libusb_close(handle);
return false;
}
+ }
out->device = libusb_ref_device(device);
out->serial = device_serial;
@@ -90,8 +93,6 @@ sc_usb_device_destroy_all(struct sc_usb_device *usb_devices, size_t count) {
ssize_t
sc_usb_find_devices(struct sc_usb *usb, const char *serial,
struct sc_usb_device *devices, size_t len) {
- assert(serial);
-
libusb_device **list;
ssize_t count = libusb_get_device_list(usb->context, &list);
if (count < 0) {
