mirror of
https://github.com/Genymobile/scrcpy.git
synced 2024-09-19 05:31:21 +02:00
Add --display-orientation
Deprecate the option --rotation and introduce a new option --display-orientation with the 8 possible orientations (0, 90, 180, 270, flip0, flip90, flip180 and flip270). New shortcuts MOD+Shift+(arrow) dynamically change the display (horizontal or vertical) flip. Fixes #1380 <https://github.com/Genymobile/scrcpy/issues/1380> Fixes #3819 <https://github.com/Genymobile/scrcpy/issues/3819> PR #4441 <https://github.com/Genymobile/scrcpy/pull/4441>
This commit is contained in:
parent
9df92ebe37
commit
bb88b60227
15 changed files with 409 additions and 80 deletions
|
@ -21,6 +21,7 @@ _scrcpy() {
|
||||||
--disable-screensaver
|
--disable-screensaver
|
||||||
--display-buffer=
|
--display-buffer=
|
||||||
--display-id=
|
--display-id=
|
||||||
|
--display-orientation=
|
||||||
-e --select-tcpip
|
-e --select-tcpip
|
||||||
-f --fullscreen
|
-f --fullscreen
|
||||||
--force-adb-forward
|
--force-adb-forward
|
||||||
|
@ -112,6 +113,10 @@ _scrcpy() {
|
||||||
COMPREPLY=($(compgen -W 'front back external' -- "$cur"))
|
COMPREPLY=($(compgen -W 'front back external' -- "$cur"))
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
|
--display-orientation)
|
||||||
|
COMPREPLY=($(compgen -> '0 90 180 270 flip0 flip90 flip180 flip270' -- "$cur"))
|
||||||
|
return
|
||||||
|
;;
|
||||||
--lock-video-orientation)
|
--lock-video-orientation)
|
||||||
COMPREPLY=($(compgen -W 'unlocked initial 0 1 2 3' -- "$cur"))
|
COMPREPLY=($(compgen -W 'unlocked initial 0 1 2 3' -- "$cur"))
|
||||||
return
|
return
|
||||||
|
@ -132,10 +137,6 @@ _scrcpy() {
|
||||||
COMPREPLY=($(compgen -W 'direct3d opengl opengles2 opengles metal software' -- "$cur"))
|
COMPREPLY=($(compgen -W 'direct3d opengl opengles2 opengles metal software' -- "$cur"))
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
--rotation)
|
|
||||||
COMPREPLY=($(compgen -W '0 1 2 3' -- "$cur"))
|
|
||||||
return
|
|
||||||
;;
|
|
||||||
--shortcut-mod)
|
--shortcut-mod)
|
||||||
# Only auto-complete a single key
|
# Only auto-complete a single key
|
||||||
COMPREPLY=($(compgen -W 'lctrl rctrl lalt ralt lsuper rsuper' -- "$cur"))
|
COMPREPLY=($(compgen -W 'lctrl rctrl lalt ralt lsuper rsuper' -- "$cur"))
|
||||||
|
|
|
@ -28,6 +28,7 @@ arguments=(
|
||||||
'--disable-screensaver[Disable screensaver while scrcpy is running]'
|
'--disable-screensaver[Disable screensaver while scrcpy is running]'
|
||||||
'--display-buffer=[Add a buffering delay \(in milliseconds\) before displaying]'
|
'--display-buffer=[Add a buffering delay \(in milliseconds\) before displaying]'
|
||||||
'--display-id=[Specify the display id to mirror]'
|
'--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]'
|
{-e,--select-tcpip}'[Use TCP/IP device]'
|
||||||
{-f,--fullscreen}'[Start in fullscreen]'
|
{-f,--fullscreen}'[Start in fullscreen]'
|
||||||
'--force-adb-forward[Do not attempt to use \"adb reverse\" to connect to the device]'
|
'--force-adb-forward[Do not attempt to use \"adb reverse\" to connect to the device]'
|
||||||
|
@ -68,7 +69,6 @@ arguments=(
|
||||||
'--record-format=[Force recording format]:format:(mp4 mkv m4a mka opus aac flac wav)'
|
'--record-format=[Force recording format]:format:(mp4 mkv m4a mka opus aac flac wav)'
|
||||||
'--render-driver=[Request SDL to use the given render driver]:driver name:(direct3d opengl opengles2 opengles metal software)'
|
'--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]'
|
'--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,--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]'
|
{-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)'
|
'--shortcut-mod=[\[key1,key2+key3,...\] Specify the modifiers to use for scrcpy shortcuts]:shortcut mod:(lctrl rctrl lalt ralt lsuper rsuper)'
|
||||||
|
|
|
@ -289,6 +289,10 @@ if get_option('buildtype') == 'debug'
|
||||||
'tests/test_device_msg_deserialize.c',
|
'tests/test_device_msg_deserialize.c',
|
||||||
'src/device_msg.c',
|
'src/device_msg.c',
|
||||||
]],
|
]],
|
||||||
|
['test_orientation', [
|
||||||
|
'tests/test_orientation.c',
|
||||||
|
'src/options.c',
|
||||||
|
]],
|
||||||
['test_strbuf', [
|
['test_strbuf', [
|
||||||
'tests/test_strbuf.c',
|
'tests/test_strbuf.c',
|
||||||
'src/util/strbuf.c',
|
'src/util/strbuf.c',
|
||||||
|
|
20
app/scrcpy.1
20
app/scrcpy.1
|
@ -141,6 +141,14 @@ The available display ids can be listed by \fB\-\-list\-displays\fR.
|
||||||
|
|
||||||
Default is 0.
|
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
|
.TP
|
||||||
.B \-e, \-\-select\-tcpip
|
.B \-e, \-\-select\-tcpip
|
||||||
Use TCP/IP device (if there is exactly one, like adb -e).
|
Use TCP/IP device (if there is exactly one, like adb -e).
|
||||||
|
@ -369,10 +377,6 @@ Supported names are currently "direct3d", "opengl", "opengles2", "opengles", "me
|
||||||
.B \-\-require\-audio
|
.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.
|
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
|
.TP
|
||||||
.BI "\-s, \-\-serial " number
|
.BI "\-s, \-\-serial " number
|
||||||
The device serial number. Mandatory only if several devices are connected to adb.
|
The device serial number. Mandatory only if several devices are connected to adb.
|
||||||
|
@ -534,6 +538,14 @@ Rotate display left
|
||||||
.B MOD+Right
|
.B MOD+Right
|
||||||
Rotate display 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
|
.TP
|
||||||
.B MOD+g
|
.B MOD+g
|
||||||
Resize window to 1:1 (pixel\-perfect)
|
Resize window to 1:1 (pixel\-perfect)
|
||||||
|
|
|
@ -90,6 +90,7 @@ enum {
|
||||||
OPT_CAMERA_AR,
|
OPT_CAMERA_AR,
|
||||||
OPT_CAMERA_FPS,
|
OPT_CAMERA_FPS,
|
||||||
OPT_CAMERA_HIGH_SPEED,
|
OPT_CAMERA_HIGH_SPEED,
|
||||||
|
OPT_DISPLAY_ORIENTATION,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sc_option {
|
struct sc_option {
|
||||||
|
@ -309,6 +310,17 @@ static const struct sc_option options[] = {
|
||||||
" scrcpy --list-displays\n"
|
" scrcpy --list-displays\n"
|
||||||
"Default is 0.",
|
"Default is 0.",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.longopt_id = OPT_DISPLAY_ORIENTATION,
|
||||||
|
.longopt = "display-orientation",
|
||||||
|
.argdesc = "value",
|
||||||
|
.text = "Set the initial display orientation.\n"
|
||||||
|
"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.\n"
|
||||||
|
"Default is 0.",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.shortopt = 'e',
|
.shortopt = 'e',
|
||||||
.longopt = "select-tcpip",
|
.longopt = "select-tcpip",
|
||||||
|
@ -615,12 +627,10 @@ static const struct sc_option options[] = {
|
||||||
"is enabled but does not work."
|
"is enabled but does not work."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// deprecated
|
||||||
.longopt_id = OPT_ROTATION,
|
.longopt_id = OPT_ROTATION,
|
||||||
.longopt = "rotation",
|
.longopt = "rotation",
|
||||||
.argdesc = "value",
|
.argdesc = "value",
|
||||||
.text = "Set the initial display rotation.\n"
|
|
||||||
"Possible values are 0, 1, 2 and 3. Each increment adds a 90 "
|
|
||||||
"degrees rotation counterclockwise.",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.shortopt = 's',
|
.shortopt = 's',
|
||||||
|
@ -824,6 +834,14 @@ static const struct sc_shortcut shortcuts[] = {
|
||||||
.shortcuts = { "MOD+Right" },
|
.shortcuts = { "MOD+Right" },
|
||||||
.text = "Rotate display right",
|
.text = "Rotate display right",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.shortcuts = { "MOD+Shift+Left", "MOD+Shift+Right" },
|
||||||
|
.text = "Flip display horizontally",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.shortcuts = { "MOD+Shift+Up", "MOD+Shift+Down" },
|
||||||
|
.text = "Flip display vertically",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.shortcuts = { "MOD+g" },
|
.shortcuts = { "MOD+g" },
|
||||||
.text = "Resize window to 1:1 (pixel-perfect)",
|
.text = "Resize window to 1:1 (pixel-perfect)",
|
||||||
|
@ -1405,6 +1423,45 @@ parse_rotation(const char *s, uint8_t *rotation) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
parse_orientation(const char *s, enum sc_orientation *orientation) {
|
||||||
|
if (!strcmp(s, "0")) {
|
||||||
|
*orientation = SC_ORIENTATION_0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!strcmp(s, "90")) {
|
||||||
|
*orientation = SC_ORIENTATION_90;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!strcmp(s, "180")) {
|
||||||
|
*orientation = SC_ORIENTATION_180;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!strcmp(s, "270")) {
|
||||||
|
*orientation = SC_ORIENTATION_270;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!strcmp(s, "flip0")) {
|
||||||
|
*orientation = SC_ORIENTATION_FLIP_0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!strcmp(s, "flip90")) {
|
||||||
|
*orientation = SC_ORIENTATION_FLIP_90;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!strcmp(s, "flip180")) {
|
||||||
|
*orientation = SC_ORIENTATION_FLIP_180;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!strcmp(s, "flip270")) {
|
||||||
|
*orientation = SC_ORIENTATION_FLIP_270;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
LOGE("Unsupported orientation: %s (expected 0, 90, 180, 270, flip0, "
|
||||||
|
"flip90, flip180 or flip270)", optarg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_window_position(const char *s, int16_t *position) {
|
parse_window_position(const char *s, int16_t *position) {
|
||||||
// special value for "auto"
|
// special value for "auto"
|
||||||
|
@ -2008,7 +2065,34 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
||||||
opts->key_inject_mode = SC_KEY_INJECT_MODE_RAW;
|
opts->key_inject_mode = SC_KEY_INJECT_MODE_RAW;
|
||||||
break;
|
break;
|
||||||
case OPT_ROTATION:
|
case OPT_ROTATION:
|
||||||
if (!parse_rotation(optarg, &opts->rotation)) {
|
LOGW("--rotation is deprecated, use --display-orientation "
|
||||||
|
"instead.");
|
||||||
|
uint8_t rotation;
|
||||||
|
if (!parse_rotation(optarg, &rotation)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
assert(rotation <= 3);
|
||||||
|
switch (rotation) {
|
||||||
|
case 0:
|
||||||
|
opts->display_orientation = SC_ORIENTATION_0;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
// rotation 1 was 90° counterclockwise, but orientation
|
||||||
|
// is expressed clockwise
|
||||||
|
opts->display_orientation = SC_ORIENTATION_270;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
opts->display_orientation = SC_ORIENTATION_180;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
// rotation 3 was 270° counterclockwise, but orientation
|
||||||
|
// is expressed clockwise
|
||||||
|
opts->display_orientation = SC_ORIENTATION_90;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OPT_DISPLAY_ORIENTATION:
|
||||||
|
if (!parse_orientation(optarg, &opts->display_orientation)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -234,7 +234,7 @@ sc_display_update_texture(struct sc_display *display, const AVFrame *frame) {
|
||||||
|
|
||||||
enum sc_display_result
|
enum sc_display_result
|
||||||
sc_display_render(struct sc_display *display, const SDL_Rect *geometry,
|
sc_display_render(struct sc_display *display, const SDL_Rect *geometry,
|
||||||
unsigned rotation) {
|
enum sc_orientation orientation) {
|
||||||
SDL_RenderClear(display->renderer);
|
SDL_RenderClear(display->renderer);
|
||||||
|
|
||||||
if (display->pending.flags) {
|
if (display->pending.flags) {
|
||||||
|
@ -247,33 +247,33 @@ sc_display_render(struct sc_display *display, const SDL_Rect *geometry,
|
||||||
SDL_Renderer *renderer = display->renderer;
|
SDL_Renderer *renderer = display->renderer;
|
||||||
SDL_Texture *texture = display->texture;
|
SDL_Texture *texture = display->texture;
|
||||||
|
|
||||||
if (rotation == 0) {
|
if (orientation == SC_ORIENTATION_0) {
|
||||||
int ret = SDL_RenderCopy(renderer, texture, NULL, geometry);
|
int ret = SDL_RenderCopy(renderer, texture, NULL, geometry);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
LOGE("Could not render texture: %s", SDL_GetError());
|
LOGE("Could not render texture: %s", SDL_GetError());
|
||||||
return SC_DISPLAY_RESULT_ERROR;
|
return SC_DISPLAY_RESULT_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// rotation in RenderCopyEx() is clockwise, while screen->rotation is
|
unsigned cw_rotation = sc_orientation_get_rotation(orientation);
|
||||||
// counterclockwise (to be consistent with --lock-video-orientation)
|
|
||||||
int cw_rotation = (4 - rotation) % 4;
|
|
||||||
double angle = 90 * cw_rotation;
|
double angle = 90 * cw_rotation;
|
||||||
|
|
||||||
const SDL_Rect *dstrect = NULL;
|
const SDL_Rect *dstrect = NULL;
|
||||||
SDL_Rect rect;
|
SDL_Rect rect;
|
||||||
if (rotation & 1) {
|
if (sc_orientation_is_swap(orientation)) {
|
||||||
rect.x = geometry->x + (geometry->w - geometry->h) / 2;
|
rect.x = geometry->x + (geometry->w - geometry->h) / 2;
|
||||||
rect.y = geometry->y + (geometry->h - geometry->w) / 2;
|
rect.y = geometry->y + (geometry->h - geometry->w) / 2;
|
||||||
rect.w = geometry->h;
|
rect.w = geometry->h;
|
||||||
rect.h = geometry->w;
|
rect.h = geometry->w;
|
||||||
dstrect = ▭
|
dstrect = ▭
|
||||||
} else {
|
} else {
|
||||||
assert(rotation == 2);
|
|
||||||
dstrect = geometry;
|
dstrect = geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_RendererFlip flip = sc_orientation_is_mirror(orientation)
|
||||||
|
? SDL_FLIP_HORIZONTAL : 0;
|
||||||
|
|
||||||
int ret = SDL_RenderCopyEx(renderer, texture, NULL, dstrect, angle,
|
int ret = SDL_RenderCopyEx(renderer, texture, NULL, dstrect, angle,
|
||||||
NULL, 0);
|
NULL, flip);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
LOGE("Could not render texture: %s", SDL_GetError());
|
LOGE("Could not render texture: %s", SDL_GetError());
|
||||||
return SC_DISPLAY_RESULT_ERROR;
|
return SC_DISPLAY_RESULT_ERROR;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "coords.h"
|
#include "coords.h"
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
|
#include "options.h"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
# define SC_DISPLAY_FORCE_OPENGL_CORE_PROFILE
|
# define SC_DISPLAY_FORCE_OPENGL_CORE_PROFILE
|
||||||
|
@ -54,6 +55,6 @@ sc_display_update_texture(struct sc_display *display, const AVFrame *frame);
|
||||||
|
|
||||||
enum sc_display_result
|
enum sc_display_result
|
||||||
sc_display_render(struct sc_display *display, const SDL_Rect *geometry,
|
sc_display_render(struct sc_display *display, const SDL_Rect *geometry,
|
||||||
unsigned rotation);
|
enum sc_orientation orientation);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -293,15 +293,11 @@ rotate_device(struct sc_controller *controller) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rotate_client_left(struct sc_screen *screen) {
|
apply_orientation_transform(struct sc_screen *screen,
|
||||||
unsigned new_rotation = (screen->rotation + 1) % 4;
|
enum sc_orientation transform) {
|
||||||
sc_screen_set_rotation(screen, new_rotation);
|
enum sc_orientation new_orientation =
|
||||||
}
|
sc_orientation_apply(screen->orientation, transform);
|
||||||
|
sc_screen_set_orientation(screen, new_orientation);
|
||||||
static void
|
|
||||||
rotate_client_right(struct sc_screen *screen) {
|
|
||||||
unsigned new_rotation = (screen->rotation + 3) % 4;
|
|
||||||
sc_screen_set_rotation(screen, new_rotation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -421,25 +417,47 @@ sc_input_manager_process_key(struct sc_input_manager *im,
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case SDLK_DOWN:
|
case SDLK_DOWN:
|
||||||
if (controller && !shift) {
|
if (shift) {
|
||||||
|
if (!repeat & down) {
|
||||||
|
apply_orientation_transform(im->screen,
|
||||||
|
SC_ORIENTATION_FLIP_180);
|
||||||
|
}
|
||||||
|
} else if (controller) {
|
||||||
// forward repeated events
|
// forward repeated events
|
||||||
action_volume_down(controller, action);
|
action_volume_down(controller, action);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case SDLK_UP:
|
case SDLK_UP:
|
||||||
if (controller && !shift) {
|
if (shift) {
|
||||||
|
if (!repeat & down) {
|
||||||
|
apply_orientation_transform(im->screen,
|
||||||
|
SC_ORIENTATION_FLIP_180);
|
||||||
|
}
|
||||||
|
} else if (controller) {
|
||||||
// forward repeated events
|
// forward repeated events
|
||||||
action_volume_up(controller, action);
|
action_volume_up(controller, action);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case SDLK_LEFT:
|
case SDLK_LEFT:
|
||||||
if (!shift && !repeat && down) {
|
if (!repeat && down) {
|
||||||
rotate_client_left(im->screen);
|
if (shift) {
|
||||||
|
apply_orientation_transform(im->screen,
|
||||||
|
SC_ORIENTATION_FLIP_0);
|
||||||
|
} else {
|
||||||
|
apply_orientation_transform(im->screen,
|
||||||
|
SC_ORIENTATION_270);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case SDLK_RIGHT:
|
case SDLK_RIGHT:
|
||||||
if (!shift && !repeat && down) {
|
if (!repeat && down) {
|
||||||
rotate_client_right(im->screen);
|
if (shift) {
|
||||||
|
apply_orientation_transform(im->screen,
|
||||||
|
SC_ORIENTATION_FLIP_0);
|
||||||
|
} else {
|
||||||
|
apply_orientation_transform(im->screen,
|
||||||
|
SC_ORIENTATION_90);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case SDLK_c:
|
case SDLK_c:
|
||||||
|
|
|
@ -39,7 +39,7 @@ const struct scrcpy_options scrcpy_options_default = {
|
||||||
.audio_bit_rate = 0,
|
.audio_bit_rate = 0,
|
||||||
.max_fps = 0,
|
.max_fps = 0,
|
||||||
.lock_video_orientation = SC_LOCK_VIDEO_ORIENTATION_UNLOCKED,
|
.lock_video_orientation = SC_LOCK_VIDEO_ORIENTATION_UNLOCKED,
|
||||||
.rotation = 0,
|
.display_orientation = SC_ORIENTATION_0,
|
||||||
.window_x = SC_WINDOW_POSITION_UNDEFINED,
|
.window_x = SC_WINDOW_POSITION_UNDEFINED,
|
||||||
.window_y = SC_WINDOW_POSITION_UNDEFINED,
|
.window_y = SC_WINDOW_POSITION_UNDEFINED,
|
||||||
.window_width = 0,
|
.window_width = 0,
|
||||||
|
@ -89,3 +89,39 @@ const struct scrcpy_options scrcpy_options_default = {
|
||||||
.camera_high_speed = false,
|
.camera_high_speed = false,
|
||||||
.list = 0,
|
.list = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum sc_orientation
|
||||||
|
sc_orientation_apply(enum sc_orientation src, enum sc_orientation transform) {
|
||||||
|
assert(!(src & ~7));
|
||||||
|
assert(!(transform & ~7));
|
||||||
|
|
||||||
|
unsigned transform_hflip = transform & 4;
|
||||||
|
unsigned transform_rotation = transform & 3;
|
||||||
|
unsigned src_hflip = src & 4;
|
||||||
|
unsigned src_rotation = src & 3;
|
||||||
|
unsigned src_swap = src & 1;
|
||||||
|
if (src_swap && transform_hflip) {
|
||||||
|
// If the src is rotated by 90 or 270 degrees, applying a flipped
|
||||||
|
// transformation requires an additional 180 degrees rotation to
|
||||||
|
// compensate for the inversion of the order of multiplication:
|
||||||
|
//
|
||||||
|
// hflip1 × rotate1 × hflip2 × rotate2
|
||||||
|
// `--------------' `--------------'
|
||||||
|
// src transform
|
||||||
|
//
|
||||||
|
// In the final result, we want all the hflips then all the rotations,
|
||||||
|
// so we must move hflip2 to the left:
|
||||||
|
//
|
||||||
|
// hflip1 × hflip2 × rotate1' × rotate2
|
||||||
|
//
|
||||||
|
// with rotate1' = | rotate1 if src is 0° or 180°
|
||||||
|
// | rotate1 + 180° if src is 90° or 270°
|
||||||
|
|
||||||
|
src_rotation += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned result_hflip = src_hflip ^ transform_hflip;
|
||||||
|
unsigned result_rotation = (transform_rotation + src_rotation) % 4;
|
||||||
|
enum sc_orientation result = result_hflip | result_rotation;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -67,6 +68,67 @@ enum sc_camera_facing {
|
||||||
SC_CAMERA_FACING_EXTERNAL,
|
SC_CAMERA_FACING_EXTERNAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ,----- hflip (applied before the rotation)
|
||||||
|
// | ,--- 180°
|
||||||
|
// | | ,- 90° clockwise
|
||||||
|
// | | |
|
||||||
|
enum sc_orientation { // v v v
|
||||||
|
SC_ORIENTATION_0, // 0 0 0
|
||||||
|
SC_ORIENTATION_90, // 0 0 1
|
||||||
|
SC_ORIENTATION_180, // 0 1 0
|
||||||
|
SC_ORIENTATION_270, // 0 1 1
|
||||||
|
SC_ORIENTATION_FLIP_0, // 1 0 0
|
||||||
|
SC_ORIENTATION_FLIP_90, // 1 0 1
|
||||||
|
SC_ORIENTATION_FLIP_180, // 1 1 0
|
||||||
|
SC_ORIENTATION_FLIP_270, // 1 1 1
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
sc_orientation_is_mirror(enum sc_orientation orientation) {
|
||||||
|
assert(!(orientation & ~7));
|
||||||
|
return orientation & 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Does the orientation swap width and height?
|
||||||
|
static inline bool
|
||||||
|
sc_orientation_is_swap(enum sc_orientation orientation) {
|
||||||
|
assert(!(orientation & ~7));
|
||||||
|
return orientation & 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline enum sc_orientation
|
||||||
|
sc_orientation_get_rotation(enum sc_orientation orientation) {
|
||||||
|
assert(!(orientation & ~7));
|
||||||
|
return orientation & 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum sc_orientation
|
||||||
|
sc_orientation_apply(enum sc_orientation src, enum sc_orientation transform);
|
||||||
|
|
||||||
|
static inline const char *
|
||||||
|
sc_orientation_get_name(enum sc_orientation orientation) {
|
||||||
|
switch (orientation) {
|
||||||
|
case SC_ORIENTATION_0:
|
||||||
|
return "0";
|
||||||
|
case SC_ORIENTATION_90:
|
||||||
|
return "90";
|
||||||
|
case SC_ORIENTATION_180:
|
||||||
|
return "180";
|
||||||
|
case SC_ORIENTATION_270:
|
||||||
|
return "270";
|
||||||
|
case SC_ORIENTATION_FLIP_0:
|
||||||
|
return "flip0";
|
||||||
|
case SC_ORIENTATION_FLIP_90:
|
||||||
|
return "flip90";
|
||||||
|
case SC_ORIENTATION_FLIP_180:
|
||||||
|
return "flip180";
|
||||||
|
case SC_ORIENTATION_FLIP_270:
|
||||||
|
return "flip270";
|
||||||
|
default:
|
||||||
|
return "(unknown)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum sc_lock_video_orientation {
|
enum sc_lock_video_orientation {
|
||||||
SC_LOCK_VIDEO_ORIENTATION_UNLOCKED = -1,
|
SC_LOCK_VIDEO_ORIENTATION_UNLOCKED = -1,
|
||||||
// lock the current orientation when scrcpy starts
|
// lock the current orientation when scrcpy starts
|
||||||
|
@ -157,7 +219,7 @@ struct scrcpy_options {
|
||||||
uint32_t audio_bit_rate;
|
uint32_t audio_bit_rate;
|
||||||
uint16_t max_fps;
|
uint16_t max_fps;
|
||||||
enum sc_lock_video_orientation lock_video_orientation;
|
enum sc_lock_video_orientation lock_video_orientation;
|
||||||
uint8_t rotation;
|
enum sc_orientation display_orientation;
|
||||||
int16_t window_x; // SC_WINDOW_POSITION_UNDEFINED for "auto"
|
int16_t window_x; // SC_WINDOW_POSITION_UNDEFINED for "auto"
|
||||||
int16_t window_y; // SC_WINDOW_POSITION_UNDEFINED for "auto"
|
int16_t window_y; // SC_WINDOW_POSITION_UNDEFINED for "auto"
|
||||||
uint16_t window_width;
|
uint16_t window_width;
|
||||||
|
|
|
@ -691,7 +691,7 @@ aoa_hid_end:
|
||||||
.window_width = options->window_width,
|
.window_width = options->window_width,
|
||||||
.window_height = options->window_height,
|
.window_height = options->window_height,
|
||||||
.window_borderless = options->window_borderless,
|
.window_borderless = options->window_borderless,
|
||||||
.rotation = options->rotation,
|
.orientation = options->display_orientation,
|
||||||
.mipmaps = options->mipmaps,
|
.mipmaps = options->mipmaps,
|
||||||
.fullscreen = options->fullscreen,
|
.fullscreen = options->fullscreen,
|
||||||
.start_fps_counter = options->start_fps_counter,
|
.start_fps_counter = options->start_fps_counter,
|
||||||
|
|
|
@ -14,16 +14,16 @@
|
||||||
#define DOWNCAST(SINK) container_of(SINK, struct sc_screen, frame_sink)
|
#define DOWNCAST(SINK) container_of(SINK, struct sc_screen, frame_sink)
|
||||||
|
|
||||||
static inline struct sc_size
|
static inline struct sc_size
|
||||||
get_rotated_size(struct sc_size size, int rotation) {
|
get_oriented_size(struct sc_size size, enum sc_orientation orientation) {
|
||||||
struct sc_size rotated_size;
|
struct sc_size oriented_size;
|
||||||
if (rotation & 1) {
|
if (sc_orientation_is_swap(orientation)) {
|
||||||
rotated_size.width = size.height;
|
oriented_size.width = size.height;
|
||||||
rotated_size.height = size.width;
|
oriented_size.height = size.width;
|
||||||
} else {
|
} else {
|
||||||
rotated_size.width = size.width;
|
oriented_size.width = size.width;
|
||||||
rotated_size.height = size.height;
|
oriented_size.height = size.height;
|
||||||
}
|
}
|
||||||
return rotated_size;
|
return oriented_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the window size in a struct sc_size
|
// get the window size in a struct sc_size
|
||||||
|
@ -251,7 +251,7 @@ sc_screen_render(struct sc_screen *screen, bool update_content_rect) {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum sc_display_result res =
|
enum sc_display_result res =
|
||||||
sc_display_render(&screen->display, &screen->rect, screen->rotation);
|
sc_display_render(&screen->display, &screen->rect, screen->orientation);
|
||||||
(void) res; // any error already logged
|
(void) res; // any error already logged
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,9 +379,10 @@ sc_screen_init(struct sc_screen *screen,
|
||||||
goto error_destroy_frame_buffer;
|
goto error_destroy_frame_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
screen->rotation = params->rotation;
|
screen->orientation = params->orientation;
|
||||||
if (screen->rotation) {
|
if (screen->orientation != SC_ORIENTATION_0) {
|
||||||
LOGI("Initial display rotation set to %u", screen->rotation);
|
LOGI("Initial display orientation set to %s",
|
||||||
|
sc_orientation_get_name(screen->orientation));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t window_flags = SDL_WINDOW_HIDDEN
|
uint32_t window_flags = SDL_WINDOW_HIDDEN
|
||||||
|
@ -559,19 +560,19 @@ apply_pending_resize(struct sc_screen *screen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sc_screen_set_rotation(struct sc_screen *screen, unsigned rotation) {
|
sc_screen_set_orientation(struct sc_screen *screen,
|
||||||
assert(rotation < 4);
|
enum sc_orientation orientation) {
|
||||||
if (rotation == screen->rotation) {
|
if (orientation == screen->orientation) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sc_size new_content_size =
|
struct sc_size new_content_size =
|
||||||
get_rotated_size(screen->frame_size, rotation);
|
get_oriented_size(screen->frame_size, orientation);
|
||||||
|
|
||||||
set_content_size(screen, new_content_size);
|
set_content_size(screen, new_content_size);
|
||||||
|
|
||||||
screen->rotation = rotation;
|
screen->orientation = orientation;
|
||||||
LOGI("Display rotation set to %u", rotation);
|
LOGI("Display orientation set to %s", sc_orientation_get_name(orientation));
|
||||||
|
|
||||||
sc_screen_render(screen, true);
|
sc_screen_render(screen, true);
|
||||||
}
|
}
|
||||||
|
@ -584,7 +585,7 @@ sc_screen_init_size(struct sc_screen *screen) {
|
||||||
// The requested size is passed via screen->frame_size
|
// The requested size is passed via screen->frame_size
|
||||||
|
|
||||||
struct sc_size content_size =
|
struct sc_size content_size =
|
||||||
get_rotated_size(screen->frame_size, screen->rotation);
|
get_oriented_size(screen->frame_size, screen->orientation);
|
||||||
screen->content_size = content_size;
|
screen->content_size = content_size;
|
||||||
|
|
||||||
enum sc_display_result res =
|
enum sc_display_result res =
|
||||||
|
@ -604,7 +605,7 @@ prepare_for_frame(struct sc_screen *screen, struct sc_size new_frame_size) {
|
||||||
screen->frame_size = new_frame_size;
|
screen->frame_size = new_frame_size;
|
||||||
|
|
||||||
struct sc_size new_content_size =
|
struct sc_size new_content_size =
|
||||||
get_rotated_size(new_frame_size, screen->rotation);
|
get_oriented_size(new_frame_size, screen->orientation);
|
||||||
set_content_size(screen, new_content_size);
|
set_content_size(screen, new_content_size);
|
||||||
|
|
||||||
sc_screen_update_content_rect(screen);
|
sc_screen_update_content_rect(screen);
|
||||||
|
@ -843,8 +844,7 @@ sc_screen_handle_event(struct sc_screen *screen, const SDL_Event *event) {
|
||||||
struct sc_point
|
struct sc_point
|
||||||
sc_screen_convert_drawable_to_frame_coords(struct sc_screen *screen,
|
sc_screen_convert_drawable_to_frame_coords(struct sc_screen *screen,
|
||||||
int32_t x, int32_t y) {
|
int32_t x, int32_t y) {
|
||||||
unsigned rotation = screen->rotation;
|
enum sc_orientation orientation = screen->orientation;
|
||||||
assert(rotation < 4);
|
|
||||||
|
|
||||||
int32_t w = screen->content_size.width;
|
int32_t w = screen->content_size.width;
|
||||||
int32_t h = screen->content_size.height;
|
int32_t h = screen->content_size.height;
|
||||||
|
@ -855,27 +855,43 @@ sc_screen_convert_drawable_to_frame_coords(struct sc_screen *screen,
|
||||||
x = (int64_t) (x - screen->rect.x) * w / screen->rect.w;
|
x = (int64_t) (x - screen->rect.x) * w / screen->rect.w;
|
||||||
y = (int64_t) (y - screen->rect.y) * h / screen->rect.h;
|
y = (int64_t) (y - screen->rect.y) * h / screen->rect.h;
|
||||||
|
|
||||||
// rotate
|
|
||||||
struct sc_point result;
|
struct sc_point result;
|
||||||
switch (rotation) {
|
switch (orientation) {
|
||||||
case 0:
|
case SC_ORIENTATION_0:
|
||||||
result.x = x;
|
result.x = x;
|
||||||
result.y = y;
|
result.y = y;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case SC_ORIENTATION_90:
|
||||||
result.x = h - y;
|
|
||||||
result.y = x;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
result.x = w - x;
|
|
||||||
result.y = h - y;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(rotation == 3);
|
|
||||||
result.x = y;
|
result.x = y;
|
||||||
result.y = w - x;
|
result.y = w - x;
|
||||||
break;
|
break;
|
||||||
|
case SC_ORIENTATION_180:
|
||||||
|
result.x = w - x;
|
||||||
|
result.y = h - y;
|
||||||
|
break;
|
||||||
|
case SC_ORIENTATION_270:
|
||||||
|
result.x = h - y;
|
||||||
|
result.y = x;
|
||||||
|
break;
|
||||||
|
case SC_ORIENTATION_FLIP_0:
|
||||||
|
result.x = w - x;
|
||||||
|
result.y = y;
|
||||||
|
break;
|
||||||
|
case SC_ORIENTATION_FLIP_90:
|
||||||
|
result.x = h - y;
|
||||||
|
result.y = w - x;
|
||||||
|
break;
|
||||||
|
case SC_ORIENTATION_FLIP_180:
|
||||||
|
result.x = x;
|
||||||
|
result.y = h - y;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(orientation == SC_ORIENTATION_FLIP_270);
|
||||||
|
result.x = y;
|
||||||
|
result.y = x;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "frame_buffer.h"
|
#include "frame_buffer.h"
|
||||||
#include "input_manager.h"
|
#include "input_manager.h"
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
|
#include "options.h"
|
||||||
#include "trait/key_processor.h"
|
#include "trait/key_processor.h"
|
||||||
#include "trait/frame_sink.h"
|
#include "trait/frame_sink.h"
|
||||||
#include "trait/mouse_processor.h"
|
#include "trait/mouse_processor.h"
|
||||||
|
@ -49,8 +50,8 @@ struct sc_screen {
|
||||||
// fullscreen (meaningful only when resize_pending is true)
|
// fullscreen (meaningful only when resize_pending is true)
|
||||||
struct sc_size windowed_content_size;
|
struct sc_size windowed_content_size;
|
||||||
|
|
||||||
// client rotation: 0, 1, 2 or 3 (x90 degrees counterclockwise)
|
// client orientation
|
||||||
unsigned rotation;
|
enum sc_orientation orientation;
|
||||||
// rectangle of the content (excluding black borders)
|
// rectangle of the content (excluding black borders)
|
||||||
struct SDL_Rect rect;
|
struct SDL_Rect rect;
|
||||||
bool has_frame;
|
bool has_frame;
|
||||||
|
@ -86,7 +87,7 @@ struct sc_screen_params {
|
||||||
|
|
||||||
bool window_borderless;
|
bool window_borderless;
|
||||||
|
|
||||||
uint8_t rotation;
|
enum sc_orientation orientation;
|
||||||
bool mipmaps;
|
bool mipmaps;
|
||||||
|
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
|
@ -129,9 +130,10 @@ sc_screen_resize_to_fit(struct sc_screen *screen);
|
||||||
void
|
void
|
||||||
sc_screen_resize_to_pixel_perfect(struct sc_screen *screen);
|
sc_screen_resize_to_pixel_perfect(struct sc_screen *screen);
|
||||||
|
|
||||||
// set the display rotation (0, 1, 2 or 3, x90 degrees counterclockwise)
|
// set the display orientation
|
||||||
void
|
void
|
||||||
sc_screen_set_rotation(struct sc_screen *screen, unsigned rotation);
|
sc_screen_set_orientation(struct sc_screen *screen,
|
||||||
|
enum sc_orientation orientation);
|
||||||
|
|
||||||
// react to SDL events
|
// react to SDL events
|
||||||
// If this function returns false, scrcpy must exit with an error.
|
// If this function returns false, scrcpy must exit with an error.
|
||||||
|
|
91
app/tests/test_orientation.c
Normal file
91
app/tests/test_orientation.c
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "options.h"
|
||||||
|
|
||||||
|
static void test_transforms(void) {
|
||||||
|
#define O(X) SC_ORIENTATION_ ## X
|
||||||
|
#define ASSERT_TRANSFORM(SRC, TR, RES) \
|
||||||
|
assert(sc_orientation_apply(O(SRC), O(TR)) == O(RES));
|
||||||
|
|
||||||
|
ASSERT_TRANSFORM(0, 0, 0);
|
||||||
|
ASSERT_TRANSFORM(0, 90, 90);
|
||||||
|
ASSERT_TRANSFORM(0, 180, 180);
|
||||||
|
ASSERT_TRANSFORM(0, 270, 270);
|
||||||
|
ASSERT_TRANSFORM(0, FLIP_0, FLIP_0);
|
||||||
|
ASSERT_TRANSFORM(0, FLIP_90, FLIP_90);
|
||||||
|
ASSERT_TRANSFORM(0, FLIP_180, FLIP_180);
|
||||||
|
ASSERT_TRANSFORM(0, FLIP_270, FLIP_270);
|
||||||
|
|
||||||
|
ASSERT_TRANSFORM(90, 0, 90);
|
||||||
|
ASSERT_TRANSFORM(90, 90, 180);
|
||||||
|
ASSERT_TRANSFORM(90, 180, 270);
|
||||||
|
ASSERT_TRANSFORM(90, 270, 0);
|
||||||
|
ASSERT_TRANSFORM(90, FLIP_0, FLIP_270);
|
||||||
|
ASSERT_TRANSFORM(90, FLIP_90, FLIP_0);
|
||||||
|
ASSERT_TRANSFORM(90, FLIP_180, FLIP_90);
|
||||||
|
ASSERT_TRANSFORM(90, FLIP_270, FLIP_180);
|
||||||
|
|
||||||
|
ASSERT_TRANSFORM(180, 0, 180);
|
||||||
|
ASSERT_TRANSFORM(180, 90, 270);
|
||||||
|
ASSERT_TRANSFORM(180, 180, 0);
|
||||||
|
ASSERT_TRANSFORM(180, 270, 90);
|
||||||
|
ASSERT_TRANSFORM(180, FLIP_0, FLIP_180);
|
||||||
|
ASSERT_TRANSFORM(180, FLIP_90, FLIP_270);
|
||||||
|
ASSERT_TRANSFORM(180, FLIP_180, FLIP_0);
|
||||||
|
ASSERT_TRANSFORM(180, FLIP_270, FLIP_90);
|
||||||
|
|
||||||
|
ASSERT_TRANSFORM(270, 0, 270);
|
||||||
|
ASSERT_TRANSFORM(270, 90, 0);
|
||||||
|
ASSERT_TRANSFORM(270, 180, 90);
|
||||||
|
ASSERT_TRANSFORM(270, 270, 180);
|
||||||
|
ASSERT_TRANSFORM(270, FLIP_0, FLIP_90);
|
||||||
|
ASSERT_TRANSFORM(270, FLIP_90, FLIP_180);
|
||||||
|
ASSERT_TRANSFORM(270, FLIP_180, FLIP_270);
|
||||||
|
ASSERT_TRANSFORM(270, FLIP_270, FLIP_0);
|
||||||
|
|
||||||
|
ASSERT_TRANSFORM(FLIP_0, 0, FLIP_0);
|
||||||
|
ASSERT_TRANSFORM(FLIP_0, 90, FLIP_90);
|
||||||
|
ASSERT_TRANSFORM(FLIP_0, 180, FLIP_180);
|
||||||
|
ASSERT_TRANSFORM(FLIP_0, 270, FLIP_270);
|
||||||
|
ASSERT_TRANSFORM(FLIP_0, FLIP_0, 0);
|
||||||
|
ASSERT_TRANSFORM(FLIP_0, FLIP_90, 90);
|
||||||
|
ASSERT_TRANSFORM(FLIP_0, FLIP_180, 180);
|
||||||
|
ASSERT_TRANSFORM(FLIP_0, FLIP_270, 270);
|
||||||
|
|
||||||
|
ASSERT_TRANSFORM(FLIP_90, 0, FLIP_90);
|
||||||
|
ASSERT_TRANSFORM(FLIP_90, 90, FLIP_180);
|
||||||
|
ASSERT_TRANSFORM(FLIP_90, 180, FLIP_270);
|
||||||
|
ASSERT_TRANSFORM(FLIP_90, 270, FLIP_0);
|
||||||
|
ASSERT_TRANSFORM(FLIP_90, FLIP_0, 270);
|
||||||
|
ASSERT_TRANSFORM(FLIP_90, FLIP_90, 0);
|
||||||
|
ASSERT_TRANSFORM(FLIP_90, FLIP_180, 90);
|
||||||
|
ASSERT_TRANSFORM(FLIP_90, FLIP_270, 180);
|
||||||
|
|
||||||
|
ASSERT_TRANSFORM(FLIP_180, 0, FLIP_180);
|
||||||
|
ASSERT_TRANSFORM(FLIP_180, 90, FLIP_270);
|
||||||
|
ASSERT_TRANSFORM(FLIP_180, 180, FLIP_0);
|
||||||
|
ASSERT_TRANSFORM(FLIP_180, 270, FLIP_90);
|
||||||
|
ASSERT_TRANSFORM(FLIP_180, FLIP_0, 180);
|
||||||
|
ASSERT_TRANSFORM(FLIP_180, FLIP_90, 270);
|
||||||
|
ASSERT_TRANSFORM(FLIP_180, FLIP_180, 0);
|
||||||
|
ASSERT_TRANSFORM(FLIP_180, FLIP_270, 90);
|
||||||
|
|
||||||
|
ASSERT_TRANSFORM(FLIP_270, 0, FLIP_270);
|
||||||
|
ASSERT_TRANSFORM(FLIP_270, 90, FLIP_0);
|
||||||
|
ASSERT_TRANSFORM(FLIP_270, 180, FLIP_90);
|
||||||
|
ASSERT_TRANSFORM(FLIP_270, 270, FLIP_180);
|
||||||
|
ASSERT_TRANSFORM(FLIP_270, FLIP_0, 90);
|
||||||
|
ASSERT_TRANSFORM(FLIP_270, FLIP_90, 180);
|
||||||
|
ASSERT_TRANSFORM(FLIP_270, FLIP_180, 270);
|
||||||
|
ASSERT_TRANSFORM(FLIP_270, FLIP_270, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
(void) argc;
|
||||||
|
(void) argv;
|
||||||
|
|
||||||
|
test_transforms();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -26,6 +26,8 @@ _<kbd>[Super]</kbd> is typically the <kbd>Windows</kbd> or <kbd>Cmd</kbd> key._
|
||||||
| Switch fullscreen mode | <kbd>MOD</kbd>+<kbd>f</kbd>
|
| Switch fullscreen mode | <kbd>MOD</kbd>+<kbd>f</kbd>
|
||||||
| Rotate display left | <kbd>MOD</kbd>+<kbd>←</kbd> _(left)_
|
| Rotate display left | <kbd>MOD</kbd>+<kbd>←</kbd> _(left)_
|
||||||
| Rotate display right | <kbd>MOD</kbd>+<kbd>→</kbd> _(right)_
|
| Rotate display right | <kbd>MOD</kbd>+<kbd>→</kbd> _(right)_
|
||||||
|
| Flip display horizontally | <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>←</kbd> _(left)_ \| <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>→</kbd> _(right)_
|
||||||
|
| Flip display vertically | <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>↑</kbd> _(up)_ \| <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>↓</kbd> _(down)_
|
||||||
| Resize window to 1:1 (pixel-perfect) | <kbd>MOD</kbd>+<kbd>g</kbd>
|
| Resize window to 1:1 (pixel-perfect) | <kbd>MOD</kbd>+<kbd>g</kbd>
|
||||||
| Resize window to remove black borders | <kbd>MOD</kbd>+<kbd>w</kbd> \| _Double-left-click¹_
|
| Resize window to remove black borders | <kbd>MOD</kbd>+<kbd>w</kbd> \| _Double-left-click¹_
|
||||||
| Click on `HOME` | <kbd>MOD</kbd>+<kbd>h</kbd> \| _Middle-click_
|
| Click on `HOME` | <kbd>MOD</kbd>+<kbd>h</kbd> \| _Middle-click_
|
||||||
|
|
Loading…
Reference in a new issue