diff options
| author | lubomyr | 2017-01-30 22:35:40 +0200 | 
|---|---|---|
| committer | lubomyr | 2017-01-30 22:35:40 +0200 | 
| commit | 15acee29f19c845dc534d2c8af48a449ea1cd380 (patch) | |
| tree | 5dd92b665f9131a0903bbaf15c913dc63d5ddf90 | |
| parent | ca55163ea1daa6e322ef1ddf4615ad73b4634e0d (diff) | |
| download | scummvm-rg350-15acee29f19c845dc534d2c8af48a449ea1cd380.tar.gz scummvm-rg350-15acee29f19c845dc534d2c8af48a449ea1cd380.tar.bz2 scummvm-rg350-15acee29f19c845dc534d2c8af48a449ea1cd380.zip | |
ANDROIDSDL: implemented checkbox for change mouse mode in Options menu
| -rw-r--r-- | backends/platform/androidsdl/androidsdl-sdl.cpp | 33 | ||||
| -rw-r--r-- | backends/platform/androidsdl/androidsdl-sdl.h | 4 | ||||
| -rw-r--r-- | common/system.h | 8 | ||||
| -rw-r--r-- | gui/options.cpp | 41 | ||||
| -rw-r--r-- | gui/options.h | 16 | ||||
| -rw-r--r-- | gui/themes/scummclassic.zip | bin | 126739 -> 127241 bytes | |||
| -rw-r--r-- | gui/themes/scummclassic/classic_layout.stx | 8 | ||||
| -rw-r--r-- | gui/themes/scummclassic/classic_layout_lowres.stx | 8 | ||||
| -rw-r--r-- | gui/themes/scummmodern.zip | bin | 1646279 -> 1646781 bytes | |||
| -rw-r--r-- | gui/themes/scummmodern/scummmodern_layout.stx | 8 | ||||
| -rw-r--r-- | gui/themes/scummmodern/scummmodern_layout_lowres.stx | 8 | 
11 files changed, 134 insertions, 0 deletions
| diff --git a/backends/platform/androidsdl/androidsdl-sdl.cpp b/backends/platform/androidsdl/androidsdl-sdl.cpp index d04512475a..ab0c0524f1 100644 --- a/backends/platform/androidsdl/androidsdl-sdl.cpp +++ b/backends/platform/androidsdl/androidsdl-sdl.cpp @@ -27,6 +27,7 @@  #include "backends/platform/androidsdl/androidsdl-sdl.h"  #include "backends/events/androidsdl/androidsdl-events.h"  #include "backends/graphics/androidsdl/androidsdl-graphics.h" +#include <SDL_android.h>  void OSystem_ANDROIDSDL::initBackend() {  	// Create the backend custom managers @@ -42,7 +43,39 @@ void OSystem_ANDROIDSDL::initBackend() {  	if (!ConfMan.hasKey("gfx_mode"))  		ConfMan.set("gfx_mode", "2x"); +	 +	if (!ConfMan.hasKey("touchpad_mouse_mode")) { +		const bool enable = (SDL_ANDROID_GetMouseEmulationMode() == 0) ? false : true; +		ConfMan.setBool("touchpad_mouse_mode", enable); +	} else { +		touchpadMode(ConfMan.getBool("touchpad_mouse_mode")); +	}  	// Call parent implementation of this method  	OSystem_POSIX::initBackend();  } + +void OSystem_ANDROIDSDL::touchpadMode(bool enable) { +		if (enable) +			switchToRelativeMouseMode(); +		else +			switchToDirectMouseMode(); +} + +void OSystem_ANDROIDSDL::switchToDirectMouseMode() { +	SDL_ANDROID_SetMouseEmulationMode(0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); +} + +void OSystem_ANDROIDSDL::switchToRelativeMouseMode() { +	SDL_ANDROID_SetMouseEmulationMode(1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); +} + +void OSystem_ANDROIDSDL::setFeatureState(Feature f, bool enable) { +	switch (f) { +			case kFeatureTouchpadMode: +			touchpadMode(enable); +			break; +	} +	 +	OSystem_POSIX::setFeatureState(f, enable); +} diff --git a/backends/platform/androidsdl/androidsdl-sdl.h b/backends/platform/androidsdl/androidsdl-sdl.h index 6ebe5022eb..72d2a50093 100644 --- a/backends/platform/androidsdl/androidsdl-sdl.h +++ b/backends/platform/androidsdl/androidsdl-sdl.h @@ -28,6 +28,10 @@  class OSystem_ANDROIDSDL : public OSystem_POSIX {  public:  	virtual void initBackend(); +	virtual void setFeatureState(Feature f, bool enable); +	void touchpadMode(bool enable); +	void switchToDirectMouseMode(); +	void switchToRelativeMouseMode();  #ifdef ENABLE_KEYMAPPER  	// FIXME: This just calls parent methods, is it needed? diff --git a/common/system.h b/common/system.h index 41f217fc0b..5dd3f68bc0 100644 --- a/common/system.h +++ b/common/system.h @@ -337,6 +337,14 @@ public:  		 * This feature has no associated state.  		 */  		kFeatureOpenUrl +			 +#ifdef ANDROIDSDL +			/** +			* mouse emulation mode +			*/ +			, +		kFeatureTouchpadMode +#endif  	};  	/** diff --git a/gui/options.cpp b/gui/options.cpp index 371a949c35..ffce01fc1e 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -136,6 +136,10 @@ OptionsDialog::~OptionsDialog() {  }  void OptionsDialog::init() { +#ifdef ANDROIDSDL +	_enableAndroidSdlSettings = false; +	_touchpadCheckbox = 0; +#endif  	_enableGraphicSettings = false;  	_gfxPopUp = 0;  	_gfxPopUpDesc = 0; @@ -202,6 +206,14 @@ void OptionsDialog::build() {  		_guioptionsString = ConfMan.get("guioptions", _domain);  		_guioptions = parseGameGUIOptions(_guioptionsString);  	} +	 +#ifdef ANDROIDSDL +	// AndroidSDL options +	if (ConfMan.hasKey("touchpad_mouse_mode", _domain)) { +		bool touchpadState = ConfMan.getBool("touchpad_mouse_mode", _domain); +		_touchpadCheckbox->setState(touchpadState); +	} +#endif  	// Graphic options  	if (_fullscreenCheckbox) { @@ -380,6 +392,14 @@ void OptionsDialog::open() {  }  void OptionsDialog::apply() { +#ifdef ANDROIDSDL +	if (_enableAndroidSdlSettings) { +		if (ConfMan.getBool("touchpad_mouse_mode", _domain) != _touchpadCheckbox->getState()) { +			ConfMan.setBool("touchpad_mouse_mode", _touchpadCheckbox->getState(), _domain); +			g_system->setFeatureState(OSystem::kFeatureTouchpadMode, _touchpadCheckbox->getState()); +		} +	} +#endif  	// Graphic options  	bool graphicsModeChanged = false;  	if (_fullscreenCheckbox) { @@ -672,6 +692,10 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data  		Dialog::handleCommand(sender, cmd, data);  	}  } +	 +void OptionsDialog::setAndroidSdlSettingsState(bool enabled) { +	_enableAndroidSdlSettings = enabled; +}  void OptionsDialog::setGraphicSettingsState(bool enabled) {  	_enableGraphicSettings = enabled; @@ -798,6 +822,15 @@ void OptionsDialog::setSubtitleSettingsState(bool enabled) {  	_subSpeedSlider->setEnabled(ena);  	_subSpeedLabel->setEnabled(ena);  } +	 +#ifdef ANDROIDSDL +	void OptionsDialog::addAndroidSdlControls(GuiObject *boss, const Common::String &prefix) { +		// Touchpad Mouse mode +		_touchpadCheckbox = new CheckboxWidget(boss, prefix + "grTouchpadCheckbox", _("Touchpad mouse mode")); +		 +		_enableAndroidSdlSettings = true; +	} +#endif  void OptionsDialog::addGraphicControls(GuiObject *boss, const Common::String &prefix) {  	const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes(); @@ -1226,6 +1259,14 @@ void GlobalOptionsDialog::build() {  	// The tab widget  	TabWidget *tab = new TabWidget(this, "GlobalOptions.TabWidget"); +#ifdef ANDROIDSDL +	// +	// The control tab only for Android SDL platform +	// +	tab->addTab(_("Control")); +	addAndroidSdlControls(tab, "GlobalOptions_AndroidSdl."); +#endif +	  	//  	// 1) The graphics tab  	// diff --git a/gui/options.h b/gui/options.h index a6eebe5748..e6bb195b41 100644 --- a/gui/options.h +++ b/gui/options.h @@ -86,6 +86,9 @@ protected:  	virtual void clean();  	void rebuild(); +#ifdef ANDROIDSDL +	void addAndroidSdlControls(GuiObject *boss, const Common::String &prefix); +#endif  	void addGraphicControls(GuiObject *boss, const Common::String &prefix);  	void addAudioControls(GuiObject *boss, const Common::String &prefix);  	void addMIDIControls(GuiObject *boss, const Common::String &prefix); @@ -96,6 +99,9 @@ protected:  	void addSubtitleControls(GuiObject *boss, const Common::String &prefix, int maxSliderVal = 255);  	void addEngineControls(GuiObject *boss, const Common::String &prefix, const ExtraGuiOptions &engineOptions); +#ifdef ANDROIDSDL +	void setAndroidSdlSettingsState(bool enabled); +#endif  	void setGraphicSettingsState(bool enabled);  	void setAudioSettingsState(bool enabled);  	void setMIDISettingsState(bool enabled); @@ -112,6 +118,16 @@ protected:  	int _pathsTabId;  private: +	 +#ifdef ANDROIDSDL +	// +	// AndroidSDL controls +	// +	bool _enableAndroidSdlSettings; + +	CheckboxWidget *_touchpadCheckbox; +#endif +	  	//  	// Graphics controls  	// diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zipBinary files differ index 400b997b93..175a646fd6 100644 --- a/gui/themes/scummclassic.zip +++ b/gui/themes/scummclassic.zip diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx index b3100d4b92..d48f208714 100644 --- a/gui/themes/scummclassic/classic_layout.stx +++ b/gui/themes/scummclassic/classic_layout.stx @@ -237,6 +237,14 @@  			</layout>  		</layout>  	</dialog> +	 +	<dialog name = 'GlobalOptions_AndroidSdl' overlays = 'Dialog.GlobalOptions.TabWidget'> +		<layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> +			<widget name = 'grTouchpadCheckbox' +					type = 'Checkbox' +			/> +		</layout> +	</dialog>  	<dialog name = 'GlobalOptions_Graphics' overlays = 'Dialog.GlobalOptions.TabWidget'>  		<layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx index 7879e05a97..f58cf76e23 100644 --- a/gui/themes/scummclassic/classic_layout_lowres.stx +++ b/gui/themes/scummclassic/classic_layout_lowres.stx @@ -234,6 +234,14 @@  			</layout>  		</layout>  	</dialog> +	 +	<dialog name = 'GlobalOptions_AndroidSdl' overlays = 'Dialog.GlobalOptions.TabWidget'> +		<layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> +			<widget name = 'grTouchpadCheckbox' +					type = 'Checkbox' +			/> +		</layout> +	</dialog>  	<dialog name = 'GlobalOptions_Graphics' overlays = 'Dialog.GlobalOptions.TabWidget'>  		<layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zipBinary files differ index 673d67ed87..8eb1353e27 100644 --- a/gui/themes/scummmodern.zip +++ b/gui/themes/scummmodern.zip diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index 9cadc11e13..4ac032ac67 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -251,6 +251,14 @@  			</layout>  		</layout>  	</dialog> +	 +	<dialog name = 'GlobalOptions_AndroidSdl' overlays = 'Dialog.GlobalOptions.TabWidget'> +		<layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> +			<widget name = 'grTouchpadCheckbox' +					type = 'Checkbox' +			/> +		</layout> +	</dialog>  	<dialog name = 'GlobalOptions_Graphics' overlays = 'Dialog.GlobalOptions.TabWidget'>  		<layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx index 7ef5fc5ee1..f8e56f4083 100644 --- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx +++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx @@ -232,6 +232,14 @@  			</layout>  		</layout>  	</dialog> +	 +	<dialog name = 'GlobalOptions_AndroidSdl' overlays = 'Dialog.GlobalOptions.TabWidget'> +		<layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> +			<widget name = 'grTouchpadCheckbox' +					type = 'Checkbox' +			/> +		</layout> +	</dialog>  	<dialog name = 'GlobalOptions_Graphics' overlays = 'Dialog.GlobalOptions.TabWidget'>  		<layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'> | 
