From a98b74df3d06a5c3eafa4a9abfd59d7fd03d0d31 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 29 May 2020 23:10:41 +0200 Subject: [PATCH] Add Meta+x shortcut for CUT Add a scrcpy shortcut to send the CUT keycode. --- README.md | 1 + app/scrcpy.1 | 4 ++++ app/src/cli.c | 3 +++ app/src/input_manager.c | 13 +++++++++++++ 4 files changed, 21 insertions(+) diff --git a/README.md b/README.md index 8709fb1a02..63d9b93aca 100644 --- a/README.md +++ b/README.md @@ -583,6 +583,7 @@ _`Meta` is typically the `Windows` key on the keyboard, or `Cmd` on macOS._ | Expand notification panel | `Meta`+`n` | Collapse notification panel | `Meta`+`Shift`+`n` | Press COPY³, then Copy device clipboard to computer | `Meta`+`c` + | Press CUT³ | `Meta`+`x` | Paste computer clipboard to device | `Meta`+`v` | Copy computer clipboard to device, then press PASTE³ | `Meta`+`Shift`+`v` | Enable/disable FPS counter (on stdout) | `Meta`+`i` diff --git a/app/scrcpy.1 b/app/scrcpy.1 index 592967d34e..6d1893a17e 100644 --- a/app/scrcpy.1 +++ b/app/scrcpy.1 @@ -279,6 +279,10 @@ Collapse notification panel .B Meta+c Press COPY (Android >= 7), then copy device clipboard to computer +.TP +.B Meta+x +Press CUT (Android >= 7) + .TP .B Meta+v Paste computer clipboard to device diff --git a/app/src/cli.c b/app/src/cli.c index ee832ed360..1c2f93e877 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -248,6 +248,9 @@ scrcpy_print_usage(const char *arg0) { " Press COPY (Android >= 7), then copy device clipboard to\n" " computer\n" "\n" + " " MOD "+x\n" + " Press CUT (Android >= 7)\n" + "\n" " " MOD "+v\n" " Paste computer clipboard to device\n" "\n" diff --git a/app/src/input_manager.c b/app/src/input_manager.c index c43fe6872e..4d55f0f1d3 100644 --- a/app/src/input_manager.c +++ b/app/src/input_manager.c @@ -70,6 +70,11 @@ action_menu(struct controller *controller, int actions) { send_keycode(controller, AKEYCODE_MENU, actions, "MENU"); } +static inline void +action_cut(struct controller *controller, int actions) { + send_keycode(controller, AKEYCODE_CUT, actions, "CUT"); +} + // turn the screen on if it was off, press BACK otherwise static void press_back_or_turn_screen_on(struct controller *controller) { @@ -346,6 +351,14 @@ input_manager_process_key(struct input_manager *im, request_device_clipboard(controller, true); } return; + case SDLK_x: + if (control && !shift && !repeat && down) { + // For convenience (especially on macOS), bind Meta+x to + // CUT (even if it is already accessible by pressing Ctrl+x + // on the device) + action_cut(controller, action); + } + return; case SDLK_v: if (control && !repeat && down) { if (shift) {