Synchronized the on-screen keyboard state with whether we are accepting text input.
authorSam Lantinga <slouken@libsdl.org>
Sun, 04 Nov 2012 21:53:28 -0800
changeset 6654 2ecfb25be1e2
parent 6653 b73f8ee5f033
child 6655 6a3e741ea70d
Synchronized the on-screen keyboard state with whether we are accepting text input. The functions to show/hide/toggle the on-screen keyboard have been folded into the text input state. Calling SDL_StartTextInput() will automatically show the on-screen keyboard if it's available. Calling SDL_StopTextInput() will automatically hide the on-screen keyboard if it's available. There is a new API function SDL_IsTextInputActive() which will return whether text input is currently active. Text input is disabled by default, you must call SDL_StartTextInput() when you are ready to accept text input. SDL_HasScreenKeyboardSupport() no longer needs to be passed a window. The iPhone-specific on-screen keyboard functions have been removed.
README.iOS
Xcode-iOS/Demos/src/keyboard.c
android-project/src/org/libsdl/app/SDLActivity.java
include/SDL_keyboard.h
include/SDL_system.h
src/core/android/SDL_android.cpp
src/core/android/SDL_android.h
src/events/SDL_events.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/android/SDL_androidkeyboard.c
src/video/android/SDL_androidkeyboard.h
src/video/android/SDL_androidvideo.c
src/video/android/SDL_androidwindow.c
src/video/uikit/SDL_uikitvideo.m
src/video/uikit/SDL_uikitview.h
src/video/uikit/SDL_uikitview.m
test/checkkeys.c
--- a/README.iOS	Sun Nov 04 20:20:53 2012 -0800
+++ b/README.iOS	Sun Nov 04 21:53:28 2012 -0800
@@ -80,14 +80,12 @@
 
 The SDL keyboard API has been extended to support on-screen keyboards:
 
-int SDL_ShowScreenKeyboard(SDL_Window * window) 
-	-- reveals the onscreen keyboard.  Returns 0 on success and -1 on error.
-int SDL_HideScreenKeyboard(SDL_Window * window) 
-	-- hides the onscreen keyboard.  Returns 0 on success and -1 on error.
-SDL_bool SDL_IsScreenKeyboardShown(SDL_Window * window) 
-	-- returns whether or not the onscreen keyboard is currently visible.
-int SDL_ToggleScreenKeyboard(SDL_Window * window) 	
-	-- toggles the visibility of the onscreen keyboard.  Returns 0 on success and -1 on error.
+void SDL_StartTextInput()
+	-- enables text events and reveals the onscreen keyboard.
+void SDL_StopTextInput()
+	-- disables text events and hides the onscreen keyboard.
+SDL_bool SDL_IsTextInputActive()
+	-- returns whether or not text events are enabled (and the onscreen keyboard is visible)
 
 ==============================================================================
 Notes -- Reading and Writing files
--- a/Xcode-iOS/Demos/src/keyboard.c	Sun Nov 04 20:20:53 2012 -0800
+++ b/Xcode-iOS/Demos/src/keyboard.c	Sun Nov 04 21:53:28 2012 -0800
@@ -291,7 +291,11 @@
             break;
         case SDL_MOUSEBUTTONUP:
             /*      mouse up toggles onscreen keyboard visibility */
-            SDL_ToggleScreenKeyboard(window);
+            if (SDL_IsTextInputActive()) {
+                SDL_StopTextInput();
+            } else {
+                SDL_StartTextInput();
+            }
             break;
         }
     }
--- a/android-project/src/org/libsdl/app/SDLActivity.java	Sun Nov 04 20:20:53 2012 -0800
+++ b/android-project/src/org/libsdl/app/SDLActivity.java	Sun Nov 04 21:53:28 2012 -0800
@@ -119,7 +119,7 @@
 
     // Messages from the SDLMain thread
     static final int COMMAND_CHANGE_TITLE = 1;
-    static final int COMMAND_KEYBOARD_SHOW = 2;
+    static final int COMMAND_UNUSED = 2;
     static final int COMMAND_TEXTEDIT_HIDE = 3;
 
     // Handler for the messages
@@ -130,22 +130,6 @@
             case COMMAND_CHANGE_TITLE:
                 setTitle((String)msg.obj);
                 break;
