Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions Runtime/InputSources/TuioInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using TouchScript.Utils;
using TuioNet.Common;
using UnityEngine;
using UnityEngine.Serialization;

namespace TouchScript.InputSources
{
Expand All @@ -29,6 +28,15 @@ public class TuioInput : InputSource

private ITuioInput _tuioInput;

public TuioConnectionType ConnectionType
{
get => _connectionType;
set
{
_connectionType = value;
}
}

public Vector2Int Resolution { get; private set; }

public int UdpPort
Expand All @@ -37,7 +45,7 @@ public int UdpPort
set
{
if(value < 0) return;
UdpPort = value;
_udpPort = value;
}
}

Expand All @@ -53,6 +61,24 @@ public string IpAddress
}
}

public int Port
{
get
{
return _connectionType switch
{
TuioConnectionType.Websocket => _tuioVersion switch
{
TuioVersion.Tuio11 => 3333,
TuioVersion.Tuio20 => 3343,
_ => throw new ArgumentOutOfRangeException($"{typeof(TuioVersion)} has no value of {_tuioVersion}.")
},
TuioConnectionType.UDP => _udpPort,
_ => throw new ArgumentOutOfRangeException($"{typeof(TuioConnectionType)} has no value of {_connectionType}."),
};
}
}

public ITuioDispatcher TuioDispatcher
{
get
Expand Down Expand Up @@ -88,18 +114,7 @@ public void Reinit()
protected override void Init()
{
if(_isInitialized) return;
var port = UdpPort;
if (_connectionType == TuioConnectionType.Websocket)
{
port = _tuioVersion switch
{
TuioVersion.Tuio11 => 3333,
TuioVersion.Tuio20 => 3343,
_ => throw new ArgumentOutOfRangeException($"{typeof(TuioVersion)} has no value of {_tuioVersion}.")
};
}

_session = new TuioSession(_tuioVersion, _connectionType, IpAddress, port, false);
_session = new TuioSession(_tuioVersion, _connectionType, IpAddress, Port, false);
_isInitialized = true;
}

Expand Down