feat: boss key

pull/4830/head
hax0r31337 2 months ago
parent 7011dd1ef0
commit cca54f9786
No known key found for this signature in database
GPG Key ID: 49F83061C5DF13D6

@ -669,6 +669,10 @@ Open keyboard settings on the device (for HID keyboard only)
.B MOD+i
Enable/disable FPS counter (print frames/second in logs)
.TP
.B MOD+d
Hides the window (press enter in console to recover)
.TP
.B Ctrl+click-and-move
Pinch-to-zoom and rotate from the center of the screen

@ -921,7 +921,8 @@ static const struct sc_shortcut shortcuts[] = {
.text = "Click on HOME",
},
{
.shortcuts = {
.shortcuts =
{
"MOD+b",
"MOD+Backspace",
"Right-click (when screen is on)",
@ -997,6 +998,10 @@ static const struct sc_shortcut shortcuts[] = {
.shortcuts = {"MOD+i"},
.text = "Enable/disable FPS counter (print frames/second in logs)",
},
{
.shortcuts = {"MOD+d"},
.text = "Hides the window (press enter in console to recover)",
},
{
.shortcuts = {"Ctrl+click-and-move"},
.text = "Pinch-to-zoom and rotate from the center of the screen",

@ -2,10 +2,12 @@
#include <assert.h>
#include <SDL2/SDL_keycode.h>
#include <stdio.h>
#include "input_events.h"
#include "screen.h"
#include "util/log.h"
#include "util/thread.h"
#define SC_SDL_SHORTCUT_MODS_MASK (KMOD_CTRL | KMOD_ALT | KMOD_GUI)
@ -397,6 +399,18 @@ inverse_point(struct sc_point point, struct sc_size size,
return point;
}
static int
run_window_restore(void *data) {
struct sc_screen *screen = data;
getchar();
sc_screen_show_window(screen);
printf("Window resumed\n");
return 0;
}
static void
sc_input_manager_process_key(struct sc_input_manager *im,
const SDL_KeyboardEvent *event) {
@ -575,6 +589,21 @@ sc_input_manager_process_key(struct sc_input_manager *im,
open_hard_keyboard_settings(im);
}
return;
case SDLK_d:
if (!shift && !repeat && down && !im->screen->hidden) {
sc_screen_hide_window(im->screen);
printf("Window hidden, press [Enter] to restore...\n");
sc_thread thread;
bool ok = sc_thread_create(&thread, run_window_restore, "scrcpy-hidden-screen", im->screen);
if (!ok) {
LOGE("Could not start window restore thread");
sc_screen_show_window(im->screen);
return;
}
}
return;
}
return;

@ -361,6 +361,7 @@ sc_screen_init(struct sc_screen *screen,
screen->fullscreen = false;
screen->maximized = false;
screen->minimized = false;
screen->hidden = false;
screen->mouse_capture_key_pressed = 0;
screen->paused = false;
screen->resume_frame = NULL;
@ -496,9 +497,24 @@ sc_screen_show_initial_window(struct sc_screen *screen) {
void
sc_screen_hide_window(struct sc_screen *screen) {
if (screen->hidden) {
return;
}
screen->hidden = true;
SDL_HideWindow(screen->window);
}
void
sc_screen_show_window(struct sc_screen *screen) {
if (!screen->hidden) {
return;
}
screen->hidden = false;
SDL_ShowWindow(screen->window);
}
void
sc_screen_interrupt(struct sc_screen *screen) {
sc_fps_counter_interrupt(&screen->fps_counter);

@ -58,6 +58,7 @@ struct sc_screen {
bool fullscreen;
bool maximized;
bool minimized;
bool hidden;
// To enable/disable mouse capture, a mouse capture key (LALT, LGUI or
// RGUI) must be pressed. This variable tracks the pressed capture key.
@ -118,9 +119,14 @@ sc_screen_destroy(struct sc_screen *screen);
//
// It is used to hide the window immediately on closing without waiting for
// screen_destroy()
// It is also used for hide the window temporarly as a feature
void
sc_screen_hide_window(struct sc_screen *screen);
// show the window
void
sc_screen_show_window(struct sc_screen *screen);
// switch the fullscreen mode
void
sc_screen_switch_fullscreen(struct sc_screen *screen);

@ -52,6 +52,7 @@ _<kbd>[Super]</kbd> is typically the <kbd>Windows</kbd> or <kbd>Cmd</kbd> key._
| Inject computer clipboard text | <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>v</kbd>
| Open keyboard settings (HID keyboard only) | <kbd>MOD</kbd>+<kbd>k</kbd>
| Enable/disable FPS counter (on stdout) | <kbd>MOD</kbd>+<kbd>i</kbd>
| Hides the window | <kbd>MOD</kbd>+<kbd>d</kbd>
| Pinch-to-zoom/rotate | <kbd>Ctrl</kbd>+_click-and-move_
| Tilt (slide vertically with 2 fingers) | <kbd>Shift</kbd>+_click-and-move_
| Drag & drop APK file | Install APK from computer

Loading…
Cancel
Save