From 3100533e56b2efdfc6f07b96681a7eef25ff63e0 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Tue, 3 Dec 2019 21:10:43 +0100 Subject: [PATCH] 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. 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 --- app/src/input_manager.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/src/input_manager.c b/app/src/input_manager.c index 013fb640..60879005 100644 --- a/app/src/input_manager.c +++ b/app/src/input_manager.c @@ -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 - // - 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; }