From ce1327f37ad4991ff194e72154942940635fb3cb Mon Sep 17 00:00:00 2001 From: Dav999 Date: Wed, 25 Oct 2023 01:35:00 +0200 Subject: [PATCH] Enable SDL_HINT_IME_SHOW_UI to make typing CJK not guesswork For some reason, the default behavior of SDL and/or Windows(?) (I only tested this on Windows) seems to result in the fact that if any SDL app doesn't account for it, there is no way for Japanese and Chinese speakers to know what they're typing in. How IMEs are supposed to work is that you can type words as sort of WIP versions, and then select out of a list of candidates what the final result should be. The app may display the WIP text and tell the IME where the text field is so that the IME's menu can be displayed around it. But if the app doesn't say where the text field is, then the candidate list can also be displayed at the corner of the screen, which is done in Minecraft. By default, however, SDL apps don't get a candidate list at all, which means you're basically flying blind as to what you're typing in, and you would have to basically open notepad and copy-paste everything from there - unless I'm missing something. This commit sets the SDL_HINT_IME_SHOW_UI hint (added in SDL 2.0.18 apparently), so that the candidate list is at least shown in the corner. We can probably deal with positioning and uncommitted text later. --- desktop_version/src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/desktop_version/src/main.cpp b/desktop_version/src/main.cpp index ac4a488e..f64a4aa7 100644 --- a/desktop_version/src/main.cpp +++ b/desktop_version/src/main.cpp @@ -556,6 +556,8 @@ int main(int argc, char *argv[]) } #endif + SDL_SetHintWithPriority(SDL_HINT_IME_SHOW_UI, "1", SDL_HINT_OVERRIDE); + if(!FILESYSTEM_init(argv[0], baseDir, assetsPath, langDir, fontsDir)) { vlog_error("Unable to initialize filesystem!");