1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef PLATFORM_SDL_H 24 #define PLATFORM_SDL_H 25 26 #include "backends/platform/sdl/sdl-sys.h" 27 28 #include "backends/modular-backend.h" 29 #include "backends/mixer/sdl/sdl-mixer.h" 30 #include "backends/events/sdl/sdl-events.h" 31 #include "backends/log/log.h" 32 #include "backends/platform/sdl/sdl-window.h" 33 34 #include "common/array.h" 35 36 /** 37 * Base OSystem class for all SDL ports. 38 */ 39 class OSystem_SDL : public ModularBackend { 40 public: 41 OSystem_SDL(); 42 virtual ~OSystem_SDL(); 43 44 /** 45 * Pre-initialize backend. It should be called after 46 * instantiating the backend. Early needed managers are 47 * created here. 48 */ 49 virtual void init(); 50 51 /** 52 * Get the Mixer Manager instance. Not to confuse with getMixer(), 53 * that returns Audio::Mixer. The Mixer Manager is a SDL wrapper class 54 * for the Audio::Mixer. Used by other managers. 55 */ 56 virtual SdlMixerManager *getMixerManager(); 57 58 virtual bool hasFeature(Feature f); 59 60 // Override functions from ModularBackend and OSystem 61 virtual void initBackend(); 62 virtual void engineInit(); 63 virtual void engineDone(); 64 virtual void quit(); 65 virtual void fatalError(); 66 67 // Logging 68 virtual void logMessage(LogMessageType::Type type, const char *message); 69 70 virtual Common::String getSystemLanguage() const; 71 72 #if SDL_VERSION_ATLEAST(2, 0, 0) 73 // Clipboard 74 virtual bool hasTextInClipboard(); 75 virtual Common::String getTextFromClipboard(); 76 virtual bool setTextInClipboard(const Common::String &text); 77 #endif 78 79 virtual void setWindowCaption(const char *caption); 80 virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); 81 virtual uint32 getMillis(bool skipRecord = false); 82 virtual void delayMillis(uint msecs); 83 virtual void getTimeAndDate(TimeDate &td) const; 84 virtual Audio::Mixer *getMixer(); 85 virtual Common::TimerManager *getTimerManager(); 86 virtual Common::SaveFileManager *getSavefileManager(); 87 88 //Screenshots 89 virtual Common::String getScreenshotsPath(); 90 91 protected: 92 bool _inited; 93 bool _initedSDL; 94 #ifdef USE_SDL_NET 95 bool _initedSDLnet; 96 #endif 97 98 /** 99 * The path of the currently open log file, if any. 100 * 101 * @note This is currently a string and not an FSNode for simplicity; 102 * e.g. we don't need to include fs.h here, and currently the 103 * only use of this value is to use it to open the log file in an 104 * editor; for that, we need it only as a string anyway. 105 */ 106 Common::String _logFilePath; 107 108 /** 109 * Mixer manager that configures and setups SDL for 110 * the wrapped Audio::Mixer, the true mixer. 111 */ 112 SdlMixerManager *_mixerManager; 113 114 /** 115 * The event source we use for obtaining SDL events. 116 */ 117 SdlEventSource *_eventSource; 118 119 /** 120 * The SDL output window. 121 */ 122 SdlWindow *_window; 123 getDefaultEventSource()124 virtual Common::EventSource *getDefaultEventSource() { return _eventSource; } 125 126 /** 127 * Initialze the SDL library. 128 */ 129 virtual void initSDL(); 130 131 /** 132 * Create the audio CD manager 133 */ 134 virtual AudioCDManager *createAudioCDManager(); 135 136 // Logging getDefaultLogFileName()137 virtual Common::String getDefaultLogFileName() { return Common::String(); } 138 virtual Common::WriteStream *createLogFile(); 139 Backends::Log::Log *_logger; 140 141 #ifdef USE_OPENGL 142 int _desktopWidth, _desktopHeight; 143 144 typedef Common::Array<GraphicsMode> GraphicsModeArray; 145 GraphicsModeArray _graphicsModes; 146 Common::Array<int> _graphicsModeIds; 147 int _graphicsMode; 148 int _firstGLMode; 149 int _defaultSDLMode; 150 int _defaultGLMode; 151 152 /** 153 * Creates the merged graphics modes list 154 */ 155 void setupGraphicsModes(); 156 157 virtual const OSystem::GraphicsMode *getSupportedGraphicsModes() const; 158 virtual int getDefaultGraphicsMode() const; 159 virtual bool setGraphicsMode(int mode); 160 virtual int getGraphicsMode() const; 161 #endif 162 protected: 163 virtual char *convertEncoding(const char *to, const char *from, const char *string, size_t length); 164 }; 165 166 #endif 167