include/SDL_compat.h
author Tim Angus <tim@blackcompanystudios.co.uk>
Fri, 10 Jun 2011 14:23:24 +0100
changeset 5554 4b4258be8699
parent 5535 96594ac5fd1a
child 6138 4c64952a58fb
permissions -rw-r--r--
* SDL_IOS_ORIENTATIONS hint
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
     4 
     5   This software is provided 'as-is', without any express or implied
     6   warranty.  In no event will the authors be held liable for any damages
     7   arising from the use of this software.
     8 
     9   Permission is granted to anyone to use this software for any purpose,
    10   including commercial applications, and to alter it and redistribute it
    11   freely, subject to the following restrictions:
    12 
    13   1. The origin of this software must not be misrepresented; you must not
    14      claim that you wrote the original software. If you use this software
    15      in a product, an acknowledgment in the product documentation would be
    16      appreciated but is not required.
    17   2. Altered source versions must be plainly marked as such, and must not be
    18      misrepresented as being the original software.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    21 
    22  /**
    23  *  \defgroup Compatibility SDL 1.2 Compatibility API
    24  */
    25 /*@{*/
    26 
    27 /**
    28  *  \file SDL_compat.h
    29  *
    30  *  This file contains functions for backwards compatibility with SDL 1.2.
    31  */
    32 
    33 /**
    34  *  \def SDL_NO_COMPAT
    35  *
    36  *  #define SDL_NO_COMPAT to prevent SDL_compat.h from being included.
    37  *  SDL_NO_COMPAT is intended to make it easier to covert SDL 1.2 code to
    38  *  SDL 1.3/2.0.
    39  */
    40 
    41  /*@}*/
    42 
    43 #ifdef SDL_NO_COMPAT
    44 #define _SDL_compat_h
    45 #endif
    46 
    47 #ifndef _SDL_compat_h
    48 #define _SDL_compat_h
    49 
    50 #include "SDL_video.h"
    51 #include "SDL_version.h"
    52 
    53 #include "begin_code.h"
    54 /* Set up for C function definitions, even when using C++ */
    55 #ifdef __cplusplus
    56 /* *INDENT-OFF* */
    57 extern "C" {
    58 /* *INDENT-ON* */
    59 #endif
    60 
    61 /**
    62  *  \addtogroup Compatibility
    63  */
    64 /*@{*/
    65 
    66 /* Platform */
    67 #ifdef __WIN32__
    68 #undef __WIN32__
    69 #define __WIN32__   1
    70 #endif
    71 
    72 /**
    73  *  \name Surface flags
    74  */
    75 /*@{*/
    76 #define SDL_SWSURFACE       0x00000000  /**< \note Not used */
    77 #define SDL_SRCALPHA        0x00010000
    78 #define SDL_SRCCOLORKEY     0x00020000
    79 #define SDL_ANYFORMAT       0x00100000
    80 #define SDL_HWPALETTE       0x00200000
    81 #define SDL_DOUBLEBUF       0x00400000
    82 #define SDL_FULLSCREEN      0x00800000
    83 #define SDL_RESIZABLE       0x01000000
    84 #define SDL_NOFRAME         0x02000000
    85 #define SDL_OPENGL          0x04000000
    86 #define SDL_HWSURFACE       0x08000001  /**< \note Not used */
    87 #define SDL_ASYNCBLIT       0x08000000  /**< \note Not used */
    88 #define SDL_RLEACCELOK      0x08000000  /**< \note Not used */
    89 #define SDL_HWACCEL         0x08000000  /**< \note Not used */
    90 /*@}*//*Surface flags*/
    91 
    92 #define SDL_APPMOUSEFOCUS	0x01
    93 #define SDL_APPINPUTFOCUS	0x02
    94 #define SDL_APPACTIVE		0x04
    95 
    96 #define SDL_LOGPAL 0x01
    97 #define SDL_PHYSPAL 0x02
    98 
    99 #define SDL_ACTIVEEVENT	SDL_EVENT_COMPAT1
   100 #define SDL_VIDEORESIZE	SDL_EVENT_COMPAT2
   101 #define SDL_VIDEOEXPOSE	SDL_EVENT_COMPAT3
   102 #define SDL_ACTIVEEVENTMASK	SDL_ACTIVEEVENT, SDL_ACTIVEEVENT
   103 #define SDL_VIDEORESIZEMASK SDL_VIDEORESIZE, SDL_VIDEORESIZE
   104 #define SDL_VIDEOEXPOSEMASK SDL_VIDEOEXPOSE, SDL_VIDEOEXPOSE
   105 #define SDL_WINDOWEVENTMASK SDL_WINDOWEVENT, SDL_WINDOWEVENT
   106 #define SDL_KEYDOWNMASK SDL_KEYDOWN, SDL_KEYDOWN
   107 #define SDL_KEYUPMASK SDL_KEYUP, SDL_KEYUP
   108 #define SDL_KEYEVENTMASK SDL_KEYDOWN, SDL_KEYUP
   109 #define SDL_TEXTEDITINGMASK SDL_TEXTEDITING, SDL_TEXTEDITING
   110 #define SDL_TEXTINPUTMASK SDL_TEXTINPUT, SDL_TEXTINPUT
   111 #define SDL_MOUSEMOTIONMASK SDL_MOUSEMOTION, SDL_MOUSEMOTION
   112 #define SDL_MOUSEBUTTONDOWNMASK SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONDOWN
   113 #define SDL_MOUSEBUTTONUPMASK SDL_MOUSEBUTTONUP, SDL_MOUSEBUTTONUP
   114 #define SDL_MOUSEWHEELMASK SDL_MOUSEWHEEL, SDL_MOUSEWHEEL
   115 #define SDL_MOUSEEVENTMASK SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP
   116 #define SDL_JOYAXISMOTIONMASK SDL_JOYAXISMOTION, SDL_JOYAXISMOTION
   117 #define SDL_JOYBALLMOTIONMASK SDL_JOYBALLMOTION, SDL_JOYBALLMOTION
   118 #define SDL_JOYHATMOTIONMASK SDL_JOYHATMOTION, SDL_JOYHATMOTION
   119 #define SDL_JOYBUTTONDOWNMASK SDL_JOYBUTTONDOWN, SDL_JOYBUTTONDOWN
   120 #define SDL_JOYBUTTONUPMASK SDL_JOYBUTTONUP, SDL_JOYBUTTONUP
   121 #define SDL_JOYEVENTMASK SDL_JOYAXISMOTION, SDL_JOYBUTTONUP
   122 #define SDL_QUITMASK SDL_QUIT, SDL_QUIT
   123 #define SDL_SYSWMEVENTMASK SDL_SYSWMEVENT, SDL_SYSWMEVENT
   124 #define SDL_PROXIMITYINMASK SDL_PROXIMITYIN, SDL_PROXIMITYIN
   125 #define SDL_PROXIMITYOUTMASK SDL_PROXIMITYOUT, SDL_PROXIMITYOUT
   126 #define SDL_ALLEVENTS SDL_FIRSTEVENT, SDL_LASTEVENT
   127 
   128 #define SDL_BUTTON_WHEELUP	4
   129 #define SDL_BUTTON_WHEELDOWN	5
   130 
   131 #define SDL_DEFAULT_REPEAT_DELAY	500
   132 #define SDL_DEFAULT_REPEAT_INTERVAL	30
   133 
   134 typedef struct SDL_VideoInfo
   135 {
   136     Uint32 hw_available:1;
   137     Uint32 wm_available:1;
   138     Uint32 UnusedBits1:6;
   139     Uint32 UnusedBits2:1;
   140     Uint32 blit_hw:1;
   141     Uint32 blit_hw_CC:1;
   142     Uint32 blit_hw_A:1;
   143     Uint32 blit_sw:1;
   144     Uint32 blit_sw_CC:1;
   145     Uint32 blit_sw_A:1;
   146     Uint32 blit_fill:1;
   147     Uint32 UnusedBits3:16;
   148     Uint32 video_mem;
   149 
   150     SDL_PixelFormat *vfmt;
   151 
   152     int current_w;
   153     int current_h;
   154 } SDL_VideoInfo;
   155 
   156 /**
   157  *  \name Overlay formats
   158  *
   159  *  The most common video overlay formats.
   160  *  
   161  *  For an explanation of these pixel formats, see:
   162  *  http://www.webartz.com/fourcc/indexyuv.htm
   163  *  
   164  *  For information on the relationship between color spaces, see:
   165  *  http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
   166  */
   167 /*@{*/
   168 #define SDL_YV12_OVERLAY  0x32315659    /**< Planar mode: Y + V + U  (3 planes) */
   169 #define SDL_IYUV_OVERLAY  0x56555949    /**< Planar mode: Y + U + V  (3 planes) */
   170 #define SDL_YUY2_OVERLAY  0x32595559    /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
   171 #define SDL_UYVY_OVERLAY  0x59565955    /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
   172 #define SDL_YVYU_OVERLAY  0x55595659    /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
   173 /*@}*//*Overlay formats*/
   174 
   175 /**
   176  *  The YUV hardware video overlay.
   177  */
   178 typedef struct SDL_Overlay
   179 {
   180     Uint32 format;              /**< Read-only */
   181     int w, h;                   /**< Read-only */
   182     int planes;                 /**< Read-only */
   183     Uint16 *pitches;            /**< Read-only */
   184     Uint8 **pixels;             /**< Read-write */
   185 
   186     /** 
   187      *  \name Hardware-specific surface info
   188      */
   189     /*@{*/
   190     struct private_yuvhwfuncs *hwfuncs;
   191     struct private_yuvhwdata *hwdata;
   192     /*@}*//*Hardware-specific surface info*/
   193 
   194     /** 
   195      *  \name Special flags
   196      */
   197     /*@{*/
   198     Uint32 hw_overlay:1;        /**< Flag: This overlay hardware accelerated? */
   199     Uint32 UnusedBits:31;
   200     /*@}*//*Special flags*/
   201 } SDL_Overlay;
   202 
   203 typedef enum
   204 {
   205     SDL_GRAB_QUERY = -1,
   206     SDL_GRAB_OFF = 0,
   207     SDL_GRAB_ON = 1
   208 } SDL_GrabMode;
   209 
   210 struct SDL_SysWMinfo;
   211 
   212 /**
   213  *  \name Obsolete or renamed key codes
   214  */
   215 /*@{*/
   216 
   217 #define SDL_keysym		SDL_Keysym
   218 #define SDL_KeySym		SDL_Keysym
   219 #define SDL_scancode	SDL_Scancode
   220 #define SDL_ScanCode	SDL_Scancode
   221 #define SDLKey          SDL_Keycode
   222 #define SDLMod          SDL_Keymod
   223 
   224 /** 
   225  *  \name Renamed keys
   226  *
   227  *  These key constants were renamed for clarity or consistency. 
   228  */
   229 /*@{*/
   230 #define SDLK_KP0 SDLK_KP_0
   231 #define SDLK_KP1 SDLK_KP_1
   232 #define SDLK_KP2 SDLK_KP_2
   233 #define SDLK_KP3 SDLK_KP_3
   234 #define SDLK_KP4 SDLK_KP_4
   235 #define SDLK_KP5 SDLK_KP_5
   236 #define SDLK_KP6 SDLK_KP_6
   237 #define SDLK_KP7 SDLK_KP_7
   238 #define SDLK_KP8 SDLK_KP_8
   239 #define SDLK_KP9 SDLK_KP_9
   240 #define SDLK_NUMLOCK SDLK_NUMLOCKCLEAR
   241 #define SDLK_SCROLLOCK SDLK_SCROLLLOCK
   242 #define SDLK_PRINT SDLK_PRINTSCREEN
   243 #define SDLK_LMETA SDLK_LGUI
   244 #define SDLK_RMETA SDLK_RGUI
   245 /*@}*//*Renamed keys*/
   246 
   247 /**
   248  *  \name META modifier
   249  *  
   250  *  The META modifier is equivalent to the GUI modifier from the USB standard.
   251  */
   252 /*@{*/
   253 #define KMOD_LMETA KMOD_LGUI
   254 #define KMOD_RMETA KMOD_RGUI
   255 #define KMOD_META KMOD_GUI
   256 /*@}*//*META modifier*/
   257 
   258 /** 
   259  *  \name Not in USB
   260  *
   261  *  These keys don't appear in the USB specification (or at least not under 
   262  *  those names). I'm unsure if the following assignments make sense or if these
   263  *  codes should be defined as actual additional SDLK_ constants.
   264  */
   265 /*@{*/
   266 #define SDLK_LSUPER SDLK_LMETA
   267 #define SDLK_RSUPER SDLK_RMETA
   268 #define SDLK_COMPOSE SDLK_APPLICATION
   269 #define SDLK_BREAK SDLK_STOP
   270 #define SDLK_EURO SDLK_2
   271 /*@}*//*Not in USB*/
   272 
   273 /*@}*//*Obsolete or renamed key codes*/
   274 
   275 #define SDL_SetModuleHandle(x)
   276 #define SDL_AllocSurface    SDL_CreateRGBSurface
   277 
   278 extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void);
   279 extern DECLSPEC const char *SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
   280 extern DECLSPEC const char *SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen);
   281 extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void);
   282 extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width,
   283                                             int height,
   284                                             int bpp, Uint32 flags);
   285 extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(const SDL_PixelFormat *
   286                                                  format, Uint32 flags);
   287 extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width, int height,
   288                                                       int bpp, Uint32 flags);
   289 extern DECLSPEC SDL_Surface *SDLCALL SDL_GetVideoSurface(void);
   290 extern DECLSPEC void SDLCALL SDL_UpdateRects(SDL_Surface * screen,
   291                                              int numrects, SDL_Rect * rects);
   292 extern DECLSPEC void SDLCALL SDL_UpdateRect(SDL_Surface * screen,
   293                                             Sint32 x,
   294                                             Sint32 y, Uint32 w, Uint32 h);
   295 extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface * screen);
   296 extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface * surface,
   297                                          Uint32 flag, Uint8 alpha);
   298 extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormat(SDL_Surface * surface);
   299 extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *
   300                                                             surface);
   301 extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title,
   302                                                const char *icon);
   303 extern DECLSPEC void SDLCALL SDL_WM_GetCaption(const char **title,
   304                                                const char **icon);
   305 extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask);
   306 extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
   307 extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface * surface);
   308 extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode);
   309 extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface * surface,
   310                                            int flags,
   311                                            const SDL_Color * colors,
   312                                            int firstcolor, int ncolors);
   313 extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface * surface,
   314                                           const SDL_Color * colors,
   315                                           int firstcolor, int ncolors);
   316 extern DECLSPEC int SDLCALL SDL_GetWMInfo(struct SDL_SysWMinfo *info);
   317 extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void);
   318 extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
   319 extern DECLSPEC SDL_Overlay *SDLCALL SDL_CreateYUVOverlay(int width,
   320                                                           int height,
   321                                                           Uint32 format,
   322                                                           SDL_Surface *
   323                                                           display);
   324 extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay * overlay);
   325 extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay * overlay);
   326 extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay * overlay,
   327                                                   SDL_Rect * dstrect);
   328 extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay);
   329 extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
   330 extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue);
   331 extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 * red,
   332                                              const Uint16 * green,
   333                                              const Uint16 * blue);
   334 extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 * red, Uint16 * green,
   335                                              Uint16 * blue);
   336 extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
   337 extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
   338 extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
   339 
   340 typedef SDL_Window* SDL_WindowID;
   341 
   342 #define SDL_KillThread(X)
   343 
   344 /* The timeslice and timer resolution are no longer relevant */
   345 #define SDL_TIMESLICE		10
   346 #define TIMER_RESOLUTION	10
   347 
   348 typedef Uint32 (SDLCALL * SDL_OldTimerCallback) (Uint32 interval);
   349 extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_OldTimerCallback callback);
   350 
   351 extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
   352 
   353 /*@}*//*Compatibility*/
   354 
   355 /* Ends C function definitions when using C++ */
   356 #ifdef __cplusplus
   357 /* *INDENT-OFF* */
   358 }
   359 /* *INDENT-ON* */
   360 #endif
   361 #include "close_code.h"
   362 
   363 #endif /* _SDL_compat_h */
   364 
   365 /* vi: set ts=4 sw=4 expandtab: */