From 14ead499fd848504895fee7649b5c7430be148b5 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 17 Apr 2020 18:17:12 +0200 Subject: [PATCH] Fix touch coordinates on rotated display The touch coordinates were not rotated. --- app/src/input_manager.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/input_manager.c b/app/src/input_manager.c index 589eb842..72f15ee3 100644 --- a/app/src/input_manager.c +++ b/app/src/input_manager.c @@ -515,13 +515,11 @@ convert_touch(const SDL_TouchFingerEvent *from, struct screen *screen, return false; } - struct size frame_size = screen->frame_size; - to->inject_touch_event.pointer_id = from->fingerId; - to->inject_touch_event.position.screen_size = frame_size; + to->inject_touch_event.position.screen_size = screen->frame_size; // SDL touch event coordinates are normalized in the range [0; 1] - float x = from->x * frame_size.width; - float y = from->y * frame_size.height; + float x = from->x * screen->content_size.width; + float y = from->y * screen->content_size.height; to->inject_touch_event.position.point = rotate_position(screen, x, y); to->inject_touch_event.pressure = from->pressure; to->inject_touch_event.buttons = 0;