diff src/events/SDL_keyboard.c @ 2989:aba5a5cc2e63

Make the SDL keysyms that represent unprintable ASCII values actually have those values, for more intuitive use and better compatibility with SDL 1.2.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 04 Jan 2009 17:10:04 +0000
parents 99210400e8b9
children 502adab079a4
line wrap: on
line diff
--- a/src/events/SDL_keyboard.c	Sun Jan 04 17:04:29 2009 +0000
+++ b/src/events/SDL_keyboard.c	Sun Jan 04 17:10:04 2009 +0000
@@ -973,17 +973,32 @@
             SDL_GetScancodeName((SDL_scancode) (key & ~SDLK_SCANCODE_MASK));
     }
 
-    /* Unaccented letter keys on latin keyboards are normally
-       labeled in upper case (and probably on others like Greek or
-       Cyrillic too, so if you happen to know for sure, please
-       adapt this). */
-    if (key >= 'a' && key <= 'z') {
-        key -= 32;
+    switch (key) {
+    case SDLK_RETURN:
+            return SDL_GetScancodeName(SDL_SCANCODE_RETURN);
+    case SDLK_ESCAPE:
+            return SDL_GetScancodeName(SDL_SCANCODE_ESCAPE);
+    case SDLK_BACKSPACE:
+            return SDL_GetScancodeName(SDL_SCANCODE_BACKSPACE);
+    case SDLK_TAB:
+            return SDL_GetScancodeName(SDL_SCANCODE_TAB);
+    case SDLK_SPACE:
+            return SDL_GetScancodeName(SDL_SCANCODE_SPACE);
+    case SDLK_DELETE:
+            return SDL_GetScancodeName(SDL_SCANCODE_DELETE);
+    default:
+        /* Unaccented letter keys on latin keyboards are normally
+           labeled in upper case (and probably on others like Greek or
+           Cyrillic too, so if you happen to know for sure, please
+           adapt this). */
+        if (key >= 'a' && key <= 'z') {
+            key -= 32;
+        }
+
+        end = SDL_UCS4ToUTF8((Uint32) key, name);
+        *end = '\0';
+        return name;
     }
-
-    end = SDL_UCS4ToUTF8((Uint32) key, name);
-    *end = '\0';
-    return name;
 }
 
 /* vi: set ts=4 sw=4 expandtab: */