continuing input framework integration

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@631 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2009-01-03 18:53:35 +00:00
parent 963b7f4f2a
commit b682092681
14 changed files with 264 additions and 506 deletions

View file

@ -15,7 +15,11 @@
#define PBTN_L GP2X_L #define PBTN_L GP2X_L
#define PBTN_R GP2X_R #define PBTN_R GP2X_R
int wait_for_input(int interesting); /* menu nav */
#define PBTN_MOK GP2X_B
#define PBTN_MBACK GP2X_X
#define PBTN_MENU GP2X_SELECT
void gp2x_pd_clone_buffer2(void); void gp2x_pd_clone_buffer2(void);
void menu_darken_bg(void *dst, int pixels, int darker); void menu_darken_bg(void *dst, int pixels, int darker);
void menu_flip(void); void menu_flip(void);
@ -24,10 +28,6 @@ void menu_flip(void);
#define SCREEN_HEIGHT 240 #define SCREEN_HEIGHT 240
#define SCREEN_BUFFER gp2x_screen #define SCREEN_BUFFER gp2x_screen
#define read_buttons(which) \
wait_for_input(which)
#define read_buttons_async(which) \
(gp2x_joystick_read(0) & (which))
#define menu_draw_begin() \ #define menu_draw_begin() \
gp2x_pd_clone_buffer2() gp2x_pd_clone_buffer2()
#define clear_screen() \ #define clear_screen() \
@ -48,7 +48,6 @@ void menu_flip(void);
#define PBTN_WEST PBTN_REW #define PBTN_WEST PBTN_REW
#define PBTN_EAST PBTN_FWD #define PBTN_EAST PBTN_FWD
unsigned long wait_for_input(unsigned int interesting);
void menu_draw_begin(int use_bgbuff); void menu_draw_begin(int use_bgbuff);
void menu_darken_bg(void *dst, const void *src, int pixels, int darker); void menu_darken_bg(void *dst, const void *src, int pixels, int darker);
void menu_draw_end(void); void menu_draw_end(void);
@ -59,9 +58,6 @@ void menu_draw_end(void);
extern void *menu_screen; extern void *menu_screen;
extern void *giz_screen; extern void *giz_screen;
#define read_buttons(which) \
wait_for_input(which)
#define read_buttons_async(which) 0
#define menu_draw_begin() \ #define menu_draw_begin() \
menu_draw_begin(1) menu_draw_begin(1)
#define clear_screen() \ #define clear_screen() \
@ -80,7 +76,6 @@ extern void *giz_screen;
#define PBTN_WEST PBTN_SQUARE #define PBTN_WEST PBTN_SQUARE
#define PBTN_EAST PBTN_CIRCLE #define PBTN_EAST PBTN_CIRCLE
unsigned long wait_for_input(unsigned int interesting, int is_key_config);
void menu_draw_begin(void); void menu_draw_begin(void);
void menu_darken_bg(void *dst, const void *src, int pixels, int darker); void menu_darken_bg(void *dst, const void *src, int pixels, int darker);
void menu_draw_end(void); void menu_draw_end(void);
@ -89,10 +84,6 @@ void menu_draw_end(void);
#define SCREEN_HEIGHT 272 #define SCREEN_HEIGHT 272
#define SCREEN_BUFFER psp_screen #define SCREEN_BUFFER psp_screen
#define read_buttons(which) \
wait_for_input(which, 0)
#define read_buttons_async(which) \
(psp_pad_read(0) & (which))
#define clear_screen() \ #define clear_screen() \
memset(SCREEN_BUFFER, 0, SCREEN_WIDTH*SCREEN_HEIGHT*2) memset(SCREEN_BUFFER, 0, SCREEN_WIDTH*SCREEN_HEIGHT*2)
#define darken_screen() \ #define darken_screen() \
@ -102,10 +93,6 @@ void menu_draw_end(void);
#elif defined(PANDORA) #elif defined(PANDORA)
// TODO
#include "../gp2x/gp2x.h"
#define PBTN_UP (1 << 0) #define PBTN_UP (1 << 0)
#define PBTN_DOWN (1 << 1) #define PBTN_DOWN (1 << 1)
#define PBTN_LEFT (1 << 2) #define PBTN_LEFT (1 << 2)
@ -118,19 +105,21 @@ void menu_draw_end(void);
#define PBTN_L (1 << 8) #define PBTN_L (1 << 8)
#define PBTN_R (1 << 9) #define PBTN_R (1 << 9)
unsigned long wait_for_input(unsigned long interesting); /* menu nav */
#define PBTN_MOK PBTN_EAST
#define PBTN_MBACK PBTN_SOUTH
#define PBTN_MENU (1 << 10)
void gp2x_pd_clone_buffer2(void); void gp2x_pd_clone_buffer2(void);
void menu_darken_bg(void *dst, int pixels, int darker); void menu_darken_bg(void *dst, int pixels, int darker);
void menu_flip(void); void menu_flip(void);
extern void *gp2x_screen;
#define SCREEN_WIDTH 800 #define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 480 #define SCREEN_HEIGHT 480
#define SCREEN_BUFFER gp2x_screen #define SCREEN_BUFFER gp2x_screen
#define read_buttons(which) \
wait_for_input(which)
#define read_buttons_async(which) \
(gp2x_joystick_read(0) & (which))
#define menu_draw_begin() \ #define menu_draw_begin() \
gp2x_pd_clone_buffer2() gp2x_pd_clone_buffer2()
#define clear_screen() \ #define clear_screen() \

View file

