[Scummvm-git-logs] scummvm master -> 1d63f4f0af42688845ff6ef63e8a68c6e65b6cc9

larsamannen noreply at scummvm.org
Mon Jul 17 19:42:30 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:
3c85d6a7a6 IOS7: Add on-screen opacity to iOS backend options
77244e516f IOS7: Set virtual gamepad controller properties
1d63f4f0af IOS7: Update virtual controller on orientation changes


Commit: 3c85d6a7a635fed274bd9c3610c988779b610377
    https://github.com/scummvm/scummvm/commit/3c85d6a7a635fed274bd9c3610c988779b610377
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-07-17T21:42:25+02:00

Commit Message:
IOS7: Add on-screen opacity to iOS backend options

Let the user configure the opacity for the on-screen controls using
a slider with allowed values from 1 to 10, where 10 is 100%.

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


diff --git a/backends/platform/ios7/ios7_options.mm b/backends/platform/ios7/ios7_options.mm
index 03093c85c88..c6709ed437b 100644
--- a/backends/platform/ios7/ios7_options.mm
+++ b/backends/platform/ios7/ios7_options.mm
@@ -35,6 +35,7 @@
 
 enum {
 	kHelpCmd = 'Help',
+	kOnscreenOpacityChanged = 'osoc',
 };
 
 class IOS7OptionsWidget final : public GUI::OptionsContainerWidget {
@@ -58,6 +59,9 @@ private:
 #endif
 
 	GUI::CheckboxWidget *_onscreenCheckbox;
+	GUI::StaticTextWidget *_onscreenOpacityDesc;
+	GUI::SliderWidget *_onscreenOpacitySlider;
+	GUI::StaticTextWidget *_onscreenOpacityLabel;
 	GUI::CheckboxWidget *_touchpadCheckbox;
 	GUI::CheckboxWidget *_clickAndDragCheckbox;
 	GUI::CheckboxWidget *_keyboardFnBarCheckbox;
@@ -77,6 +81,11 @@ IOS7OptionsWidget::IOS7OptionsWidget(GuiObject *boss, const Common::String &name
 	const bool inAppDomain = domain.equalsIgnoreCase(Common::ConfigManager::kApplicationDomain);
 
 	_onscreenCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "IOS7OptionsDialog.OnScreenControl", _("Show On-screen control (iOS 15 and later)"));
+	_onscreenOpacityDesc = new GUI::StaticTextWidget(widgetsBoss(), "IOS7OptionsDialog.OnScreenControlOpacity", _("Control opacity"));
+	_onscreenOpacitySlider = new GUI::SliderWidget(widgetsBoss(), "IOS7OptionsDialog.OnScreenControlOpacitySlider", _("Control opacity"), kOnscreenOpacityChanged);
+	_onscreenOpacityLabel = new GUI::StaticTextWidget(widgetsBoss(), "IOS7OptionsDialog.OnScreenControlOpacityLabel", Common::U32String(" "), Common::U32String(), GUI::ThemeEngine::kFontStyleBold, Common::UNK_LANG, false);
+	_onscreenOpacitySlider->setMinValue(1);
+	_onscreenOpacitySlider->setMaxValue(10);
 	_touchpadCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "IOS7OptionsDialog.TouchpadMouseMode", _("Touchpad mouse mode"));
 	_clickAndDragCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "IOS7OptionsDialog.ClickAndDragMode", _("Mouse-click-and-drag mode"));
 	_keyboardFnBarCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "IOS7OptionsDialog.KeyboardFunctionBar", _("Show keyboard function bar"));
@@ -123,6 +132,12 @@ void IOS7OptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::Stri
 	        .addLayout(GUI::ThemeLayout::kLayoutVertical)
 	            .addPadding(0, 0, 0, 0)
 	            .addWidget("OnScreenControl", "Checkbox")
+	        .addLayout(GUI::ThemeLayout::kLayoutHorizontal)
+	            .addPadding(0, 0, 0, 0)
+	            .addWidget("OnScreenControlOpacity", "OptionsLabel")
+	            .addWidget("OnScreenControlOpacitySlider", "Slider")
+	            .addWidget("OnScreenControlOpacityLabel", "OptionsLabel")
+	        .closeLayout()
 	            .addWidget("TouchpadMouseMode", "Checkbox")
 	            .addWidget("ClickAndDragMode", "Checkbox")
 	            .addWidget("KeyboardFunctionBar", "Checkbox")
@@ -184,6 +199,12 @@ void IOS7OptionsWidget::handleCommand(GUI::CommandSender *sender, uint32 cmd, ui
 		help.runModal();
 		break;
 	}
+	case kOnscreenOpacityChanged: {
+		const int newValue = _onscreenOpacitySlider->getValue();
+		_onscreenOpacityLabel->setValue(newValue);
+		_onscreenOpacityLabel->markAsDirty();
+		break;
+	}
 	default:
 		GUI::OptionsContainerWidget::handleCommand(sender, cmd, data);
 	}
