diff --git a/Readme.txt b/Readme.txt index d1ab815..d01d9ec 100755 --- a/Readme.txt +++ b/Readme.txt @@ -49,6 +49,7 @@ VITA-EXCLUSIVE FEATURES: - Additional emulator settings: sprite-sprite collisions can be enabled, blitter settings can be changed - Adjustable stereo separation - Bluetooth keyboard and mouse support +- Sticky virtual keyboard modifiers: allows keyboard combos like CTRL-C to be entered easily NOTES: @@ -92,8 +93,11 @@ Dpad = Amiga joystick directions When custom controls are off: L/R shoulder buttons = Mousebuttons -Square = Joystick button autofire (can be customized) -X = Joystick button (can be customized) +(Shown below are control presets 1 (default) / 2 / 3 / 4) +Square = Autofire (default) / Fire / Autofire / Fire +Cross = Fire (default) / Autofire / Up (Jump) / Up (Jump) +Triangle = Space (default) / Space / Fire / Autofire +Circle = Secondary Fire (used only in a few games) R+Square = Ctrl R+Circle = Left Alt R+Cross = Help @@ -108,10 +112,16 @@ Virtual keyboard controls: Start = Toggle virtual keyboard Right analog stick up/down = Move virtual keyboard up and down Right analog stick left/right = Change virtual keyboard transparency +Cross = Press selected key Square = Backspace -Triangle = Toggle Shift +Triangle = Toggle shift +Circle = Turn off all sticky keys (ctrl, alt, amiga, and shift) CHANGELOG: +1.57 + +- Sticky virtual keyboard keys implemented. The alt, ctrl, amiga, and shift virtual keyboard keys are now sticky. Press them once to enable and another time to let go of the key. Key combos like "Amiga-Q" can now be entered using the virtual keyboard. The circle button quickly un-sticks all keys. + 1.56 - fix keys being pressed when pressing Vita buttons (introduced in 1.55) diff --git a/src/gui.cpp b/src/gui.cpp index 39f3d5e..f215616 100755 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -160,10 +160,10 @@ int dpadUp[4]={0,0,0,0}; int dpadDown[4]={0,0,0,0}; int dpadLeft[4]={0,0,0,0}; int dpadRight[4]={0,0,0,0}; -int buttonA[4]={0,0,0,0}; -int buttonB[4]={0,0,0,0}; -int buttonX[4]={0,0,0,0}; -int buttonY[4]={0,0,0,0}; +int buttonA[4]={0,0,0,0}; // Vita Square, GP2X_BUTTON_B +int buttonB[4]={0,0,0,0}; // Vita Circle, GP2X_BUTTON_A +int buttonX[4]={0,0,0,0}; // Vita Cross, GP2X_BUTTON_X +int buttonY[4]={0,0,0,0}; // Vita Triangle, GP2X_BUTTON_Y int triggerL[4]={0,0,0,0}; int triggerR[4]={0,0,0,0}; int buttonSelect[4]={0,0,0,0}; @@ -432,7 +432,7 @@ static void goMenu(void) } if(gp2xButtonRemappingOn) togglemouse(); - uae_reset (); + uae_reset (); } check_all_prefs(); gui_purge_events(); @@ -1188,7 +1188,7 @@ if(!vkbd_mode) { for (int i=0; i= 0) { - vkbd_keysave=vkbd_key; // remember which key we are pressing so we can release it later - if (vkbd_keysave >= 0) + // Handle all sticky keys (release and press) here up front + bool sticky=false; + for (int i=0; i= 0) //turn off shift together with any other key release if it was on + if (vkbd_keysave >= 0) //handle key release { - if (uae4all_keystate[AK_LSH] == 1) - { - uae4all_keystate[AK_LSH]=0; - record_key((AK_LSH<<1)|1); - } uae4all_keystate[vkbd_keysave]=0; record_key((vkbd_keysave << 1) | 1); } - vkbd_keysave=-1234567; + vkbd_keysave=KEYCODE_NOTHING; } #endif } diff --git a/src/main.cpp b/src/main.cpp index 203d9ae..497b3fa 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -57,6 +57,10 @@ extern SDL_Surface *current_screenshot; #include "gp2xutil.h" #endif +#ifdef USE_UAE4ALL_VKBD +#include "vkbd.h" +#endif + #ifdef __PSP2__ //Allow locking PS Button #include @@ -153,6 +157,9 @@ int quit_program = 0; void uae_reset (void) { gui_purge_events(); +#ifdef USE_UAE4ALL_VKBD + vkbd_reset_sticky_keys(); // keyvalues clear on reset, so vkbd must reflect this +#endif black_screen_now(); quit_program = 2; set_special (SPCFLAG_BRK); diff --git a/src/od-joy.cpp b/src/od-joy.cpp index b206053..5219b0d 100755 --- a/src/od-joy.cpp +++ b/src/od-joy.cpp @@ -551,6 +551,12 @@ void read_joystick(int nr, unsigned int *dir, int *button) buttonA[0] = 0; *button = 0; } + else if (buttonB[0]) + { + vkbd_move=VKBD_BUTTON_RESET_STICKY; + buttonB[0] = 0; + *button = 0; + } #else // in other cases where those buttons might not be available, use the amiga joystick if (*button || buttonX[0] ) { @@ -559,9 +565,11 @@ void read_joystick(int nr, unsigned int *dir, int *button) *button = 0; } #endif - else //button release, make shift toggle possible again. - { - vkbd_can_switch_shift=1; + else { //button release, pressing sticky keys is possible again. + for (int i=0; iw-ksur->w)/2; vkbd_y=prSDLScreen->h-ksur->h; @@ -666,9 +693,9 @@ int vkbd_init(void) vkbd_move=0; vkbd_last_press_time=0; vkbd_last_move_time=0; - vkbd_key=-1234567; + vkbd_key=KEYCODE_NOTHING; vkbd_button2=(SDLKey)0; - vkbd_keysave=-1234567; + vkbd_keysave=KEYCODE_NOTHING; return 0; } @@ -685,43 +712,80 @@ void vkbd_quit(void) SDL_FreeSurface(ksur); SDL_FreeSurface(ksurHires); vkbd_mode=0; - vkbd_shift=0; + for (int i=0; iw; + r.h=toDraw->h; + SDL_BlitSurface(toDraw,NULL,myCanvas,&r); + +#ifdef LARGEKEYBOARD + // highlight sticky keys that are pressed with a green dot + // do this on a canvas to ensure correct transparency on final blit + Uint32 sticky_key_color=SDL_MapRGB(myCanvas->format, 0, 255, 0); + for (int i=0; iprSDLScreen->h-myCanvas->h) + vkbd_y=prSDLScreen->h-myCanvas->h; - if (vkbd_y>prSDLScreen->h-todraw->h) - vkbd_y=prSDLScreen->h-todraw->h; - - vkbd_x=(prSDLScreen->w-todraw->w)/2; + vkbd_x=(prSDLScreen->w-myCanvas->w)/2; r.x=vkbd_x; r.y=vkbd_y; - r.w=todraw->w; - r.h=todraw->h; - - SDL_BlitSurface(todraw,NULL,prSDLScreen,&r); + r.w=myCanvas->w; + r.h=myCanvas->h; + + SDL_BlitSurface(myCanvas,NULL,prSDLScreen,&r); } void vkbd_transparency_up(void) @@ -746,21 +810,13 @@ void vkbd_transparency_up(void) } if (vkbd_transparency != 255) { - SDL_SetAlpha(ksur, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency); - SDL_SetAlpha(ksurHires, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency); -#ifdef LARGEKEYBOARD - SDL_SetAlpha(ksurShift, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency); - SDL_SetAlpha(ksurShiftHires, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency); -#endif + SDL_SetAlpha(canvas, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency); + SDL_SetAlpha(canvasHires, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency); } else //fully opague { - SDL_SetAlpha(ksur, 0, 255); - SDL_SetAlpha(ksurHires, 0, 255); -#ifdef LARGEKEYBOARD - SDL_SetAlpha(ksurShift, 0, 255); - SDL_SetAlpha(ksurShiftHires, 0, 255); -#endif + SDL_SetAlpha(canvas, 0, 255); + SDL_SetAlpha(canvasHires, 0, 255); } } @@ -786,21 +842,13 @@ void vkbd_transparency_down(void) } if (vkbd_transparency != 255) { - SDL_SetAlpha(ksur, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency); - SDL_SetAlpha(ksurHires, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency); -#ifdef LARGEKEYBOARD - SDL_SetAlpha(ksurShift, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency); - SDL_SetAlpha(ksurShiftHires, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency); -#endif + SDL_SetAlpha(canvas, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency); + SDL_SetAlpha(canvasHires, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency); } else //fully opague { - SDL_SetAlpha(ksur, 0, 255); - SDL_SetAlpha(ksurHires, 0, 255); -#ifdef LARGEKEYBOARD - SDL_SetAlpha(ksurShift, 0, 255); - SDL_SetAlpha(ksurShiftHires, 0, 255); -#endif + SDL_SetAlpha(canvas, 0, 255); + SDL_SetAlpha(canvasHires, 0, 255); } } @@ -836,17 +884,25 @@ int vkbd_process(void) #ifndef LARGEKEYBOARD //the old small keyboard struct contains SDL codes SDL_keysym ks; ks.sym=vkbd_rect[vkbd_actual].key; - return keycode2amiga(&ks); + int amigaKeyCode=keycode2amiga(&ks); #else //the large keyboard struct contains Amiga key codes int amigaKeyCode=vkbd_rect[vkbd_actual].key; - if ((amigaKeyCode == AK_LSH || amigaKeyCode == AK_RSH) && vkbd_can_switch_shift) +#endif + //some keys are sticky + for (int i=0; i #define VKBD_X 20 #define VKBD_Y 200 -#define VKBD_LEFT 1 -#define VKBD_RIGHT 2 -#define VKBD_UP 4 -#define VKBD_DOWN 8 -#define VKBD_BUTTON 16 -#define VKBD_BUTTON_BACKSPACE 32 -#define VKBD_BUTTON_SHIFT 64 +#define VKBD_LEFT 1 +#define VKBD_RIGHT 2 +#define VKBD_UP 4 +#define VKBD_DOWN 8 +#define VKBD_BUTTON 16 +#define VKBD_BUTTON_BACKSPACE 32 +#define VKBD_BUTTON_SHIFT 64 +#define VKBD_BUTTON_RESET_STICKY 128 #define VLBD_BUTTON2 128 +// special return codes for vkbd_process +#define KEYCODE_NOTHING -1234567 +#define KEYCODE_STICKY_RESET -100 + +#define NUM_STICKY 7 // number of sticky keys (shift, alt etc) + int vkbd_init(void); void vkbd_quit(void); void vkbd_redraw(void); @@ -21,12 +30,20 @@ void vkbd_displace_up(void); void vkbd_displace_down(void); void vkbd_transparency_up(void); void vkbd_transparency_down(void); +void vkbd_reset_sticky_keys(void); extern int vkbd_mode; extern int vkbd_move; -extern int vkbd_shift; -extern int vkbd_can_switch_shift; +typedef struct +{ + int code; // amiga-side keycode + bool stuck; // is it currently stuck pressed? + bool can_switch; // de-bounce + unsigned char index; // index in vkbd_rect[] +} t_vkbd_sticky_key; +extern t_vkbd_sticky_key vkbd_sticky_key[NUM_STICKY]; extern int vkbd_key; extern int vkbd_keysave; extern SDLKey vkbd_button2; extern int keymappings[10][3]; +#endif // VKBD_H \ No newline at end of file