From 56a115b5c5971b7035609d5e0e3eabf97e91f874 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 17 Jul 2020 00:00:42 +0200 Subject: [PATCH] Add shortcuts for COPY and CUT Send COPY and CUT on MOD+c and MOD+x (only supported for Android >= 7). The shortcuts Ctrl+c and Ctrl+x should generally also work (even before Android 7), but the active Android app may use them for other actions instead. --- README.md | 5 ++++- app/scrcpy.1 | 8 ++++++++ app/src/cli.c | 6 ++++++ app/src/input_manager.c | 20 ++++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5bfd32d427..96d3926b1a 100644 --- a/README.md +++ b/README.md @@ -608,12 +608,15 @@ _[Super] is typically the "Windows" or "Cmd" key._ | Rotate device screen | `MOD`+`r` | Expand notification panel | `MOD`+`n` | Collapse notification panel | `MOD`+`Shift`+`n` + | Copy to clipboard³ | `MOD`+`c` + | Cut to clipboard³ | `MOD`+`x` | Paste computer clipboard to device | `MOD`+`v` | Copy computer clipboard to device and paste | `MOD`+`Shift`+`v` | Enable/disable FPS counter (on stdout) | `MOD`+`i` _¹Double-click on black borders to remove them._ -_²Right-click turns the screen on if it was off, presses BACK otherwise._ +_²Right-click turns the screen on if it was off, presses BACK otherwise._ +_³Only on Android >= 7._ ## Custom paths diff --git a/app/scrcpy.1 b/app/scrcpy.1 index ee32c8fbe0..9193171e48 100644 --- a/app/scrcpy.1 +++ b/app/scrcpy.1 @@ -292,6 +292,14 @@ Expand notification panel .B MOD+Shift+n Collapse notification panel +.TP +.B Mod+c +Copy to clipboard (inject COPY keycode, Android >= 7 only) + +.TP +.B Mod+x +Cut to clipboard (inject CUT keycode, Android >= 7 only) + .TP .B MOD+v Paste computer clipboard to device diff --git a/app/src/cli.c b/app/src/cli.c index 0662a552e8..ff810aedd1 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -260,6 +260,12 @@ scrcpy_print_usage(const char *arg0) { " MOD+Shift+n\n" " Collapse notification panel\n" "\n" + " MOD+c\n" + " Copy to clipboard (inject COPY keycode, Android >= 7 only)\n" + "\n" + " MOD+x\n" + " Cut to clipboard (inject CUT keycode, Android >= 7 only)\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 580f1a6799..75808f7562 100644 --- a/app/src/input_manager.c +++ b/app/src/input_manager.c @@ -129,6 +129,16 @@ action_menu(struct controller *controller, int actions) { send_keycode(controller, AKEYCODE_MENU, actions, "MENU"); } +static inline void +action_copy(struct controller *controller, int actions) { + send_keycode(controller, AKEYCODE_COPY, actions, "COPY"); +} + +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) { @@ -382,6 +392,16 @@ input_manager_process_key(struct input_manager *im, rotate_client_right(im->screen); } return; + case SDLK_c: + if (control && !shift && !repeat) { + action_copy(controller, action); + } + return; + case SDLK_x: + if (control && !shift && !repeat) { + action_cut(controller, action); + } + return; case SDLK_v: if (control && !repeat && down) { if (shift) {