Add Enter Key support to PSVita IME keyboard

This commit is contained in:
Jaylon Gowie 2021-07-25 01:04:51 -05:00 committed by Sam Lantinga
parent 10ec4c8671
commit 5cd37c0a7b
1 changed files with 14 additions and 1 deletions

View File

@ -414,10 +414,17 @@ static void utf16_to_utf8(const uint16_t *src, uint8_t *dst) {
*dst = '\0'; *dst = '\0';
} }
static SDL_bool reset_enter = SDL_FALSE;
void VITA_PumpEvents(_THIS) void VITA_PumpEvents(_THIS)
{ {
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; 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_PollTouch();
VITA_PollKeyboard(); VITA_PollKeyboard();
VITA_PollMouse(); VITA_PollMouse();
@ -435,9 +442,15 @@ void VITA_PumpEvents(_THIS)
// Convert UTF16 to UTF8 // Convert UTF16 to UTF8
utf16_to_utf8(videodata->ime_buffer, utf8_buffer); utf16_to_utf8(videodata->ime_buffer, utf8_buffer);
// send sdl event // Send SDL event
SDL_SendKeyboardText((const char*)utf8_buffer); 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(); sceImeDialogTerm();
videodata->ime_active = SDL_FALSE; videodata->ime_active = SDL_FALSE;