src/events/SDL_keyboard.c
changeset 2989 aba5a5cc2e63
parent 2859 99210400e8b9
child 2990 502adab079a4
     1.1 --- a/src/events/SDL_keyboard.c	Sun Jan 04 17:04:29 2009 +0000
     1.2 +++ b/src/events/SDL_keyboard.c	Sun Jan 04 17:10:04 2009 +0000
     1.3 @@ -973,17 +973,32 @@
     1.4              SDL_GetScancodeName((SDL_scancode) (key & ~SDLK_SCANCODE_MASK));
     1.5      }
     1.6  
     1.7 -    /* Unaccented letter keys on latin keyboards are normally
     1.8 -       labeled in upper case (and probably on others like Greek or
     1.9 -       Cyrillic too, so if you happen to know for sure, please
    1.10 -       adapt this). */
    1.11 -    if (key >= 'a' && key <= 'z') {
    1.12 -        key -= 32;
    1.13 +    switch (key) {
    1.14 +    case SDLK_RETURN:
    1.15 +            return SDL_GetScancodeName(SDL_SCANCODE_RETURN);
    1.16 +    case SDLK_ESCAPE:
    1.17 +            return SDL_GetScancodeName(SDL_SCANCODE_ESCAPE);
    1.18 +    case SDLK_BACKSPACE:
    1.19 +            return SDL_GetScancodeName(SDL_SCANCODE_BACKSPACE);
    1.20 +    case SDLK_TAB:
    1.21 +            return SDL_GetScancodeName(SDL_SCANCODE_TAB);
    1.22 +    case SDLK_SPACE:
    1.23 +            return SDL_GetScancodeName(SDL_SCANCODE_SPACE);
    1.24 +    case SDLK_DELETE:
    1.25 +            return SDL_GetScancodeName(SDL_SCANCODE_DELETE);
    1.26 +    default:
    1.27 +        /* Unaccented letter keys on latin keyboards are normally
    1.28 +           labeled in upper case (and probably on others like Greek or
    1.29 +           Cyrillic too, so if you happen to know for sure, please
    1.30 +           adapt this). */
    1.31 +        if (key >= 'a' && key <= 'z') {
    1.32 +            key -= 32;
    1.33 +        }
    1.34 +
    1.35 +        end = SDL_UCS4ToUTF8((Uint32) key, name);
    1.36 +        *end = '\0';
    1.37 +        return name;
    1.38      }
    1.39 -
    1.40 -    end = SDL_UCS4ToUTF8((Uint32) key, name);
    1.41 -    *end = '\0';
    1.42 -    return name;
    1.43  }
    1.44  
    1.45  /* vi: set ts=4 sw=4 expandtab: */