mirror of
https://github.com/Genymobile/scrcpy
synced 2024-12-19 13:51:22 +00:00
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
@ -550,13 +550,8 @@ convert_mouse_wheel(const SDL_MouseWheelEvent *from, struct screen *screen,
|
||||
to->type = CONTROL_MSG_TYPE_INJECT_SCROLL_EVENT;
|
||||
|
||||
to->inject_scroll_event.position = position;
|
||||
|
||||
int mul = from->direction == SDL_MOUSEWHEEL_NORMAL ? 1 : -1;
|
||||
// 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;
|
||||
to->inject_scroll_event.hscroll = from->x;
|
||||
to->inject_scroll_event.vscroll = from->y;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user