mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-18 22:14:20 +01:00
Detect USB device disconnection
The device disconnection is detected when the video socket closes. In order to introduce an OTG mode (HID events) without mirroring (and without server), we must be able to detect USB device disconnection. This feature will only be used in OTG mode. PR #2974 <https://github.com/Genymobile/scrcpy/pull/2974>
This commit is contained in:
@@ -456,7 +456,7 @@ scrcpy(struct scrcpy_options *options) {
|
||||
usb_device->serial, usb_device->vid, usb_device->pid,
|
||||
usb_device->manufacturer, usb_device->product);
|
||||
|
||||
ok = sc_usb_connect(&s->usb, usb_device->device);
|
||||
ok = sc_usb_connect(&s->usb, usb_device->device, NULL, NULL);
|
||||
sc_usb_device_destroy(usb_device);
|
||||
if (!ok) {
|
||||
LOGE("Failed to connect to USB device %s", serial);
|
||||
@@ -650,6 +650,7 @@ end:
|
||||
sc_hid_mouse_destroy(&s->mouse_hid);
|
||||
}
|
||||
sc_aoa_stop(&s->aoa);
|
||||
sc_usb_stop(&s->usb);
|
||||
}
|
||||
if (acksync) {
|
||||
sc_acksync_destroy(acksync);
|
||||
@@ -686,6 +687,7 @@ end:
|
||||
if (aoa_hid_initialized) {
|
||||
sc_aoa_join(&s->aoa);
|
||||
sc_aoa_destroy(&s->aoa);
|
||||
sc_usb_join(&s->usb);
|
||||
sc_usb_disconnect(&s->usb);
|
||||
sc_usb_destroy(&s->usb);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user