-            case COMMAND_KEYBOARD_SHOW:
-                InputMethodManager manager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
-                if (manager != null) {
-                    switch (((Integer)msg.obj).intValue()) {
-                    case 0:
-                        manager.hideSoftInputFromWindow(mSurface.getWindowToken(), 0);
-                        break;
-                    case 1:
-                        manager.showSoftInput(mSurface, 0);
-                        break;
-                    case 2:
-                        manager.toggleSoftInputFromWindow(mSurface.getWindowToken(), 0, 0);
-                        break;
-                    }
-                }
-               break;
             case COMMAND_TEXTEDIT_HIDE:
                 if (mTextEdit != null) {
                     mTextEdit.setVisibility(View.GONE);
--- a/include/SDL_keyboard.h	Sun Nov 04 20:20:53 2012 -0800
+++ b/include/SDL_keyboard.h	Sun Nov 04 21:53:28 2012 -0800
@@ -151,21 +151,34 @@
 
 /**
  *  \brief Start accepting Unicode text input events.
+ *         This function will show the on-screen keyboard if supported.
  *  
  *  \sa SDL_StopTextInput()
  *  \sa SDL_SetTextInputRect()
+ *  \sa SDL_HasScreenKeyboardSupport()
  */
 extern DECLSPEC void SDLCALL SDL_StartTextInput(void);
 
 /**
+ *  \brief Return whether or not Unicode text input events are enabled.
+ *
+ *  \sa SDL_StartTextInput()
+ *  \sa SDL_StopTextInput()
+ */
+extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void);
+
+/**
  *  \brief Stop receiving any text input events.
+ *         This function will hide the on-screen keyboard if supported.
  *  
  *  \sa SDL_StartTextInput()
+ *  \sa SDL_HasScreenKeyboardSupport()
  */
 extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
 
 /**
  *  \brief Set the rectangle used to type Unicode text inputs.
+ *         This is used as a hint for IME and on-screen keyboard placement.
  *  
  *  \sa SDL_StartTextInput()
  */
@@ -174,60 +187,13 @@
 /**
  *  \brief Returns whether the platform has some screen keyboard support.
  *  
- *  \param window The window for which screen keyboard should be checked.
- *  
  *  \return SDL_TRUE if some keyboard support is available else SDL_FALSE.
  *  
  *  \note Not all screen keyboard functions are supported on all platforms.
  *  
- *  \sa SDL_ShowScreenKeyboard()
- *  \sa SDL_HideScreenKeyboard()
- *  \sa SDL_IsScreenKeyboardShown()
- *  \sa SDL_ToggleScreenKeyboard()
- */
-extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(SDL_Window *window);
-
-/**
- *  \brief Requests to show a screen keyboard for given window.
- *  
- *  \param window The window for which screen keyboard should be shown.
- *  
- *  \return 0 if request will be processed or -1 on error (e.g. no support).
- *  
- *  \note Showing screen keyboards is asynchronous on some platforms.
- *  
- *  \sa SDL_HasScreenKeyboardSupport()
- *  \sa SDL_HideScreenKeyboard()
- */
-extern DECLSPEC int SDLCALL SDL_ShowScreenKeyboard(SDL_Window *window);
-
-/**
- *  \brief Requests to hide a screen keyboard for given window.
- *  
- *  \param window The window for which screen keyboard should be shown.
- *  
- *  \return 0 if request will be processed or -1 on error (e.g. no support).
- *  
- *  \note Hiding screen keyboards is asynchronous on some platforms.
- *  
- *  \sa SDL_HasScreenKeyboardSupport()
- *  \sa SDL_ShowScreenKeyboard()
- */
-extern DECLSPEC int SDLCALL SDL_HideScreenKeyboard(SDL_Window *window);
-
-/**
- *  \brief Requests to toggle a screen keyboard for given window.
- *  
- *  \param window The window for which screen keyboard should be toggled.
- *  
- *  \return 0 if request will be processed or -1 on error (e.g. no support).
- *  
- *  \note Showing and hiding screen keyboards is asynchronous on some platforms.
- *  
- *  \sa SDL_HasScreenKeyboardSupport()
  *  \sa SDL_IsScreenKeyboardShown()
  */