@ -209,16 +209,6 @@ static void custom_write(FILE *f, const menu_entry *me, int no_def)
} }
#if PLAT_HAVE_JOY
static const char *joyKeyNames[32] =
{
"UP", "DOWN", "LEFT", "RIGHT", "b1", "b2", "b3", "b4",
"b5", "b6", "b7", "b8", "b9", "b10", "b11", "b12",
"b13", "b14", "b15", "b16", "b17", "b19", "b19", "b20",
"b21", "b22", "b23", "b24", "b25", "b26", "b27", "b28"
};
#endif
static void keys_write(FILE *fn, const char *bind_str, int dev_id, const int *binds, int no_defaults) static void keys_write(FILE *fn, const char *bind_str, int dev_id, const int *binds, int no_defaults)
{ {
char act[48]; char act[48];
@ -401,7 +391,7 @@ write:
for (t = 0; t < IN_MAX_DEVS; t++) for (t = 0; t < IN_MAX_DEVS; t++)
{ {
const int *binds = in_get_dev_binds(t); const int *binds = in_get_dev_binds(t);
const char *name = in_get_dev_name(t); const char *name = in_get_dev_name(t, 0);
if (binds == NULL || name == NULL) if (binds == NULL || name == NULL)
continue; continue;
@ -412,7 +402,7 @@ write:
for (t = 0; t < IN_MAX_DEVS; t++) for (t = 0; t < IN_MAX_DEVS; t++)
{ {
const int *binds = in_get_dev_binds(t); const int *binds = in_get_dev_binds(t);
const char *name = in_get_dev_name(t); const char *name = in_get_dev_name(t, 0);
char strbind[16]; char strbind[16];
int count; int count;
@ -426,17 +416,6 @@ write:
keys_write(fn, strbind, t, binds, no_defaults); keys_write(fn, strbind, t, binds, no_defaults);
} }
#if 0
/* old stuff */
keys_write(fn, "bind", currentConfig.KeyBinds, defaultConfig.KeyBinds, keyNames, PLAT_MAX_KEYS, no_defaults);
#if PLAT_HAVE_JOY
keys_write(fn, "bind_joy0", currentConfig.JoyBinds[0], defaultConfig.JoyBinds[0], joyKeyNames, 32, 1);
keys_write(fn, "bind_joy1", currentConfig.JoyBinds[1], defaultConfig.JoyBinds[1], joyKeyNames, 32, 1);
keys_write(fn, "bind_joy2", currentConfig.JoyBinds[2], defaultConfig.JoyBinds[2], joyKeyNames, 32, 1);
keys_write(fn, "bind_joy3", currentConfig.JoyBinds[3], defaultConfig.JoyBinds[3], joyKeyNames, 32, 1);
#endif
#endif
#ifndef PSP #ifndef PSP
if (section == NULL) if (section == NULL)
fprintf(fn, "Sound Volume = %i" NL, currentConfig.volume); fprintf(fn, "Sound Volume = %i" NL, currentConfig.volume);
@ -771,42 +750,6 @@ static void keys_parse(const char *key, const char *val, int dev_id)
} }
in_config_bind_key(dev_id, key, binds); in_config_bind_key(dev_id, key, binds);
/*
for (t = 0; t < 32; t++)
{
if (names[t] && strcmp(names[t], var) == 0) break;
}
if (t == 32)
{
int len = strlen(var);
if (len == 1) t = var[0];
else if (len >= 4 && var[0] == '\\' && var[1] == 'x') {
char *p;
t = (int)strtoul(var + 2, &p, 16);
if (*p != 0) t = max_keys; // parse failed
}
else
t = max_keys; // invalid
}
if (t < 0 || t >= max_keys) {
lprintf("unhandled bind \"%s\"\n", var);
return;
}
// unbind old, but only when key is first encountered
if (t < 32 && binds == currentConfig.KeyBinds && !(keys_encountered & (1<<t))) {
binds[t] = 0;
keys_encountered |= 1<<t;
}
*/
}
#define try_joy_parse(num) { \
if (strncasecmp(var, "bind_joy"#num " ", 10) == 0) { \
keys_parse(var + 10, val, currentConfig.JoyBinds[num], joyKeyNames, 32); \
return; \
} \
} }
static int get_numvar_num(const char *var) static int get_numvar_num(const char *var)
@ -846,7 +789,7 @@ static void parse(const char *var, const char *val)
if (num >= 0 && num < IN_MAX_DEVS) if (num >= 0 && num < IN_MAX_DEVS)
input_dev_map[num] = in_config_parse_dev(val); input_dev_map[num] = in_config_parse_dev(val);
else else
printf("failed to parse: %s\n", var); lprintf("config: failed to parse: %s\n", var);
return; return;
} }
@ -855,13 +798,13 @@ static void parse(const char *var, const char *val)
const char *p = var + 4; const char *p = var + 4;
int num = get_numvar_num(p); int num = get_numvar_num(p);
if (num < 0 || num >= IN_MAX_DEVS) { if (num < 0 || num >= IN_MAX_DEVS) {
printf("failed to parse: %s\n", var); lprintf("config: failed to parse: %s\n", var);
return; return;
} }
num = input_dev_map[num]; num = input_dev_map[num];
if (num < 0 || num >= IN_MAX_DEVS) { if (num < 0 || num >= IN_MAX_DEVS) {
printf("invalid device id: %s\n", var); lprintf("config: invalid device id: %s\n", var);
return; return;
} }
@ -871,13 +814,6 @@ static void parse(const char *var, const char *val)
return; return;
} }
#if 0//PLAT_HAVE_JOY
try_joy_parse(0)
try_joy_parse(1)
try_joy_parse(2)
try_joy_parse(3)
#endif
for (t = 0; t < sizeof(cfg_opts) / sizeof(cfg_opts[0]) && ret == 0; t++) for (t = 0; t < sizeof(cfg_opts) / sizeof(cfg_opts[0]) && ret == 0; t++)
{ {
me = cfg_opts[t]; me = cfg_opts[t];

View file

@ -2,6 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "common.h"
#include "input.h" #include "input.h"
#include "../linux/in_evdev.h" #include "../linux/in_evdev.h"
@ -195,7 +196,7 @@ void in_set_blocking(int is_blocking)
menu_key_state = 0; menu_key_state = 0;
/* flush events */ /* flush events */
in_update_keycode(NULL, NULL, 1); in_update_keycode(NULL, NULL, 0);
} }
/* /*
@ -204,7 +205,7 @@ void in_set_blocking(int is_blocking)
*/ */
int in_update_keycode(int *dev_id_out, int *is_down_out, int timeout_ms) int in_update_keycode(int *dev_id_out, int *is_down_out, int timeout_ms)
{ {
int result = 0, dev_id, is_down, result_menu; int result = 0, dev_id = 0, is_down, result_menu;
#ifdef IN_EVDEV #ifdef IN_EVDEV
void **data; void **data;
int i, id = 0, count = 0; int i, id = 0, count = 0;
@ -229,7 +230,7 @@ int in_update_keycode(int *dev_id_out, int *is_down_out, int timeout_ms)
#endif #endif
/* keep track of menu key state, to allow mixing /* keep track of menu key state, to allow mixing
* in_update_keycode() and in_update_menu() calls */ * in_update_keycode() and in_menu_wait_any() calls */
result_menu = DRV(in_devices[dev_id].drv_id).menu_translate(result); result_menu = DRV(in_devices[dev_id].drv_id).menu_translate(result);
if (result_menu != 0) { if (result_menu != 0) {
if (is_down) if (is_down)
@ -245,10 +246,8 @@ int in_update_keycode(int *dev_id_out, int *is_down_out, int timeout_ms)
return result; return result;
} }
/* /* same as above, only return bitfield of PBTN_* */
* same as above, only return bitfield of BTN_* int in_menu_wait_any(int timeout_ms)
*/
int in_update_menu(int timeout_ms)
{ {
int keys_old = menu_key_state; int keys_old = menu_key_state;
@ -259,7 +258,7 @@ int in_update_menu(int timeout_ms)
code = in_update_keycode(&dev_id, &is_down, timeout_ms); code = in_update_keycode(&dev_id, &is_down, timeout_ms);
code = DRV(in_devices[dev_id].drv_id).menu_translate(code); code = DRV(in_devices[dev_id].drv_id).menu_translate(code);
if (timeout_ms != 0) if (timeout_ms >= 0)
break; break;
if (code == 0) if (code == 0)
continue; continue;
@ -270,6 +269,45 @@ int in_update_menu(int timeout_ms)
return menu_key_state; return menu_key_state;
} }
/* wait for menu input, do autorepeat */
int in_menu_wait(int interesting)
{
static int inp_prev = 0;
static int repeats = 0, wait = 20;
int ret = 0, release = 0, i;
if (repeats == 2) wait = 3;
else if (repeats == 4) wait = 2;
else if (repeats == 6) wait = 1;
for (i = 0; i < wait; i++) {
ret = in_menu_wait_any(30);
if (ret != inp_prev) break;
if (i == 0) repeats++;
}
while (!(ret & interesting)) {
ret = in_menu_wait_any(-1);
release = 1;
}
if (release || ret != inp_prev) {
repeats = 0;
wait = 20;
}
if (wait > 6 && (ret & (PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT)))
wait = 6;
inp_prev = ret;
// we don't need diagonals in menus
if ((ret & PBTN_UP) && (ret & PBTN_LEFT)) ret &= ~PBTN_LEFT;
if ((ret & PBTN_UP) && (ret & PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
if ((ret & PBTN_DOWN) && (ret & PBTN_LEFT)) ret &= ~PBTN_LEFT;
if ((ret & PBTN_DOWN) && (ret & PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
return ret;
}
const int *in_get_dev_binds(int dev_id) const int *in_get_dev_binds(int dev_id)
{ {
if (dev_id < 0 || dev_id >= IN_MAX_DEVS) if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
@ -297,11 +335,13 @@ int in_get_dev_bind_count(int dev_id)
return in_bind_count(in_devices[dev_id].drv_id); return in_bind_count(in_devices[dev_id].drv_id);
} }
const char *in_get_dev_name(int dev_id) const char *in_get_dev_name(int dev_id, int must_be_active)
{ {
if (dev_id < 0 || dev_id >= IN_MAX_DEVS) if (dev_id < 0 || dev_id >= IN_MAX_DEVS)
return NULL; return NULL;
if (must_be_active && !in_devices[dev_id].probed)
return NULL;
return in_devices[dev_id].name; return in_devices[dev_id].name;
} }
@ -580,7 +620,7 @@ int main(void)
} }
#else #else
while (1) { while (1) {
ret = in_update_menu(); ret = in_menu_wait_any();
printf("%08x\n", ret); printf("%08x\n", ret);
} }
#endif #endif

View file

@ -28,7 +28,8 @@ void in_probe(void);
int in_update(void); int in_update(void);
void in_set_blocking(int is_blocking); void in_set_blocking(int is_blocking);
int in_update_keycode(int *dev_id, int *is_down, int timeout_ms); int in_update_keycode(int *dev_id, int *is_down, int timeout_ms);
int in_update_menu(int timeout_ms); int in_menu_wait_any(int timeout_ms);
int in_menu_wait(int interesting);
int in_get_dev_bind_count(int dev_id); int in_get_dev_bind_count(int dev_id);
void in_config_start(void); void in_config_start(void);
int in_config_parse_dev(const char *dev_name); int in_config_parse_dev(const char *dev_name);
@ -39,5 +40,5 @@ void in_debug_dump(void);
const int *in_get_dev_binds(int dev_id); const int *in_get_dev_binds(int dev_id);
const int *in_get_dev_def_binds(int dev_id); const int *in_get_dev_def_binds(int dev_id);
const char *in_get_dev_name(int dev_id); const char *in_get_dev_name(int dev_id, int must_be_active);
const char *in_get_key_name(int dev_id, int keycode); const char *in_get_key_name(int dev_id, int keycode);

View file

@ -13,6 +13,7 @@
#include "readpng.h" #include "readpng.h"
#include "lprintf.h" #include "lprintf.h"
#include "common.h" #include "common.h"
#include "input.h"
#include "emu.h" #include "emu.h"
@ -350,7 +351,7 @@ static void mplayer_loop(void)
while (1) while (1)
{ {
PDebugZ80Frame(); PDebugZ80Frame();
if (read_buttons_async(PBTN_NORTH)) break; if (in_menu_wait_any(0) & PBTN_NORTH) break;
emu_waitSound(); emu_waitSound();
} }
@ -429,8 +430,8 @@ void debug_menu_loop(void)
} }
menu_draw_end(); menu_draw_end();
inp = read_buttons(PBTN_EAST|PBTN_SOUTH|PBTN_WEST|PBTN_NORTH|PBTN_L|PBTN_R|PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT); inp = in_menu_wait(PBTN_EAST|PBTN_MBACK|PBTN_WEST|PBTN_NORTH|PBTN_L|PBTN_R|PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT);
if (inp & PBTN_SOUTH) return; if (inp & PBTN_MBACK) return;
if (inp & PBTN_L) { mode--; if (mode < 0) mode = 3; } if (inp & PBTN_L) { mode--; if (mode < 0) mode = 3; }
if (inp & PBTN_R) { mode++; if (mode > 3) mode = 0; } if (inp & PBTN_R) { mode++; if (mode > 3) mode = 0; }
switch (mode) switch (mode)
@ -438,13 +439,13 @@ void debug_menu_loop(void)
case 0: case 0:
if (inp & PBTN_EAST) SekStepM68k(); if (inp & PBTN_EAST) SekStepM68k();
if (inp & PBTN_NORTH) { if (inp & PBTN_NORTH) {
while (inp & PBTN_NORTH) inp = read_buttons_async(PBTN_NORTH); while (inp & PBTN_NORTH) inp = in_menu_wait_any(-1);
mplayer_loop(); mplayer_loop();
} }
if ((inp & (PBTN_WEST|PBTN_LEFT)) == (PBTN_WEST|PBTN_LEFT)) { if ((inp & (PBTN_WEST|PBTN_LEFT)) == (PBTN_WEST|PBTN_LEFT)) {
mkdir("dumps", 0777); mkdir("dumps", 0777);
PDebugDumpMem(); PDebugDumpMem();
while (inp & PBTN_WEST) inp = read_buttons_async(PBTN_WEST); while (inp & PBTN_WEST) inp = in_menu_wait_any(-1);
dumped = 1; dumped = 1;
} }
break; break;
@ -458,7 +459,7 @@ void debug_menu_loop(void)
PicoSkipFrame = 1; PicoSkipFrame = 1;
PicoFrame(); PicoFrame();
PicoSkipFrame = 0; PicoSkipFrame = 0;
while (inp & PBTN_EAST) inp = read_buttons_async(PBTN_EAST); while (inp & PBTN_EAST) inp = in_menu_wait_any(-1);
} }
break; break;
case 3: case 3:

