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 2931 - SDL_SetRelativeMouseMode ignores SDL_TOUCH_MOUSEID
Summary: SDL_SetRelativeMouseMode ignores SDL_TOUCH_MOUSEID
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.3
Hardware: iPhone/iPod touch iOS (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-07 14:27 UTC by RobLM
Modified: 2017-08-13 03:26 UTC (History)
1 user (show)

See Also:


Attachments
First patch to preserve mouse ID when warping mouse (3.93 KB, patch)
2015-04-08 08:15 UTC, RobLM
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description RobLM 2015-04-07 14:27:44 UTC
Problem context:
SDL_SetRelativeMouseMode is set to SDL_TRUE in an iOS application. Probably affects all platforms as it seems to originate in the generic (main) mouse warping code that doesn't honor the originating mouse ID.

Problematic behavior:
Every finger motion starts generates an SDL_MOUSEMOTION event with:
- a bogus (0) 'event.motion.which' value
- huge, negative, relative motion values in 'event.motion.xrel' and 'event.motion.yrel' -- these appear to be equal to (negative) half the window width and height

Expected behavior:
The SDL_MOUSEMOTION events generated by finger motions have SDL_TOUCH_MOUSEID as the 'event.motion.which' value.

Possible solutions:
- if seen as unintended behavior: fix mouse warping code to honor originating mouse ID
- if seen as intended behavior: acknowledge and document current SDL_MOUSEMOTION  behavior with bogus values so applications won't break in the future (maybe add an SDL unit test for this?)
Comment 1 RobLM 2015-04-08 08:15:22 UTC
Created attachment 2112 [details]
First patch to preserve mouse ID when warping mouse

Here's a first patch trying to solve the issue by preserving the mouse ID between SDL_SendMouseMotion() and SDL_WarpMouseInWindow().
Comment 2 RobLM 2015-04-08 11:01:57 UTC
I thought about this some more. Maybe a better solution would be to not generate relative mouse events at all for SDL-originated mouse warps, because they are not actual (physical) relative mouse motions.
Comment 3 Sam Lantinga 2017-08-13 00:49:45 UTC
Yes, I think we don't want relative motion at all for warps. I'll have to think about how we want to implement this.
Comment 4 Sam Lantinga 2017-08-13 03:26:36 UTC
This is fixed in a much better way now - you won't get large relative motion jumps when fingers touch down on iOS.
https://hg.libsdl.org/SDL/rev/9fc2e83124ba
Comment 5 Sam Lantinga 2017-08-13 03:26:48 UTC
Fixed!