diff --git a/README.md b/README.md index 08e47344..f1f94d5b 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,12 @@ To show physical touches while scrcpy is running: scrcpy -t ``` +The app may be started directly in fullscreen: + +``` +scrcpy -f +``` + To run without installing: ```bash diff --git a/app/src/main.c b/app/src/main.c index 1317da79..634c7bb4 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -11,6 +11,7 @@ struct args { const char *serial; const char *crop; + SDL_bool fullscreen; SDL_bool help; SDL_bool version; SDL_bool show_touches; @@ -36,6 +37,9 @@ static void usage(const char *arg0) { " (typically, portrait for a phone, landscape for a tablet).\n" " Any --max-size value is computed on the cropped size.\n" "\n" + " -f, --fullscreen\n" + " Start in fullscreen.\n" + "\n" " -h, --help\n" " Print this help.\n" "\n" @@ -200,6 +204,7 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) { static const struct option long_options[] = { {"bit-rate", required_argument, NULL, 'b'}, {"crop", required_argument, NULL, 'c'}, + {"fullscreen", no_argument, NULL, 'f'}, {"help", no_argument, NULL, 'h'}, {"max-size", required_argument, NULL, 'm'}, {"port", required_argument, NULL, 'p'}, @@ -209,7 +214,7 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) { {NULL, 0, NULL, 0 }, }; int c; - while ((c = getopt_long(argc, argv, "b:c:hm:p:s:tv", long_options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "b:c:fhm:p:s:tv", long_options, NULL)) != -1) { switch (c) { case 'b': if (!parse_bit_rate(optarg, &args->bit_rate)) { @@ -219,6 +224,9 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) { case 'c': args->crop = optarg; break; + case 'f': + args->fullscreen = SDL_TRUE; + break; case 'h': args->help = SDL_TRUE; break; @@ -305,6 +313,7 @@ int main(int argc, char *argv[]) { .max_size = args.max_size, .bit_rate = args.bit_rate, .show_touches = args.show_touches, + .fullscreen = args.fullscreen, }; int res = scrcpy(&options) ? 0 : 1; diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 3eaa45c0..54a7f993 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -223,6 +223,10 @@ SDL_bool scrcpy(const struct scrcpy_options *options) { show_touches_waited = SDL_TRUE; } + if (options->fullscreen) { + screen_switch_fullscreen(&screen); + } + ret = event_loop(); LOGD("quit..."); diff --git a/app/src/scrcpy.h b/app/src/scrcpy.h index 7ddabf28..f64d4c02 100644 --- a/app/src/scrcpy.h +++ b/app/src/scrcpy.h @@ -10,6 +10,7 @@ struct scrcpy_options { Uint16 max_size; Uint32 bit_rate; SDL_bool show_touches; + SDL_bool fullscreen; }; SDL_bool scrcpy(const struct scrcpy_options *options);