endif
ifdef PND
CFLAGS += -DPND
-OBJ += host_pnd.o
TAG = _pnd
endif
ifdef WIZ
CFLAGS += -DWIZ
-OBJ += host_wiz.o wiz_video_arm.o
+OBJ += wiz_video_arm.o
TAG = _wiz
endif
TARGET_S = ginge_sloader$(TAG)
TARGET_D = ginge_dyn$(TAG)
-OBJ += emu.o host_fb.o cmn.o
+OBJ += emu.o host.o host_fb.o cmn.o
OBJ_S += $(OBJ) loader.o loader_$(ARCH).o patches.o
OBJ_D += $(OBJ) dl.o
int host_init(void);
int host_read_btns(void);
+void host_forced_exit(void);
enum { GP2X_UP = 0, GP2X_LEFT = 2, GP2X_DOWN = 4, GP2X_RIGHT = 6,
GP2X_START = 8, GP2X_SELECT = 9, GP2X_L = 10, GP2X_R = 11,
--- /dev/null
+// vim:shiftwidth=2:expandtab
+
+#define _GNU_SOURCE // for plat.c
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "header.h"
+#include "realfuncs.h"
+
+#define IN_EVDEV
+#include "../common/common/input.c"
+#include "../common/linux/plat.c"
+#include "../common/linux/in_evdev.c"
+
+#ifdef PND
+#include "host_pnd.c"
+#elif defined(WIZ)
+#include "host_wiz.c"
+#endif
+
+// for plat.c
+char **g_argv;
+
+int host_init(void)
+{
+ in_init();
+ in_probe();
+
+ return 0;
+}
+
+int host_read_btns(void)
+{
+ int actions[IN_BINDTYPE_COUNT] = { 0, };
+
+ in_update(actions);
+ host_actions(actions);
+
+ return actions[IN_BINDTYPE_PLAYER12];
+}
+
+void host_forced_exit(void)
+{
+ // exit() might not be enough because loader and app data is out of sync,
+ // and other threads (which are really processes on this old glibc used)
+ // might not exit properly.
+ system("killall ginge_sloader");
+ usleep(300000);
+ system("killall -9 ginge_sloader");
+ exit(1);
+}
// 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 <stdio.h>
#include <string.h>
return keystate;
}
-
+#endif
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
-
-#include "header.h"
-#include "../common/warm.h"
-#include "realfuncs.h"
-
+#include <linux/input.h>
+
+#include "../common/warm/warm.h"
+
+extern int memdev, probably_caanoo; // leasing from wiz_video
+
+#define BTN_JOY BTN_JOYSTICK
+
+struct in_default_bind in_evdev_defbinds[] = {
+ { KEY_UP, IN_BINDTYPE_PLAYER12, GP2X_UP },
+ { KEY_DOWN, IN_BINDTYPE_PLAYER12, GP2X_DOWN },
+ { KEY_LEFT, IN_BINDTYPE_PLAYER12, GP2X_LEFT },
+ { KEY_RIGHT, IN_BINDTYPE_PLAYER12, GP2X_RIGHT },
+ { BTN_JOY + 0, IN_BINDTYPE_PLAYER12, GP2X_A },
+ { BTN_JOY + 1, IN_BINDTYPE_PLAYER12, GP2X_X },
+ { BTN_JOY + 2, IN_BINDTYPE_PLAYER12, GP2X_B },
+ { BTN_JOY + 3, IN_BINDTYPE_PLAYER12, GP2X_Y },
+ { BTN_JOY + 4, IN_BINDTYPE_PLAYER12, GP2X_L },
+ { BTN_JOY + 5, IN_BINDTYPE_PLAYER12, GP2X_R },
+ { BTN_JOY + 8, IN_BINDTYPE_PLAYER12, GP2X_START },
+ { BTN_JOY + 9, IN_BINDTYPE_PLAYER12, GP2X_SELECT },
+ { BTN_JOY + 10, IN_BINDTYPE_PLAYER12, GP2X_PUSH },
+ { BTN_JOY + 6, IN_BINDTYPE_EMU, 0 },
+ { 0, 0, 0 }
+};
+
+// todo: rm when generic code works on Wiz
+#if 0
static int gpiodev = -1;
-extern int memdev; // leasing from wiz_video
int host_init(void)
{
return value;
}
+#endif
void *host_mmap_upper(void)
{
void *ret;
int r;
+ // make sure this never happens on Caanoo
+ if (probably_caanoo) {
+ err("Wiz mmap code called on Caanoo?");
+ return MAP_FAILED;
+ }
+
// Wiz GP2X
// <linux mem> 03460000-03ffffff 00ba0000
// 02aa0000-02dfffff 03100000-0345ffff 00360000
exit(1);
}
+static void host_actions(int actions[IN_BINDTYPE_COUNT])
+{
+ if (probably_caanoo && (actions[IN_BINDTYPE_EMU] & 1)) {
+ // 'home key as Fn' handling
+ int act = actions[IN_BINDTYPE_PLAYER12];
+ if (act & (1 << GP2X_START)) {
+ act &= ~(1 << GP2X_START);
+ act |= 1 << GP2X_VOL_UP;
+ }
+ if (act & (1 << GP2X_SELECT)) {
+ act &= ~(1 << GP2X_SELECT);
+ act |= 1 << GP2X_VOL_DOWN;
+ }
+ if (act & (1 << GP2X_Y))
+ host_forced_exit();
+ actions[IN_BINDTYPE_PLAYER12] = act;
+ }
+}