-// (c) Copyright 2006,2007 notaz, All rights reserved.\r
-// Free for non-commercial use.\r
-\r
-// For commercial use, separate licencing terms must be obtained.\r
+/*\r
+ * PicoDrive\r
+ * (C) notaz, 2006-2008\r
+ *\r
+ * This work is licensed under the terms of MAME license.\r
+ * See COPYING file in the top-level directory.\r
+ */\r
\r
// don't like to use loads of #ifdefs, so duplicating GP2X code\r
// horribly instead\r
#include "../common/menu.h"\r
#include "../common/emu.h"\r
#include "../common/readpng.h"\r
+#include "../common/input.h"\r
#include "version.h"\r
\r
#include <pico/pico_int.h>\r
\r
static unsigned int inp_prev = 0;\r
\r
-unsigned long wait_for_input(unsigned int interesting)\r
-{\r
- unsigned long ret;\r
- static int repeats = 0, wait = 20;\r
- int release = 0, i;\r
-\r
- if (repeats == 2) wait = 3;\r
- else if (repeats == 4) wait = 2;\r
- else if (repeats == 6) wait = 1;\r
-\r
- for (i = 0; i < wait && inp_prev == Framework_PollGetButtons(); i++) {\r
- if (i == 0) repeats++;\r
- Sleep(30);\r
- }\r
-\r
- while ( !((ret = Framework_PollGetButtons()) & interesting) ) {\r
- Sleep(50);\r
- release = 1;\r
- }\r
-\r
- if (release || ret != inp_prev) {\r
- repeats = 0;\r
- wait = 20;\r
- }\r
- if (wait > 6 && (ret&(PBTN_UP|PBTN_LEFT|PBTN_DOWN|PBTN_RIGHT|PBTN_L|PBTN_R)))\r
- wait = 6;\r
- inp_prev = ret;\r
-\r
- // we don't need diagonals in menus\r
- if ((ret&PBTN_UP) && (ret&PBTN_LEFT)) ret &= ~PBTN_LEFT;\r
- if ((ret&PBTN_UP) && (ret&PBTN_RIGHT)) ret &= ~PBTN_RIGHT;\r
- if ((ret&PBTN_DOWN) && (ret&PBTN_LEFT)) ret &= ~PBTN_LEFT;\r
- if ((ret&PBTN_DOWN) && (ret&PBTN_RIGHT)) ret &= ~PBTN_RIGHT;\r
-\r
- return ret;\r
-}\r
-\r
-\r
void menu_draw_begin(int use_bgbuff)\r
{\r
if (use_bgbuff)\r
for (;;)\r
{\r
draw_dirlist(curr_path, namelist, n, sel);\r
- inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP);\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP);\r
if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; }\r
if(inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; }\r
if(inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; }\r
for(;;)\r
{\r
draw_patchlist(menu_sel);\r
- inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP);\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP);\r
if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; }\r
if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; }\r
if(inp &(PBTN_LEFT|PBTN_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; }\r
for(;;)\r
{\r
draw_savestate_menu(menu_sel, is_loading);\r
- inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP);\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP);\r
if(inp & PBTN_UP ) {\r
do {\r
menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max;\r
for (;;)\r
{\r
draw_key_config(opts, opt_cnt, player_idx, sel);\r
- inp = wait_for_input(CONFIGURABLE_KEYS|PBTN_HOME);\r
+ inp = in_menu_wait(CONFIGURABLE_KEYS|PBTN_HOME);\r
if (!(inp & PBTN_HOME)) {\r
prev_select = 0;\r
if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; }\r
while (1)\r
{\r
draw_kc_sel(menu_sel);\r
- inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP);\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP);\r
selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel);\r
if (inp & (PBTN_LEFT|PBTN_RIGHT)) // multi choise\r
me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0);\r
for(;;)\r
{\r
draw_cd_menu_options(menu_sel, &bios_names);\r
- inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);\r
if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel);\r
for(;;)\r
{\r
draw_amenu_options(menu_sel);\r
- inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);\r
if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel);\r
while (1)\r
{\r
draw_menu_options(menu_sel);\r
- inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);\r
if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel);\r
for (;;)\r
{\r
draw_menu_root(menu_sel);\r
- inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP|PBTN_HOME|PBTN_L|PBTN_R);\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP|PBTN_HOME|PBTN_L|PBTN_R);\r
if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
if((inp & (PBTN_L|PBTN_R)) == (PBTN_L|PBTN_R)) debug_menu_loop();\r
case MA_MAIN_CREDITS:\r
draw_menu_credits();\r
Sleep(500);\r
- inp = wait_for_input(PBTN_PLAY|PBTN_STOP);\r
+ inp = in_menu_wait(PBTN_PLAY|PBTN_STOP);\r
break;\r
case MA_MAIN_EXIT:\r
engineState = PGS_Quit;\r
for (;;)\r
{\r
draw_menu_tray(menu_sel);\r
- inp = wait_for_input(PBTN_UP|PBTN_DOWN|PBTN_PLAY);\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY);\r
if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
if(inp & PBTN_PLAY) {\r