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 2196

Summary: Touchscreen touches do not register unless user touches screen once before launching app
Product: SDL Reporter: Brett Ernst <brett.ernst.77>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED DUPLICATE QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: demlow
Version: 2.0.1   
Hardware: x86_64   
OS: Linux   
Attachments: Patch illustrating workaround

Description Brett Ernst 2013-10-30 02:48:05 UTC
Created attachment 1398 [details]
Patch illustrating workaround

Environment: Arch Linux, NVIDIA graphics, Xorg server with NO window manager (kiosk project) and multiple touchscreen displays of different brands.

After starting a fresh instance of Xorg on a touchscreen device (using the standard evdev driver), launching an SDL app before giving any input to the touchscreen will result in touch events being ignored and SDL_GetNumTouchDevices() returning zero.

However, if the user taps the screen and then launches an SDL app again, SDL_GetNumTouchDevices() returns 1 and touch events are honored. All further instances of the application perform normally until the Xorg session is restarted.

I traced this back to the fact that XIQueryInputDevice() does not return touch devices for which there has not yet been input for the current X session. The proposed fix is to watch for touch events from previously unrecognized touch devices and then add those devices if XIQueryInputDevice() returns information for them.

I have attached a patch that illustrates one potential fix (tested in Arch Linux under Xorg with no window manager). It's a rough attempt but should illustrate a potential solution. May want to add the same logic to the other two touch events for completeness.

Thanks!
Comment 1 Sam Lantinga 2013-11-23 10:15:17 UTC
Hey Ryan, this seems sane to me, but it's been a while since I've looked at that code.  What do you think?
Comment 2 Ryan C. Gordon 2015-02-19 05:22:21 UTC
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry if you got a lot of email from this. This is to help me sort through some bugs in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4, though!
Comment 3 Volumetric 2015-05-22 19:59:04 UTC
See bug 2974 for what may be an alternate, simpler solution to this problem.
Comment 4 Sam Lantinga 2017-08-15 05:08:28 UTC
I believe the fix in bug 2974 is the right one here.

Thanks!

*** This bug has been marked as a duplicate of bug 2974 ***