Пример #1
0
// Process incoming events
static int callback(int device, Finger *data, int nFingers, double timestamp, int frame)
{
	if (!running || !sampling_interval_passed()) {
		return 0;
	}

	tuio_frame_begin();

	std::set<int> fingers;

	// Process incoming events
	int i;
	for (i=0; i<nFingers; i++) {
		Finger *f = &data[i];
		int id = f->identifier;

		float x = f->normalized.pos.x;
		float y = 1.0f - f->normalized.pos.y; // reverse y axis
		float size = f->size;
		
		if (EXISTS(currentFingers, id)) {
			// update
			touch_update(id, x, y, size);
		}
		else {
			// add
			touch_add(id, x, y, size);
		}
		fingers.insert(id);
	}

	// Remove old events
	std::set<int>::iterator iter;
	FOREACH(currentFingers, iter) {
		int id = *iter;
		if (!EXISTS(fingers, id)) {
			// remove
			touch_remove(id);
		}
	}
Пример #2
0
// Process incoming events
static void callback(MTDeviceRef device, MTTouch touches[], size_t numTouches, double timestamp, size_t frame) {
	
	if (!running || !sampling_interval_passed()) {
		return;
	}

	tuio_frame_begin();

	std::set<int> fingers;

	// Process incoming events
	int i;
	for (i=0; i<numTouches; i++) {
		MTTouch *f = &touches[i];
		int id = f->pathIndex;

		float x = f->normalizedVector.position.x;
		float y = 1.0f - f->normalizedVector.position.y; // reverse y axis
		
		if (EXISTS(currentFingers, id)) {
			// update
			touch_update(id, x, y);
		}
		else {
			// add
			touch_add(id, x, y);
		}
		fingers.insert(id);
	}

	// Remove old events
	std::set<int>::iterator iter;
	FOREACH(currentFingers, iter) {
		int id = *iter;
		if (!EXISTS(fingers, id)) {
			// remove
			touch_remove(id);
		}
	}
//[*]--------------------------------------------------------------------------------------------------[*]
static int touch_i2c_remove(struct i2c_client *client)
{
	return	touch_remove(&client->dev);
}