mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-10-04 07:08:43 +00:00
Add option to select USB or TCP/IP devices
If several devices are connected (as listed by `adb devices`), it was necessary to provide the explicit serial via -s/--serial. If only one device is connected via USB (respectively, via TCP/IP), it might be convenient to select it automatically. For this purpose, two new options are introduced: - -d/--select-usb: select the single device connected over USB - -e/--select-tcpip: select the single device connected over TCP/IP PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005>
This commit is contained in:
parent
146f65d7b2
commit
582161607e
9 changed files with 79 additions and 3 deletions
|
@ -451,6 +451,10 @@ sc_adb_accept_device(const struct sc_adb_device *device,
|
|||
}
|
||||
}
|
||||
return !strcmp(selector->serial, device->serial);
|
||||
case SC_ADB_DEVICE_SELECT_USB:
|
||||
return !sc_adb_is_serial_tcpip(device->serial);
|
||||
case SC_ADB_DEVICE_SELECT_TCPIP:
|
||||
return sc_adb_is_serial_tcpip(device->serial);
|
||||
default:
|
||||
assert(!"Missing SC_ADB_DEVICE_SELECT_* handling");
|
||||
break;
|
||||
|
@ -542,6 +546,12 @@ sc_adb_select_device(struct sc_intr *intr,
|
|||
assert(selector->serial);
|
||||
LOGE("Could not find ADB device %s:", selector->serial);
|
||||
break;
|
||||
case SC_ADB_DEVICE_SELECT_USB:
|
||||
LOGE("Could not find any ADB device over USB:");
|
||||
break;
|
||||
case SC_ADB_DEVICE_SELECT_TCPIP:
|
||||
LOGE("Could not find any ADB device over TCP/IP:");
|
||||
break;
|
||||
default:
|
||||
assert(!"Unexpected selector type");
|
||||
break;
|
||||
|
@ -562,12 +572,21 @@ sc_adb_select_device(struct sc_intr *intr,
|
|||
LOGE("Multiple (%" SC_PRIsizet ") ADB devices with serial %s:",
|
||||
sel_count, selector->serial);
|
||||
break;
|
||||
case SC_ADB_DEVICE_SELECT_USB:
|
||||
LOGE("Multiple (%" SC_PRIsizet ") ADB devices over USB:",
|
||||
sel_count);
|
||||
break;
|
||||
case SC_ADB_DEVICE_SELECT_TCPIP:
|
||||
LOGE("Multiple (%" SC_PRIsizet ") ADB devices over TCP/IP:",
|
||||
sel_count);
|
||||
break;
|
||||
default:
|
||||
assert(!"Unexpected selector type");
|
||||
break;
|
||||
}
|
||||
sc_adb_devices_log(SC_LOG_LEVEL_ERROR, devices, count);
|
||||
LOGE("Select a device via -s (--serial)");
|
||||
LOGE("Select a device via -s (--serial), -d (--select-usb) or -e "
|
||||
"(--select-tcpip)");
|
||||
sc_adb_devices_destroy_all(devices, count);
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue