mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
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:
parent
93a7109873
commit
25915832ff
2 changed files with 52 additions and 52 deletions
|
@ -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
|
||||||
|
|
|
@ -392,57 +392,60 @@ static int in_evdev_update_keycode(void *data, int *is_down)
|
||||||
struct input_event ev;
|
struct input_event ev;
|
||||||
int rd;
|
int rd;
|
||||||
|
|
||||||
rd = read(dev->fd, &ev, sizeof(ev));
|
while (1)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
int lzone = dev->abs_lzone, down = 0, *last;
|
rd = read(dev->fd, &ev, sizeof(ev));
|
||||||
|
if (rd < (int) sizeof(ev)) {
|
||||||
// map absolute to up/down/left/right
|
if (errno != EAGAIN) {
|
||||||
if (lzone != 0 && ev.code == ABS_X) {
|
perror("in_evdev: error reading");
|
||||||
if (ev.value < dev->abs_min_x + lzone)
|
sleep(1);
|
||||||
down = KEY_LEFT;
|
}
|
||||||
else if (ev.value > dev->abs_max_x - lzone)
|
goto out;
|
||||||
down = KEY_RIGHT;
|
}
|
||||||
last = &dev->abs_lastx;
|
|
||||||
}
|
if (ev.type == EV_KEY) {
|
||||||
else if (lzone != 0 && ev.code == ABS_Y) {
|
if (ev.value < 0 || ev.value > 1)
|
||||||
if (ev.value < dev->abs_min_y + lzone)
|
continue;
|
||||||
down = KEY_UP;
|
ret_kc = ev.code;
|
||||||
else if (ev.value > dev->abs_max_y - lzone)
|
ret_down = ev.value;
|
||||||
down = KEY_DOWN;
|
goto out;
|
||||||
last = &dev->abs_lasty;
|
}
|
||||||
}
|
else if (ev.type == EV_ABS)
|
||||||
else
|
{
|
||||||
goto out;
|
int lzone = dev->abs_lzone, down = 0, *last;
|
||||||
|
|
||||||
if (down == *last)
|
// map absolute to up/down/left/right
|
||||||
goto out;
|
if (lzone != 0 && ev.code == ABS_X) {
|
||||||
|
if (ev.value < dev->abs_min_x + lzone)
|
||||||
if (down == 0 || *last != 0) {
|
down = KEY_LEFT;
|
||||||
/* key up or direction change, return up event for old key */
|
else if (ev.value > dev->abs_max_x - lzone)
|
||||||
ret_kc = *last;
|
down = KEY_RIGHT;
|
||||||
ret_down = 0;
|
last = &dev->abs_lastx;
|
||||||
*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