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 2800 - Incorrect type casting in Touch processing sometimes leads to event loss
Summary: Incorrect type casting in Touch processing sometimes leads to event loss
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 2.0.3
Hardware: iPhone/iPod touch iOS (All)
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-03 14:10 UTC by ken48
Modified: 2015-05-28 20:16 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ken48 2014-12-03 14:10:30 UTC
First, look at calls of the SDL_SendTouch in SDL_uikitview.m

line 139: SDL_SendTouch(touchId, (long)touch, ....
'touch' is a pointer (UITouch *touch).

I build my project only for 32-bit architecture. And long is 32 bit integer there.

Now look at SDL_SendTouch signature:

int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, ...

According to SDL_touch.h SDL_FingerID is a Sint64.

Because of this fingerId was passed into SDL_SendTouch with incorrect value and there was no processing of touchEnded after touchBegan.

Changing 

typedef Sint64 SDL_FingerID;

to

typedef long SDL_FingerID;

in SDL_touch.h solved the problem
Comment 1 Alex Szpakowski 2015-02-23 03:40:23 UTC
The 'long' type will always be 32 bits in 32-bit iOS apps and 64 bits in 64-bit iOS apps. SDL_FingerID is always 64 bits, so it always has at least enough space to hold all possible pointer (and long) values on iOS, so the SDL_SendTouch call should be fine. Am I missing something?
Comment 2 Alex Szpakowski 2015-05-28 02:30:59 UTC
(In reply to Alex Szpakowski from comment #1)
> Am I missing something?

Closing this for now, but do tell me if this needs revisiting!
Comment 3 Ryan C. Gordon 2015-05-28 19:23:49 UTC
(In reply to Alex Szpakowski from comment #2)
> (In reply to Alex Szpakowski from comment #1)
> > Am I missing something?
> 
> Closing this for now, but do tell me if this needs revisiting!

Well, we definitely weren't going to change SDL_FingerID's type in any case, but I guess it would be more proper cast to SDL_FingerID instead of long in that SDL_SendTouch() call?

(I don't see where the bug would have happened there, either. Maybe the pointer would have resulted in a negative 32-bit integer and the sign-extension to 64 bits confused things? No idea.)

--ryan.
Comment 4 Alex Szpakowski 2015-05-28 19:33:40 UTC
(In reply to Ryan C. Gordon from comment #3)
> Well, we definitely weren't going to change SDL_FingerID's type in any case,
> but I guess it would be more proper cast to SDL_FingerID instead of long in
> that SDL_SendTouch() call?

Agreed – and apparently I already changed it to do that in one of my commits several months ago. :)
Comment 5 Ryan C. Gordon 2015-05-28 20:16:20 UTC
(In reply to Alex Szpakowski from comment #4)
> Agreed – and apparently I already changed it to do that in one of my commits
> several months ago. :)

Cool, we're good here, then.  :)

--ryan.