mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-20 19:45:00 +00:00
Turn on device screen when scrcpy window becomes active.
This commit is contained in:
parent
0be766e71a
commit
ea63e7c279
3 changed files with 22 additions and 1 deletions
|
@ -21,6 +21,9 @@ scrcpy_print_usage(const char *arg0) {
|
|||
" --always-on-top\n"
|
||||
" Make scrcpy window always on top (above other windows).\n"
|
||||
"\n"
|
||||
" --auto-turn-on\n"
|
||||
" Turn on device screen when scrcpy window become active.\n"
|
||||
"\n"
|
||||
" -b, --bit-rate value\n"
|
||||
" Encode the video at the given bit-rate, expressed in bits/s.\n"
|
||||
" Unit suffixes are supported: 'K' (x1000) and 'M' (x1000000).\n"
|
||||
|
@ -651,11 +654,13 @@ guess_record_format(const char *filename) {
|
|||
#define OPT_DISABLE_SCREENSAVER 1020
|
||||
#define OPT_SHORTCUT_MOD 1021
|
||||
#define OPT_NO_KEY_REPEAT 1022
|
||||
#define OPT_AUTO_TURN_ON 1023
|
||||
|
||||
bool
|
||||
scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
||||
static const struct option long_options[] = {
|
||||
{"always-on-top", no_argument, NULL, OPT_ALWAYS_ON_TOP},
|
||||
{"auto-turn-on", no_argument, NULL, OPT_AUTO_TURN_ON},
|
||||
{"bit-rate", required_argument, NULL, 'b'},
|
||||
{"codec-options", required_argument, NULL, OPT_CODEC_OPTIONS},
|
||||
{"crop", required_argument, NULL, OPT_CROP},
|
||||
|
@ -856,6 +861,9 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
|||
return false;
|
||||
}
|
||||
break;
|
||||
case OPT_AUTO_TURN_ON:
|
||||
opts->auto_turn_on = true;
|
||||
break;
|
||||
default:
|
||||
// getopt prints the error message on stderr
|
||||
return false;
|
||||
|
|
|
@ -191,6 +191,17 @@ handle_event(SDL_Event *event, const struct scrcpy_options *options) {
|
|||
case SDL_WINDOWEVENT:
|
||||
screen_handle_window_event(&screen, &event->window);
|
||||
break;
|
||||
case SDL_ACTIVEEVENT:
|
||||
if (options->auto_turn_on && event->gain == 1) {
|
||||
struct control_msg msg;
|
||||
msg.type = CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE;
|
||||
msg.set_screen_power_mode.mode = SCREEN_POWER_MODE_NORMAL;
|
||||
|
||||
if (!controller_push_msg(&controller, &msg)) {
|
||||
LOGW("Could not request 'set screen power mode'");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_TEXTINPUT:
|
||||
if (!options->control) {
|
||||
break;
|
||||
|
@ -422,7 +433,7 @@ scrcpy(const struct scrcpy_options *options) {
|
|||
options->window_y, options->window_width,
|
||||
options->window_height,
|
||||
options->window_borderless,
|
||||
options->rotation, options-> mipmaps)) {
|
||||
options->rotation, options->mipmaps)) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ struct scrcpy_options {
|
|||
bool force_adb_forward;
|
||||
bool disable_screensaver;
|
||||
bool forward_key_repeat;
|
||||
bool auto_turn_on;
|
||||
};
|
||||
|
||||
#define SCRCPY_OPTIONS_DEFAULT { \
|
||||
|
@ -123,6 +124,7 @@ struct scrcpy_options {
|
|||
.force_adb_forward = false, \
|
||||
.disable_screensaver = false, \
|
||||
.forward_key_repeat = true, \
|
||||
.auto_turn_on = false, \
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
Loading…
Add table
Reference in a new issue