From 586dd0f17bbd6e2e8b51f3e2fca9269e33f8038a Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Thu, 17 Mar 2011 10:39:59 +0100 Subject: Allow replay of device data through grail This patch adds replay capabilities to grail. If the specified device points to a valid evemu file, the device properties will be extracted from that file instead. Any appended event data will be replayed in realtime when calling grail_pull_mtdev(). In practise, grail_gesture may be executed with a test file. Signed-off-by: Henrik Rydberg --- tools/grail-gesture.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tools/grail-gesture.c') diff --git a/tools/grail-gesture.c b/tools/grail-gesture.c index 368150e..7230c3b 100644 --- a/tools/grail-gesture.c +++ b/tools/grail-gesture.c @@ -82,6 +82,7 @@ static void loop_device(struct grail *ge, int fd) int main(int argc, char *argv[]) { struct grail ge; + struct stat fs; int i, fd; if (argc < 3) { @@ -104,7 +105,11 @@ int main(int argc, char *argv[]) fprintf(stderr, "error: could not open device\n"); return -1; } - if (ioctl(fd, EVIOCGRAB, 1)) { + if (fstat(fd, &fs)) { + fprintf(stderr, "error: could not stat the device\n"); + return -1; + } + if (fs.st_rdev && ioctl(fd, EVIOCGRAB, 1)) { fprintf(stderr, "error: could not grab the device\n"); return -1; } @@ -121,7 +126,8 @@ int main(int argc, char *argv[]) loop_device(&ge, fd); grail_close(&ge, fd); - ioctl(fd, EVIOCGRAB, 0); + if (fs.st_rdev) + ioctl(fd, EVIOCGRAB, 0); close(fd); return 0; } -- cgit v1.2.3