View file

@ -24,6 +24,7 @@
#include "../common/menu.h" #include "../common/menu.h"
#include "../common/emu.h" #include "../common/emu.h"
#include "../common/readpng.h" #include "../common/readpng.h"
#include "../common/input.h"
#include "version.h" #include "version.h"
#include <pico/pico_int.h> #include <pico/pico_int.h>
@ -47,44 +48,6 @@ static void menu_prepare_bg(int use_game_bg);
static unsigned int inp_prev = 0; static unsigned int inp_prev = 0;
unsigned long wait_for_input(unsigned int interesting)
{
unsigned long ret;
static int repeats = 0, wait = 20;
int release = 0, i;
if (repeats == 2) wait = 3;
else if (repeats == 4) wait = 2;
else if (repeats == 6) wait = 1;
for (i = 0; i < wait && inp_prev == Framework_PollGetButtons(); i++) {
if (i == 0) repeats++;
Sleep(30);
}
while ( !((ret = Framework_PollGetButtons()) & interesting) ) {
Sleep(50);
release = 1;
}
if (release || ret != inp_prev) {
repeats = 0;
wait = 20;
}
if (wait > 6 && (ret&(PBTN_UP|PBTN_LEFT|PBTN_DOWN|PBTN_RIGHT|PBTN_L|PBTN_R)))
wait = 6;
inp_prev = ret;
// we don't need diagonals in menus
if ((ret&PBTN_UP) && (ret&PBTN_LEFT)) ret &= ~PBTN_LEFT;
if ((ret&PBTN_UP) && (ret&PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
if ((ret&PBTN_DOWN) && (ret&PBTN_LEFT)) ret &= ~PBTN_LEFT;
if ((ret&PBTN_DOWN) && (ret&PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
return ret;
}
void menu_draw_begin(int use_bgbuff) void menu_draw_begin(int use_bgbuff)
{ {
if (use_bgbuff) if (use_bgbuff)
@ -386,7 +349,7 @@ static char *romsel_loop(char *curr_path)
for (;;) for (;;)
{ {
draw_dirlist(curr_path, namelist, n, sel); draw_dirlist(curr_path, namelist, n, sel);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP);
if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; } if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; }
if(inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; } if(inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; }
if(inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; } if(inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; }
@ -473,7 +436,7 @@ static void patches_menu_loop(void)
for(;;) for(;;)
{ {
draw_patchlist(menu_sel); draw_patchlist(menu_sel);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP);
if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; } if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; }
if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; } if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; }
if(inp &(PBTN_LEFT|PBTN_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; } if(inp &(PBTN_LEFT|PBTN_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; }
@ -593,7 +556,7 @@ static int savestate_menu_loop(int is_loading)
for(;;) for(;;)
{ {
draw_savestate_menu(menu_sel, is_loading); draw_savestate_menu(menu_sel, is_loading);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP);
if(inp & PBTN_UP ) { if(inp & PBTN_UP ) {
do { do {
menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max;
@ -703,7 +666,7 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
for (;;) for (;;)
{ {
draw_key_config(opts, opt_cnt, player_idx, sel); draw_key_config(opts, opt_cnt, player_idx, sel);
inp = wait_for_input(CONFIGURABLE_KEYS|PBTN_HOME); inp = in_menu_wait(CONFIGURABLE_KEYS|PBTN_HOME);
if (!(inp & PBTN_HOME)) { if (!(inp & PBTN_HOME)) {
prev_select = 0; prev_select = 0;
if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; } if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; }
@ -783,7 +746,7 @@ static void kc_sel_loop(void)
while (1) while (1)
{ {
draw_kc_sel(menu_sel); draw_kc_sel(menu_sel);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP);
selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel); selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel);
if (inp & (PBTN_LEFT|PBTN_RIGHT)) // multi choise if (inp & (PBTN_LEFT|PBTN_RIGHT)) // multi choise
me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0); me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0);
@ -904,7 +867,7 @@ static void cd_menu_loop_options(void)
for(;;) for(;;)
{ {
draw_cd_menu_options(menu_sel, &bios_names); draw_cd_menu_options(menu_sel, &bios_names);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);
if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel); selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel);
@ -1003,7 +966,7 @@ static void amenu_loop_options(void)
for(;;) for(;;)
{ {
draw_amenu_options(menu_sel); draw_amenu_options(menu_sel);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);
if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel); selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel);
@ -1187,7 +1150,7 @@ static int menu_loop_options(void)
while (1) while (1)
{ {
draw_menu_options(menu_sel); draw_menu_options(menu_sel);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);
if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel); selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel);
@ -1388,7 +1351,7 @@ static void menu_loop_root(void)
for (;;) for (;;)
{ {
draw_menu_root(menu_sel); draw_menu_root(menu_sel);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP|PBTN_HOME|PBTN_L|PBTN_R); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP|PBTN_HOME|PBTN_L|PBTN_R);
if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if((inp & (PBTN_L|PBTN_R)) == (PBTN_L|PBTN_R)) debug_menu_loop(); if((inp & (PBTN_L|PBTN_R)) == (PBTN_L|PBTN_R)) debug_menu_loop();
@ -1465,7 +1428,7 @@ static void menu_loop_root(void)
case MA_MAIN_CREDITS: case MA_MAIN_CREDITS:
draw_menu_credits(); draw_menu_credits();
Sleep(500); Sleep(500);
inp = wait_for_input(PBTN_PLAY|PBTN_STOP); inp = in_menu_wait(PBTN_PLAY|PBTN_STOP);
break; break;
case MA_MAIN_EXIT: case MA_MAIN_EXIT:
engineState = PGS_Quit; engineState = PGS_Quit;
@ -1603,7 +1566,7 @@ int menu_loop_tray(void)
for (;;) for (;;)
{ {
draw_menu_tray(menu_sel); draw_menu_tray(menu_sel);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY);
if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if(inp & PBTN_PLAY) { if(inp & PBTN_PLAY) {

View file

@ -582,12 +582,8 @@ static void updateKeys(void)
keys2 = keys; keys2 = keys;
#if 1 #if 1
{ /* FIXME: combos, player2 */
/* FIXME: combos */ allActions[0] = in_update();
int acts = in_update();
int pl = (acts >> 16) & 1;
allActions[pl] |= acts;
}
#else #else
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
{ {

View file

@ -42,45 +42,6 @@ const char * const keyNames[] = {
void menu_darken_bg(void *dst, int pixels, int darker); void menu_darken_bg(void *dst, int pixels, int darker);
static void menu_prepare_bg(int use_game_bg); static void menu_prepare_bg(int use_game_bg);
/* wait for input, do autorepeat */
int wait_for_input(int interesting)
{
static int inp_prev = 0;
static int repeats = 0, wait = 20;
int ret, release = 0, i;
if (repeats == 2) wait = 3;
else if (repeats == 4) wait = 2;
else if (repeats == 6) wait = 1;
for (i = 0; i < wait; i++) {
ret = in_update_menu(30);
if (ret != inp_prev) break;
if (i == 0) repeats++;
}
while (!(ret & interesting)) {
ret = in_update_menu(0);
release = 1;
}
if (release || ret != inp_prev) {
repeats = 0;
wait = 20;
}
if (wait > 6 && (ret & (PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT)))
wait = 6;
inp_prev = ret;
// we don't need diagonals in menus
if ((ret & PBTN_UP) && (ret & PBTN_LEFT)) ret &= ~PBTN_LEFT;
if ((ret & PBTN_UP) && (ret & PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
if ((ret & PBTN_DOWN) && (ret & PBTN_LEFT)) ret &= ~PBTN_LEFT;
if ((ret & PBTN_DOWN) && (ret & PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
return ret;
}
void menu_flip(void) void menu_flip(void)
{ {
gp2x_video_flush_cache(); gp2x_video_flush_cache();
@ -247,8 +208,8 @@ static void do_delete(const char *fpath, const char *fname)
menu_flip(); menu_flip();
while (gp2x_joystick_read(1) & (GP2X_A|GP2X_SELECT)) usleep(50*1000); while (in_menu_wait_any(50) & (PBTN_WEST|PBTN_MENU));
inp = wait_for_input(GP2X_Y|GP2X_X); inp = in_menu_wait(GP2X_Y|PBTN_MBACK); /* FIXME */
if (inp & GP2X_Y) if (inp & GP2X_Y)
remove(fpath); remove(fpath);
} }
@ -298,14 +259,14 @@ rescan:
for (;;) for (;;)
{ {
draw_dirlist(curr_path, namelist, n, sel); draw_dirlist(curr_path, namelist, n, sel);
inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_L|GP2X_R|GP2X_A|GP2X_B|GP2X_X|GP2X_SELECT); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_WEST|PBTN_MOK|PBTN_MBACK|PBTN_MENU);
if(inp & GP2X_UP ) { sel--; if (sel < 0) sel = n-2; } if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; }
if(inp & GP2X_DOWN) { sel++; if (sel > n-2) sel = 0; } if(inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; }
if(inp & GP2X_LEFT) { sel-=10; if (sel < 0) sel = 0; } if(inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; }
if(inp & GP2X_L) { sel-=24; if (sel < 0) sel = 0; } if(inp & PBTN_L) { sel-=24; if (sel < 0) sel = 0; }
if(inp & GP2X_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; } if(inp & PBTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; }
if(inp & GP2X_R) { sel+=24; if (sel > n-2) sel = n-2; } if(inp & PBTN_R) { sel+=24; if (sel > n-2) sel = n-2; }
if ((inp & GP2X_B) || (inp & (GP2X_SELECT|GP2X_A)) == (GP2X_SELECT|GP2X_A)) // enter dir/select || delete if ((inp & PBTN_MOK) || (inp & (PBTN_MENU|PBTN_WEST)) == (PBTN_MENU|PBTN_WEST)) // enter dir/select || delete
{ {
again: again:
if (namelist[sel+1]->d_type == DT_REG) if (namelist[sel+1]->d_type == DT_REG)
@ -313,7 +274,7 @@ rescan:
strcpy(romFileName, curr_path); strcpy(romFileName, curr_path);
strcat(romFileName, "/"); strcat(romFileName, "/");
strcat(romFileName, namelist[sel+1]->d_name); strcat(romFileName, namelist[sel+1]->d_name);
if (inp & GP2X_B) { // return sel if (inp & PBTN_MOK) { // return sel
ret = romFileName; ret = romFileName;
break; break;
} }
@ -328,7 +289,7 @@ rescan:
{ {
int newlen; int newlen;
char *p, *newdir; char *p, *newdir;
if (!(inp & GP2X_B)) continue; if (!(inp & PBTN_MOK)) continue;
newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2; newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2;
newdir = malloc(newlen); newdir = malloc(newlen);
if (strcmp(namelist[sel+1]->d_name, "..") == 0) { if (strcmp(namelist[sel+1]->d_name, "..") == 0) {
@ -367,7 +328,7 @@ rescan:
} }
} }
} }
if(inp & GP2X_X) break; // cancel if(inp & PBTN_MBACK) break; // cancel
} }
if (n > 0) { if (n > 0) {
@ -412,17 +373,17 @@ static void patches_menu_loop(void)
for(;;) for(;;)
{ {
draw_patchlist(menu_sel); draw_patchlist(menu_sel);
inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_L|GP2X_R|GP2X_B|GP2X_X); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_MOK|PBTN_MBACK);
if(inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; } if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; }
if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; } if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; }
if(inp &(GP2X_LEFT|GP2X_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; } if(inp &(PBTN_LEFT|PBTN_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; }
if(inp &(GP2X_RIGHT|GP2X_R)) { menu_sel+=10; if (menu_sel > PicoPatchCount) menu_sel = PicoPatchCount; } if(inp &(PBTN_RIGHT|PBTN_R)) { menu_sel+=10; if (menu_sel > PicoPatchCount) menu_sel = PicoPatchCount; }
if(inp & GP2X_B) { // action if(inp & PBTN_MOK) { // action
if (menu_sel < PicoPatchCount) if (menu_sel < PicoPatchCount)
PicoPatches[menu_sel].active = !PicoPatches[menu_sel].active; PicoPatches[menu_sel].active = !PicoPatches[menu_sel].active;
else return; else return;
} }
if(inp & GP2X_X) return; if(inp & PBTN_MBACK) return;
} }
} }
@ -532,18 +493,18 @@ static int savestate_menu_loop(int is_loading)
for(;;) for(;;)
{ {
draw_savestate_menu(menu_sel, is_loading); draw_savestate_menu(menu_sel, is_loading);
inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_B|GP2X_X); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_MOK|PBTN_MBACK);
if(inp & GP2X_UP ) { if(inp & PBTN_UP ) {
do { do {
menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max;
} while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading); } while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading);
} }
if(inp & GP2X_DOWN) { if(inp & PBTN_DOWN) {
do { do {
menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0;
} while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading); } while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading);
} }
if(inp & GP2X_B) { // save/load if(inp & PBTN_MOK) { // save/load
if (menu_sel < 10) { if (menu_sel < 10) {
state_slot = menu_sel; state_slot = menu_sel;
if (emu_SaveLoadGame(is_loading, 0)) { if (emu_SaveLoadGame(is_loading, 0)) {
@ -553,26 +514,12 @@ static int savestate_menu_loop(int is_loading)
return 0; return 0;
} else return 1; } else return 1;
} }
if(inp & GP2X_X) return 1; if(inp & PBTN_MBACK) return 1;
} }
} }
// -------------- key config -------------- // -------------- key config --------------
static char *usb_joy_key_name(int joy, int num)
{
static char name[16];
switch (num)
{
case 0: sprintf(name, "Joy%i UP", joy); break;
case 1: sprintf(name, "Joy%i DOWN", joy); break;
case 2: sprintf(name, "Joy%i LEFT", joy); break;
case 3: sprintf(name, "Joy%i RIGHT", joy); break;
default:sprintf(name, "Joy%i b%i", joy, num-3); break;
}
return name;
}
static char *action_binds(int player_idx, int action_mask) static char *action_binds(int player_idx, int action_mask)
{ {
static char strkeys[32]; static char strkeys[32];
@ -609,33 +556,6 @@ static char *action_binds(int player_idx, int action_mask)
d_prev = d; d_prev = d;
} }
} }
#if 0
for (i = 0; i < 32; i++) // i is key index
{
if (currentConfig.KeyBinds[i] & action_mask)
{
if (player_idx >= 0 && ((currentConfig.KeyBinds[i] >> 16) & 3) != player_idx) continue;
if (strkeys[0]) { strcat(strkeys, " + "); strcat(strkeys, keyNames[i]); break; }
else strcpy(strkeys, keyNames[i]);
}
}
for (joy = 0; joy < num_of_joys; joy++)
{
for (i = 0; i < 32; i++)
{
if (currentConfig.JoyBinds[joy][i] & action_mask)
{
if (player_idx >= 0 && ((currentConfig.JoyBinds[joy][i] >> 16) & 3) != player_idx) continue;
if (strkeys[0]) {
strcat(strkeys, ", "); strcat(strkeys, usb_joy_key_name(joy + 1, i));
break;
}
else strcpy(strkeys, usb_joy_key_name(joy + 1, i));
}
}
}
#endif
// limit.. // limit..
strkeys[20] = 0; strkeys[20] = 0;
@ -737,25 +657,25 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
for (;;) for (;;)
{ {
draw_key_config(opts, opt_cnt, player_idx, sel, 0); draw_key_config(opts, opt_cnt, player_idx, sel, 0);
mkey = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_SOUTH|PBTN_EAST); mkey = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_MBACK|PBTN_MOK);
switch (mkey) { switch (mkey) {
case PBTN_UP: sel--; if (sel < 0) sel = menu_sel_max; continue; case PBTN_UP: sel--; if (sel < 0) sel = menu_sel_max; continue;
case PBTN_DOWN: sel++; if (sel > menu_sel_max) sel = 0; continue; case PBTN_DOWN: sel++; if (sel > menu_sel_max) sel = 0; continue;
case PBTN_SOUTH: case PBTN_MBACK: return;
if (sel >= opt_cnt) case PBTN_MOK:
return;
continue;
case PBTN_EAST:
if (sel >= opt_cnt) if (sel >= opt_cnt)
return; return;
while (in_menu_wait_any(30) & PBTN_MOK);
break; break;
default:continue; default:continue;
} }
draw_key_config(opts, opt_cnt, player_idx, sel, 1); draw_key_config(opts, opt_cnt, player_idx, sel, 1);
//inp = wait_for_input_usbjoy(CONFIGURABLE_KEYS, &joy);
for (is_down = 0; is_down == 0; ) /* wait for some up event */
kc = in_update_keycode(&dev_id, &is_down, 0); for (is_down = 1; is_down; ) {
kc = in_update_keycode(&dev_id, &is_down, -1);
}
unbind = count_bound_keys(dev_id, opts[sel].mask, player_idx) >= 2; unbind = count_bound_keys(dev_id, opts[sel].mask, player_idx) >= 2;
@ -795,14 +715,16 @@ static void draw_kc_sel(int menu_sel)
me_draw(ctrlopt_entries, ctrlopt_entry_count, tl_x, tl_y, NULL, NULL); me_draw(ctrlopt_entries, ctrlopt_entry_count, tl_x, tl_y, NULL, NULL);
tl_x = 25; tl_x = 25;
text_out16(tl_x, (y=130), "USB joys detected:"); text_out16(tl_x, (y=130), "Input devices:");
if (num_of_joys > 0) { for (i = 0; i < IN_MAX_DEVS && y < 230; i++) {
for (i = 0; i < num_of_joys; i++) { const char *tmp, *name = in_get_dev_name(i, 1);
strncpy(joyname, joy_name(joys[i]), 33); joyname[33] = 0; if (name == NULL)
text_out16(tl_x, (y+=10), "%i: %s", i+1, joyname); continue;
} tmp = strchr(name, ':');
} else { if (tmp != NULL)
text_out16(tl_x, (y+=10), "none"); name = tmp + 1;
strncpy(joyname, name, 33); joyname[33] = 0;
text_out16(tl_x, (y+=10), "%i: %s", i, joyname);
} }
menu_flip(); menu_flip();
@ -839,13 +761,13 @@ static void kc_sel_loop(void)
while (1) while (1)
{ {
draw_kc_sel(menu_sel); draw_kc_sel(menu_sel);
inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_RIGHT|GP2X_LEFT|GP2X_B|GP2X_X); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_RIGHT|PBTN_LEFT|PBTN_MOK|PBTN_MBACK);
selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel); selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel);
if (inp & (GP2X_LEFT|GP2X_RIGHT)) // multi choise if (inp & (PBTN_LEFT|PBTN_RIGHT)) // multi choise
me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&GP2X_RIGHT) ? 1 : 0); me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0);
if (inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if (inp & GP2X_B) { if (inp & PBTN_MOK) {
int is_6button = PicoOpt & POPT_6BTN_PAD; int is_6button = PicoOpt & POPT_6BTN_PAD;
switch (selected_id) { switch (selected_id) {
case MA_CTRL_PLAYER1: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 0); return; case MA_CTRL_PLAYER1: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 0); return;
@ -856,7 +778,7 @@ static void kc_sel_loop(void)
default: return; default: return;
} }
} }
if (inp & GP2X_X) return; if (inp & PBTN_MBACK) return;
} }
} }
@ -957,14 +879,14 @@ static void cd_menu_loop_options(void)
for(;;) for(;;)
{ {
draw_cd_menu_options(menu_sel, &bios_names); draw_cd_menu_options(menu_sel, &bios_names);
inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_B|GP2X_X|GP2X_A|GP2X_START); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_MOK|PBTN_MBACK|GP2X_START); /* FIXME */
if (inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel); selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel);
if (inp & (GP2X_LEFT|GP2X_RIGHT)) { // multi choise if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise
if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, (inp&GP2X_RIGHT) ? 1 : 0) && if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0) &&
selected_id == MA_CDOPT_READAHEAD) { selected_id == MA_CDOPT_READAHEAD) {
if (inp & GP2X_LEFT) { if (inp & PBTN_LEFT) {
PicoCDBuffers >>= 1; PicoCDBuffers >>= 1;
if (PicoCDBuffers < 2) PicoCDBuffers = 0; if (PicoCDBuffers < 2) PicoCDBuffers = 0;
} else { } else {
@ -974,7 +896,7 @@ static void cd_menu_loop_options(void)
} }
} }
} }
if (inp & GP2X_B) { // toggleable options if (inp & PBTN_MOK) { // toggleable options
if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, 1) && if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, 1) &&
selected_id == MA_CDOPT_DONE) { selected_id == MA_CDOPT_DONE) {
return; return;
@ -1007,7 +929,7 @@ static void cd_menu_loop_options(void)
break; break;
} }
} }
if (inp & (GP2X_X|GP2X_A)) return; if (inp & PBTN_MBACK) return;
} }
} }
@ -1071,29 +993,28 @@ static void amenu_loop_options(void)
for(;;) for(;;)
{ {
draw_amenu_options(menu_sel); draw_amenu_options(menu_sel);
inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_B|GP2X_X|GP2X_A); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_MOK|PBTN_MBACK);
if (inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel); selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel);
if (inp & (GP2X_LEFT|GP2X_RIGHT)) { // multi choise if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise
if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, (inp&GP2X_RIGHT) ? 1 : 0) && if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0) &&
selected_id == MA_OPT2_GAMMA) { selected_id == MA_OPT2_GAMMA) {
while ((inp = gp2x_joystick_read(1)) & (GP2X_LEFT|GP2X_RIGHT)) { while ((inp = in_menu_wait_any(20)) & (PBTN_LEFT|PBTN_RIGHT)) {
currentConfig.gamma += (inp & GP2X_LEFT) ? -1 : 1; currentConfig.gamma += (inp & PBTN_LEFT) ? -1 : 1;
if (currentConfig.gamma < 1) currentConfig.gamma = 1; if (currentConfig.gamma < 1) currentConfig.gamma = 1;
if (currentConfig.gamma > 300) currentConfig.gamma = 300; if (currentConfig.gamma > 300) currentConfig.gamma = 300;
draw_amenu_options(menu_sel); draw_amenu_options(menu_sel);
usleep(18*1000);
} }
} }
} }
if (inp & GP2X_B) { // toggleable options if (inp & PBTN_MOK) { // toggleable options
if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, 1) && if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, 1) &&
selected_id == MA_OPT2_DONE) { selected_id == MA_OPT2_DONE) {
return; return;
} }
} }
if (inp & (GP2X_X|GP2X_A)) return; if (inp & PBTN_MBACK) return;
} }
} }
@ -1268,15 +1189,15 @@ static int menu_loop_options(void)
while (1) while (1)
{ {
draw_menu_options(menu_sel); draw_menu_options(menu_sel);
inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_B|GP2X_X|GP2X_A); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_MOK|PBTN_MBACK);
if (inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel); selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel);
if (inp & (GP2X_LEFT|GP2X_RIGHT)) { // multi choice if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choice
if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, (inp&GP2X_RIGHT) ? 1 : 0)) { if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0)) {
switch (selected_id) { switch (selected_id) {
case MA_OPT_RENDERER: case MA_OPT_RENDERER:
if (inp & GP2X_LEFT) { if (inp & PBTN_LEFT) {
if (PicoOpt&0x10) PicoOpt&= ~0x10; if (PicoOpt&0x10) PicoOpt&= ~0x10;
else if (!(currentConfig.EmuOpt &0x80))currentConfig.EmuOpt |= 0x80; else if (!(currentConfig.EmuOpt &0x80))currentConfig.EmuOpt |= 0x80;
else if ( currentConfig.EmuOpt &0x80) break; else if ( currentConfig.EmuOpt &0x80) break;
@ -1287,18 +1208,18 @@ static int menu_loop_options(void)
} }
break; break;
case MA_OPT_SOUND_QUALITY: case MA_OPT_SOUND_QUALITY:
if ((inp & GP2X_RIGHT) && PsndRate == 44100 && !(PicoOpt&0x08)) { if ((inp & PBTN_RIGHT) && PsndRate == 44100 && !(PicoOpt&0x08)) {
PsndRate = 8000; PicoOpt|= 0x08; PsndRate = 8000; PicoOpt|= 0x08;
} else if ((inp & GP2X_LEFT) && PsndRate == 8000 && (PicoOpt&0x08)) { } else if ((inp & PBTN_LEFT) && PsndRate == 8000 && (PicoOpt&0x08)) {
PsndRate = 44100; PicoOpt&=~0x08; PsndRate = 44100; PicoOpt&=~0x08;
} else PsndRate = sndrate_prevnext(PsndRate, inp & GP2X_RIGHT); } else PsndRate = sndrate_prevnext(PsndRate, inp & PBTN_RIGHT);
break; break;
case MA_OPT_REGION: case MA_OPT_REGION:
region_prevnext(inp & GP2X_RIGHT); region_prevnext(inp & PBTN_RIGHT);
break; break;
case MA_OPT_CONFIRM_STATES: { case MA_OPT_CONFIRM_STATES: {
int n = ((currentConfig.EmuOpt>>9)&1) | ((currentConfig.EmuOpt>>10)&2); int n = ((currentConfig.EmuOpt>>9)&1) | ((currentConfig.EmuOpt>>10)&2);
n += (inp & GP2X_LEFT) ? -1 : 1; n += (inp & PBTN_LEFT) ? -1 : 1;
if (n < 0) n = 0; else if (n > 3) n = 3; if (n < 0) n = 0; else if (n > 3) n = 3;
n |= n << 1; n &= ~2; n |= n << 1; n &= ~2;
currentConfig.EmuOpt &= ~0xa00; currentConfig.EmuOpt &= ~0xa00;
@ -1306,23 +1227,22 @@ static int menu_loop_options(void)
break; break;
} }
case MA_OPT_SAVE_SLOT: case MA_OPT_SAVE_SLOT:
if (inp & GP2X_RIGHT) { if (inp & PBTN_RIGHT) {
state_slot++; if (state_slot > 9) state_slot = 0; state_slot++; if (state_slot > 9) state_slot = 0;
} else {state_slot--; if (state_slot < 0) state_slot = 9; } else {state_slot--; if (state_slot < 0) state_slot = 9;
} }
break; break;
case MA_OPT_CPU_CLOCKS: case MA_OPT_CPU_CLOCKS:
while ((inp = gp2x_joystick_read(1)) & (GP2X_LEFT|GP2X_RIGHT)) { while ((inp = in_menu_wait_any(50)) & (PBTN_LEFT|PBTN_RIGHT)) {
currentConfig.CPUclock += (inp & GP2X_LEFT) ? -1 : 1; currentConfig.CPUclock += (inp & PBTN_LEFT) ? -1 : 1;
if (currentConfig.CPUclock < 1) currentConfig.CPUclock = 1; if (currentConfig.CPUclock < 1) currentConfig.CPUclock = 1;
draw_menu_options(menu_sel); draw_menu_options(menu_sel);
usleep(50*1000);
} }
break; break;
case MA_OPT_SAVECFG: case MA_OPT_SAVECFG:
case MA_OPT_SAVECFG_GAME: case MA_OPT_SAVECFG_GAME:
case MA_OPT_LOADCFG: case MA_OPT_LOADCFG:
config_slot += (inp&GP2X_RIGHT) ? 1 : -1; config_slot += (inp&PBTN_RIGHT) ? 1 : -1;
if (config_slot > 9) config_slot = 0; if (config_slot > 9) config_slot = 0;
if (config_slot < 0) config_slot = 9; if (config_slot < 0) config_slot = 9;
me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current); me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current);
@ -1335,7 +1255,7 @@ static int menu_loop_options(void)
} }
} }
} }
if (inp & GP2X_B) { if (inp & PBTN_MOK) {
if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, 1)) if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, 1))
{ {
switch (selected_id) switch (selected_id)
@ -1370,7 +1290,7 @@ static int menu_loop_options(void)
} }
} }
} }
if(inp & (GP2X_X|GP2X_A)) { if(inp & PBTN_MBACK) {
menu_options_save(); menu_options_save();
return 0; // done (update, no write) return 0; // done (update, no write)
} }
@ -1464,28 +1384,28 @@ static void menu_loop_root(void)
/* make sure action buttons are not pressed on entering menu */ /* make sure action buttons are not pressed on entering menu */
draw_menu_root(menu_sel); draw_menu_root(menu_sel);
while (gp2x_joystick_read(1) & (GP2X_B|GP2X_X|GP2X_SELECT)) usleep(50*1000); while (in_menu_wait_any(50) & (PBTN_MOK|PBTN_MBACK|PBTN_MENU));
for (;;) for (;;)
{ {
draw_menu_root(menu_sel); draw_menu_root(menu_sel);
inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_B|GP2X_X|GP2X_SELECT|GP2X_L|GP2X_R); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_MOK|PBTN_MBACK|PBTN_MENU|PBTN_L|PBTN_R);
if(inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if((inp & (GP2X_L|GP2X_R)) == (GP2X_L|GP2X_R)) debug_menu_loop(); if((inp & (PBTN_L|PBTN_R)) == (PBTN_L|PBTN_R)) debug_menu_loop();
if(inp &(GP2X_SELECT|GP2X_X)){ if(inp &(PBTN_MENU|PBTN_MBACK)){
if (rom_loaded) { if (rom_loaded) {
while (gp2x_joystick_read(1) & (GP2X_SELECT|GP2X_X)) usleep(50*1000); // wait until select is released while (in_menu_wait_any(50) & (PBTN_MENU|PBTN_MBACK)); // wait until select is released
engineState = PGS_Running; engineState = PGS_Running;
break; break;
} }
} }
if(inp & GP2X_B) { if(inp & PBTN_MOK) {
switch (me_index2id(main_entries, MAIN_ENTRY_COUNT, menu_sel)) switch (me_index2id(main_entries, MAIN_ENTRY_COUNT, menu_sel))
{ {
case MA_MAIN_RESUME_GAME: case MA_MAIN_RESUME_GAME:
if (rom_loaded) { if (rom_loaded) {
while (gp2x_joystick_read(1) & GP2X_B) usleep(50*1000); while (in_menu_wait_any(50) & PBTN_MOK);
engineState = PGS_Running; engineState = PGS_Running;
return; return;
} }
@ -1502,7 +1422,7 @@ static void menu_loop_root(void)
if (rom_loaded) { if (rom_loaded) {
if(savestate_menu_loop(1)) if(savestate_menu_loop(1))
continue; continue;
while (gp2x_joystick_read(1) & GP2X_B) usleep(50*1000); while (in_menu_wait_any(50) & PBTN_MOK);
engineState = PGS_Running; engineState = PGS_Running;
return; return;
} }
@ -1510,7 +1430,7 @@ static void menu_loop_root(void)
case MA_MAIN_RESET_GAME: case MA_MAIN_RESET_GAME:
if (rom_loaded) { if (rom_loaded) {
emu_ResetGame(); emu_ResetGame();
while (gp2x_joystick_read(1) & GP2X_B) usleep(50*1000); while (in_menu_wait_any(50) & PBTN_MOK);
engineState = PGS_Running; engineState = PGS_Running;
return; return;
} }
@ -1546,7 +1466,7 @@ static void menu_loop_root(void)
case MA_MAIN_CREDITS: case MA_MAIN_CREDITS:
draw_menu_credits(); draw_menu_credits();
usleep(500*1000); usleep(500*1000);
inp = wait_for_input(GP2X_B|GP2X_X); inp = in_menu_wait(PBTN_MOK|PBTN_MBACK);
break; break;
case MA_MAIN_EXIT: case MA_MAIN_EXIT:
engineState = PGS_Quit; engineState = PGS_Quit;
@ -1676,15 +1596,15 @@ int menu_loop_tray(void)
/* make sure action buttons are not pressed on entering menu */ /* make sure action buttons are not pressed on entering menu */
draw_menu_tray(menu_sel); draw_menu_tray(menu_sel);
while (gp2x_joystick_read(1) & GP2X_B) usleep(50*1000); while (in_menu_wait_any(50) & PBTN_MOK);
for (;;) for (;;)
{ {
draw_menu_tray(menu_sel); draw_menu_tray(menu_sel);
inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_B); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_MOK);
if(inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if(inp & GP2X_B ) { if(inp & PBTN_MOK ) {
switch (menu_sel) { switch (menu_sel) {
case 0: // select image case 0: // select image
selfname = romsel_loop(curr_path); selfname = romsel_loop(curr_path);

View file

@ -1,2 +1,2 @@
#define VERSION "1.51b" #define VERSION "1.52"

View file

@ -29,7 +29,7 @@ else
use_cyclone = 1 use_cyclone = 1
endif endif
DEFINC = -I../.. -I. -DARM -DPANDORA DEFINC = -I../.. -I. -DARM -DPANDORA -DIN_EVDEV
COPT_COMMON = -Wall -Winline -mcpu=cortex-a8 -mtune=cortex-a8 -march=armv7-a -I$(LIBROOT)/include COPT_COMMON = -Wall -Winline -mcpu=cortex-a8 -mtune=cortex-a8 -march=armv7-a -I$(LIBROOT)/include
ifeq ($(DEBUG),) ifeq ($(DEBUG),)
COPT_COMMON += -O2 # -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math COPT_COMMON += -O2 # -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math
@ -57,7 +57,8 @@ OBJS += pandora.o main.o emu.o asm_utils.o platform/gp2x/menu.o
# common # common
OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \ OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \
platform/common/arm_utils.o platform/common/mp3_helix.o platform/common/arm_linux.o \ platform/common/arm_utils.o platform/common/mp3_helix.o platform/common/arm_linux.o \
platform/common/readpng.o platform/linux/usbjoy.o platform/linux/sndout_oss.o platform/common/readpng.o platform/common/input.o platform/linux/in_evdev.o \
platform/linux/sndout_oss.o
# Pico # Pico
ifeq "$(amalgamate)" "1" ifeq "$(amalgamate)" "1"
@ -131,7 +132,7 @@ include ../common/common_arm.mak
PicoDrive : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a PicoDrive : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a
@echo ">>>" $@ @echo ">>>" $@
$(CC) -o $@ $(CFLAGS) $^ -lm -Wl,-Map=PicoDrive.map -lpng -L$(LIBROOT)/lib $(CC) -o $@ $(CFLAGS) $^ -lm -Wl,-Map=PicoDrive.map -lpng -L$(LIBROOT)/lib -static
ifeq ($(DEBUG),) ifeq ($(DEBUG),)
$(STRIP) $@ $(STRIP) $@
endif endif

View file

@ -16,12 +16,13 @@
#include "../gp2x/emu.h" #include "../gp2x/emu.h"
#include "../gp2x/menu.h" #include "../gp2x/menu.h"
#include "../gp2x/gp2x.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"
#include "../common/config.h" #include "../common/config.h"
#include "../common/common.h" #include "../common/common.h"
#include "../linux/usbjoy.h" #include "../common/input.h"
#include "../linux/sndout_oss.h" #include "../linux/sndout_oss.h"
#include "asm_utils.h" #include "asm_utils.h"
@ -475,6 +476,7 @@ static void emu_msg_tray_open(void)
gettimeofday(&noticeMsgTime, 0); gettimeofday(&noticeMsgTime, 0);
} }
#if 0
static void RunEventsPico(unsigned int events, unsigned int gp2x_keys) static void RunEventsPico(unsigned int events, unsigned int gp2x_keys)
{ {
int ret, px, py, lim_x; int ret, px, py, lim_x;
@ -526,6 +528,7 @@ static void RunEventsPico(unsigned int events, unsigned int gp2x_keys)
PicoPicohw.pen_pos[0] += 0x3c; PicoPicohw.pen_pos[0] += 0x3c;
PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y); PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y);
} }
#endif
static void update_volume(int has_changed, int is_up) static void update_volume(int has_changed, int is_up)
{ {
@ -569,6 +572,7 @@ static void RunEvents(unsigned int which)
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
#if 0
unsigned long keys; unsigned long keys;
blit("", (which & 0x1000) ? "LOAD STATE? (Y=yes, X=no)" : "OVERWRITE SAVE? (Y=yes, X=no)"); 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)) ) while ( !((keys = gp2x_joystick_read(1)) & (GP2X_X|GP2X_Y)) )
@ -577,6 +581,7 @@ static void RunEvents(unsigned int which)
while ( gp2x_joystick_read(1) & (GP2X_X|GP2X_Y) ) // wait for release while ( gp2x_joystick_read(1) & (GP2X_X|GP2X_Y) ) // wait for release
usleep(50*1024); usleep(50*1024);
clearArea(0); clearArea(0);
#endif
} }
if (do_it) { if (do_it) {
osd_text(4, SCREEN_HEIGHT-16, (which & 0x1000) ? "LOADING GAME" : "SAVING GAME"); osd_text(4, SCREEN_HEIGHT-16, (which & 0x1000) ? "LOADING GAME" : "SAVING GAME");
@ -625,63 +630,11 @@ 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;
int joy, i;
keys = gp2x_joystick_read(0); /* FIXME: combos, player2 */
if (keys & GP2X_SELECT) { allActions[0] = in_update();
engineState = select_exits ? PGS_Quit : PGS_Menu;
// wait until select is released, so menu would not resume game
while (gp2x_joystick_read(1) & GP2X_SELECT) usleep(50*1000);
}
keys &= CONFIGURABLE_KEYS;
keys2 = keys;
for (i = 0; i < 32; i++)
{
if (keys2 & (1 << i))
{
int pl, acts = currentConfig.KeyBinds[i];
if (!acts) continue;
pl = (acts >> 16) & 1;
if (kb_combo_keys & (1 << i))
{
int u = i+1, acts_c = acts & kb_combo_acts;
// let's try to find the other one
if (acts_c) {
for (; u < 32; u++)
if ( (keys2 & (1 << u)) && (currentConfig.KeyBinds[u] & acts_c) ) {
allActions[pl] |= acts_c & currentConfig.KeyBinds[u];
keys2 &= ~((1 << i) | (1 << u));
break;
}
}
// add non-combo actions if combo ones were not found
if (!acts_c || u == 32)
allActions[pl] |= acts & ~kb_combo_acts;
} else {
allActions[pl] |= acts;
}
}
}
// add joy inputs
if (num_of_joys > 0)
{
usbjoy_update();
for (joy = 0; joy < num_of_joys; joy++) {
int btns = usbjoy_check2(joy);
for (i = 0; i < 32; i++) {
if (btns & (1 << i)) {
int acts = currentConfig.JoyBinds[joy][i];
int pl = (acts >> 16) & 1;
allActions[pl] |= acts;
}
}
}
}
PicoPad[0] = allActions[0] & 0xfff; PicoPad[0] = allActions[0] & 0xfff;
PicoPad[1] = allActions[1] & 0xfff; PicoPad[1] = allActions[1] & 0xfff;
@ -703,8 +656,10 @@ static void updateKeys(void)
events &= ~prevEvents; events &= ~prevEvents;
/*
if (PicoAHW == PAHW_PICO) if (PicoAHW == PAHW_PICO)
RunEventsPico(events, keys); RunEventsPico(events, keys);
*/
if (events) RunEvents(events); if (events) RunEvents(events);
if (movie_data) emu_updateMovie(); if (movie_data) emu_updateMovie();
@ -785,10 +740,46 @@ static void simpleWait(int thissec, int lim_time)
} }
} }
void emu_startSound(void)
{
static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;
int target_fps = Pico.m.pal ? 50 : 60;
PsndOut = NULL;
if (currentConfig.EmuOpt & 4)
{
int snd_excess_add;
if (PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old)
PsndRerate(Pico.m.frame_count ? 1 : 0);
snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;
printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",
PsndRate, PsndLen, snd_excess_add, (PicoOpt&8)>>3, Pico.m.pal);
sndout_oss_start(PsndRate, 16, (PicoOpt&8)>>3);
sndout_oss_setvol(currentConfig.volume, currentConfig.volume);
PicoWriteSound = updateSound;
update_volume(0, 0);
memset(sndBuffer, 0, sizeof(sndBuffer));
PsndOut = sndBuffer;
PsndRate_old = PsndRate;
PicoOpt_old = PicoOpt;
pal_old = Pico.m.pal;
}
}
void emu_endSound(void)
{
}
/* wait until we can write more sound */
void emu_waitSound(void)
{
// don't need to do anything, writes will block by themselves
}
void emu_Loop(void) void emu_Loop(void)
{ {
static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;
char fpsbuff[24]; // fps count c string char fpsbuff[24]; // fps count c string
struct timeval tval; // timing struct timeval tval; // timing
int pframes_done, pframes_shown, pthissec; // "period" frames, used for sync int pframes_done, pframes_shown, pthissec; // "period" frames, used for sync
@ -811,28 +802,7 @@ void emu_Loop(void)
target_frametime = 1000000/target_fps; target_frametime = 1000000/target_fps;
reset_timing = 1; reset_timing = 1;
// prepare sound stuff emu_startSound();
if (currentConfig.EmuOpt & 4)
{
int snd_excess_add;
if (PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old)
PsndRerate(Pico.m.frame_count ? 1 : 0);
snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;
printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",
PsndRate, PsndLen, snd_excess_add, (PicoOpt&8)>>3, Pico.m.pal);
sndout_oss_start(PsndRate, 16, (PicoOpt&8)>>3);
sndout_oss_setvol(currentConfig.volume, currentConfig.volume);
PicoWriteSound = updateSound;
update_volume(0, 0);
memset(sndBuffer, 0, sizeof(sndBuffer));
PsndOut = sndBuffer;
PsndRate_old = PsndRate;
PicoOpt_old = PicoOpt;
pal_old = Pico.m.pal;
} else {
PsndOut = NULL;
}
// prepare CD buffer // prepare CD buffer
if (PicoAHW & PAHW_MCD) PicoCDBufferInit(); if (PicoAHW & PAHW_MCD) PicoCDBufferInit();

View file

@ -15,6 +15,7 @@
#include "../common/menu.h" #include "../common/menu.h"
#include "../common/emu.h" #include "../common/emu.h"
#include "../common/config.h" #include "../common/config.h"
#include "../common/input.h"
#include "../gp2x/emu.h" #include "../gp2x/emu.h"
#include "../gp2x/version.h" #include "../gp2x/version.h"
@ -77,10 +78,13 @@ int main(int argc, char *argv[])
{ {
g_argv = argv; g_argv = argv;
in_init();
emu_prepareDefaultConfig(); emu_prepareDefaultConfig();
emu_ReadConfig(0, 0); emu_ReadConfig(0, 0);
config_readlrom(PicoConfigFile); config_readlrom(PicoConfigFile);
in_probe();
in_debug_dump();
gp2x_init(); gp2x_init();
emu_Init(); emu_Init();
menu_init(); menu_init();

View file

@ -12,7 +12,6 @@
#include <errno.h> #include <errno.h>
#include "../gp2x/gp2x.h" #include "../gp2x/gp2x.h"
#include "../linux/usbjoy.h"
#include "../linux/sndout_oss.h" #include "../linux/sndout_oss.h"
#include "../common/arm_linux.h" #include "../common/arm_linux.h"
@ -87,22 +86,6 @@ void gp2x_pd_clone_buffer2(void)
memset(gp2x_screen, 0, 800*480*2); memset(gp2x_screen, 0, 800*480*2);
} }
unsigned long gp2x_joystick_read(int allow_usb_joy)
{
unsigned long value = 0;
int i;
if (allow_usb_joy && num_of_joys > 0) {
// check the usb joy as well..
usbjoy_update();
for (i = 0; i < num_of_joys; i++)
value |= usbjoy_check(i);
}
return value;
}
// FIXME // FIXME
#if 0 #if 0
static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 }; static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };
@ -180,9 +163,6 @@ void gp2x_init(void)
// snd // snd
sndout_oss_init(); sndout_oss_init();
/* init usb joys -GnoStiC */
usbjoy_init();
printf("exitting init()\n"); fflush(stdout); printf("exitting init()\n"); fflush(stdout);
} }
@ -196,7 +176,6 @@ void gp2x_deinit(void)
if (fbdev >= 0) close(fbdev); if (fbdev >= 0) close(fbdev);
sndout_oss_exit(); sndout_oss_exit();
usbjoy_deinit();
printf("all done"); printf("all done");
} }

