mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-20 19:45:00 +00:00
add no-repeat cli option
This commit is contained in:
parent
199c74f62f
commit
434ffbdbc1
5 changed files with 21 additions and 10 deletions
|
@ -531,6 +531,7 @@ guess_record_format(const char *filename) {
|
|||
#define OPT_CODEC_OPTIONS 1018
|
||||
#define OPT_FORCE_ADB_FORWARD 1019
|
||||
#define OPT_DISABLE_SCREENSAVER 1020
|
||||
#define OPT_NO_REPEAT 1021
|
||||
|
||||
bool
|
||||
scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
||||
|
@ -553,6 +554,7 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
|||
{"no-control", no_argument, NULL, 'n'},
|
||||
{"no-display", no_argument, NULL, 'N'},
|
||||
{"no-mipmaps", no_argument, NULL, OPT_NO_MIPMAPS},
|
||||
{"no-repeat", no_argument, NULL, OPT_NO_REPEAT},
|
||||
{"port", required_argument, NULL, 'p'},
|
||||
{"prefer-text", no_argument, NULL, OPT_PREFER_TEXT},
|
||||
{"push-target", required_argument, NULL, OPT_PUSH_TARGET},
|
||||
|
@ -573,8 +575,7 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
|||
{"window-y", required_argument, NULL, OPT_WINDOW_Y},
|
||||
{"window-width", required_argument, NULL, OPT_WINDOW_WIDTH},
|
||||
{"window-height", required_argument, NULL, OPT_WINDOW_HEIGHT},
|
||||
{"window-borderless", no_argument, NULL,
|
||||
OPT_WINDOW_BORDERLESS},
|
||||
{"window-borderless", no_argument, NULL, OPT_WINDOW_BORDERLESS},
|
||||
{NULL, 0, NULL, 0 },
|
||||
};
|
||||
|
||||
|
@ -717,6 +718,9 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
|||
case OPT_NO_MIPMAPS:
|
||||
opts->mipmaps = false;
|
||||
break;
|
||||
case OPT_NO_REPEAT:
|
||||
opts->ignore_key_repeat = true;
|
||||
break;
|
||||
case OPT_CODEC_OPTIONS:
|
||||
opts->codec_options = optarg;
|
||||
break;
|
||||
|
|
|
@ -256,7 +256,10 @@ convert_input_key(const SDL_KeyboardEvent *from, struct control_msg *to,
|
|||
void
|
||||
input_manager_process_key(struct input_manager *im,
|
||||
const SDL_KeyboardEvent *event,
|
||||
bool control) {
|
||||
const struct scrcpy_options *options) {
|
||||
|
||||
|
||||
bool control = options->control;
|
||||
// control: indicates the state of the command-line option --no-control
|
||||
// ctrl: the Ctrl key
|
||||
|
||||
|
@ -408,7 +411,7 @@ input_manager_process_key(struct input_manager *im,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!control) {
|
||||
if (!control || (options->ignore_key_repeat && event->repeat)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "scrcpy.h"
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include "controller.h"
|
||||
|
@ -29,7 +30,7 @@ input_manager_process_text_input(struct input_manager *im,
|
|||
void
|
||||
input_manager_process_key(struct input_manager *im,
|
||||
const SDL_KeyboardEvent *event,
|
||||
bool control);
|
||||
const struct scrcpy_options *options);
|
||||
|
||||
void
|
||||
input_manager_process_mouse_motion(struct input_manager *im,
|
||||
|
|
|
@ -164,7 +164,8 @@ enum event_result {
|
|||
};
|
||||
|
||||
static enum event_result
|
||||
handle_event(SDL_Event *event, bool control) {
|
||||
handle_event(SDL_Event *event, const struct scrcpy_options *options) {
|
||||
bool control = options->control;
|
||||
switch (event->type) {
|
||||
case EVENT_STREAM_STOPPED:
|
||||
LOGD("Video stream stopped");
|
||||
|
@ -195,7 +196,7 @@ handle_event(SDL_Event *event, bool control) {
|
|||
case SDL_KEYUP:
|
||||
// some key events do not interact with the device, so process the
|
||||
// event even if control is disabled
|
||||
input_manager_process_key(&input_manager, &event->key, control);
|
||||
input_manager_process_key(&input_manager, &event->key, options);
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
if (!control) {
|
||||
|
@ -239,7 +240,8 @@ handle_event(SDL_Event *event, bool control) {
|
|||
}
|
||||
|
||||
static bool
|
||||
event_loop(bool display, bool control) {
|
||||
event_loop(const struct scrcpy_options *options) {
|
||||
bool display = options->display;
|
||||
(void) display;
|
||||
#ifdef CONTINUOUS_RESIZING_WORKAROUND
|
||||
if (display) {
|
||||
|
@ -248,7 +250,7 @@ event_loop(bool display, bool control) {
|
|||
#endif
|
||||
SDL_Event event;
|
||||
while (SDL_WaitEvent(&event)) {
|
||||
enum event_result result = handle_event(&event, control);
|
||||
enum event_result result = handle_event(&event, options);
|
||||
switch (result) {
|
||||
case EVENT_RESULT_STOPPED_BY_USER:
|
||||
return true;
|
||||
|
@ -439,7 +441,7 @@ scrcpy(const struct scrcpy_options *options) {
|
|||
|
||||
input_manager.prefer_text = options->prefer_text;
|
||||
|
||||
ret = event_loop(options->display, options->control);
|
||||
ret = event_loop(options);
|
||||
LOGD("quit...");
|
||||
|
||||
screen_destroy(&screen);
|
||||
|
|
|
@ -58,6 +58,7 @@ struct scrcpy_options {
|
|||
bool prefer_text;
|
||||
bool window_borderless;
|
||||
bool mipmaps;
|
||||
bool ignore_key_repeat;
|
||||
bool stay_awake;
|
||||
bool force_adb_forward;
|
||||
bool disable_screensaver;
|
||||
|
|
Loading…
Add table
Reference in a new issue