目录
TUIO 输入提供器¶
TUIO 是用于在服务器和客户端之间传输触摸及基准点信息的实际标准网络协议。要了解更多关于 TUIO(其本身基于 OSC 协议)的信息,请参阅 http://tuio.org —— 该规范应特别关注。
在 config.ini 中配置一个 TUIO 提供者。¶
TUIO 提供程序可以在配置文件的 [input] 部分中进行配置:
[input]
# name = tuio,<ip>:<port>
multitouchtable = tuio,192.168.0.1:3333
在应用程序中配置一个TUIO提供者。¶
您必须在应用程序运行之前添加提供程序,如下所示:
from kivy.app import App
from kivy.config import Config
class TestApp(App):
def build(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
- class kivy.input.providers.tuio.Tuio2dCurMotionEvent(*args, **kwargs)[源代码]¶
基类:
TuioMotionEvent一个2D曲线TUIO触摸。
- class kivy.input.providers.tuio.Tuio2dObjMotionEvent(*args, **kwargs)[源代码]¶
基类:
TuioMotionEvent一个2D对象TUIO对象。
- class kivy.input.providers.tuio.TuioMotionEventProvider(device, args)[源代码]¶
-
TUIO 提供程序监听一个套接字,并处理部分传入的 OSC 消息:
/tuio/2Dcur
/tuio/2Dobj
你可以轻松地扩展提供者来处理新的TUIO路径,如下所示:
# Create a class to handle the new TUIO type/path # Replace NEWPATH with the pathname you want to handle class TuioNEWPATHMotionEvent(MotionEvent): def depack(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: if len(args) == 2: self.sx, self.sy = args self.profile = ('pos', ) self.sy = 1 - self.sy super().depack(args) # Register it with the TUIO MotionEvent provider. # You obviously need to replace the PATH placeholders appropriately. TuioMotionEventProvider.register('/tuio/PATH', TuioNEWPATHMotionEvent)
备注
类名在技术上并不重要。你的类将与传递给
register()函数的路径相关联。不过,为了简单起见,你应该根据它处理的路径来命名你的类。