X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Flinux%2Fin_evdev.c;h=7866015212c45c64b89e377eb3a426c77a2fca5f;hb=db1d3564e69b422518701926bffdeae05379c400;hp=6eea20a8d6c02f70940704f98af66056c386ac5d;hpb=2843d00e70d545a0d336a38851ca97ad15f1dff2;p=picodrive.git diff --git a/platform/linux/in_evdev.c b/platform/linux/in_evdev.c index 6eea20a..7866015 100644 --- a/platform/linux/in_evdev.c +++ b/platform/linux/in_evdev.c @@ -256,7 +256,7 @@ int in_evdev_update(void *drv_data, const int *binds, int *result) 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; @@ -317,6 +317,16 @@ static void in_evdev_set_blocking(void *drv_data, int y) 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