- result = in_evdev_update_keycode(data, count, &id, &is_down, timeout_ms);
+again:
+ /* TODO: move this block to platform/linux */
+ {
+ struct timeval tv, *timeout = NULL;
+ int fdmax = -1;
+ fd_set fdset;
+
+ if (timeout_ms >= 0) {
+ tv.tv_sec = timeout_ms / 1000;
+ tv.tv_usec = (timeout_ms % 1000) * 1000;
+ timeout = &tv;
+ }
+
+ 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 -1;
+ }
+
+ if (ret == 0)
+ return -1; /* timeout */