This is small code examples of how to drive a mouse using a TUIO device.
- One finger is for mouse move.
- Two figers is for left-click. Mouse down is maintained while the second finger is pressed.
- Three fingers is right-click. Mouse up is immediately called, no need to keep finger down.
To use the mouse driver:
- git clone https://github.com/artistech-inc/tuio-mouse-driver.git
- cd tuio-mouse-driver
- git checkout v1.1.3
- mvn package
- java -jar target/tuio-mouse-driver-1.1.3.jar
Also available in this module is the ability to subscribe to TUIO broadcasts via ZeroMQ.
ZeroMQ support is dependent on available native libraries. When compiling, maven will search for these files and provide any jar dependencies suitable.
- Linux:
- Searches for /usr/lib/libjzmq.so
- If this file exists, the dependency jar jzmq.jar is imported.
- If this file is missing, the dependency jar jeromq.jar is imported.
- Mac OS X:
- Searches for /usr/lib/libjzmq.dynlib
- If this file exists, the dependency jar jzmq.jar is imported.
- If this file is missing, the dependency jar jeromq.jar is imported.
The two jar files provide identical support. However, the jzmq.jar file uses JNI to provide faster support where jeromq.jar is a pure java implementation. The jzmq.jar requires libjzmq.so which in turn requires libzmq.so to be available.
Transmission of the TUIO objects via ZeroMQ is provided by 3 different mechanisms.
- Java Object Serialization
- JSON Serialization (using Jackson)
- Google Protocol Buffer
Since this is the subscribing client, it is unknown how the object has been serialized by the publisher, and so all 3 mechanisms will be attempted for deserialization.
To use the ZeroMqMouse driver:
- git clone https://github.com/artistech-inc/tuio-mouse-driver.git
- cd tuio-mouse-driver
- git checkout v1.1.3
- mvn package
- java -cp target/tuio-mouse-driver-1.1.3.jar com.artistech.tuio.mouse.ZeroMqMouse -z <ZMQ_PUB_HOST:PORT>
If using the companion tuio-zeromq-publish application, the default port used is 5565, so invokation would look similar to:
java -cp target/tuio-mouse-driver-1.1.3.jar com.artistech.tuio.mouse.ZeroMqMouse -z localhost:5565