gp2x->common menu migration finished, gp2x now only uses input fwk

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@692 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2009-05-14 13:41:48 +00:00
parent 9025b93159
commit 991473ad43
24 changed files with 207 additions and 1769 deletions

View file

@ -1,17 +0,0 @@
/* random common definitions */
#define PBTN_UP (1 << 0)
#define PBTN_DOWN (1 << 1)
#define PBTN_LEFT (1 << 2)
#define PBTN_RIGHT (1 << 3)
#define PBTN_MOK (1 << 4)
#define PBTN_MBACK (1 << 5)
#define PBTN_MA2 (1 << 6) /* menu action 2 */
#define PBTN_MA3 (1 << 7)
#define PBTN_L (1 << 8)
#define PBTN_R (1 << 9)
#define PBTN_MENU (1 << 10)

View file

@ -15,7 +15,6 @@
#include "fonts.h" #include "fonts.h"
#include "lprintf.h" #include "lprintf.h"
#include "config.h" #include "config.h"
#include "common.h"
#include "plat.h" #include "plat.h"
#include <pico/pico_int.h> #include <pico/pico_int.h>
@ -631,13 +630,7 @@ int emu_ReadConfig(int game, int no_defaults)
if (currentConfig.gamma < 10 || currentConfig.gamma > 300) currentConfig.gamma = 100; if (currentConfig.gamma < 10 || currentConfig.gamma > 300) currentConfig.gamma = 100;
#endif #endif
if (currentConfig.volume < 0 || currentConfig.volume > 99) currentConfig.volume = 50; if (currentConfig.volume < 0 || currentConfig.volume > 99) currentConfig.volume = 50;
#ifdef __GP2X__
// if volume keys are unbound, bind them to volume control
if (!currentConfig.KeyBinds[23] && !currentConfig.KeyBinds[22]) {
currentConfig.KeyBinds[23] = 1<<29; // vol up
currentConfig.KeyBinds[22] = 1<<30; // vol down
}
#endif
if (ret == 0) config_slot_current = config_slot; if (ret == 0) config_slot_current = config_slot;
return (ret == 0); return (ret == 0);
} }

View file

@ -40,12 +40,8 @@ typedef struct _currentConfig_t {
int s_PicoCDBuffers; int s_PicoCDBuffers;
int Frameskip; int Frameskip;
int CPUclock; int CPUclock;
int KeyBinds[PLAT_MAX_KEYS];
int volume; int volume;
int gamma; int gamma;
#if PLAT_HAVE_JOY
int JoyBinds[4][32];
#endif
int scaling; // gp2x: 0=center, 1=hscale, 2=hvscale, 3=hsoftscale; psp: bilinear filtering int scaling; // gp2x: 0=center, 1=hscale, 2=hvscale, 3=hsoftscale; psp: bilinear filtering
int rotation; // for UIQ int rotation; // for UIQ
float scale; // psp: screen scale float scale; // psp: screen scale

View file

@ -2,7 +2,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "common.h"
#include "input.h" #include "input.h"
#include "plat.h" #include "plat.h"
#include "../linux/in_evdev.h" #include "../linux/in_evdev.h"
@ -23,6 +22,8 @@ static in_drv_t in_drivers[IN_DRVID_COUNT];
static in_dev_t in_devices[IN_MAX_DEVS]; static in_dev_t in_devices[IN_MAX_DEVS];
static int in_dev_count = 0; static int in_dev_count = 0;
static int in_have_async_devs = 0; static int in_have_async_devs = 0;
static int menu_key_state = 0;
static int menu_last_used_dev = 0;
#define DRV(id) in_drivers[(unsigned)(id) < IN_DRVID_COUNT ? (id) : 0] #define DRV(id) in_drivers[(unsigned)(id) < IN_DRVID_COUNT ? (id) : 0]
@ -259,8 +260,6 @@ int in_update(void)
return result; return result;
} }
static int menu_key_state = 0;
void in_set_blocking(int is_blocking) void in_set_blocking(int is_blocking)
{ {
int i, ret; int i, ret;
@ -414,6 +413,7 @@ int in_menu_wait_any(int timeout_ms)
break; break;
if (code < 0) if (code < 0)
continue; continue;
menu_last_used_dev = dev_id;
if (keys_old != menu_key_state) if (keys_old != menu_key_state)
break; break;
} }
@ -516,9 +516,15 @@ const char *in_get_key_name(int dev_id, int keycode)
static char xname[16]; static char xname[16];
const char *name; const char *name;
if (dev_id < 0) /* want last used dev? */
dev_id = menu_last_used_dev;
if (dev_id < 0 || dev_id >= IN_MAX_DEVS) if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
return "Unkn0"; return "Unkn0";
if (keycode < 0) /* want name for menu key? */
keycode = DRV(in_devices[dev_id].drv_id).menu_translate(keycode);
name = DRV(in_devices[dev_id].drv_id).get_key_name(keycode); name = DRV(in_devices[dev_id].drv_id).get_key_name(keycode);
if (name != NULL) if (name != NULL)
return name; return name;

