Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [A5 iPad] input tracking

This thread is locked; no one can reply to it. rss feed Print
 1   2 
[A5 iPad] input tracking
23yrold3yrold
Member #1,134
March 2001
avatar

Hey all. I was just wondering if the iPhone/iPad port of Allegro handles input tracking. Well, more specifically (of course it handles input; duh), assigning unique IDs to inputs to facilitate multitouch. I know for our last game I had to keep track of unique touch IDs because people wanted to be able to drag two things with two fingers, and the Apple API keeps track of the IDs and sends them with all the input events. I don't see any parameter like that in ALLEGRO_EVENT so I was curious if it was being handled.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Evert
Member #794
November 2000
avatar

Short answer, no.
Long answer, no, not yet. It's something we should have some sort of support for, but it's not clear yet how to do that in a way that is somewhat cross-platform, or whether that makes sense at all. At least it wasn't clear yet a while back.

So if you have suggestions or opinions on how to do that, please let use know. :)

23yrold3yrold
Member #1,134
March 2001
avatar

It probably wouldn't be cross-platform at all, unless other platforms have a need for that information. We use a void pointer to keep track of each touch and that's all we needed (we weren't originally keeping track of it; I had to add in multitouch functionality afterward). I haven't looked at the Allegro code on this yet, but the iOS tracks touch and assigns unique IDs already so assuming there's room in the union/struct, that should be all there is to it. Unless there's some other consideration I'm not aware of.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Thomas Fjellstrom
Member #476
June 2000
avatar

It probably wouldn't be cross-platform at all, unless other platforms have a need for that information.

Why wouldn't other platforms want multi-touch?

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

23yrold3yrold
Member #1,134
March 2001
avatar

Does Allegro 5 support other platforms that have touch interfaces? I honestly didn't think it did.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Thomas Fjellstrom
Member #476
June 2000
avatar

Does Allegro 5 support other platforms that have touch interfaces? I honestly didn't think it did.

X has touch support, least newer versions of it does. Windows 7 has touch support as well.

Its not something we want to leave out.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

23yrold3yrold
Member #1,134
March 2001
avatar

Well I guess it depends on how they all use it then, since the only one I've used is the iOS version. Can't imagine it's terribly different, but I have no experience.

Anyway, for iOS all you need is the void pointer reference from the low-level API. We just used it as the key in a dictionary of inputs on the high-level side. Worked out fine. How do the other OS's do it?

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Trent Gamblin
Member #261
April 2000
avatar

Touches are supposed to be tracked by mouse button. That may be 5.1 though. I haven't tested it.

23yrold3yrold
Member #1,134
March 2001
avatar

I can track touches by mouse ups and mouse downs, yes. But are you saying that the mouse.button variable itself is the unique identifier? Because that would actually make sense ...

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Trent Gamblin
Member #261
April 2000
avatar

Yes, that's what I'm saying.

23yrold3yrold
Member #1,134
March 2001
avatar

I'll check that out. What's the maximum number of touches it can track?

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Trent Gamblin
Member #261
April 2000
avatar

I'm not sure but I think the iPhone is (was?) only reports 5.

Michał Cichoń
Member #11,736
March 2010

iPhone and iPod report up to 5 touches. iPad up to 11 (why?).

Allegro 5.1 track touches. Treat button number as Touch ID (it is indexed from 1 not from zero).
Tested and working like a charm.

Also Window 7 may receive touch support soon. That will probably force us to differentiate between touches and mouse events.

"God starts from scratch too"
Windows Allegro Build Repo: http://targonski.nazwa.pl/thedmd/allegro/

Neil Walker
Member #210
April 2000
avatar

Probably a poor idea, but to save adding yet another input device, why not allow multiple mice (as you can with joypads) then each touch point would be a 'new' mouse.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Arthur Kalliokoski
Second in Command
February 2005
avatar

why not allow multiple mice (as you can with joypads) then each touch point would be a 'new' mouse.

Sounds like a good idea to me! You might have to flip-flop a bit as to which is the "current mouse", but that sounds doable as well.

They all watch too much MSNBC... they get ideas.

Michał Cichoń
Member #11,736
March 2010

This poor idea is implemented in similar way in iOS, Mac OS X and Windows 7. I do not understand why Allegro should try to be smarter. If user need to unify input, he is free to do so. Oversimplification do not server well for general purpose library.

If Allegro get support for touch interface on Windows then from where the user will know something was clicked by right button of the mouse? Maybe that was second touch? iOS doesn't not have this problem for now, because it support only touch-based devices. Latter Apple designers will have to face very same problem, because iOS is supposed to be Apple desktop system instead of Mac OS X.

The bottom line is, sending touch events trough mouse related messages is not a reliable solution. This is different kind of input and need to be treated that way.

"God starts from scratch too"
Windows Allegro Build Repo: http://targonski.nazwa.pl/thedmd/allegro/

X-G
Member #856
December 2000
avatar

I agree that mouse and touch need to be separated. They are fundamentally different kinds of input. The only thing they share in common is their ability to indicate X/Y positions on the screen.

Consider a game that supports both mouse and touch input. It is entirely plausible for the semantics to be somewhat different between the two, and the program may want to detect this and offer different functionality. But if touch events transparently look like mouse events, this is not possible.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Elias
Member #358
May 2000

On the other hand for games which do not differentiate (e.g. all you do is press buttons) it would be very nice to not have to add in special touch handling just to make it work.

--
"Either help out or stop whining" - Evert

Matthew Leverton
Supreme Loser
January 1999
avatar

The simple solution would be to have Allegro by default generate mouse button events for touches. If the programmer wants touch events, then he could explicitly detach the two.

By enabling them, it could also enable touch "gestures" like pinching, etc. It would be nice (although not necessary) if Allegro detected those events on devices that didn't natively support it.

Neil Walker
Member #210
April 2000
avatar

X-G said:

They are fundamentally different kinds of input.

I wouldn't say that: They are all pointing devices of some sort.

On my laptop I have a mouse pointer that is controlled by my mouse, my track pad and my nipple - they are all different but equally are all the same. The same way if you have a trackball you pretend it's a mouse and even a light-pen you could argue is just another mouse.

Quote:

the program may want to detect this and offer different functionality

Joysticks have a FLAGS struct for analogue/digital, just add one to the mouse to signify it's type, e.g. mouse, multi-touch, trackball, pen, etc. This would allow the gestures matthew said, also for example use the multi-touch with the mouse to give a wider drag area.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Michał Cichoń
Member #11,736
March 2010

Elias said:

On the other hand for games which do not differentiate (e.g. all you do is press buttons) it would be very nice to not have to add in special touch handling just to make it work.

That would be nice if you trying to maximize backward compatibility. Which is not an issue to Allegro ATM.
Multi-touch support is a new (recently popularized) feature. Lack of support for it is not a bug. Cleaner solution is to add yet another input source, events for it. This for the API side.
In the spirit of backward compatibility there may be an entry in allegro.cfg which enable mouse emulation by touch when stated explicitly.

Tablets, trackballs, etc. are pointing devices like a mouse. This is not odd, because the intention was to provide better or more natural control over the pointer.

Multi-touch is quite new philosophy where you have multiple pointers to control. They are not like mouse, because you do not use two or more mice, you're using fingers and you're actually touching device.
Frankly, did someone used two mice in one PC for other purpose than to annoy other user? Touchpad and mouse works, because they are controlled by you and therefore you do not have a conflict.

If someone invent thought-control input, Allegro will (or at least should) adopt to it. Mapping to mouse or keyboard may be a good idea to keep the compatibility for some time, but a new API should be provided to take full advantage of the feature, not only scraps.

"God starts from scratch too"
Windows Allegro Build Repo: http://targonski.nazwa.pl/thedmd/allegro/

Aaron Santiago
Member #12,074
June 2010
avatar

This poor idea is implemented in similar way in iOS, Mac OS X and Windows 7. I do not understand why Allegro should try to be smarter. If user need to unify input, he is free to do so. Oversimplification do not server well for general purpose library.

If Allegro get support for touch interface on Windows then from where the user will know something was clicked by right button of the mouse? Maybe that was second touch? iOS doesn't not have this problem for now, because it support only touch-based devices. Latter Apple designers will have to face very same problem, because iOS is supposed to be Apple desktop system instead of Mac OS X.

The bottom line is, sending touch events trough mouse related messages is not a reliable solution. This is different kind of input and need to be treated that way.

What if:
Allegro treated touch input LIKE mouse input, except:
-The initial touch would be the "mouse" and
-Any other touches were reported with x and y relative to the "mouse."
This way, you can get multiple touch presses without interfering with the mouse simply by checking if the other touches exist. This would also make it easier for multitouch gestures to be implemented, seeing how they would be the main use for multitouch anyway.

Michał Cichoń
Member #11,736
March 2010

So any other touch will be relative to the first one? Simple is better. If touch location will be dependent from other variable (in this case first touch location) this is not real simplification. You then have to remember position of first touch to compute position of remaining. What advantage does it have?

Gesture interpreter do not need help in the form of relative touches. It can very easily calculate them if needed.

The point is to do not hack Allegro to support a feature in some non-intuitive way, but provide and API to do this properly. To keep compatibility a mouse emulation implemented using touches may be provided. May be, because this is very simple task to map touch events into mouse input in application itself. More, if Allegro is a basis for game engine, this is preferred way.

"God starts from scratch too"
Windows Allegro Build Repo: http://targonski.nazwa.pl/thedmd/allegro/

X-G
Member #856
December 2000
avatar

There's nothing fundamentally wrong with providing an emulation layer that transforms touch events to mouse events. However, I think this should be something that needs to be explicitly requested through a simple API call like "al_map_touch_events_to_mouse_events();" or something. The default should be as simple as possible, namely no crossing of the streams. Explicit is better than implicit.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Elias
Member #358
May 2000

X-G said:

Explicit is better than implicit.

Couldn't agree more to that in general. But here the idea is that a lot of stuff (e.g. most of the A5 examples, but also any button based games) could work fine without any IPhone-specific code if the touch input would emulate a mouse by default. If you want to make IOS specific changes it's easy to simply use the touch events instead (and turn off the mouse emulation, but probably no need for that - just ignore the events).

But I'm also not opposed a lot to separating mouse/touch events. My main reason for wanting this emulations really is just the examples... makes it much easier to test them all on iphone/ipad. If we separate the touch events I'll just add touch event handling to some examples - should only make them a bit longer, but still keep them readable.

The current situation is very bad in any case. We have no emulation (I had put it in but it was broken as it seems to have interfered with actual touch reporting) and no touch events. So worse of both of the above solutions :P

--
"Either help out or stop whining" - Evert

 1   2 


Go to: