Browse Source

Fixed key names for Thai keyboards

Using the shifted versions of keys for the key names doesn't make any sense on the Thai keyboard. Thai keyboards are QWERTY plus Thai characters, so let's use the ASCII key names.
Sam Lantinga 1 year ago
parent
commit
eac8e858d5
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/events/SDL_keymap.c

+ 5 - 0
src/events/SDL_keymap.c

@@ -1015,6 +1015,11 @@ const char *SDL_GetKeyName(SDL_Keycode key)
         } else if (key > 0x7F) {
             SDL_Scancode scancode = SDL_GetScancodeFromKey(key, SDL_KMOD_NONE);
             if (scancode != SDL_SCANCODE_UNKNOWN) {
+                if (key >= 0x0E00 && key <= 0x0E7F) {
+                    // Thai keyboards are QWERTY plus Thai characters, so let's use the ASCII key names
+                    return SDL_GetScancodeName(scancode);
+                }
+
                 SDL_Keycode capital = SDL_GetKeyFromScancode(scancode, SDL_KMOD_SHIFT);
                 if (capital > 0x7F || (capital >= 'A' && capital <= 'Z')) {
                     key = capital;