Ejemplo n.º 1
0
/*
 * Timers documentation:
 * http://www.x.org/releases/X11R7.7/doc/xorg-server/Xserver-spec.html#id2536042
 *
 * This function indirectly may call itself recursively using timer to guarantee correct
 * event delivery time. Ususally recursion ends after first recursive call.
 */
static CARD32 check_resolve_delayed(OsTimerPtr timer, CARD32 time, void *arg){
	LocalDevicePtr local = arg;
	struct MTouch *mt = local->private;
	mstime_t delta_millis;
	struct timeval delta;

	// If it was to early to trigger delayed button, next timer will be set,
	// but when called by timer such situation shouldn't take place.
	switch (mtouch_delayed(mt)){
	case 1:
		if(mt->is_timer_installed != 1){
			TimerCancel(mt->timer);
			mt->is_timer_installed = 1;
			timersub(&mt->gs.button_delayed_time, &mt->gs.time, &delta);
			delta_millis = timertoms(&delta);
			mt->timer = TimerSet(mt->timer, 0, delta_millis, check_resolve_delayed, local);
		}
		break;
	case 2:
		TimerCancel(mt->timer);
		mt->is_timer_installed = 0;
		handle_gestures(local, &mt->gs);
		break;
	case 3:
		TimerCancel(mt->timer);
		handle_gestures(local, &mt->gs);
		mt->is_timer_installed = 2;

		/* Install coasting timer */
		coasting_delayed(mt->timer, -1, arg);
		break;
	case 0: break;
	}
	return 0;
}
Ejemplo n.º 2
0
static void loop_device(int fd)
{
	struct MTouch mt;
	if (mtouch_configure(&mt, fd)) {
		fprintf(stderr, "error: could not configure device\n");
		return;
	}
	if (mtouch_open(&mt, fd)) {
		fprintf(stderr, "error: could not open device\n");
		return;
	}

	mconfig_defaults(&mt.cfg);
	printf("width:  %d\n", mt.hs.max_x);
	printf("height: %d\n", mt.hs.max_y);

	//while (!mtdev_idle(&mt.dev, fd, 5000)) {
	while (1) {
		while (mtouch_read(&mt) > 0)
			print_gestures(&mt.gs);
		if (mtouch_delayed(&mt))
			print_gestures(&mt.gs);
	}
	mtouch_close(&mt);
}
Ejemplo n.º 3
0
/* called for each full received packet from the touchpad */
static void read_input(LocalDevicePtr local)
{
	struct MTouch *mt = local->private;
	while (mtouch_read(mt) > 0)
		handle_gestures(local, &mt->gs);
	if (mtouch_delayed(mt))
		handle_gestures(local, &mt->gs);
}