From c87d94ee2779838cf4576f6505a918bc485620d5 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 10 Mar 2018 00:40:55 +0100 Subject: [PATCH] Map middle-click to HOME Middle-click is useless in practice. Use it for HOME. --- README.md | 30 +++++++++++++++--------------- app/src/inputmanager.c | 12 +++++++++--- app/src/main.c | 4 +++- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 9c034ae2..337f12e1 100644 --- a/README.md +++ b/README.md @@ -188,22 +188,22 @@ To run without installing: ## Shortcuts - | Action | Shortcut | - | ------------------------------------- | -------------:| - | switch fullscreen mode | `Ctrl`+`f` | - | resize window to 1:1 (pixel-perfect) | `Ctrl`+`g` | - | resize window to remove black borders | `Ctrl`+`x` | - | click on `HOME` | `Ctrl`+`h` | - | click on `BACK` | `Ctrl`+`b` | - | click on `APP_SWITCH` | `Ctrl`+`m` | - | click on `VOLUME_UP` | `Ctrl`+`+` | - | click on `VOLUME_DOWN` | `Ctrl`+`-` | - | click on `POWER` | `Ctrl`+`p` | - | turn screen on or press BACK¹ | _Right-click_ | - | paste computer clipboard to device | `Ctrl`+`v` | - | enable/disable FPS counter (on stdout) | `Ctrl`+`i` | + | Action | Shortcut | + | -------------------------------------- |:---------------------------- | + | switch fullscreen mode | `Ctrl`+`f` | + | resize window to 1:1 (pixel-perfect) | `Ctrl`+`g` | + | resize window to remove black borders | `Ctrl`+`x` | + | click on `HOME` | `Ctrl`+`h` \| _Middle-click_ | + | click on `BACK` | `Ctrl`+`b` \| _Right-click¹_ | + | click on `APP_SWITCH` | `Ctrl`+`m` | + | click on `VOLUME_UP` | `Ctrl`+`+` | + | click on `VOLUME_DOWN` | `Ctrl`+`-` | + | click on `POWER` | `Ctrl`+`p` | + | turn screen on | _Right-click¹_ | + | paste computer clipboard to device | `Ctrl`+`v` | + | enable/disable FPS counter (on stdout) | `Ctrl`+`i` | -_¹ Press BACK if the screen is already on._ +_¹Right-click turns the screen on if it was off, presses BACK otherwise._ ## Why _scrcpy_? diff --git a/app/src/inputmanager.c b/app/src/inputmanager.c index 7b10a91d..6a9243e2 100644 --- a/app/src/inputmanager.c +++ b/app/src/inputmanager.c @@ -226,9 +226,15 @@ void input_manager_process_mouse_motion(struct input_manager *input_manager, void input_manager_process_mouse_button(struct input_manager *input_manager, const SDL_MouseButtonEvent *event) { - if (event->button == SDL_BUTTON_RIGHT && event->type == SDL_MOUSEBUTTONDOWN) { - press_back_or_turn_screen_on(input_manager->controller); - return; + if (event->type == SDL_MOUSEBUTTONDOWN) { + if (event->button == SDL_BUTTON_RIGHT) { + press_back_or_turn_screen_on(input_manager->controller); + return; + } + if (event->button == SDL_BUTTON_MIDDLE) { + action_home(input_manager->controller); + return; + } }; struct control_event control_event; if (mouse_button_from_sdl_to_android(event, input_manager->screen->frame_size, &control_event)) { diff --git a/app/src/main.c b/app/src/main.c index 1f2164b6..287c9d7d 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -61,10 +61,12 @@ static void usage(const char *arg0) { "\n" " Ctrl+h\n" " Home\n" + " Middle-click\n" " click on HOME\n" "\n" " Ctrl+b\n" " Ctrl+Backspace\n" + " Right-click (when screen is on)\n" " click on BACK\n" "\n" " Ctrl+m\n" @@ -79,7 +81,7 @@ static void usage(const char *arg0) { " Ctrl+p\n" " click on POWER (turn screen on/off)\n" "\n" - " Right-click\n" + " Right-click (when screen is off)\n" " turn screen on\n" "\n" " Ctrl+v\n"