[Scummvm-git-logs] scummvm master -> eb601e86bb2bec616bbf48ec90a172fc309247d2

larsamannen noreply at scummvm.org
Wed Oct 25 20:05:09 UTC 2023


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4dff5ab486 IOS7: Don't account suspended time in getMillis()
01106f01d6 IOS7: Enable HW keyboards without first enabling the soft keyboard
eb601e86bb IOS7: Fix showing/hiding of inputAccessoryView


Commit: 4dff5ab486c146e1c053bd086211d683aafb4ef9
    https://github.com/scummvm/scummvm/commit/4dff5ab486c146e1c053bd086211d683aafb4ef9
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-10-25T22:05:04+02:00

Commit Message:
IOS7: Don't account suspended time in getMillis()

It was reported that in some games, e.g. COMI, if suspending the iOS
application by putting it to background and then some time later
resuming it again the music doesn't start playing. It was reproduced
in The Dig and most probably Full Throttle was affected.

The time it took for the music to play again after resuming turned
out to be related to the time the app was in background. The longer
the app was in background, the longer it took for the music to start
playing again.

The legacy implementation of getMillis in the iOS7 backend accounted
the time the application was suspended. The time was accumulated
every time the app moved to background and it was never reset.
The getMillis function used the accumulated value and substracted it
from the time difference from the current time.

This seems to have caused problems with the timer handler, causing
slots to not be executed in correct time. The Android backend do not
account for the time in background.

Changed paths:
    backends/platform/ios7/ios7_osys_main.cpp
    backends/platform/ios7/ios7_osys_main.h


diff --git a/backends/platform/ios7/ios7_osys_main.cpp b/backends/platform/ios7/ios7_osys_main.cpp
index 08562241eaa..09c83692e30 100644
--- a/backends/platform/ios7/ios7_osys_main.cpp
+++ b/backends/platform/ios7/ios7_osys_main.cpp
@@ -90,7 +90,7 @@ public:
 OSystem_iOS7::OSystem_iOS7() :
 	_mixer(NULL), _queuedEventTime(0),
 	_screenOrientation(kScreenOrientationAuto),
