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 66542ecfb25be1e2
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
     1.1 --- a/README.iOS	Sun Nov 04 20:20:53 2012 -0800
     1.2 +++ b/README.iOS	Sun Nov 04 21:53:28 2012 -0800
     1.3 @@ -80,14 +80,12 @@
     1.4  
     1.5  The SDL keyboard API has been extended to support on-screen keyboards:
     1.6  
     1.7 -int SDL_ShowScreenKeyboard(SDL_Window * window) 
     1.8 -	-- reveals the onscreen keyboard.  Returns 0 on success and -1 on error.
     1.9 -int SDL_HideScreenKeyboard(SDL_Window * window) 
    1.10 -	-- hides the onscreen keyboard.  Returns 0 on success and -1 on error.
    1.11 -SDL_bool SDL_IsScreenKeyboardShown(SDL_Window * window) 
    1.12 -	-- returns whether or not the onscreen keyboard is currently visible.
    1.13 -int SDL_ToggleScreenKeyboard(SDL_Window * window) 	
    1.14 -	-- toggles the visibility of the onscreen keyboard.  Returns 0 on success and -1 on error.
    1.15 +void SDL_StartTextInput()
    1.16 +	-- enables text events and reveals the onscreen keyboard.
    1.17 +void SDL_StopTextInput()
    1.18 +	-- disables text events and hides the onscreen keyboard.
    1.19 +SDL_bool SDL_IsTextInputActive()
    1.20 +	-- returns whether or not text events are enabled (and the onscreen keyboard is visible)
    1.21  
    1.22  ==============================================================================
    1.23  Notes -- Reading and Writing files
     2.1 --- a/Xcode-iOS/Demos/src/keyboard.c	Sun Nov 04 20:20:53 2012 -0800
     2.2 +++ b/Xcode-iOS/Demos/src/keyboard.c	Sun Nov 04 21:53:28 2012 -0800
     2.3 @@ -291,7 +291,11 @@
     2.4              break;
     2.5          case SDL_MOUSEBUTTONUP:
     2.6              /*      mouse up toggles onscreen keyboard visibility */
     2.7 -            SDL_ToggleScreenKeyboard(window);
     2.8 +            if (SDL_IsTextInputActive()) {
     2.9 +                SDL_StopTextInput();
    2.10 +            } else {
    2.11 +                SDL_StartTextInput();
    2.12 +            }
    2.13              break;
    2.14          }
    2.15      }
     3.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Sun Nov 04 20:20:53 2012 -0800
     3.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Sun Nov 04 21:53:28 2012 -0800
     3.3 @@ -119,7 +119,7 @@
     3.4  
     3.5      // Messages from the SDLMain thread
     3.6      static final int COMMAND_CHANGE_TITLE = 1;
     3.7 -    static final int COMMAND_KEYBOARD_SHOW = 2;
     3.8 +    static final int COMMAND_UNUSED = 2;
     3.9      static final int COMMAND_TEXTEDIT_HIDE = 3;
    3.10  
    3.11      // Handler for the messages
    3.12 @@ -130,22 +130,6 @@
    3.13              case COMMAND_CHANGE_TITLE:
    3.14                  setTitle((String)msg.obj);
    3.15                  break;
    3.16 -            case COMMAND_KEYBOARD_SHOW:
    3.17 -                InputMethodManager manager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
    3.18 -                if (manager != null) {
    3.19 -                    switch (((Integer)msg.obj).intValue()) {
    3.20 -                    case 0:
    3.21 -                        manager.hideSoftInputFromWindow(mSurface.getWindowToken(), 0);
    3.22 -                        break;
    3.23 -                    case 1:
    3.24 -                        manager.showSoftInput(mSurface, 0);
    3.25 -                        break;
    3.26 -                    case 2:
    3.27 -                        manager.toggleSoftInputFromWindow(mSurface.getWindowToken(), 0, 0);
    3.28 -                        break;
    3.29 -                    }
    3.30 -                }
    3.31 -               break;
    3.32              case COMMAND_TEXTEDIT_HIDE:
    3.33                  if (mTextEdit != null) {
    3.34                      mTextEdit.setVisibility(View.GONE);
     4.1 --- a/include/SDL_keyboard.h	Sun Nov 04 20:20:53 2012 -0800
     4.2 +++ b/include/SDL_keyboard.h	Sun Nov 04 21:53:28 2012 -0800
     4.3 @@ -151,21 +151,34 @@
     4.4  
     4.5  /**
     4.6   *  \brief Start accepting Unicode text input events.
     4.7 + *         This function will show the on-screen keyboard if supported.
     4.8   *  
     4.9   *  \sa SDL_StopTextInput()
    4.10   *  \sa SDL_SetTextInputRect()
    4.11 + *  \sa SDL_HasScreenKeyboardSupport()
    4.12   */
    4.13  extern DECLSPEC void SDLCALL SDL_StartTextInput(void);
    4.14  
    4.15  /**
    4.16 + *  \brief Return whether or not Unicode text input events are enabled.
    4.17 + *
    4.18 + *  \sa SDL_StartTextInput()
    4.19 + *  \sa SDL_StopTextInput()
    4.20 + */
    4.21 +extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void);
    4.22 +
    4.23 +/**
    4.24   *  \brief Stop receiving any text input events.
    4.25 + *         This function will hide the on-screen keyboard if supported.
    4.26   *  
    4.27   *  \sa SDL_StartTextInput()
    4.28 + *  \sa SDL_HasScreenKeyboardSupport()
    4.29   */
    4.30  extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
    4.31  
    4.32  /**
    4.33   *  \brief Set the rectangle used to type Unicode text inputs.
    4.34 + *         This is used as a hint for IME and on-screen keyboard placement.
    4.35   *  
    4.36   *  \sa SDL_StartTextInput()
    4.37   */
    4.38 @@ -174,60 +187,13 @@
    4.39  /**
    4.40   *  \brief Returns whether the platform has some screen keyboard support.
    4.41   *  
    4.42 - *  \param window The window for which screen keyboard should be checked.
    4.43 - *  
    4.44   *  \return SDL_TRUE if some keyboard support is available else SDL_FALSE.
    4.45   *  
    4.46   *  \note Not all screen keyboard functions are supported on all platforms.
    4.47   *  
    4.48 - *  \sa SDL_ShowScreenKeyboard()
    4.49 - *  \sa SDL_HideScreenKeyboard()
    4.50 - *  \sa SDL_IsScreenKeyboardShown()
    4.51 - *  \sa SDL_ToggleScreenKeyboard()
    4.52 - */
    4.53 -extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(SDL_Window *window);
    4.54 -
    4.55 -/**
    4.56 - *  \brief Requests to show a screen keyboard for given window.
    4.57 - *  
    4.58 - *  \param window The window for which screen keyboard should be shown.
    4.59 - *  
    4.60 - *  \return 0 if request will be processed or -1 on error (e.g. no support).
    4.61 - *  
    4.62 - *  \note Showing screen keyboards is asynchronous on some platforms.
    4.63 - *  
    4.64 - *  \sa SDL_HasScreenKeyboardSupport()
    4.65 - *  \sa SDL_HideScreenKeyboard()
    4.66 - */
    4.67 -extern DECLSPEC int SDLCALL SDL_ShowScreenKeyboard(SDL_Window *window);
    4.68 -
    4.69 -/**
    4.70 - *  \brief Requests to hide a screen keyboard for given window.
    4.71 - *  
    4.72 - *  \param window The window for which screen keyboard should be shown.
    4.73 - *  
    4.74 - *  \return 0 if request will be processed or -1 on error (e.g. no support).
    4.75 - *  
    4.76 - *  \note Hiding screen keyboards is asynchronous on some platforms.
    4.77 - *  
    4.78 - *  \sa SDL_HasScreenKeyboardSupport()
    4.79 - *  \sa SDL_ShowScreenKeyboard()
    4.80 - */
    4.81 -extern DECLSPEC int SDLCALL SDL_HideScreenKeyboard(SDL_Window *window);
    4.82 -
    4.83 -/**
    4.84 - *  \brief Requests to toggle a screen keyboard for given window.
    4.85 - *  
    4.86 - *  \param window The window for which screen keyboard should be toggled.
    4.87 - *  
    4.88 - *  \return 0 if request will be processed or -1 on error (e.g. no support).
    4.89 - *  
    4.90 - *  \note Showing and hiding screen keyboards is asynchronous on some platforms.
    4.91 - *  
    4.92 - *  \sa SDL_HasScreenKeyboardSupport()
    4.93   *  \sa SDL_IsScreenKeyboardShown()
    4.94   */
    4.95 -extern DECLSPEC int SDLCALL SDL_ToggleScreenKeyboard(SDL_Window * window);
    4.96 +extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport();
    4.97  
    4.98  /**
    4.99   *  \brief Returns whether the screen keyboard is shown for given window.
   4.100 @@ -236,11 +202,7 @@
   4.101   *  
   4.102   *  \return SDL_TRUE if screen keyboard is shown else SDL_FALSE.
   4.103   *  
   4.104 - *  \note May always return SDL_FALSE on some platforms (not implemented there).
   4.105 - *  
   4.106   *  \sa SDL_HasScreenKeyboardSupport()
   4.107 - *  \sa SDL_ShowScreenKeyboard()
   4.108 - *  \sa SDL_HideScreenKeyboard()
   4.109   */
   4.110  extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window);
   4.111  
     5.1 --- a/include/SDL_system.h	Sun Nov 04 20:20:53 2012 -0800
     5.2 +++ b/include/SDL_system.h	Sun Nov 04 21:53:28 2012 -0800
     5.3 @@ -49,11 +49,6 @@
     5.4  extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
     5.5  extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
     5.6  
     5.7 -#define SDL_iPhoneKeyboardShow  SDL_ShowScreenKeyboard
     5.8 -#define SDL_iPhoneKeyboardHide  SDL_HideScreenKeyboard
     5.9 -#define SDL_iPhoneKeyboardToggle    SDL_ToggleScreenKeyboard
    5.10 -#define SDL_iPhoneKeyboardIsShown   SDL_IsScreenKeyboardShown
    5.11 -
    5.12  #endif /* __IPHONEOS__ */
    5.13  
    5.14  
     6.1 --- a/src/core/android/SDL_android.cpp	Sun Nov 04 20:20:53 2012 -0800
     6.2 +++ b/src/core/android/SDL_android.cpp	Sun Nov 04 21:53:28 2012 -0800
     6.3 @@ -957,39 +957,30 @@
     6.4      return 0;
     6.5  }
     6.6  
     6.7 -extern "C" int Android_JNI_ShowTextInput(SDL_Rect *inputRect)
     6.8 +extern "C" void Android_JNI_ShowTextInput(SDL_Rect *inputRect)
     6.9  {
    6.10      JNIEnv *env = Android_JNI_GetEnv();
    6.11      if (!env) {
    6.12 -        return -1;
    6.13 +        return;
    6.14      }
    6.15  
    6.16      jmethodID mid = env->GetStaticMethodID(mActivityClass, "showTextInput", "(IIII)V");
    6.17      if (!mid) {
    6.18 -        return -1;
    6.19 +        return;
    6.20      }
    6.21      env->CallStaticVoidMethod( mActivityClass, mid,
    6.22                                 inputRect->x,
    6.23                                 inputRect->y,
    6.24                                 inputRect->w,
    6.25                                 inputRect->h );
    6.26 -    return 0;
    6.27  }
    6.28  
    6.29 -/*extern "C" int Android_JNI_HideTextInput()
    6.30 +extern "C" void Android_JNI_HideTextInput()
    6.31  {
    6.32 -    JNIEnv *env = Android_JNI_GetEnv();
    6.33 -    if (!env) {
    6.34 -        return -1;
    6.35 -    }
    6.36 -
    6.37 -    jmethodID mid = env->GetStaticMethodID(mActivityClass, "hideTextInput", "()V");
    6.38 -    if (!mid) {
    6.39 -        return -1;
    6.40 -    }
    6.41 -    env->CallStaticVoidMethod(mActivityClass, mid);
    6.42 -    return 0;
    6.43 -}*/
    6.44 +    // has to match Activity constant
    6.45 +    const int COMMAND_TEXTEDIT_HIDE = 3;
    6.46 +    Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0);
    6.47 +}
    6.48  
    6.49  //////////////////////////////////////////////////////////////////////////////
    6.50  //
     7.1 --- a/src/core/android/SDL_android.h	Sun Nov 04 20:20:53 2012 -0800
     7.2 +++ b/src/core/android/SDL_android.h	Sun Nov 04 21:53:28 2012 -0800
     7.3 @@ -34,7 +34,8 @@
     7.4  extern void Android_JNI_SwapWindow();
     7.5  extern void Android_JNI_SetActivityTitle(const char *title);
     7.6  extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]);
     7.7 -extern int Android_JNI_ShowTextInput(SDL_Rect *inputRect);
     7.8 +extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect);
     7.9 +extern void Android_JNI_HideTextInput();
    7.10  
    7.11  // Audio support
    7.12  extern int Android_JNI_OpenAudioDevice(int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames);
     8.1 --- a/src/events/SDL_events.c	Sun Nov 04 20:20:53 2012 -0800
     8.2 +++ b/src/events/SDL_events.c	Sun Nov 04 21:53:28 2012 -0800
     8.3 @@ -125,6 +125,8 @@
     8.4  
     8.5      /* No filter to start with, process most event types */
     8.6      SDL_EventOK = NULL;
     8.7 +    SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE);
     8.8 +    SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE);
     8.9      SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
    8.10  
    8.11      /* Create the lock and set ourselves active */
     9.1 --- a/src/video/SDL_sysvideo.h	Sun Nov 04 20:20:53 2012 -0800
     9.2 +++ b/src/video/SDL_sysvideo.h	Sun Nov 04 21:53:28 2012 -0800
     9.3 @@ -236,10 +236,9 @@
     9.4      void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
     9.5  
     9.6      /* Screen keyboard */
     9.7 -    SDL_bool (*SDL_HasScreenKeyboardSupport) (_THIS, SDL_Window *window);
     9.8 -    int (*SDL_ShowScreenKeyboard) (_THIS, SDL_Window *window);
     9.9 -    int (*SDL_HideScreenKeyboard) (_THIS, SDL_Window *window);
    9.10 -    int (*SDL_ToggleScreenKeyboard) (_THIS, SDL_Window *window);
    9.11 +    SDL_bool (*SDL_HasScreenKeyboardSupport) (_THIS);
    9.12 +    void (*SDL_ShowScreenKeyboard) (_THIS, SDL_Window *window);
    9.13 +    void (*SDL_HideScreenKeyboard) (_THIS, SDL_Window *window);
    9.14      SDL_bool (*SDL_IsScreenKeyboardShown) (_THIS, SDL_Window *window);
    9.15  
    9.16      /* Clipboard */
    10.1 --- a/src/video/SDL_video.c	Sun Nov 04 20:20:53 2012 -0800
    10.2 +++ b/src/video/SDL_video.c	Sun Nov 04 21:53:28 2012 -0800
    10.3 @@ -2771,19 +2771,47 @@
    10.4  void
    10.5  SDL_StartTextInput(void)
    10.6  {
    10.7 +    SDL_Window *window;
    10.8 +
    10.9 +    /* First, enable text events */
   10.10 +    SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE);
   10.11 +    SDL_EventState(SDL_TEXTEDITING, SDL_ENABLE);
   10.12 +
   10.13 +    /* Then show the on-screen keyboard, if any */
   10.14 +    window = SDL_GetFocusWindow();
   10.15 +    if (window && _this && _this->SDL_ShowScreenKeyboard) {
   10.16 +        _this->SDL_ShowScreenKeyboard(_this, window);
   10.17 +    }
   10.18 +
   10.19 +    /* Finally start the text input system */
   10.20      if (_this && _this->StartTextInput) {
   10.21          _this->StartTextInput(_this);
   10.22      }
   10.23 -    SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE);
   10.24 -    SDL_EventState(SDL_TEXTEDITING, SDL_ENABLE);
   10.25 +}
   10.26 +
   10.27 +SDL_bool
   10.28 +SDL_IsTextInputActive(void)
   10.29 +{
   10.30 +    return (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE);
   10.31  }
   10.32  
   10.33  void
   10.34  SDL_StopTextInput(void)
   10.35  {
   10.36 +    SDL_Window *window;
   10.37 +
   10.38 +    /* Stop the text input system */
   10.39      if (_this && _this->StopTextInput) {
   10.40          _this->StopTextInput(_this);
   10.41      }
   10.42 +
   10.43 +    /* Hide the on-screen keyboard, if any */
   10.44 +    window = SDL_GetFocusWindow();
   10.45 +    if (window && _this && _this->SDL_HideScreenKeyboard) {
   10.46 +        _this->SDL_HideScreenKeyboard(_this, window);
   10.47 +    }
   10.48 +
   10.49 +    /* Finally disable text events */
   10.50      SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE);
   10.51      SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE);
   10.52  }
   10.53 @@ -2797,41 +2825,14 @@
   10.54  }
   10.55  
   10.56  SDL_bool
   10.57 -SDL_HasScreenKeyboardSupport(SDL_Window *window)
   10.58 +SDL_HasScreenKeyboardSupport(void)
   10.59  {
   10.60 -    if (window && _this && _this->SDL_HasScreenKeyboardSupport) {
   10.61 -        return _this->SDL_HasScreenKeyboardSupport(_this, window);
   10.62 +    if (_this && _this->SDL_HasScreenKeyboardSupport) {
   10.63 +        return _this->SDL_HasScreenKeyboardSupport(_this);
   10.64      }
   10.65      return SDL_FALSE;
   10.66  }
   10.67  
   10.68 -int
   10.69 -SDL_ShowScreenKeyboard(SDL_Window *window)
   10.70 -{
   10.71 -    if (window && _this && _this->SDL_ShowScreenKeyboard) {
   10.72 -        return _this->SDL_ShowScreenKeyboard(_this, window);
   10.73 -    }
   10.74 -    return -1;
   10.75 -}
   10.76 -
   10.77 -int
   10.78 -SDL_HideScreenKeyboard(SDL_Window *window)
   10.79 -{
   10.80 -    if (window && _this && _this->SDL_HideScreenKeyboard) {
   10.81 -        return _this->SDL_HideScreenKeyboard(_this, window);
   10.82 -    }
   10.83 -    return -1;
   10.84 -}
   10.85 -
   10.86 -int
   10.87 -SDL_ToggleScreenKeyboard(SDL_Window *window)
   10.88 -{
   10.89 -    if (window && _this && _this->SDL_ToggleScreenKeyboard) {
   10.90 -        return _this->SDL_ToggleScreenKeyboard(_this, window);
   10.91 -    }
   10.92 -    return -1;
   10.93 -}
   10.94 -
   10.95  SDL_bool
   10.96  SDL_IsScreenKeyboardShown(SDL_Window *window)
   10.97  {
    11.1 --- a/src/video/android/SDL_androidkeyboard.c	Sun Nov 04 20:20:53 2012 -0800
    11.2 +++ b/src/video/android/SDL_androidkeyboard.c	Sun Nov 04 21:53:28 2012 -0800
    11.3 @@ -287,37 +287,16 @@
    11.4      return SDL_SendKeyboardKey(SDL_RELEASED, TranslateKeycode(keycode));
    11.5  }
    11.6  
    11.7 -// has to fit Activity constant
    11.8 -#define COMMAND_KEYBOARD_SHOW 2
    11.9 -
   11.10  SDL_bool
   11.11 -Android_HasScreenKeyboardSupport(_THIS, SDL_Window * window)
   11.12 +Android_HasScreenKeyboardSupport(_THIS)
   11.13  {
   11.14 -    return Android_Window ? SDL_TRUE : SDL_FALSE;
   11.15 -}
   11.16 -
   11.17 -int
   11.18 -Android_ShowScreenKeyboard(_THIS, SDL_Window * window)
   11.19 -{
   11.20 -    return Android_Window ? Android_JNI_SendMessage(COMMAND_KEYBOARD_SHOW, 1) : -1;
   11.21 -}
   11.22 -
   11.23 -int
   11.24 -Android_HideScreenKeyboard(_THIS, SDL_Window * window)
   11.25 -{
   11.26 -    return Android_Window ? Android_JNI_SendMessage(COMMAND_KEYBOARD_SHOW, 0) : -1;
   11.27 -}
   11.28 -
   11.29 -int
   11.30 -Android_ToggleScreenKeyboard(_THIS, SDL_Window * window)
   11.31 -{
   11.32 -    return Android_Window ? Android_JNI_SendMessage(COMMAND_KEYBOARD_SHOW, 2) : -1;
   11.33 +    return SDL_TRUE;
   11.34  }
   11.35  
   11.36  SDL_bool
   11.37  Android_IsScreenKeyboardShown(_THIS, SDL_Window * window)
   11.38  {
   11.39 -    return SDL_FALSE;
   11.40 +    return SDL_IsTextInputActive();
   11.41  }
   11.42  
   11.43  void
   11.44 @@ -327,11 +306,10 @@
   11.45      Android_JNI_ShowTextInput(&videodata->textRect);
   11.46  }
   11.47  
   11.48 -#define COMMAND_TEXTEDIT_HIDE 3
   11.49  void
   11.50  Android_StopTextInput(_THIS)
   11.51  {
   11.52 -    Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0);
   11.53 +    Android_JNI_HideTextInput();
   11.54  }
   11.55  
   11.56  void
    12.1 --- a/src/video/android/SDL_androidkeyboard.h	Sun Nov 04 20:20:53 2012 -0800
    12.2 +++ b/src/video/android/SDL_androidkeyboard.h	Sun Nov 04 21:53:28 2012 -0800
    12.3 @@ -26,10 +26,7 @@
    12.4  extern int Android_OnKeyDown(int keycode);
    12.5  extern int Android_OnKeyUp(int keycode);
    12.6  
    12.7 -extern SDL_bool Android_HasScreenKeyboardSupport(_THIS, SDL_Window * window);
    12.8 -extern int Android_ShowScreenKeyboard(_THIS, SDL_Window * window);
    12.9 -extern int Android_HideScreenKeyboard(_THIS, SDL_Window * window);
   12.10 -extern int Android_ToggleScreenKeyboard(_THIS, SDL_Window * window);
   12.11 +extern SDL_bool Android_HasScreenKeyboardSupport(_THIS);
   12.12  extern SDL_bool Android_IsScreenKeyboardShown(_THIS, SDL_Window * window);
   12.13  
   12.14  extern void Android_StartTextInput(_THIS);
    13.1 --- a/src/video/android/SDL_androidvideo.c	Sun Nov 04 20:20:53 2012 -0800
    13.2 +++ b/src/video/android/SDL_androidvideo.c	Sun Nov 04 21:53:28 2012 -0800
    13.3 @@ -127,11 +127,13 @@
    13.4      device->GL_SwapWindow = Android_GL_SwapWindow;
    13.5      device->GL_DeleteContext = Android_GL_DeleteContext;
    13.6  
    13.7 +    /* Text input */
    13.8 +    device->StartTextInput = Android_StartTextInput;
    13.9 +    device->StopTextInput = Android_StopTextInput;
   13.10 +    device->SetTextInputRect = Android_SetTextInputRect;
   13.11 +
   13.12      /* Screen keyboard */
   13.13      device->SDL_HasScreenKeyboardSupport = Android_HasScreenKeyboardSupport;
   13.14 -    device->SDL_ShowScreenKeyboard = Android_ShowScreenKeyboard;
   13.15 -    device->SDL_HideScreenKeyboard = Android_HideScreenKeyboard;
   13.16 -    device->SDL_ToggleScreenKeyboard = Android_ToggleScreenKeyboard;
   13.17      device->SDL_IsScreenKeyboardShown = Android_IsScreenKeyboardShown;
   13.18  
   13.19      /* Clipboard */
   13.20 @@ -139,11 +141,6 @@
   13.21      device->GetClipboardText = Android_GetClipboardText;
   13.22      device->HasClipboardText = Android_HasClipboardText;
   13.23  
   13.24 -    /* Text input */
   13.25 -    device->StartTextInput = Android_StartTextInput;
   13.26 -    device->StopTextInput = Android_StopTextInput;
   13.27 -    device->SetTextInputRect = Android_SetTextInputRect;
   13.28 -
   13.29      return device;
   13.30  }
   13.31  
    14.1 --- a/src/video/android/SDL_androidwindow.c	Sun Nov 04 20:20:53 2012 -0800
    14.2 +++ b/src/video/android/SDL_androidwindow.c	Sun Nov 04 21:53:28 2012 -0800
    14.3 @@ -52,7 +52,7 @@
    14.4  
    14.5      /* One window, it always has focus */
    14.6      SDL_SetMouseFocus(window);
    14.7 -    //SDL_SetKeyboardFocus(window);
    14.8 +    SDL_SetKeyboardFocus(window);
    14.9  
   14.10      return 0;
   14.11  }
    15.1 --- a/src/video/uikit/SDL_uikitvideo.m	Sun Nov 04 20:20:53 2012 -0800
    15.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Sun Nov 04 21:53:28 2012 -0800
    15.3 @@ -89,7 +89,6 @@
    15.4      device->SDL_HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport;
    15.5      device->SDL_ShowScreenKeyboard = UIKit_ShowScreenKeyboard;
    15.6      device->SDL_HideScreenKeyboard = UIKit_HideScreenKeyboard;
    15.7 -    device->SDL_ToggleScreenKeyboard = UIKit_ToggleScreenKeyboard;
    15.8      device->SDL_IsScreenKeyboardShown = UIKit_IsScreenKeyboardShown;
    15.9  
   15.10      /* OpenGL (ES) functions */
    16.1 --- a/src/video/uikit/SDL_uikitview.h	Sun Nov 04 20:20:53 2012 -0800
    16.2 +++ b/src/video/uikit/SDL_uikitview.h	Sun Nov 04 21:53:28 2012 -0800
    16.3 @@ -61,10 +61,9 @@
    16.4  - (void)initializeKeyboard;
    16.5  @property (readonly) BOOL keyboardVisible;
    16.6  
    16.7 -SDL_bool UIKit_HasScreenKeyboardSupport(_THIS, SDL_Window *window);
    16.8 -int UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window);
    16.9 -int UIKit_HideScreenKeyboard(_THIS, SDL_Window *window);
   16.10 -int UIKit_ToggleScreenKeyboard(_THIS, SDL_Window *window);
   16.11 +SDL_bool UIKit_HasScreenKeyboardSupport(_THIS);
   16.12 +void UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window);
   16.13 +void UIKit_HideScreenKeyboard(_THIS, SDL_Window *window);
   16.14  SDL_bool UIKit_IsScreenKeyboardShown(_THIS, SDL_Window *window);
   16.15  
   16.16  #endif
    17.1 --- a/src/video/uikit/SDL_uikitview.m	Sun Nov 04 20:20:53 2012 -0800
    17.2 +++ b/src/video/uikit/SDL_uikitview.m	Sun Nov 04 21:53:28 2012 -0800
    17.3 @@ -313,7 +313,7 @@
    17.4  {
    17.5      SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RETURN);
    17.6      SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RETURN);
    17.7 -    [self hideKeyboard];
    17.8 +    SDL_StopTextInput();
    17.9      return YES;
   17.10  }
   17.11  
   17.12 @@ -341,36 +341,25 @@
   17.13      return view;
   17.14  }
   17.15  
   17.16 -SDL_bool UIKit_HasScreenKeyboardSupport(_THIS, SDL_Window *window)
   17.17 +SDL_bool UIKit_HasScreenKeyboardSupport(_THIS)
   17.18  {
   17.19 -    SDL_uikitview *view = getWindowView(window);
   17.20 -    if (view == nil) {
   17.21 -        return SDL_FALSE;
   17.22 -    }
   17.23 -
   17.24      return SDL_TRUE;
   17.25  }
   17.26  
   17.27 -int UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window)
   17.28 +void UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window)
   17.29  {
   17.30      SDL_uikitview *view = getWindowView(window);
   17.31 -    if (view == nil) {
   17.32 -        return -1;
   17.33 +    if (view != nil) {
   17.34 +        [view showKeyboard];
   17.35      }
   17.36 -
   17.37 -    [view showKeyboard];
   17.38 -    return 0;
   17.39  }
   17.40  
   17.41 -int UIKit_HideScreenKeyboard(_THIS, SDL_Window *window)
   17.42 +void UIKit_HideScreenKeyboard(_THIS, SDL_Window *window)
   17.43  {
   17.44      SDL_uikitview *view = getWindowView(window);
   17.45 -    if (view == nil) {
   17.46 -        return -1;
   17.47 +    if (view != nil) {
   17.48 +        [view hideKeyboard];
   17.49      }
   17.50 -
   17.51 -    [view hideKeyboard];
   17.52 -    return 0;
   17.53  }
   17.54  
   17.55  SDL_bool UIKit_IsScreenKeyboardShown(_THIS, SDL_Window *window)
   17.56 @@ -383,22 +372,6 @@
   17.57      return view.keyboardVisible;
   17.58  }
   17.59  
   17.60 -int UIKit_ToggleScreenKeyboard(_THIS, SDL_Window *window)
   17.61 -{
   17.62 -    SDL_uikitview *view = getWindowView(window);
   17.63 -    if (view == nil) {
   17.64 -        return -1;
   17.65 -    }
   17.66 -
   17.67 -    if (UIKit_IsScreenKeyboardShown(_this, window)) {
   17.68 -        UIKit_HideScreenKeyboard(_this, window);
   17.69 -    }
   17.70 -    else {
   17.71 -        UIKit_ShowScreenKeyboard(_this, window);
   17.72 -    }
   17.73 -    return 0;
   17.74 -}
   17.75 -
   17.76  #endif /* SDL_IPHONE_KEYBOARD */
   17.77  
   17.78  #endif /* SDL_VIDEO_DRIVER_UIKIT */
    18.1 --- a/test/checkkeys.c	Sun Nov 04 20:20:53 2012 -0800
    18.2 +++ b/test/checkkeys.c	Sun Nov 04 21:53:28 2012 -0800
    18.3 @@ -166,9 +166,7 @@
    18.4      SDL_GL_CreateContext(window);
    18.5  #endif
    18.6  
    18.7 -    if (SDL_HasScreenKeyboardSupport(window)) {
    18.8 -        SDL_ShowScreenKeyboard(window);
    18.9 -    }
   18.10 +    SDL_StartTextInput();
   18.11  
   18.12      /* Watch keystrokes */
   18.13      done = 0;