In general, I think you only want to handle the mouse events, unless
you’re
doing something that’s specifically touch sensitive, e.g. handling
gestures.
The intent is that you can assume that any touch input will also
generate
simulated mouse events if no mouse is present, so any non-touch-specific
UI
elements will work consistently on platforms with only mice as well as
platforms
with only touch input.
If you have a UI element that works better with touch input for some
reason,
then as soon as you get touch input events you should reset your state
and start
ignoring mouse input.
Looking at the event sequence it may make sense to send the touch events
first
so you know the mouse events are coming. e.g.
FINGERDOWN
MOUSEMOTION
MOUSEBUTTONDOWN
FINGERMOTION ,MOUSEMOTION,… dozens of these pairs.
FINGERUP
MOUSEBUTTONUP
Cheers!
On Sat, Dec 1, 2012 at 8:47 PM, John <john at puckerupgames.com <mailto:john at puckerupgames.com**>> wrote:
Yes, sort of. It's not important to me whether the events were truly
triggered by such-and-such device, although I can see why an app
might need
that. I’d like to know how a “well behaved” app event loop should
interpret
the new SDL events. Knowing that, I can revise my apps to follow suit.
Perhaps a real example would make more sense: A game displays a button
graphic. The player can "press" the on-screen button with a mouse down
event. They may also press the on-screen button with a finger event.
The app
handles both events, and it handles the “up” events as well in order
to
alter the button appearance. Just your typical
"onmousedown/onmouseup" sort
of stuff. The code compiles nicely on all platforms that SDL
supports. Now,
with the mouse emulation patch applied, on Android, when the user
touches
the screen, the app recieves a flurry of mouse events AND touch
events. The
mousemotion is even weirder, because the mouse emulation patch
generates
very sudden, fast motion when there is no motion at all. On
finger-down, SDL
moves the “fake” mouse location from it’s previously fake location to
the
new finger location by generating a mouse motion event. Kinda like
the old
WarpMouse call.
Here's the event sequence on Android before the patch, when the user
touches
the screen then releases:
FINGERDOWN
FINGERMOTION
FINGERMOTION... dozens of these.
FINGERUP
Here's the event sequence after the emulation patch:
MOUSEMOTION
MOUSEBUTTONDOWN
FINGERDOWN
MOUSEMOTION,FINGERMOTION,.. dozens of these pairs.
MOUSEBUTTONUP
FINGERUP
On 12/01/2012 10:08 PM, Sik the hedgehog wrote:
So you want to distinguish between cursor events caused by the
mouse
and cursor events caused by touch, if I’m understanding right?
(honestly it should be called cursor, not mouse)
2012/12/1 John <john at puckerupgames.com <mailto:
john at puckerupgames.com**>>:
How will the app event handler know whether to ignore mouse
events?
I think the issue is that now SDL is always in this emulation
mode. It
generates fake mouse events whenever it sees touch events,
then delivers
BOTH events to the app. From the perspective of an app’s
event loop,
sometimes SDL_MouseEvent is really a mouse event, and
sometimes it is a
duplicate of a touch event or a finger event.
I guess this is really a question of what an app event loop
should
look like
now. Say an app’s event handler resembles this code,
case SDL_MOUSEBUTTONDOWN: handle_mousedown(); break;
case SDL_TOUCHBUTTONDOWN: handle_touchbuttondown(); break;
case SDL_FINGERDOWN: handle_fingerdown(); break;
case SDL_MOUSEMOTION: handle_mousemotion(); break;
case SDL_FINGERMOTION: handle_fingermotion(); break;
case SDL_MOUSEWHEEL: handle_mousewheel(); break;
...etc.
How would you recommend app developers revise their event
handlers
to work
after the mouse emulation patch?
On 12/01/2012 05:17 PM, Sam Lantinga wrote:
This is a required feature for games that use gesture
support as
well as
mouse
interaction. If you prefer to use only touch events, can
you
ignore the
mouse
events?
On Thu, Nov 29, 2012 at 3:31 PM, John < john at puckerupgames.com <mailto:john at puckerupgames.com**> <mailto:john at puckerupgames.com <mailto:john at puckerupgames.com**>__>> wrote:
Hi,
The patch in the SDL trunk (listed below) breaks
apps that
correctly
handle
mouse and touch events. Apps will receive mouse
events AND
touch
events.
Also, the precision of the mouse events will be
incredibly
lossy due
to
integer truncation when compared with the touch
events,
which have
double
precision.
Recommend removing this patch altogether.
The patch in question is
http://hg.libsdl.org/SDL/raw-_**___rev/17ef8a7cab55<http://hg.libsdl.org/SDL/raw-____rev/17ef8a7cab55>
<http://hg.libsdl.org/SDL/raw-**__rev/17ef8a7cab55<http://hg.libsdl.org/SDL/raw-__rev/17ef8a7cab55>
<http://hg.libsdl.org/SDL/raw-**__rev/17ef8a7cab55<http://hg.libsdl.org/SDL/raw-__rev/17ef8a7cab55>
<http://hg.libsdl.org/SDL/raw-**rev/17ef8a7cab55<http://hg.libsdl.org/SDL/raw-rev/17ef8a7cab55>
in file "src/video/android/SDL_____**
androidtouch.c"
-John
______________________________**
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
<mailto:SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org
http://lists.libsdl.org/____**listinfo.cgi/sdl-libsdl.org<http://lists.libsdl.org/____listinfo.cgi/sdl-libsdl.org>
<http://lists.libsdl.org/__**listinfo.cgi/sdl-libsdl.org<http://lists.libsdl.org/__listinfo.cgi/sdl-libsdl.org>
<http://lists.libsdl.org/__**
listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/__listinfo.cgi/sdl-libsdl.org
<http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
______________________________**___________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/__**listinfo.cgi/sdl-libsdl.org<http://lists.libsdl.org/__listinfo.cgi/sdl-libsdl.org>
<http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.org<http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org>
______________________________**___________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/__**listinfo.cgi/sdl-libsdl.org<http://lists.libsdl.org/__listinfo.cgi/sdl-libsdl.org>
<http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.org<http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org>
______________________________**___________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/__**listinfo.cgi/sdl-libsdl.org<http://lists.libsdl.org/__listinfo.cgi/sdl-libsdl.org>
<http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.org<http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org>
______________________________**___________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/__**listinfo.cgi/sdl-libsdl.org<http://lists.libsdl.org/__listinfo.cgi/sdl-libsdl.org>
<http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.org<http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org>
_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org