Display and control your Android device
Pass --lock-video-orientation argument in degrees
Romain Vimont2f926869300f
diff --git a/app/data/bash-completion/scrcpy b/app/data/bash-completion/scrcpyindex 5e359f4f..0ecace96 100644--- a/app/data/bash-completion/scrcpy+++ b/app/data/bash-completion/scrcpy@@ -118,7 +118,7 @@ _scrcpy() {return;;--lock-video-orientation)- COMPREPLY=($(compgen -W 'unlocked initial 0 1 2 3' -- "$cur"))+ COMPREPLY=($(compgen -W 'unlocked initial 0 90 180 270' -- "$cur"))return;;--pause-on-exit)diff --git a/app/data/zsh-completion/_scrcpy b/app/data/zsh-completion/_scrcpyindex 16729d2a..3f65cb4e 100644--- a/app/data/zsh-completion/_scrcpy+++ b/app/data/zsh-completion/_scrcpy@@ -41,7 +41,7 @@ arguments=('--list-cameras[List cameras available on the device]''--list-displays[List displays available on the device]''--list-encoders[List video and audio encoders available on the device]'- '--lock-video-orientation=[Lock video orientation]:orientation:(unlocked initial 0 1 2 3)'+ '--lock-video-orientation=[Lock video orientation]:orientation:(unlocked initial 0 90 180 270)'{-m,--max-size=}'[Limit both the width and height of the video to value]'{-M,--hid-mouse}'[Simulate a physical mouse by using HID over AOAv2]''--max-fps=[Limit the frame rate of screen capture]'diff --git a/app/scrcpy.1 b/app/scrcpy.1index 08a366ee..266ba1f4 100644--- a/app/scrcpy.1+++ b/app/scrcpy.1@@ -215,7 +215,9 @@ List displays available on the device..TP\fB\-\-lock\-video\-orientation\fR[=\fIvalue\fR]-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 rotation counterclockwise.+Lock capture video orientation to \fIvalue\fR.++Possible values are "unlocked", "initial" (locked to the initial orientation), 0, 90, 180, and 270. The values represent the clockwise rotation from the natural device orientation, in degrees.Default is "unlocked".diff --git a/app/src/cli.c b/app/src/cli.cindex 668de31d..37c2274c 100644--- a/app/src/cli.c+++ b/app/src/cli.c@@ -411,11 +411,11 @@ static const struct sc_option options[] = {.longopt = "lock-video-orientation",.argdesc = "value",.optional_arg = true,- .text = "Lock video orientation to value.\n"+ .text = "Lock capture video orientation to value.\n""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 "- "rotation counterclockwise.\n"+ "initial orientation), 0, 90, 180 and 270. The values "+ "represent the clockwise rotation from the natural device "+ "orientation, in degrees.\n""Default is \"unlocked\".\n""Passing the option without argument is equivalent to passing ""\"initial\".",@@ -1400,15 +1400,50 @@ parse_lock_video_orientation(const char *s,return true;}- long value;- bool ok = parse_integer_arg(s, &value, false, 0, 3,- "lock video orientation");- if (!ok) {- return false;+ if (!strcmp(s, "0")) {+ *lock_mode = SC_LOCK_VIDEO_ORIENTATION_0;+ return true;}- *lock_mode = (enum sc_lock_video_orientation) value;- return true;+ if (!strcmp(s, "90")) {+ *lock_mode = SC_LOCK_VIDEO_ORIENTATION_90;+ return true;+ }++ if (!strcmp(s, "180")) {+ *lock_mode = SC_LOCK_VIDEO_ORIENTATION_180;+ return true;+ }++ if (!strcmp(s, "270")) {+ *lock_mode = SC_LOCK_VIDEO_ORIENTATION_270;+ return true;+ }++ if (!strcmp(s, "1")) {+ LOGW("--lock-video-orientation=1 is deprecated, use "+ "--lock-video-orientation=270 instead.");+ *lock_mode = SC_LOCK_VIDEO_ORIENTATION_270;+ return true;+ }++ if (!strcmp(s, "2")) {+ LOGW("--lock-video-orientation=2 is deprecated, use "+ "--lock-video-orientation=180 instead.");+ *lock_mode = SC_LOCK_VIDEO_ORIENTATION_180;+ return true;+ }++ if (!strcmp(s, "3")) {+ LOGW("--lock-video-orientation=3 is deprecated, use "+ "--lock-video-orientation=90 instead.");+ *lock_mode = SC_LOCK_VIDEO_ORIENTATION_90;+ return true;+ }++ LOGE("Unsupported --lock-video-orientation value: %s (expected initial, "+ "unlocked, 0, 90, 180 or 270).", s);+ return false;}static booldiff --git a/app/src/options.h b/app/src/options.hindex 5a6c3276..4fb45840 100644--- a/app/src/options.h+++ b/app/src/options.h@@ -134,9 +134,9 @@ enum sc_lock_video_orientation {// lock the current orientation when scrcpy startsSC_LOCK_VIDEO_ORIENTATION_INITIAL = -2,SC_LOCK_VIDEO_ORIENTATION_0 = 0,- SC_LOCK_VIDEO_ORIENTATION_1,- SC_LOCK_VIDEO_ORIENTATION_2,- SC_LOCK_VIDEO_ORIENTATION_3,+ SC_LOCK_VIDEO_ORIENTATION_90 = 3,+ SC_LOCK_VIDEO_ORIENTATION_180 = 2,+ SC_LOCK_VIDEO_ORIENTATION_270 = 1,};enum sc_keyboard_input_mode {