mirror of
https://github.com/Genymobile/scrcpy
synced 2025-09-02 07:15:30 +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:
@@ -118,6 +118,12 @@ static const struct sc_option options[] = {
|
||||
"(typically, portrait for a phone, landscape for a tablet). "
|
||||
"Any --max-size value is cmoputed on the cropped size.",
|
||||
},
|
||||
{
|
||||
.shortopt = 'd',
|
||||
.longopt = "select-usb",
|
||||
.text = "Use USB device (if there is exactly one, like adb -d).\n"
|
||||
"Also see -e (--select-tcpip).",
|
||||
},
|
||||
{
|
||||
.longopt_id = OPT_DISABLE_SCREENSAVER,
|
||||
.longopt = "disable-screensaver",
|
||||
@@ -141,6 +147,12 @@ static const struct sc_option options[] = {
|
||||
"This increases latency to compensate for jitter.\n"
|
||||
"Default is 0 (no buffering).",
|
||||
},
|
||||
{
|
||||
.shortopt = 'e',
|
||||
.longopt = "select-tcpip",
|
||||
.text = "Use TCP/IP device (if there is exactly one, like adb -e).\n"
|
||||
"Also see -d (--select-usb).",
|
||||
},
|
||||
{
|
||||
.longopt_id = OPT_ENCODER_NAME,
|
||||
.longopt = "encoder",
|
||||
@@ -1320,6 +1332,12 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
opts->select_usb = true;
|
||||
break;
|
||||
case 'e':
|
||||
opts->select_tcpip = true;
|
||||
break;
|
||||
case 'f':
|
||||
opts->fullscreen = true;
|
||||
break;
|
||||
@@ -1559,8 +1577,16 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
||||
// If a TCP/IP address is provided, then tcpip must be enabled
|
||||
assert(opts->tcpip || !opts->tcpip_dst);
|
||||
|
||||
if (opts->serial && opts->tcpip_dst) {
|
||||
LOGE("Incompatible options: -s/--serial and --tcpip with an argument");
|
||||
unsigned selectors = !!opts->serial
|
||||
+ !!opts->tcpip_dst
|
||||
+ opts->select_tcpip
|
||||
+ opts->select_usb;
|
||||
if (selectors > 1) {
|
||||
LOGE("At most one device selector option may be passed, among:\n"
|
||||
" --serial (-s)\n"
|
||||
" --select-usb (-d)\n"
|
||||
" --select-tcpip (-e)\n"
|
||||
" --tcpip=<addr> (with an argument)");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user