Skip to content

Commit

Permalink
Add Meta+x shortcut for CUT
Browse files Browse the repository at this point in the history
Add a scrcpy shortcut to send the CUT keycode.
  • Loading branch information
rom1v committed May 29, 2020
1 parent 567c5a7 commit a98b74d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
4 changes: 4 additions & 0 deletions app/scrcpy.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions app/src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 13 additions & 0 deletions app/src/input_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a98b74d

Please sign in to comment.