From b1485e3365faa06715817a65923345da6a73cef3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 4 Nov 2012 21:53:28 -0800 Subject: [PATCH] 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 | 14 ++-- Xcode-iOS/Demos/src/keyboard.c | 6 +- .../src/org/libsdl/app/SDLActivity.java | 18 +---- include/SDL_keyboard.h | 66 ++++--------------- include/SDL_system.h | 5 -- src/core/android/SDL_android.cpp | 25 +++---- src/core/android/SDL_android.h | 3 +- src/events/SDL_events.c | 2 + src/video/SDL_sysvideo.h | 7 +- src/video/SDL_video.c | 65 +++++++++--------- src/video/android/SDL_androidkeyboard.c | 30 ++------- src/video/android/SDL_androidkeyboard.h | 5 +- src/video/android/SDL_androidvideo.c | 13 ++-- src/video/android/SDL_androidwindow.c | 2 +- src/video/uikit/SDL_uikitvideo.m | 1 - src/video/uikit/SDL_uikitview.h | 7 +- src/video/uikit/SDL_uikitview.m | 43 +++--------- test/checkkeys.c | 4 +- 18 files changed, 97 insertions(+), 219 deletions(-) diff --git a/README.iOS b/README.iOS index ab96788f7..a1844a3fb 100644 --- a/README.iOS +++ b/README.iOS @@ -80,14 +80,12 @@ Notes -- Keyboard 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 diff --git a/Xcode-iOS/Demos/src/keyboard.c b/Xcode-iOS/Demos/src/keyboard.c index df4b6e1c6..3e2bc5459 100644 --- a/Xcode-iOS/Demos/src/keyboard.c +++ b/Xcode-iOS/Demos/src/keyboard.c @@ -291,7 +291,11 @@ main(int argc, char *argv[]) break; case SDL_MOUSEBUTTONUP: /* mouse up toggles onscreen keyboard visibility */ - SDL_ToggleScreenKeyboard(window); + if (SDL_IsTextInputActive()) { + SDL_StopTextInput(); + } else { + SDL_StartTextInput(); + } break; } } diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java index 3e0b1b2b0..dc7aa3198 100644 --- a/android-project/src/org/libsdl/app/SDLActivity.java +++ b/android-project/src/org/libsdl/app/SDLActivity.java @@ -119,7 +119,7 @@ protected void onDestroy() { // 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 @@ public void handleMessage(Message msg) { 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); diff --git a/include/SDL_keyboard.h b/include/SDL_keyboard.h index fc8abcc73..19ca8b4a5 100644 --- a/include/SDL_keyboard.h +++ b/include/SDL_keyboard.h @@ -151,21 +151,34 @@ extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name); /** * \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 @@ extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect); /** * \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 @@ extern DECLSPEC int SDLCALL SDL_ToggleScreenKeyboard(SDL_Window * window); * * \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); diff --git a/include/SDL_system.h b/include/SDL_system.h index 1bc0d506a..aa141489d 100644 --- a/include/SDL_system.h +++ b/include/SDL_system.h @@ -49,11 +49,6 @@ extern "C" { 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__ */ diff --git a/src/core/android/SDL_android.cpp b/src/core/android/SDL_android.cpp index e7b02c29f..fb06cd5c0 100644 --- a/src/core/android/SDL_android.cpp +++ b/src/core/android/SDL_android.cpp @@ -957,39 +957,30 @@ extern "C" int Android_JNI_SendMessage(int command, int param) 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); +} ////////////////////////////////////////////////////////////////////////////// // diff --git a/src/core/android/SDL_android.h b/src/core/android/SDL_android.h index 505e92b69..d72761bfb 100644 --- a/src/core/android/SDL_android.h +++ b/src/core/android/SDL_android.h @@ -34,7 +34,8 @@ extern SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion); 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); diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 431eaa25c..4083f17b4 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -125,6 +125,8 @@ SDL_StartEventLoop(void) /* 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 */ diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 25c4f437f..f4044e819 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -236,10 +236,9 @@ struct SDL_VideoDevice 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 */ diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 5d12d10af..b7a07f624 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -2771,19 +2771,47 @@ SDL_GetWindowWMInfo(SDL_Window * window, struct SDL_SysWMinfo *info) 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_SetTextInputRect(SDL_Rect *rect) } 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) { diff --git a/src/video/android/SDL_androidkeyboard.c b/src/video/android/SDL_androidkeyboard.c index 7e66226b3..b1fe43a0e 100644 --- a/src/video/android/SDL_androidkeyboard.c +++ b/src/video/android/SDL_androidkeyboard.c @@ -287,37 +287,16 @@ Android_OnKeyUp(int keycode) 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) -{ - 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) +Android_HasScreenKeyboardSupport(_THIS) { - 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_StartTextInput(_THIS) 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 diff --git a/src/video/android/SDL_androidkeyboard.h b/src/video/android/SDL_androidkeyboard.h index be3d82833..9cc7b0261 100644 --- a/src/video/android/SDL_androidkeyboard.h +++ b/src/video/android/SDL_androidkeyboard.h @@ -26,10 +26,7 @@ extern void Android_InitKeyboard(); 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); diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c index a171094ca..ecb70f2f8 100644 --- a/src/video/android/SDL_androidvideo.c +++ b/src/video/android/SDL_androidvideo.c @@ -127,11 +127,13 @@ Android_CreateDevice(int devindex) 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 @@ Android_CreateDevice(int devindex) device->GetClipboardText = Android_GetClipboardText; device->HasClipboardText = Android_HasClipboardText; - /* Text input */ - device->StartTextInput = Android_StartTextInput; - device->StopTextInput = Android_StopTextInput; - device->SetTextInputRect = Android_SetTextInputRect; - return device; } diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c index 6df317fa2..ba3093dca 100644 --- a/src/video/android/SDL_androidwindow.c +++ b/src/video/android/SDL_androidwindow.c @@ -52,7 +52,7 @@ Android_CreateWindow(_THIS, SDL_Window * window) /* One window, it always has focus */ SDL_SetMouseFocus(window); - //SDL_SetKeyboardFocus(window); + SDL_SetKeyboardFocus(window); return 0; } diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m index 58f32787f..7de783f34 100644 --- a/src/video/uikit/SDL_uikitvideo.m +++ b/src/video/uikit/SDL_uikitvideo.m @@ -89,7 +89,6 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device) 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 */ diff --git a/src/video/uikit/SDL_uikitview.h b/src/video/uikit/SDL_uikitview.h index c60830ab1..a1f833b04 100644 --- a/src/video/uikit/SDL_uikitview.h +++ b/src/video/uikit/SDL_uikitview.h @@ -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 diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index a54cc501d..254a96149 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -313,7 +313,7 @@ - (BOOL)textFieldShouldReturn:(UITextField*)_textField { SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RETURN); SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RETURN); - [self hideKeyboard]; + SDL_StopTextInput(); return YES; } @@ -341,36 +341,25 @@ - (BOOL)textFieldShouldReturn:(UITextField*)_textField 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 @@ SDL_bool UIKit_IsScreenKeyboardShown(_THIS, SDL_Window *window) 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 */ diff --git a/test/checkkeys.c b/test/checkkeys.c index 421ede4a7..fdbce60dd 100644 --- a/test/checkkeys.c +++ b/test/checkkeys.c @@ -166,9 +166,7 @@ main(int argc, char *argv[]) SDL_GL_CreateContext(window); #endif - if (SDL_HasScreenKeyboardSupport(window)) { - SDL_ShowScreenKeyboard(window); - } + SDL_StartTextInput(); /* Watch keystrokes */ done = 0;