Code examples

Where we have been asked to supply useful code examples we have taken a copy below to aid the understanding of the API interface.

 Q How to retrieve the currently designated TUIO port?
 A The UPDD setting name is "tuio port". If the global setting "tuio displays have own host" is 0 or undefined then "tuio port" is a global setting. Otherwise you have to specify a device index to get the port for that device. If "tuio port" isn't specified then it defaults to port 3333 (which is the standard TUIO port).

Here's a quick function that demonstrates how to get the port for a device:

int32_t tuioPortForDevice(HTBDEVICE device) {
    int32_t port = 0;
    int32_t displaysHaveOwnHost = 0;
    bool success = TBApiGetSettingAsInt(0, "tuio displays have own host", &displaysHaveOwnHost);
    if (success && displaysHaveOwnHost) {
        success = TBApiGetSettingAsInt(device, "tuio port", &port);
    } else {
        success = TBApiGetSettingAsInt(0, "tuio port", &port);
    if (!success || port == 0) {
        port = 3333;
    return port;

Also note that you can launch UPDD TUIO with command line arguments that override the port number so that UPDD settings aren't used. If this is the case then there's no way to get the port number using the UPDD API.