Skip to content

Commit

Permalink
Vita: - Allow menu quit from within sub-menus using 'select'
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 committed Dec 27, 2016
1 parent dc877ea commit 799a89d
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 19 deletions.
16 changes: 14 additions & 2 deletions src/gp2x/menu/menu_controls.cpp
Expand Up @@ -34,6 +34,8 @@ const char *text_str_controls_separator="----------------------------------";
const char *text_str_controls_title= " Custom Controls -";
char mapping[32]="";
int menuControls = 0;
extern int quit_pressed_in_submenu;
extern int emulating;

enum {
MENUCONTROLS_RETURNMAIN = 0,
Expand Down Expand Up @@ -463,7 +465,7 @@ static int key_controlsMenu(int *c)
{
int end=0;
static int delay=0;
int left=0, right=0, up=0, down=0, hit0=0, hit1=0;
int left=0, right=0, up=0, down=0, hit0=0, hit1=0, hit2=0;
SDL_Event event;
#ifndef __PSP2__ // this can be snappy on Vita no need to worry about touch
delay ++;
Expand All @@ -486,9 +488,19 @@ static int key_controlsMenu(int *c)
case SDLK_LALT: hit1=1; break;
case SDLK_END: hit0=1; break;
case SDLK_PAGEUP: hit0=1;
case SDLK_LCTRL: hit2=1; break; //allow user to quit menu completely at any time
//note SDLK_CTRL corresponds to ButtonSelect on Vita
}
}
if (hit2) //Does the user want to cancel the menu completely?
{
if (emulating)
{
end = -1;
quit_pressed_in_submenu = 1; //Tell the mainMenu to cancel, too
}
}
if (hit0)
else if (hit0)
{
end = -1;
}
Expand Down
19 changes: 15 additions & 4 deletions src/gp2x/menu/menu_display.cpp
Expand Up @@ -45,6 +45,8 @@ int menuDisplay = 0;
extern int moveY;
extern int screenWidth;
extern int sound_rate;
extern int quit_pressed_in_submenu;
extern int emulating;

enum {
MENUDISPLAY_RETURNMAIN = 0,
Expand Down Expand Up @@ -350,7 +352,7 @@ static void draw_displayMenu(int c)
static int key_displayMenu(int *c)
{
int end=0;
int left=0, right=0, up=0, down=0, hit0=0, hit1=0;
int left=0, right=0, up=0, down=0, hit0=0, hit1=0, hit2=0;
SDL_Event event;

while (SDL_PollEvent(&event) > 0)
Expand All @@ -368,12 +370,21 @@ static int key_displayMenu(int *c)
case SDLK_HOME: hit0=1; break;
case SDLK_LALT: hit1=1; break;
case SDLK_END: hit0=1; break;
case SDLK_PAGEUP: hit0=1;
case SDLK_PAGEUP: hit0=1;
case SDLK_LCTRL: hit2=1; break; //allow user to quit menu completely at any time
//note SDLK_CTRL corresponds to ButtonSelect on Vita
}
}
}

if (hit0)
if (hit2) //Does the user want to cancel the menu completely?
{
if (emulating)
{
end = -1;
quit_pressed_in_submenu = 1; //Tell the mainMenu to cancel, too
}
}
else if (hit0)
{
end = -1;
}
Expand Down
68 changes: 64 additions & 4 deletions src/gp2x/menu/menu_main.cpp
Expand Up @@ -87,6 +87,7 @@ static const char *text_str_exit= "Quit (Q)";

int mainMenu_case=-1;
int mainMenu_system=-1;
int quit_pressed_in_submenu=0;

int nr_drives=DEFAULT_DRIVES;
int current_drive=0;
Expand Down Expand Up @@ -821,7 +822,19 @@ int run_mainMenu()
break;
case MAIN_MENU_CASE_MEMDISK:
run_menuMemDisk();
mainMenu_case=-1;
if (quit_pressed_in_submenu) //User quit menu while in sub-menu
{
if (emulating)
{
setCpuSpeed();
mainMenu_case=1;
}
else
mainMenu_case=-1;
quit_pressed_in_submenu=0;
}
else
mainMenu_case=-1;
break;
case MAIN_MENU_CASE_SAVESTATES:
run_menuSavestates();
Expand All @@ -830,6 +843,17 @@ int run_mainMenu()
setCpuSpeed();
mainMenu_case=1;
}
else if (quit_pressed_in_submenu) //User quit menu while in sub-menu
{
if (emulating)
{
setCpuSpeed();
mainMenu_case=1;
}
else
mainMenu_case=-1;
quit_pressed_in_submenu=0;
}
else
mainMenu_case=-1;
break;
Expand Down Expand Up @@ -877,19 +901,55 @@ int run_mainMenu()
case MAIN_MENU_CASE_CONTROLS:
{
run_menuControls();
mainMenu_case=-1;
if (quit_pressed_in_submenu) //User quit menu while in sub-menu
{
if (emulating)
{
setCpuSpeed();
mainMenu_case=1;
}
else
mainMenu_case=-1;
quit_pressed_in_submenu=0;
}
else
mainMenu_case=-1;
}
break;
case MAIN_MENU_CASE_DISPLAY:
{
run_menuDisplay();
mainMenu_case=-1;
if (quit_pressed_in_submenu) //User quit menu while in sub-menu
{
if (emulating)
{
setCpuSpeed();
mainMenu_case=1;
}
else
mainMenu_case=-1;
quit_pressed_in_submenu=0;
}
else
mainMenu_case=-1;
}
break;
case MAIN_MENU_CASE_MISC:
{
run_menuMisc();
mainMenu_case=-1;
if (quit_pressed_in_submenu) //User quit menu while in sub-menu
{
if (emulating)
{
setCpuSpeed();
mainMenu_case=1;
}
else
mainMenu_case=-1;
quit_pressed_in_submenu=0;
}
else
mainMenu_case=-1;
}
break;
case MAIN_MENU_CASE_QUIT:
Expand Down
18 changes: 14 additions & 4 deletions src/gp2x/menu/menu_memory_disk.cpp
Expand Up @@ -44,6 +44,8 @@ const char *text_str_4M="4M";
const char *text_str_8M="8M";

