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 997

Summary: SDL_MOUSEBUTTONDOWN sent for the wrong mouse cursor co-ordinates
Product: SDL Reporter: Maus Dabber <mausdabber>
Component: eventsAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: icculus, mausdabber
Version: 1.2.14   
Hardware: x86   
OS: Windows (XP)   

Description Maus Dabber 2010-05-02 09:26:07 UTC
Hello

I've created a widget system using SDL. Everything was working happily until I started using a touchscreen. The touchscreen is installed as a standard USB HID mouse so SDL does not know there's a touchscreen in the system. The touchscreen works perfectly in Windows.

When I click the touchscreen somewhere away from the current mouse position, SDL first sends event SDL_MOUSEBUTTONDOWN with the old co-ordinates, followed by event MOUSEMOTION containing the correct co-ordinates. Obviously, this is wrong. Here's an except of my program's log:

00000018	5:49:57.343 PM	[1316] [CAWRDPOS    ] SDL event: type 05 - SDL_MOUSEBUTTONDOWN	
00000019	5:49:57.343 PM	[1316] [CAWRDPOS    ]            (348,0)	
00000020	5:49:57.343 PM	[1316] [CAWRDPOS    ] SDL event: type 04 - SDL_MOUSEMOTION	
00000021	5:49:57.343 PM	[1316] [CAWRDPOS    ]            (629,287)	
00000022	5:49:57.437 PM	[1316] [CAWRDPOS    ] SDL event: type 06 - SDL_MOUSEBUTTONUP	
00000023	5:49:57.437 PM	[1316] [CAWRDPOS    ]            (629,287)	

You can see SDL_MOUSEBUTTONDOWN comes with the old co-ordinates (348,0) followed by SDL_MOUSEMOTION with the actual co-ordinates where I touched the screen (629,287). This is a major problem. It disrupts the proper working of a widget kit.

I can repeat this situation 100%.

For the sake of clarity, I also checked the generated Win32 messages using a test program. When I click the touchscreen, it first generates a WM_MOUSEMOVE for the new co-ordinates, followed by WM_LBUTTONDOWN for the same co-ordinates. This is normal behaviour for touchscreens.

I also installed the vendor-supplied drivers for the touchscreen. I tried different modes of behaviour including mouse emulation. However the results remained the same; SDL still generates incorrect events.

I'm using an ELO 1515. However, since the touchscreen is installed as a generic USB mouse (using standard Windows drivers), I'm afraid SDL will have problems with other touchscreens as well because they generate similar events.

BR
Comment 1 Maus Dabber 2010-05-03 04:05:42 UTC
Today, I tested with a different touchscreen, a Kortek KT-L15-03. This one comes with a 3M touch system. The result are the same as with the other touchscreen: the SDL problem remains.

BR
Comment 2 Sam Lantinga 2011-12-29 08:58:41 UTC
This is fixed, thanks!
http://hg.libsdl.org/SDL/rev/8c88cae7911e
Comment 3 Ryan C. Gordon 2011-12-30 00:51:24 UTC
Marking this FIXED because Sam forgot to.  :)

--ryan.