summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-02-10 08:34:52 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-02-10 09:33:18 +1000
commit65f36426543c64129f723bf49f2434668fddbd6f (patch)
treed9bb112b21a6423ad22936aa8fb38507a4d5de6c
parent7c03a3f5f113fb202dd6999edceaa2b5580cc134 (diff)
Test for device grabs and spit out huge warning.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--evtest.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/evtest.c b/evtest.c
index 3af6f66..273b6ee 100644
--- a/evtest.c
+++ b/evtest.c
@@ -598,6 +598,23 @@ static int print_events(int fd)
}
}
+/**
+ * Grab and immediately ungrab the device.
+ *
+ * Returns 0 if the grab was successful, or 1 otherwise.
+ */
+static int test_grab(int fd)
+{
+ int rc;
+
+ rc = ioctl(fd, EVIOCGRAB, (void*)1);
+
+ if (!rc)
+ ioctl(fd, EVIOCGRAB, (void*)0);
+
+ return rc;
+}
+
int main (int argc, char **argv)
{
int fd;
@@ -620,5 +637,17 @@ int main (int argc, char **argv)
printf("Testing ... (interrupt to exit)\n");
+ if (test_grab(fd))
+ {
+ printf("***********************************************\n");
+ printf(" This device is grabbed by another process.\n");
+ printf(" No events are available to evtest while the\n"
+ " other grab is active.\n");
+ printf(" In most cases, this is caused by an X driver,\n"
+ " try VT-switching and re-run evtest again.\n");
+ printf("***********************************************\n");
+ }
+
+
return print_events(fd);
}