int menuMemDisk = 0;
extern int quit_pressed_in_submenu;
extern int emulating;

enum {
MENUDISK_RETURNMAIN = 0,
Expand Down Expand Up @@ -278,7 +280,7 @@ static int key_memDiskMenu(int *c)
{
int end=0;
int left=0, right=0, up=0, down=0;
int hit0=0, hit1=0;
int hit0=0, hit1=0, hit2=0;
int del=0;

SDL_Event event;
Expand All @@ -299,19 +301,27 @@ static int key_memDiskMenu(int *c)
case SDLK_PAGEDOWN: hit0=1; break;
case SDLK_HOME: hit0=1; break;
case SDLK_LALT: hit1=1; break;
case SDLK_LCTRL: hit0=1; break;
case SDLK_RSHIFT: hit0=1; break;
case SDLK_RCTRL: hit0=1; break;
case SDLK_END: hit0=1; break;
case SDLK_PAGEUP: hit0=1; break;
case SDLK_DELETE: case SDLK_BACKSPACE: case SDLK_ESCAPE: del=1; break;
case SDLK_LCTRL: hit2=1; break; //allow user to quit menu completely at any time
//note SDLK_CTRL corresponds to ButtonSelect on Vita
default:
break;
}
}
}

if (hit1)
if (hit2) //Does the user want to cancel the menu completely?
{
if (emulating)
{
end = -1;
quit_pressed_in_submenu = 1; //Tell the mainMenu to cancel, too
}
}
else if (hit1)
{
end=-1;
}
Expand Down
17 changes: 14 additions & 3 deletions src/gp2x/menu/menu_misc.cpp
Expand Up @@ -51,6 +51,8 @@ static const char *text_str_4x="4x";
int menuMisc = 0;

extern int kickstart;
extern int quit_pressed_in_submenu;
extern int emulating;

enum {
MENUMISC_RETURNMAIN = 0,
Expand Down Expand Up @@ -424,7 +426,7 @@ static void draw_miscMenu(int c)
static int key_miscMenu(int *c)
{
int end=0;
int left=0, right=0, up=0, down=0, hit0=0, hit1=0;
int left=0, right=0, up=0, down=0, hit0=0, hit1=0, hit2=0;
SDL_Event event;

while (SDL_PollEvent(&event) > 0)
Expand All @@ -443,10 +445,19 @@ static int key_miscMenu(int *c)
case SDLK_LALT: hit1=1; break;
case SDLK_END: hit0=1; break;
case SDLK_PAGEUP: hit0=1;
case SDLK_LCTRL: hit2=1; break; //allow user to quit menu completely at any time
//note SDLK_CTRL corresponds to ButtonSelect on Vita
}
}

if (hit0)
if (hit2) //Does the user want to cancel the menu completely?
{
if (emulating)
{
end = -1;
quit_pressed_in_submenu = 1; //Tell the mainMenu to cancel, too
}
}
else if (hit0)
{
end = -1;
}
Expand Down
15 changes: 13 additions & 2 deletions src/gp2x/menu/menu_savestates.cpp
Expand Up @@ -32,6 +32,7 @@ static const char *text_str_exit="Back to Main Menu";

extern int emulating;
extern int saveMenu_n_savestate;
extern int quit_pressed_in_submenu;

int saveMenu_case=-1;

Expand Down Expand Up @@ -128,10 +129,20 @@ static inline int key_saveMenu(int *cp)
case SDLK_LALT: hit1=1; break;
case SDLK_END: hit0=1; break;
case SDLK_PAGEUP: hit0=1;
case SDLK_LCTRL: hit2=1; break; //allow user to quit menu completely at any time
//note SDLK_CTRL corresponds to ButtonSelect on Vita
}
}

if (up)
if (hit2) // does the user want to shut-down the whole menu?
{
if (emulating)
{
saveMenu_case=SAVE_MENU_CASE_CANCEL; // quit this menu
end=1;
quit_pressed_in_submenu=1; //also change mainMenu state so that it automatically exits
}
}
else if (up)
{
if (c>0) c=(c-1)%4;
else c=3;
Expand Down

0 comments on commit 799a89d

Please sign in to comment.