Skip to content

Commit

Permalink
Fix touch coordinates on rotated display
Browse files Browse the repository at this point in the history
The touch coordinates were not rotated.
  • Loading branch information
rom1v committed Apr 17, 2020
1 parent 94a7f1a commit 14ead49
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions app/src/input_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 14ead49

Please sign in to comment.