Expose function to find a USB device
The device was automatically found by sc_usb_connect(). Instead, expose a function to find a device from a serial, and let the caller connect to the device found (if any). This will allow to list all devices first, then select one device to connect to. PR #2974 <https://github.com/Genymobile/scrcpy/pull/2974>
This commit is contained in:
@@ -431,7 +431,17 @@ scrcpy(struct scrcpy_options *options) {
|
||||
goto aoa_hid_end;
|
||||
}
|
||||
|
||||
ok = sc_usb_connect(&s->usb, serial);
|
||||
assert(serial);
|
||||
libusb_device *device = sc_usb_find_device(&s->usb, serial);
|
||||
if (!device) {
|
||||
LOGE("Could not find USB device %s", serial);
|
||||
sc_usb_destroy(&s->usb);
|
||||
sc_acksync_destroy(&s->acksync);
|
||||
goto aoa_hid_end;
|
||||
}
|
||||
|
||||
ok = sc_usb_connect(&s->usb, device);
|
||||
libusb_unref_device(device);
|
||||
if (!ok) {
|
||||
LOGE("Failed to connect to USB device %s", serial);
|
||||
sc_usb_destroy(&s->usb);
|
||||
|
||||
Reference in New Issue
Block a user