View file

@ -25,6 +25,7 @@
#include "../common/emu.h" #include "../common/emu.h"
#include "../common/readpng.h" #include "../common/readpng.h"
#include "../common/lprintf.h" #include "../common/lprintf.h"
#include "../common/input.h"
#include "version.h" #include "version.h"
#include <pico/pico_int.h> #include <pico/pico_int.h>
@ -49,49 +50,6 @@ static void menu_prepare_bg(int use_game_bg, int use_fg);
static unsigned int inp_prev = 0; static unsigned int inp_prev = 0;
unsigned long wait_for_input(unsigned int interesting, int is_key_config)
{
unsigned int ret;
static int repeats = 0, wait = 20;
int release = 0, count, i;
if (!is_key_config)
interesting |= (interesting & 0xf0) << 24; // also use analog
if (repeats == 2) wait = 3;
else if (repeats == 4) wait = 2;
else if (repeats == 6) wait = 1;
for (i = 0; i < wait && inp_prev == psp_pad_read(1); i++) {
if (i == 0) repeats++;
psp_msleep(30);
}
for (count = 0; !((ret = psp_pad_read(1)) & interesting) && count < 100; count++) {
psp_msleep(50);
release = 1;
}
if (release || ret != inp_prev) {
repeats = 0;
wait = 20;
}
inp_prev = ret;
if (!is_key_config)
ret |= (ret & 0xf0000000) >> 24; // use analog as d-pad
if (wait > 6 && (ret&(PBTN_UP|PBTN_LEFT|PBTN_DOWN|PBTN_RIGHT|PBTN_L|PBTN_R)))
wait = 6;
// we don't need diagonals in menus
if ((ret&PBTN_UP) && (ret&PBTN_LEFT)) ret &= ~PBTN_LEFT;
if ((ret&PBTN_UP) && (ret&PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
if ((ret&PBTN_DOWN) && (ret&PBTN_LEFT)) ret &= ~PBTN_LEFT;
if ((ret&PBTN_DOWN) && (ret&PBTN_RIGHT)) ret &= ~PBTN_RIGHT;
return ret;
}
void menu_draw_begin(void) void menu_draw_begin(void)
{ {
// short *src = (short *)bg_buffer, *dst = (short *)menu_screen; // short *src = (short *)bg_buffer, *dst = (short *)menu_screen;
@ -384,7 +342,7 @@ static char *romsel_loop(char *curr_path)
for (;;) for (;;)
{ {
draw_dirlist(curr_path, namelist, n, sel); draw_dirlist(curr_path, namelist, n, sel);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_X|PBTN_CIRCLE, 0); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_X|PBTN_CIRCLE, 0);
if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; } if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; }
if(inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; } if(inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; }
if(inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; } if(inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; }
@ -469,7 +427,7 @@ static void patches_menu_loop(void)
for(;;) for(;;)
{ {
draw_patchlist(menu_sel); draw_patchlist(menu_sel);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_X|PBTN_CIRCLE, 0); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_X|PBTN_CIRCLE, 0);
if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; } if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; }
if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; } if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; }
if(inp &(PBTN_LEFT|PBTN_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; } if(inp &(PBTN_LEFT|PBTN_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; }
@ -599,7 +557,7 @@ static int savestate_menu_loop(int is_loading)
for(;;) for(;;)
{ {
draw_savestate_menu(menu_sel, is_loading); draw_savestate_menu(menu_sel, is_loading);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_X|PBTN_CIRCLE, 0); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_X|PBTN_CIRCLE, 0);
if(inp & PBTN_UP ) { if(inp & PBTN_UP ) {
do { do {
menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max;
@ -713,7 +671,7 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_
for (;;) for (;;)
{ {
draw_key_config(opts, opt_cnt, player_idx, sel); draw_key_config(opts, opt_cnt, player_idx, sel);
inp = wait_for_input(CONFIGURABLE_KEYS|PBTN_SELECT, 1); inp = in_menu_wait(CONFIGURABLE_KEYS|PBTN_SELECT, 1);
if (!(inp & PBTN_SELECT)) { if (!(inp & PBTN_SELECT)) {
prev_select = 0; prev_select = 0;
if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; } if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; }
@ -795,7 +753,7 @@ static void kc_sel_loop(void)
while (1) while (1)
{ {
draw_kc_sel(menu_sel); draw_kc_sel(menu_sel);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0);
selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel); selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel);
if (inp & (PBTN_LEFT|PBTN_RIGHT)) // multi choise if (inp & (PBTN_LEFT|PBTN_RIGHT)) // multi choise
me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0); me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0);
@ -918,7 +876,7 @@ static void cd_menu_loop_options(void)
for (;;) for (;;)
{ {
draw_cd_menu_options(menu_sel, &bios_names); draw_cd_menu_options(menu_sel, &bios_names);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE|PBTN_START, 0); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE|PBTN_START, 0);
if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel); selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel);
@ -1081,7 +1039,7 @@ static void dispmenu_loop_options(void)
for (;;) for (;;)
{ {
draw_dispmenu_options(menu_sel); draw_dispmenu_options(menu_sel);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0);
if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(opt3_entries, OPT3_ENTRY_COUNT, menu_sel); selected_id = me_index2id(opt3_entries, OPT3_ENTRY_COUNT, menu_sel);
@ -1195,7 +1153,7 @@ static void amenu_loop_options(void)
for(;;) for(;;)
{ {
draw_amenu_options(menu_sel); draw_amenu_options(menu_sel);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0);
if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel); selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel);
@ -1375,7 +1333,7 @@ static int menu_loop_options(void)
while (1) while (1)
{ {
draw_menu_options(menu_sel); draw_menu_options(menu_sel);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_X|PBTN_CIRCLE, 0);
if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel); selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel);
@ -1581,7 +1539,7 @@ static void menu_loop_root(void)
for (;;) for (;;)
{ {
draw_menu_root(menu_sel); draw_menu_root(menu_sel);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_X|PBTN_CIRCLE|PBTN_SELECT|PBTN_L|PBTN_R, 0); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_X|PBTN_CIRCLE|PBTN_SELECT|PBTN_L|PBTN_R, 0);
if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if((inp & (PBTN_L|PBTN_R)) == (PBTN_L|PBTN_R)) debug_menu_loop(); if((inp & (PBTN_L|PBTN_R)) == (PBTN_L|PBTN_R)) debug_menu_loop();
@ -1661,7 +1619,7 @@ static void menu_loop_root(void)
psp_msleep(500); psp_msleep(500);
inp = 0; inp = 0;
while (!(inp & (PBTN_X|PBTN_CIRCLE))) while (!(inp & (PBTN_X|PBTN_CIRCLE)))
inp = wait_for_input(PBTN_X|PBTN_CIRCLE, 0); inp = in_menu_wait(PBTN_X|PBTN_CIRCLE, 0);
break; break;
case MA_MAIN_EXIT: case MA_MAIN_EXIT:
engineState = PGS_Quit; engineState = PGS_Quit;
@ -1794,7 +1752,7 @@ int menu_loop_tray(void)
for (;;) for (;;)
{ {
draw_menu_tray(menu_sel); draw_menu_tray(menu_sel);
inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_CIRCLE, 0); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_CIRCLE, 0);
if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }
if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if(inp & PBTN_CIRCLE) { if(inp & PBTN_CIRCLE) {