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!):
- 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.
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).
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.
- 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…