int rd, ret, u;
if (dev->kbits == NULL) {
- ret = ioctl(dev->fd, EVIOCGKEY(sizeof(keybits)), keybits);
+ ret = ioctl(dev->fd, EVIOCGKEY(sizeof(keybits_)), keybits_);
if (ret == -1) {
perror("in_evdev: ioctl failed");
return -1;
perror("in_evdev: F_GETFL fcntl failed");
return;
}
+
+ if (flags & O_NONBLOCK) {
+ /* flush the event queue */
+ struct input_event ev;
+ do {
+ ret = read(dev->fd, &ev, sizeof(ev));
+ }
+ while (ret == sizeof(ev));
+ }
+
if (y)
flags &= ~O_NONBLOCK;
else