View file

@ -1,5 +1,21 @@
#define IN_MAX_DEVS 10 #define IN_MAX_DEVS 10
/* unified menu keys */
#define PBTN_UP (1 << 0)
#define PBTN_DOWN (1 << 1)
#define PBTN_LEFT (1 << 2)
#define PBTN_RIGHT (1 << 3)
#define PBTN_MOK (1 << 4)
#define PBTN_MBACK (1 << 5)
#define PBTN_MA2 (1 << 6) /* menu action 2 */
#define PBTN_MA3 (1 << 7)
#define PBTN_L (1 << 8)
#define PBTN_R (1 << 9)
#define PBTN_MENU (1 << 10)
enum { enum {
IN_DRVID_UNKNOWN = 0, IN_DRVID_UNKNOWN = 0,
IN_DRVID_GP2X, IN_DRVID_GP2X,

View file

@ -12,7 +12,6 @@
#include "fonts.h" #include "fonts.h"
#include "readpng.h" #include "readpng.h"
#include "lprintf.h" #include "lprintf.h"
#include "common.h"
#include "input.h" #include "input.h"
#include "emu.h" #include "emu.h"
#include "plat.h" #include "plat.h"
@ -641,6 +640,44 @@ void menu_romload_end(void)
plat_video_menu_end(); plat_video_menu_end();
} }
// -------------- del confirm ---------------
static void do_delete(const char *fpath, const char *fname)
{
int len, mid, inp;
const char *nm;
char tmp[64];
plat_video_menu_begin();
if (!rom_loaded)
menu_darken_bg(g_screen_ptr, g_screen_width * g_screen_height, 0);
len = strlen(fname);
if (len > g_screen_width/6)
len = g_screen_width/6;
mid = g_screen_width / 2;
text_out16(mid - me_mfont_w * 15 / 2, 8 * me_mfont_h, "About to delete");
smalltext_out16(mid - len * me_sfont_w / 2, 9 * me_mfont_h + 5, fname, 0xbdff);
text_out16(mid - me_mfont_w * 13 / 2, 11 * me_mfont_h, "Are you sure?");
nm = in_get_key_name(-1, -PBTN_MA3);
snprintf(tmp, sizeof(tmp), "(%s - confirm, ", nm);
len = strlen(tmp);
nm = in_get_key_name(-1, -PBTN_MBACK);
snprintf(tmp + len, sizeof(tmp) - len, "%s - cancel)", nm);
len = strlen(tmp);
text_out16(mid - me_mfont_w * len / 2, 12 * me_mfont_h, tmp);
plat_video_menu_end();
while (in_menu_wait_any(50) & (PBTN_MENU|PBTN_MA2));
inp = in_menu_wait(PBTN_MA3|PBTN_MBACK, 100);
if (inp & PBTN_MA3)
remove(fpath);
}
// -------------- ROM selector -------------- // -------------- ROM selector --------------
// rrrr rggg gggb bbbb // rrrr rggg gggb bbbb
@ -788,7 +825,7 @@ rescan:
ret = rom_fname_reload; ret = rom_fname_reload;
break; break;
} }
// do_delete(rom_fname_reload, namelist[sel+1]->d_name); // TODO do_delete(rom_fname_reload, namelist[sel+1]->d_name);
if (n > 0) { if (n > 0) {
while (n--) free(namelist[n]); while (n--) free(namelist[n]);
free(namelist); free(namelist);

View file

@ -29,8 +29,6 @@
#define dprintf(x...) #define dprintf(x...)
// platform // platform
#define PLAT_MAX_KEYS 32
#define PLAT_HAVE_JOY 0
#define PATH_SEP "/" // because of cegcc #define PATH_SEP "/" // because of cegcc
#define PATH_SEP_C '/' #define PATH_SEP_C '/'
#define MENU_X2 0 #define MENU_X2 0

View file

@ -13,7 +13,6 @@
#include "code940/940shared.h" #include "code940/940shared.h"
#include "gp2x.h" #include "gp2x.h"
#include "emu.h" #include "emu.h"
#include "menu.h"
#include "../common/mp3.h" #include "../common/mp3.h"
#include "../common/arm_utils.h" #include "../common/arm_utils.h"
#include "../common/menu.h" #include "../common/menu.h"

View file

@ -16,7 +16,7 @@
#include "emu.h" #include "emu.h"
#include "gp2x.h" #include "gp2x.h"
#include "menu.h" #include "../common/menu.h"
#include "../common/arm_utils.h" #include "../common/arm_utils.h"
#include "../common/fonts.h" #include "../common/fonts.h"
#include "../common/emu.h" #include "../common/emu.h"
@ -145,19 +145,6 @@ void emu_prepareDefaultConfig(void)
defaultConfig.Frameskip = -1; // auto defaultConfig.Frameskip = -1; // auto
defaultConfig.CPUclock = 200; defaultConfig.CPUclock = 200;
defaultConfig.volume = 50; defaultConfig.volume = 50;
defaultConfig.KeyBinds[ 0] = 1<<0; // SACB RLDU
defaultConfig.KeyBinds[ 4] = 1<<1;
defaultConfig.KeyBinds[ 2] = 1<<2;
defaultConfig.KeyBinds[ 6] = 1<<3;
defaultConfig.KeyBinds[14] = 1<<4;
defaultConfig.KeyBinds[13] = 1<<5;
defaultConfig.KeyBinds[12] = 1<<6;
defaultConfig.KeyBinds[ 8] = 1<<7;
defaultConfig.KeyBinds[15] = 1<<26; // switch rend
defaultConfig.KeyBinds[10] = 1<<27; // save state
defaultConfig.KeyBinds[11] = 1<<28; // load state
defaultConfig.KeyBinds[23] = 1<<29; // vol up
defaultConfig.KeyBinds[22] = 1<<30; // vol down
defaultConfig.gamma = 100; defaultConfig.gamma = 100;
defaultConfig.scaling = 0; defaultConfig.scaling = 0;
defaultConfig.turbo_rate = 15; defaultConfig.turbo_rate = 15;
@ -415,7 +402,7 @@ static void emu_msg_tray_open(void)
gettimeofday(&noticeMsgTime, 0); gettimeofday(&noticeMsgTime, 0);
} }
static void RunEventsPico(unsigned int events, unsigned int gp2x_keys) static void RunEventsPico(unsigned int events)
{ {
int ret, px, py, lim_x; int ret, px, py, lim_x;
static int pdown_frames = 0; static int pdown_frames = 0;
@ -449,11 +436,11 @@ static void RunEventsPico(unsigned int events, unsigned int gp2x_keys)
// PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000; // PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;
} }
if (PicoPad[0] & 1) pico_pen_y--;
if (PicoPad[0] & 2) pico_pen_y++;
if (PicoPad[0] & 4) pico_pen_x--;
if (PicoPad[0] & 8) pico_pen_x++;
PicoPad[0] &= ~0x0f; // release UDLR PicoPad[0] &= ~0x0f; // release UDLR
if (gp2x_keys & GP2X_UP) pico_pen_y--;
if (gp2x_keys & GP2X_DOWN) pico_pen_y++;
if (gp2x_keys & GP2X_LEFT) pico_pen_x--;
if (gp2x_keys & GP2X_RIGHT) pico_pen_x++;
lim_x = (Pico.video.reg[12]&1) ? 319 : 255; lim_x = (Pico.video.reg[12]&1) ? 319 : 255;
if (pico_pen_y < 8) pico_pen_y = 8; if (pico_pen_y < 8) pico_pen_y = 8;
@ -508,14 +495,30 @@ static void RunEvents(unsigned int which)
int do_it = 1; int do_it = 1;
if ( emu_checkSaveFile(state_slot) && if ( emu_checkSaveFile(state_slot) &&
(( (which & 0x1000) && (currentConfig.EmuOpt & 0x800)) || // load (( (which & 0x1000) && (currentConfig.EmuOpt & 0x800)) || // load
(!(which & 0x1000) && (currentConfig.EmuOpt & 0x200))) ) { // save (!(which & 0x1000) && (currentConfig.EmuOpt & 0x200))) ) // save
unsigned long keys; {
blit("", (which & 0x1000) ? "LOAD STATE? (Y=yes, X=no)" : "OVERWRITE SAVE? (Y=yes, X=no)"); const char *nm;
while ( !((keys = gp2x_joystick_read(1)) & (GP2X_X|GP2X_Y)) ) char tmp[64];
usleep(50*1024); int keys, len;
if (keys & GP2X_X) do_it = 0;
while ( gp2x_joystick_read(1) & (GP2X_X|GP2X_Y) ) // wait for release strcpy(tmp, (which & 0x1000) ? "LOAD STATE? " : "OVERWRITE SAVE? ");
usleep(50*1024); len = strlen(tmp);
nm = in_get_key_name(-1, -PBTN_MA3);
snprintf(tmp + len, sizeof(tmp) - len, "(%s=yes, ", nm);
len = strlen(tmp);
nm = in_get_key_name(-1, -PBTN_MBACK);
snprintf(tmp + len, sizeof(tmp) - len, "%s=no)", nm);
blit("", tmp);
in_set_blocking(1);
while (in_menu_wait_any(50) & (PBTN_MA3|PBTN_MBACK)); // wait for release
while ( !((keys = in_menu_wait_any(50)) & (PBTN_MA3|PBTN_MBACK)) ); // .. press
if (keys & PBTN_MBACK)
do_it = 0;
while (in_menu_wait_any(50) & (PBTN_MA3|PBTN_MBACK)); // .. release
in_set_blocking(0);
clearArea(0); clearArea(0);
} }
if (do_it) { if (do_it) {
@ -544,7 +547,7 @@ static void RunEvents(unsigned int which)
strcpy(noticeMsg, " 8bit accurate renderer"); strcpy(noticeMsg, " 8bit accurate renderer");
} }
gettimeofday(&noticeMsgTime, 0); emu_noticeMsgUpdated();
} }
if (which & 0x0300) if (which & 0x0300)
{ {
@ -556,7 +559,7 @@ static void RunEvents(unsigned int which)
if(state_slot > 9) state_slot = 0; if(state_slot > 9) state_slot = 0;
} }
sprintf(noticeMsg, "SAVE SLOT %i [%s]", state_slot, emu_checkSaveFile(state_slot) ? "USED" : "FREE"); sprintf(noticeMsg, "SAVE SLOT %i [%s]", state_slot, emu_checkSaveFile(state_slot) ? "USED" : "FREE");
gettimeofday(&noticeMsgTime, 0); emu_noticeMsgUpdated();
} }
if (which & 0x0080) { if (which & 0x0080) {
engineState = PGS_Menu; engineState = PGS_Menu;
@ -565,16 +568,9 @@ static void RunEvents(unsigned int which)
static void updateKeys(void) static void updateKeys(void)
{ {
unsigned int keys, keys2, allActions[2] = { 0, 0 }, events; unsigned int allActions[2] = { 0, 0 }, events;
static unsigned int prevEvents = 0; static unsigned int prevEvents = 0;
keys = gp2x_joystick_read(0);
if (keys & GP2X_SELECT)
engineState = select_exits ? PGS_Quit : PGS_Menu;
keys &= CONFIGURABLE_KEYS;
keys2 = keys;
/* FIXME: player2 */ /* FIXME: player2 */
allActions[0] = in_update(); allActions[0] = in_update();
@ -599,7 +595,7 @@ static void updateKeys(void)
events &= ~prevEvents; events &= ~prevEvents;
if (PicoAHW == PAHW_PICO) if (PicoAHW == PAHW_PICO)
RunEventsPico(events, keys); RunEventsPico(events);
if (events) RunEvents(events); if (events) RunEvents(events);
if (movie_data) emu_updateMovie(); if (movie_data) emu_updateMovie();

View file

@ -195,18 +195,6 @@ void gp2x_pd_clone_buffer2(void)
} }
unsigned long gp2x_joystick_read(int unused)
{
unsigned long value=(gp2x_memregs[0x1198>>1] & 0x00FF); // GPIO M
if(value==0xFD) value=0xFA;
if(value==0xF7) value=0xEB;
if(value==0xDF) value=0xAF;
if(value==0x7F) value=0xBE;
value = ~((gp2x_memregs[0x1184>>1] & 0xFF00) | value | (gp2x_memregs[0x1186>>1] << 16)); // C D
return value;
}
typedef struct ucb1x00_ts_event typedef struct ucb1x00_ts_event
{ {
unsigned short pressure; unsigned short pressure;

View file

@ -21,7 +21,6 @@ void gp2x_memset_all_buffers(int offset, int byte, int len);
void gp2x_pd_clone_buffer2(void); void gp2x_pd_clone_buffer2(void);
/* input */ /* input */
unsigned long gp2x_joystick_read(int allow_usb_joy);
int gp2x_touchpad_read(int *x, int *y); int gp2x_touchpad_read(int *x, int *y);
/* 940 core */ /* 940 core */
@ -32,9 +31,4 @@ void Reset940(int yes, int bank);
extern int memdev; extern int memdev;
enum { GP2X_UP=0x1, GP2X_LEFT=0x4, GP2X_DOWN=0x10, GP2X_RIGHT=0x40,
GP2X_START=1<<8, GP2X_SELECT=1<<9, GP2X_L=1<<10, GP2X_R=1<<11,
GP2X_A=1<<12, GP2X_B=1<<13, GP2X_X=1<<14, GP2X_Y=1<<15,
GP2X_VOL_UP=1<<23, GP2X_VOL_DOWN=1<<22, GP2X_PUSH=1<<27 };
#endif #endif

View file

@ -1,7 +1,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "../common/common.h"
#include "../common/input.h" #include "../common/input.h"
#include "in_gp2x.h" #include "in_gp2x.h"
@ -102,20 +101,45 @@ int in_gp2x_update_keycode(void *data, int *is_down)
return i; return i;
} }
static const struct {
short key;
short pbtn;
} key_pbtn_map[] =
{
{ BTN_UP, PBTN_UP },
{ BTN_DOWN, PBTN_DOWN },
{ BTN_LEFT, PBTN_LEFT },
{ BTN_RIGHT, PBTN_RIGHT },
{ BTN_B, PBTN_MOK },
{ BTN_X, PBTN_MBACK },
{ BTN_A, PBTN_MA2 },
{ BTN_Y, PBTN_MA3 },
{ BTN_L, PBTN_L },
{ BTN_R, PBTN_R },
{ BTN_SELECT, PBTN_MENU },
};
#define KEY_PBTN_MAP_SIZE (sizeof(key_pbtn_map) / sizeof(key_pbtn_map[0]))
static int in_gp2x_menu_translate(int keycode) static int in_gp2x_menu_translate(int keycode)
{ {
switch (keycode) { int i;
case BTN_UP: return PBTN_UP; if (keycode < 0)
case BTN_LEFT: return PBTN_LEFT; {
case BTN_DOWN: return PBTN_DOWN; /* menu -> kc */
case BTN_RIGHT: return PBTN_RIGHT; keycode = -keycode;
case BTN_B: return PBTN_MOK; for (i = 0; i < KEY_PBTN_MAP_SIZE; i++)
case BTN_X: return PBTN_MBACK; if (key_pbtn_map[i].pbtn == keycode)
case BTN_SELECT:return PBTN_MENU; return key_pbtn_map[i].key;
case BTN_L: return PBTN_L;
case BTN_R: return PBTN_R;
default: return 0;
} }
else
{
for (i = 0; i < KEY_PBTN_MAP_SIZE; i++)
if (key_pbtn_map[i].key == keycode)
return key_pbtn_map[i].pbtn;
}
return 0;
} }
static int in_gp2x_get_key_code(const char *key_name) static int in_gp2x_get_key_code(const char *key_name)
@ -156,6 +180,12 @@ static const struct {
{ BTN_B, 5 }, /* C */ { BTN_B, 5 }, /* C */
{ BTN_A, 6 }, /* A */ { BTN_A, 6 }, /* A */
{ BTN_START, 7 }, { BTN_START, 7 },
{ BTN_SELECT, 23 }, /* menu */
{ BTN_Y, 26 }, /* switch rend */
{ BTN_L, 27 }, /* save state */
{ BTN_R, 28 }, /* load state */
{ BTN_VOL_UP, 29 }, /* vol up */
{ BTN_VOL_DOWN, 30 }, /* vol down */
}; };
#define DEF_BIND_COUNT (sizeof(in_gp2x_def_binds) / sizeof(in_gp2x_def_binds[0])) #define DEF_BIND_COUNT (sizeof(in_gp2x_def_binds) / sizeof(in_gp2x_def_binds[0]))
@ -171,14 +201,28 @@ static void in_gp2x_get_def_binds(int *binds)
/* remove binds of missing keys, count remaining ones */ /* remove binds of missing keys, count remaining ones */
static int in_gp2x_clean_binds(void *drv_data, int *binds) static int in_gp2x_clean_binds(void *drv_data, int *binds)
{ {
int i, count = 0; int i, count = 0, have_vol = 0, have_menu = 0;
for (i = 0; i < IN_GP2X_NBUTTONS; i++) { for (i = 0; i < IN_GP2X_NBUTTONS; i++) {
if (in_gp2x_keys[i] == NULL) if (in_gp2x_keys[i] == NULL)
binds[i] = binds[i + IN_GP2X_NBUTTONS] = 0; binds[i] = binds[i + IN_GP2X_NBUTTONS] = 0;
if (binds[i]) if (binds[i]) {
count++; count++;
if (binds[i] & ((1 << 29)|(1 << 30)))
have_vol = 1;
if (binds[i] & (1 << 23))
have_menu = 1;
} }
}
/* autobind some important keys, if they are unbound */
if (!have_vol && binds[BTN_VOL_UP] == 0 && binds[BTN_VOL_DOWN] == 0) {
binds[BTN_VOL_UP] = 1 << 29;
binds[BTN_VOL_DOWN] = 1 << 30;
}
if (!have_menu && binds[BTN_SELECT] == 0)
binds[BTN_SELECT] = 1 << 23;
in_combos_find(binds, BTN_PUSH, &in_gp2x_combo_keys, &in_gp2x_combo_acts); in_combos_find(binds, BTN_PUSH, &in_gp2x_combo_keys, &in_gp2x_combo_acts);

View file

@ -11,7 +11,6 @@
#include <linux/limits.h> #include <linux/limits.h>
#include "gp2x.h" #include "gp2x.h"
#include "menu.h"
#include "../common/menu.h" #include "../common/menu.h"
#include "../common/emu.h" #include "../common/emu.h"
#include "../common/config.h" #include "../common/config.h"

File diff suppressed because it is too large Load diff

View file

@ -1,14 +0,0 @@
// (c) Copyright 2006,2007 notaz, All rights reserved.
// Free for non-commercial use.
// For commercial use, separate licencing terms must be obtained.
void menu_loop(void);
int menu_loop_tray(void);
void menu_romload_prepare(const char *rom_name);
void menu_romload_end(void);
#define CONFIGURABLE_KEYS \
(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_A|GP2X_B|GP2X_X|GP2X_Y| \
GP2X_START|GP2X_SELECT|GP2X_L|GP2X_R|GP2X_PUSH|GP2X_VOL_UP|GP2X_VOL_DOWN)

View file

@ -31,8 +31,6 @@
#define dprintf(x...) #define dprintf(x...)
// platform // platform
#define PLAT_MAX_KEYS 32
#define PLAT_HAVE_JOY 1
#define PATH_SEP "/" #define PATH_SEP "/"
#define PATH_SEP_C '/' #define PATH_SEP_C '/'
#define MENU_X2 0 #define MENU_X2 0

View file

@ -11,7 +11,6 @@
#include "../../pico/sound/ym2612.h" #include "../../pico/sound/ym2612.h"
#include "../gp2x/gp2x.h" #include "../gp2x/gp2x.h"
#include "../gp2x/emu.h" #include "../gp2x/emu.h"
#include "../gp2x/menu.h"
#include "../gp2x/code940/940shared.h" #include "../gp2x/code940/940shared.h"
#include "../common/helix/pub/mp3dec.h" #include "../common/helix/pub/mp3dec.h"
#include "../../pico/pico_int.h" #include "../../pico/pico_int.h"

View file

@ -48,6 +48,12 @@ static void destroy (GtkWidget *widget, gpointer data)
gtk_main_quit (); gtk_main_quit ();
} }
/* faking GP2X pad */
enum { GP2X_UP=0x1, GP2X_LEFT=0x4, GP2X_DOWN=0x10, GP2X_RIGHT=0x40,
GP2X_START=1<<8, GP2X_SELECT=1<<9, GP2X_L=1<<10, GP2X_R=1<<11,
GP2X_A=1<<12, GP2X_B=1<<13, GP2X_X=1<<14, GP2X_Y=1<<15,
GP2X_VOL_UP=1<<23, GP2X_VOL_DOWN=1<<22, GP2X_PUSH=1<<27 };
static gint key_press_event (GtkWidget *widget, GdkEventKey *event) static gint key_press_event (GtkWidget *widget, GdkEventKey *event)
{ {
switch (event->hardware_keycode) switch (event->hardware_keycode)
@ -334,11 +340,6 @@ void gp2x_pd_clone_buffer2(void)
} }
/* joy */ /* joy */
unsigned long gp2x_joystick_read(int allow_usb_joy)
{
return current_keys;
}
int gp2x_touchpad_read(int *x, int *y) int gp2x_touchpad_read(int *x, int *y)
{ {
return -1; return -1;

View file

@ -9,7 +9,6 @@
#include <linux/input.h> #include <linux/input.h>
#include <errno.h> #include <errno.h>
#include "../common/common.h"
#include "../common/input.h" #include "../common/input.h"
#include "in_evdev.h" #include "in_evdev.h"
@ -354,29 +353,50 @@ static int in_evdev_update_keycode(void *data, int *is_down)
return -1; return -1;
} }
static const struct {
short key;
short pbtn;
} key_pbtn_map[] =
{
{ KEY_UP, PBTN_UP },
{ KEY_DOWN, PBTN_DOWN },
{ KEY_LEFT, PBTN_LEFT },
{ KEY_RIGHT, PBTN_RIGHT },
{ KEY_ENTER, PBTN_MOK },
{ BTN_A, PBTN_MOK },
{ BTN_TRIGGER, PBTN_MOK },
{ KEY_ESC, PBTN_MBACK },
{ BTN_B, PBTN_MBACK },
{ BTN_THUMB, PBTN_MBACK },
{ KEY_A, PBTN_MA2 },
{ KEY_S, PBTN_MA3 },
{ KEY_BACKSLASH, PBTN_MENU },
{ KEY_MENU, PBTN_MENU },
{ KEY_LEFTBRACE, PBTN_L },
{ KEY_RIGHTBRACE, PBTN_R },
};
#define KEY_PBTN_MAP_SIZE (sizeof(key_pbtn_map) / sizeof(key_pbtn_map[0]))
static int in_evdev_menu_translate(int keycode) static int in_evdev_menu_translate(int keycode)
{ {
switch (keycode) { int i;
case KEY_UP: return PBTN_UP; if (keycode < 0)
case KEY_DOWN: return PBTN_DOWN; {
case KEY_LEFT: return PBTN_LEFT; /* menu -> kc */
case KEY_RIGHT: return PBTN_RIGHT; keycode = -keycode;
case KEY_ENTER: for (i = 0; i < KEY_PBTN_MAP_SIZE; i++)
case BTN_A: if (key_pbtn_map[i].pbtn == keycode)
case BTN_TRIGGER: return key_pbtn_map[i].key;
return PBTN_MOK;
case KEY_ESC:
case BTN_B:
case BTN_THUMB:
return PBTN_MBACK;
case KEY_MENU:
return PBTN_MENU;
case KEY_LEFTBRACE:
return PBTN_L;
case KEY_RIGHTBRACE:
return PBTN_R;
default: return 0;
} }
else
{
for (i = 0; i < KEY_PBTN_MAP_SIZE; i++)
if (key_pbtn_map[i].key == keycode)
return key_pbtn_map[i].pbtn;
}
return 0;
} }
static int in_evdev_get_key_code(const char *key_name) static int in_evdev_get_key_code(const char *key_name)
@ -421,6 +441,8 @@ static const struct {
{ BTN_Y, 6 }, { BTN_Y, 6 },
{ KEY_ENTER, 7 }, { KEY_ENTER, 7 },
{ BTN_START, 7 }, { BTN_START, 7 },
{ BTN_TL, 27 }, /* save state */
{ BTN_TR, 28 }, /* load state */
}; };
#define DEF_BIND_COUNT (sizeof(in_evdev_def_binds) / sizeof(in_evdev_def_binds[0])) #define DEF_BIND_COUNT (sizeof(in_evdev_def_binds) / sizeof(in_evdev_def_binds[0]))

