diff options
Diffstat (limited to 'backends/platform/sdl')
| -rw-r--r-- | backends/platform/sdl/amigaos/amigaos-main.cpp | 35 | ||||
| -rw-r--r-- | backends/platform/sdl/macosx/macosx.cpp | 27 | ||||
| -rw-r--r-- | backends/platform/sdl/macosx/macosx.h | 10 | ||||
| -rw-r--r-- | backends/platform/sdl/macosx/macosx_wrapper.h | 31 | ||||
| -rw-r--r-- | backends/platform/sdl/macosx/macosx_wrapper.mm | 48 | ||||
| -rw-r--r-- | backends/platform/sdl/module.mk | 1 | ||||
| -rw-r--r-- | backends/platform/sdl/posix/posix-main.cpp | 2 | ||||
| -rw-r--r-- | backends/platform/sdl/posix/posix.cpp | 82 | ||||
| -rw-r--r-- | backends/platform/sdl/posix/posix.h | 8 | ||||
| -rw-r--r-- | backends/platform/sdl/sdl-sys.h | 131 | ||||
| -rw-r--r-- | backends/platform/sdl/sdl-window.cpp | 2 | ||||
| -rw-r--r-- | backends/platform/sdl/sdl-window.h | 4 | ||||
| -rw-r--r-- | backends/platform/sdl/sdl.cpp | 84 | ||||
| -rw-r--r-- | backends/platform/sdl/sdl.h | 15 | ||||
| -rw-r--r-- | backends/platform/sdl/win32/win32.cpp | 23 | ||||
| -rw-r--r-- | backends/platform/sdl/win32/win32.h | 6 | 
16 files changed, 489 insertions, 20 deletions
| diff --git a/backends/platform/sdl/amigaos/amigaos-main.cpp b/backends/platform/sdl/amigaos/amigaos-main.cpp index 65da6bbf85..7bbf8d1fff 100644 --- a/backends/platform/sdl/amigaos/amigaos-main.cpp +++ b/backends/platform/sdl/amigaos/amigaos-main.cpp @@ -24,13 +24,44 @@  #if defined(__amigaos4__) +#include "backends/fs/amigaos4/amigaos4-fs.h"  #include "backends/platform/sdl/amigaos/amigaos.h"  #include "backends/plugins/sdl/sdl-provider.h"  #include "base/main.h"  int main(int argc, char *argv[]) { -	// Set up a stack cookie to avoid crashes due to too few stack set by users  +	// The following will gather the application name and add the install path +	// to a variable in AmigaOS4's ENV(ARC) system. It will be placed in AppPaths +	// so that ScummVM can become AmiUpdate aware +	const char *const appname = "ScummVM"; + +	BPTR lock; +	APTR oldwin; + +	// Obtain a lock to the home directory +	if ((lock = IDOS->GetProgramDir())) { +		TEXT progpath[2048]; +		TEXT apppath[1024] = "AppPaths"; + +		if (IDOS->DevNameFromLock(lock, +			progpath, +			sizeof(progpath), +			DN_FULLPATH)) { + +			// Stop any "Insert volume..." type requesters +			oldwin = IDOS->SetProcWindow((APTR)-1); + +			// Finally, set the variable to the path the executable was run from +			IDOS->AddPart( apppath, appname, 1024); +			IDOS->SetVar( apppath, progpath, -1, GVF_GLOBAL_ONLY|GVF_SAVE_VAR ); + +			// Turn system requesters back on +			IDOS->SetProcWindow( oldwin ); +		} +	} + +	// Set up a stack cookie to avoid crashes from a stack set too low  	static const char *stack_cookie __attribute__((used)) = "$STACK: 600000";  	// Create our OSystem instance @@ -44,7 +75,7 @@ int main(int argc, char *argv[]) {  	PluginManager::instance().addPluginProvider(new SDLPluginProvider());  #endif -	// Invoke the actual ScummVM main entry point: +	// Invoke the actual ScummVM main entry point  	int res = scummvm_main(argc, argv);  	// Free OSystem diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 38a2d7441c..e90d459e67 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -27,11 +27,13 @@  #ifdef MACOSX -#include "backends/platform/sdl/macosx/macosx.h" +#include "backends/audiocd/macosx/macosx-audiocd.h"  #include "backends/mixer/doublebuffersdl/doublebuffersdl-mixer.h"  #include "backends/platform/sdl/macosx/appmenu_osx.h" +#include "backends/platform/sdl/macosx/macosx.h"  #include "backends/updates/macosx/macosx-updates.h"  #include "backends/taskbar/macosx/macosx-taskbar.h" +#include "backends/platform/sdl/macosx/macosx_wrapper.h"  #include "common/archive.h"  #include "common/config-manager.h" @@ -54,7 +56,7 @@ void OSystem_MacOSX::init() {  	// Initialize taskbar manager  	_taskbarManager = new MacOSXTaskbarManager();  #endif -	 +  	// Invoke parent implementation of this method  	OSystem_POSIX::init();  } @@ -105,7 +107,7 @@ void OSystem_MacOSX::addSysArchivesToSearchSet(Common::SearchSet &s, int priorit  }  bool OSystem_MacOSX::hasFeature(Feature f) { -	if (f == kFeatureDisplayLogFile) +	if (f == kFeatureDisplayLogFile || f == kFeatureClipboardSupport || f == kFeatureOpenUrl)  		return true;  	return OSystem_POSIX::hasFeature(f);  } @@ -123,6 +125,21 @@ bool OSystem_MacOSX::displayLogFile() {  	return err != noErr;  } +bool OSystem_MacOSX::hasTextInClipboard() { +	return hasTextInClipboardMacOSX(); +} + +Common::String OSystem_MacOSX::getTextFromClipboard() { +	return getTextFromClipboardMacOSX(); +} + +bool OSystem_MacOSX::openUrl(const Common::String &url) { +	CFURLRef urlRef = CFURLCreateWithBytes (NULL, (UInt8*)url.c_str(), url.size(), kCFStringEncodingASCII, NULL); +	OSStatus err = LSOpenCFURLRef(urlRef, NULL); +	CFRelease(urlRef); +	return err != noErr; +} +  Common::String OSystem_MacOSX::getSystemLanguage() const {  #if defined(USE_DETECTLANG) && defined(USE_TRANSLATION)  	CFArrayRef availableLocalizations = CFBundleCopyBundleLocalizations(CFBundleGetMainBundle()); @@ -170,4 +187,8 @@ Common::String OSystem_MacOSX::getSystemLanguage() const {  #endif // USE_DETECTLANG  } +AudioCDManager *OSystem_MacOSX::createAudioCDManager() { +	return createMacOSXAudioCDManager(); +} +  #endif diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h index c8b4beaeec..72bb4a4787 100644 --- a/backends/platform/sdl/macosx/macosx.h +++ b/backends/platform/sdl/macosx/macosx.h @@ -33,11 +33,21 @@ public:  	virtual bool displayLogFile(); +	virtual bool hasTextInClipboard(); +	virtual Common::String getTextFromClipboard(); + +	virtual bool openUrl(const Common::String &url); +  	virtual Common::String getSystemLanguage() const;  	virtual void init();  	virtual void initBackend();  	virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); + +protected: +	// Override createAudioCDManager() to get our Mac-specific +	// version. +	virtual AudioCDManager *createAudioCDManager();  };  #endif diff --git a/backends/platform/sdl/macosx/macosx_wrapper.h b/backends/platform/sdl/macosx/macosx_wrapper.h new file mode 100644 index 0000000000..3b346fc486 --- /dev/null +++ b/backends/platform/sdl/macosx/macosx_wrapper.h @@ -0,0 +1,31 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef PLATFORM_SDL_MACOSX_WRAPPER_H +#define PLATFORM_SDL_MACOSX_WRAPPER_H + +#include <common/str.h> + +bool hasTextInClipboardMacOSX(); +Common::String getTextFromClipboardMacOSX(); + +#endif diff --git a/backends/platform/sdl/macosx/macosx_wrapper.mm b/backends/platform/sdl/macosx/macosx_wrapper.mm new file mode 100644 index 0000000000..8ec9eac5ac --- /dev/null +++ b/backends/platform/sdl/macosx/macosx_wrapper.mm @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +#include "backends/platform/sdl/macosx/macosx_wrapper.h" + +#include <AppKit/NSPasteboard.h> +#include <Foundation/NSArray.h> + +bool hasTextInClipboardMacOSX() { +	return [[NSPasteboard generalPasteboard] availableTypeFromArray:[NSArray arrayWithObject:NSStringPboardType]] != nil; +} + +Common::String getTextFromClipboardMacOSX() { +	if (!hasTextInClipboardMacOSX()) +		return Common::String(); +	// Note: on OS X 10.6 and above it is recommanded to use NSPasteboardTypeString rather than NSStringPboardType. +	// But since we still target older version use NSStringPboardType. +	NSPasteboard *pb = [NSPasteboard generalPasteboard]; +	NSString* str = [pb  stringForType:NSStringPboardType]; +	if (str == nil) +		return Common::String(); +	// If the string cannot be represented using the requested encoding we get a null pointer below. +	// This is fine as ScummVM would not know what to do with non-ASCII characters (although maybe +	// we should use NSISOLatin1StringEncoding?). +	return Common::String([str cStringUsingEncoding:NSASCIIStringEncoding]); +} diff --git a/backends/platform/sdl/module.mk b/backends/platform/sdl/module.mk index 74dd506d31..84ce272d3c 100644 --- a/backends/platform/sdl/module.mk +++ b/backends/platform/sdl/module.mk @@ -14,6 +14,7 @@ ifdef MACOSX  MODULE_OBJS += \  	macosx/macosx-main.o \  	macosx/macosx.o \ +	macosx/macosx_wrapper.o \  	macosx/appmenu_osx.o  endif diff --git a/backends/platform/sdl/posix/posix-main.cpp b/backends/platform/sdl/posix/posix-main.cpp index d07db11b0c..5deebb0ae3 100644 --- a/backends/platform/sdl/posix/posix-main.cpp +++ b/backends/platform/sdl/posix/posix-main.cpp @@ -22,7 +22,7 @@  #include "common/scummsys.h" -#if defined(POSIX) && !defined(MACOSX) && !defined(SAMSUNGTV) && !defined(MAEMO) && !defined(WEBOS) && !defined(LINUXMOTO) && !defined(GPH_DEVICE) && !defined(GP2X) && !defined(DINGUX) && !defined(OPENPANDORA) && !defined(PLAYSTATION3) +#if defined(POSIX) && !defined(MACOSX) && !defined(SAMSUNGTV) && !defined(MAEMO) && !defined(WEBOS) && !defined(LINUXMOTO) && !defined(GPH_DEVICE) && !defined(GP2X) && !defined(DINGUX) && !defined(OPENPANDORA) && !defined(PLAYSTATION3) && !defined(ANDROIDSDL)  #include "backends/platform/sdl/posix/posix.h"  #include "backends/plugins/sdl/sdl-provider.h" diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index 525c74a91a..b805a452cf 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -25,6 +25,7 @@  #define FORBIDDEN_SYMBOL_EXCEPTION_exit  #define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h  #define FORBIDDEN_SYMBOL_EXCEPTION_time_h	//On IRIX, sys/stat.h includes sys/time.h +#define FORBIDDEN_SYMBOL_EXCEPTION_system  #include "common/scummsys.h" @@ -36,6 +37,14 @@  #include "backends/fs/posix/posix-fs.h"  #include "backends/taskbar/unity/unity-taskbar.h" +#ifdef USE_LINUXCD +#include "backends/audiocd/linux/linux-audiocd.h" +#endif + +#include "common/textconsole.h" + +#include <stdlib.h> +#include <errno.h>  #include <sys/stat.h>  #include <sys/wait.h>  #include <unistd.h> @@ -73,7 +82,7 @@ void OSystem_POSIX::initBackend() {  }  bool OSystem_POSIX::hasFeature(Feature f) { -	if (f == kFeatureDisplayLogFile) +	if (f == kFeatureDisplayLogFile || f == kFeatureOpenUrl)  		return true;  	return OSystem_SDL::hasFeature(f);  } @@ -136,6 +145,24 @@ Common::String OSystem_POSIX::getDefaultConfigFileName() {  	return configFile;  } +void OSystem_POSIX::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { +#ifdef DATA_PATH +	const char *snap = getenv("SNAP"); +	if (snap) { +		Common::String dataPath = Common::String(snap) + DATA_PATH; +		Common::FSNode dataNode(dataPath); +		if (dataNode.exists() && dataNode.isDirectory()) { +			// This is the same priority which is used for the data path (below), +			// but we insert this one first, so it will be searched first. +			s.add(dataPath, new Common::FSDirectory(dataNode, 4), priority); +		} +	} +#endif + +	// For now, we always add the data path, just in case SNAP doesn't make sense. +	OSystem_SDL::addSysArchivesToSearchSet(s, priority); +} +  Common::WriteStream *OSystem_POSIX::createLogFile() {  	// Start out by resetting _logFilePath, so that in case  	// of a failure, we know that no log file is open. @@ -238,5 +265,58 @@ bool OSystem_POSIX::displayLogFile() {  	return WIFEXITED(status) && WEXITSTATUS(status) == 0;  } +bool OSystem_POSIX::openUrl(const Common::String &url) { +	// inspired by Qt's "qdesktopservices_x11.cpp" + +	// try "standards" +	if (launchBrowser("xdg-open", url)) +		return true; +	if (launchBrowser(getenv("DEFAULT_BROWSER"), url)) +		return true; +	if (launchBrowser(getenv("BROWSER"), url)) +		return true; + +	// try desktop environment specific tools +	if (launchBrowser("gnome-open", url)) // gnome +		return true; +	if (launchBrowser("kfmclient openURL", url)) // kde +		return true; +	if (launchBrowser("exo-open", url)) // xfce +		return true; + +	// try browser names +	if (launchBrowser("firefox", url)) +		return true; +	if (launchBrowser("mozilla", url)) +		return true; +	if (launchBrowser("netscape", url)) +		return true; +	if (launchBrowser("opera", url)) +		return true; +	if (launchBrowser("chromium-browser", url)) +		return true; +	if (launchBrowser("google-chrome", url)) +		return true; + +	warning("openUrl() (POSIX) failed to open URL"); +	return false; +} + +bool OSystem_POSIX::launchBrowser(const Common::String& client, const Common::String &url) { +	// FIXME: system's input must be heavily escaped +	// well, when url's specified by user +	// it's OK now (urls are hardcoded somewhere in GUI) +	Common::String cmd = client + " " + url; +	return (system(cmd.c_str()) != -1); +} + + +AudioCDManager *OSystem_POSIX::createAudioCDManager() { +#ifdef USE_LINUXCD +	return createLinuxAudioCDManager(); +#else +	return OSystem_SDL::createAudioCDManager(); +#endif +}  #endif diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h index f67515ddb3..bd3a069d5b 100644 --- a/backends/platform/sdl/posix/posix.h +++ b/backends/platform/sdl/posix/posix.h @@ -35,9 +35,13 @@ public:  	virtual bool displayLogFile(); +	virtual bool openUrl(const Common::String &url); +  	virtual void init();  	virtual void initBackend(); +	virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); +  protected:  	/**  	 * Base string for creating the default path and filename for the @@ -59,6 +63,10 @@ protected:  	virtual Common::String getDefaultConfigFileName();  	virtual Common::WriteStream *createLogFile(); + +	virtual AudioCDManager *createAudioCDManager(); + +	bool launchBrowser(const Common::String& client, const Common::String &url);  };  #endif diff --git a/backends/platform/sdl/sdl-sys.h b/backends/platform/sdl/sdl-sys.h index 219755219f..9ebd123bb4 100644 --- a/backends/platform/sdl/sdl-sys.h +++ b/backends/platform/sdl/sdl-sys.h @@ -52,6 +52,72 @@ typedef struct { int FAKE; } FAKE_FILE;  #define strncasecmp FAKE_strncasecmp  #endif +#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_exit) +#undef exit +#define exit FAKE_exit +#endif + +#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_abort) +#undef abort +#define abort FAKE_abort +#endif + +#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_system) +#undef system +#define system FAKE_system +#endif + +// Fix compilation with MacPorts SDL 2 +// It needs various (usually forbidden) symbols from time.h +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_h + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_asctime) +	#undef asctime +	#define asctime FAKE_asctime +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_clock) +	#undef clock +	#define clock FAKE_clock +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_ctime) +	#undef ctime +	#define ctime FAKE_ctime +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_difftime) +	#undef difftime +	#define difftime FAKE_difftime +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_getdate) +	#undef getdate +	#define getdate FAKE_getdate +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_gmtime) +	#undef gmtime +	#define gmtime FAKE_gmtime +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_localtime) +	#undef localtime +	#define localtime FAKE_localtime +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_mktime) +	#undef mktime +	#define mktime FAKE_mktime +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_time) +	#undef time +	#define time FAKE_time +	#endif + +#endif // FORBIDDEN_SYMBOL_EXCEPTION_time_h +  // HACK: SDL might include windows.h which defines its own ARRAYSIZE.  // However, we want to use the version from common/util.h. Thus, we make sure  // that we actually have this definition after including the SDL headers. @@ -146,6 +212,71 @@ typedef struct { int FAKE; } FAKE_FILE;  #define strncasecmp    FORBIDDEN_SYMBOL_REPLACEMENT  #endif +#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_exit) +#undef exit +#define exit(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_abort) +#undef abort +#define abort() FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_system) +#undef system +#define system(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +// re-forbid all those time.h symbols again (if they were forbidden) +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_h + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_asctime) +	#undef asctime +	#define asctime(a) FORBIDDEN_SYMBOL_REPLACEMENT +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_clock) +	#undef clock +	#define clock() FORBIDDEN_SYMBOL_REPLACEMENT +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_ctime) +	#undef ctime +	#define ctime(a) FORBIDDEN_SYMBOL_REPLACEMENT +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_difftime) +	#undef difftime +	#define difftime(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_getdate) +	#undef getdate +	#define getdate(a) FORBIDDEN_SYMBOL_REPLACEMENT +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_gmtime) +	#undef gmtime +	#define gmtime(a) FORBIDDEN_SYMBOL_REPLACEMENT +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_localtime) +	#undef localtime +	#define localtime(a) FORBIDDEN_SYMBOL_REPLACEMENT +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_mktime) +	#undef mktime +	#define mktime(a) FORBIDDEN_SYMBOL_REPLACEMENT +	#endif + +	#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_time) +	#undef time +	#define time(a) FORBIDDEN_SYMBOL_REPLACEMENT +	#endif + +#endif // FORBIDDEN_SYMBOL_EXCEPTION_time_h +  // SDL 2 has major API changes. We redefine constants which got renamed to  // ease the transition. This is sometimes dangerous because the values changed  // too! diff --git a/backends/platform/sdl/sdl-window.cpp b/backends/platform/sdl/sdl-window.cpp index 6d35f77ae0..609186a061 100644 --- a/backends/platform/sdl/sdl-window.cpp +++ b/backends/platform/sdl/sdl-window.cpp @@ -150,7 +150,7 @@ bool SdlWindow::hasMouseFocus() const {  void SdlWindow::warpMouseInWindow(uint x, uint y) {  #if SDL_VERSION_ATLEAST(2, 0, 0) -	if (_window) { +	if (_window && hasMouseFocus()) {  		SDL_WarpMouseInWindow(_window, x, y);  	}  #else diff --git a/backends/platform/sdl/sdl-window.h b/backends/platform/sdl/sdl-window.h index 58b898f824..b62860960d 100644 --- a/backends/platform/sdl/sdl-window.h +++ b/backends/platform/sdl/sdl-window.h @@ -81,7 +81,7 @@ public:  	SDL_Window *getSDLWindow() const { return _window; }  	/** -	 * Creates a new SDL window (and destroies the old one). +	 * Creates a new SDL window (and destroys the old one).  	 *  	 * @param width   Width of the window.  	 * @param height  Height of the window. @@ -91,7 +91,7 @@ public:  	bool createWindow(int width, int height, uint32 flags);  	/** -	 * Destroies the current SDL window. +	 * Destroys the current SDL window.  	 */  	void destroyWindow(); diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index fffb9d56d9..74c40ade10 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -60,6 +60,14 @@  #endif // !WIN32  #endif +#ifdef USE_SDL_NET +#include <SDL_net.h> +#endif + +#if SDL_VERSION_ATLEAST(2, 0, 0) +#include <SDL_clipboard.h> +#endif +  OSystem_SDL::OSystem_SDL()  	:  #ifdef USE_OPENGL @@ -73,6 +81,9 @@ OSystem_SDL::OSystem_SDL()  #endif  	_inited(false),  	_initedSDL(false), +#ifdef USE_SDL_NET +	_initedSDLnet(false), +#endif  	_logger(0),  	_mixerManager(0),  	_eventSource(0), @@ -120,6 +131,10 @@ OSystem_SDL::~OSystem_SDL() {  	delete _logger;  	_logger = 0; +#ifdef USE_SDL_NET +	if (_initedSDLnet) SDLNet_Quit(); +#endif +  	SDL_Quit();  } @@ -160,6 +175,13 @@ void OSystem_SDL::init() {  } +bool OSystem_SDL::hasFeature(Feature f) { +#if SDL_VERSION_ATLEAST(2, 0, 0) +	if (f == kFeatureClipboardSupport) return true; +#endif +	return ModularBackend::hasFeature(f); +} +  void OSystem_SDL::initBackend() {  	// Check if backend has not been initialized  	assert(!_inited); @@ -245,15 +267,7 @@ void OSystem_SDL::initBackend() {  		_timerManager = new SdlTimerManager();  #endif -	if (_audiocdManager == 0) { -		// Audio CD support was removed with SDL 2.0 -#if SDL_VERSION_ATLEAST(2, 0, 0) -		_audiocdManager = new DefaultAudioCDManager(); -#else -		_audiocdManager = new SdlAudioCDManager(); -#endif - -	} +	_audiocdManager = createAudioCDManager();  	// Setup a custom program icon.  	_window->setupIcon(); @@ -302,6 +316,17 @@ void OSystem_SDL::initSDL() {  		_initedSDL = true;  	} + +#ifdef USE_SDL_NET +	// Check if SDL_net has not been initialized +	if (!_initedSDLnet) { +		// Initialize SDL_net +		if (SDLNet_Init() == -1) +			error("Could not initialize SDL_net: %s", SDLNet_GetError()); + +		_initedSDLnet = true; +	} +#endif  }  void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { @@ -439,6 +464,30 @@ Common::String OSystem_SDL::getSystemLanguage() const {  #endif // USE_DETECTLANG  } +bool OSystem_SDL::hasTextInClipboard() { +#if SDL_VERSION_ATLEAST(2, 0, 0) +	return SDL_HasClipboardText() == SDL_TRUE; +#else +	return false; +#endif +} + +Common::String OSystem_SDL::getTextFromClipboard() { +	if (!hasTextInClipboard()) return ""; + +#if SDL_VERSION_ATLEAST(2, 0, 0) +	char *text = SDL_GetClipboardText(); +	Common::String strText = text; +	SDL_free(text); + +	// FIXME: The string returned by SDL is in UTF-8, it is not clear +	// what encoding should be used for the returned string. +	return strText; +#else +	return ""; +#endif +} +  uint32 OSystem_SDL::getMillis(bool skipRecord) {  	uint32 millis = SDL_GetTicks(); @@ -491,6 +540,23 @@ Common::TimerManager *OSystem_SDL::getTimerManager() {  #endif  } +AudioCDManager *OSystem_SDL::createAudioCDManager() { +	// Audio CD support was removed with SDL 2.0 +#if SDL_VERSION_ATLEAST(2, 0, 0) +	return new DefaultAudioCDManager(); +#else +	return new SdlAudioCDManager(); +#endif +} + +Common::SaveFileManager *OSystem_SDL::getSavefileManager() { +#ifdef ENABLE_EVENTRECORDER +    return g_eventRec.getSaveManager(_savefileManager); +#else +    return _savefileManager; +#endif +} +  #ifdef USE_OPENGL  const OSystem::GraphicsMode *OSystem_SDL::getSupportedGraphicsModes() const { diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 5ee56d0568..17b4e9b001 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -55,6 +55,8 @@ public:  	 */  	virtual SdlMixerManager *getMixerManager(); +	virtual bool hasFeature(Feature f); +  	// Override functions from ModularBackend and OSystem  	virtual void initBackend();  #if defined(USE_TASKBAR) @@ -69,6 +71,10 @@ public:  	virtual Common::String getSystemLanguage() const; +	// Clipboard +	virtual bool hasTextInClipboard(); +	virtual Common::String getTextFromClipboard(); +  	virtual void setWindowCaption(const char *caption);  	virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);  	virtual uint32 getMillis(bool skipRecord = false); @@ -76,10 +82,14 @@ public:  	virtual void getTimeAndDate(TimeDate &td) const;  	virtual Audio::Mixer *getMixer();  	virtual Common::TimerManager *getTimerManager(); +	virtual Common::SaveFileManager *getSavefileManager();  protected:  	bool _inited;  	bool _initedSDL; +#ifdef USE_SDL_NET +	bool _initedSDLnet; +#endif  	/**  	 * Mixer manager that configures and setups SDL for @@ -104,6 +114,11 @@ protected:  	 */  	virtual void initSDL(); +	/** +	 * Create the audio CD manager +	 */ +	virtual AudioCDManager *createAudioCDManager(); +  	// Logging  	virtual Common::WriteStream *createLogFile() { return 0; }  	Backends::Log::Log *_logger; diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 0f70c00b40..99c71a49e0 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -35,11 +35,13 @@  #include "common/error.h"  #include "common/textconsole.h" +#include "backends/audiocd/win32/win32-audiocd.h"  #include "backends/platform/sdl/win32/win32.h"  #include "backends/platform/sdl/win32/win32-window.h"  #include "backends/saves/windows/windows-saves.h"  #include "backends/fs/windows/windows-fs-factory.h"  #include "backends/taskbar/win32/win32-taskbar.h" +#include "backends/updates/win32/win32-updates.h"  #include "common/memstream.h" @@ -81,13 +83,18 @@ void OSystem_Win32::initBackend() {  	if (_savefileManager == 0)  		_savefileManager = new WindowsSaveFileManager(); +#if defined(USE_SPARKLE) +	// Initialize updates manager +	_updateManager = new Win32UpdateManager(); +#endif +  	// Invoke parent implementation of this method  	OSystem_SDL::initBackend();  }  bool OSystem_Win32::hasFeature(Feature f) { -	if (f == kFeatureDisplayLogFile) +	if (f == kFeatureDisplayLogFile || f == kFeatureOpenUrl)  		return true;  	return OSystem_SDL::hasFeature(f); @@ -128,6 +135,16 @@ bool OSystem_Win32::displayLogFile() {  	return false;  } +bool OSystem_Win32::openUrl(const Common::String &url) { +	const uint64 result = (uint64)ShellExecute(0, 0, /*(wchar_t*)nativeFilePath.utf16()*/url.c_str(), 0, 0, SW_SHOWNORMAL); +	// ShellExecute returns a value greater than 32 if successful +	if (result <= 32) { +		warning("ShellExecute failed: error = %u", result); +		return false; +	} +	return true; +} +  Common::String OSystem_Win32::getDefaultConfigFileName() {  	char configFile[MAXPATHLEN]; @@ -318,4 +335,8 @@ void OSystem_Win32::addSysArchivesToSearchSet(Common::SearchSet &s, int priority  	OSystem_SDL::addSysArchivesToSearchSet(s, priority);  } +AudioCDManager *OSystem_Win32::createAudioCDManager() { +	return createWin32AudioCDManager(); +} +  #endif diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h index 473e78ff0b..636ebae88f 100644 --- a/backends/platform/sdl/win32/win32.h +++ b/backends/platform/sdl/win32/win32.h @@ -36,6 +36,8 @@ public:  	virtual bool displayLogFile(); +	virtual bool openUrl(const Common::String &url); +  protected:  	/**  	 * The path of the currently open log file, if any. @@ -49,6 +51,10 @@ protected:  	virtual Common::String getDefaultConfigFileName();  	virtual Common::WriteStream *createLogFile(); + +	// Override createAudioCDManager() to get our Mac-specific +	// version. +	virtual AudioCDManager *createAudioCDManager();  };  #endif | 
