summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/grail-gesture.c10
1 files changed, 8 insertions, 2 deletions
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)
82int main(int argc, char *argv[]) 82int main(int argc, char *argv[])
83{ 83{
84 struct grail ge; 84 struct grail ge;
85 struct stat fs;
85 int i, fd; 86 int i, fd;
86 87
87 if (argc < 3) { 88 if (argc < 3) {
@@ -104,7 +105,11 @@ int main(int argc, char *argv[])
104 fprintf(stderr, "error: could not open device\n"); 105 fprintf(stderr, "error: could not open device\n");
105 return -1; 106 return -1;
106 } 107 }
107 if (ioctl(fd, EVIOCGRAB, 1)) { 108 if (fstat(fd, &fs)) {
109 fprintf(stderr, "error: could not stat the device\n");
110 return -1;
111 }
112 if (fs.st_rdev && ioctl(fd, EVIOCGRAB, 1)) {
108 fprintf(stderr, "error: could not grab the device\n"); 113 fprintf(stderr, "error: could not grab the device\n");
109 return -1; 114 return -1;
110 } 115 }
@@ -121,7 +126,8 @@ int main(int argc, char *argv[])
121 loop_device(&ge, fd); 126 loop_device(&ge, fd);
122 grail_close(&ge, fd); 127 grail_close(&ge, fd);
123 128
124 ioctl(fd, EVIOCGRAB, 0); 129 if (fs.st_rdev)
130 ioctl(fd, EVIOCGRAB, 0);
125 close(fd); 131 close(fd);
126 return 0; 132 return 0;
127} 133}