2007-05-30 21:56:52 +00:00
|
|
|
/* 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.
|
2002-08-24 10:41:32 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2014-02-18 02:34:24 +01:00
|
|
|
*
|
2002-08-24 10:41:32 +00:00
|
|
|
* 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.
|
2014-02-18 02:34:24 +01:00
|
|
|
*
|
2002-08-24 10:41:32 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-08-24 10:41:32 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-07-02 06:44:42 +00:00
|
|
|
#ifndef PLATFORM_SDL_H
|
|
|
|
#define PLATFORM_SDL_H
|
2002-08-24 10:41:32 +00:00
|
|
|
|
2010-11-29 16:16:50 +00:00
|
|
|
#include "backends/platform/sdl/sdl-sys.h"
|
2006-05-23 16:49:46 +00:00
|
|
|
|
2010-06-11 02:50:25 +00:00
|
|
|
#include "backends/modular-backend.h"
|
2010-06-24 04:11:54 +00:00
|
|
|
#include "backends/mixer/sdl/sdl-mixer.h"
|
2010-10-13 15:42:16 +00:00
|
|
|
#include "backends/events/sdl/sdl-events.h"
|
2010-11-26 00:51:42 +00:00
|
|
|
#include "backends/log/log.h"
|
2015-02-16 00:49:42 +01:00
|
|
|
#include "backends/platform/sdl/sdl-window.h"
|
2002-08-24 10:41:32 +00:00
|
|
|
|
2013-10-20 23:29:40 +02:00
|
|
|
#include "common/array.h"
|
|
|
|
|
2020-05-25 09:39:49 +01:00
|
|
|
#ifdef USE_DISCORD
|
|
|
|
class DiscordPresence;
|
|
|
|
#endif
|
|
|
|
|
2011-04-26 12:47:03 -04:00
|
|
|
/**
|
2010-07-02 06:44:42 +00:00
|
|
|
* Base OSystem class for all SDL ports.
|
|
|
|
*/
|
2019-11-30 20:22:19 +00:00
|
|
|
class OSystem_SDL : public ModularMutexBackend, public ModularMixerBackend, public ModularGraphicsBackend {
|
2002-08-24 10:41:32 +00:00
|
|
|
public:
|
2004-02-29 00:49:40 +00:00
|
|
|
OSystem_SDL();
|
|
|
|
virtual ~OSystem_SDL();
|
|
|
|
|
2011-04-26 12:47:03 -04:00
|
|
|
/**
|
2010-07-02 06:44:42 +00:00
|
|
|
* Pre-initialize backend. It should be called after
|
|
|
|
* instantiating the backend. Early needed managers are
|
|
|
|
* created here.
|
2010-06-24 17:37:09 +00:00
|
|
|
*/
|
2020-08-01 23:43:01 +01:00
|
|
|
virtual void init() override;
|
2009-11-09 23:31:46 +00:00
|
|
|
|
2020-01-31 12:39:23 +01:00
|
|
|
virtual bool hasFeature(Feature f) override;
|
2016-07-26 12:21:15 +06:00
|
|
|
|
2010-07-03 00:25:06 +00:00
|
|
|
// Override functions from ModularBackend and OSystem
|
2020-01-31 12:39:23 +01:00
|
|
|
virtual void initBackend() override;
|
|
|
|
virtual void engineInit() override;
|
|
|
|
virtual void engineDone() override;
|
|
|
|
virtual void quit() override;
|
|
|
|
virtual void fatalError() override;
|
2017-08-15 14:35:26 +02:00
|
|
|
Common::KeymapArray getGlobalKeymaps() override;
|
2020-01-26 16:33:25 +01:00
|
|
|
Common::HardwareInputSet *getHardwareInputSet() override;
|
2002-08-24 10:41:32 +00:00
|
|
|
|
2010-11-18 19:12:14 +00:00
|
|
|
// Logging
|
2020-01-31 12:39:23 +01:00
|
|
|
virtual void logMessage(LogMessageType::Type type, const char *message) override;
|
2010-11-18 19:12:14 +00:00
|
|
|
|
2020-01-31 12:39:23 +01:00
|
|
|
virtual Common::String getSystemLanguage() const override;
|
2010-11-25 18:40:56 +00:00
|
|
|
|
2019-09-19 22:20:08 +01:00
|
|
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
2016-07-26 12:21:15 +06:00
|
|
|
// Clipboard
|
2020-01-31 12:39:23 +01:00
|
|
|
virtual bool hasTextInClipboard() override;
|
2020-06-15 21:07:22 +05:30
|
|
|
virtual Common::U32String getTextFromClipboard() override;
|
|
|
|
virtual bool setTextInClipboard(const Common::U32String &text) override;
|
2021-07-24 16:04:02 +01:00
|
|
|
|
|
|
|
virtual void messageBox(LogMessageType::Type type, const char *message) override;
|
2019-09-19 22:20:08 +01:00
|
|
|
#endif
|
2016-07-26 12:21:15 +06:00
|
|
|
|
2021-02-24 22:26:56 +00:00
|
|
|
#if SDL_VERSION_ATLEAST(2, 0, 14)
|
|
|
|
virtual bool openUrl(const Common::String &url) override;
|
|
|
|
#endif
|
|
|
|
|
2020-11-01 21:15:34 +00:00
|
|
|
virtual void setWindowCaption(const Common::U32String &caption) override;
|
2020-01-31 12:39:23 +01:00
|
|
|
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) override;
|
|
|
|
virtual uint32 getMillis(bool skipRecord = false) override;
|
|
|
|
virtual void delayMillis(uint msecs) override;
|
2021-07-08 19:31:13 +02:00
|
|
|
virtual void getTimeAndDate(TimeDate &td, bool skipRecord = false) const override;
|
2019-11-30 20:22:19 +00:00
|
|
|
virtual MixerManager *getMixerManager() override;
|
2020-01-31 12:39:23 +01:00
|
|
|
virtual Common::TimerManager *getTimerManager() override;
|
|
|
|
virtual Common::SaveFileManager *getSavefileManager() override;
|
2008-08-03 17:05:01 +00:00
|
|
|
|
2017-03-24 22:25:46 +01:00
|
|
|
//Screenshots
|
|
|
|
virtual Common::String getScreenshotsPath();
|
|
|
|
|
2020-10-14 18:37:17 +02:00
|
|
|
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
|
2020-09-25 18:51:18 +02:00
|
|
|
Common::Array<uint> getSupportedAntiAliasingLevels() const override;
|
2020-05-12 23:46:03 +02:00
|
|
|
#endif
|
2016-06-17 19:59:42 +02:00
|
|
|
|
2002-08-24 10:41:32 +00:00
|
|
|
protected:
|
2005-04-19 20:22:50 +00:00
|
|
|
bool _inited;
|
2010-06-23 19:34:07 +00:00
|
|
|
bool _initedSDL;
|
2016-06-15 16:37:01 +06:00
|
|
|
#ifdef USE_SDL_NET
|
|
|
|
bool _initedSDLnet;
|
|
|
|
#endif
|
2010-07-12 23:18:44 +00:00
|
|
|
|
2020-05-25 09:39:49 +01:00
|
|
|
#ifdef USE_DISCORD
|
|
|
|
DiscordPresence *_presence;
|
|
|
|
#endif
|
|
|
|
|
2019-08-04 21:45:17 +01:00
|
|
|
/**
|
|
|
|
* The path of the currently open log file, if any.
|
|
|
|
*
|
|
|
|
* @note This is currently a string and not an FSNode for simplicity;
|
|
|
|
* e.g. we don't need to include fs.h here, and currently the
|
|
|
|
* only use of this value is to use it to open the log file in an
|
|
|
|
* editor; for that, we need it only as a string anyway.
|
|
|
|
*/
|
|
|
|
Common::String _logFilePath;
|
|
|
|
|
2004-02-28 12:58:13 +00:00
|
|
|
/**
|
2010-10-21 18:13:13 +00:00
|
|
|
* The event source we use for obtaining SDL events.
|
2004-02-28 12:58:13 +00:00
|
|
|
*/
|
2010-10-21 18:13:13 +00:00
|
|
|
SdlEventSource *_eventSource;
|
2020-04-12 10:47:47 +02:00
|
|
|
Common::EventSource *_eventSourceWrapper;
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2015-02-16 00:49:42 +01:00
|
|
|
/**
|
|
|
|
* The SDL output window.
|
|
|
|
*/
|
|
|
|
SdlWindow *_window;
|
|
|
|
|
2020-10-02 19:14:19 +02:00
|
|
|
SdlGraphicsManager::State _gfxManagerState;
|
|
|
|
|
2020-10-14 18:37:17 +02:00
|
|
|
#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) || defined(USE_GLES2)
|
2016-06-19 10:13:01 +02:00
|
|
|
// Graphics capabilities
|
2016-06-21 07:16:16 +02:00
|
|
|
void detectFramebufferSupport();
|
2019-05-16 22:23:32 +02:00
|
|
|
void detectAntiAliasingSupport();
|
2021-01-01 23:19:33 +00:00
|
|
|
|
|
|
|
bool _supportsFrameBuffer;
|
|
|
|
Common::Array<uint> _antiAliasLevels;
|
2020-05-12 23:46:03 +02:00
|
|
|
#endif
|
2011-06-09 11:17:15 +02:00
|
|
|
|
2010-07-02 06:44:42 +00:00
|
|
|
/**
|
2021-05-06 21:51:23 +02:00
|
|
|
* Initialize the SDL library.
|
2010-07-02 06:44:42 +00:00
|
|
|
*/
|
2010-06-23 19:34:07 +00:00
|
|
|
virtual void initSDL();
|
2008-07-15 17:13:06 +00:00
|
|
|
|
2015-10-03 14:07:30 -04:00
|
|
|
/**
|
|
|
|
* Create the audio CD manager
|
|
|
|
*/
|
|
|
|
virtual AudioCDManager *createAudioCDManager();
|
|
|
|
|
2010-11-26 00:51:42 +00:00
|
|
|
// Logging
|
2019-08-04 21:45:17 +01:00
|
|
|
virtual Common::String getDefaultLogFileName() { return Common::String(); }
|
|
|
|
virtual Common::WriteStream *createLogFile();
|
2010-11-26 00:51:42 +00:00
|
|
|
Backends::Log::Log *_logger;
|
2013-08-18 16:56:34 +02:00
|
|
|
|
|
|
|
#ifdef USE_OPENGL
|
2013-10-20 23:29:40 +02:00
|
|
|
typedef Common::Array<GraphicsMode> GraphicsModeArray;
|
|
|
|
GraphicsModeArray _graphicsModes;
|
2013-10-20 23:39:46 +02:00
|
|
|
Common::Array<int> _graphicsModeIds;
|
2013-08-18 16:56:34 +02:00
|
|
|
int _graphicsMode;
|
2013-10-21 00:21:51 +02:00
|
|
|
int _firstGLMode;
|
2013-10-21 01:10:09 +02:00
|
|
|
int _defaultSDLMode;
|
|
|
|
int _defaultGLMode;
|
2013-08-18 16:56:34 +02:00
|
|
|
|
|
|
|
/**
|
2021-05-06 21:51:23 +02:00
|
|
|
* Create the merged graphics modes list.
|
2013-08-18 16:56:34 +02:00
|
|
|
*/
|
2013-10-21 00:50:35 +02:00
|
|
|
void setupGraphicsModes();
|
2013-08-18 16:56:34 +02:00
|
|
|
|
2021-05-06 21:51:23 +02:00
|
|
|
/**
|
|
|
|
* Clear the merged graphics modes list.
|
|
|
|
*/
|
|
|
|
void clearGraphicsModes();
|
|
|
|
|
2020-01-31 12:39:23 +01:00
|
|
|
virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const override;
|
|
|
|
virtual int getDefaultGraphicsMode() const override;
|
2020-10-09 19:04:07 +02:00
|
|
|
virtual bool setGraphicsMode(int mode, uint flags) override;
|
2020-01-31 12:39:23 +01:00
|
|
|
virtual int getGraphicsMode() const override;
|
2013-08-18 16:56:34 +02:00
|
|
|
#endif
|
2002-08-24 10:41:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|