+ int maxfd = 0;
+ glob_t glob_result;
+ int glob_return = glob(device, GLOB_ERR | GLOB_NOSORT, NULL, &glob_result);
+ if (glob_return == GLOB_NOMATCH) {
+ errx(EX_NOINPUT, "Could not find keyboard event file(s): %s", device);
+ }
+ if (glob_return != 0) {
+ err(EX_NOINPUT, "Could not glob keyboard event file(s): %s", device);
+ }
+ for (unsigned i = 0; i < glob_result.gl_pathc; i++) {
+ int device_fd = open(glob_result.gl_pathv[i], O_RDONLY);
+ if (device_fd < 0) {
+ err(EX_NOINPUT, "Could not open keyboard event file: %s", glob_result.gl_pathv[i]);
+ }
+ if (device_fd > maxfd) {
+ maxfd = device_fd;
+ }
+ FD_SET(device_fd, &all_inputs);
+ }
+ globfree(&glob_result);
+
+ /* Report keystroke timestamps */
+ struct input_event i;