Add Enter Key support to PSVita IME keyboard
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
diff --git a/src/video/vita/SDL_vitavideo.c b/src/video/vita/SDL_vitavideo.c
index 5df0fe1..ec96e86 100644
--- a/src/video/vita/SDL_vitavideo.c
+++ b/src/video/vita/SDL_vitavideo.c
@@ -414,10 +414,17 @@ static void utf16_to_utf8(const uint16_t *src, uint8_t *dst) {
*dst = '\0';
}
+static SDL_bool reset_enter = SDL_FALSE;
void VITA_PumpEvents(_THIS)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
+ // Little fix for adding proper enter key emulation
+ if (reset_enter == SDL_TRUE) {
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RETURN);
+ reset_enter = SDL_FALSE;
+ }
+
VITA_PollTouch();
VITA_PollKeyboard();
VITA_PollMouse();
@@ -435,9 +442,15 @@ void VITA_PumpEvents(_THIS)
// Convert UTF16 to UTF8
utf16_to_utf8(videodata->ime_buffer, utf8_buffer);
- // send sdl event
+ // Send SDL event
SDL_SendKeyboardText((const char*)utf8_buffer);
+ // Send enter key only on enter
+ if (result.button == SCE_IME_DIALOG_BUTTON_ENTER) {
+ SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RETURN);
+ reset_enter = SDL_TRUE;
+ }
+
sceImeDialogTerm();
videodata->ime_active = SDL_FALSE;