X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=ginge.git;a=blobdiff_plain;f=loader%2Fhost_pnd.c;h=32fe95a95010d6b8118732500f4d0ef242481e5b;hp=a3d42152c05602bab1ca52ca05e11219c116fe85;hb=cc559d92a3578536dcd7a499751ae97aa6d409d7;hpb=6720e4e4ee1f5c815bc82dd8a5f276d7c5e71b24 diff --git a/loader/host_pnd.c b/loader/host_pnd.c index a3d4215..32fe95a 100644 --- a/loader/host_pnd.c +++ b/loader/host_pnd.c @@ -11,12 +11,12 @@ #include #include "header.h" +#include "realfuncs.h" static int ifds[2] = { -1, -1 }; -static int init_done; static int keystate; -static void init(void) +int host_init(void) { char buff[64]; int i, ifd, ret; @@ -46,7 +46,8 @@ static void init(void) fprintf(stderr, PFX "missing buttons\n"); if (ifds[1] < 0) fprintf(stderr, PFX "missing keypad\n"); - init_done = 1; + + return 0; } static const struct { @@ -75,7 +76,7 @@ static const struct { { BTN_SELECT, GP2X_SELECT }, { KEY_COMMA, GP2X_VOL_DOWN }, { KEY_DOT, GP2X_VOL_UP }, - { KEY_Q, GP2X_PUSH }, + { KEY_1, GP2X_PUSH }, }; int host_read_btns(void) @@ -83,9 +84,6 @@ int host_read_btns(void) struct input_event ev; int i, ret; - if (!init_done) - init(); - while (1) { ret = read(ifds[0], &ev, sizeof(ev)); @@ -105,6 +103,15 @@ int host_read_btns(void) if (ev.type != EV_KEY) continue; + if (ev.code == KEY_Q && ev.value) { + // exit() might not be enough because loader and app data is out of sync, + // and other threads (which are really processes) might not exit properly. + system("killall ginge_sloader"); + usleep(300000); + system("killall -9 ginge_sloader"); + exit(1); + } + for (i = 0; i < sizeof(key_map) / sizeof(key_map[0]); i++) { if (key_map[i].key != ev.code) continue;