Table Of Contents

TUIO is the de facto standard network protocol for the transmission of
touch and fiducial information between a server and a client. To learn
more about TUIO (which is itself based on the OSC protocol), please
refer to http://tuio.org – The specification should be of special
interest.

fromkivy.appimportAppfromkivy.configimportConfigclassTestApp(App):defbuild(self):Config.set('input','multitouchscreen1','tuio,0.0.0.0:3333')# You can also add a second TUIO listener# Config.set('input', 'source2', 'tuio,0.0.0.0:3334')# Then do the usual things# ...return

The TUIO provider listens to a socket and handles some of the incoming
OSC messages:

/tuio/2Dcur

/tuio/2Dobj

You can easily extend the provider to handle new TUIO paths like so:

# Create a class to handle the new TUIO type/path# Replace NEWPATH with the pathname you want to handleclassTuioNEWPATHMotionEvent(MotionEvent):def__init__(self,id,args):super(TuioNEWPATHMotionEvent,self).__init__(id,args)defdepack(self,args):# In this method, implement 'unpacking' for the received# arguments. you basically translate from TUIO args to Kivy# MotionEvent variables. If all you receive are x and y# values, you can do it like this:iflen(args)==2:self.sx,self.sy=argsself.profile=('pos',)self.sy=1-self.sysuper(TuioNEWPATHMotionEvent,self).depack(args)# Register it with the TUIO MotionEvent provider.# You obviously need to replace the PATH placeholders appropriately.TuioMotionEventProvider.register('/tuio/PATH',TuioNEWPATHMotionEvent)

Note

The class name is of no technical importance. Your class will be
associated with the path that you pass to the register()
function. To keep things simple, you should name your class after the
path that it handles, though.