Esempio n. 1
0
static int play_from_stdin(int fd)
{
	int ret;

	ret = evemu_play(stdin, fd);

	if (ret != 0)
		fprintf(stderr, "error: could not replay device\n");

	return ret;
}
Esempio n. 2
0
static int play_from_file(int recording_fd)
{
	FILE *fp;
	struct evemu_device *dev = NULL;
	int fd;

	fp = fdopen(recording_fd, "r");
	if (!fp) {
		fprintf(stderr, "error: could not open file (%m)\n");
		return -1;
	}

	dev = create_device(fp);
	if (!dev) {
		fprintf(stderr, "error: could not create device: %m\n");
		fclose(fp);
		return -1;
	}

	fd = open_evemu_device(dev);
	if (fd < 0)
		goto out;

	while (1) {
		int ret;
		char line[32];

		printf("Hit enter to start replaying");
		fflush(stdout);
		fgets(line, sizeof(line), stdin);

		fseek(fp, 0, SEEK_SET);
		ret = evemu_play(fp, fd);
		if (ret != 0) {
			fprintf(stderr, "error: could not replay device\n");
			break;
		}
	}

out:
	evemu_delete(dev);
	fclose(fp);
	close(fd);
	return 0;
}
Esempio n. 3
0
int main(int argc, char *argv[])
{
	int fd;
	if (argc != 2) {
		fprintf(stderr, "Usage: %s <device>\n", argv[0]);
		fprintf(stderr, "\n");
		fprintf(stderr, "Event data is read from standard input.\n");
		return -1;
	}
	fd = open(argv[1], O_WRONLY);
	if (fd < 0) {
		fprintf(stderr, "error: could not open device\n");
		return -1;
	}
	if (evemu_play(stdin, fd)) {
		fprintf(stderr, "error: could not describe device\n");
	}
	close(fd);
	return 0;
}