mirror of
https://github.com/Genymobile/scrcpy
synced 2024-12-26 00:52:20 +00:00
Copy the options used in input manager init
This avoids to pass additional options to some input manager functions. Refs #1623 <https://github.com/Genymobile/scrcpy/pull/1623>
This commit is contained in:
parent
0870d8620f
commit
74079ea5e4
@ -54,11 +54,13 @@ is_shortcut_mod(struct input_manager *im, uint16_t sdl_mod) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
input_manager_init(struct input_manager *im, bool prefer_text,
|
input_manager_init(struct input_manager *im,
|
||||||
const struct sc_shortcut_mods *shortcut_mods)
|
const struct scrcpy_options *options)
|
||||||
{
|
{
|
||||||
im->prefer_text = prefer_text;
|
im->control = options->control;
|
||||||
|
im->prefer_text = options->prefer_text;
|
||||||
|
|
||||||
|
const struct sc_shortcut_mods *shortcut_mods = &options->shortcut_mods;
|
||||||
assert(shortcut_mods->count);
|
assert(shortcut_mods->count);
|
||||||
assert(shortcut_mods->count < SC_MAX_SHORTCUT_MODS);
|
assert(shortcut_mods->count < SC_MAX_SHORTCUT_MODS);
|
||||||
for (unsigned i = 0; i < shortcut_mods->count; ++i) {
|
for (unsigned i = 0; i < shortcut_mods->count; ++i) {
|
||||||
@ -318,9 +320,9 @@ convert_input_key(const SDL_KeyboardEvent *from, struct control_msg *to,
|
|||||||
|
|
||||||
void
|
void
|
||||||
input_manager_process_key(struct input_manager *im,
|
input_manager_process_key(struct input_manager *im,
|
||||||
const SDL_KeyboardEvent *event,
|
const SDL_KeyboardEvent *event) {
|
||||||
bool control) {
|
|
||||||
// control: indicates the state of the command-line option --no-control
|
// control: indicates the state of the command-line option --no-control
|
||||||
|
bool control = im->control;
|
||||||
|
|
||||||
bool smod = is_shortcut_mod(im, event->keysym.mod);
|
bool smod = is_shortcut_mod(im, event->keysym.mod);
|
||||||
|
|
||||||
@ -573,8 +575,9 @@ convert_mouse_button(const SDL_MouseButtonEvent *from, struct screen *screen,
|
|||||||
|
|
||||||
void
|
void
|
||||||
input_manager_process_mouse_button(struct input_manager *im,
|
input_manager_process_mouse_button(struct input_manager *im,
|
||||||
const SDL_MouseButtonEvent *event,
|
const SDL_MouseButtonEvent *event) {
|
||||||
bool control) {
|
bool control = im->control;
|
||||||
|
|
||||||
if (event->which == SDL_TOUCH_MOUSEID) {
|
if (event->which == SDL_TOUCH_MOUSEID) {
|
||||||
// simulated from touch events, so it's a duplicate
|
// simulated from touch events, so it's a duplicate
|
||||||
return;
|
return;
|
||||||
|
@ -22,6 +22,7 @@ struct input_manager {
|
|||||||
// number of repetitions. This variable keeps track of the count.
|
// number of repetitions. This variable keeps track of the count.
|
||||||
unsigned repeat;
|
unsigned repeat;
|
||||||
|
|
||||||
|
bool control;
|
||||||
bool prefer_text;
|
bool prefer_text;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@ -31,8 +32,8 @@ struct input_manager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
input_manager_init(struct input_manager *im, bool prefer_text,
|
input_manager_init(struct input_manager *im,
|
||||||
const struct sc_shortcut_mods *shortcut_mods);
|
const struct scrcpy_options *options);
|
||||||
|
|
||||||
void
|
void
|
||||||
input_manager_process_text_input(struct input_manager *im,
|
input_manager_process_text_input(struct input_manager *im,
|
||||||
@ -40,8 +41,7 @@ input_manager_process_text_input(struct input_manager *im,
|
|||||||
|
|
||||||
void
|
void
|
||||||
input_manager_process_key(struct input_manager *im,
|
input_manager_process_key(struct input_manager *im,
|
||||||
const SDL_KeyboardEvent *event,
|
const SDL_KeyboardEvent *event);
|
||||||
bool control);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
input_manager_process_mouse_motion(struct input_manager *im,
|
input_manager_process_mouse_motion(struct input_manager *im,
|
||||||
@ -53,8 +53,7 @@ input_manager_process_touch(struct input_manager *im,
|
|||||||
|
|
||||||
void
|
void
|
||||||
input_manager_process_mouse_button(struct input_manager *im,
|
input_manager_process_mouse_button(struct input_manager *im,
|
||||||
const SDL_MouseButtonEvent *event,
|
const SDL_MouseButtonEvent *event);
|
||||||
bool control);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
input_manager_process_mouse_wheel(struct input_manager *im,
|
input_manager_process_mouse_wheel(struct input_manager *im,
|
||||||
|
@ -201,7 +201,7 @@ handle_event(SDL_Event *event, bool control) {
|
|||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
// some key events do not interact with the device, so process the
|
// some key events do not interact with the device, so process the
|
||||||
// event even if control is disabled
|
// event even if control is disabled
|
||||||
input_manager_process_key(&input_manager, &event->key, control);
|
input_manager_process_key(&input_manager, &event->key);
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
if (!control) {
|
if (!control) {
|
||||||
@ -219,8 +219,7 @@ handle_event(SDL_Event *event, bool control) {
|
|||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONUP:
|
||||||
// some mouse events do not interact with the device, so process
|
// some mouse events do not interact with the device, so process
|
||||||
// the event even if control is disabled
|
// the event even if control is disabled
|
||||||
input_manager_process_mouse_button(&input_manager, &event->button,
|
input_manager_process_mouse_button(&input_manager, &event->button);
|
||||||
control);
|
|
||||||
break;
|
break;
|
||||||
case SDL_FINGERMOTION:
|
case SDL_FINGERMOTION:
|
||||||
case SDL_FINGERDOWN:
|
case SDL_FINGERDOWN:
|
||||||
@ -443,8 +442,7 @@ scrcpy(const struct scrcpy_options *options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
input_manager_init(&input_manager, options->prefer_text,
|
input_manager_init(&input_manager, options);
|
||||||
&options->shortcut_mods);
|
|
||||||
|
|
||||||
ret = event_loop(options->display, options->control);
|
ret = event_loop(options->display, options->control);
|
||||||
LOGD("quit...");
|
LOGD("quit...");
|
||||||
|
Loading…
Reference in New Issue
Block a user