-extern DECLSPEC int SDLCALL SDL_ToggleScreenKeyboard(SDL_Window * window);
+extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport();
 
 /**
  *  \brief Returns whether the screen keyboard is shown for given window.
@@ -236,11 +202,7 @@
  *  
  *  \return SDL_TRUE if screen keyboard is shown else SDL_FALSE.
  *  
- *  \note May always return SDL_FALSE on some platforms (not implemented there).
- *  
  *  \sa SDL_HasScreenKeyboardSupport()
- *  \sa SDL_ShowScreenKeyboard()
- *  \sa SDL_HideScreenKeyboard()
  */
 extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window);
 
--- a/include/SDL_system.h	Sun Nov 04 20:20:53 2012 -0800
+++ b/include/SDL_system.h	Sun Nov 04 21:53:28 2012 -0800
@@ -49,11 +49,6 @@
 extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
 extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
 
-#define SDL_iPhoneKeyboardShow  SDL_ShowScreenKeyboard
-#define SDL_iPhoneKeyboardHide  SDL_HideScreenKeyboard
-#define SDL_iPhoneKeyboardToggle    SDL_ToggleScreenKeyboard
-#define SDL_iPhoneKeyboardIsShown   SDL_IsScreenKeyboardShown
-
 #endif /* __IPHONEOS__ */
 
 
--- a/src/core/android/SDL_android.cpp	Sun Nov 04 20:20:53 2012 -0800
+++ b/src/core/android/SDL_android.cpp	Sun Nov 04 21:53:28 2012 -0800
@@ -957,39 +957,30 @@
     return 0;
 }
 
-extern "C" int Android_JNI_ShowTextInput(SDL_Rect *inputRect)
+extern "C" void Android_JNI_ShowTextInput(SDL_Rect *inputRect)
 {
     JNIEnv *env = Android_JNI_GetEnv();
     if (!env) {
-        return -1;
+        return;
     }
 
     jmethodID mid = env->GetStaticMethodID(mActivityClass, "showTextInput", "(IIII)V");
     if (!mid) {
-        return -1;
+        return;
     }
     env->CallStaticVoidMethod( mActivityClass, mid,
                                inputRect->x,
                                inputRect->y,
                                inputRect->w,
                                inputRect->h );
-    return 0;
 }
 
-/*extern "C" int Android_JNI_HideTextInput()
+extern "C" void Android_JNI_HideTextInput()
 {
-    JNIEnv *env = Android_JNI_GetEnv();
-    if (!env) {
-        return -1;
-    }
-
-    jmethodID mid = env->GetStaticMethodID(mActivityClass, "hideTextInput", "()V");
-    if (!mid) {
-        return -1;
-    }
-    env->CallStaticVoidMethod(mActivityClass, mid);
-    return 0;
-}*/
+    // has to match Activity constant
+    const int COMMAND_TEXTEDIT_HIDE = 3;
+    Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0);
+}
 
 //////////////////////////////////////////////////////////////////////////////
 //
--- a/src/core/android/SDL_android.h	Sun Nov 04 20:20:53 2012 -0800
+++ b/src/core/android/SDL_android.h	Sun Nov 04 21:53:28 2012 -0800
@@ -34,7 +34,8 @@
 extern void Android_JNI_SwapWindow();
 extern void Android_JNI_SetActivityTitle(const char *title);
 extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]);
-extern int Android_JNI_ShowTextInput(SDL_Rect *inputRect);
+extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect);
+extern void Android_JNI_HideTextInput();
 
 // Audio support
 extern int Android_JNI_OpenAudioDevice(int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames);
--- a/src/events/SDL_events.c	Sun Nov 04 20:20:53 2012 -0800
+++ b/src/events/SDL_events.c	Sun Nov 04 21:53:28 2012 -0800
@@ -125,6 +125,8 @@
 
     /* No filter to start with, process most event types */
     SDL_EventOK = NULL;
+    SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE);
+    SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE);
     SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
 
     /* Create the lock and set ourselves active */
--- a/src/video/SDL_sysvideo.h	Sun Nov 04 20:20:53 2012 -0800
+++ b/src/video/SDL_sysvideo.h	Sun Nov 04 21:53:28 2012 -0800
@@ -236,10 +236,9 @@
     void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
 
     /* Screen keyboard */
