浏览代码

If we get a newline character, treat it as SDLK_RETURN

Fixes https://github.com/libsdl-org/SDL/issues/10679
Sam Lantinga 11 月之前
父节点
当前提交
faa404a652
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      src/events/SDL_keyboard.c

+ 6 - 1
src/events/SDL_keyboard.c

@@ -637,7 +637,12 @@ void SDL_SendKeyboardUnicodeKey(Uint64 timestamp, Uint32 ch)
 {
     SDL_Keyboard *keyboard = &SDL_keyboard;
     SDL_Keymod modstate = SDL_KMOD_NONE;
-    SDL_Scancode scancode = SDL_GetKeymapScancode(keyboard->keymap, ch, &modstate);
+    SDL_Scancode scancode;
+
+    if (ch == '\n') {
+        ch = SDLK_RETURN;
+    }
+    scancode = SDL_GetKeymapScancode(keyboard->keymap, ch, &modstate);
 
     // Make sure we have this keycode in our keymap
     if (scancode == SDL_SCANCODE_UNKNOWN && ch < SDLK_SCANCODE_MASK) {