front_idill/extern/fajran-npTuioClient/example/tuio.js
author bastiena
Fri, 06 Apr 2012 10:44:54 +0200
changeset 21 e4e5f02787a1
child 28 9ccef81f02ab
permissions -rw-r--r--
Front IDILL : Added Communication extern named fajran-npTuioClient It contains the project generating a dll used as a browser plugin.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     1
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     2
var tuio = {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     3
	cursors: [],
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     4
	objects: [],
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     5
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     6
	_data: {},
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     7
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     8
	_cb_object_add:    function(obj) { },
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
     9
	_cb_object_update: function(obj) { },
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    10
	_cb_object_remove: function(obj) { },
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    11
	_cb_cursor_add:    function(cur) { },
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    12
	_cb_cursor_update: function(cur) { },
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    13
	_cb_cursor_remove: function(cur) { },
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    14
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    15
	// Callback from the main event handler
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    16
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    17
	callback: function(type, sid, fid, x, y, angle) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    18
		var data;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    19
		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    20
		if ((type != 0) && (type != 3)) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    21
			data = this._data[sid];
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    22
		}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    23
		else {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    24
			data = {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    25
				sid: sid,
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    26
				fid: fid
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    27
			}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    28
			this._data[sid] = data;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    29
		}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    30
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    31
		data.x = x;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    32
		data.y = y;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    33
		
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    34
		if (type < 3) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    35
			data.angle = angle;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    36
		}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    37
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    38
		switch (type) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    39
			case 0: 
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    40
				this.objects.push(data);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    41
				this._cb_object_add(data);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    42
				break;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    43
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    44
			case 1: 
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    45
				this._cb_object_update(data);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    46
				break;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    47
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    48
			case 2: 
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    49
				this.objects.splice(this.objects.indexOf(data), 1);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    50
				this._cb_object_remove(data);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    51
				break;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    52
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    53
			case 3: 
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    54
				this.cursors.push(data);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    55
				this._cb_cursor_add(data);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    56
				break;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    57
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    58
			case 4: 
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    59
				this._cb_cursor_update(data);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    60
				break;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    61
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    62
			case 5: 
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    63
				this.cursors.splice(this.cursors.indexOf(data), 1);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    64
				this._cb_cursor_remove(data);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    65
				break;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    66
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    67
			default:
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    68
				break;
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    69
		}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    70
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    71
		if ((type == 2) || (type == 5)) {
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    72
			delete this._data[sid];
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    73
		}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    74
	},
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    75
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    76
	// Callback for the developer
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    77
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    78
	object_add:    function(f) { this._cb_object_add    = f; },
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    79
	object_update: function(f) { this._cb_object_update = f; },
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    80
	object_remove: function(f) { this._cb_object_remove = f; },
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    81
	cursor_add:    function(f) { this._cb_cursor_add    = f; },
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    82
	cursor_update: function(f) { this._cb_cursor_update = f; },
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    83
	cursor_remove: function(f) { this._cb_cursor_remove = f; },
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    84
}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    85
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    86
function tuio_callback(type, sid, fid, x, y, angle)	{
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    87
	tuio.callback(type, sid, fid, x, y, angle);
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    88
}
e4e5f02787a1 Front IDILL :
bastiena
parents:
diff changeset
    89