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 #2974 <https://github.com/Genymobile/scrcpy/pull/2974>
This commit is contained in:
parent
1c17f57c10
commit
8fc9dca8cb
1 changed files with 8 additions and 7 deletions
|
@ -53,12 +53,15 @@ accept_device(libusb_device *device, const char *serial,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (serial) {
|
||||||
|
// Filter by serial
|
||||||
bool matches = !strcmp(serial, device_serial);
|
bool matches = !strcmp(serial, device_serial);
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
free(device_serial);
|
free(device_serial);
|
||||||
libusb_close(handle);
|
libusb_close(handle);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
out->device = libusb_ref_device(device);
|
out->device = libusb_ref_device(device);
|
||||||
out->serial = device_serial;
|
out->serial = device_serial;
|
||||||
|
@ -90,8 +93,6 @@ sc_usb_device_destroy_all(struct sc_usb_device *usb_devices, size_t count) {
|
||||||
ssize_t
|
ssize_t
|
||||||
sc_usb_find_devices(struct sc_usb *usb, const char *serial,
|
sc_usb_find_devices(struct sc_usb *usb, const char *serial,
|
||||||
struct sc_usb_device *devices, size_t len) {
|
struct sc_usb_device *devices, size_t len) {
|
||||||
assert(serial);
|
|
||||||
|
|
||||||
libusb_device **list;
|
libusb_device **list;
|
||||||
ssize_t count = libusb_get_device_list(usb->context, &list);
|
ssize_t count = libusb_get_device_list(usb->context, &list);
|
||||||
if (count < 0) {
|
if (count < 0) {
|
||||||
|
|
Loading…
Reference in a new issue