- int optch;
- int i;
- event_t events[EVENTS];
- int verbose = 0;
-
- while((optch = getopt(argc, argv, "hv")) != -1) {
- switch(optch) {
- case('h'):
- printf("Usage: %s [-v|-h]\n", argv[0]);
- return 0;
- break;
- case('v'):
- verbose = 1;
- break;
- }
- }
-
- signal(SIGINT, sigint);
-
- printf("Press CTRL-C to exit.\n\n");
-
- memset(events, 0, sizeof(events));
-
- // List input devices
- for(i = 0; i < EVENTS; i++) {
- char device[18];
-
- sprintf(device, "/dev/input/event%i", i);
- events[i].fd = open(device, O_RDONLY);
+ int optch;
+ int i;
+ event_t events[EVENTS];
+ int verbose = 1;
+ int max_event = 0;
+
+ while((optch = getopt(argc, argv, "hn")) != -1) {
+ switch(optch) {
+ case('h'):
+ printf("Usage: %s [-n|-h]\n", argv[0]);
+ printf("-n nonverbose\n");
+ printf("-h help\n");
+ return 0;
+ break;
+ 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");
+
+ memset(events, 0, sizeof(events));
+
+ // List input devices
+ for(i = 0; i < EVENTS; i++) {
+ // 20 is needed for 3 digits of event devs under the expected format, but
+ // just give it some extra in case.
+ char device[30];
+
+ sprintf(device, "/dev/input/event%i", i);
+ events[i].fd = open(device, O_RDONLY);