ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

sdl-sys.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef BACKEND_SDL_SYS_H
00024 #define BACKEND_SDL_SYS_H
00025 
00026 // The purpose of this header is to include the SDL headers in a uniform
00027 // fashion, even on the Symbian port.
00028 // Moreover, it contains a workaround for the fact that SDL_rwops.h uses
00029 // a FILE pointer in one place, which conflicts with common/forbidden.h.
00030 // The SDL 1.3 headers also include strings.h
00031 
00032 #include "common/scummsys.h"
00033 
00034 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_FILE)
00035 #undef FILE
00036 #endif
00037 
00038 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_strcasecmp)
00039 #undef strcasecmp
00040 #define strcasecmp FAKE_strcasecmp
00041 #endif
00042 
00043 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_strncasecmp)
00044 #undef strncasecmp
00045 #define strncasecmp FAKE_strncasecmp
00046 #endif
00047 
00048 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_exit)
00049 #undef exit
00050 #define exit FAKE_exit
00051 #endif
00052 
00053 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_abort)
00054 #undef abort
00055 #define abort FAKE_abort
00056 #endif
00057 
00058 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_system)
00059 #undef system
00060 #define system FAKE_system
00061 #endif
00062 
00063 // Fix compilation with MacPorts SDL 2
00064 // It needs various (usually forbidden) symbols from time.h
00065 #ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_h
00066 
00067     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_asctime)
00068     #undef asctime
00069     #define asctime FAKE_asctime
00070     #endif
00071 
00072     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_clock)
00073     #undef clock
00074     #define clock FAKE_clock
00075     #endif
00076 
00077     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_ctime)
00078     #undef ctime
00079     #define ctime FAKE_ctime
00080     #endif
00081 
00082     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_difftime)
00083     #undef difftime
00084     #define difftime FAKE_difftime
00085     #endif
00086 
00087     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_getdate)
00088     #undef getdate
00089     #define getdate FAKE_getdate
00090     #endif
00091 
00092     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_gmtime)
00093     #undef gmtime
00094     #define gmtime FAKE_gmtime
00095     #endif
00096 
00097     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_localtime)
00098     #undef localtime
00099     #define localtime FAKE_localtime
00100     #endif
00101 
00102     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_mktime)
00103     #undef mktime
00104     #define mktime FAKE_mktime
00105     #endif
00106 
00107     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_time)
00108     #undef time
00109     #define time FAKE_time
00110     #endif
00111 
00112 #endif // FORBIDDEN_SYMBOL_EXCEPTION_time_h
00113 
00114 // HACK: SDL might include windows.h which defines its own ARRAYSIZE.
00115 // However, we want to use the version from common/util.h. Thus, we make sure
00116 // that we actually have this definition after including the SDL headers.
00117 #if defined(ARRAYSIZE) && defined(COMMON_UTIL_H)
00118 #define HACK_REDEFINE_ARRAYSIZE
00119 #undef ARRAYSIZE
00120 #endif
00121 
00122 // HACK to fix compilation with SDL 2.0 in MSVC.
00123 // In SDL 2.0, intrin.h is now included in SDL_cpuinfo.h, which includes
00124 // setjmp.h. SDL_cpuinfo.h is included from SDL.h and SDL_syswm.h.
00125 // Thus, we remove the exceptions for setjmp and longjmp before these two
00126 // includes. Unfortunately, we can't use SDL_VERSION_ATLEAST here, as SDL.h
00127 // hasn't been included yet at this point.
00128 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && defined(_MSC_VER)
00129 // We unset any fake definitions of setjmp/longjmp here
00130 
00131 #ifndef FORBIDDEN_SYMBOL_EXCEPTION_setjmp
00132 #undef setjmp
00133 #endif
00134 
00135 #ifndef FORBIDDEN_SYMBOL_EXCEPTION_longjmp
00136 #undef longjmp
00137 #endif
00138 
00139 #endif
00140 
00141 #if defined(__SYMBIAN32__)
00142 #include <esdl\SDL.h>
00143 #else
00144 #include <SDL.h>
00145 #endif
00146 
00147 // Ignore warnings from system headers pulled by SDL
00148 #pragma warning(push)
00149 #pragma warning(disable:4121) // alignment of a member was sensitive to packing
00150 #include <SDL_syswm.h>
00151 #pragma warning(pop)
00152 
00153 // Restore the forbidden exceptions from the hack above
00154 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && defined(_MSC_VER)
00155 
00156 #ifndef FORBIDDEN_SYMBOL_EXCEPTION_setjmp
00157 #undef setjmp
00158 #define setjmp(a)   FORBIDDEN_SYMBOL_REPLACEMENT
00159 #endif
00160 
00161 #ifndef FORBIDDEN_SYMBOL_EXCEPTION_longjmp
00162 #undef longjmp
00163 #define longjmp(a,b)    FORBIDDEN_SYMBOL_REPLACEMENT
00164 #endif
00165 
00166 #endif
00167 
00168 // SDL_syswm.h will include windows.h on Win32. We need to undefine its
00169 // ARRAYSIZE definition because we supply our own.
00170 #undef ARRAYSIZE
00171 
00172 #ifdef HACK_REDEFINE_ARRAYSIZE
00173 #undef HACK_REDEFINE_ARRAYSIZE
00174 #define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0])))
00175 #endif
00176 
00177 // In a moment of brilliance Xlib.h included by SDL_syswm.h #defines the
00178 // following names. In a moment of mental breakdown, which occurred upon
00179 // gazing at Xlib.h, LordHoto decided to undefine them to prevent havoc.
00180 #ifdef Status
00181 #undef Status
00182 #endif
00183 
00184 #ifdef Bool
00185 #undef Bool
00186 #endif
00187 
00188 #ifdef True
00189 #undef True
00190 #endif
00191 
00192 #ifdef False
00193 #undef False
00194 #endif
00195 
00196 // Finally forbid FILE again (if it was forbidden to start with)
00197 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_FILE)
00198 #undef FILE
00199 #define FILE    FORBIDDEN_SYMBOL_REPLACEMENT
00200 #endif
00201 
00202 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_strcasecmp)
00203 #undef strcasecmp
00204 #define strcasecmp     FORBIDDEN_SYMBOL_REPLACEMENT
00205 #endif
00206 
00207 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_strncasecmp)
00208 #undef strncasecmp
00209 #define strncasecmp    FORBIDDEN_SYMBOL_REPLACEMENT
00210 #endif
00211 
00212 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_exit)
00213 #undef exit
00214 #define exit(a) FORBIDDEN_SYMBOL_REPLACEMENT
00215 #endif
00216 
00217 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_abort)
00218 #undef abort
00219 #define abort() FORBIDDEN_SYMBOL_REPLACEMENT
00220 #endif
00221 
00222 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_system)
00223 #undef system
00224 #define system(a) FORBIDDEN_SYMBOL_REPLACEMENT
00225 #endif
00226 
00227 // re-forbid all those time.h symbols again (if they were forbidden)
00228 #ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_h
00229 
00230     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_asctime)
00231     #undef asctime
00232     #define asctime(a) FORBIDDEN_SYMBOL_REPLACEMENT
00233     #endif
00234 
00235     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_clock)
00236     #undef clock
00237     #define clock() FORBIDDEN_SYMBOL_REPLACEMENT
00238     #endif
00239 
00240     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_ctime)
00241     #undef ctime
00242     #define ctime(a) FORBIDDEN_SYMBOL_REPLACEMENT
00243     #endif
00244 
00245     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_difftime)
00246     #undef difftime
00247     #define difftime(a,b) FORBIDDEN_SYMBOL_REPLACEMENT
00248     #endif
00249 
00250     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_getdate)
00251     #undef getdate
00252     #define getdate(a) FORBIDDEN_SYMBOL_REPLACEMENT
00253     #endif
00254 
00255     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_gmtime)
00256     #undef gmtime
00257     #define gmtime(a) FORBIDDEN_SYMBOL_REPLACEMENT
00258     #endif
00259 
00260     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_localtime)
00261     #undef localtime
00262     #define localtime(a) FORBIDDEN_SYMBOL_REPLACEMENT
00263     #endif
00264 
00265     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_mktime)
00266     #undef mktime
00267     #define mktime(a) FORBIDDEN_SYMBOL_REPLACEMENT
00268     #endif
00269 
00270     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_time)
00271     #undef time
00272     #define time(a) FORBIDDEN_SYMBOL_REPLACEMENT
00273     #endif
00274 
00275 #endif // FORBIDDEN_SYMBOL_EXCEPTION_time_h
00276 
00277 // SDL 2 has major API changes. We redefine constants which got renamed to
00278 // ease the transition. This is sometimes dangerous because the values changed
00279 // too!
00280 #if SDL_VERSION_ATLEAST(2, 0, 0)
00281 
00282 // Type names which changed between SDL 1.2 and SDL 2.
00283 #define SDLKey     SDL_Keycode
00284 #define SDLMod     SDL_Keymod
00285 #define SDL_keysym SDL_Keysym
00286 
00287 // Key code constants which got renamed.
00288 #define SDLK_SCROLLOCK SDLK_SCROLLLOCK
00289 #define SDLK_NUMLOCK   SDLK_NUMLOCKCLEAR
00290 #define SDLK_LSUPER    SDLK_LGUI
00291 #define SDLK_RSUPER    SDLK_RGUI
00292 #define SDLK_PRINT     SDLK_PRINTSCREEN
00293 #define SDLK_COMPOSE   SDLK_APPLICATION
00294 #define SDLK_KP0       SDLK_KP_0
00295 #define SDLK_KP1       SDLK_KP_1
00296 #define SDLK_KP2       SDLK_KP_2
00297 #define SDLK_KP3       SDLK_KP_3
00298 #define SDLK_KP4       SDLK_KP_4
00299 #define SDLK_KP5       SDLK_KP_5
00300 #define SDLK_KP6       SDLK_KP_6
00301 #define SDLK_KP7       SDLK_KP_7
00302 #define SDLK_KP8       SDLK_KP_8
00303 #define SDLK_KP9       SDLK_KP_9
00304 
00305 // Meta key constants which got renamed.
00306 #define KMOD_META KMOD_GUI
00307 
00308 // SDL surface flags which got removed.
00309 #define SDL_SRCCOLORKEY 0
00310 #define SDL_SRCALPHA    0
00311 #define SDL_FULLSCREEN  0x40000000
00312 
00313 // Compatibility implementations for removed functionality.
00314 int SDL_SetColors(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors);
00315 int SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha);
00316 
00317 #define SDL_SetColorKey SDL_SetColorKey_replacement
00318 int SDL_SetColorKey_replacement(SDL_Surface *surface, Uint32 flag, Uint32 key);
00319 
00320 #endif
00321 
00322 
00323 #endif


Generated on Sat Nov 16 2019 05:00:32 for ResidualVM by doxygen 1.7.1
curved edge   curved edge