-// (c) Copyright 2007 notaz, All rights reserved.
-// Free for non-commercial use.
-
-// For commercial use, separate licencing terms must be obtained.
+/*
+ * PicoDrive
+ * (C) notaz, 2006-2008
+ *
+ * This work is licensed under the terms of MAME license.
+ * See COPYING file in the top-level directory.
+ */
// don't like to use loads of #ifdefs, so duplicating GP2X code
// horribly instead
#include "../common/emu.h"
#include "../common/readpng.h"
#include "../common/lprintf.h"
+#include "../common/input.h"
#include "version.h"
#include <pico/pico_int.h>
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)
{
// short *src = (short *)bg_buffer, *dst = (short *)menu_screen;
for (;;)
{
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_DOWN) { sel++; if (sel > n-2) sel = 0; }
if(inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; }
for(;;)
{
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_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; }
for(;;)
{
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 ) {
do {
menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max;
for (;;)
{
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)) {
prev_select = 0;
if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; }
while (1)
{
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);
if (inp & (PBTN_LEFT|PBTN_RIGHT)) // multi choise
me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0);
for (;;)
{
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_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel);
for (;;)
{
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_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(opt3_entries, OPT3_ENTRY_COUNT, menu_sel);
for(;;)
{
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_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel);
while (1)
{
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_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel);
for (;;)
{
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_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();
psp_msleep(500);
inp = 0;
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;
case MA_MAIN_EXIT:
engineState = PGS_Quit;
for (;;)
{
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_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if(inp & PBTN_CIRCLE) {