ofxUI and TUIO

Hi there,

Some weeks ago i posted this thread (http://forum.openframeworks.cc/t/ofxui-and-tuio/11155/0) asking for some advice on how to integrate ofxUI in multitouch applications. After some (ok, many) hours of figuring out how listeners and templates work (this is my first time in OF!) i realized that no templates nor listeners were needed (bummer), and…
in short, here is the outline of what i did to make it work (only for cursors, no objects!):

  1. ofxUI supports MT events, but only when compiled for iOS. I commented all the preprocessor directives like this one:

Some care should be taken here, as one should also comment corresponding #endifs.

  1. I used a TUIO wrapper. There are some out-of-date versions around. I got the wrapper from here (https://github.com/naychrist/ofxTuioClient-ofxMultiTouchObject-example).

  2. I made the listeners of the TUIO wrapper trigger ofxUI events. This means that in the tuioCursorDown listener, one should trigger the onTouchDown function from the canvas (same for onTouchUp and onTouchMoved functions). The onTouchDown function is like this:

void onTouchDown(ofTouchEventArgs &data)  

and I had no idea on how to construct a ofTouchEventArgs object, so i decided to tweak the the function so it could get TuioCursor arguments:

void onTouchDown(TuioCursor &data)  

The argument is passed to some underlying functions so their argument type should also be changed.

  1. The touchDown function from ofxUICanvas will call the touchDown function from ofxUIWidget (argument type should be changed since it will now get a TuioCursor ). In the latter, the mousePressed function should be called like this:
mouseReleased(touch.getScreenX(ofGetWidth()), touch.getScreenY(ofGetHeight()), 0);  

so the position is rescaled (tuio data from the simulator is in the range [0,1]).

Thats how it worked for me! Hope it helps anyone…

1 Like

Later I simply wrote a constructor for the ofEventTouchArgs class and this avoided the hassle of changing ofEventTouchArgs by TuioCursor.

Hello Sergio,

I 'm new on openframeworks and I wonder to make a little application with TuIOl, like I’done before with Pure Data…
But I have a big problem to bind ofxUI and TUIO, please, maybe can you send me an exemple, or some code to help ?
Thank you very much for your answer !
Best Regards