We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3871

Summary: Touch events are not normalised on X11
Product: SDL Reporter: Trent Gamblin <trent>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sezeroz, sylvain.becker
Version: HG 2.0   
Hardware: x86_64   
OS: Linux   
Attachments: Fix for the issue.
Fixed patch (fully spans 0-1)
Remove changed files

Description Trent Gamblin 2017-10-11 15:53:39 UTC
Created attachment 2975 [details]
Fix for the issue.

The documentation for SDL_TouchFingerEvent says that the x and y coordinates are normalised between 0-1. I've found that to be true on Windows, Android and iOS but on X11 they are in pixel coordinates. This patch fixes the issue. This was the cleanest way I could do it with what was available without changing things around a lot but you may know a better way.
Comment 1 Trent Gamblin 2017-10-11 16:26:36 UTC
One small change needed to the patch: divide by width/height - 1 instead of just width/height.
Comment 2 Ozkan Sezer 2017-10-11 17:24:38 UTC
Can you please attach a new patch instead?
Comment 3 Trent Gamblin 2017-10-11 17:28:25 UTC
Created attachment 2977 [details]
Fixed patch (fully spans 0-1)

Here's a new patch.
Comment 4 Trent Gamblin 2017-10-11 17:30:35 UTC
Created attachment 2978 [details]
Remove changed files

Guh, here's one without touching files I'm not supposed to. Sorry about that!
Comment 5 Sylvain 2017-10-12 07:08:07 UTC
This is a duplicated of bug 2307,
Patch are similar, but :

- maybe xinput2_normalize_touch_coordinates() should be within preprocessor "#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH". So that it avoids a warning on compilation.

- why do you divide by "width/height - 1" and not "width/height"
  ok, you get a value of 1.0 at the border, but if the window size is 1x1, you have a division by 0 ?


Also, in bug 2307, there is a patch to adapt touch event to logical size of the SDL_Renderer, you may want to double check it !
Comment 6 Sam Lantinga 2017-10-12 15:27:36 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/6fde74294cc9

Sylvain, your comments are addressed here:
https://hg.libsdl.org/SDL/rev/8dd72342f1f1