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 #include <SDL_syswm.h>
00148 
00149 // Restore the forbidden exceptions from the hack above
00150 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && defined(_MSC_VER)
00151 
00152 #ifndef FORBIDDEN_SYMBOL_EXCEPTION_setjmp
00153 #undef setjmp
00154 #define setjmp(a)   FORBIDDEN_SYMBOL_REPLACEMENT
00155 #endif
00156 
00157 #ifndef FORBIDDEN_SYMBOL_EXCEPTION_longjmp
00158 #undef longjmp
00159 #define longjmp(a,b)    FORBIDDEN_SYMBOL_REPLACEMENT
00160 #endif
00161 
00162 #endif
00163 
00164 // SDL_syswm.h will include windows.h on Win32. We need to undefine its
00165 // ARRAYSIZE definition because we supply our own.
00166 #undef ARRAYSIZE
00167 
00168 #ifdef HACK_REDEFINE_ARRAYSIZE
00169 #undef HACK_REDEFINE_ARRAYSIZE
00170 #define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0])))
00171 #endif
00172 
00173 // In a moment of brilliance Xlib.h included by SDL_syswm.h #defines the
00174 // following names. In a moment of mental breakdown, which occurred upon
00175 // gazing at Xlib.h, LordHoto decided to undefine them to prevent havoc.
00176 #ifdef Status
00177 #undef Status
00178 #endif
00179 
00180 #ifdef Bool
00181 #undef Bool
00182 #endif
00183 
00184 #ifdef True
00185 #undef True
00186 #endif
00187 
00188 #ifdef False
00189 #undef False
00190 #endif
00191 
00192 // Finally forbid FILE again (if it was forbidden to start with)
00193 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_FILE)
00194 #undef FILE
00195 #define FILE    FORBIDDEN_SYMBOL_REPLACEMENT
00196 #endif
00197 
00198 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_strcasecmp)
00199 #undef strcasecmp
00200 #define strcasecmp     FORBIDDEN_SYMBOL_REPLACEMENT
00201 #endif
00202 
00203 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_strncasecmp)
00204 #undef strncasecmp
00205 #define strncasecmp    FORBIDDEN_SYMBOL_REPLACEMENT
00206 #endif
00207 
00208 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_exit)
00209 #undef exit
00210 #define exit(a) FORBIDDEN_SYMBOL_REPLACEMENT
00211 #endif
00212 
00213 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_abort)
00214 #undef abort
00215 #define abort() FORBIDDEN_SYMBOL_REPLACEMENT
00216 #endif
00217 
00218 #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_system)
00219 #undef system
00220 #define system(a) FORBIDDEN_SYMBOL_REPLACEMENT
00221 #endif
00222 
00223 // re-forbid all those time.h symbols again (if they were forbidden)
00224 #ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_h
00225 
00226     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_asctime)
00227     #undef asctime
00228     #define asctime(a) FORBIDDEN_SYMBOL_REPLACEMENT
00229     #endif
00230 
00231     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_clock)
00232     #undef clock
00233     #define clock() FORBIDDEN_SYMBOL_REPLACEMENT
00234     #endif
00235 
00236     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_ctime)
00237     #undef ctime
00238     #define ctime(a) FORBIDDEN_SYMBOL_REPLACEMENT
00239     #endif
00240 
00241     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_difftime)
00242     #undef difftime
00243     #define difftime(a,b) FORBIDDEN_SYMBOL_REPLACEMENT
00244     #endif
00245 
00246     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_getdate)
00247     #undef getdate
00248     #define getdate(a) FORBIDDEN_SYMBOL_REPLACEMENT
00249     #endif
00250 
00251     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_gmtime)
00252     #undef gmtime
00253     #define gmtime(a) FORBIDDEN_SYMBOL_REPLACEMENT
00254     #endif
00255 
00256     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_localtime)
00257     #undef localtime
00258     #define localtime(a) FORBIDDEN_SYMBOL_REPLACEMENT
00259     #endif
00260 
00261     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_mktime)
00262     #undef mktime
00263     #define mktime(a) FORBIDDEN_SYMBOL_REPLACEMENT
00264     #endif
00265 
00266     #if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_time)
00267     #undef time
00268     #define time(a) FORBIDDEN_SYMBOL_REPLACEMENT
00269     #endif
00270 
00271 #endif // FORBIDDEN_SYMBOL_EXCEPTION_time_h
00272 
00273 // SDL 2 has major API changes. We redefine constants which got renamed to
00274 // ease the transition. This is sometimes dangerous because the values changed
00275 // too!
00276 #if SDL_VERSION_ATLEAST(2, 0, 0)
00277 
00278 // Type names which changed between SDL 1.2 and SDL 2.
00279 #define SDLKey     SDL_Keycode
00280 #define SDLMod     SDL_Keymod
00281 #define SDL_keysym SDL_Keysym
00282 
00283 // Key code constants which got renamed.
00284 #define SDLK_SCROLLOCK SDLK_SCROLLLOCK
00285 #define SDLK_NUMLOCK   SDLK_NUMLOCKCLEAR
00286 #define SDLK_LSUPER    SDLK_LGUI
00287 #define SDLK_RSUPER    SDLK_RGUI
00288 #define SDLK_PRINT     SDLK_PRINTSCREEN
00289 #define SDLK_COMPOSE   SDLK_APPLICATION
00290 #define SDLK_KP0       SDLK_KP_0
00291 #define SDLK_KP1       SDLK_KP_1
00292 #define SDLK_KP2       SDLK_KP_2
00293 #define SDLK_KP3       SDLK_KP_3
00294 #define SDLK_KP4       SDLK_KP_4
00295 #define SDLK_KP5       SDLK_KP_5
00296 #define SDLK_KP6       SDLK_KP_6
00297 #define SDLK_KP7       SDLK_KP_7
00298 #define SDLK_KP8       SDLK_KP_8
00299 #define SDLK_KP9       SDLK_KP_9
00300 
00301 // Meta key constants which got renamed.
00302 #define KMOD_META KMOD_GUI
00303 
00304 // SDL surface flags which got removed.
00305 #define SDL_SRCCOLORKEY 0
00306 #define SDL_SRCALPHA    0
00307 #define SDL_FULLSCREEN  0x40000000
00308 
00309 // Compatibility implementations for removed functionality.
00310 int SDL_SetColors(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors);
00311 int SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha);
00312 
00313 #define SDL_SetColorKey SDL_SetColorKey_replacement
00314 int SDL_SetColorKey_replacement(SDL_Surface *surface, Uint32 flag, Uint32 key);
00315 
00316 #endif
00317 
00318 
00319 #endif


Generated on Sat Feb 16 2019 05:01:03 for ResidualVM by doxygen 1.7.1
curved edge   curved edge