diff --git a/CMakeLists.txt b/CMakeLists.txt index c4cb966..62a0b5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ set(INC_FILES src/menu src/include src/gp2x/menu + src/vkbd ) set(FLAGS @@ -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 @@ -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 .. - ) \ No newline at end of file + ) diff --git a/Readme.txt b/Readme.txt index 97d5350..2082eef 100755 --- a/Readme.txt +++ b/Readme.txt @@ -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 diff --git a/src/gp2x/menu/menu_config.cpp b/src/gp2x/menu/menu_config.cpp index d8d4b4f..daf4570 100755 --- a/src/gp2x/menu/menu_config.cpp +++ b/src/gp2x/menu/menu_config.cpp @@ -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; @@ -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 @@ -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; @@ -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 diff --git a/src/gp2x/menu/menu_controls.cpp b/src/gp2x/menu/menu_controls.cpp index f57cbdd..eb295ec 100755 --- a/src/gp2x/menu/menu_controls.cpp +++ b/src/gp2x/menu/menu_controls.cpp @@ -391,7 +391,11 @@ 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); @@ -399,7 +403,11 @@ static void draw_controlsMenu(int c) 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); @@ -407,7 +415,11 @@ static void draw_controlsMenu(int c) 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); @@ -415,7 +427,11 @@ static void draw_controlsMenu(int c) 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); diff --git a/src/gui.cpp b/src/gui.cpp index 9da3165..9ee49f0 100755 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -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; @@ -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 @@ -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(); @@ -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) { diff --git a/src/main.cpp b/src/main.cpp index e1fdd52..7601629 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 diff --git a/src/od-joy.cpp b/src/od-joy.cpp index 9c73b2d..861ee31 100755 --- a/src/od-joy.cpp +++ b/src/od-joy.cpp @@ -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) @@ -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 @@ -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) diff --git a/src/sdlgfx.cpp b/src/sdlgfx.cpp index a43191a..0e0a7b2 100755 --- a/src/sdlgfx.cpp +++ b/src/sdlgfx.cpp @@ -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" @@ -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(); @@ -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 diff --git a/src/vkbd/vkbd.cpp b/src/vkbd/vkbd.cpp index f9e48ea..e68af24 100755 --- a/src/vkbd/vkbd.cpp +++ b/src/vkbd/vkbd.cpp @@ -4,6 +4,8 @@ #include "vkbd.h" +#define MENU_FILE_BACKGROUND DATA_PREFIX "background.bmp" + #define MIN_VKBD_TIME 100 int vkbd_mode=0; @@ -12,7 +14,7 @@ SDLKey vkbd_key=(SDLKey)0; SDLKey vkbd_button2=(SDLKey)0; int vkbd_keysave=-1234567; -#if !defined (DREAMCAST) && !defined (GP2X) && !defined (PSP) && !defined (GIZMONDO) +#if !defined (DREAMCAST) && !defined (GP2X) && !defined (PSP) && !defined (GIZMONDO) int vkbd_init(void) { return 0; } void vkbd_init_button2(void) { } @@ -140,7 +142,6 @@ static t_vkbd_rect vkbd_rect[]= {{ 80,34,10, 5 },84, 8,90,92, SDLK_RCTRL}, // 91 {{131,34,12, 5 },86,28,91,93, SDLK_KP0}, // 92 {{145,34, 6, 5 },87,29,92,88, SDLK_KP_PERIOD}, // 93 - }; void vkbd_init_button2(void) @@ -148,21 +149,28 @@ void vkbd_init_button2(void) vkbd_button2=(SDLKey)0; } - int vkbd_init(void) { int i; char tmpchar[256]; +#ifdef __PSP2__ +// if (!vkbd_screen) +// { //vkbd_screen=SDL_CreateRGBSurface(prSDLScreen->flags,prSDLScreen->w,prSDLScreen->h,prSDLScreen->format->BitsPerPixel,prSDLScreen->format->Rmask,prSDLScreen->format->Gmask,prSDLScreen->format->Bmask,prSDLScreen->format->Amask); +// } + SDL_Surface *tmp=SDL_LoadBMP(DATA_PREFIX "vkbd.bmp"); +// SDL_Surface *tmp=SDL_LoadBMP("app0:/data/vkbd.bmp"); +#else #ifdef GP2X - snprintf(tmpchar, 256, "%s/data/vkbd.bmp", launchDir); - SDL_Surface *tmp = SDL_LoadBMP(tmpchar); -#else -#ifdef GIZMONDO - SDL_Surface *tmp = SDL_LoadBMP("\\SD Card\\uae4all\\data\\vkbd.bmp"); -#else + snprintf(tmpchar, 256, "%s/data/vkbd.bmp", launchDir); + SDL_Surface *tmp = SDL_LoadBMP(tmpchar); +#else +#ifdef GIZMONDO + SDL_Surface *tmp = SDL_LoadBMP("\\SD Card\\uae4all\\data\\vkbd.bmp"); +#else SDL_Surface *tmp=SDL_LoadBMP(DATA_PREFIX "vkbd.bmp"); -#endif #endif +#endif +#endif //__PSP2__ if (tmp==NULL) { printf("Virtual Keyboard Bitmap Error: %s\n",SDL_GetError()); @@ -174,15 +182,19 @@ int vkbd_init(void) vkey[i]=NULL; for(i=0;iMIN_VKBD_TIME); + #ifndef VKBD_ALWAYS - if (vkbd_move) + if (vkbd_move) #endif - vkbd_redraw(); + vkbd_redraw(); if (vkbd_move&VKBD_BUTTON) { vkbd_move=0; @@ -275,5 +289,4 @@ SDLKey vkbd_process(void) #endif return (SDLKey)0; } - #endif