IOS: Implement kFeatureVirtualKeyboard to show/hide the keyboard

This commit is contained in:
Thierry Crozat 2019-02-12 23:48:14 +00:00
parent 63a6a3c3de
commit 4795f2b68a
5 changed files with 51 additions and 3 deletions

View File

@ -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;

View File

@ -209,6 +209,8 @@ public:
protected:
void initVideoContext();
void updateOutputSurface();
void setShowKeyboard(bool);
bool isKeyboardShown() const;
void internUpdateScreen();
void dirtyFullScreen();

View File

@ -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];
}

View File

@ -48,6 +48,7 @@ typedef struct {
Common::List<InternalEvent> _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;

View File

@ -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) {