Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve orientation support #4441

Merged
merged 5 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions app/data/bash-completion/scrcpy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ _scrcpy() {
--disable-screensaver
--display-buffer=
--display-id=
--display-orientation=
-e --select-tcpip
-f --fullscreen
--force-adb-forward
Expand Down Expand Up @@ -50,6 +51,7 @@ _scrcpy() {
--no-power-on
--no-video
--no-video-playback
--orientation=
--otg
-p --port=
--pause-on-exit
Expand All @@ -61,6 +63,7 @@ _scrcpy() {
-r --record=
--raw-key-events
--record-format=
--record-orientation=
--render-driver=
--require-audio
--rotation=
Expand Down Expand Up @@ -112,8 +115,17 @@ _scrcpy() {
COMPREPLY=($(compgen -W 'front back external' -- "$cur"))
return
;;
--orientation
--display-orientation)
COMPREPLY=($(compgen -> '0 90 180 270 flip0 flip90 flip180 flip270' -- "$cur"))
return
;;
--record-orientation)
COMPREPLY=($(compgen -> '0 90 180 270' -- "$cur"))
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)
Expand All @@ -132,10 +144,6 @@ _scrcpy() {
COMPREPLY=($(compgen -W 'direct3d opengl opengles2 opengles metal software' -- "$cur"))
return
;;
--rotation)
COMPREPLY=($(compgen -W '0 1 2 3' -- "$cur"))
return
;;
--shortcut-mod)
# Only auto-complete a single key
COMPREPLY=($(compgen -W 'lctrl rctrl lalt ralt lsuper rsuper' -- "$cur"))
Expand Down
6 changes: 4 additions & 2 deletions app/data/zsh-completion/_scrcpy
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ arguments=(
'--disable-screensaver[Disable screensaver while scrcpy is running]'
'--display-buffer=[Add a buffering delay \(in milliseconds\) before displaying]'
'--display-id=[Specify the display id to mirror]'
'--display-orientation=[Set the initial display orientation]:orientation values:(0 90 180 270 flip0 flip90 flip180 flip270)'
{-e,--select-tcpip}'[Use TCP/IP device]'
{-f,--fullscreen}'[Start in fullscreen]'
'--force-adb-forward[Do not attempt to use \"adb reverse\" to connect to the device]'
Expand All @@ -40,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]'
Expand All @@ -56,6 +57,7 @@ arguments=(
'--no-power-on[Do not power on the device on start]'
'--no-video[Disable video forwarding]'
'--no-video-playback[Disable video playback]'
'--orientation=[Set the video orientation]:orientation values:(0 90 180 270 flip0 flip90 flip180 flip270)'
'--otg[Run in OTG mode \(simulating physical keyboard and mouse\)]'
{-p,--port=}'[\[port\[\:port\]\] Set the TCP port \(range\) used by the client to listen]'
'--pause-on-exit=[Make scrcpy pause before exiting]:mode:(true false if-error)'
Expand All @@ -66,9 +68,9 @@ arguments=(
{-r,--record=}'[Record screen to file]:record file:_files'
'--raw-key-events[Inject key events for all input keys, and ignore text events]'
'--record-format=[Force recording format]:format:(mp4 mkv m4a mka opus aac flac wav)'
'--record-orientation=[Set the record orientation]:orientation values:(0 90 180 270)'
'--render-driver=[Request SDL to use the given render driver]:driver name:(direct3d opengl opengles2 opengles metal software)'
'--require-audio=[Make scrcpy fail if audio is enabled but does not work]'
'--rotation=[Set the initial display rotation]:rotation values:(0 1 2 3)'
{-s,--serial=}'[The device serial number \(mandatory for multiple devices only\)]:serial:($("${ADB-adb}" devices | awk '\''$2 == "device" {print $1}'\''))'
{-S,--turn-screen-off}'[Turn the device screen off immediately]'
'--shortcut-mod=[\[key1,key2+key3,...\] Specify the modifiers to use for scrcpy shortcuts]:shortcut mod:(lctrl rctrl lalt ralt lsuper rsuper)'
Expand Down
4 changes: 4 additions & 0 deletions app/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ if get_option('buildtype') == 'debug'
'tests/test_device_msg_deserialize.c',
'src/device_msg.c',
]],
['test_orientation', [
'tests/test_orientation.c',
'src/options.c',
]],
['test_strbuf', [
'tests/test_strbuf.c',
'src/util/strbuf.c',
Expand Down
36 changes: 31 additions & 5 deletions app/scrcpy.1
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ The available display ids can be listed by \fB\-\-list\-displays\fR.

Default is 0.

.TP
.BI "\-\-display\-orientation " value
Set the initial display orientation.

Possible values are 0, 90, 180, 270, flip0, flip90, flip180 and flip270. The number represents the clockwise rotation in degrees; the "flip" keyword applies a horizontal flip before the rotation.

Default is 0.

.TP
.B \-e, \-\-select\-tcpip
Use TCP/IP device (if there is exactly one, like adb -e).
Expand Down Expand Up @@ -207,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".

Expand Down Expand Up @@ -289,6 +299,10 @@ Disable video forwarding.
.B \-\-no\-video\-playback
Disable video playback on the computer.

.TP
.BI "\-\-orientation " value
Same as --display-orientation=value --record-orientation=value.

.TP
.B \-\-otg
Run in OTG mode: simulate physical keyboard and mouse, as if the computer keyboard and mouse were plugged directly to the device via an OTG cable.
Expand Down Expand Up @@ -357,6 +371,14 @@ Inject key events for all input keys, and ignore text events.
.BI "\-\-record\-format " format
Force recording format (mp4, mkv, m4a, mka, opus, aac, flac or wav).

.TP
.BI "\-\-record\-orientation " value
Set the record orientation.

Possible values are 0, 90, 180 and 270. The number represents the clockwise rotation in degrees.

Default is 0.

.TP
.BI "\-\-render\-driver " name
Request SDL to use the given render driver (this is just a hint).
Expand All @@ -369,10 +391,6 @@ Supported names are currently "direct3d", "opengl", "opengles2", "opengles", "me
.B \-\-require\-audio
By default, scrcpy mirrors only the video if audio capture fails on the device. This option makes scrcpy fail if audio is enabled but does not work.

.TP
.BI "\-\-rotation " value
Set the initial display rotation. Possibles values are 0, 1, 2 and 3. Each increment adds a 90 degrees rotation counterclockwise.

.TP
.BI "\-s, \-\-serial " number
The device serial number. Mandatory only if several devices are connected to adb.
Expand Down Expand Up @@ -534,6 +552,14 @@ Rotate display left
.B MOD+Right
Rotate display right

.TP
.B MOD+Shift+Left, MOD+Shift+Right
Flip display horizontally

.TP
.B MOD+Shift+Up, MOD+Shift+Down
Flip display vertically

.TP
.B MOD+g
Resize window to 1:1 (pixel\-perfect)
Expand Down
Loading