diff --git a/backends/platform/ios7/ios7_osys_main.cpp b/backends/platform/ios7/ios7_osys_main.cpp index 318838d3bff..9b740ca69dd 100644 --- a/backends/platform/ios7/ios7_osys_main.cpp +++ b/backends/platform/ios7/ios7_osys_main.cpp @@ -171,6 +171,7 @@ bool OSystem_iOS7::hasFeature(Feature f) { switch (f) { case kFeatureCursorPalette: case kFeatureFilteringMode: + case kFeatureVirtualKeyboard: return true; default: @@ -193,6 +194,9 @@ void OSystem_iOS7::setFeatureState(Feature f, bool enable) { case kFeatureAspectRatioCorrection: _videoContext->asprectRatioCorrection = enable; break; + case kFeatureVirtualKeyboard: + setShowKeyboard(enable); + break; default: break; @@ -207,6 +211,8 @@ bool OSystem_iOS7::getFeatureState(Feature f) { return _videoContext->filtering; case kFeatureAspectRatioCorrection: return _videoContext->asprectRatioCorrection; + case kFeatureVirtualKeyboard: + return isKeyboardShown(); default: return false; diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h index c57d95bdd22..ca98991f1be 100644 --- a/backends/platform/ios7/ios7_osys_main.h +++ b/backends/platform/ios7/ios7_osys_main.h @@ -209,6 +209,8 @@ public: protected: void initVideoContext(); void updateOutputSurface(); + void setShowKeyboard(bool); + bool isKeyboardShown() const; void internUpdateScreen(); void dirtyFullScreen(); diff --git a/backends/platform/ios7/ios7_osys_video.mm b/backends/platform/ios7/ios7_osys_video.mm index 3196f88822f..20cf6877097 100644 --- a/backends/platform/ios7/ios7_osys_video.mm +++ b/backends/platform/ios7/ios7_osys_video.mm @@ -583,3 +583,23 @@ void OSystem_iOS7::updateMouseTexture() { [[iOS7AppDelegate iPhoneView] updateMouseCursor]; }); } + +void OSystem_iOS7::setShowKeyboard(bool show) { + if (show) { + execute_on_main_thread(^ { + [[iOS7AppDelegate iPhoneView] showKeyboard]; + }); + } else { + // Do not hide the keyboard in portrait mode as it is shown automatically and not + // just when asked with the kFeatureVirtualKeyboard. + if (_screenOrientation == kScreenOrientationLandscape || _screenOrientation == kScreenOrientationFlippedLandscape) { + execute_on_main_thread(^ { + [[iOS7AppDelegate iPhoneView] hideKeyboard]; + }); + } + } +} + +bool OSystem_iOS7::isKeyboardShown() const { + return [[iOS7AppDelegate iPhoneView] isKeyboardShown]; +} diff --git a/backends/platform/ios7/ios7_video.h b/backends/platform/ios7/ios7_video.h index 9c5d92a9708..a26213f28e4 100644 --- a/backends/platform/ios7/ios7_video.h +++ b/backends/platform/ios7/ios7_video.h @@ -48,6 +48,7 @@ typedef struct { Common::List _events; NSLock *_eventLock; SoftKeyboard *_keyboardView; + BOOL _keyboardVisible; EAGLContext *_context; GLuint _viewRenderbuffer; @@ -120,6 +121,10 @@ typedef struct { - (void)deviceOrientationChanged:(UIDeviceOrientation)orientation; +- (void)showKeyboard; +- (void)hideKeyboard; +- (BOOL)isKeyboardShown; + - (void)applicationSuspend; - (void)applicationResume; diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm index 8e3edb3d84b..679dedffc40 100644 --- a/backends/platform/ios7/ios7_video.mm +++ b/backends/platform/ios7/ios7_video.mm @@ -413,6 +413,7 @@ uint getSizeNextPOT(uint size) { #endif _keyboardView = nil; + _keyboardVisible = NO; _screenTexture = 0; _overlayTexture = 0; _mouseCursorTexture = 0; @@ -725,7 +726,7 @@ uint getSizeNextPOT(uint size) { [_keyboardView setInputDelegate:self]; [self addSubview:[_keyboardView inputView]]; [self addSubview: _keyboardView]; - [_keyboardView showKeyboard]; + [self showKeyboard]; } glBindRenderbuffer(GL_RENDERBUFFER, _viewRenderbuffer); printOpenGLError(); @@ -907,12 +908,26 @@ uint getSizeNextPOT(uint size) { BOOL isLandscape = (self.bounds.size.width > self.bounds.size.height); if (isLandscape) { - [_keyboardView hideKeyboard]; + [self hideKeyboard]; } else { - [_keyboardView showKeyboard]; + [self showKeyboard]; } } +- (void)showKeyboard { + [_keyboardView showKeyboard]; + _keyboardVisible = YES; +} + +- (void)hideKeyboard { + [_keyboardView hideKeyboard]; + _keyboardVisible = NO; +} + +- (BOOL)isKeyboardShown { + return _keyboardVisible; +} + - (UITouch *)secondTouchOtherTouchThan:(UITouch *)touch in:(NSSet *)set { NSArray *all = [set allObjects]; for (UITouch *t in all) {