-    SDL_bool (*SDL_HasScreenKeyboardSupport) (_THIS, SDL_Window *window);
-    int (*SDL_ShowScreenKeyboard) (_THIS, SDL_Window *window);
-    int (*SDL_HideScreenKeyboard) (_THIS, SDL_Window *window);
-    int (*SDL_ToggleScreenKeyboard) (_THIS, SDL_Window *window);
+    SDL_bool (*SDL_HasScreenKeyboardSupport) (_THIS);
+    void (*SDL_ShowScreenKeyboard) (_THIS, SDL_Window *window);
+    void (*SDL_HideScreenKeyboard) (_THIS, SDL_Window *window);
     SDL_bool (*SDL_IsScreenKeyboardShown) (_THIS, SDL_Window *window);
 
     /* Clipboard */
--- a/src/video/SDL_video.c	Sun Nov 04 20:20:53 2012 -0800
+++ b/src/video/SDL_video.c	Sun Nov 04 21:53:28 2012 -0800
@@ -2771,19 +2771,47 @@
 void
 SDL_StartTextInput(void)
 {
+    SDL_Window *window;
+
+    /* First, enable text events */
+    SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE);
+    SDL_EventState(SDL_TEXTEDITING, SDL_ENABLE);
+
+    /* Then show the on-screen keyboard, if any */
+    window = SDL_GetFocusWindow();
+    if (window && _this && _this->SDL_ShowScreenKeyboard) {
+        _this->SDL_ShowScreenKeyboard(_this, window);
+    }
+
+    /* Finally start the text input system */
     if (_this && _this->StartTextInput) {
         _this->StartTextInput(_this);
     }
-    SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE);
-    SDL_EventState(SDL_TEXTEDITING, SDL_ENABLE);
+}
+
+SDL_bool
+SDL_IsTextInputActive(void)
+{
+    return (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE);
 }
 
 void
 SDL_StopTextInput(void)
 {
+    SDL_Window *window;
+
+    /* Stop the text input system */
     if (_this && _this->StopTextInput) {
         _this->StopTextInput(_this);
     }
+
+    /* Hide the on-screen keyboard, if any */
+    window = SDL_GetFocusWindow();
+    if (window && _this && _this->SDL_HideScreenKeyboard) {
+        _this->SDL_HideScreenKeyboard(_this, window);
+    }
+
+    /* Finally disable text events */
     SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE);
     SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE);
 }
@@ -2797,41 +2825,14 @@
 }
 
 SDL_bool
-SDL_HasScreenKeyboardSupport(SDL_Window *window)
+SDL_HasScreenKeyboardSupport(void)
 {
-    if (window && _this && _this->SDL_HasScreenKeyboardSupport) {
-        return _this->SDL_HasScreenKeyboardSupport(_this, window);
+    if (_this && _this->SDL_HasScreenKeyboardSupport) {
+        return _this->SDL_HasScreenKeyboardSupport(_this);
     }
     return SDL_FALSE;
 }
 
-int
-SDL_ShowScreenKeyboard(SDL_Window *window)
-{
-    if (window && _this && _this->SDL_ShowScreenKeyboard) {
-        return _this->SDL_ShowScreenKeyboard(_this, window);
-    }
-    return -1;
-}
-
-int
-SDL_HideScreenKeyboard(SDL_Window *window)
-{
-    if (window && _this && _this->SDL_HideScreenKeyboard) {
-        return _this->SDL_HideScreenKeyboard(_this, window);
-    }
-    return -1;
-}
-
-int
-SDL_ToggleScreenKeyboard(SDL_Window *window)
-{
-    if (window && _this && _this->SDL_ToggleScreenKeyboard) {
-        return _this->SDL_ToggleScreenKeyboard(_this, window);
-    }
-    return -1;
-}
-
 SDL_bool
 SDL_IsScreenKeyboardShown(SDL_Window *window)
 {
--- a/src/video/android/SDL_androidkeyboard.c	Sun Nov 04 20:20:53 2012 -0800
+++ b/src/video/android/SDL_androidkeyboard.c	Sun Nov 04 21:53:28 2012 -0800
@@ -287,37 +287,16 @@
     return SDL_SendKeyboardKey(SDL_RELEASED, TranslateKeycode(keycode));
 }
 
-// has to fit Activity constant
-#define COMMAND_KEYBOARD_SHOW 2
-
 SDL_bool
-Android_HasScreenKeyboardSupport(_THIS, SDL_Window * window)
-{
-    return Android_Window ? SDL_TRUE : SDL_FALSE;
-}
-
-int
-Android_ShowScreenKeyboard(_THIS, SDL_Window * window)
+Android_HasScreenKeyboardSupport(_THIS)
 {
-    return Android_Window ? Android_JNI_SendMessage(COMMAND_KEYBOARD_SHOW, 1) : -1;
-}
-
-int
-Android_HideScreenKeyboard(_THIS, SDL_Window * window)
-{
-    return Android_Window ? Android_JNI_SendMessage(COMMAND_KEYBOARD_SHOW, 0) : -1;
-}
-
-int
-Android_ToggleScreenKeyboard(_THIS, SDL_Window * window)
-{
-    return Android_Window ? Android_JNI_SendMessage(COMMAND_KEYBOARD_SHOW, 2) : -1;
+    return SDL_TRUE;
 }
 
 SDL_bool
 Android_IsScreenKeyboardShown(_THIS, SDL_Window * window)
 {
-    return SDL_FALSE;
+    return SDL_IsTextInputActive();
 }
 
 void
@@ -327,11 +306,10 @@
     Android_JNI_ShowTextInput(&videodata->textRect);
 }
 
