Пример #1
0
static void loop_device(int fd)
{
	struct mtdev dev;
	struct input_event ev;
	int ret = mtdev_open(&dev, fd);
	if (ret) {
		fprintf(stderr, "error: could not open device: %d\n", ret);
		return;
	}
	show_props(&dev);
	/* while the device has not been inactive for five seconds */
	while (!mtdev_idle(&dev, fd, 5000)) {
		/* extract all available processed events */
		while (mtdev_get(&dev, fd, &ev, 1) > 0) {
			if (use_event(&ev))
				print_event(&ev);
		}
	}
	mtdev_close(&dev);
}
Пример #2
0
int mtouch_open(struct MTouch* mt, int fd)
{
	int ret;
	mt->fd = fd;
	ret = mtdev_open(&mt->dev, mt->fd);
	if (ret)
		goto error;
	mconfig_init(&mt->cfg, &mt->caps);
	hwstate_init(&mt->hs, &mt->caps);
	mtstate_init(&mt->state);
	gestures_init(mt);
	if (use_grab) {
		SYSCALL(ret = ioctl(fd, EVIOCGRAB, 1));
		if (ret)
			goto close;
	}
	return 0;
 close:
	mtdev_close(&mt->dev);
 error:
	return ret;
}
Пример #3
0
int main(int, char **)
{
    mtdev m;
    mtdev_open(&m, 0);
    return 0;
}