mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 19:38:14 +00:00
Fixed key names when KEYCODE_OPTION_LATIN_LETTERS is enabled
This commit is contained in:
@@ -1010,19 +1010,16 @@ const char *SDL_GetKeyName(SDL_Keycode key)
|
|||||||
// SDL_Keycode is defined as the unshifted key on the keyboard,
|
// SDL_Keycode is defined as the unshifted key on the keyboard,
|
||||||
// but the key name is defined as the letter printed on that key,
|
// but the key name is defined as the letter printed on that key,
|
||||||
// which is usually the shifted capital letter.
|
// which is usually the shifted capital letter.
|
||||||
if (key > 0x7F || (key >= 'a' && key <= 'z')) {
|
if (key >= 'a' && key <= 'z') {
|
||||||
SDL_bool translated = SDL_FALSE;
|
key = 'A' + (key - 'a');
|
||||||
|
} else if (key > 0x7F) {
|
||||||
SDL_Scancode scancode = SDL_GetScancodeFromKey(key, SDL_KMOD_NONE);
|
SDL_Scancode scancode = SDL_GetScancodeFromKey(key, SDL_KMOD_NONE);
|
||||||
if (scancode != SDL_SCANCODE_UNKNOWN) {
|
if (scancode != SDL_SCANCODE_UNKNOWN) {
|
||||||
SDL_Keycode capital = SDL_GetKeyFromScancode(scancode, SDL_KMOD_SHIFT);
|
SDL_Keycode capital = SDL_GetKeyFromScancode(scancode, SDL_KMOD_SHIFT);
|
||||||
if (capital > 0x7F || (capital >= 'A' && capital <= 'Z')) {
|
if (capital > 0x7F || (capital >= 'A' && capital <= 'Z')) {
|
||||||
key = capital;
|
key = capital;
|
||||||
translated = SDL_TRUE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!translated && key >= 'a' && key <= 'z') {
|
|
||||||
key = 'A' + (key - 'a');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
end = SDL_UCS4ToUTF8(key, name);
|
end = SDL_UCS4ToUTF8(key, name);
|
||||||
|
Reference in New Issue
Block a user