diff --git a/Readme.txt b/Readme.txt index 04a25a8..97d5350 100755 --- a/Readme.txt +++ b/Readme.txt @@ -32,15 +32,14 @@ Files must be named as kick13.rom kick20.rom kick31.rom Vita Controls: -A=square -B=circle -X=cross -Y=triangle - -Vita controls: +square=A +circle=B +cross=X +triangle=Y Select = toggle menu -Start+dpad = move screen +Start+dpad up/down = move screen up down +Start+dpad left/right = change screenmode (to zoom in on games with borders) right analog stick = analog mouse (can switch this to left in menu) left analog stick = acts as amiga joystick diff --git a/src/gp2x/menu/menu_config.cpp b/src/gp2x/menu/menu_config.cpp index 4be2cb3..d8d4b4f 100755 --- a/src/gp2x/menu/menu_config.cpp +++ b/src/gp2x/menu/menu_config.cpp @@ -93,7 +93,9 @@ int visibleAreaWidth = 320; int saveMenu_n_savestate = 0; #ifdef __PSP2__ +int mainMenu_shader = 5; int mainMenu_leftStickMouse = 0; +int mainMenu_deadZone = 100; #endif // The following params in use, but can't be changed with gui @@ -103,10 +105,6 @@ int mainMenu_button2 = GP2X_BUTTON_A; int mainMenu_autofireButton1 = GP2X_BUTTON_B; int mainMenu_jump = -1; -#ifdef __PSP2__ -int mainMenu_shader = 5; -#endif - // The following params not in use, but stored to write them back to the config file int gp2xClockSpeed = -1; int mainMenu_scanlines = 0; @@ -222,6 +220,7 @@ void SetDefaultMenuSettings(int general) #ifdef __PSP2__ mainMenu_shader = 5; mainMenu_leftStickMouse = 0; + mainMenu_deadZone = 100; #endif // The following params can't be changed in gui @@ -810,6 +809,8 @@ int saveconfig(int general) fputs(buffer,f); snprintf((char*)buffer, 255, "leftstickmouse=%d\n",mainMenu_leftStickMouse); fputs(buffer,f); + snprintf((char*)buffer, 255, "deadzone=%d\n",mainMenu_deadZone); + fputs(buffer,f); #endif snprintf((char*)buffer, 255, "showstatus=%d\n",mainMenu_showStatus); fputs(buffer,f); @@ -1110,7 +1111,8 @@ void loadconfig(int general) #endif #ifdef __PSP2__ fscanf(f,"shader=%d\n",&mainMenu_shader); - fscanf(f,"leftstickmouse=%d\n",&mainMenu_leftStickMouse); + fscanf(f,"leftstickmouse=%d\n",&mainMenu_leftStickMouse); + fscanf(f,"deadzone=%d\n",&mainMenu_deadZone); #endif fscanf(f,"showstatus=%d\n",&mainMenu_showStatus); fscanf(f,"mousemultiplier=%d\n",&mainMenu_mouseMultiplier ); diff --git a/src/gp2x/menu/menu_config.h b/src/gp2x/menu/menu_config.h index 086c5c4..13cbf9d 100755 --- a/src/gp2x/menu/menu_config.h +++ b/src/gp2x/menu/menu_config.h @@ -106,4 +106,5 @@ extern char custom_kickrom[256]; #ifdef __PSP2__ extern int mainMenu_leftStickMouse; extern int mainMenu_shader; +extern int mainMenu_deadZone; #endif diff --git a/src/gp2x/menu/menu_misc.cpp b/src/gp2x/menu/menu_misc.cpp index 81a35ce..1db28ba 100755 --- a/src/gp2x/menu/menu_misc.cpp +++ b/src/gp2x/menu/menu_misc.cpp @@ -73,7 +73,11 @@ enum { MENUMISC_STATUSLINE, MENUMISC_MOUSEMULTIPLIER, MENUMISC_STYLUSOFFSET, +#ifdef __PSP2__ + MENUMISC_DEADZONE, +#else MENUMISC_TAPDELAY, +#endif MENUMISC_END }; @@ -371,7 +375,18 @@ static void draw_miscMenu(int c) if ((mainMenu_stylusOffset==16)&&((menuMisc!=MENUMISC_STYLUSOFFSET)||(bb))) write_text_inv(tabstop9,menuLine,text_str_8px); else - write_text(tabstop9,menuLine,text_str_8px); + write_text(tabstop9,menuLine,text_str_8px); +#ifdef __PSP2__ + //Analog Stick Deadzone settings on Vita + //MENUMISC_DEADZONE + menuLine+=2; + write_text(leftMargin,menuLine,"Mouse Deadzone"); + snprintf((char*)cpuSpeed, 8, "%d", mainMenu_deadZone); + if ((menuMisc!=MENUMISC_DEADZONE)||(bb)) + write_text_inv(tabstop3-2,menuLine,cpuSpeed); + else + write_text(tabstop3-2,menuLine,cpuSpeed); +#else // MENUMISC_TAPDELAY menuLine+=2; write_text(leftMargin,menuLine,text_str_tap_delay); @@ -390,7 +405,7 @@ static void draw_miscMenu(int c) write_text_inv(tabstop9,menuLine,text_str_none); else write_text(tabstop9,menuLine,text_str_none); - +#endif menuLine++; write_text(leftMargin,menuLine,text_str_misc_separator); menuLine++; @@ -645,6 +660,36 @@ static int key_miscMenu(int *c) mainMenu_stylusOffset = 0; } break; +#ifdef __PSP2__ + case MENUMISC_DEADZONE: + if (left) + { + if (mainMenu_deadZone <= 0) + mainMenu_deadZone=0; + else if (mainMenu_deadZone >= 2000) + mainMenu_deadZone-=1000; + else if (mainMenu_deadZone >= 200) + mainMenu_deadZone-=100; + else if (mainMenu_deadZone >= 20) + mainMenu_deadZone-=10; + else if (mainMenu_deadZone >= 1) + mainMenu_deadZone-=1; + } + else if (right) + { + if (mainMenu_deadZone >= 10000) + mainMenu_deadZone=10000; + else if (mainMenu_deadZone>=1000) + mainMenu_deadZone+=1000; + else if (mainMenu_deadZone>=100) + mainMenu_deadZone+=100; + else if (mainMenu_deadZone>=10) + mainMenu_deadZone+=10; + else if (mainMenu_deadZone>=0) + mainMenu_deadZone+=1; + } + break; +#else case MENUMISC_TAPDELAY: if (left) { @@ -665,6 +710,7 @@ static int key_miscMenu(int *c) mainMenu_tapDelay = 10; } break; +#endif } } diff --git a/src/gui.cpp b/src/gui.cpp index 6772661..9da3165 100755 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -74,6 +74,45 @@ extern SDL_Surface *prSDLScreen; extern SDL_Joystick *uae4all_joy0, *uae4all_joy1; +#ifdef __PSP2__ +//Predefined quick switch resolutions to select via START+DPAD LEFT/RIGHT +int quickSwitchModeID=8; +struct myRes +{ + int num_lines; + int top_pos; +}; +myRes quickSwitchModes[] = { + {192, 0}, + {200, 0}, + {216, 0}, + {224, 0}, + {240, 0}, + {256, 0}, + {270, 0}, + {192, 14}, + {200, 14}, + {216, 14}, + {224, 14}, + {240, 14}, + {256, 14}, + {270, 14}, +}; +extern int moveY; + +//analog stick values for mouse emulation on Vita +int lAnalogX=0; +int lAnalogY=0; +int rAnalogX=0; +int rAnalogY=0; +int lAnalogXCenter=0; +int lAnalogYCenter=0; +int rAnalogXCenter=0; +int rAnalogYCenter=0; +int haveJoysticksBeenCentered=0; +extern int mainMenu_leftStickMouse; +#endif // __PSP2__ + #ifdef USE_UAE4ALL_VKBD extern int keycode2amiga(SDL_keysym *prKeySym); #endif @@ -105,14 +144,6 @@ int triggerL=0; int triggerR=0; int buttonSelect=0; int buttonStart=0; -#ifdef __PSP2__ -//right analog stick values for mouse emulation on Vita -int lAnalogX=0; -int lAnalogY=0; -int rAnalogX=0; -int rAnalogY=0; -extern int mainMenu_leftStickMouse; -#endif extern int mainMenu_case; #ifdef WITH_TESTMODE @@ -133,7 +164,7 @@ static void getChanges(void) changed_produce_sound=0; changed_gfx_framerate=mainMenu_frameskip; } - + int gui_init (void) { SDL_ShowCursor(SDL_DISABLE); @@ -520,6 +551,18 @@ void gui_handle_events (void) rAnalogX=SDL_JoystickGetAxis(uae4all_joy0, 2); rAnalogY=SDL_JoystickGetAxis(uae4all_joy0, 3); + //Is this the first time this routine is called when the program has just been launched? + //If yes, center the joysticks now + //After that, center the joysticks everytime we open the menu with "select" + if (!haveJoysticksBeenCentered) { + lAnalogXCenter=lAnalogX; + lAnalogYCenter=lAnalogY; + rAnalogXCenter=rAnalogX; + rAnalogYCenter=rAnalogY; + //From now on only center when entering menu + haveJoysticksBeenCentered=1; + } + if (mainMenu_leftStickMouse) { dpadRight = SDL_JoystickGetButton(uae4all_joy0, 9) || (rAnalogX > 1024*10) ? 1 : 0; @@ -529,6 +572,8 @@ 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 { @@ -540,6 +585,8 @@ 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); @@ -552,7 +599,15 @@ void gui_handle_events (void) buttonStart = SDL_JoystickGetButton(uae4all_joy0, PAD_START); if(buttonSelect) + { + //re-center the Joysticks when the user opens the menu + SDL_JoystickUpdate(); + lAnalogXCenter=SDL_JoystickGetAxis(uae4all_joy0, 0); + lAnalogYCenter=SDL_JoystickGetAxis(uae4all_joy0, 1); + rAnalogXCenter=SDL_JoystickGetAxis(uae4all_joy0, 2); + rAnalogYCenter=SDL_JoystickGetAxis(uae4all_joy0, 3); goMenu(); + } #else dpadUp = keystate[SDLK_UP]; dpadDown = keystate[SDLK_DOWN]; @@ -695,18 +750,56 @@ if(!vkbd_mode) //left else if(dpadLeft) { +#ifdef __PSP2__ +// Change zoom: +// quickSwitch resolution presets + if (quickSwitchModeID==0) + { + quickSwitchModeID=sizeof(quickSwitchModes)/sizeof(quickSwitchModes[0])-1; + } + else + { + quickSwitchModeID--; + } + mainMenu_displayedLines = + quickSwitchModes[quickSwitchModeID].num_lines; + moveY = + quickSwitchModes[quickSwitchModeID].top_pos; + getChanges(); + check_all_prefs(); + update_display(); +#else screenWidth -=10; if(screenWidth<200) screenWidth = 200; update_display(); +#endif } //right else if(dpadRight) { +#ifdef __PSP2__ + if (quickSwitchModeID==sizeof(quickSwitchModes)/sizeof(quickSwitchModes[0])-1) + { + quickSwitchModeID=0; + } + else + { + quickSwitchModeID++; + } + mainMenu_displayedLines = + quickSwitchModes[quickSwitchModeID].num_lines; + moveY = + quickSwitchModes[quickSwitchModeID].top_pos; + getChanges(); + check_all_prefs(); + update_display(); +#else screenWidth +=10; if(screenWidth>800) screenWidth = 800; update_display(); +#endif } //1 else if(keystate[SDLK_1]) diff --git a/src/od-joy.cpp b/src/od-joy.cpp index 88a2849..9c73b2d 100755 --- a/src/od-joy.cpp +++ b/src/od-joy.cpp @@ -54,6 +54,7 @@ extern int rAnalogY; extern int lAnalogX; extern int lAnalogY; extern int mainMenu_leftStickMouse; +extern int mainMenu_deadZone; #endif extern char launchDir[300]; @@ -111,7 +112,7 @@ void read_joystick(int nr, unsigned int *dir, int *button) if (((mainMenu_customControls && mainMenu_custom_dpad==2) || gp2xMouseEmuOn)) #else if (((mainMenu_customControls && mainMenu_custom_dpad==2) || gp2xMouseEmuOn || (triggerL && !triggerR && !gp2xButtonRemappingOn))) -#endif __PSP2__ +#endif //__PSP2__ #endif { if (buttonY) @@ -183,10 +184,11 @@ void read_joystick(int nr, unsigned int *dir, int *button) #ifdef __PSP2__ //VITA: always use an analog stick (default: right stick) for mouse pointer movements //here we are using a small deadzone - int analogX; - int analogY; + int analogX=0; + int analogY=0; - if (mainMenu_leftStickMouse) { + if (mainMenu_leftStickMouse) + { analogX=lAnalogX; analogY=lAnalogY; } @@ -195,21 +197,17 @@ void read_joystick(int nr, unsigned int *dir, int *button) analogX=rAnalogX; analogY=rAnalogY; } - - if (analogX<100 && analogX>-100) - { - analogX=0; - } - if (analogY<100 && analogY>-100) + //Deadzone + //max movement is mouseScale. + //that way, when in one of the other mouse modes, + //the Y button to change scale still works + if (!(analogX-mainMenu_deadZone)) { - analogY=0; - } - if (analogX != 0 || analogY != 0 ) - { - //max movement is mouseScale. - //that way, when in one of the other mouse modes, - //the Y button to change scale still works lastmx += (int) (analogX/32769.0f * mouseScale); + newmousecounters=1; + } + if (!(analogY-mainMenu_deadZone)) + { lastmy += (int) (analogY/32769.0f * mouseScale); newmousecounters=1; }