https://github.com/libsdl-org/Maelstrom/commit/a5ca33220a9fe116d99d9d8fa1245bcddd733b1c
From a5ca33220a9fe116d99d9d8fa1245bcddd733b1c Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 7 Nov 2011 02:28:45 -0500
Subject: [PATCH] Use the on-screen keyboard on iOS
---
netlogic/game.cpp | 4 ++--
screenlib/SDL_FrameBuf.cpp | 27 +++++++++++++++++++++++++++
screenlib/SDL_FrameBuf.h | 3 +++
3 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/netlogic/game.cpp b/netlogic/game.cpp
index 969b3548..feac9c3a 100644
--- a/netlogic/game.cpp
+++ b/netlogic/game.cpp
@@ -938,7 +938,7 @@ static void DoGameOver(void)
chars_in_handle = SDL_strlen(handle);
while ( screen->PollEvent(&event) ) /* Loop, flushing events */;
- SDL_StartTextInput();
+ screen->EnableTextInput();
while ( label && !done ) {
screen->WaitEvent(&event);
@@ -975,7 +975,7 @@ static void DoGameOver(void)
}
ui->Draw();
}
- SDL_StopTextInput();
+ screen->DisableTextInput();
if (*handle) {
for ( i = 8; i >= which ; --i ) {
diff --git a/screenlib/SDL_FrameBuf.cpp b/screenlib/SDL_FrameBuf.cpp
index 31585805..c922f608 100644
--- a/screenlib/SDL_FrameBuf.cpp
+++ b/screenlib/SDL_FrameBuf.cpp
@@ -122,6 +122,33 @@ FrameBuf::ConvertTouchCoordinates(const SDL_TouchFingerEvent &finger, int *x, in
return true;
}
+#ifdef __IPHONEOS__
+extern "C" {
+ extern int SDL_iPhoneKeyboardHide(SDL_Window * window);
+ extern int SDL_iPhoneKeyboardShow(SDL_Window * window);
+}
+#endif
+
+void
+FrameBuf::EnableTextInput()
+{
+ SDL_StartTextInput();
+
+#ifdef __IPHONEOS__
+ SDL_iPhoneKeyboardShow(window);
+#endif
+}
+
+void
+FrameBuf::DisableTextInput()
+{
+#ifdef __IPHONEOS__
+ SDL_iPhoneKeyboardHide(window);
+#endif
+
+ SDL_StopTextInput();
+}
+
void
FrameBuf:: QueueBlit(int dstx, int dsty, SDL_Texture *src,
int srcx, int srcy, int w, int h, clipval do_clip)
diff --git a/screenlib/SDL_FrameBuf.h b/screenlib/SDL_FrameBuf.h
index 38885c5e..de2afeae 100644
--- a/screenlib/SDL_FrameBuf.h
+++ b/screenlib/SDL_FrameBuf.h
@@ -96,6 +96,9 @@ class FrameBuf : public ErrorBase {
}
bool ConvertTouchCoordinates(const SDL_TouchFingerEvent &finger, int *x, int *y);
+ void EnableTextInput();
+ void DisableTextInput();
+
void ToggleFullScreen(void) {
if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) {
SDL_SetWindowFullscreen(window, SDL_FALSE);