SDL_compat.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. /*
  2. SDL - Simple DirectMedia Layer
  3. Copyright (C) 1997-2010 Sam Lantinga
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. Sam Lantinga
  16. [email protected]
  17. */
  18. /**
  19. * \defgroup Compatibility SDL 1.2 Compatibility API
  20. */
  21. /*@{*/
  22. /**
  23. * \file SDL_compat.h
  24. *
  25. * This file contains functions for backwards compatibility with SDL 1.2.
  26. */
  27. /**
  28. * \def SDL_NO_COMPAT
  29. *
  30. * #define SDL_NO_COMPAT to prevent SDL_compat.h from being included.
  31. * SDL_NO_COMPAT is intended to make it easier to covert SDL 1.2 code to
  32. * SDL 1.3/2.0.
  33. */
  34. /*@}*/
  35. #ifdef SDL_NO_COMPAT
  36. #define _SDL_compat_h
  37. #endif
  38. #ifndef _SDL_compat_h
  39. #define _SDL_compat_h
  40. #include "SDL_video.h"
  41. #include "SDL_version.h"
  42. #include "begin_code.h"
  43. /* Set up for C function definitions, even when using C++ */
  44. #ifdef __cplusplus
  45. /* *INDENT-OFF* */
  46. extern "C" {
  47. /* *INDENT-ON* */
  48. #endif
  49. /**
  50. * \addtogroup Compatibility
  51. */
  52. /*@{*/
  53. /**
  54. * \name Surface flags
  55. */
  56. /*@{*/
  57. #define SDL_SWSURFACE 0x00000000 /**< \note Not used */
  58. #define SDL_SRCALPHA 0x00010000
  59. #define SDL_SRCCOLORKEY 0x00020000
  60. #define SDL_ANYFORMAT 0x00100000
  61. #define SDL_HWPALETTE 0x00200000
  62. #define SDL_DOUBLEBUF 0x00400000
  63. #define SDL_FULLSCREEN 0x00800000
  64. #define SDL_RESIZABLE 0x01000000
  65. #define SDL_NOFRAME 0x02000000
  66. #define SDL_OPENGL 0x04000000
  67. #define SDL_HWSURFACE 0x08000001 /**< \note Not used */
  68. #define SDL_ASYNCBLIT 0x08000000 /**< \note Not used */
  69. #define SDL_RLEACCELOK 0x08000000 /**< \note Not used */
  70. #define SDL_HWACCEL 0x08000000 /**< \note Not used */
  71. /*@}*//*Surface flags*/
  72. #define SDL_APPMOUSEFOCUS 0x01
  73. #define SDL_APPINPUTFOCUS 0x02
  74. #define SDL_APPACTIVE 0x04
  75. #define SDL_LOGPAL 0x01
  76. #define SDL_PHYSPAL 0x02
  77. #define SDL_ACTIVEEVENT SDL_EVENT_COMPAT1
  78. #define SDL_VIDEORESIZE SDL_EVENT_COMPAT2
  79. #define SDL_VIDEOEXPOSE SDL_EVENT_COMPAT3
  80. #define SDL_ACTIVEEVENTMASK SDL_ACTIVEEVENT, SDL_ACTIVEEVENT
  81. #define SDL_VIDEORESIZEMASK SDL_VIDEORESIZE, SDL_VIDEORESIZE
  82. #define SDL_VIDEOEXPOSEMASK SDL_VIDEOEXPOSE, SDL_VIDEOEXPOSE
  83. #define SDL_WINDOWEVENTMASK SDL_WINDOWEVENT, SDL_WINDOWEVENT
  84. #define SDL_KEYDOWNMASK SDL_KEYDOWN, SDL_KEYDOWN
  85. #define SDL_KEYUPMASK SDL_KEYUP, SDL_KEYUP
  86. #define SDL_KEYEVENTMASK SDL_KEYDOWN, SDL_KEYUP
  87. #define SDL_TEXTEDITINGMASK SDL_TEXTEDITING, SDL_TEXTEDITING
  88. #define SDL_TEXTINPUTMASK SDL_TEXTINPUT, SDL_TEXTINPUT
  89. #define SDL_MOUSEMOTIONMASK SDL_MOUSEMOTION, SDL_MOUSEMOTION
  90. #define SDL_MOUSEBUTTONDOWNMASK SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONDOWN
  91. #define SDL_MOUSEBUTTONUPMASK SDL_MOUSEBUTTONUP, SDL_MOUSEBUTTONUP
  92. #define SDL_MOUSEWHEELMASK SDL_MOUSEWHEEL, SDL_MOUSEWHEEL
  93. #define SDL_MOUSEEVENTMASK SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP
  94. #define SDL_JOYAXISMOTIONMASK SDL_JOYAXISMOTION, SDL_JOYAXISMOTION
  95. #define SDL_JOYBALLMOTIONMASK SDL_JOYBALLMOTION, SDL_JOYBALLMOTION
  96. #define SDL_JOYHATMOTIONMASK SDL_JOYHATMOTION, SDL_JOYHATMOTION
  97. #define SDL_JOYBUTTONDOWNMASK SDL_JOYBUTTONDOWN, SDL_JOYBUTTONDOWN
  98. #define SDL_JOYBUTTONUPMASK SDL_JOYBUTTONUP, SDL_JOYBUTTONUP
  99. #define SDL_JOYEVENTMASK SDL_JOYAXISMOTION, SDL_JOYBUTTONUP
  100. #define SDL_QUITMASK SDL_QUIT, SDL_QUIT
  101. #define SDL_SYSWMEVENTMASK SDL_SYSWMEVENT, SDL_SYSWMEVENT
  102. #define SDL_PROXIMITYINMASK SDL_PROXIMITYIN, SDL_PROXIMITYIN
  103. #define SDL_PROXIMITYOUTMASK SDL_PROXIMITYOUT, SDL_PROXIMITYOUT
  104. #define SDL_ALLEVENTS SDL_FIRSTEVENT, SDL_LASTEVENT
  105. #define SDL_BUTTON_WHEELUP 4
  106. #define SDL_BUTTON_WHEELDOWN 5
  107. #define SDL_DEFAULT_REPEAT_DELAY 500
  108. #define SDL_DEFAULT_REPEAT_INTERVAL 30
  109. typedef struct SDL_VideoInfo
  110. {
  111. Uint32 hw_available:1;
  112. Uint32 wm_available:1;
  113. Uint32 UnusedBits1:6;
  114. Uint32 UnusedBits2:1;
  115. Uint32 blit_hw:1;
  116. Uint32 blit_hw_CC:1;
  117. Uint32 blit_hw_A:1;
  118. Uint32 blit_sw:1;
  119. Uint32 blit_sw_CC:1;
  120. Uint32 blit_sw_A:1;
  121. Uint32 blit_fill:1;
  122. Uint32 UnusedBits3:16;
  123. Uint32 video_mem;
  124. SDL_PixelFormat *vfmt;
  125. int current_w;
  126. int current_h;
  127. } SDL_VideoInfo;
  128. /**
  129. * \name Overlay formats
  130. *
  131. * The most common video overlay formats.
  132. *
  133. * For an explanation of these pixel formats, see:
  134. * http://www.webartz.com/fourcc/indexyuv.htm
  135. *
  136. * For information on the relationship between color spaces, see:
  137. * http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
  138. */
  139. /*@{*/
  140. #define SDL_YV12_OVERLAY 0x32315659 /**< Planar mode: Y + V + U (3 planes) */
  141. #define SDL_IYUV_OVERLAY 0x56555949 /**< Planar mode: Y + U + V (3 planes) */
  142. #define SDL_YUY2_OVERLAY 0x32595559 /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
  143. #define SDL_UYVY_OVERLAY 0x59565955 /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
  144. #define SDL_YVYU_OVERLAY 0x55595659 /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
  145. /*@}*//*Overlay formats*/
  146. /**
  147. * The YUV hardware video overlay.
  148. */
  149. typedef struct SDL_Overlay
  150. {
  151. Uint32 format; /**< Read-only */
  152. int w, h; /**< Read-only */
  153. int planes; /**< Read-only */
  154. Uint16 *pitches; /**< Read-only */
  155. Uint8 **pixels; /**< Read-write */
  156. /**
  157. * \name Hardware-specific surface info
  158. */
  159. /*@{*/
  160. struct private_yuvhwfuncs *hwfuncs;
  161. struct private_yuvhwdata *hwdata;
  162. /*@}*//*Hardware-specific surface info*/
  163. /**
  164. * \name Special flags
  165. */
  166. /*@{*/
  167. Uint32 hw_overlay:1; /**< Flag: This overlay hardware accelerated? */
  168. Uint32 UnusedBits:31;
  169. /*@}*//*Special flags*/
  170. } SDL_Overlay;
  171. typedef enum
  172. {
  173. SDL_GRAB_QUERY = -1,
  174. SDL_GRAB_OFF = 0,
  175. SDL_GRAB_ON = 1
  176. } SDL_GrabMode;
  177. struct SDL_SysWMinfo;
  178. /**
  179. * \name Obsolete or renamed key codes
  180. */
  181. /*@{*/
  182. /**
  183. * \name Renamed keys
  184. *
  185. * These key constants were renamed for clarity or consistency.
  186. */
  187. /*@{*/
  188. #define SDLK_KP0 SDLK_KP_0
  189. #define SDLK_KP1 SDLK_KP_1
  190. #define SDLK_KP2 SDLK_KP_2
  191. #define SDLK_KP3 SDLK_KP_3
  192. #define SDLK_KP4 SDLK_KP_4
  193. #define SDLK_KP5 SDLK_KP_5
  194. #define SDLK_KP6 SDLK_KP_6
  195. #define SDLK_KP7 SDLK_KP_7
  196. #define SDLK_KP8 SDLK_KP_8
  197. #define SDLK_KP9 SDLK_KP_9
  198. #define SDLK_NUMLOCK SDLK_NUMLOCKCLEAR
  199. #define SDLK_SCROLLOCK SDLK_SCROLLLOCK
  200. #define SDLK_PRINT SDLK_PRINTSCREEN
  201. #define SDLK_LMETA SDLK_LGUI
  202. #define SDLK_RMETA SDLK_RGUI
  203. /*@}*//*Renamed keys*/
  204. /**
  205. * \name META modifier
  206. *
  207. * The META modifier is equivalent to the GUI modifier from the USB standard.
  208. */
  209. /*@{*/
  210. #define KMOD_LMETA KMOD_LGUI
  211. #define KMOD_RMETA KMOD_RGUI
  212. #define KMOD_META KMOD_GUI
  213. /*@}*//*META modifier*/
  214. /**
  215. * \name Not in USB
  216. *
  217. * These keys don't appear in the USB specification (or at least not under
  218. * those names). I'm unsure if the following assignments make sense or if these
  219. * codes should be defined as actual additional SDLK_ constants.
  220. */
  221. /*@{*/
  222. #define SDLK_LSUPER SDLK_LMETA
  223. #define SDLK_RSUPER SDLK_RMETA
  224. #define SDLK_COMPOSE SDLK_APPLICATION
  225. #define SDLK_BREAK SDLK_STOP
  226. #define SDLK_EURO SDLK_2
  227. /*@}*//*Not in USB*/
  228. /*@}*//*Obsolete or renamed key codes*/
  229. #define SDL_SetModuleHandle(x)
  230. #define SDL_AllocSurface SDL_CreateRGBSurface
  231. extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void);
  232. extern DECLSPEC char *SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen);
  233. extern DECLSPEC char *SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen);
  234. extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void);
  235. extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width,
  236. int height,
  237. int bpp, Uint32 flags);
  238. extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(const SDL_PixelFormat *
  239. format, Uint32 flags);
  240. extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width, int height,
  241. int bpp, Uint32 flags);
  242. extern DECLSPEC SDL_Surface *SDLCALL SDL_GetVideoSurface(void);
  243. extern DECLSPEC void SDLCALL SDL_UpdateRects(SDL_Surface * screen,
  244. int numrects, SDL_Rect * rects);
  245. extern DECLSPEC void SDLCALL SDL_UpdateRect(SDL_Surface * screen,
  246. Sint32 x,
  247. Sint32 y, Uint32 w, Uint32 h);
  248. extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface * screen);
  249. extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface * surface,
  250. Uint32 flag, Uint8 alpha);
  251. extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormat(SDL_Surface * surface);
  252. extern DECLSPEC SDL_Surface *SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *
  253. surface);
  254. extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title,
  255. const char *icon);
  256. extern DECLSPEC void SDLCALL SDL_WM_GetCaption(const char **title,
  257. const char **icon);
  258. extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask);
  259. extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
  260. extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface * surface);
  261. extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode);
  262. extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface * surface,
  263. int flags,
  264. const SDL_Color * colors,
  265. int firstcolor, int ncolors);
  266. extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface * surface,
  267. const SDL_Color * colors,
  268. int firstcolor, int ncolors);
  269. extern DECLSPEC int SDLCALL SDL_GetWMInfo(struct SDL_SysWMinfo *info);
  270. extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void);
  271. extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y);
  272. extern DECLSPEC SDL_Overlay *SDLCALL SDL_CreateYUVOverlay(int width,
  273. int height,
  274. Uint32 format,
  275. SDL_Surface *
  276. display);
  277. extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay * overlay);
  278. extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay * overlay);
  279. extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay * overlay,
  280. SDL_Rect * dstrect);
  281. extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay);
  282. extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
  283. extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval);
  284. extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
  285. extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
  286. #define SDL_TextureID SDL_Texture*
  287. #define SDL_WindowID SDL_Window*
  288. #define SDL_RenderPoint SDL_RenderDrawPoint
  289. #define SDL_RenderLine SDL_RenderDrawLine
  290. #define SDL_RenderFill(X) (X) ? SDL_RenderFillRect(X) : SDL_RenderClear()
  291. #define SDL_KillThread(X)
  292. extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
  293. /*@}*//*Compatibility*/
  294. /* Ends C function definitions when using C++ */
  295. #ifdef __cplusplus
  296. /* *INDENT-OFF* */
  297. }
  298. /* *INDENT-ON* */
  299. #endif
  300. #include "close_code.h"
  301. #endif /* _SDL_compat_h */
  302. /* vi: set ts=4 sw=4 expandtab: */