Skip to content

Commit

Permalink
Vita: - virtual keyboard (mapped to "hold start then press select")
Browse files Browse the repository at this point in the history
- labels in custom control menu now reflect Vita controller
- default analog mouse control deadzone increased from 100 to 1000 to fix mouse pointer drift (can be changed in menu)
- default joystick port set to 1, since the mouse is always on (can be changed in menu)
  • Loading branch information
rsn8887 committed Dec 23, 2016
1 parent 515c939 commit 7d3449b
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 36 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Expand Up @@ -27,6 +27,7 @@ set(INC_FILES
src/menu
src/include
src/gp2x/menu
src/vkbd
)

set(FLAGS
Expand All @@ -37,6 +38,8 @@ set(FLAGS
-DUSE_SDL -DGCCCONSTFUNC="__attribute__\(\(const\)\)" -DUSE_UNDERSCORE
-DSHM_SUPPORT_LINKS=0 -DUNALIGNED_PROFITABLE -DOPTIMIZED_FLAGS -DOS_WITHOUT_MEMORY_MANAGEMENT
-DROM_PATH_PREFIX=\"ux0:/data/uae4all/roms/\" -DDATA_PREFIX=\"app0:/data/\" -DSAVE_PREFIX=\"ux0:/data/uae4all/saves/\"
-DUSE_UAE4ALL_VKBD
-DVKBD_ALWAYS
-fomit-frame-pointer -Wno-unused -Wno-format
-ffast-math -fstrict-aliasing -mstructure-size-boundary=32 -fexpensive-optimizations
-fweb -frename-registers -fomit-frame-pointer
Expand Down Expand Up @@ -152,4 +155,4 @@ add_custom_target(${PROJECT_NAME}-debug.vpk
COMMAND ${VITASDK}/bin/vita-mksfoex -s TITLE_ID=${TITLE_ID} "${PROJECT_NAME}" vpk/sce_sys/param.sfo
COMMAND cp -r ${CMAKE_SOURCE_DIR}/psp2data/* vpk
COMMAND cd vpk && zip -r ../uae4all-debug-${BUILD_DATE}.vpk . && cd ..
)
)
5 changes: 3 additions & 2 deletions Readme.txt
Expand Up @@ -38,12 +38,13 @@ 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 in on games with borders)
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

Only when custom controls are off:
When custom controls are off:
L/R=mousebuttons
R+Square = CTRL
R+Circle = LALT
Expand Down
12 changes: 10 additions & 2 deletions src/gp2x/menu/menu_config.cpp
Expand Up @@ -60,7 +60,11 @@ int mainMenu_CPU_speed = 0;
int mainMenu_cpuSpeed = 600;

int mainMenu_joyConf = 0;
#ifdef __PSP2__
int mainMenu_joyPort = 2; // Default to port 1 on Vita because mouse is always on.
#else
int mainMenu_joyPort = 0; // Both ports
#endif
int mainMenu_autofireRate = 8;
int mainMenu_showStatus = DEFAULT_STATUSLN;
int mainMenu_mouseMultiplier = DEFAULT_MOUSEMULTIPLIER;
Expand Down Expand Up @@ -95,7 +99,7 @@ int saveMenu_n_savestate = 0;
#ifdef __PSP2__
int mainMenu_shader = 5;
int mainMenu_leftStickMouse = 0;
int mainMenu_deadZone = 100;
int mainMenu_deadZone = 1000;
#endif

// The following params in use, but can't be changed with gui
Expand Down Expand Up @@ -189,7 +193,11 @@ void SetDefaultMenuSettings(int general)

mainMenu_cpuSpeed = 600;
mainMenu_joyConf = 0;
#ifdef __PSP2__
mainMenu_joyPort = 2; // Default to port 1 on Vita because mouse is always on.
#else
mainMenu_joyPort = 0;
#endif
mainMenu_autofireRate = 8;
mainMenu_showStatus = DEFAULT_STATUSLN;
mainMenu_mouseMultiplier = DEFAULT_MOUSEMULTIPLIER;
Expand Down Expand Up @@ -220,7 +228,7 @@ void SetDefaultMenuSettings(int general)
#ifdef __PSP2__
mainMenu_shader = 5;
mainMenu_leftStickMouse = 0;
mainMenu_deadZone = 100;
mainMenu_deadZone = 1000;
#endif

// The following params can't be changed in gui
Expand Down
16 changes: 16 additions & 0 deletions src/gp2x/menu/menu_controls.cpp
Expand Up @@ -391,31 +391,47 @@ static void draw_controlsMenu(int c)

// MENUCONTROLS_A
menuLine+=3;
#ifdef __PSP2__
write_text(leftMargin,menuLine,"(Square)");
#else
write_text(leftMargin,menuLine," (A)");
#endif
getMapping(mainMenu_custom_A);
if ((menuControls!=MENUCONTROLS_A)||(bb))
write_text_inv(tabstop1-4,menuLine,mapping);
else
write_text(tabstop1-4,menuLine,mapping);
// MENUCONTROLS_B
menuLine+=2;
#ifdef __PSP2__
write_text(leftMargin,menuLine,"(Circle)");
#else
write_text(leftMargin,menuLine," (B)");
#endif
getMapping(mainMenu_custom_B);
if ((menuControls!=MENUCONTROLS_B)||(bb))
write_text_inv(tabstop1-4,menuLine,mapping);
else
write_text(tabstop1-4,menuLine,mapping);
// MENUCONTROLS_X
menuLine+=2;
#ifdef __PSP2__
write_text(leftMargin,menuLine,"(Cross)");
#else
write_text(leftMargin,menuLine," (X)");
#endif
getMapping(mainMenu_custom_X);
if ((menuControls!=MENUCONTROLS_X)||(bb))
write_text_inv(tabstop1-4,menuLine,mapping);
else
write_text(tabstop1-4,menuLine,mapping);
// MENUCONTROLS_Y
menuLine+=2;
#ifdef __PSP2__
write_text(leftMargin,menuLine,"(Triangle)");
#else
write_text(leftMargin,menuLine," (Y)");
#endif
getMapping(mainMenu_custom_Y);
if ((menuControls!=MENUCONTROLS_Y)||(bb))
write_text_inv(tabstop1-4,menuLine,mapping);
Expand Down
11 changes: 10 additions & 1 deletion src/gui.cpp
Expand Up @@ -253,9 +253,11 @@ static void goMenu(void)
if (quit_program != 0)
return;
emulating=1;
#ifndef __PSP2__ //no need to erase all the vkbd graphics from memory on Vita
#ifdef USE_UAE4ALL_VKBD
vkbd_quit();
#endif
#endif
pause_sound();
#ifdef USE_GUICHAN
running=true;
Expand All @@ -276,7 +278,9 @@ static void goMenu(void)
quit_text();
#endif
#ifdef USE_UAE4ALL_VKBD
#ifndef __PSP2__ //no need to reload all the vkbd graphics everytime on Vita
vkbd_init();
#endif
#endif
getChanges();
#ifdef USE_UAE4ALL_VKBD
Expand Down Expand Up @@ -598,7 +602,7 @@ void gui_handle_events (void)
buttonSelect = SDL_JoystickGetButton(uae4all_joy0, PAD_SELECT);
buttonStart = SDL_JoystickGetButton(uae4all_joy0, PAD_START);

if(buttonSelect)
if(buttonSelect && !buttonStart) //start+select = virtual keyboard vkbd
{
//re-center the Joysticks when the user opens the menu
SDL_JoystickUpdate();
Expand Down Expand Up @@ -1700,8 +1704,13 @@ if(!vkbd_mode)
} // if(!vkbd_mode)

#ifdef USE_UAE4ALL_VKBD
#ifdef __PSP2__
//on Vita Start+Select (in this order) brings up the virtual keyboard
if(buttonStart && buttonSelect)
#else
//L+K: virtual keyboard
if(triggerL && keystate[SDLK_k])
#endif
{
if(!justLK)
{
Expand Down
5 changes: 5 additions & 0 deletions src/main.cpp
Expand Up @@ -186,6 +186,11 @@ void do_start_program (void)
void do_leave_program (void)
{
#ifdef USE_SDL
#ifdef __PSP2__ //On Vita, only remove keyboard graphics from memory when quitting the emu
#ifdef USE_UAE4ALL_VKBD
vkbd_quit();
#endif
#endif
if(current_screenshot != NULL)
SDL_FreeSurface(current_screenshot);
#endif
Expand Down
18 changes: 14 additions & 4 deletions src/od-joy.cpp
Expand Up @@ -103,16 +103,20 @@ void read_joystick(int nr, unsigned int *dir, int *button)
if (mouseScale > (99*16))
mouseScale /= 100;

#ifdef USE_UAE4ALL_VKBD
#if !defined(__PSP2__) && defined(USE_UAE4ALL_VKBD)
if (!vkbd_mode && ((mainMenu_customControls && mainMenu_custom_dpad==2) || gp2xMouseEmuOn || (triggerL && !triggerR && !gp2xButtonRemappingOn)))
#else
#ifdef __PSP2__
#if defined(__PSP2__) && defined(USE_UAE4ALL_VKBD)
//on Vita, the L trigger is by default mapped to a mousebutton
//so remove the hard coded LTrigger here that was enabling the digital mouse
if (((mainMenu_customControls && mainMenu_custom_dpad==2) || gp2xMouseEmuOn))
if (!vkbd_mode && ((mainMenu_customControls && mainMenu_custom_dpad==2) || gp2xMouseEmuOn))
#else
#if defined(__PSP2__)
if ((mainMenu_customControls && mainMenu_custom_dpad==2) || gp2xMouseEmuOn)
#else
if (((mainMenu_customControls && mainMenu_custom_dpad==2) || gp2xMouseEmuOn || (triggerL && !triggerR && !gp2xButtonRemappingOn)))
#endif //__PSP2__
#endif
#endif
#endif
{
if (buttonY)
Expand Down Expand Up @@ -181,6 +185,9 @@ void read_joystick(int nr, unsigned int *dir, int *button)
}
}

#ifdef USE_UAE4ALL_VKBD
if (!vkbd_mode) {
#endif
#ifdef __PSP2__
//VITA: always use an analog stick (default: right stick) for mouse pointer movements
//here we are using a small deadzone
Expand Down Expand Up @@ -212,6 +219,9 @@ void read_joystick(int nr, unsigned int *dir, int *button)
newmousecounters=1;
}
#endif //__PSP2__
#ifdef USE_UAE4ALL_VKBD
}
#endif

#ifdef USE_UAE4ALL_VKBD
if(mainMenu_customControls && !vkbd_mode)
Expand Down
30 changes: 22 additions & 8 deletions src/sdlgfx.cpp
Expand Up @@ -36,7 +36,7 @@
#include "gui.h"
#include "debug.h"
#ifdef USE_UAE4ALL_VKBD
#include "vkbd/vkbd.h"
#include "vkbd.h"
#endif
#include "gp2x.h"
#include "gp2xutil.h"
Expand Down Expand Up @@ -118,12 +118,21 @@ static unsigned long next_synctime = 0;

void flush_block ()
{
#ifndef __PSP2__
SDL_UnlockSurface (prSDLScreen);
#ifndef __PSP2__ //no need to unlock screen on Vita unless we have to
SDL_UnlockSurface(prSDLScreen);
#endif
#ifdef USE_UAE4ALL_VKBD
#ifdef USE_UAE4ALL_VKBD //draw vkbd and process user input
#ifdef __PSP2__ //even on Vita, vkbd blitting requires unlock/lock
if (vkbd_mode)
{
SDL_UnlockSurface(prSDLScreen);
vkbd_key=vkbd_process();
SDL_LockSurface(prSDLScreen);
}
#else
if (vkbd_mode)
vkbd_key=vkbd_process();
vkbd_key=vkbd_process();
#endif
#endif
if (show_inputmode)
inputmode_redraw();
Expand Down Expand Up @@ -605,16 +614,21 @@ void handle_events (void)
show_inputmode = 1;
}
}
#endif //__PSP2__
#ifdef USE_UAE4ALL_VKBD
#ifdef __PSP2__ //skipped the above inputmode cycling on PSP2
if ((!gp2xMouseEmuOn) && (!gp2xButtonRemappingOn) && (!vkbd_mode) && (vkbd_button2!=(SDLKey)0))
#else
else if ((!gp2xMouseEmuOn) && (!gp2xButtonRemappingOn) && (!vkbd_mode) && (vkbd_button2!=(SDLKey)0))
#endif
{
if (vkbd_button2)
if (vkbd_button2) // button2 keyboard was a planned feature, not yet implemented
rEvent.key.keysym.sym=vkbd_button2;
else
break;
}
#endif
#endif //__PSP2__
#endif //UAE_UAE4ALL_VKBD

#ifndef PANDORA
if (gp2xButtonRemappingOn)
#endif
Expand Down

0 comments on commit 7d3449b

Please sign in to comment.