Tuio Flash Blog

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:

  1. import org.tuio.tuio.TuioClient;
  2. import org.tuio.osc.*;
  3. 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.

  1. //TUIO.init(...);

Now you have to insert the lines to initialize a new TuioClient.

  1. var tc:TuioClient = new TuioClient(new LCConnector());
  2. 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.

Comments (25) Trackbacks (0)
  1. Can i use TouchEvents with this method?

  2. Yes that is what this guide is about ;) I should maybe mention that somwhere in the article x)

  3. 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.

  4. Well in order to make the RotatableScalable class “compatible” you would have to change all the calls to TUIO into TuioLegacyListener within that class.

  5. That works for me! Thanks :)

  6. Im I wrong or LCListener should be LCConnector?

  7. you are right. thx! already corrected.

  8. 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.

  9. 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.

  10. 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.

  11. 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.

  12. Thank you! You did an excellent job with that library. I am looking forward to the next releases!

  13. 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 )?

  14. Currently MOUSE_UP, MOUSE_DOWN and MOUSE_OVER are dispatched in a way equal to the old library.

  15. 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).

  16. 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.

  17. MOUSE_MOVE doesn’t work for me ( I use QMTSim simulator ).

  18. okay we’ll look into it.

  19. Is there a way to get width and height of the TouchEvent?

  20. 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

  21. It is difficult to change that? ;)

  22. 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 ;)

  23. 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!

  24. 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

  25. I am glad you were able to solve your problem and thanks for posting the solution.


Leave a comment


No trackbacks yet.