SDL: Fixed key names when KEYCODE_OPTION_LATIN_LETTERS is enabled

From b7aca89466d02ec2da1efc1ba4739cfbe5d6900a Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 5 Aug 2024 09:16:43 -0700
Subject: [PATCH] Fixed key names when KEYCODE_OPTION_LATIN_LETTERS is enabled

---
 src/events/SDL_keymap.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/events/SDL_keymap.c b/src/events/SDL_keymap.c
index 53bd6edd5b0e5..6f9a532d8e5ac 100644
--- a/src/events/SDL_keymap.c
+++ b/src/events/SDL_keymap.c
@@ -1010,19 +1010,16 @@ const char *SDL_GetKeyName(SDL_Keycode key)
         // SDL_Keycode is defined as the unshifted key on the keyboard,
         // but the key name is defined as the letter printed on that key,
         // which is usually the shifted capital letter.
-        if (key > 0x7F || (key >= 'a' && key <= 'z')) {
-            SDL_bool translated = SDL_FALSE;
+        if (key >= 'a' && key <= 'z') {
+            key = 'A' + (key - 'a');
+        } else if (key > 0x7F) {
             SDL_Scancode scancode = SDL_GetScancodeFromKey(key, SDL_KMOD_NONE);
             if (scancode != SDL_SCANCODE_UNKNOWN) {
                 SDL_Keycode capital = SDL_GetKeyFromScancode(scancode, SDL_KMOD_SHIFT);
                 if (capital > 0x7F || (capital >= 'A' && capital <= 'Z')) {
                     key = capital;
-                    translated = SDL_TRUE;
                 }
             }
-            if (!translated && key >= 'a' && key <= 'z') {
-                key = 'A' + (key - 'a');
-            }
         }
 
         end = SDL_UCS4ToUTF8(key, name);