aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorThierry Crozat2019-02-12 23:48:14 +0000
committerThierry Crozat2019-02-16 17:20:57 +0000
commit4795f2b68a4fd7023c2f85a79c1b7686b9226747 (patch)
tree9f107ee21e2b6bb2357249c99729d116dccbc09e /backends/platform
parent63a6a3c3debce1bc843906bf8fa277a1fb75b2d4 (diff)
downloadscummvm-rg350-4795f2b68a4fd7023c2f85a79c1b7686b9226747.tar.gz
scummvm-rg350-4795f2b68a4fd7023c2f85a79c1b7686b9226747.tar.bz2
scummvm-rg350-4795f2b68a4fd7023c2f85a79c1b7686b9226747.zip
IOS: Implement kFeatureVirtualKeyboard to show/hide the keyboard
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/ios7/ios7_osys_main.cpp6
-rw-r--r--backends/platform/ios7/ios7_osys_main.h2
-rw-r--r--backends/platform/ios7/ios7_osys_video.mm20
-rw-r--r--backends/platform/ios7/ios7_video.h5
-rw-r--r--backends/platform/ios7/ios7_video.mm21
5 files changed, 51 insertions, 3 deletions
diff --git a/backends/platform/ios7/ios7_osys_main.cpp b/backends/platform/ios7/ios7_osys_main.cpp
index 318838d3bf..9b740ca69d 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 c57d95bdd2..ca98991f1b 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 3196f88822..20cf687709 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 9c5d92a970..a26213f28e 100644
--- a/backends/platform/ios7/ios7_video.h
+++ b/backends/platform/ios7/ios7_video.h
@@ -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;
diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm
index 8e3edb3d84..679dedffc4 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) {