-#define COMMAND_TEXTEDIT_HIDE 3
 void
 Android_StopTextInput(_THIS)
 {
-    Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0);
+    Android_JNI_HideTextInput();
 }
 
 void
--- a/src/video/android/SDL_androidkeyboard.h	Sun Nov 04 20:20:53 2012 -0800
+++ b/src/video/android/SDL_androidkeyboard.h	Sun Nov 04 21:53:28 2012 -0800
@@ -26,10 +26,7 @@
 extern int Android_OnKeyDown(int keycode);
 extern int Android_OnKeyUp(int keycode);
 
-extern SDL_bool Android_HasScreenKeyboardSupport(_THIS, SDL_Window * window);
-extern int Android_ShowScreenKeyboard(_THIS, SDL_Window * window);
-extern int Android_HideScreenKeyboard(_THIS, SDL_Window * window);
-extern int Android_ToggleScreenKeyboard(_THIS, SDL_Window * window);
+extern SDL_bool Android_HasScreenKeyboardSupport(_THIS);
 extern SDL_bool Android_IsScreenKeyboardShown(_THIS, SDL_Window * window);
 
 extern void Android_StartTextInput(_THIS);
--- a/src/video/android/SDL_androidvideo.c	Sun Nov 04 20:20:53 2012 -0800
+++ b/src/video/android/SDL_androidvideo.c	Sun Nov 04 21:53:28 2012 -0800
@@ -127,11 +127,13 @@
     device->GL_SwapWindow = Android_GL_SwapWindow;
     device->GL_DeleteContext = Android_GL_DeleteContext;
 
+    /* Text input */
+    device->StartTextInput = Android_StartTextInput;
+    device->StopTextInput = Android_StopTextInput;
+    device->SetTextInputRect = Android_SetTextInputRect;
+
     /* Screen keyboard */
     device->SDL_HasScreenKeyboardSupport = Android_HasScreenKeyboardSupport;
-    device->SDL_ShowScreenKeyboard = Android_ShowScreenKeyboard;
-    device->SDL_HideScreenKeyboard = Android_HideScreenKeyboard;
-    device->SDL_ToggleScreenKeyboard = Android_ToggleScreenKeyboard;
     device->SDL_IsScreenKeyboardShown = Android_IsScreenKeyboardShown;
 
     /* Clipboard */
@@ -139,11 +141,6 @@
     device->GetClipboardText = Android_GetClipboardText;
     device->HasClipboardText = Android_HasClipboardText;
 
-    /* Text input */
-    device->StartTextInput = Android_StartTextInput;
-    device->StopTextInput = Android_StopTextInput;
-    device->SetTextInputRect = Android_SetTextInputRect;
-
     return device;
 }
 
--- a/src/video/android/SDL_androidwindow.c	Sun Nov 04 20:20:53 2012 -0800
+++ b/src/video/android/SDL_androidwindow.c	Sun Nov 04 21:53:28 2012 -0800
@@ -52,7 +52,7 @@
 
     /* One window, it always has focus */
     SDL_SetMouseFocus(window);
-    //SDL_SetKeyboardFocus(window);
+    SDL_SetKeyboardFocus(window);
 
     return 0;
 }