View file

@ -35,8 +35,6 @@
#define dprintf(x...) #define dprintf(x...)
// platform // platform
#define PLAT_MAX_KEYS 32
#define PLAT_HAVE_JOY 1
#define PATH_SEP "/" #define PATH_SEP "/"
#define PATH_SEP_C '/' #define PATH_SEP_C '/'
#define MENU_X2 0 #define MENU_X2 0

View file

@ -19,7 +19,6 @@
#include "../common/emu.h" #include "../common/emu.h"
#include "../common/menu.h" #include "../common/menu.h"
#include "../common/config.h" #include "../common/config.h"
#include "../common/common.h"
#include "../common/input.h" #include "../common/input.h"
#include "../linux/sndout_oss.h" #include "../linux/sndout_oss.h"
#include "asm_utils.h" #include "asm_utils.h"

View file

@ -31,8 +31,6 @@
#define dprintf(x...) #define dprintf(x...)
// platform // platform
#define PLAT_MAX_KEYS 32
#define PLAT_HAVE_JOY 1
#define PATH_SEP "/" #define PATH_SEP "/"
#define PATH_SEP_C '/' #define PATH_SEP_C '/'
#define MENU_X2 1 #define MENU_X2 1

View file

@ -33,8 +33,6 @@ extern void blit1(void);
#define dprintf(x...) #define dprintf(x...)
// platform // platform
#define PLAT_MAX_KEYS 32
#define PLAT_HAVE_JOY 0
#define PATH_SEP "/" #define PATH_SEP "/"
#define PATH_SEP_C '/' #define PATH_SEP_C '/'
#define MENU_X2 0 #define MENU_X2 0

View file

@ -26,8 +26,6 @@
#define dprintf(x...) #define dprintf(x...)
// platform // platform
#define PLAT_MAX_KEYS (256+19)
#define PLAT_HAVE_JOY 0
#define PATH_SEP "\\" #define PATH_SEP "\\"
#define PATH_SEP_C '\\' #define PATH_SEP_C '\\'
#define MENU_X2 0 #define MENU_X2 0