Handle down/up actions separately for HOME

Pressing middle-click generated both the DOWN and UP keyevent HOME.

Instead, generate DOWN on button pressed and UP on button released.

Ref #1062 <https://github.com/Genymobile/scrcpy/issues/1062>
This commit is contained in:
Romain Vimont 2020-01-08 22:11:03 +01:00
parent 83d48267a7
commit 149702753f

View File

@ -521,31 +521,36 @@ input_manager_process_mouse_button(struct input_manager *im,
// simulated from touch events, so it's a duplicate
return;
}
if (event->type == SDL_MOUSEBUTTONDOWN) {
if (control && event->button == SDL_BUTTON_RIGHT) {
press_back_or_turn_screen_on(im->controller);
return;
}
if (control && event->button == SDL_BUTTON_MIDDLE) {
action_home(im->controller, ACTION_DOWN | ACTION_UP);
return;
}
// double-click on black borders resize to fit the device screen
if (event->button == SDL_BUTTON_LEFT && event->clicks == 2) {
bool outside =
is_outside_device_screen(im, event->x, event->y);
if (event->type == SDL_MOUSEBUTTONDOWN
&& event->button == SDL_BUTTON_LEFT
&& event->clicks == 2) {
bool outside = is_outside_device_screen(im, event->x, event->y);
if (outside) {
screen_resize_to_fit(im->screen);
return;
}
}
// otherwise, send the click event to the device
}
if (!control) {
return;
}
if (event->button == SDL_BUTTON_MIDDLE) {
int action = event->type == SDL_MOUSEBUTTONDOWN ? ACTION_DOWN
: ACTION_UP;
action_home(im->controller, action);
return;
}
if (event->button == SDL_BUTTON_RIGHT) {
if (event->type == SDL_MOUSEBUTTONDOWN) {
press_back_or_turn_screen_on(im->controller);
}
return;
}
struct control_msg msg;
if (convert_mouse_button(event, im->screen, &msg)) {
if (!controller_push_msg(im->controller, &msg)) {