Skip to content

Commit

Permalink
Add shortcuts for COPY and CUT
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rom1v committed Aug 1, 2020
1 parent 8f64a59 commit 56a115b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions app/scrcpy.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions app/src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 20 additions & 0 deletions app/src/input_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 56a115b

Please sign in to comment.