Display and control your Android device
Add shortcut for horizontal tilt
Romain Vimont7a9ea5c66fed
diff --git a/app/scrcpy.1 b/app/scrcpy.1index a256c40e..3fd3eb29 100644--- a/app/scrcpy.1+++ b/app/scrcpy.1@@ -727,7 +727,11 @@ Pinch-to-zoom and rotate from the center of the screen.TP.B Shift+click-and-move-Tilt (slide vertically with two fingers)+Tilt vertically (slide with 2 fingers)++.TP+.B Ctrl+Shift+click-and-move+Tilt horizontally (slide with 2 fingers).TP.B Drag & drop APK filediff --git a/app/src/cli.c b/app/src/cli.cindex 3c1f9a1b..4fc3c534 100644--- a/app/src/cli.c+++ b/app/src/cli.c@@ -1072,7 +1072,11 @@ static const struct sc_shortcut shortcuts[] = {},{.shortcuts = { "Shift+click-and-move" },- .text = "Tilt (slide vertically with two fingers)",+ .text = "Tilt vertically (slide with 2 fingers)",+ },+ {+ .shortcuts = { "Ctrl+Shift+click-and-move" },+ .text = "Tilt horizontally (slide with 2 fingers)",},{.shortcuts = { "Drag & drop APK file" },diff --git a/app/src/input_manager.c b/app/src/input_manager.cindex b1d7e9b9..444a5f16 100644--- a/app/src/input_manager.c+++ b/app/src/input_manager.c@@ -836,7 +836,7 @@ sc_input_manager_process_mouse_button(struct sc_input_manager *im,}bool change_vfinger = event->button == SDL_BUTTON_LEFT &&- ((down && !im->vfinger_down && (ctrl_pressed ^ shift_pressed)) ||+ ((down && !im->vfinger_down && (ctrl_pressed || shift_pressed)) ||(!down && im->vfinger_down));bool use_finger = im->vfinger_down || change_vfinger;@@ -868,16 +868,28 @@ sc_input_manager_process_mouse_button(struct sc_input_manager *im,// In other words, the center of the rotation/scaling is the center of the// screen.//- // To simulate a tilt gesture (a vertical slide with two fingers), Shift- // can be used instead of Ctrl. The "virtual finger" has a position+ // To simulate a vertical tilt gesture (a vertical slide with two fingers),+ // Shift can be used instead of Ctrl. The "virtual finger" has a position// inverted with respect to the vertical axis of symmetry in the middle of// the screen.+ //+ // To simulate a horizontal tilt gesture (a horizontal slide with two+ // fingers), Ctrl+Shift can be used. The "virtual finger" has a position+ // inverted with respect to the horizontal axis of symmetry in the middle+ // of the screen. It is expected to be less frequently used, that's why the+ // one-mod shortcuts are assigned to rotation and vertical tilt.if (change_vfinger) {struct sc_point mouse =sc_screen_convert_window_to_frame_coords(im->screen, event->x,event->y);if (down) {- im->vfinger_invert_x = ctrl_pressed || shift_pressed;+ // Ctrl Shift invert_x invert_y+ // ---- ----- ==> -------- --------+ // 0 0 0 0 -+ // 0 1 1 0 vertical tilt+ // 1 0 1 1 rotate+ // 1 1 0 1 horizontal tilt+ im->vfinger_invert_x = ctrl_pressed ^ shift_pressed;im->vfinger_invert_y = ctrl_pressed;}struct sc_point vfinger = inverse_point(mouse, im->screen->frame_size,diff --git a/doc/control.md b/doc/control.mdindex 34eb7a6a..26805346 100644--- a/doc/control.md+++ b/doc/control.md@@ -94,14 +94,18 @@ the content (if supported by the app) relative to the center of the screen.https://github.com/Genymobile/scrcpy/assets/543275/26c4a920-9805-43f1-8d4c-608752d04767-To simulate a tilt gesture: <kbd>Shift</kbd>+_click-and-move-up-or-down_.+To simulate a vertical tilt gesture: <kbd>Shift</kbd>+_click-and-move-up-or-down_.https://github.com/Genymobile/scrcpy/assets/543275/1e252341-4a90-4b29-9d11-9153b324669f+Similarly, to simulate a horizontal tilt gesture:+<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+_click-and-move-left-or-right_.+Technically, _scrcpy_ generates additional touch events from a "virtual finger"at a location inverted through the center of the screen. When pressing<kbd>Ctrl</kbd> the _x_ and _y_ coordinates are inverted. Using <kbd>Shift</kbd>-only inverts _x_.+only inverts _x_, whereas using <kbd>Ctrl</kbd>+<kbd>Shift</kbd> only inverts+_y_.This only works for the default mouse mode (`--mouse=sdk`).diff --git a/doc/shortcuts.md b/doc/shortcuts.mdindex 841ceaa6..4ea37257 100644--- a/doc/shortcuts.md+++ b/doc/shortcuts.md@@ -53,7 +53,8 @@ _<kbd>[Super]</kbd> is typically the <kbd>Windows</kbd> or <kbd>Cmd</kbd> key._| Open keyboard settings (HID keyboard only) | <kbd>MOD</kbd>+<kbd>k</kbd>| Enable/disable FPS counter (on stdout) | <kbd>MOD</kbd>+<kbd>i</kbd>| Pinch-to-zoom/rotate | <kbd>Ctrl</kbd>+_click-and-move_- | Tilt (slide vertically with 2 fingers) | <kbd>Shift</kbd>+_click-and-move_+ | Tilt vertically (slide with 2 fingers) | <kbd>Shift</kbd>+_click-and-move_+ | Tilt horizontally (slide with 2 fingers) | <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+_click-and-move_| Drag & drop APK file | Install APK from computer| Drag & drop non-APK file | [Push file to device](control.md#push-file-to-device)