2 * GINGE - GINGE Is Not Gp2x Emulator
5 * This work is licensed under the MAME license, see COPYING file for details.
12 #include <linux/input.h>
14 #include "../common/warm/warm.h"
16 extern int memdev, probably_caanoo; // leasing from wiz_video
18 #define BTN_JOY BTN_JOYSTICK
20 static struct in_default_bind wiz_evdev_defbinds[] = {
21 { KEY_UP, IN_BINDTYPE_PLAYER12, GP2X_UP },
22 { KEY_DOWN, IN_BINDTYPE_PLAYER12, GP2X_DOWN },
23 { KEY_LEFT, IN_BINDTYPE_PLAYER12, GP2X_LEFT },
24 { KEY_RIGHT, IN_BINDTYPE_PLAYER12, GP2X_RIGHT },
25 { BTN_JOY + 0, IN_BINDTYPE_PLAYER12, GP2X_A },
26 { BTN_JOY + 1, IN_BINDTYPE_PLAYER12, GP2X_X },
27 { BTN_JOY + 2, IN_BINDTYPE_PLAYER12, GP2X_B },
28 { BTN_JOY + 3, IN_BINDTYPE_PLAYER12, GP2X_Y },
29 { BTN_JOY + 4, IN_BINDTYPE_PLAYER12, GP2X_L },
30 { BTN_JOY + 5, IN_BINDTYPE_PLAYER12, GP2X_R },
31 { BTN_JOY + 8, IN_BINDTYPE_PLAYER12, GP2X_START },
32 { BTN_JOY + 9, IN_BINDTYPE_PLAYER12, GP2X_SELECT },
33 { BTN_JOY + 10, IN_BINDTYPE_PLAYER12, GP2X_PUSH },
34 { BTN_JOY + 6, IN_BINDTYPE_EMU, 0 },
38 static const struct in_pdata wiz_evdev_pdata = {
39 .defbinds = wiz_evdev_defbinds,
42 // todo: rm when generic code works on Wiz
44 static int gpiodev = -1;
48 gpiodev = open("/dev/GPIO", O_RDONLY);
50 perror(PFX "couldn't open /dev/GPIO");
55 int host_read_btns(void)
59 r = read(gpiodev, &value, 4);
73 void *host_mmap_upper(void)
78 // make sure this never happens on Caanoo
79 if (probably_caanoo) {
80 err("Wiz mmap code called on Caanoo?");
85 // <linux mem> 03460000-03ffffff 00ba0000
86 // 02aa0000-02dfffff 03100000-0345ffff 00360000
87 // <linux mem> 03000000-030fffff 00100000
88 // 03000000-03ffffff 02000000-02ffffff 01000000
89 ret = mmap((void *)0x82000000, 0x1000000, PROT_READ|PROT_WRITE|PROT_EXEC,
90 MAP_SHARED|MAP_FIXED, memdev, 0x3000000);
91 if (ret != (void *)0x82000000)
94 ret = mmap((void *)0x83000000, 0x100000, PROT_READ|PROT_WRITE|PROT_EXEC,
95 MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);
96 if (ret != (void *)0x83000000)
99 ret = mmap((void *)0x83100000, 0x360000, PROT_READ|PROT_WRITE|PROT_EXEC,
100 MAP_SHARED|MAP_FIXED, memdev, 0x2aa0000);
101 if (ret != (void *)0x83100000)
104 ret = mmap((void *)0x83460000, 0xba0000, PROT_READ|PROT_WRITE|PROT_EXEC,
105 MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);
106 if (ret != (void *)0x83460000)
109 r = warm_change_cb_range(WCB_B_BIT|WCB_C_BIT, 1, (void *)0x82000000, 0x1000000);
110 r |= warm_change_cb_range(WCB_B_BIT|WCB_C_BIT, 1, (void *)0x83100000, 0x360000);
112 err("could not make upper mem cacheable.\n");
114 return (void *)0x82000000;
117 err("mmap %p: ", ret);
122 static void host_actions(int actions[IN_BINDTYPE_COUNT])
124 if (probably_caanoo && (actions[IN_BINDTYPE_EMU] & 1)) {
125 // 'home key as Fn' handling
126 int act = actions[IN_BINDTYPE_PLAYER12];
127 if (act & (1 << GP2X_START)) {
128 act &= ~(1 << GP2X_START);
129 act |= 1 << GP2X_VOL_UP;
131 if (act & (1 << GP2X_SELECT)) {
132 act &= ~(1 << GP2X_SELECT);
133 act |= 1 << GP2X_VOL_DOWN;
135 if (act & (1 << GP2X_Y))
137 actions[IN_BINDTYPE_PLAYER12] = act;
141 static void host_init_input(void)
143 in_evdev_init(&wiz_evdev_pdata);
146 // vim:shiftwidth=2:expandtab