From 8424752c5a6e59509c85af7a144ac1849d20f6c5 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 8 Nov 2015 18:31:52 +0200 Subject: [PATCH] better port to newer libpicofe --- common/host_fb.c | 2 +- common/libpicofe | 2 +- loader/Makefile | 5 +- loader/host.c | 20 ++++--- loader/host_pnd.c | 147 ++++++---------------------------------------- loader/host_wiz.c | 11 +++- 6 files changed, 47 insertions(+), 140 deletions(-) diff --git a/common/host_fb.c b/common/host_fb.c index 4583a4c..a59e869 100644 --- a/common/host_fb.c +++ b/common/host_fb.c @@ -37,7 +37,7 @@ int host_video_init(int *stride, int no_dblbuf) fbdev_name = "/dev/fb1"; w = h = 0; - fbdev = vout_fbdev_init(fbdev_name, &w, &h, 16, no_dblbuf); + fbdev = vout_fbdev_init(fbdev_name, &w, &h, 16, no_dblbuf ? 1 : 3); if (fbdev == NULL) return -1; diff --git a/common/libpicofe b/common/libpicofe index 26ea181..21604a0 160000 --- a/common/libpicofe +++ b/common/libpicofe @@ -1 +1 @@ -Subproject commit 26ea18173c1228dd5ce39e2a88ffe1ae10fcb365 +Subproject commit 21604a047941b8fe81d381ede0371c75da964afd diff --git a/loader/Makefile b/loader/Makefile index ad0f9ef..b11da94 100644 --- a/loader/Makefile +++ b/loader/Makefile @@ -39,6 +39,9 @@ TARGET_S = ginge_sloader$(TAG) TARGET_D = ginge_dyn$(TAG) OBJ += emu.o host.o host_fb.o cmn.o +OBJ += ../common/libpicofe/input.o +OBJ += ../common/libpicofe/linux/plat.o +OBJ += ../common/libpicofe/linux/in_evdev.o OBJ_S += $(OBJ) loader.o loader_$(ARCH).o patches.o OBJ_D += $(OBJ) dl.o @@ -59,4 +62,4 @@ clean: # basic deps dl.o patches.o: override.c *.o: header.h - +host_fb.o: libpicofe/linux/fbdev.c diff --git a/loader/host.c b/loader/host.c index fc7a829..546839c 100644 --- a/loader/host.c +++ b/loader/host.c @@ -1,17 +1,20 @@ -// vim:shiftwidth=2:expandtab - +/* + * GINGE - GINGE Is Not Gp2x Emulator + * (C) notaz, 2010-2011,2015 + * + * This work is licensed under the MAME license, see COPYING file for details. + */ #define _GNU_SOURCE 1 // for plat.c #include #include +#include + +#include "../common/libpicofe/input.h" +#include "../common/libpicofe/linux/in_evdev.h" #include "header.h" #include "realfuncs.h" -#define IN_EVDEV -#include "../common/libpicofe/input.c" -#include "../common/libpicofe/linux/plat.c" -#include "../common/libpicofe/linux/in_evdev.c" - #ifdef PND #include "host_pnd.c" #elif defined(WIZ) @@ -24,6 +27,7 @@ char **g_argv; int host_init(void) { in_init(); + host_init_input(); in_probe(); return 0; @@ -49,3 +53,5 @@ void host_forced_exit(void) system("killall -9 ginge_sloader"); exit(1); } + +// vim:shiftwidth=2:expandtab diff --git a/loader/host_pnd.c b/loader/host_pnd.c index f52896d..86e9910 100644 --- a/loader/host_pnd.c +++ b/loader/host_pnd.c @@ -1,7 +1,15 @@ -// vim:shiftwidth=2:expandtab - -struct in_default_bind in_evdev_defbinds[] = { +/* + * GINGE - GINGE Is Not Gp2x Emulator + * (C) notaz, 2010-2011,2015 + * + * This work is licensed under the MAME license, see COPYING file for details. + */ + +static struct in_default_bind in_evdev_defbinds[] = { { KEY_UP, IN_BINDTYPE_PLAYER12, GP2X_UP }, + { KEY_LEFT, IN_BINDTYPE_PLAYER12, GP2X_LEFT }, + { KEY_DOWN, IN_BINDTYPE_PLAYER12, GP2X_DOWN }, + { KEY_RIGHT, IN_BINDTYPE_PLAYER12, GP2X_RIGHT }, { KEY_PAGEUP, IN_BINDTYPE_PLAYER12, GP2X_Y }, { KEY_END, IN_BINDTYPE_PLAYER12, GP2X_B }, { KEY_PAGEDOWN, IN_BINDTYPE_PLAYER12, GP2X_X }, @@ -17,138 +25,19 @@ struct in_default_bind in_evdev_defbinds[] = { { 0, 0, 0 }, }; +static const struct in_pdata pandora_evdev_pdata = { + .defbinds = in_evdev_defbinds, +}; + 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 -#include -#include -#include -#include -#include -#include -#include - -#include "header.h" -#include "realfuncs.h" - -static int ifds[2] = { -1, -1 }; -static int keystate; - -int host_init(void) +static void host_init_input(void) { - char buff[64]; - int i, ifd, ret; - - for (ifd = -1, i = 0; ifds[0] == -1 || ifds[1] == -1; i++) { - snprintf(buff, sizeof(buff), "/dev/input/event%i", i); - ifd = open(buff, O_RDONLY | O_NONBLOCK); - if (ifd == -1) - break; - - ret = ioctl(ifd, EVIOCGNAME(sizeof(buff)), buff); - if (ret < 0) - break; - - if (strcasestr(buff, "gpio") != NULL) { - ifds[0] = ifd; - continue; - } - if (strcasestr(buff, "keypad") != NULL) { - ifds[1] = ifd; - continue; - } - close(ifd); - } - - if (ifds[0] < 0) - fprintf(stderr, PFX "missing buttons\n"); - if (ifds[1] < 0) - fprintf(stderr, PFX "missing keypad\n"); - - return 0; + in_evdev_init(&pandora_evdev_pdata); } -static const struct { - unsigned short key; - unsigned short btn; -} key_map[] = { - { KEY_LEFT, GP2X_LEFT }, - { KEY_RIGHT, GP2X_RIGHT }, - { KEY_UP, GP2X_UP }, - { KEY_DOWN, GP2X_DOWN }, - { KEY_PAGEUP, GP2X_Y }, - { BTN_BASE, GP2X_Y }, - { KEY_END, GP2X_B }, - { BTN_BASE2, GP2X_B }, - { KEY_PAGEDOWN, GP2X_X }, - { BTN_BASE3, GP2X_X }, - { KEY_HOME, GP2X_A }, - { BTN_BASE4, GP2X_A }, - { KEY_RIGHTSHIFT, GP2X_L }, - { BTN_TL, GP2X_L }, - { KEY_RIGHTCTRL, GP2X_R }, - { BTN_TR, GP2X_R }, - { KEY_LEFTALT, GP2X_START }, - { BTN_START, GP2X_START }, - { KEY_LEFTCTRL, GP2X_SELECT }, - { BTN_SELECT, GP2X_SELECT }, - { KEY_COMMA, GP2X_VOL_DOWN }, - { KEY_DOT, GP2X_VOL_UP }, - { KEY_1, GP2X_PUSH }, -}; - -int host_read_btns(void) -{ - struct input_event ev; - int i, ret; - - while (1) - { - ret = read(ifds[0], &ev, sizeof(ev)); - if (ret < (int) sizeof(ev)) { - if (errno != EAGAIN && errno != EWOULDBLOCK) - perror(PFX "read error"); - - ret = read(ifds[1], &ev, sizeof(ev)); - if (ret < (int) sizeof(ev)) - if (errno != EAGAIN && errno != EWOULDBLOCK) - perror(PFX "read error"); - } - - if (ret < (int) sizeof(ev)) - return keystate; - - 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; - if (ev.value) - keystate |= (1 << key_map[i].btn); - else - keystate &= ~(1 << key_map[i].btn); - break; - } - } - - return keystate; -} -#endif +// vim:shiftwidth=2:expandtab diff --git a/loader/host_wiz.c b/loader/host_wiz.c index 18d7b1c..7763f35 100644 --- a/loader/host_wiz.c +++ b/loader/host_wiz.c @@ -17,7 +17,7 @@ extern int memdev, probably_caanoo; // leasing from wiz_video #define BTN_JOY BTN_JOYSTICK -struct in_default_bind in_evdev_defbinds[] = { +static struct in_default_bind wiz_evdev_defbinds[] = { { KEY_UP, IN_BINDTYPE_PLAYER12, GP2X_UP }, { KEY_DOWN, IN_BINDTYPE_PLAYER12, GP2X_DOWN }, { KEY_LEFT, IN_BINDTYPE_PLAYER12, GP2X_LEFT }, @@ -35,6 +35,10 @@ struct in_default_bind in_evdev_defbinds[] = { { 0, 0, 0 } }; +static const struct in_pdata wiz_evdev_pdata = { + .defbinds = wiz_evdev_defbinds, +}; + // todo: rm when generic code works on Wiz #if 0 static int gpiodev = -1; @@ -134,4 +138,9 @@ static void host_actions(int actions[IN_BINDTYPE_COUNT]) } } +static void host_init_input(void) +{ + in_evdev_init(&wiz_evdev_pdata); +} + // vim:shiftwidth=2:expandtab -- 2.39.2