@@ -230,6 +251,8 @@ void IOS7OptionsWidget::load() {
 	const bool inAppDomain = _domain.equalsIgnoreCase(Common::ConfigManager::kApplicationDomain);
 
 	_onscreenCheckbox->setState(ConfMan.getBool("onscreen_control", _domain));
+	_onscreenOpacitySlider->setValue(ConfMan.getInt("onscreen_control_opacity", _domain));
+	_onscreenOpacityLabel->setValue(_onscreenOpacitySlider->getValue());
 	_touchpadCheckbox->setState(ConfMan.getBool("touchpad_mode", _domain));
 	_clickAndDragCheckbox->setState(ConfMan.getBool("clickanddrag_mode", _domain));
 	_keyboardFnBarCheckbox->setState(ConfMan.getBool("keyboard_fn_bar", _domain));
@@ -247,6 +270,7 @@ bool IOS7OptionsWidget::save() {
 
 	if (_enabled) {
 		ConfMan.setBool("onscreen_control", _onscreenCheckbox->getState(), _domain);
+		ConfMan.setInt("onscreen_control_opacity", _onscreenOpacitySlider->getValue(), _domain);
 		ConfMan.setBool("touchpad_mode", _touchpadCheckbox->getState(), _domain);
 		ConfMan.setBool("clickanddrag_mode", _clickAndDragCheckbox->getState(), _domain);
 		ConfMan.setBool("keyboard_fn_bar", _keyboardFnBarCheckbox->getState(), _domain);
@@ -259,6 +283,7 @@ bool IOS7OptionsWidget::save() {
 #endif
 	} else {
 		ConfMan.removeKey("onscreen_control", _domain);
+		ConfMan.removeKey("onscreen_control_opacity", _domain);
 		ConfMan.removeKey("touchpad_mode", _domain);
 		ConfMan.removeKey("clickanddrag_mode", _domain);
 		ConfMan.removeKey("keyboard_fn_bar", _domain);
@@ -276,6 +301,7 @@ bool IOS7OptionsWidget::save() {
 
 bool IOS7OptionsWidget::hasKeys() {
 	bool hasKeys = ConfMan.hasKey("onscreen_control", _domain) ||
+	ConfMan.hasKey("onscreen_control_opacity", _domain) ||
 	ConfMan.hasKey("touchpad_mode", _domain) ||
 	ConfMan.hasKey("clickanddrag_mode", _domain);
 
@@ -296,11 +322,20 @@ void IOS7OptionsWidget::setEnabled(bool e) {
 	// On-screen controls (virtual controller is supported in iOS 15 and later)
 	if (@available(iOS 15.0, *)) {
 		_onscreenCheckbox->setEnabled(e);
+		_onscreenOpacityDesc->setEnabled(e);
+		_onscreenOpacitySlider->setEnabled(e);
+		_onscreenOpacityLabel->setEnabled(e);
 	} else {
 		_onscreenCheckbox->setEnabled(false);
+		_onscreenOpacityDesc->setEnabled(false);
+		_onscreenOpacitySlider->setEnabled(false);
+		_onscreenOpacityLabel->setEnabled(false);
 	}
 #else
 	_onscreenCheckbox->setEnabled(false);
+	_onscreenOpacityDesc->setEnabled(false);
+	_onscreenOpacitySlider->setEnabled(false);
+	_onscreenOpacityLabel->setEnabled(false);
 #endif
 #if TARGET_OS_IOS
 	_touchpadCheckbox->setEnabled(e);
@@ -326,6 +361,7 @@ GUI::OptionsContainerWidget *OSystem_iOS7::buildBackendOptionsWidget(GUI::GuiObj
 
 void OSystem_iOS7::registerDefaultSettings(const Common::String &target) const {
 	ConfMan.registerDefault("onscreen_control", false);
+	ConfMan.registerDefault("onscreen_control_opacity", 6);
 	ConfMan.registerDefault("touchpad_mode", !iOS7_isBigDevice());
 	ConfMan.registerDefault("clickanddrag_mode", false);
 	ConfMan.registerDefault("keyboard_fn_bar", true);


Commit: 77244e516f478b6524835094c6ab1304d8ead8f1
    https://github.com/scummvm/scummvm/commit/77244e516f478b6524835094c6ab1304d8ead8f1
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-07-17T21:42:25+02:00

Commit Message:
IOS7: Set virtual gamepad controller properties

Utilize an undocumented way to find the GCControllerView by drilling
down the subviews. When found, set the GCControllerView frame size
to full screen size to make sure all buttons do fit within the
screen boundries. This is important to do on devices with safe areas
like iPhones with the sensor panel.

Set the GCControllerView alpha to the user specified value.

Changed paths:
    backends/platform/ios7/ios7_gamepad_controller.mm


diff --git a/backends/platform/ios7/ios7_gamepad_controller.mm b/backends/platform/ios7/ios7_gamepad_controller.mm
index f64410d89fd..20c1776bce1 100644
--- a/backends/platform/ios7/ios7_gamepad_controller.mm
+++ b/backends/platform/ios7/ios7_gamepad_controller.mm
@@ -23,6 +23,7 @@
 #define FORBIDDEN_SYMBOL_ALLOW_ALL
 
 #include "common/events.h"
+#include "common/config-manager.h"
 #include "backends/platform/ios7/ios7_gamepad_controller.h"
 #include "backends/platform/ios7/ios7_video.h"
 #include <GameController/GameController.h>
@@ -63,13 +64,48 @@
 	return self;
 }
 
+// Undocumented way to retreive the GCControllerView.
+// Drill down the layer structure to get the GCControllerView.
+// The view layers for iPhones are:
+// - TransitionView
+//   - DropShadowView
+//     - LayoutContainerView
+//       - ContainerView
+// iPads have an additional layer under the ContainerView
+- (BOOL)setGCControllerViewProperties:(NSArray<UIView*>*)subviews {
+	BOOL stop = NO;
+	for (UIView *view in subviews) {
+		if ([[view classForCoder] isEqual:NSClassFromString(@"GCControllerView")]) {
+			// Set the virtual controller frame to full screen.
+			// Else buttons can be placed partly out of the frame
+			// due to the iPhoneView frame is adjusted according
+			// to the safe area insets.
+			// Also set the frame alpha to the user specified value
+			// to make the virtual controller more transparent
+			view.alpha = ((float)ConfMan.getInt("onscreen_control_opacity") / 10.0);
+			view.frame = [[UIScreen mainScreen] bounds];
+			stop = YES;
+		} else {
+			// Keep drilling
+			stop = [self setGCControllerViewProperties:view.subviews];
+		}
+		if (stop) {
+			break;
+		}
+	}
+	return stop;
+}
+
 - (void)virtualController:(bool)connect {
 #if TARGET_OS_IOS
 #ifdef __IPHONE_15_0
 	if (@available(iOS 15.0, *)) {
-		if (connect && ![self isConnected]) {
-			[_virtualController connectWithReplyHandler:^(NSError * _Nullable error) { }];		}
-		else if (!connect && [self isConnected]) {
+		if (connect) {
+			[_virtualController connectWithReplyHandler:^(NSError * _Nullable error) {
+				[self setGCControllerViewProperties:[[[UIApplication sharedApplication] keyWindow] subviews]];
+			}];
+		}
+		else {
 			[_virtualController disconnect];
 			[self setIsConnected:NO];
 		}


Commit: 1d63f4f0af42688845ff6ef63e8a68c6e65b6cc9
    https://github.com/scummvm/scummvm/commit/1d63f4f0af42688845ff6ef63e8a68c6e65b6cc9
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-07-17T21:42:25+02:00

Commit Message:
IOS7: Update virtual controller on orientation changes

The virtual controller layout is not updated properly on
orientation changes. Buttons can be placed outside the screen.
Make sure to set the GCControllerView properties on orientation
changes by connecting the virtual controller based on the
user settings.

On iPhones the virtual game controller buttons does not fit
within the screen borders in portrait mode. Disconnect the
virtual controller on iPhones when changing orientation to
portrait mode.

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


diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm
index 5ff35258db3..9c9a03d585b 100644
--- a/backends/platform/ios7/ios7_video.mm
+++ b/backends/platform/ios7/ios7_video.mm
@@ -23,6 +23,7 @@
 #define FORBIDDEN_SYMBOL_ALLOW_ALL
 
 #include "common/events.h"
+#include "common/config-manager.h"
 #include "backends/platform/ios7/ios7_video.h"
 #include "backends/platform/ios7/ios7_touch_controller.h"
 #include "backends/platform/ios7/ios7_mouse_controller.h"
@@ -331,6 +332,18 @@ bool iOS7_fetchEvent(InternalEvent *event) {
 	}
 
 	[self adjustViewFrameForSafeArea];
+#if TARGET_OS_IOS
+	// The virtual controller does not fit in portrait orientation on iPhones
+	// Make sure to disconnect the virtual controller in those cases
+	if (!iOS7_isBigDevice() &&
+		(_currentOrientation == UIInterfaceOrientationPortrait ||
+		 _currentOrientation == UIInterfaceOrientationPortraitUpsideDown)) {
+		[self virtualController:false];
+	} else {
+		// Connect or disconnect the virtual controller
+		[self virtualController:ConfMan.getBool("onscreen_control")];
+	}
+#endif
 }
 
 #ifndef __has_builtin




More information about the Scummvm-git-logs mailing list