src/video/winrt/SDL_winrtkeyboard.cpp
changeset 9240 dc4ad21d8596
parent 9193 5ca521b8486d
child 9619 b94b6d0bff0f
     1.1 --- a/src/video/winrt/SDL_winrtkeyboard.cpp	Tue Nov 25 22:37:12 2014 +0100
     1.2 +++ b/src/video/winrt/SDL_winrtkeyboard.cpp	Wed Nov 26 21:34:15 2014 -0500
     1.3 @@ -365,4 +365,22 @@
     1.4      SDL_SendKeyboardKey(SDL_RELEASED, sdlScancode);
     1.5  }
     1.6  
     1.7 +void
     1.8 +WINRT_ProcessCharacterReceivedEvent(Windows::UI::Core::CharacterReceivedEventArgs ^args)
     1.9 +{
    1.10 +    wchar_t src_ucs2[2];
    1.11 +    char dest_utf8[16];
    1.12 +    int result;
    1.13 +
    1.14 +    /* Setup src */
    1.15 +    src_ucs2[0] = args->KeyCode;
    1.16 +    src_ucs2[1] = L'\0';
    1.17 +
    1.18 +    /* Convert the text, then send an SDL_TEXTINPUT event. */
    1.19 +    result = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)&src_ucs2, -1, (LPSTR)dest_utf8, sizeof(dest_utf8), NULL, NULL);
    1.20 +    if (result > 0) {
    1.21 +        SDL_SendKeyboardText(dest_utf8);
    1.22 +    }
    1.23 +}
    1.24 +
    1.25  #endif // SDL_VIDEO_DRIVER_WINRT