mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-05 06:47:45 -04:00
in_evdev: revert multi event handling from r901 to avoid unwanted blocking
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@910 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
b7c7cd5d46
commit
e30684582a
1 changed files with 50 additions and 51 deletions
101
linux/in_evdev.c
101
linux/in_evdev.c
|
@ -402,60 +402,59 @@ 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)
|
/* do single event, the caller sometimes wants
|
||||||
|
* to do select() in blocking mode */
|
||||||
|
rd = read(dev->fd, &ev, sizeof(ev));
|
||||||
|
if (rd < (int) sizeof(ev)) {
|
||||||
|
if (errno != EAGAIN) {
|
||||||
|
perror("in_evdev: error reading");
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ev.type == EV_KEY) {
|
||||||
|
if (ev.value < 0 || ev.value > 1)
|
||||||
|
goto out;
|
||||||
|
ret_kc = ev.code;
|
||||||
|
ret_down = ev.value;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
else if (ev.type == EV_ABS)
|
||||||
{
|
{
|
||||||
rd = read(dev->fd, &ev, sizeof(ev));
|
int lzone = dev->abs_lzone, down = 0, *last;
|
||||||
if (rd < (int) sizeof(ev)) {
|
|
||||||
if (errno != EAGAIN) {
|
// map absolute to up/down/left/right
|
||||||
perror("in_evdev: error reading");
|
if (lzone != 0 && ev.code == ABS_X) {
|
||||||
sleep(1);
|
if (ev.value < dev->abs_min_x + lzone)
|
||||||
}
|
down = KEY_LEFT;
|
||||||
goto out;
|
else if (ev.value > dev->abs_max_x - lzone)
|
||||||
}
|
down = KEY_RIGHT;
|
||||||
|
last = &dev->abs_lastx;
|
||||||
if (ev.type == EV_KEY) {
|
}
|
||||||
if (ev.value < 0 || ev.value > 1)
|
else if (lzone != 0 && ev.code == ABS_Y) {
|
||||||
continue;
|
if (ev.value < dev->abs_min_y + lzone)
|
||||||
ret_kc = ev.code;
|
down = KEY_UP;
|
||||||
ret_down = ev.value;
|
else if (ev.value > dev->abs_max_y - lzone)
|
||||||
goto out;
|
down = KEY_DOWN;
|
||||||
}
|
last = &dev->abs_lasty;
|
||||||
else if (ev.type == EV_ABS)
|
}
|
||||||
{
|
else
|
||||||
int lzone = dev->abs_lzone, down = 0, *last;
|
goto out;
|
||||||
|
|
||||||
// map absolute to up/down/left/right
|
if (down == *last)
|
||||||
if (lzone != 0 && ev.code == ABS_X) {
|
goto out;
|
||||||
if (ev.value < dev->abs_min_x + lzone)
|
|
||||||
down = KEY_LEFT;
|
if (down == 0 || *last != 0) {
|
||||||
else if (ev.value > dev->abs_max_x - lzone)
|
/* key up or direction change, return up event for old key */
|
||||||
down = KEY_RIGHT;
|
ret_kc = *last;
|
||||||
last = &dev->abs_lastx;
|
ret_down = 0;
|
||||||
}
|
*last = 0;
|
||||||
else if (lzone != 0 && ev.code == ABS_Y) {
|
|
||||||
if (ev.value < dev->abs_min_y + lzone)
|
|
||||||
down = KEY_UP;
|
|
||||||
else if (ev.value > dev->abs_max_y - lzone)
|
|
||||||
down = KEY_DOWN;
|
|
||||||
last = &dev->abs_lasty;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (down == *last)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (down == 0 || *last != 0) {
|
|
||||||
/* key up or direction change, return up event for old key */
|
|
||||||
ret_kc = *last;
|
|
||||||
ret_down = 0;
|
|
||||||
*last = 0;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
ret_kc = *last = down;
|
|
||||||
ret_down = 1;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
ret_kc = *last = down;
|
||||||
|
ret_down = 1;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue