Example #1
0
static void handle_gestures(LocalDevicePtr local,
			struct Gestures* gs)
{
	struct MTouch *mt = local->private;
	static bitmask_t buttons_prev = 0U;
	int i;

	if(mt->absolute_mode == FALSE){
		if (mt->cfg.scroll_smooth){
			/* Copy states from button_prev into current buttons state */
			MODBIT(gs->buttons, 3, GETBIT(buttons_prev, 3));
			MODBIT(gs->buttons, 4, GETBIT(buttons_prev, 4));
			MODBIT(gs->buttons, 5, GETBIT(buttons_prev, 5));
			MODBIT(gs->buttons, 6, GETBIT(buttons_prev, 6));
			set_and_post_mask(mt, local->dev, timertoms(&gs->dt));
		}
		else{
			// mt->absolute_mode == FALSE
			if (gs->move_dx != 0 || gs->move_dy != 0)
				xf86PostMotionEvent(local->dev, 0, 0, 2, gs->move_dx, gs->move_dy);
		}
	}
	else{
		/* Give the HW coordinates to Xserver as absolute coordinates, these coordinates
		 * are not scaled, this is oke if the touchscreen has the same resolution as the display.
		 */
		xf86PostMotionEvent(local->dev, 1, 0, 2,
			mt->state.touch[0].x + get_cap_xmid(&mt->caps),
			mt->state.touch[0].y + get_cap_ymid(&mt->caps));
	}

	for (i = 0; i < 32; i++) {
		if (GETBIT(gs->buttons, i) == GETBIT(buttons_prev, i))
			continue;
		if (GETBIT(gs->buttons, i)) {
			xf86PostButtonEvent(local->dev, FALSE, i+1, 1, 0, 0);
#define DEBUG_DRIVER 0
#if DEBUG_DRIVER
			xf86Msg(X_INFO, "button %d down\n", i+1);
#endif
		}
		else {
			xf86PostButtonEvent(local->dev, FALSE, i+1, 0, 0, 0);
#if DEBUG_DRIVER
			xf86Msg(X_INFO, "button %d up\n", i+1);
#endif
#undef DEBUG_DRIVER
		}
	}
	buttons_prev = gs->buttons;
}
int translate_cap_x(const struct Capabilities *cap, int x)
{
	int mid = get_cap_xmid(cap);
	return x - mid;
}