in_evdev: do all events in update_keycode

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@901 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2010-11-07 21:55:57 +00:00
parent 93a7109873
commit 25915832ff
2 changed files with 52 additions and 52 deletions

View file

@ -355,9 +355,6 @@ int in_update_keycode(int *dev_id_out, int *is_down_out, int timeout_ms)
drv = &DRV(in_devices[dev_id].drv_id); drv = &DRV(in_devices[dev_id].drv_id);
result = drv->update_keycode(in_devices[dev_id].drv_data, &is_down); result = drv->update_keycode(in_devices[dev_id].drv_data, &is_down);
/* update_keycode() might return -1 when some not interesting
* event happened, like sync event for evdev. */
if (result >= 0) if (result >= 0)
break; break;
@ -370,7 +367,7 @@ int in_update_keycode(int *dev_id_out, int *is_down_out, int timeout_ms)
} }
} }
if (result == -1) if (result < 0)
return -1; return -1;
finish: finish:
/* keep track of menu key state, to allow mixing /* keep track of menu key state, to allow mixing

View file

@ -392,6 +392,8 @@ static int in_evdev_update_keycode(void *data, int *is_down)
struct input_event ev; struct input_event ev;
int rd; int rd;
while (1)
{
rd = read(dev->fd, &ev, sizeof(ev)); rd = read(dev->fd, &ev, sizeof(ev));
if (rd < (int) sizeof(ev)) { if (rd < (int) sizeof(ev)) {
if (errno != EAGAIN) { if (errno != EAGAIN) {
@ -403,7 +405,7 @@ static int in_evdev_update_keycode(void *data, int *is_down)
if (ev.type == EV_KEY) { if (ev.type == EV_KEY) {
if (ev.value < 0 || ev.value > 1) if (ev.value < 0 || ev.value > 1)
goto out; continue;
ret_kc = ev.code; ret_kc = ev.code;
ret_down = ev.value; ret_down = ev.value;
goto out; goto out;
@ -428,10 +430,10 @@ static int in_evdev_update_keycode(void *data, int *is_down)
last = &dev->abs_lasty; last = &dev->abs_lasty;
} }
else else
goto out; continue;
if (down == *last) if (down == *last)
goto out; continue;
if (down == 0 || *last != 0) { if (down == 0 || *last != 0) {
/* key up or direction change, return up event for old key */ /* key up or direction change, return up event for old key */
@ -444,6 +446,7 @@ static int in_evdev_update_keycode(void *data, int *is_down)
ret_down = 1; ret_down = 1;
goto out; goto out;
} }
}
out: out:
if (is_down != NULL) if (is_down != NULL)