X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=ginge.git;a=blobdiff_plain;f=loader%2Fhost_pnd.c;h=f52896d15015e3b8d3c4e81d24694b9c8cc45344;hp=a3d42152c05602bab1ca52ca05e11219c116fe85;hb=499bf01c2f0e075caeb23714e3376a641c04eb7c;hpb=6720e4e4ee1f5c815bc82dd8a5f276d7c5e71b24 diff --git a/loader/host_pnd.c b/loader/host_pnd.c index a3d4215..f52896d 100644 --- a/loader/host_pnd.c +++ b/loader/host_pnd.c @@ -1,4 +1,30 @@ // vim:shiftwidth=2:expandtab + +struct in_default_bind in_evdev_defbinds[] = { + { KEY_UP, IN_BINDTYPE_PLAYER12, GP2X_UP }, + { KEY_PAGEUP, IN_BINDTYPE_PLAYER12, GP2X_Y }, + { KEY_END, IN_BINDTYPE_PLAYER12, GP2X_B }, + { KEY_PAGEDOWN, IN_BINDTYPE_PLAYER12, GP2X_X }, + { KEY_HOME, IN_BINDTYPE_PLAYER12, GP2X_A }, + { KEY_RIGHTSHIFT, IN_BINDTYPE_PLAYER12, GP2X_L }, + { KEY_RIGHTCTRL, IN_BINDTYPE_PLAYER12, GP2X_R }, + { KEY_LEFTALT, IN_BINDTYPE_PLAYER12, GP2X_START }, + { KEY_LEFTCTRL, IN_BINDTYPE_PLAYER12, GP2X_SELECT }, + { KEY_COMMA, IN_BINDTYPE_PLAYER12, GP2X_VOL_DOWN }, + { KEY_DOT, IN_BINDTYPE_PLAYER12, GP2X_VOL_UP }, + { KEY_1, IN_BINDTYPE_PLAYER12, GP2X_PUSH }, + { KEY_Q, IN_BINDTYPE_EMU, 0 }, + { 0, 0, 0 }, +}; + +static void host_actions(int actions[IN_BINDTYPE_COUNT]) +{ + if (actions[IN_BINDTYPE_EMU] & 1) + host_forced_exit(); +} + +// todo: rm when generic code works +#if 0 #define _GNU_SOURCE #include #include @@ -11,12 +37,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 +72,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 +102,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 +110,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 +129,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; @@ -118,4 +151,4 @@ int host_read_btns(void) return keystate; } - +#endif