--- a/src/video/uikit/SDL_uikitvideo.m	Sun Nov 04 20:20:53 2012 -0800
+++ b/src/video/uikit/SDL_uikitvideo.m	Sun Nov 04 21:53:28 2012 -0800
@@ -89,7 +89,6 @@
     device->SDL_HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport;
     device->SDL_ShowScreenKeyboard = UIKit_ShowScreenKeyboard;
     device->SDL_HideScreenKeyboard = UIKit_HideScreenKeyboard;
-    device->SDL_ToggleScreenKeyboard = UIKit_ToggleScreenKeyboard;
     device->SDL_IsScreenKeyboardShown = UIKit_IsScreenKeyboardShown;
 
     /* OpenGL (ES) functions */
--- a/src/video/uikit/SDL_uikitview.h	Sun Nov 04 20:20:53 2012 -0800
+++ b/src/video/uikit/SDL_uikitview.h	Sun Nov 04 21:53:28 2012 -0800
@@ -61,10 +61,9 @@
 - (void)initializeKeyboard;
 @property (readonly) BOOL keyboardVisible;
 
-SDL_bool UIKit_HasScreenKeyboardSupport(_THIS, SDL_Window *window);
-int UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window);
-int UIKit_HideScreenKeyboard(_THIS, SDL_Window *window);
-int UIKit_ToggleScreenKeyboard(_THIS, SDL_Window *window);
+SDL_bool UIKit_HasScreenKeyboardSupport(_THIS);
+void UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window);
+void UIKit_HideScreenKeyboard(_THIS, SDL_Window *window);
 SDL_bool UIKit_IsScreenKeyboardShown(_THIS, SDL_Window *window);
 
 #endif
--- a/src/video/uikit/SDL_uikitview.m	Sun Nov 04 20:20:53 2012 -0800
+++ b/src/video/uikit/SDL_uikitview.m	Sun Nov 04 21:53:28 2012 -0800
@@ -313,7 +313,7 @@
 {
     SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RETURN);
     SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RETURN);
-    [self hideKeyboard];
+    SDL_StopTextInput();
     return YES;
 }
 
@@ -341,36 +341,25 @@
     return view;
 }
 
-SDL_bool UIKit_HasScreenKeyboardSupport(_THIS, SDL_Window *window)
+SDL_bool UIKit_HasScreenKeyboardSupport(_THIS)
 {
-    SDL_uikitview *view = getWindowView(window);
-    if (view == nil) {
-        return SDL_FALSE;
-    }
-
     return SDL_TRUE;
 }
 
-int UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window)
+void UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window)
 {
     SDL_uikitview *view = getWindowView(window);
-    if (view == nil) {
-        return -1;
+    if (view != nil) {
+        [view showKeyboard];
     }
-
-    [view showKeyboard];
-    return 0;
 }
 
-int UIKit_HideScreenKeyboard(_THIS, SDL_Window *window)
+void UIKit_HideScreenKeyboard(_THIS, SDL_Window *window)
 {
     SDL_uikitview *view = getWindowView(window);
-    if (view == nil) {
-        return -1;
+    if (view != nil) {
+        [view hideKeyboard];
     }
-
-    [view hideKeyboard];
-    return 0;
 }
 
 SDL_bool UIKit_IsScreenKeyboardShown(_THIS, SDL_Window *window)
@@ -383,22 +372,6 @@
     return view.keyboardVisible;
 }
 
-int UIKit_ToggleScreenKeyboard(_THIS, SDL_Window *window)
-{
-    SDL_uikitview *view = getWindowView(window);
-    if (view == nil) {
-        return -1;
-    }
-
-    if (UIKit_IsScreenKeyboardShown(_this, window)) {
-        UIKit_HideScreenKeyboard(_this, window);
-    }
-    else {
-        UIKit_ShowScreenKeyboard(_this, window);
-    }
-    return 0;
-}
-
 #endif /* SDL_IPHONE_KEYBOARD */
 
 #endif /* SDL_VIDEO_DRIVER_UIKIT */
--- a/test/checkkeys.c	Sun Nov 04 20:20:53 2012 -0800
+++ b/test/checkkeys.c	Sun Nov 04 21:53:28 2012 -0800
@@ -166,9 +166,7 @@
     SDL_GL_CreateContext(window);
 #endif
 
-    if (SDL_HasScreenKeyboardSupport(window)) {
-        SDL_ShowScreenKeyboard(window);
-    }
+    SDL_StartTextInput();
 
     /* Watch keystrokes */
     done = 0;