WinRT: allow on-screen keyboard to be shown via SDL APIs, Win10/UWP only
authorDavid Ludwig
Sat, 07 May 2016 21:41:59 -0400
changeset 101630f89301aae00
parent 10162 562b819414b5
child 10164 939647e604d1
WinRT: allow on-screen keyboard to be shown via SDL APIs, Win10/UWP only
src/video/winrt/SDL_winrtevents_c.h
src/video/winrt/SDL_winrtkeyboard.cpp
src/video/winrt/SDL_winrtvideo.cpp
     1.1 --- a/src/video/winrt/SDL_winrtevents_c.h	Thu May 05 22:05:21 2016 +0200
     1.2 +++ b/src/video/winrt/SDL_winrtevents_c.h	Sat May 07 21:41:59 2016 -0400
     1.3 @@ -67,6 +67,13 @@
     1.4  extern void WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^args);
     1.5  extern void WINRT_ProcessCharacterReceivedEvent(Windows::UI::Core::CharacterReceivedEventArgs ^args);
     1.6  
     1.7 +#if NTDDI_VERSION >= NTDDI_WIN10
     1.8 +extern SDL_bool WINRT_HasScreenKeyboardSupport(_THIS);
     1.9 +extern void WINRT_ShowScreenKeyboard(_THIS, SDL_Window *window);
    1.10 +extern void WINRT_HideScreenKeyboard(_THIS, SDL_Window *window);
    1.11 +extern SDL_bool WINRT_IsScreenKeyboardShown(_THIS, SDL_Window *window);
    1.12 +#endif  // NTDDI_VERSION >= ...
    1.13 +
    1.14  /* XAML Thread Management */
    1.15  extern void WINRT_CycleXAMLThread();
    1.16  
     2.1 --- a/src/video/winrt/SDL_winrtkeyboard.cpp	Thu May 05 22:05:21 2016 +0200
     2.2 +++ b/src/video/winrt/SDL_winrtkeyboard.cpp	Sat May 07 21:41:59 2016 -0400
     2.3 @@ -383,4 +383,48 @@
     2.4      }
     2.5  }
     2.6  
     2.7 +
     2.8 +#if NTDDI_VERSION >= NTDDI_WIN10
     2.9 +
    2.10 +SDL_bool WINRT_HasScreenKeyboardSupport(_THIS)
    2.11 +{
    2.12 +    return SDL_TRUE;
    2.13 +}
    2.14 +
    2.15 +void WINRT_ShowScreenKeyboard(_THIS, SDL_Window *window)
    2.16 +{
    2.17 +    using namespace Windows::UI::ViewManagement;
    2.18 +    InputPane ^ inputPane = InputPane::GetForCurrentView();
    2.19 +    if (inputPane) {
    2.20 +        inputPane->TryShow();
    2.21 +    }
    2.22 +}
    2.23 +
    2.24 +void WINRT_HideScreenKeyboard(_THIS, SDL_Window *window)
    2.25 +{
    2.26 +    using namespace Windows::UI::ViewManagement;
    2.27 +    InputPane ^ inputPane = InputPane::GetForCurrentView();
    2.28 +    if (inputPane) {
    2.29 +        inputPane->TryHide();
    2.30 +    }
    2.31 +}
    2.32 +
    2.33 +SDL_bool WINRT_IsScreenKeyboardShown(_THIS, SDL_Window *window)
    2.34 +{
    2.35 +    using namespace Windows::UI::ViewManagement;
    2.36 +    InputPane ^ inputPane = InputPane::GetForCurrentView();
    2.37 +    if (inputPane) {
    2.38 +        // dludwig@pobox.com: checking inputPane->Visible doesn't seem to detect visibility,
    2.39 +        //   at least not on the Windows Phone 10.0.10240.0 emulator.  Checking
    2.40 +        //   the size of inputPane->OccludedRect, however, does seem to work.
    2.41 +        Windows::Foundation::Rect rect = inputPane->OccludedRect;
    2.42 +        if (rect.Width > 0 && rect.Height > 0) {
    2.43 +            return SDL_TRUE;
    2.44 +        }
    2.45 +    }
    2.46 +    return SDL_FALSE;
    2.47 +}
    2.48 +
    2.49 +#endif  // NTDDI_VERSION >= ...
    2.50 +
    2.51  #endif // SDL_VIDEO_DRIVER_WINRT
     3.1 --- a/src/video/winrt/SDL_winrtvideo.cpp	Thu May 05 22:05:21 2016 +0200
     3.2 +++ b/src/video/winrt/SDL_winrtvideo.cpp	Sat May 07 21:41:59 2016 -0400
     3.3 @@ -140,6 +140,14 @@
     3.4      device->SetDisplayMode = WINRT_SetDisplayMode;
     3.5      device->PumpEvents = WINRT_PumpEvents;
     3.6      device->GetWindowWMInfo = WINRT_GetWindowWMInfo;
     3.7 +
     3.8 +#if NTDDI_VERSION >= NTDDI_WIN10
     3.9 +    device->HasScreenKeyboardSupport = WINRT_HasScreenKeyboardSupport;
    3.10 +    device->ShowScreenKeyboard = WINRT_ShowScreenKeyboard;
    3.11 +    device->HideScreenKeyboard = WINRT_HideScreenKeyboard;
    3.12 +    device->IsScreenKeyboardShown = WINRT_IsScreenKeyboardShown;
    3.13 +#endif
    3.14 +
    3.15  #ifdef SDL_VIDEO_OPENGL_EGL
    3.16      device->GL_LoadLibrary = WINRT_GLES_LoadLibrary;
    3.17      device->GL_GetProcAddress = WINRT_GLES_GetProcAddress;