From: notaz Date: Thu, 9 Dec 2010 22:23:40 +0000 (+0200) Subject: update in_evdev, fix return from menu X-Git-Tag: r1~41 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7eda34c1986911c3be91383550ec60c28f04db99;p=pcsx_rearmed.git update in_evdev, fix return from menu --- diff --git a/frontend/linux/in_evdev.c b/frontend/linux/in_evdev.c index 0b73302c..e6bdad15 100644 --- a/frontend/linux/in_evdev.c +++ b/frontend/linux/in_evdev.c @@ -402,60 +402,59 @@ static int in_evdev_update_keycode(void *data, int *is_down) struct input_event ev; int rd; - while (1) - { - rd = read(dev->fd, &ev, sizeof(ev)); - if (rd < (int) sizeof(ev)) { - if (errno != EAGAIN) { - perror("in_evdev: error reading"); - sleep(1); - } - goto out; + /* 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) - continue; - ret_kc = ev.code; - ret_down = ev.value; + 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; + + // map absolute to up/down/left/right + if (lzone != 0 && ev.code == ABS_X) { + if (ev.value < dev->abs_min_x + lzone) + down = KEY_LEFT; + else if (ev.value > dev->abs_max_x - lzone) + down = KEY_RIGHT; + last = &dev->abs_lastx; } - else if (ev.type == EV_ABS) - { - int lzone = dev->abs_lzone, down = 0, *last; - - // map absolute to up/down/left/right - if (lzone != 0 && ev.code == ABS_X) { - if (ev.value < dev->abs_min_x + lzone) - down = KEY_LEFT; - else if (ev.value > dev->abs_max_x - lzone) - down = KEY_RIGHT; - last = &dev->abs_lastx; - } - 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; + 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 + goto out; + + if (down == *last) + goto out; + + 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; } out: @@ -571,7 +570,9 @@ static void in_evdev_get_def_binds(int *binds) { int i; - for (i = 0; in_evdev_defbinds[i].bit != 0; i++) { + for (i = 0; ; i++) { + if (in_evdev_defbinds[i].bit == 0 && in_evdev_defbinds[i].code == 0) + break; binds[IN_BIND_OFFS(in_evdev_defbinds[i].code, in_evdev_defbinds[i].btype)] = 1 << in_evdev_defbinds[i].bit; } diff --git a/frontend/menu.c b/frontend/menu.c index 3b38a956..4291ac58 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -16,6 +16,7 @@ #include "omap.h" #include "common/plat.h" #include "../libpcsxcore/misc.h" +#include "../libpcsxcore/new_dynarec/new_dynarec.h" #define MENU_X2 1 #define array_size(x) (sizeof(x) / sizeof(x[0])) @@ -439,6 +440,7 @@ strcpy(last_selected_fname, "/mnt/ntz/stuff/psx"); memset(g_menuscreen_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2); menu_draw_end(); omap_enable_layer(1); + stop = 0; } void me_update_msg(const char *msg)