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

git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@692 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2009-05-14 13:41:48 +00:00
parent 2c60056042
commit 82abf46f3d
22 changed files with 207 additions and 1765 deletions

View file

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

View file

@ -16,7 +16,7 @@
#include "emu.h"
#include "gp2x.h"
#include "menu.h"
#include "../common/menu.h"
#include "../common/arm_utils.h"
#include "../common/fonts.h"
#include "../common/emu.h"
@ -145,19 +145,6 @@ void emu_prepareDefaultConfig(void)
defaultConfig.Frameskip = -1; // auto
defaultConfig.CPUclock = 200;
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.scaling = 0;
defaultConfig.turbo_rate = 15;
@ -415,7 +402,7 @@ static void emu_msg_tray_open(void)
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;
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;
}
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
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;
if (pico_pen_y < 8) pico_pen_y = 8;
@ -507,15 +494,31 @@ static void RunEvents(unsigned int which)
{
int do_it = 1;
if ( emu_checkSaveFile(state_slot) &&
(( (which & 0x1000) && (currentConfig.EmuOpt & 0x800)) || // load
(!(which & 0x1000) && (currentConfig.EmuOpt & 0x200))) ) { // save
unsigned long keys;
blit("", (which & 0x1000) ? "LOAD STATE? (Y=yes, X=no)" : "OVERWRITE SAVE? (Y=yes, X=no)");
while ( !((keys = gp2x_joystick_read(1)) & (GP2X_X|GP2X_Y)) )
usleep(50*1024);
if (keys & GP2X_X) do_it = 0;
while ( gp2x_joystick_read(1) & (GP2X_X|GP2X_Y) ) // wait for release
usleep(50*1024);
(( (which & 0x1000) && (currentConfig.EmuOpt & 0x800)) || // load
(!(which & 0x1000) && (currentConfig.EmuOpt & 0x200))) ) // save
{
const char *nm;
char tmp[64];
int keys, len;
strcpy(tmp, (which & 0x1000) ? "LOAD STATE? " : "OVERWRITE SAVE? ");
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);
}
if (do_it) {
@ -544,7 +547,7 @@ static void RunEvents(unsigned int which)
strcpy(noticeMsg, " 8bit accurate renderer");
}
gettimeofday(&noticeMsgTime, 0);
emu_noticeMsgUpdated();
}
if (which & 0x0300)
{
@ -556,7 +559,7 @@ static void RunEvents(unsigned int which)
if(state_slot > 9) state_slot = 0;
}
sprintf(noticeMsg, "SAVE SLOT %i [%s]", state_slot, emu_checkSaveFile(state_slot) ? "USED" : "FREE");
gettimeofday(&noticeMsgTime, 0);
emu_noticeMsgUpdated();
}
if (which & 0x0080) {
engineState = PGS_Menu;
@ -565,16 +568,9 @@ static void RunEvents(unsigned int which)
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;
keys = gp2x_joystick_read(0);
if (keys & GP2X_SELECT)
engineState = select_exits ? PGS_Quit : PGS_Menu;
keys &= CONFIGURABLE_KEYS;
keys2 = keys;
/* FIXME: player2 */
allActions[0] = in_update();
@ -599,7 +595,7 @@ static void updateKeys(void)
events &= ~prevEvents;
if (PicoAHW == PAHW_PICO)
RunEventsPico(events, keys);
RunEventsPico(events);
if (events) RunEvents(events);
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
{
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);
/* input */
unsigned long gp2x_joystick_read(int allow_usb_joy);
int gp2x_touchpad_read(int *x, int *y);
/* 940 core */
@ -32,9 +31,4 @@ void Reset940(int yes, int bank);
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

View file

@ -1,7 +1,6 @@
#include <stdlib.h>
#include <string.h>
#include "../common/common.h"
#include "../common/input.h"
#include "in_gp2x.h"
@ -102,20 +101,45 @@ int in_gp2x_update_keycode(void *data, int *is_down)
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)
{
switch (keycode) {
case BTN_UP: return PBTN_UP;
case BTN_LEFT: return PBTN_LEFT;
case BTN_DOWN: return PBTN_DOWN;
case BTN_RIGHT: return PBTN_RIGHT;
case BTN_B: return PBTN_MOK;
case BTN_X: return PBTN_MBACK;
case BTN_SELECT:return PBTN_MENU;
case BTN_L: return PBTN_L;
case BTN_R: return PBTN_R;
default: return 0;
int i;
if (keycode < 0)
{
/* menu -> kc */
keycode = -keycode;
for (i = 0; i < KEY_PBTN_MAP_SIZE; i++)
if (key_pbtn_map[i].pbtn == keycode)
return key_pbtn_map[i].key;
}
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)
@ -156,6 +180,12 @@ static const struct {
{ BTN_B, 5 }, /* C */
{ BTN_A, 6 }, /* A */
{ 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]))
@ -171,15 +201,29 @@ static void in_gp2x_get_def_binds(int *binds)
/* remove binds of missing keys, count remaining ones */
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++) {
if (in_gp2x_keys[i] == NULL)
binds[i] = binds[i + IN_GP2X_NBUTTONS] = 0;
if (binds[i])
if (binds[i]) {
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);
return count;

View file

@ -11,7 +11,6 @@
#include <linux/limits.h>
#include "gp2x.h"
#include "menu.h"
#include "../common/menu.h"
#include "../common/emu.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...)
// platform
#define PLAT_MAX_KEYS 32
#define PLAT_HAVE_JOY 1
#define PATH_SEP "/"
#define PATH_SEP_C '/'
#define MENU_X2 0