IOS7: Implement port-specifc option widget
Include the newly added ios7_options implementation to the project. Change the file type to .mm which is Objective C++ to be able to use the @availble mechanism. Implement virtual functions and fix build errors in initial code. Also add help section for the tvOS port when building for tvOS. Add ios7_options to POTFILES to get automatic translation on the help section.
This commit is contained in:
parent
61bbe1187b
commit
a9e44384e9
5 changed files with 67 additions and 24 deletions
|
@ -19,12 +19,18 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Disable symbol overrides so that we can use system headers.
|
||||||
|
#define FORBIDDEN_SYMBOL_ALLOW_ALL
|
||||||
|
|
||||||
#include "gui/gui-manager.h"
|
#include "gui/gui-manager.h"
|
||||||
|
#include "gui/message.h"
|
||||||
#include "gui/ThemeEval.h"
|
#include "gui/ThemeEval.h"
|
||||||
#include "gui/widget.h"
|
#include "gui/widget.h"
|
||||||
|
|
||||||
#include "common/translation.h"
|
#include "common/translation.h"
|
||||||
|
#include "backends/platform/ios7/ios7_osys_main.h"
|
||||||
|
|
||||||
|
#include <TargetConditionals.h>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kHelpCmd = 'Help',
|
kHelpCmd = 'Help',
|
||||||
|
@ -51,9 +57,6 @@ private:
|
||||||
GUI::CheckboxWidget *_clickAndDragdCheckbox;
|
GUI::CheckboxWidget *_clickAndDragdCheckbox;
|
||||||
|
|
||||||
bool _enabled;
|
bool _enabled;
|
||||||
|
|
||||||
uint32 loadTouchMode(const Common::String &setting, bool acceptDefault, uint32 defaultValue);
|
|
||||||
void saveTouchMode(const Common::String &setting, uint32 touchMode);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IOS7OptionsWidget::IOS7OptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain) :
|
IOS7OptionsWidget::IOS7OptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain) :
|
||||||
|
@ -61,11 +64,15 @@ IOS7OptionsWidget::IOS7OptionsWidget(GuiObject *boss, const Common::String &name
|
||||||
|
|
||||||
const bool inAppDomain = domain.equalsIgnoreCase(Common::ConfigManager::kApplicationDomain);
|
const bool inAppDomain = domain.equalsIgnoreCase(Common::ConfigManager::kApplicationDomain);
|
||||||
|
|
||||||
_onscreenCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "IOS7OptionsDialog.OnScreenControl", _("Show On-screen control"));
|
_onscreenCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "IOS7OptionsDialog.OnScreenControl", _("Show On-screen control (iOS 15 and later)"));
|
||||||
_touchpadCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "IOS7OptionsDialog.TouchpadMouseMode", _("Touchpad mouse mode"));
|
_touchpadCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "IOS7OptionsDialog.TouchpadMouseMode", _("Touchpad mouse mode"));
|
||||||
_clickAndDragdCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "IOS7OptionsDialog.ClickAndDragMode", _("Mouse-click-and-drag mode"));
|
_clickAndDragdCheckbox = new GUI::CheckboxWidget(widgetsBoss(), "IOS7OptionsDialog.ClickAndDragMode", _("Mouse-click-and-drag mode"));
|
||||||
|
|
||||||
new GUI::ButtonWidget(widgetsBoss(), "IOS7OptionsDialog.ControlsHelp", _("Controls Help"), Common::U32String(), kHelpCmd);
|
new GUI::ButtonWidget(widgetsBoss(), "IOS7OptionsDialog.ControlsHelp", _("Controls Help"), Common::U32String(), kHelpCmd);
|
||||||
|
|
||||||
|
// setEnabled is normally only called from the EditGameDialog, but some options (OnScreenControl)
|
||||||
|
// should be disabled in all domains if system is running a lower version of iOS than 15.0.
|
||||||
|
setEnabled(_enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
IOS7OptionsWidget::~IOS7OptionsWidget() {
|
IOS7OptionsWidget::~IOS7OptionsWidget() {
|
||||||
|
@ -90,18 +97,35 @@ void IOS7OptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::Stri
|
||||||
void IOS7OptionsWidget::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
|
void IOS7OptionsWidget::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case kHelpCmd: {
|
case kHelpCmd: {
|
||||||
GUI::MessageDialog help(_(
|
GUI::MessageDialog help(
|
||||||
"Gestures and controls:
|
#if TARGET_OS_IOS
|
||||||
|
_("Gestures and controls:\n"
|
||||||
One finger tap: Left mouse click
|
"\n"
|
||||||
Two finger tap: Right mouse click
|
"One finger tap: Left mouse click\n"
|
||||||
Two finger double tap: ESC
|
"Two finger tap: Right mouse click\n"
|
||||||
Two finger swipe (bottom to top): Toggles Click and drag mode
|
"Two finger double tap: ESC\n"
|
||||||
Two finger swipe (left to right): Toggles between touch direct mode and touchpad mode
|
"Two finger swipe (bottom to top): Toggles Click and drag mode\n"
|
||||||
Two finger swipe (top to bottom): Global Main Menu
|
"Two finger swipe (left to right): Toggles between touch direct mode and touchpad mode\n"
|
||||||
Three finger swipe: Arrow keys
|
"Two finger swipe (right to left): Shows/hides on-screen controls\n"
|
||||||
Pinch gesture: Enables/disables keyboard
|
"Two finger swipe (top to bottom): Global Main Menu\n"
|
||||||
Keyboard spacebar: Pause"));
|
"Three finger swipe: Arrow keys\n"
|
||||||
|
"Pinch gesture: Enables/disables keyboard\n"
|
||||||
|
"Keyboard spacebar: Pause"),
|
||||||
|
#else // TVOS
|
||||||
|
_("Using the Apple TV remote control:\n"
|
||||||
|
"\n"
|
||||||
|
"Press Touch area: Left mouse click\n"
|
||||||
|
"Press Play/Pause button: Right mouse click\n"
|
||||||
|
"Press Back/Menu button in game: Global Main menu\n"
|
||||||
|
"Press Back/Menu button in launcher: Apple TV Home\n"
|
||||||
|
"Press and hold Play/Pause button: Show keyboard with extra keys\n"
|
||||||
|
"Touch (not press) on top of Touch area: Up arrow key\n"
|
||||||
|
"Touch (not press) on left of Touch area: Left arrow key\n"
|
||||||
|
"Touch (not press) on right of Touch area: Right arrow key\n"
|
||||||
|
"Touch (not press) on bottom of Touch area: Down arrow key\n"
|
||||||
|
"Keyboard spacebar: Pause"),
|
||||||
|
#endif
|
||||||
|
Common::U32String(_("Close")), Common::U32String(), Graphics::kTextAlignLeft);
|
||||||
|
|
||||||
help.runModal();
|
help.runModal();
|
||||||
break;
|
break;
|
||||||
|
@ -134,24 +158,37 @@ bool IOS7OptionsWidget::save() {
|
||||||
bool IOS7OptionsWidget::hasKeys() {
|
bool IOS7OptionsWidget::hasKeys() {
|
||||||
return ConfMan.hasKey("onscreen_control", _domain) ||
|
return ConfMan.hasKey("onscreen_control", _domain) ||
|
||||||
ConfMan.hasKey("touchpad_mode", _domain) ||
|
ConfMan.hasKey("touchpad_mode", _domain) ||
|
||||||
ConfMan.hasKey("clickanddrag_mode", _domain));
|
ConfMan.hasKey("clickanddrag_mode", _domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IOS7OptionsWidget::setEnabled(bool e) {
|
void IOS7OptionsWidget::setEnabled(bool e) {
|
||||||
_enabled = e;
|
_enabled = e;
|
||||||
|
|
||||||
_onscreenCheckbox->setEnabled(e);
|
#if TARGET_OS_IOS && defined (__IPHONE_15_0)
|
||||||
|
// On-screen controls (virtual controller is supported in iOS 15 and later)
|
||||||
|
if (@available(iOS 15.0, *)) {
|
||||||
|
_onscreenCheckbox->setEnabled(e);
|
||||||
|
} else {
|
||||||
|
_onscreenCheckbox->setEnabled(false);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
_onscreenCheckbox->setEnabled(false);
|
||||||
|
#endif
|
||||||
_touchpadCheckbox->setEnabled(e);
|
_touchpadCheckbox->setEnabled(e);
|
||||||
_clickAndDragdCheckbox->setEnabled(e);
|
_clickAndDragdCheckbox->setEnabled(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GUI::OptionsContainerWidget *OSystem_iOS7::buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const {
|
GUI::OptionsContainerWidget *OSystem_iOS7::buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const {
|
||||||
return new IOS7OptionsWidget(boss, name, target);
|
return new IOS7OptionsWidget(boss, name, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OSystem_iOS7::registerDefaultSettings(const Common::String &target) const {
|
void OSystem_iOS7::registerDefaultSettings(const Common::String &target) const {
|
||||||
ConfMan.registerDefault("onscreen_control", true);
|
ConfMan.registerDefault("onscreen_control", false);
|
||||||
ConfMan.registerDefault("touchpad_mode", true);
|
ConfMan.registerDefault("touchpad_mode", !iOS7_isBigDevice());
|
||||||
ConfMan.registerDefault("clickanddrag_mode", false);
|
ConfMan.registerDefault("clickanddrag_mode", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OSystem_iOS7::applyBackendSettings() {
|
||||||
|
_touchpadModeEnabled = ConfMan.getBool("touchpad_mode");
|
||||||
|
_mouseClickAndDragEnabled = ConfMan.getBool("clickanddrag_mode");
|
||||||
|
}
|
|
@ -87,12 +87,13 @@ public:
|
||||||
OSystem_iOS7::OSystem_iOS7() :
|
OSystem_iOS7::OSystem_iOS7() :
|
||||||
_mixer(NULL), _lastMouseTap(0), _queuedEventTime(0),
|
_mixer(NULL), _lastMouseTap(0), _queuedEventTime(0),
|
||||||
_mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0),
|
_mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0),
|
||||||
_screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false),
|
_screenOrientation(kScreenOrientationFlippedLandscape),
|
||||||
_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false),
|
_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false),
|
||||||
_mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0),
|
_mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0),
|
||||||
_mouseCursorPaletteEnabled(false), _gfxTransactionError(kTransactionSuccess) {
|
_mouseCursorPaletteEnabled(false), _gfxTransactionError(kTransactionSuccess) {
|
||||||
_queuedInputEvent.type = Common::EVENT_INVALID;
|
_queuedInputEvent.type = Common::EVENT_INVALID;
|
||||||
_touchpadModeEnabled = !iOS7_isBigDevice();
|
_touchpadModeEnabled = ConfMan.getBool("touchpad_mode");
|
||||||
|
_mouseClickAndDragEnabled = ConfMan.getBool("clickanddrag_mode");
|
||||||
|
|
||||||
_chrootBasePath = iOS7_getDocumentsDir();
|
_chrootBasePath = iOS7_getDocumentsDir();
|
||||||
ChRootFilesystemFactory *chFsFactory = new ChRootFilesystemFactory(_chrootBasePath);
|
ChRootFilesystemFactory *chFsFactory = new ChRootFilesystemFactory(_chrootBasePath);
|
||||||
|
@ -300,7 +301,6 @@ void OSystem_iOS7::delayMillis(uint msecs) {
|
||||||
usleep(msecs * 1000);
|
usleep(msecs * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OSystem_iOS7::setTimerCallback(TimerProc callback, int interval) {
|
void OSystem_iOS7::setTimerCallback(TimerProc callback, int interval) {
|
||||||
//printf("setTimerCallback()\n");
|
//printf("setTimerCallback()\n");
|
||||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||||
|
|
|
@ -211,6 +211,10 @@ public:
|
||||||
|
|
||||||
virtual Common::String getDefaultLogFileName() override { return Common::String("/scummvm.log"); }
|
virtual Common::String getDefaultLogFileName() override { return Common::String("/scummvm.log"); }
|
||||||
|
|
||||||
|
virtual GUI::OptionsContainerWidget* buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
|
||||||
|
virtual void applyBackendSettings() override;
|
||||||
|
virtual void registerDefaultSettings(const Common::String &target) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initVideoContext();
|
void initVideoContext();
|
||||||
void updateOutputSurface();
|
void updateOutputSurface();
|
||||||
|
|
|
@ -8,6 +8,7 @@ MODULE_OBJS := \
|
||||||
ios7_osys_misc.o \
|
ios7_osys_misc.o \
|
||||||
ios7_misc.o \
|
ios7_misc.o \
|
||||||
ios7_main.o \
|
ios7_main.o \
|
||||||
|
ios7_options.o \
|
||||||
ios7_video.o \
|
ios7_video.o \
|
||||||
ios7_keyboard.o \
|
ios7_keyboard.o \
|
||||||
ios7_scummvm_view_controller.o \
|
ios7_scummvm_view_controller.o \
|
||||||
|
|
|
@ -97,6 +97,7 @@ backends/platform/3ds/osystem-events.cpp
|
||||||
backends/platform/android/options.cpp
|
backends/platform/android/options.cpp
|
||||||
backends/platform/ds/ds-graphics.cpp
|
backends/platform/ds/ds-graphics.cpp
|
||||||
backends/platform/ds/osystem_ds.cpp
|
backends/platform/ds/osystem_ds.cpp
|
||||||
|
backends/platform/ios7/ios7_options.mm
|
||||||
backends/platform/ios7/ios7_osys_events.cpp
|
backends/platform/ios7/ios7_osys_events.cpp
|
||||||
backends/platform/ios7/ios7_osys_main.cpp
|
backends/platform/ios7/ios7_osys_main.cpp
|
||||||
backends/platform/iphone/osys_events.cpp
|
backends/platform/iphone/osys_events.cpp
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue