浏览代码

Enable text input on video initialization without popping up an on-screen keyboard

Fixes https://github.com/libsdl-org/SDL/issues/8561
Sam Lantinga 1 年之前
父节点
当前提交
4ff3b28273
共有 1 个文件被更改,包括 12 次插入8 次删除
  1. 12 8
      src/video/SDL_video.c

+ 12 - 8
src/video/SDL_video.c

@@ -435,6 +435,7 @@ int SDL_VideoInit(const char *driver_name)
     SDL_bool init_keyboard = SDL_FALSE;
     SDL_bool init_mouse = SDL_FALSE;
     SDL_bool init_touch = SDL_FALSE;
+    const char *hint;
     int i = 0;
 
     /* Check to make sure we don't overwrite '_this' */
@@ -562,16 +563,19 @@ int SDL_VideoInit(const char *driver_name)
         SDL_DisableScreenSaver();
     }
 
-    /* If we don't use a screen keyboard, turn on text input by default,
-       otherwise programs that expect to get text events without enabling
-       UNICODE input won't get any events.
-
-       Actually, come to think of it, you needed to call SDL_EnableUNICODE(1)
-       in SDL 1.2 before you got text input events.  Hmm...
+#if !defined(SDL_VIDEO_DRIVER_N3DS)
+    /* In the initial state we don't want to pop up an on-screen keyboard,
+     * but we do want to allow text input from other mechanisms.
      */
-    if (!SDL_HasScreenKeyboardSupport()) {
-        SDL_StartTextInput();
+    hint = SDL_GetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD);
+    if (!hint) {
+        SDL_SetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD, "0");
+    }
+    SDL_StartTextInput();
+    if (!hint) {
+        SDL_SetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD, NULL);
     }
+#endif /* !SDL_VIDEO_DRIVER_N3DS */
 
     SDL_MousePostInit();