X-Git-Url: https://iankelling.org/git/?p=evhz;a=blobdiff_plain;f=evhz.c;h=217e8b0710f4c5fe86a991fd82733a94e468d3bc;hp=a34fd83277723d9397905669bc8a47451ef10a1b;hb=f9fcef9f295ac082affd059ad28241f052fcdca4;hpb=86e80de6d1c5759421e1f9702a798f05cda42207 diff --git a/evhz.c b/evhz.c index a34fd83..217e8b0 100644 --- a/evhz.c +++ b/evhz.c @@ -28,20 +28,27 @@ int main(int argc, char *argv[]) { int optch; int i; event_t events[EVENTS]; - int verbose = 0; + int verbose = 1; - while((optch = getopt(argc, argv, "hv")) != -1) { + while((optch = getopt(argc, argv, "hn")) != -1) { switch(optch) { case('h'): - printf("Usage: %s [-v|-h]\n", argv[0]); + printf("Usage: %s [-n|-h]\n", argv[0]); + printf("-n nonverbose\n"); + printf("-h help\n"); return 0; break; - case('v'): - verbose = 1; + case('n'): + verbose = 0; break; } } + if(geteuid() != 0) { + printf("%s must be used as superuser\n", argv[0]); + return 1; + } + signal(SIGINT, sigint); printf("Press CTRL-C to exit.\n\n"); @@ -50,7 +57,7 @@ int main(int argc, char *argv[]) { // List input devices for(i = 0; i < EVENTS; i++) { - char device[18]; + char device[19]; sprintf(device, "/dev/input/event%i", i); events[i].fd = open(device, O_RDONLY);