-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTUIO.ck
135 lines (117 loc) · 4.5 KB
/
TUIO.ck
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
public class TUIO
{
OscRecv listener;
3333 => int Port;
10 => int NumTouches;
-1 => int FrameSeq;
[false] @=> int updating[];
Touch @ TouchList;
0 => int debug;
function void init(Touch CustomTouchObject)
{
CustomTouchObject @=> TouchList;
}
function void init(Touch CustomTouchObject, int PortNumber)
{
init(CustomTouchObject);
PortNumber => Port;
}
function void init(Touch CustomTouchObject, int PortNumber, int NumberOfTouches)
{
init(CustomTouchObject, NumberOfTouches);
NumberOfTouches => NumTouches;
}
function void startListening()
{
Port => listener.port;
listener.listen();
"/tuio/2Dcur,s" => string alivestring;
for(0 => int i; i < NumTouches; i++){
alivestring + ",i" => alivestring;
spork ~ aliveListener(listener.event(alivestring),i+1,updating);
}
spork ~ setListener(listener.event("/tuio/2Dcur,s,i,f,f,f,f,f"),updating);
}
function void aliveListener(OscEvent event, int NumIDs, int updating[])
{
if(debug > 1)
<<<"TUIO.ck, aliveListener(): listener started",NumIDs>>>;
string message;
int stopUpdating;
while(true){
event => now;
false => stopUpdating;
if(debug > 5)
<<<"TUIO.ck, aliveListener(): Alive event",NumIDs>>>;
while(event.nextMsg() != 0){
event.getString() => message;
if(debug > 6)
<<<"TUIO.ck, aliveListener()",message>>>;
if(message == "fseq"){
if(!stopUpdating){
if(TouchList == NULL && debug > 2)
<<<"TUIO.ck, aliveListener(): Null TouchList, fuck.",TouchList>>>;
false => updating[0];
TouchList.cleanupTouches(FrameSeq) @=> TouchList;
event.getInt() => FrameSeq;
true => stopUpdating;//prevents multiple fseqs from the same event.
if(debug > 5)
<<<"TUIO.ck, aliveListener(): fseq:",FrameSeq>>>;
}
}
else if(message == "alive"){
if(debug > 5)
<<<"TUIO.ck, aliveListener(): alive:",FrameSeq>>>;
for(0 => int count; count < NumIDs; count++){
if(debug > 5){
if(TouchList == NULL)
<<<"TUIO.ck, aliveListener(): Null TouchList, fuck.",TouchList>>>;
else
<<<"TUIO.ck, aliveListener(): non-null TouchList",TouchList,event>>>;
}
TouchList.aliveTouch(event.getInt(),FrameSeq,NumIDs);
}
}
}
}
}
function void setListener(OscEvent event, int updating[])
{
if(debug > 1)
<<<"TUIO.ck, setListener(): Listener started","2DCur">>>;
string set;
int ID;
float x, y;
float dxdt, dydt;
float a;
while(true){
if(debug > 4)
<<<"Tuio.ck, setListener(): Waiting for set event.">>>;
event => now;
while(updating[0])
0.1::samp => now;//Wait for the next FSeq message.
if(debug > 4)
<<<"TUIO.ck, setListener(): Set event">>>;
while(event.nextMsg() != 0){
event.getString() => set;
if(debug > 6)
<<<"TUIO.ck, setListener():",set>>>;
if(set == "set"){
event.getInt() => ID;
event.getFloat() => x;
event.getFloat() => y;
event.getFloat() => dxdt;
event.getFloat() => dydt;
event.getFloat() => a;
if(debug > 5)
<<<"TUIO.ck, setListener(): Touch Update">>>;
TouchList.update(ID,FrameSeq,x,y,dxdt,dydt,a) @=> TouchList;
}
else{
<<<"Not a set message?",set>>>;
}
}
true => updating[0];
}
}
}