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触摸。

depack(args)[源代码]

args 解包为类的属性。

class kivy.input.providers.tuio.Tuio2dObjMotionEvent(*args, **kwargs)[源代码]

基类:TuioMotionEvent

一个2D对象TUIO对象。

depack(args)[源代码]

args 解包为类的属性。

class kivy.input.providers.tuio.TuioMotionEventProvider(device, args)[源代码]

基类:MotionEventProvider

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() 函数的路径相关联。不过,为了简单起见,你应该根据它处理的路径来命名你的类。

static create(oscpath, **kwargs)[源代码]

从TUIO路径创建触摸事件

static register(oscpath, classname)[源代码]

在TUIO提供程序中注册一个新的路径以进行处理。

start()[源代码]

启动TUIO提供程序。

stop()[源代码]

停止TUIO提供程序。

static unregister(oscpath, classname)[源代码]

在TUIO提供程序中注销一个路径,以停止处理该路径。

update(dispatch_fn)[源代码]

更新TUIO提供者(从队列中弹出事件)