Porting an old TCP/XML Project (TouchEvent)
Porting an old TouchEvent based project is actually pretty easy.
Fist you have to add following import statements:
-
import org.tuio.tuio.TuioClient;
-
import org.tuio.osc.*;
-
import org.tuio.legacy.*;
You will need the TuioClient class to actually use the new library. The osc part is needed for the Connectors that connect the TuioClient to the TuioTracker or Bridge. The legacy package delivers all the classes needed to maintain the Tuio interfaces your old code is built upon.
The next step is to remove or comment the old Tuio init line.
-
//TUIO.init(...);
Now you have to insert the lines to initialize a new TuioClient.
-
var tc:TuioClient = new TuioClient(new LCConnector());
-
TuioLegacyListener.init(stage, tc);
The first line creates a new TuioClient with a LCConnector for a LocalConnection transmission. Of course you can use any implementation of the IOSCConnector interface.
The second line initializes the TuioLegacyListener that implements the ITuioListener interface and dispatches TouchEvents just like the old TUIO class did.
Please note that the legacy package is still under development and not yet complete. So if you have any trouble getting your project to run with our library let us know.
November 8th, 2009 - 18:50
Can i use TouchEvents with this method?
November 8th, 2009 - 23:57
Yes that is what this guide is about
I should maybe mention that somwhere in the article x)
November 10th, 2009 - 11:47
I’m new to Multitouch Dev
Are the RotatableScalable Class compatible with this? I tried to replace the TouchEvent Class with the tuio.legacy.TouchEvent but i get errors at the TUIO Class which the RotatableScalable use.
November 10th, 2009 - 12:02
Well in order to make the RotatableScalable class “compatible” you would have to change all the calls to TUIO into TuioLegacyListener within that class.
November 10th, 2009 - 14:47
That works for me! Thanks
November 30th, 2009 - 12:47
Im I wrong or LCListener should be LCConnector?
November 30th, 2009 - 22:00
you are right. thx! already corrected.
December 2nd, 2009 - 14:03
I didn’t manage to make an old XML project work with the change you described above. I have a couple of questions about that. First, if I use the callbacks how can I detect a certain multitouch event. I mean in the example that you provided the application only receives information about where on the screen there is a touch and displays some points. How can I receive multitouch events using the callbacks or is it possible at all? For example PINVH_IN, PINCH_OUT etc. I will be really glad if I can do such things.
December 2nd, 2009 - 15:43
As noted above in the article the legacy stuff is still in a very early phase, so if you could provide some information what did and what didn’t work, that would be helping to improve things.
On your questions:
- If you use callbacks you can’t detect events because that is what the callback interface is all about -> no need for events. So this is mainly thought for developers who want to use our library for buidling their own libraries on.
- stuff like PINCH_IN and PINCH_OUT are higher level multitouch events that are currently not implemented in the library.
The event stuff is, as I noted in the blog and in the mai library article still under development and will be released in the upcoming months. Probably somwhere around new year.
December 2nd, 2009 - 17:04
Here is the problem: There is a simple multitouch application called Bloom( source and demo provided here: http://sethsandler.com/audiotouch/bloom-generative-music-application/ ). It works with the old TUIO.init(…) method and can be easily tested with the simulator SimTouch( http://code.google.com/p/simtouch/ ) and a server called selectserver.exe ( http://www.rshields.com/?q=node/116 ). When I try to change the TUIO.init(…) with
var tc:TuioClient = new TuioClient(new LCConnector());
TuioLegacyListener.init(stage, tc);
together with QMTSim and udp-flashlc-bridge, nothing happens. I don’t even know if something should happen( I wonder how the events passed by QMTSim to the bridge and then sent to the application will be interpreted as TouchEvent events. Could you please explain further if I have misunderstood something or propose a solution. I will be really thankful since I really want to use the LCConnection instead of TUIO.init but together with the legacy TouchEvent.
December 2nd, 2009 - 20:47
Thanks! What seems to be the problem is that the CLICK event isn’t dispatched yet by the TuioLegacyListener which is needed by the bloom app. If you change that to MOUSE_DOWN or MOUSE_UP it should work fine for now but this will be corrected for sure in future releases.
December 2nd, 2009 - 22:21
Thank you! You did an excellent job with that library. I am looking forward to the next releases!
December 7th, 2009 - 13:57
I have one more question:which events are dispatched by the TuioLegacyListener in this release( for example the CLICK is not yet dispatched but MOUSE_DOWN and MOUSE_UP are )?
December 7th, 2009 - 15:25
Currently MOUSE_UP, MOUSE_DOWN and MOUSE_OVER are dispatched in a way equal to the old library.
December 7th, 2009 - 15:35
And what about MOUSE_MOVE… The truth is that I really want to use LCConnectin for my project and I can fake the CLICK event with MOUSE_DOWN and MOUSE_UP but I don’t know how to fake MOUSE_MOVE. Can you give me any ideas since I really need at least MOUSE_MOVE( MOUSE_OUT will be very helpful too).
December 7th, 2009 - 15:55
To be honest the MOUSE_MOVE is also dispatched but the behaviour isn’t correctly implemented yet because there is no check if the point actually moved. So depending on the tracker it could work just fine. Maybe just try it out and let me know if it is acceptable for now or if a real fix is needed.
December 7th, 2009 - 16:47
MOUSE_MOVE doesn’t work for me ( I use QMTSim simulator ).
December 7th, 2009 - 16:53
okay we’ll look into it.
December 10th, 2009 - 17:53
Is there a way to get width and height of the TouchEvent?
December 10th, 2009 - 20:52
Currently there isn’t any because the TuioLegacyListener works with Tuio’s 2Dcur profile which only tracks coordinates. I’ll look into changing that fpr future releases since the original TUIO class seems to have used some mishmash of 2Dcur and 2Dobj
December 12th, 2009 - 15:36
It is difficult to change that?
December 12th, 2009 - 17:49
no it isn’t really. You’d basically have to copy all the stuff from the cursor handlers into the object handlers add the width and height stuff, change some types and see if it compiles/works x) So I guess it is very likely that this will be in the next release
July 20th, 2010 - 15:35
Hi gimmix, and thanks for your great work.
I’ve been trying to get the RotatableScalable class to work with your library in order to get UDP support, but I’m facing a few problems.
I’ve managed to get touch inputs to trigger legacy TouchEvents, but there’s an important difference between the old TUIO.as and TuioLegacyListener.as: the method getObjectById is static in the old class, but not in the new one. TUIO.as references an also static OBJECT_ARRAY, but in your class the objectArray is created inside that method, referencing the non-static tuioClient property. This is obviously not possible with a static method call, and the RotatableScalable class does not have access to the tuioClient object created by the “new TuioClient” call.
Not sure if I was clear enough, but I’m kinda confused here…
Thanks again!
July 20th, 2010 - 16:23
Got it! In case anyone else is having the same issue, just need to add a property to the RotatableScalable class and call “newProperty = TuioLegacyListener.getInstance()”.
Now just switch your references to the static TUIO methods like “TUIO.getObjectById()” to “newProperty.getObjectById()”.
Works great, and by the looks of it, UDP already seems much smoother than the old XML based communication.
Cheers
July 20th, 2010 - 19:06
I am glad you were able to solve your problem and thanks for posting the solution.
March 29th, 2011 - 13:49
hi gimmix , i have tried those progress in the article , the lcConnector and UDPConnector is going well and the same as the RotatableScalable class stuff,
but there is a problem with me that is i can connect with the TCPConnector
but it appear nothing on screen …..but when i change to LC and UDP it works well
do u know what is wrong?…thx
March 29th, 2011 - 19:17
What tracker / bridge are you using and how do you initialize the TCPConnector?
March 30th, 2011 - 08:13
hi hi , when it comes to TCPConnector , i dont use bridge , should i ?
and the tracker is ccv 1.2 and we transmit tcp 3000 port
and i initialize with new TCPConnector(“127.0.0.1″,3000) or i just try to change the original port from 3333 to 3000 inside the TCPConnector class,thx
March 30th, 2011 - 10:18
I see, well CCV doesn’t support binary Tuio via TCP, even though they have a mode called “binary TCP”, but this mode sends their own protocol. I would suggest using UDP anyway because that will give you the best performance.
March 30th, 2011 - 10:37
thx a lot for response so rapidly ,very appreciate and help me so much,
so i might use UDP now , but can i ask one more question is that what tracker
do u use for the TCPConnector as it can support binary tuio or in what way i can
make TCPConnector work ,…..thx a lot again…..^^
March 30th, 2011 - 21:55
The TCPConnector should work with reacTIVision. I use TuioPad on the iPad for testing which works just fine. Another option would be using CCV in udp mode and a udp -> tcp or udp -> lc (LCConnector) bridge. e.g. udp-tcp-bridge by memo akten or udp-flashlc-bridge by georg kaindl -> http://www.tuio.org/?software at the bottom right
March 31st, 2011 - 04:33
yes it works,just as u said, thx a lot!!……^^
April 8th, 2011 - 12:24
hihi now i use this lagency for doing some project and find out one problem
the mouse_out event disappear ,and when i compare the old TUIO class ,there is a internal function called notifyremoved and dispatch mouse_out event but the new TuiolagencyListener class doesnt…….so ……what can i do if i need mouse_up and mouse_out Event to listen the same function ……..THX
April 8th, 2011 - 21:16
Which version of the library are you using? The mouse_out and mouse_over should work with the TuioLegacyListener in the latest release and the current svn version.
If you want to listen to both you simply have to use the same function when calling addEventListener.
April 9th, 2011 - 16:23
hello master!! ya i use 0.71 version ,ok i will check the google code!! and find out if it can use those events ……thx….
August 1st, 2011 - 17:36
I adapted the AS3 classes from the Nuigroup to work with the legacy implementation of tuio-as3. you can find them here: http://code.google.com/p/tuio-as3/downloads/detail?name=Touchlib_TUIO_AS3.zip