Fix "natural scrolling"
> Movements down (scroll backward) generate negative y values and up > (scroll forward) generate positive y values. > If direction is SDL_MOUSEWHEEL_FLIPPED the values in x and y will be > opposite. Multiply by -1 to change them back. <https://wiki.libsdl.org/SDL_MouseWheelEvent#Remarks> The x and y values already take the scrolling configuration into account. Reversing the values when the direction is flipped cancels the scrolling configuration. Therefore, just ignore the direction field. Fixes <https://github.com/Genymobile/scrcpy/issues/966>
This commit is contained in:
parent
8a694a9785
commit
3100533e56
1 changed files with 2 additions and 7 deletions
|
@ -550,13 +550,8 @@ convert_mouse_wheel(const SDL_MouseWheelEvent *from, struct screen *screen,
|
||||||
to->type = CONTROL_MSG_TYPE_INJECT_SCROLL_EVENT;
|
to->type = CONTROL_MSG_TYPE_INJECT_SCROLL_EVENT;
|
||||||
|
|
||||||
to->inject_scroll_event.position = position;
|
to->inject_scroll_event.position = position;
|
||||||
|
to->inject_scroll_event.hscroll = from->x;
|
||||||
int mul = from->direction == SDL_MOUSEWHEEL_NORMAL ? 1 : -1;
|
to->inject_scroll_event.vscroll = from->y;
|
||||||
// SDL behavior seems inconsistent between horizontal and vertical scrolling
|
|
||||||
// so reverse the horizontal
|
|
||||||
// <https://wiki.libsdl.org/SDL_MouseWheelEvent#Remarks>
|
|
||||||
to->inject_scroll_event.hscroll = -mul * from->x;
|
|
||||||
to->inject_scroll_event.vscroll = mul * from->y;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue