Compare commits
4
Commits
fixhidpi.4
...
textevents
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
532843d856 | ||
|
|
44791d6b40 | ||
|
|
2d90e1befd | ||
|
|
0e301ddf19 |
@@ -61,6 +61,16 @@ Set the TCP port the client listens on.
|
|||||||
|
|
||||||
Default is 27183.
|
Default is 27183.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BI \-\-prefer\-text\-events " mode
|
||||||
|
Configure how key/text events are forwarded to the Android device.
|
||||||
|
|
||||||
|
Possible \fImode\fRs are "always" (every text is sent as text), "non-alpha"
|
||||||
|
(only letters are sent as a sequence of key events, other characters are sent
|
||||||
|
as text) and "never" (every text is sent as a sequence of key events).
|
||||||
|
|
||||||
|
Default is "always".
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI "\-\-push\-target " path
|
.BI "\-\-push\-target " path
|
||||||
Set the target directory for pushing files to the device by drag & drop. It is passed as\-is to "adb push".
|
Set the target directory for pushing files to the device by drag & drop. It is passed as\-is to "adb push".
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ convert_meta_state(SDL_Keymod mod) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
convert_keycode(SDL_Keycode from, enum android_keycode *to, uint16_t mod) {
|
convert_keycode(SDL_Keycode from, enum android_keycode *to, uint16_t mod,
|
||||||
|
enum text_events_pref pref) {
|
||||||
switch (from) {
|
switch (from) {
|
||||||
MAP(SDLK_RETURN, AKEYCODE_ENTER);
|
MAP(SDLK_RETURN, AKEYCODE_ENTER);
|
||||||
MAP(SDLK_KP_ENTER, AKEYCODE_NUMPAD_ENTER);
|
MAP(SDLK_KP_ENTER, AKEYCODE_NUMPAD_ENTER);
|
||||||
@@ -92,6 +93,16 @@ convert_keycode(SDL_Keycode from, enum android_keycode *to, uint16_t mod) {
|
|||||||
MAP(SDLK_DOWN, AKEYCODE_DPAD_DOWN);
|
MAP(SDLK_DOWN, AKEYCODE_DPAD_DOWN);
|
||||||
MAP(SDLK_UP, AKEYCODE_DPAD_UP);
|
MAP(SDLK_UP, AKEYCODE_DPAD_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pref == PREFER_TEXT_EVENTS_ALWAYS) {
|
||||||
|
// never forward key events
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// forward all supported key events
|
||||||
|
SDL_assert(pref == PREFER_TEXT_EVENTS_NEVER ||
|
||||||
|
pref == PREFER_TEXT_EVENTS_NON_ALPHA);
|
||||||
|
|
||||||
if (mod & (KMOD_LALT | KMOD_RALT | KMOD_LGUI | KMOD_RGUI)) {
|
if (mod & (KMOD_LALT | KMOD_RALT | KMOD_LGUI | KMOD_RGUI)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,12 @@
|
|||||||
#define CONVERT_H
|
#define CONVERT_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <SDL2/SDL_assert.h>
|
||||||
#include <SDL2/SDL_events.h>
|
#include <SDL2/SDL_events.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "control_msg.h"
|
#include "control_msg.h"
|
||||||
|
#include "input_manager.h"
|
||||||
|
|
||||||
bool
|
bool
|
||||||
convert_keycode_action(SDL_EventType from, enum android_keyevent_action *to);
|
convert_keycode_action(SDL_EventType from, enum android_keyevent_action *to);
|
||||||
@@ -14,7 +16,8 @@ enum android_metastate
|
|||||||
convert_meta_state(SDL_Keymod mod);
|
convert_meta_state(SDL_Keymod mod);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
convert_keycode(SDL_Keycode from, enum android_keycode *to, uint16_t mod);
|
convert_keycode(SDL_Keycode from, enum android_keycode *to, uint16_t mod,
|
||||||
|
enum text_events_pref pref);
|
||||||
|
|
||||||
enum android_motionevent_buttons
|
enum android_motionevent_buttons
|
||||||
convert_mouse_buttons(uint32_t state);
|
convert_mouse_buttons(uint32_t state);
|
||||||
|
|||||||
+17
-7
@@ -214,12 +214,20 @@ clipboard_paste(struct controller *controller) {
|
|||||||
void
|
void
|
||||||
input_manager_process_text_input(struct input_manager *im,
|
input_manager_process_text_input(struct input_manager *im,
|
||||||
const SDL_TextInputEvent *event) {
|
const SDL_TextInputEvent *event) {
|
||||||
char c = event->text[0];
|
if (im->text_events_pref == PREFER_TEXT_EVENTS_NEVER) {
|
||||||
if (isalpha(c) || c == ' ') {
|
// ignore all text events (key events will be injected instead)
|
||||||
SDL_assert(event->text[1] == '\0');
|
|
||||||
// letters and space are handled as raw key event
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (im->text_events_pref == PREFER_TEXT_EVENTS_NON_ALPHA) {
|
||||||
|
char c = event->text[0];
|
||||||
|
if (isalpha(c) || c == ' ') {
|
||||||
|
SDL_assert(event->text[1] == '\0');
|
||||||
|
// letters and space are handled as raw key event
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct control_msg msg;
|
struct control_msg msg;
|
||||||
msg.type = CONTROL_MSG_TYPE_INJECT_TEXT;
|
msg.type = CONTROL_MSG_TYPE_INJECT_TEXT;
|
||||||
msg.inject_text.text = SDL_strdup(event->text);
|
msg.inject_text.text = SDL_strdup(event->text);
|
||||||
@@ -234,7 +242,8 @@ input_manager_process_text_input(struct input_manager *im,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
convert_input_key(const SDL_KeyboardEvent *from, struct control_msg *to) {
|
convert_input_key(const SDL_KeyboardEvent *from, struct control_msg *to,
|
||||||
|
enum text_events_pref pref) {
|
||||||
to->type = CONTROL_MSG_TYPE_INJECT_KEYCODE;
|
to->type = CONTROL_MSG_TYPE_INJECT_KEYCODE;
|
||||||
|
|
||||||
if (!convert_keycode_action(from->type, &to->inject_keycode.action)) {
|
if (!convert_keycode_action(from->type, &to->inject_keycode.action)) {
|
||||||
@@ -242,7 +251,8 @@ convert_input_key(const SDL_KeyboardEvent *from, struct control_msg *to) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t mod = from->keysym.mod;
|
uint16_t mod = from->keysym.mod;
|
||||||
if (!convert_keycode(from->keysym.sym, &to->inject_keycode.keycode, mod)) {
|
if (!convert_keycode(from->keysym.sym, &to->inject_keycode.keycode, mod,
|
||||||
|
pref)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,7 +403,7 @@ input_manager_process_key(struct input_manager *im,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct control_msg msg;
|
struct control_msg msg;
|
||||||
if (convert_input_key(event, &msg)) {
|
if (convert_input_key(event, &msg, im->text_events_pref)) {
|
||||||
if (!controller_push_msg(controller, &msg)) {
|
if (!controller_push_msg(controller, &msg)) {
|
||||||
LOGW("Could not request 'inject keycode'");
|
LOGW("Could not request 'inject keycode'");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,17 @@
|
|||||||
#include "video_buffer.h"
|
#include "video_buffer.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
|
enum text_events_pref {
|
||||||
|
PREFER_TEXT_EVENTS_ALWAYS,
|
||||||
|
PREFER_TEXT_EVENTS_NON_ALPHA,
|
||||||
|
PREFER_TEXT_EVENTS_NEVER,
|
||||||
|
};
|
||||||
|
|
||||||
struct input_manager {
|
struct input_manager {
|
||||||
struct controller *controller;
|
struct controller *controller;
|
||||||
struct video_buffer *video_buffer;
|
struct video_buffer *video_buffer;
|
||||||
struct screen *screen;
|
struct screen *screen;
|
||||||
|
enum text_events_pref text_events_pref;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
+76
-74
@@ -11,27 +11,13 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "input_manager.h"
|
||||||
#include "recorder.h"
|
#include "recorder.h"
|
||||||
|
|
||||||
struct args {
|
struct args {
|
||||||
const char *serial;
|
struct scrcpy_options opts;
|
||||||
const char *crop;
|
|
||||||
const char *record_filename;
|
|
||||||
const char *window_title;
|
|
||||||
const char *push_target;
|
|
||||||
enum recorder_format record_format;
|
|
||||||
bool fullscreen;
|
|
||||||
bool no_control;
|
|
||||||
bool no_display;
|
|
||||||
bool help;
|
bool help;
|
||||||
bool version;
|
bool version;
|
||||||
bool show_touches;
|
|
||||||
uint16_t port;
|
|
||||||
uint16_t max_size;
|
|
||||||
uint32_t bit_rate;
|
|
||||||
bool always_on_top;
|
|
||||||
bool turn_screen_off;
|
|
||||||
bool render_expired_frames;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void usage(const char *arg0) {
|
static void usage(const char *arg0) {
|
||||||
@@ -82,6 +68,18 @@ static void usage(const char *arg0) {
|
|||||||
" Set the TCP port the client listens on.\n"
|
" Set the TCP port the client listens on.\n"
|
||||||
" Default is %d.\n"
|
" Default is %d.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
" --prefer-text-events mode\n"
|
||||||
|
" Configure how key/text events are forwarded to the Android\n"
|
||||||
|
" device.\n"
|
||||||
|
" Possible values are:\n"
|
||||||
|
" always:\n"
|
||||||
|
" Every text is sent as text. (default)\n"
|
||||||
|
" non-alpha:\n"
|
||||||
|
" Only letters are sent as a sequence of key events, other\n"
|
||||||
|
" characters are sent as text.\n"
|
||||||
|
" never:\n"
|
||||||
|
" Every text is sent as a sequence of key events.\n"
|
||||||
|
"\n"
|
||||||
" --push-target path\n"
|
" --push-target path\n"
|
||||||
" Set the target directory for pushing files to the device by\n"
|
" Set the target directory for pushing files to the device by\n"
|
||||||
" drag & drop. It is passed as-is to \"adb push\".\n"
|
" drag & drop. It is passed as-is to \"adb push\".\n"
|
||||||
@@ -309,9 +307,33 @@ guess_record_format(const char *filename) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
parse_prefer_text_events(const char *optarg,
|
||||||
|
enum text_events_pref *pref) {
|
||||||
|
if (!strcmp(optarg, "always")) {
|
||||||
|
*pref = PREFER_TEXT_EVENTS_ALWAYS;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(optarg, "non-alpha")) {
|
||||||
|
*pref = PREFER_TEXT_EVENTS_NON_ALPHA;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(optarg, "never")) {
|
||||||
|
*pref = PREFER_TEXT_EVENTS_NEVER;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGE("Unsupported text events preference: %s"
|
||||||
|
"(expected 'always', 'non-alpha' or 'never')", optarg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#define OPT_RENDER_EXPIRED_FRAMES 1000
|
#define OPT_RENDER_EXPIRED_FRAMES 1000
|
||||||
#define OPT_WINDOW_TITLE 1001
|
#define OPT_WINDOW_TITLE 1001
|
||||||
#define OPT_PUSH_TARGET 1002
|
#define OPT_PUSH_TARGET 1002
|
||||||
|
#define OPT_PREFER_TEXT_EVENTS 1003
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_args(struct args *args, int argc, char *argv[]) {
|
parse_args(struct args *args, int argc, char *argv[]) {
|
||||||
@@ -334,28 +356,33 @@ parse_args(struct args *args, int argc, char *argv[]) {
|
|||||||
{"serial", required_argument, NULL, 's'},
|
{"serial", required_argument, NULL, 's'},
|
||||||
{"show-touches", no_argument, NULL, 't'},
|
{"show-touches", no_argument, NULL, 't'},
|
||||||
{"turn-screen-off", no_argument, NULL, 'S'},
|
{"turn-screen-off", no_argument, NULL, 'S'},
|
||||||
|
{"prefer-text-events", required_argument, NULL,
|
||||||
|
OPT_PREFER_TEXT_EVENTS},
|
||||||
{"version", no_argument, NULL, 'v'},
|
{"version", no_argument, NULL, 'v'},
|
||||||
{"window-title", required_argument, NULL,
|
{"window-title", required_argument, NULL,
|
||||||
OPT_WINDOW_TITLE},
|
OPT_WINDOW_TITLE},
|
||||||
{NULL, 0, NULL, 0 },
|
{NULL, 0, NULL, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct scrcpy_options *opts = &args->opts;
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while ((c = getopt_long(argc, argv, "b:c:fF:hm:nNp:r:s:StTv", long_options,
|
while ((c = getopt_long(argc, argv, "b:c:fF:hm:nNp:r:s:StTv", long_options,
|
||||||
NULL)) != -1) {
|
NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'b':
|
case 'b':
|
||||||
if (!parse_bit_rate(optarg, &args->bit_rate)) {
|
if (!parse_bit_rate(optarg, &opts->bit_rate)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
args->crop = optarg;
|
opts->crop = optarg;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
args->fullscreen = true;
|
opts->fullscreen = true;
|
||||||
break;
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
if (!parse_record_format(optarg, &args->record_format)) {
|
if (!parse_record_format(optarg, &opts->record_format)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -363,47 +390,53 @@ parse_args(struct args *args, int argc, char *argv[]) {
|
|||||||
args->help = true;
|
args->help = true;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
if (!parse_max_size(optarg, &args->max_size)) {
|
if (!parse_max_size(optarg, &opts->max_size)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
args->no_control = true;
|
opts->control = false;
|
||||||
break;
|
break;
|
||||||
case 'N':
|
case 'N':
|
||||||
args->no_display = true;
|
opts->display = false;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
if (!parse_port(optarg, &args->port)) {
|
if (!parse_port(optarg, &opts->port)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
args->record_filename = optarg;
|
opts->record_filename = optarg;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
args->serial = optarg;
|
opts->serial = optarg;
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
args->turn_screen_off = true;
|
opts->turn_screen_off = true;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
args->show_touches = true;
|
opts->show_touches = true;
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
args->always_on_top = true;
|
opts->always_on_top = true;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
args->version = true;
|
args->version = true;
|
||||||
break;
|
break;
|
||||||
case OPT_RENDER_EXPIRED_FRAMES:
|
case OPT_RENDER_EXPIRED_FRAMES:
|
||||||
args->render_expired_frames = true;
|
opts->render_expired_frames = true;
|
||||||
break;
|
break;
|
||||||
case OPT_WINDOW_TITLE:
|
case OPT_WINDOW_TITLE:
|
||||||
args->window_title = optarg;
|
opts->window_title = optarg;
|
||||||
break;
|
break;
|
||||||
case OPT_PUSH_TARGET:
|
case OPT_PUSH_TARGET:
|
||||||
args->push_target = optarg;
|
opts->push_target = optarg;
|
||||||
|
break;
|
||||||
|
case OPT_PREFER_TEXT_EVENTS:
|
||||||
|
if (!parse_prefer_text_events(optarg,
|
||||||
|
&opts->text_events_pref)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// getopt prints the error message on stderr
|
// getopt prints the error message on stderr
|
||||||
@@ -411,12 +444,12 @@ parse_args(struct args *args, int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->no_display && !args->record_filename) {
|
if (!opts->display && !opts->record_filename) {
|
||||||
LOGE("-N/--no-display requires screen recording (-r/--record)");
|
LOGE("-N/--no-display requires screen recording (-r/--record)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->no_display && args->fullscreen) {
|
if (!opts->display && opts->fullscreen) {
|
||||||
LOGE("-f/--fullscreen-window is incompatible with -N/--no-display");
|
LOGE("-f/--fullscreen-window is incompatible with -N/--no-display");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -427,21 +460,21 @@ parse_args(struct args *args, int argc, char *argv[]) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->record_format && !args->record_filename) {
|
if (opts->record_format && !opts->record_filename) {
|
||||||
LOGE("Record format specified without recording");
|
LOGE("Record format specified without recording");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->record_filename && !args->record_format) {
|
if (opts->record_filename && !opts->record_format) {
|
||||||
args->record_format = guess_record_format(args->record_filename);
|
opts->record_format = guess_record_format(opts->record_filename);
|
||||||
if (!args->record_format) {
|
if (!opts->record_format) {
|
||||||
LOGE("No format specified for \"%s\" (try with -F mkv)",
|
LOGE("No format specified for \"%s\" (try with -F mkv)",
|
||||||
args->record_filename);
|
opts->record_filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->no_control && args->turn_screen_off) {
|
if (!opts->control && opts->turn_screen_off) {
|
||||||
LOGE("Could not request to turn screen off if control is disabled");
|
LOGE("Could not request to turn screen off if control is disabled");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -458,24 +491,11 @@ main(int argc, char *argv[]) {
|
|||||||
setbuf(stderr, NULL);
|
setbuf(stderr, NULL);
|
||||||
#endif
|
#endif
|
||||||
struct args args = {
|
struct args args = {
|
||||||
.serial = NULL,
|
.opts = SCRCPY_OPTIONS_DEFAULT,
|
||||||
.crop = NULL,
|
|
||||||
.record_filename = NULL,
|
|
||||||
.window_title = NULL,
|
|
||||||
.push_target = NULL,
|
|
||||||
.record_format = 0,
|
|
||||||
.help = false,
|
.help = false,
|
||||||
.version = false,
|
.version = false,
|
||||||
.show_touches = false,
|
|
||||||
.port = DEFAULT_LOCAL_PORT,
|
|
||||||
.max_size = DEFAULT_MAX_SIZE,
|
|
||||||
.bit_rate = DEFAULT_BIT_RATE,
|
|
||||||
.always_on_top = false,
|
|
||||||
.no_control = false,
|
|
||||||
.no_display = false,
|
|
||||||
.turn_screen_off = false,
|
|
||||||
.render_expired_frames = false,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!parse_args(&args, argc, argv)) {
|
if (!parse_args(&args, argc, argv)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -504,25 +524,7 @@ main(int argc, char *argv[]) {
|
|||||||
SDL_LogSetAllPriority(SDL_LOG_PRIORITY_DEBUG);
|
SDL_LogSetAllPriority(SDL_LOG_PRIORITY_DEBUG);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct scrcpy_options options = {
|
int res = scrcpy(&args.opts) ? 0 : 1;
|
||||||
.serial = args.serial,
|
|
||||||
.crop = args.crop,
|
|
||||||
.port = args.port,
|
|
||||||
.record_filename = args.record_filename,
|
|
||||||
.window_title = args.window_title,
|
|
||||||
.push_target = args.push_target,
|
|
||||||
.record_format = args.record_format,
|
|
||||||
.max_size = args.max_size,
|
|
||||||
.bit_rate = args.bit_rate,
|
|
||||||
.show_touches = args.show_touches,
|
|
||||||
.fullscreen = args.fullscreen,
|
|
||||||
.always_on_top = args.always_on_top,
|
|
||||||
.control = !args.no_control,
|
|
||||||
.display = !args.no_display,
|
|
||||||
.turn_screen_off = args.turn_screen_off,
|
|
||||||
.render_expired_frames = args.render_expired_frames,
|
|
||||||
};
|
|
||||||
int res = scrcpy(&options) ? 0 : 1;
|
|
||||||
|
|
||||||
avformat_network_deinit(); // ignore failure
|
avformat_network_deinit(); // ignore failure
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -11,7 +11,8 @@
|
|||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
|
|
||||||
enum recorder_format {
|
enum recorder_format {
|
||||||
RECORDER_FORMAT_MP4 = 1,
|
RECORDER_FORMAT_AUTO,
|
||||||
|
RECORDER_FORMAT_MP4,
|
||||||
RECORDER_FORMAT_MKV,
|
RECORDER_FORMAT_MKV,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ static struct input_manager input_manager = {
|
|||||||
.controller = &controller,
|
.controller = &controller,
|
||||||
.video_buffer = &video_buffer,
|
.video_buffer = &video_buffer,
|
||||||
.screen = &screen,
|
.screen = &screen,
|
||||||
|
.text_events_pref = 0, // initialized later
|
||||||
};
|
};
|
||||||
|
|
||||||
// init SDL and set appropriate hints
|
// init SDL and set appropriate hints
|
||||||
@@ -414,6 +415,8 @@ scrcpy(const struct scrcpy_options *options) {
|
|||||||
show_touches_waited = true;
|
show_touches_waited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input_manager.text_events_pref = options->text_events_pref;
|
||||||
|
|
||||||
ret = event_loop(options->display, options->control);
|
ret = event_loop(options->display, options->control);
|
||||||
LOGD("quit...");
|
LOGD("quit...");
|
||||||
|
|
||||||
|
|||||||
+23
-1
@@ -3,9 +3,10 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <recorder.h>
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "input_manager.h"
|
||||||
|
#include "recorder.h"
|
||||||
|
|
||||||
struct scrcpy_options {
|
struct scrcpy_options {
|
||||||
const char *serial;
|
const char *serial;
|
||||||
@@ -14,6 +15,7 @@ struct scrcpy_options {
|
|||||||
const char *window_title;
|
const char *window_title;
|
||||||
const char *push_target;
|
const char *push_target;
|
||||||
enum recorder_format record_format;
|
enum recorder_format record_format;
|
||||||
|
enum text_events_pref text_events_pref;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
uint16_t max_size;
|
uint16_t max_size;
|
||||||
uint32_t bit_rate;
|
uint32_t bit_rate;
|
||||||
@@ -26,6 +28,26 @@ struct scrcpy_options {
|
|||||||
bool render_expired_frames;
|
bool render_expired_frames;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SCRCPY_OPTIONS_DEFAULT { \
|
||||||
|
.serial = NULL, \
|
||||||
|
.crop = NULL, \
|
||||||
|
.record_filename = NULL, \
|
||||||
|
.window_title = NULL, \
|
||||||
|
.push_target = NULL, \
|
||||||
|
.record_format = RECORDER_FORMAT_AUTO, \
|
||||||
|
.text_events_pref = PREFER_TEXT_EVENTS_ALWAYS, \
|
||||||
|
.port = DEFAULT_LOCAL_PORT, \
|
||||||
|
.max_size = DEFAULT_LOCAL_PORT, \
|
||||||
|
.bit_rate = DEFAULT_BIT_RATE, \
|
||||||
|
.show_touches = false, \
|
||||||
|
.fullscreen = false, \
|
||||||
|
.always_on_top = false, \
|
||||||
|
.control = true, \
|
||||||
|
.display = true, \
|
||||||
|
.turn_screen_off = false, \
|
||||||
|
.render_expired_frames = false, \
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
scrcpy(const struct scrcpy_options *options);
|
scrcpy(const struct scrcpy_options *options);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user