From 5af9d0ee0faddfca689f468c7d463c86233e8d93 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 19 Apr 2021 18:40:48 +0200 Subject: [PATCH] Make --lock-video-orientation argument optional If the option is set without argument, lock the initial device orientation (as if the value "initial" was passed). --- README.md | 2 +- app/scrcpy.1 | 4 +++- app/src/cli.c | 8 +++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 037c5828..f162fb3d 100644 --- a/README.md +++ b/README.md @@ -198,7 +198,7 @@ If `--max-size` is also specified, resizing is applied after cropping. To lock the orientation of the mirroring: ```bash -scrcpy --lock-video-orientation initial # initial (current) orientation +scrcpy --lock-video-orientation # initial (current) orientation scrcpy --lock-video-orientation 0 # natural orientation scrcpy --lock-video-orientation 1 # 90° counterclockwise scrcpy --lock-video-orientation 2 # 180° diff --git a/app/scrcpy.1 b/app/scrcpy.1 index 89b7ee75..51c618a8 100644 --- a/app/scrcpy.1 +++ b/app/scrcpy.1 @@ -83,11 +83,13 @@ Inject computer clipboard text as a sequence of key events on Ctrl+v (like MOD+S This is a workaround for some devices not behaving as expected when setting the device clipboard programmatically. .TP -.BI "\-\-lock\-video\-orientation " value +.BI "\-\-lock\-video\-orientation " [value] Lock video orientation to \fIvalue\fR. Possible values are "unlocked", "initial" (locked to the initial orientation), 0, 1, 2 and 3. Natural device orientation is 0, and each increment adds a 90 degrees otation counterclockwise. Default is "unlocked". +Passing the option without argument is equivalent to passing "initial". + .TP .BI "\-\-max\-fps " value Limit the framerate of screen capture (officially supported since Android 10, but may work on earlier versions). diff --git a/app/src/cli.c b/app/src/cli.c index 05e178e0..6d5fd6b8 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -79,13 +79,15 @@ scrcpy_print_usage(const char *arg0) { " This is a workaround for some devices not behaving as\n" " expected when setting the device clipboard programmatically.\n" "\n" - " --lock-video-orientation value\n" + " --lock-video-orientation [value]\n" " Lock video orientation to value.\n" " Possible values are \"unlocked\", \"initial\" (locked to the\n" " initial orientation), 0, 1, 2 and 3.\n" " Natural device orientation is 0, and each increment adds a\n" " 90 degrees rotation counterclockwise.\n" " Default is \"unlocked\".\n" + " Passing the option without argument is equivalent to passing\n" + " \"initial\".\n" "\n" " --max-fps value\n" " Limit the frame rate of screen capture (officially supported\n" @@ -386,7 +388,7 @@ parse_max_fps(const char *s, uint16_t *max_fps) { static bool parse_lock_video_orientation(const char *s, enum sc_lock_video_orientation *lock_mode) { - if (!strcmp(s, "initial")) { + if (!s || !strcmp(s, "initial")) { // Without argument, lock the initial orientation *lock_mode = SC_LOCK_VIDEO_ORIENTATION_INITIAL; return true; @@ -693,7 +695,7 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) { {"fullscreen", no_argument, NULL, 'f'}, {"help", no_argument, NULL, 'h'}, {"legacy-paste", no_argument, NULL, OPT_LEGACY_PASTE}, - {"lock-video-orientation", required_argument, NULL, + {"lock-video-orientation", optional_argument, NULL, OPT_LOCK_VIDEO_ORIENTATION}, {"max-fps", required_argument, NULL, OPT_MAX_FPS}, {"max-size", required_argument, NULL, 'm'},