Game Development Community

Multi-touch input is not implemented!! (iTGB 1.0)

by Alex Rice · in iTorque 2D · 09/30/2008 (10:15 pm) · 15 replies

It appears to me that multi-touch input is not implemented.

You are taking the UIEvent and UITouch events, stripping all the context, and injecting the touch's screen coordinates into plain old mouseDown, mouseMoved and mouseUp events. This kind of misses the point of having a multi-touch input device.

Multi-touch cannot be forced into traditional mouse-input event handling frameworks. This is a fundamental issue in how the whole UIKit framework for iPhone was designed to support multi-touch. See platformiPhone/iPhoneOGLVideo.mm for where the context is being discarded. See "Handling Multi-Touch Events" in the iPhone OS programming guide for background information.

Accelerometer events appear to be translated to Joystick input which makes sense I guess.

However the multi-touch issue really concerns me though, as that is a major feature that I want to use in iphone games. Please correct me if I am wrong about this; I have only been looking at the source code for a couple of hours.

Alex

#1
09/30/2008 (10:47 pm)
Product page says:
"GarageGames has provides additional iPhone-specific functionality for Torque with:
* -Multi-Touch Input Support
* -Touch Screen Gesture Recognition
* -iPhone Optimized Compressed Textures
* -Advanced Character and Shape Animations"
#2
10/01/2008 (12:05 pm)
Multi-touch is implemented, for some reason, the multi-touch example did not make it out with this release. It will be updated shortly.
#3
10/01/2008 (12:30 pm)
OK looking forward to it then. I am curious how extensible (or not) is the Torque events subsystem. Seems like a new class of input events is required, not simply mapping touch coordinates into mouse clicks!

Paul if you don't mind me asking: what is your affiliation with Garagegames? Are you one of the iTGB developers? Employed by Garagegames? Or another iTGB user.

Thanks
#4
10/01/2008 (12:37 pm)
We are the iTGB developers porting TGB to iPhone.

At the moment we simply mapped the touches to mouse events and the accellerometers to joystick events, in theory that should be easily changed by the user to do what ever they want with them.
#5
10/01/2008 (12:41 pm)
Please explain this theory. Multi touch isn't implemented if you simply mapped the touches to mouse events. The iPhone OS programming guide explains why mouseDown, mouseMoved and mouseUp does not work in a multi-touch environment.
#6
10/02/2008 (11:59 am)
Paul, multi-touch aside something broke my mini-game test between 0.8.5 and 1.0 for both the simulator and iPhone. It almost appears as if mouseUp events aren't read, like some of my basic behavior driven buttons have stopped working.

A couple thoughts: first, is there any console.log file written by the game in the simulator or phone? I couldn't find it and it's hard to debug what's up. Or, it it possible to access the console window inside the simulator or phone?

Second, I'd like to send you my test mini-game so you can see these issues first hand, and I think it would be a good simple test case as it uses light physics, particles, animation. I can be reached at kwik [at] skunkstudios [dot] com if you want the demo project.
#7
10/02/2008 (4:20 pm)
Paul, I would also like to hear more about how to implement this.
#8
10/02/2008 (5:14 pm)
Thanks for the great feedback everyone.

Multi-touch _is_ implemented and we have a demo for it, at the moment, you guys don't...
We are making sure there aren't any obvious issues this time for a 1.0.1 release, expect this soon.

At the moment touches are set to mouse events and do work 100%, multi-touches are sent as callbacks to script to be handled separately, we are investigating putting in a new event type to handle them.
#9
11/18/2008 (2:57 am)
I'm working on a game using multi-touch at the moment so I'm keen to hear how you plan on implementing it.

If I press 2 buttons at the same time, only 1 of them gets an 'onMouseDown' callback.

If I press somewhere on the screen (not on a specific button) and hold my finger down, the press on a button, the second press does not register.
#10
11/18/2008 (3:23 pm)
You don't get any onMouseDown callback for touches.
Touches are handled through the touches.

You can already give it a go if you checkout the iPhoneTest project which implements multitouch.
#11
11/18/2008 (3:27 pm)
Ah I see, I've just been using regular mouse events and it's been working fine as long as there's only 1 touch at a time. Thanks Marc.
#12
11/18/2008 (4:04 pm)
Thats the good think. Touch 1 is also redirected to the mouse callbacks which makes straight ports possible up to a given point and actually also makes some stuff simpler :)
#13
08/20/2009 (5:05 am)
Can someone direct me to the iPhoneTest project that Marc is talking about. I am looking at the documentation that came with iTGB, and it doesn't seem to be there in it. I need an example for multitouch in iTGB. If there is any other resource that illustrates that, please mention that too. Thanks.
#14
08/20/2009 (9:48 am)
TGB Directory\games\iPhoneTest
#15
08/22/2009 (9:23 pm)
Yes look at the iPhoneTest code. It's VERY easy to use. It stores touch info in an array and you simply iterate through the array to handle touches. It's not perfect but it works for simple multi touch applications. I implemented a coin-op style joystick and buttons no problemo using the built-in touch handlers. Basically, I test to see if the touch is in the area of the joystick and if it is then I determine which sprite frame to display and which joystick direction handler to call. I use regular mouse events for the buttons and ignore those touches and touches on any other area of the display. Here's the example showing how to get the touch data:

function oniPhoneTouchDown( %touchCount, %touchX, %touchY ) {

for( %i = 0; %i < %touchCount; %i++ ) {
%screenPos = getWord( %touchX, %i ) SPC getWord( %touchY, %i );
%worldPos = sceneWindow2D.getWorldPoint( %screenPos );
}

}


function oniPhoneTouchUp( %touchCount, %touchX, %touchY ) {
for( %i = 0; %i < %touchCount; %i++ ) {
%screenPos = getWord( %touchX, %i ) SPC getWord( %touchY, %i );
%worldPos = sceneWindow2D.getWorldPoint( %screenPos );
}
}


function oniPhoneTouchMove( %touchCount, %touchX, %touchY ) {
for( %i = 0; %i < %touchCount; %i++ ) {
%screenPos = getWord( %touchX, %i ) SPC getWord( %touchY, %i );
%worldPos = sceneWindow2D.getWorldPoint( %screenPos );
}
}