1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 09:39:43 +01:00

Add buffer for IME editing events

When inputting uncommitted text from an IME, this is now stored in a
std::string imebuffer, just like keybuffer. It also enables extended
editing events, so text longer than what fits in the standard editing
event is also supported. This commit does not yet display the text
onscreen.
This commit is contained in:
Dav999 2024-08-01 19:18:20 +02:00 committed by Misa Elizabeth Kai
parent 345eca5e10
commit a9ca63b367
3 changed files with 14 additions and 2 deletions

View file

@ -50,7 +50,8 @@ KeyPoll::KeyPoll(void)
// 0..5 // 0..5
sensitivity = 2; sensitivity = 2;
keybuffer=""; keybuffer = "";
imebuffer = "";
leftbutton=0; rightbutton=0; middlebutton=0; leftbutton=0; rightbutton=0; middlebutton=0;
mousex = 0; mousex = 0;
mousey = 0; mousey = 0;
@ -64,13 +65,15 @@ KeyPoll::KeyPoll(void)
void KeyPoll::enabletextentry(void) void KeyPoll::enabletextentry(void)
{ {
keybuffer=""; keybuffer = "";
imebuffer = "";
SDL_StartTextInput(); SDL_StartTextInput();
} }
void KeyPoll::disabletextentry(void) void KeyPoll::disabletextentry(void)
{ {
SDL_StopTextInput(); SDL_StopTextInput();
imebuffer = "";
} }
bool KeyPoll::textentry(void) bool KeyPoll::textentry(void)
@ -321,6 +324,13 @@ void KeyPoll::Poll(void)
keybuffer += evt.text.text; keybuffer += evt.text.text;
} }
break; break;
case SDL_TEXTEDITING:
imebuffer = evt.edit.text;
break;
case SDL_TEXTEDITING_EXT:
imebuffer = evt.editExt.text;
SDL_free(evt.editExt.text);
break;
/* Mouse Input */ /* Mouse Input */
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:

View file

@ -69,6 +69,7 @@ public:
bool textentry(void); bool textentry(void);
bool pressedbackspace; bool pressedbackspace;
std::string keybuffer; std::string keybuffer;
std::string imebuffer;
bool linealreadyemptykludge; bool linealreadyemptykludge;

View file

@ -599,6 +599,7 @@ int main(int argc, char *argv[])
} }
SDL_SetHintWithPriority(SDL_HINT_IME_SHOW_UI, "1", SDL_HINT_OVERRIDE); SDL_SetHintWithPriority(SDL_HINT_IME_SHOW_UI, "1", SDL_HINT_OVERRIDE);
SDL_SetHintWithPriority(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, "1", SDL_HINT_OVERRIDE);
/* We already do the button swapping in ButtonGlyphs, disable SDL's swapping */ /* We already do the button swapping in ButtonGlyphs, disable SDL's swapping */
SDL_SetHintWithPriority(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, "0", SDL_HINT_OVERRIDE); SDL_SetHintWithPriority(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, "0", SDL_HINT_OVERRIDE);