Skip to content

Commit

Permalink
Merge pull request #8 from rsn8887/master
Browse files Browse the repository at this point in the history
Update virtual keyboard controls to be easier
  • Loading branch information
Cpasjuste committed Dec 27, 2016
2 parents 670c342 + 799a89d commit adcabab
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 32 deletions.
12 changes: 9 additions & 3 deletions Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ cross=X
triangle=Y

Select = toggle menu
Start + Select (in this order) = toggle virtual keyboard
Start+dpad up/down = move screen up down
Start+dpad left/right = change screenmode (to zoom games with large black borders)
Start = toggle virtual keyboard
R+Start+dpad up/down = move screen up down
R+Start+dpad left/right = change screenmode (to zoom games with large black borders)
right analog stick = analog mouse (can switch this to left in menu)
left analog stick = acts as amiga joystick

Expand All @@ -56,3 +56,9 @@ R+dpad = arrow keys
When custom mouse controls are on:
Dpad = digital mouse
Triangle = slow mouse down

When virtual keyboard is on:
Right analog stick up/down = move virtual keyboard up/down
Right analog stick left/right = change virtual keyboard transparency
Square = backspace
Triangle = toggle shift
16 changes: 14 additions & 2 deletions src/gp2x/menu/menu_controls.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
20 changes: 11 additions & 9 deletions src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ extern SDL_Surface *prSDLScreen;
extern SDL_Joystick *uae4all_joy0, *uae4all_joy1;

#ifdef __PSP2__
//Predefined quick switch resolutions to select via START+DPAD LEFT/RIGHT
//Predefined quick switch resolutions to select via TRIGGER R+START+DPAD LEFT/RIGHT
int quickSwitchModeID=8;
struct myRes
{
Expand Down Expand Up @@ -566,6 +566,11 @@ void gui_handle_events (void)
//From now on only center when entering menu
haveJoysticksBeenCentered=1;
}

lAnalogX=lAnalogX-lAnalogXCenter;
lAnalogY=lAnalogY-lAnalogYCenter;
rAnalogX=rAnalogX-rAnalogXCenter;
rAnalogY=rAnalogY-rAnalogYCenter;

if (mainMenu_leftStickMouse) {
dpadRight = SDL_JoystickGetButton(uae4all_joy0, 9)
Expand All @@ -576,8 +581,6 @@ void gui_handle_events (void)
|| (rAnalogY < -1024*10) ? 1 : 0;
dpadDown = SDL_JoystickGetButton(uae4all_joy0, 6)
|| (rAnalogY > 1024*10) ? 1 : 0;
lAnalogX=lAnalogX-lAnalogXCenter;
lAnalogY=lAnalogY-lAnalogYCenter;
}
else
{
Expand All @@ -589,8 +592,6 @@ void gui_handle_events (void)
|| (lAnalogY < -1024*10) ? 1 : 0;
dpadDown = SDL_JoystickGetButton(uae4all_joy0, 6)
|| (lAnalogY > 1024*10) ? 1 : 0;
rAnalogX=rAnalogX-rAnalogXCenter;
rAnalogY=rAnalogY-rAnalogYCenter;
}

buttonA = SDL_JoystickGetButton(uae4all_joy0, PAD_SQUARE);
Expand All @@ -602,7 +603,7 @@ void gui_handle_events (void)
buttonSelect = SDL_JoystickGetButton(uae4all_joy0, PAD_SELECT);
buttonStart = SDL_JoystickGetButton(uae4all_joy0, PAD_START);

if(buttonSelect && !buttonStart) //start+select = virtual keyboard vkbd
if(buttonSelect)
{
//re-center the Joysticks when the user opens the menu
SDL_JoystickUpdate();
Expand Down Expand Up @@ -733,7 +734,7 @@ if(!vkbd_mode)
{
#ifdef __PSP2__
//holding start on Vita to move screen, L/R are used for mousebuttons.
if(buttonStart)
if(buttonStart && triggerR)
#else
//L + R
if(triggerL && triggerR)
Expand Down Expand Up @@ -1705,8 +1706,9 @@ if(!vkbd_mode)

#ifdef USE_UAE4ALL_VKBD
#ifdef __PSP2__
//on Vita Start+Select (in this order) brings up the virtual keyboard
if(buttonStart && buttonSelect)
//on Vita, Start brings up the virtual keyboard, but Trigger R + Start is used for
//quickswitch resolution etc.
if(buttonStart && !triggerR)
#else
//L+K: virtual keyboard
if(triggerL && keystate[SDLK_k])
Expand Down

0 comments on commit adcabab

Please sign in to comment.