-	_timeSuspended(0), _runningTasks(0) {
+	_runningTasks(0) {
 	_queuedInputEvent.type = Common::EVENT_INVALID;
 	_currentTouchMode = kTouchModeTouchpad;
 
@@ -247,7 +247,6 @@ bool OSystem_iOS7::setGraphicsMode(int mode, uint flags) {
 
 void OSystem_iOS7::suspendLoop() {
 	bool done = false;
-	uint32 startTime = getMillis();
 
 	PauseToken pt;
 	if (g_engine)
@@ -269,8 +268,6 @@ void OSystem_iOS7::suspendLoop() {
 	}
 
 	startSoundsystem();
-
-	_timeSuspended += getMillis() - startTime;
 }
 
 void OSystem_iOS7::saveState() {
@@ -329,7 +326,7 @@ void OSystem_iOS7::clearState() {
 
 uint32 OSystem_iOS7::getMillis(bool skipRecord) {
 	CFTimeInterval timeInSeconds = CACurrentMediaTime();
-	return (uint32) ((timeInSeconds - _startTime) * 1000.0) - _timeSuspended;
+	return (uint32) ((timeInSeconds - _startTime) * 1000.0);
 }
 
 void OSystem_iOS7::delayMillis(uint msecs) {
diff --git a/backends/platform/ios7/ios7_osys_main.h b/backends/platform/ios7/ios7_osys_main.h
index f3a61a41774..b9e19702368 100644
--- a/backends/platform/ios7/ios7_osys_main.h
+++ b/backends/platform/ios7/ios7_osys_main.h
@@ -59,7 +59,6 @@ protected:
 	Audio::MixerImpl *_mixer;
 
 	CFTimeInterval _startTime;
-	uint32 _timeSuspended;
 
 	int _runningTasks;
 


Commit: 01106f01d643b6b646339f1c595cfae39f69ee46
    https://github.com/scummvm/scummvm/commit/01106f01d643b6b646339f1c595cfae39f69ee46
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-10-25T22:05:04+02:00

Commit Message:
IOS7: Enable HW keyboards without first enabling the soft keyboard

The soft keyboard is enabled by calling showKeyboard which will set
the inputView, which is a UITextField, to become the first responder.
This will trigger the software keyboard to pop up. The showKeyboard
function is either called by the GUI when clicking into an editable
box, by the engine when keyboard input is required or when the user
forces it to be shown by a gesture or pressing the on-screen control
button..

The keyboard handling above suits the software keyboard but no HW
keyboards since if the inputView is not the first responder no key
presses are registered. One can expect that key button presses on a
HW keyboard should be registered without enabling the soft keyboard.

Implement handling to enable the inputView when HW keyboards are
connected.

Changed paths:
    backends/platform/ios7/ios7_keyboard.h
    backends/platform/ios7/ios7_keyboard.mm
    backends/platform/ios7/ios7_video.mm


diff --git a/backends/platform/ios7/ios7_keyboard.h b/backends/platform/ios7/ios7_keyboard.h
index b5a7f583289..3e6f7c7930c 100644
--- a/backends/platform/ios7/ios7_keyboard.h
+++ b/backends/platform/ios7/ios7_keyboard.h
@@ -32,8 +32,6 @@
 	TextInputHandler *inputView;
 }
 
- at property BOOL hwKeyboardConnected;
-
 - (id)initWithFrame:(CGRect)frame;
 - (void)dealloc;
 - (UITextField *)inputView;
diff --git a/backends/platform/ios7/ios7_keyboard.mm b/backends/platform/ios7/ios7_keyboard.mm
index df108adc4ea..291f6c63940 100644
--- a/backends/platform/ios7/ios7_keyboard.mm
+++ b/backends/platform/ios7/ios7_keyboard.mm
@@ -22,6 +22,9 @@
 #include "backends/platform/ios7/ios7_keyboard.h"
 #include "common/keyboard.h"
 #include "common/config-manager.h"
+#ifdef __IPHONE_14_0
+#include <GameController/GameController.h>
+#endif
 
 @interface UITextInputTraits
 - (void)setAutocorrectionType:(int)type;
@@ -405,8 +408,6 @@
 	BOOL _keyboardVisible;
 }
 
- at synthesize hwKeyboardConnected;
-
 #if TARGET_OS_IOS
 - (void)resizeParentFrame:(NSNotification*)notification keyboardDidShow:(BOOL)didShow
 {
@@ -416,11 +417,11 @@
 
 	// Base the new frame size on the current parent frame size
 	CGRect newFrame = self.superview.frame;
-	if ([self hwKeyboardConnected]) {
-		if (ConfMan.getBool("keyboard_fn_bar")) {
+	if (@available(iOS 14.0, tvOS 14.0, *)) {
+		if (GCKeyboard.coalescedKeyboard != nil && ConfMan.getBool("keyboard_fn_bar")) {
 			newFrame.size.height += (inputView.inputAccessoryView.frame.size.height) * (didShow ? -1 : 1);
 		} else {
-			return;
+			newFrame.size.height += (keyboardFrame.size.height) * (didShow ? -1 : 1);
 		}
 	} else {
 		newFrame.size.height += (keyboardFrame.size.height) * (didShow ? -1 : 1);
@@ -454,6 +455,20 @@
 	[self resizeParentFrame:notification keyboardDidShow:NO];
 	_keyboardVisible = NO;
 }
+
+- (void)keyboardDidConnect:(NSNotification*)notification
+{
+	[inputView becomeFirstResponder];
+}
+
+- (void)keyboardDidDisconnect:(NSNotification*)notification
+{
+	if (@available(iOS 14.0, tvOS 14.0, *)) {
+		if (GCKeyboard.coalescedKeyboard == nil) {
+			[inputView endEditing:YES];
+		}
+	}
+}
 #endif
 
 - (id)initWithFrame:(CGRect)frame {
@@ -470,6 +485,17 @@
 	 name:UIKeyboardDidHideNotification
 	 object:nil];
 #endif
+	if (@available(iOS 14.0, tvOS 14.0, *)) {
+		[[NSNotificationCenter defaultCenter] addObserver:self
+		 selector:@selector(keyboardDidConnect:)
+		 name:GCKeyboardDidConnectNotification
+	     object:nil];
+
+		[[NSNotificationCenter defaultCenter] addObserver:self
+		 selector:@selector(keyboardDidDisconnect:)
+		 name:GCKeyboardDidDisconnectNotification
+	     object:nil];
+	}
 
 	inputDelegate = nil;
 	inputView = [[TextInputHandler alloc] initWithKeyboard:self];
@@ -478,6 +504,14 @@
 	inputView.keyboardType = UIKeyboardTypeDefault;
 	[inputView layoutIfNeeded];
 	_keyboardVisible = NO;
+
+	if (@available(iOS 14.0, tvOS 14.0, *)) {
+		// If already connected to a HW keyboard, start
+		// monitoring key presses
+		if (GCKeyboard.coalescedKeyboard != nil) {
+			[inputView becomeFirstResponder];
+		}
+	}
 	return self;
 }
 
@@ -522,6 +556,11 @@
 }
 
 - (void)hideKeyboard {
+	if (@available(iOS 14.0, tvOS 14.0, *)) {
+		if (GCKeyboard.coalescedKeyboard != nil) {
+			return;
+		}
+	}
 	[inputView endEditing:YES];
 }
 
diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm
index f857aaf910d..207f3e65842 100644
--- a/backends/platform/ios7/ios7_video.mm
+++ b/backends/platform/ios7/ios7_video.mm
@@ -578,17 +578,6 @@ bool iOS7_fetchEvent(InternalEvent *event) {
 #endif
 
 - (void)showKeyboard {
-	if (@available(iOS 14.0, tvOS 14.0, *)) {
-		// This will check if any hardware keyboard is connected, this also includes keyboards connected through Universal
-		// Control. If hardware keyboard is disconnected it might take some time before the software keyboard is shown again.
-		// This also happens in iOS system as well so it's not specific to ScummVM.
-		if (GCKeyboard.coalescedKeyboard != nil) {
-			[_keyboardView setHwKeyboardConnected:YES];
-		} else {
-			[_keyboardView setHwKeyboardConnected:NO];
-		}
-	}
-
 	[_keyboardView showKeyboard];
 #if TARGET_OS_IOS
 	[_toggleTouchModeButton setImage:[UIImage imageNamed:@"ic_action_keyboard"] forState:UIControlStateNormal];


Commit: eb601e86bb2bec616bbf48ec90a172fc309247d2
    https://github.com/scummvm/scummvm/commit/eb601e86bb2bec616bbf48ec90a172fc309247d2
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-10-25T22:05:04+02:00

Commit Message:
IOS7: Fix showing/hiding of inputAccessoryView

There is an option to show/hide the inputAccessoryView contataing
special buttons not present on the iOS system keyboard, nor the
Apple iPad Magic keyboard.

Make sure the parent frame size is resized properly depending on
the option setting and if HW keyboards are connected.

Changed paths:
    backends/platform/ios7/ios7_keyboard.mm
    backends/platform/ios7/ios7_options.mm


diff --git a/backends/platform/ios7/ios7_keyboard.mm b/backends/platform/ios7/ios7_keyboard.mm
index 291f6c63940..308fe56fa9b 100644
--- a/backends/platform/ios7/ios7_keyboard.mm
+++ b/backends/platform/ios7/ios7_keyboard.mm
@@ -138,7 +138,7 @@
 	scrollView.showsHorizontalScrollIndicator = false;
 	toolbar.autoresizingMask = UIViewAutoresizingNone;
 	[scrollView addSubview:toolbar];
-	self.inputAccessoryView = scrollView;
+	self.inputAccessoryView = nil;
 
 #endif
 	return self;
@@ -249,24 +249,21 @@
 }
 
 - (void)attachAccessoryView {
-	self.inputAccessoryView.hidden = NO;
-	// Alternatively we could add/remove instead of show/hide the inpute accessory view
-//	self.inputAccessoryView = scrollView;
-//	[self reloadInputViews];
 	// We need at least a width of 1024 pt for the toolbar. If we add more buttons this may need to be increased.
 	toolbar.frame = CGRectMake(0, 0, MAX(CGFloat(1024), [[UIScreen mainScreen] bounds].size.width), toolbar.frame.size.height);
 	toolbar.bounds = toolbar.frame;
 	toolbar.selectedItem = nil;
+	self.inputAccessoryView = toolbar;
 #if TARGET_OS_IOS
 	scrollView.contentSize = toolbar.frame.size;
+	self.inputAccessoryView = scrollView;
 #endif
+	[self reloadInputViews];
 }
 
 - (void)detachAccessoryView {
-	self.inputAccessoryView.hidden = YES;
-	// Alternatively we could add/remove instead of show/hide the inpute accessory view
-//	self.inputAccessoryView = nil;
-//	[self reloadInputViews];
+	self.inputAccessoryView = nil;
+	[self reloadInputViews];
 }
 
 - (void) setWantsPriority: (UIKeyCommand*) keyCommand {
@@ -406,6 +403,7 @@
 
 @implementation SoftKeyboard {
 	BOOL _keyboardVisible;
+	CGFloat _inputAccessoryHeight;
 }
 
 #if TARGET_OS_IOS
@@ -418,8 +416,15 @@
 	// Base the new frame size on the current parent frame size
 	CGRect newFrame = self.superview.frame;
 	if (@available(iOS 14.0, tvOS 14.0, *)) {
-		if (GCKeyboard.coalescedKeyboard != nil && ConfMan.getBool("keyboard_fn_bar")) {
-			newFrame.size.height += (inputView.inputAccessoryView.frame.size.height) * (didShow ? -1 : 1);
+		if (GCKeyboard.coalescedKeyboard != nil) {
+			if (didShow) {
+				// The inputAccessoryView is hidden by setting it to nil. Then when
+				// receving the UIKeyboardDidHideNotification the height will be 0.
+				// Remember the height of the inputAccessoryView when it's presented
+				// so the main frame can be resized back to the proper size.
+				_inputAccessoryHeight = inputView.inputAccessoryView.frame.size.height;
+			}
+			newFrame.size.height += (_inputAccessoryHeight) * (didShow ? -1 : 1);
 		} else {
 			newFrame.size.height += (keyboardFrame.size.height) * (didShow ? -1 : 1);
 		}
@@ -504,6 +509,7 @@
 	inputView.keyboardType = UIKeyboardTypeDefault;
 	[inputView layoutIfNeeded];
 	_keyboardVisible = NO;
+	_inputAccessoryHeight = 0.0f;
 
 	if (@available(iOS 14.0, tvOS 14.0, *)) {
 		// If already connected to a HW keyboard, start
@@ -552,12 +558,25 @@
 }
 
 - (void)showKeyboard {
+	if (@available(iOS 14.0, tvOS 14.0, *)) {
+		if ([inputView isFirstResponder] &&
+			GCKeyboard.coalescedKeyboard != nil) {
+			if (ConfMan.getBool("keyboard_fn_bar")) {
+				[inputView attachAccessoryView];
+			}
+			return;
+		}
+	}
 	[inputView becomeFirstResponder];
 }
 
 - (void)hideKeyboard {
 	if (@available(iOS 14.0, tvOS 14.0, *)) {
-		if (GCKeyboard.coalescedKeyboard != nil) {
+		if ([inputView isFirstResponder] &&
+			GCKeyboard.coalescedKeyboard != nil) {
+			if (!ConfMan.getBool("keyboard_fn_bar")) {
+				[inputView detachAccessoryView];
+			}
 			return;
 		}
 	}
diff --git a/backends/platform/ios7/ios7_options.mm b/backends/platform/ios7/ios7_options.mm
index fc89f4f60d7..1b311425a96 100644
--- a/backends/platform/ios7/ios7_options.mm
+++ b/backends/platform/ios7/ios7_options.mm
@@ -529,6 +529,10 @@ void OSystem_iOS7::applyBackendSettings() {
 #if TARGET_OS_IOS
 	applyOrientationSettings();
 	updateTouchMode();
+	if (isKeyboardShown()) {
+		setShowKeyboard(false);
+		setShowKeyboard(true);
+	}
 #endif
 }
 




More information about the Scummvm-git-logs mailing list