Implemented text input event for Win32
authorSam Lantinga <slouken@libsdl.org>
Sat, 09 Feb 2008 06:47:46 +0000
changeset 230921591ae7355d
parent 2308 514f7c1651fc
child 2310 2f31ce8f1149
Implemented text input event for Win32
src/video/win32/SDL_win32events.c
     1.1 --- a/src/video/win32/SDL_win32events.c	Fri Feb 08 08:35:49 2008 +0000
     1.2 +++ b/src/video/win32/SDL_win32events.c	Sat Feb 09 06:47:46 2008 +0000
     1.3 @@ -397,6 +397,28 @@
     1.4          }
     1.5          return (0);
     1.6  
     1.7 +    case WM_CHAR:
     1.8 +        {
     1.9 +            char text[4];
    1.10 +
    1.11 +            /* Convert to UTF-8 and send it on... */
    1.12 +            if (wParam <= 0x7F) {
    1.13 +                text[0] = (char) wParam;
    1.14 +                text[1] = '\0';
    1.15 +            } else if (wParam <= 0x7FF) {
    1.16 +                text[0] = 0xC0 | (char) ((wParam >> 6) & 0x1F);
    1.17 +                text[1] = 0x80 | (char) (wParam & 0x3F);
    1.18 +                text[2] = '\0';
    1.19 +            } else {
    1.20 +                text[0] = 0xE0 | (char) ((wParam >> 12) & 0x0F);
    1.21 +                text[1] = 0x80 | (char) ((wParam >> 6) & 0x3F);
    1.22 +                text[2] = 0x80 | (char) (wParam & 0x3F);
    1.23 +                text[3] = '\0';
    1.24 +            }
    1.25 +            SDL_SendKeyboardText(data->videodata->keyboard, text);
    1.26 +        }
    1.27 +        return (0);
    1.28 +
    1.29      case WM_GETMINMAXINFO:
    1.30          {
    1.31              MINMAXINFO *info;