Add Meta+x shortcut for CUT

Add a scrcpy shortcut to send the CUT keycode.
This commit is contained in:
Romain Vimont 2020-05-29 23:10:41 +02:00
parent 567c5a7da7
commit a98b74df3d
4 changed files with 21 additions and 0 deletions

View File

@ -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`

View File

@ -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

View File

@ -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"

View File

@ -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) {