- FD_SET(fd, &all_inputs);
- while (1) {
- ready_inputs = all_inputs;
- if (select(fd+1, &ready_inputs, NULL, NULL, NULL) != 1) {
- err(EX_IOERR, "select");
+ 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]);