+ FD_ZERO(&fdset);
+ for (i = 0; i < count; i++) {
+ if (fds_hnds[i] > fdmax) fdmax = fds_hnds[i];
+ FD_SET(fds_hnds[i], &fdset);
+ }
+
+ ret = select(fdmax + 1, &fdset, NULL, NULL, timeout);
+ if (ret == -1)
+ {
+ perror("input: select failed");
+ sleep(1);
+ return 0;
+ }
+
+ if (ret == 0)
+ return 0; /* timeout */
+
+ for (i = 0; i < count; i++)
+ if (FD_ISSET(fds_hnds[i], &fdset))
+ ret = fds_hnds[i];
+ }
+
+ for (i = 0; i < in_dev_count; i++) {
+ if (in_devices[i].drv_fd_hnd == ret) {