icculus@9
|
1 |
/*
|
icculus@9
|
2 |
Simple DirectMedia Layer
|
icculus@46
|
3 |
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
icculus@9
|
4 |
|
icculus@9
|
5 |
This software is provided 'as-is', without any express or implied
|
icculus@9
|
6 |
warranty. In no event will the authors be held liable for any damages
|
icculus@9
|
7 |
arising from the use of this software.
|
icculus@9
|
8 |
|
icculus@9
|
9 |
Permission is granted to anyone to use this software for any purpose,
|
icculus@9
|
10 |
including commercial applications, and to alter it and redistribute it
|
icculus@9
|
11 |
freely, subject to the following restrictions:
|
icculus@9
|
12 |
|
icculus@9
|
13 |
1. The origin of this software must not be misrepresented; you must not
|
icculus@9
|
14 |
claim that you wrote the original software. If you use this software
|
icculus@9
|
15 |
in a product, an acknowledgment in the product documentation would be
|
icculus@9
|
16 |
appreciated but is not required.
|
icculus@9
|
17 |
2. Altered source versions must be plainly marked as such, and must not be
|
icculus@9
|
18 |
misrepresented as being the original software.
|
icculus@9
|
19 |
3. This notice may not be removed or altered from any source distribution.
|
icculus@9
|
20 |
*/
|
icculus@9
|
21 |
|
icculus@9
|
22 |
/* This file contains functions for backwards compatibility with SDL 1.2 */
|
icculus@9
|
23 |
|
icculus@49
|
24 |
// !!! FIXME: clean up code conventions
|
icculus@54
|
25 |
// !!! FIXME: grep for VideoWindow20 places that might care if it's NULL
|
icculus@49
|
26 |
|
icculus@31
|
27 |
#include "SDL20_include_wrapper.h"
|
icculus@9
|
28 |
|
icculus@9
|
29 |
#if !SDL_VERSION_ATLEAST(2,0,0)
|
icculus@9
|
30 |
#error You need to compile against SDL 2.0 headers.
|
icculus@9
|
31 |
#endif
|
icculus@9
|
32 |
|
icculus@33
|
33 |
/*
|
icculus@33
|
34 |
* We report the library version as 1.2.$(SDL12_COMPAT_VERSION). This number
|
icculus@33
|
35 |
* should be way ahead of what SDL-1.2 Classic would report, so apps can
|
icculus@33
|
36 |
* decide if they're running under the compat layer, if they really care.
|
icculus@33
|
37 |
*/
|
icculus@33
|
38 |
#define SDL12_COMPAT_VERSION 50
|
icculus@33
|
39 |
|
icculus@11
|
40 |
#include <stdarg.h>
|
icculus@11
|
41 |
|
icculus@49
|
42 |
// !!! IMPLEMENT_ME SDL_CDClose
|
icculus@49
|
43 |
// !!! IMPLEMENT_ME SDL_CDEject
|
icculus@49
|
44 |
// !!! IMPLEMENT_ME SDL_CDName
|
icculus@49
|
45 |
// !!! IMPLEMENT_ME SDL_CDNumDrives
|
icculus@49
|
46 |
// !!! IMPLEMENT_ME SDL_CDOpen
|
icculus@49
|
47 |
// !!! IMPLEMENT_ME SDL_CDPause
|
icculus@49
|
48 |
// !!! IMPLEMENT_ME SDL_CDPlay
|
icculus@49
|
49 |
// !!! IMPLEMENT_ME SDL_CDPlayTracks
|
icculus@49
|
50 |
// !!! IMPLEMENT_ME SDL_CDResume
|
icculus@49
|
51 |
// !!! IMPLEMENT_ME SDL_CDStatus
|
icculus@49
|
52 |
// !!! IMPLEMENT_ME SDL_CDStop
|
icculus@49
|
53 |
// !!! IMPLEMENT_ME SDL_CreateYUVOverlay
|
icculus@49
|
54 |
|
icculus@49
|
55 |
// !!! IMPLEMENT_ME SDL_DisplayFormatAlpha
|
icculus@49
|
56 |
// !!! IMPLEMENT_ME SDL_DisplayYUVOverlay
|
icculus@49
|
57 |
// !!! IMPLEMENT_ME SDL_EnableKeyRepeat
|
icculus@49
|
58 |
// !!! IMPLEMENT_ME SDL_EnableUNICODE
|
icculus@49
|
59 |
// !!! IMPLEMENT_ME SDL_FreeYUVOverlay
|
icculus@49
|
60 |
|
icculus@49
|
61 |
// !!! IMPLEMENT_ME SDL_GL_Lock
|
icculus@49
|
62 |
// !!! IMPLEMENT_ME SDL_GL_Unlock
|
icculus@49
|
63 |
// !!! IMPLEMENT_ME SDL_GL_UpdateRects
|
icculus@49
|
64 |
|
icculus@9
|
65 |
// !!! IMPLEMENT_ME SDL_GetKeyName
|
icculus@9
|
66 |
// !!! IMPLEMENT_ME SDL_GetKeyState
|
icculus@9
|
67 |
// !!! IMPLEMENT_ME SDL_GetModState
|
icculus@9
|
68 |
// !!! IMPLEMENT_ME SDL_GetRelativeMouseState
|
icculus@49
|
69 |
|
icculus@49
|
70 |
// !!! IMPLEMENT_ME SDL_GetVideoSurface
|
icculus@49
|
71 |
// !!! IMPLEMENT_ME SDL_GetWMInfo
|
icculus@49
|
72 |
|
icculus@9
|
73 |
// !!! IMPLEMENT_ME SDL_LockSurface
|
icculus@49
|
74 |
// !!! IMPLEMENT_ME SDL_LockYUVOverlay
|
icculus@9
|
75 |
// !!! IMPLEMENT_ME SDL_LowerBlit
|
icculus@49
|
76 |
|
icculus@49
|
77 |
// !!! IMPLEMENT_ME SDL_SetAlpha
|
icculus@9
|
78 |
// !!! IMPLEMENT_ME SDL_SetColorKey
|
icculus@49
|
79 |
// !!! IMPLEMENT_ME SDL_SetColors
|
icculus@49
|
80 |
|
icculus@9
|
81 |
// !!! IMPLEMENT_ME SDL_SetModState
|
icculus@49
|
82 |
// !!! IMPLEMENT_ME SDL_SetPalette
|
icculus@49
|
83 |
// !!! IMPLEMENT_ME SDL_SetVideoMode
|
icculus@9
|
84 |
// !!! IMPLEMENT_ME SDL_SoftStretch
|
icculus@9
|
85 |
// !!! IMPLEMENT_ME SDL_UnlockSurface
|
icculus@49
|
86 |
// !!! IMPLEMENT_ME SDL_UnlockYUVOverlay
|
icculus@49
|
87 |
// !!! IMPLEMENT_ME SDL_UpdateRects
|
icculus@9
|
88 |
// !!! IMPLEMENT_ME SDL_UpperBlit
|
icculus@49
|
89 |
|
icculus@49
|
90 |
// !!! FIXME: should SDL_VideoInit really be a passthrough?
|
icculus@49
|
91 |
// !!! FIXME: should SDL_VideoQuit really be a passthrough?
|
icculus@49
|
92 |
|
icculus@49
|
93 |
// !!! IMPLEMENT_ME SDL_WM_SetIcon
|
icculus@49
|
94 |
// !!! IMPLEMENT_ME SDL_WM_ToggleFullScreen
|
icculus@49
|
95 |
|
icculus@9
|
96 |
// !!! IMPLEMENT_ME X11_KeyToUnicode
|
icculus@9
|
97 |
|
icculus@64
|
98 |
#define SDL_BlitSurface SDL_UpperBlit
|
icculus@64
|
99 |
|
icculus@54
|
100 |
|
icculus@54
|
101 |
#if 0
|
icculus@54
|
102 |
#define FIXME(x) do {} while (0)
|
icculus@54
|
103 |
#else
|
icculus@54
|
104 |
#define FIXME(x) \
|
icculus@54
|
105 |
do { \
|
icculus@54
|
106 |
static SDL_bool seen = SDL_FALSE; \
|
icculus@54
|
107 |
if (!seen) { \
|
icculus@54
|
108 |
fprintf(stderr, "FIXME: %s (%s:%d)\n", x, __FILE__, __LINE__); \
|
icculus@54
|
109 |
seen = SDL_TRUE; \
|
icculus@54
|
110 |
} \
|
icculus@54
|
111 |
} while (0)
|
icculus@54
|
112 |
#endif
|
icculus@54
|
113 |
|
icculus@9
|
114 |
#define SDL20_SYM(rc,fn,params,args,ret) \
|
icculus@35
|
115 |
typedef rc (SDLCALL *SDL20_##fn##_t) params; \
|
icculus@9
|
116 |
static SDL20_##fn##_t SDL20_##fn = NULL;
|
icculus@9
|
117 |
#include "SDL20_syms.h"
|
icculus@48
|
118 |
|
icculus@34
|
119 |
/* Things that _should_ be binary compatible pass right through... */
|
icculus@34
|
120 |
#define SDL20_SYM_PASSTHROUGH(rc,fn,params,args,ret) \
|
icculus@35
|
121 |
DECLSPEC rc SDLCALL SDL_##fn params { ret SDL20_##fn args; }
|
icculus@34
|
122 |
#include "SDL20_syms.h"
|
icculus@34
|
123 |
|
icculus@34
|
124 |
|
icculus@34
|
125 |
/* these are macros (etc) in the SDL headers, so make our own. */
|
icculus@34
|
126 |
#define SDL20_OutOfMemory() SDL20_Error(SDL_ENOMEM)
|
icculus@34
|
127 |
#define SDL20_Unsupported() SDL20_Error(SDL_UNSUPPORTED)
|
icculus@34
|
128 |
#define SDL20_InvalidParamError(param) SDL20_SetError("Parameter '%s' is invalid", (param))
|
icculus@34
|
129 |
#define SDL20_zero(x) SDL20_memset(&(x), 0, sizeof((x)))
|
icculus@34
|
130 |
#define SDL20_zerop(x) SDL20_memset((x), 0, sizeof(*(x)))
|
icculus@34
|
131 |
#define SDL_ReportAssertion SDL20_ReportAssertion
|
icculus@34
|
132 |
|
icculus@34
|
133 |
#define SDL12_DEFAULT_REPEAT_DELAY 500
|
icculus@34
|
134 |
#define SDL12_DEFAULT_REPEAT_INTERVAL 30
|
icculus@9
|
135 |
|
icculus@9
|
136 |
#define SDL12_INIT_TIMER 0x00000001
|
icculus@9
|
137 |
#define SDL12_INIT_AUDIO 0x00000010
|
icculus@9
|
138 |
#define SDL12_INIT_VIDEO 0x00000020
|
icculus@9
|
139 |
#define SDL12_INIT_CDROM 0x00000100
|
icculus@9
|
140 |
#define SDL12_INIT_JOYSTICK 0x00000200
|
icculus@9
|
141 |
#define SDL12_INIT_NOPARACHUTE 0x00100000
|
icculus@9
|
142 |
#define SDL12_INIT_EVENTTHREAD 0x01000000
|
icculus@9
|
143 |
#define SDL12_INIT_EVERYTHING 0x0000FFFF
|
icculus@9
|
144 |
|
icculus@73
|
145 |
typedef struct SDL12_Rect
|
icculus@73
|
146 |
{
|
icculus@73
|
147 |
Sint16 x;
|
icculus@73
|
148 |
Sint16 y;
|
icculus@73
|
149 |
Uint16 w;
|
icculus@73
|
150 |
Uint16 h;
|
icculus@73
|
151 |
} SDL12_Rect;
|
icculus@73
|
152 |
|
icculus@15
|
153 |
typedef struct SDL12_Palette
|
icculus@15
|
154 |
{
|
icculus@15
|
155 |
int ncolors;
|
icculus@15
|
156 |
SDL_Color *colors;
|
icculus@15
|
157 |
} SDL12_Palette;
|
icculus@15
|
158 |
|
icculus@15
|
159 |
typedef struct SDL12_PixelFormat
|
icculus@15
|
160 |
{
|
icculus@15
|
161 |
SDL12_Palette *palette;
|
icculus@15
|
162 |
Uint8 BitsPerPixel;
|
icculus@15
|
163 |
Uint8 BytesPerPixel;
|
icculus@15
|
164 |
Uint8 Rloss;
|
icculus@15
|
165 |
Uint8 Gloss;
|
icculus@15
|
166 |
Uint8 Bloss;
|
icculus@15
|
167 |
Uint8 Aloss;
|
icculus@15
|
168 |
Uint8 Rshift;
|
icculus@15
|
169 |
Uint8 Gshift;
|
icculus@15
|
170 |
Uint8 Bshift;
|
icculus@15
|
171 |
Uint8 Ashift;
|
icculus@15
|
172 |
Uint32 Rmask;
|
icculus@15
|
173 |
Uint32 Gmask;
|
icculus@15
|
174 |
Uint32 Bmask;
|
icculus@15
|
175 |
Uint32 Amask;
|
icculus@15
|
176 |
Uint32 colorkey;
|
icculus@15
|
177 |
Uint8 alpha;
|
icculus@15
|
178 |
} SDL12_PixelFormat;
|
icculus@15
|
179 |
|
icculus@18
|
180 |
typedef struct SDL12_Surface
|
icculus@18
|
181 |
{
|
icculus@18
|
182 |
Uint32 flags;
|
icculus@18
|
183 |
SDL12_PixelFormat *format;
|
icculus@18
|
184 |
int w;
|
icculus@18
|
185 |
int h;
|
icculus@18
|
186 |
Uint16 pitch;
|
icculus@18
|
187 |
void *pixels;
|
icculus@18
|
188 |
int offset;
|
icculus@34
|
189 |
SDL_Surface *surface20; /* the real SDL 1.2 has an opaque pointer to a platform-specific thing here named "hwdata". */
|
icculus@73
|
190 |
SDL12_Rect clip_rect;
|
icculus@18
|
191 |
Uint32 unused1;
|
icculus@18
|
192 |
Uint32 locked;
|
icculus@18
|
193 |
void *blitmap;
|
icculus@18
|
194 |
unsigned int format_version;
|
icculus@18
|
195 |
int refcount;
|
icculus@18
|
196 |
} SDL12_Surface;
|
icculus@18
|
197 |
|
icculus@57
|
198 |
typedef struct SDL12_Overlay
|
icculus@57
|
199 |
{
|
icculus@57
|
200 |
Uint32 format;
|
icculus@57
|
201 |
int w;
|
icculus@57
|
202 |
int h;
|
icculus@57
|
203 |
int planes;
|
icculus@57
|
204 |
Uint16 *pitches;
|
icculus@57
|
205 |
Uint8 **pixels;
|
icculus@57
|
206 |
void *hwfuncs;
|
icculus@57
|
207 |
void *hwdata;
|
icculus@57
|
208 |
Uint32 hw_overlay :1;
|
icculus@57
|
209 |
Uint32 UnusedBits :31;
|
icculus@57
|
210 |
} SDL12_Overlay;
|
icculus@57
|
211 |
|
icculus@9
|
212 |
typedef struct
|
icculus@9
|
213 |
{
|
icculus@15
|
214 |
Uint32 hw_available :1;
|
icculus@15
|
215 |
Uint32 wm_available :1;
|
icculus@15
|
216 |
Uint32 UnusedBits1 :6;
|
icculus@15
|
217 |
Uint32 UnusedBits2 :1;
|
icculus@15
|
218 |
Uint32 blit_hw :1;
|
icculus@15
|
219 |
Uint32 blit_hw_CC :1;
|
icculus@15
|
220 |
Uint32 blit_hw_A :1;
|
icculus@15
|
221 |
Uint32 blit_sw :1;
|
icculus@15
|
222 |
Uint32 blit_sw_CC :1;
|
icculus@15
|
223 |
Uint32 blit_sw_A :1;
|
icculus@15
|
224 |
Uint32 blit_fill :1;
|
icculus@15
|
225 |
Uint32 UnusedBits3 :16;
|
icculus@15
|
226 |
Uint32 video_mem;
|
icculus@15
|
227 |
SDL_PixelFormat *vfmt;
|
icculus@15
|
228 |
int current_w;
|
icculus@15
|
229 |
int current_h;
|
icculus@9
|
230 |
} SDL12_VideoInfo;
|
icculus@9
|
231 |
|
icculus@9
|
232 |
|
icculus@15
|
233 |
#define SDL12_HWSURFACE 0x00000001
|
icculus@15
|
234 |
#define SDL12_ASYNCBLIT 0x00000004
|
icculus@15
|
235 |
#define SDL12_ANYFORMAT 0x10000000
|
icculus@15
|
236 |
#define SDL12_HWPALETTE 0x20000000
|
icculus@15
|
237 |
#define SDL12_DOUBLEBUF 0x40000000
|
icculus@15
|
238 |
#define SDL12_FULLSCREEN 0x80000000
|
icculus@15
|
239 |
#define SDL12_OPENGL 0x00000002
|
icculus@15
|
240 |
#define SDL12_OPENGLBLIT 0x0000000A
|
icculus@15
|
241 |
#define SDL12_RESIZABLE 0x00000010
|
icculus@15
|
242 |
#define SDL12_NOFRAME 0x00000020
|
icculus@15
|
243 |
#define SDL12_HWACCEL 0x00000100
|
icculus@15
|
244 |
#define SDL12_SRCCOLORKEY 0x00001000
|
icculus@15
|
245 |
#define SDL12_RLEACCELOK 0x00002000
|
icculus@15
|
246 |
#define SDL12_RLEACCEL 0x00004000
|
icculus@15
|
247 |
#define SDL12_SRCALPHA 0x00010000
|
icculus@15
|
248 |
#define SDL12_PREALLOC 0x01000000
|
icculus@9
|
249 |
|
icculus@18
|
250 |
typedef enum
|
icculus@18
|
251 |
{
|
icculus@77
|
252 |
SDLK12_UNKNOWN = 0,
|
icculus@77
|
253 |
SDLK12_FIRST = 0,
|
icculus@77
|
254 |
SDLK12_BACKSPACE = 8,
|
icculus@77
|
255 |
SDLK12_TAB = 9,
|
icculus@77
|
256 |
SDLK12_CLEAR = 12,
|
icculus@77
|
257 |
SDLK12_RETURN = 13,
|
icculus@77
|
258 |
SDLK12_PAUSE = 19,
|
icculus@77
|
259 |
SDLK12_ESCAPE = 27,
|
icculus@77
|
260 |
SDLK12_SPACE = 32,
|
icculus@77
|
261 |
SDLK12_EXCLAIM = 33,
|
icculus@77
|
262 |
SDLK12_QUOTEDBL = 34,
|
icculus@77
|
263 |
SDLK12_HASH = 35,
|
icculus@77
|
264 |
SDLK12_DOLLAR = 36,
|
icculus@77
|
265 |
SDLK12_AMPERSAND = 38,
|
icculus@77
|
266 |
SDLK12_QUOTE = 39,
|
icculus@77
|
267 |
SDLK12_LEFTPAREN = 40,
|
icculus@77
|
268 |
SDLK12_RIGHTPAREN = 41,
|
icculus@77
|
269 |
SDLK12_ASTERISK = 42,
|
icculus@77
|
270 |
SDLK12_PLUS = 43,
|
icculus@77
|
271 |
SDLK12_COMMA = 44,
|
icculus@77
|
272 |
SDLK12_MINUS = 45,
|
icculus@77
|
273 |
SDLK12_PERIOD = 46,
|
icculus@77
|
274 |
SDLK12_SLASH = 47,
|
icculus@77
|
275 |
SDLK12_0 = 48,
|
icculus@77
|
276 |
SDLK12_1 = 49,
|
icculus@77
|
277 |
SDLK12_2 = 50,
|
icculus@77
|
278 |
SDLK12_3 = 51,
|
icculus@77
|
279 |
SDLK12_4 = 52,
|
icculus@77
|
280 |
SDLK12_5 = 53,
|
icculus@77
|
281 |
SDLK12_6 = 54,
|
icculus@77
|
282 |
SDLK12_7 = 55,
|
icculus@77
|
283 |
SDLK12_8 = 56,
|
icculus@77
|
284 |
SDLK12_9 = 57,
|
icculus@77
|
285 |
SDLK12_COLON = 58,
|
icculus@77
|
286 |
SDLK12_SEMICOLON = 59,
|
icculus@77
|
287 |
SDLK12_LESS = 60,
|
icculus@77
|
288 |
SDLK12_EQUALS = 61,
|
icculus@77
|
289 |
SDLK12_GREATER = 62,
|
icculus@77
|
290 |
SDLK12_QUESTION = 63,
|
icculus@77
|
291 |
SDLK12_AT = 64,
|
icculus@77
|
292 |
SDLK12_LEFTBRACKET = 91,
|
icculus@77
|
293 |
SDLK12_BACKSLASH = 92,
|
icculus@77
|
294 |
SDLK12_RIGHTBRACKET = 93,
|
icculus@77
|
295 |
SDLK12_CARET = 94,
|
icculus@77
|
296 |
SDLK12_UNDERSCORE = 95,
|
icculus@77
|
297 |
SDLK12_BACKQUOTE = 96,
|
icculus@77
|
298 |
SDLK12_a = 97,
|
icculus@77
|
299 |
SDLK12_b = 98,
|
icculus@77
|
300 |
SDLK12_c = 99,
|
icculus@77
|
301 |
SDLK12_d = 100,
|
icculus@77
|
302 |
SDLK12_e = 101,
|
icculus@77
|
303 |
SDLK12_f = 102,
|
icculus@77
|
304 |
SDLK12_g = 103,
|
icculus@77
|
305 |
SDLK12_h = 104,
|
icculus@77
|
306 |
SDLK12_i = 105,
|
icculus@77
|
307 |
SDLK12_j = 106,
|
icculus@77
|
308 |
SDLK12_k = 107,
|
icculus@77
|
309 |
SDLK12_l = 108,
|
icculus@77
|
310 |
SDLK12_m = 109,
|
icculus@77
|
311 |
SDLK12_n = 110,
|
icculus@77
|
312 |
SDLK12_o = 111,
|
icculus@77
|
313 |
SDLK12_p = 112,
|
icculus@77
|
314 |
SDLK12_q = 113,
|
icculus@77
|
315 |
SDLK12_r = 114,
|
icculus@77
|
316 |
SDLK12_s = 115,
|
icculus@77
|
317 |
SDLK12_t = 116,
|
icculus@77
|
318 |
SDLK12_u = 117,
|
icculus@77
|
319 |
SDLK12_v = 118,
|
icculus@77
|
320 |
SDLK12_w = 119,
|
icculus@77
|
321 |
SDLK12_x = 120,
|
icculus@77
|
322 |
SDLK12_y = 121,
|
icculus@77
|
323 |
SDLK12_z = 122,
|
icculus@77
|
324 |
SDLK12_DELETE = 127,
|
icculus@77
|
325 |
SDLK12_WORLD_0 = 160,
|
icculus@77
|
326 |
SDLK12_WORLD_1 = 161,
|
icculus@77
|
327 |
SDLK12_WORLD_2 = 162,
|
icculus@77
|
328 |
SDLK12_WORLD_3 = 163,
|
icculus@77
|
329 |
SDLK12_WORLD_4 = 164,
|
icculus@77
|
330 |
SDLK12_WORLD_5 = 165,
|
icculus@77
|
331 |
SDLK12_WORLD_6 = 166,
|
icculus@77
|
332 |
SDLK12_WORLD_7 = 167,
|
icculus@77
|
333 |
SDLK12_WORLD_8 = 168,
|
icculus@77
|
334 |
SDLK12_WORLD_9 = 169,
|
icculus@77
|
335 |
SDLK12_WORLD_10 = 170,
|
icculus@77
|
336 |
SDLK12_WORLD_11 = 171,
|
icculus@77
|
337 |
SDLK12_WORLD_12 = 172,
|
icculus@77
|
338 |
SDLK12_WORLD_13 = 173,
|
icculus@77
|
339 |
SDLK12_WORLD_14 = 174,
|
icculus@77
|
340 |
SDLK12_WORLD_15 = 175,
|
icculus@77
|
341 |
SDLK12_WORLD_16 = 176,
|
icculus@77
|
342 |
SDLK12_WORLD_17 = 177,
|
icculus@77
|
343 |
SDLK12_WORLD_18 = 178,
|
icculus@77
|
344 |
SDLK12_WORLD_19 = 179,
|
icculus@77
|
345 |
SDLK12_WORLD_20 = 180,
|
icculus@77
|
346 |
SDLK12_WORLD_21 = 181,
|
icculus@77
|
347 |
SDLK12_WORLD_22 = 182,
|
icculus@77
|
348 |
SDLK12_WORLD_23 = 183,
|
icculus@77
|
349 |
SDLK12_WORLD_24 = 184,
|
icculus@77
|
350 |
SDLK12_WORLD_25 = 185,
|
icculus@77
|
351 |
SDLK12_WORLD_26 = 186,
|
icculus@77
|
352 |
SDLK12_WORLD_27 = 187,
|
icculus@77
|
353 |
SDLK12_WORLD_28 = 188,
|
icculus@77
|
354 |
SDLK12_WORLD_29 = 189,
|
icculus@77
|
355 |
SDLK12_WORLD_30 = 190,
|
icculus@77
|
356 |
SDLK12_WORLD_31 = 191,
|
icculus@77
|
357 |
SDLK12_WORLD_32 = 192,
|
icculus@77
|
358 |
SDLK12_WORLD_33 = 193,
|
icculus@77
|
359 |
SDLK12_WORLD_34 = 194,
|
icculus@77
|
360 |
SDLK12_WORLD_35 = 195,
|
icculus@77
|
361 |
SDLK12_WORLD_36 = 196,
|
icculus@77
|
362 |
SDLK12_WORLD_37 = 197,
|
icculus@77
|
363 |
SDLK12_WORLD_38 = 198,
|
icculus@77
|
364 |
SDLK12_WORLD_39 = 199,
|
icculus@77
|
365 |
SDLK12_WORLD_40 = 200,
|
icculus@77
|
366 |
SDLK12_WORLD_41 = 201,
|
icculus@77
|
367 |
SDLK12_WORLD_42 = 202,
|
icculus@77
|
368 |
SDLK12_WORLD_43 = 203,
|
icculus@77
|
369 |
SDLK12_WORLD_44 = 204,
|
icculus@77
|
370 |
SDLK12_WORLD_45 = 205,
|
icculus@77
|
371 |
SDLK12_WORLD_46 = 206,
|
icculus@77
|
372 |
SDLK12_WORLD_47 = 207,
|
icculus@77
|
373 |
SDLK12_WORLD_48 = 208,
|
icculus@77
|
374 |
SDLK12_WORLD_49 = 209,
|
icculus@77
|
375 |
SDLK12_WORLD_50 = 210,
|
icculus@77
|
376 |
SDLK12_WORLD_51 = 211,
|
icculus@77
|
377 |
SDLK12_WORLD_52 = 212,
|
icculus@77
|
378 |
SDLK12_WORLD_53 = 213,
|
icculus@77
|
379 |
SDLK12_WORLD_54 = 214,
|
icculus@77
|
380 |
SDLK12_WORLD_55 = 215,
|
icculus@77
|
381 |
SDLK12_WORLD_56 = 216,
|
icculus@77
|
382 |
SDLK12_WORLD_57 = 217,
|
icculus@77
|
383 |
SDLK12_WORLD_58 = 218,
|
icculus@77
|
384 |
SDLK12_WORLD_59 = 219,
|
icculus@77
|
385 |
SDLK12_WORLD_60 = 220,
|
icculus@77
|
386 |
SDLK12_WORLD_61 = 221,
|
icculus@77
|
387 |
SDLK12_WORLD_62 = 222,
|
icculus@77
|
388 |
SDLK12_WORLD_63 = 223,
|
icculus@77
|
389 |
SDLK12_WORLD_64 = 224,
|
icculus@77
|
390 |
SDLK12_WORLD_65 = 225,
|
icculus@77
|
391 |
SDLK12_WORLD_66 = 226,
|
icculus@77
|
392 |
SDLK12_WORLD_67 = 227,
|
icculus@77
|
393 |
SDLK12_WORLD_68 = 228,
|
icculus@77
|
394 |
SDLK12_WORLD_69 = 229,
|
icculus@77
|
395 |
SDLK12_WORLD_70 = 230,
|
icculus@77
|
396 |
SDLK12_WORLD_71 = 231,
|
icculus@77
|
397 |
SDLK12_WORLD_72 = 232,
|
icculus@77
|
398 |
SDLK12_WORLD_73 = 233,
|
icculus@77
|
399 |
SDLK12_WORLD_74 = 234,
|
icculus@77
|
400 |
SDLK12_WORLD_75 = 235,
|
icculus@77
|
401 |
SDLK12_WORLD_76 = 236,
|
icculus@77
|
402 |
SDLK12_WORLD_77 = 237,
|
icculus@77
|
403 |
SDLK12_WORLD_78 = 238,
|
icculus@77
|
404 |
SDLK12_WORLD_79 = 239,
|
icculus@77
|
405 |
SDLK12_WORLD_80 = 240,
|
icculus@77
|
406 |
SDLK12_WORLD_81 = 241,
|
icculus@77
|
407 |
SDLK12_WORLD_82 = 242,
|
icculus@77
|
408 |
SDLK12_WORLD_83 = 243,
|
icculus@77
|
409 |
SDLK12_WORLD_84 = 244,
|
icculus@77
|
410 |
SDLK12_WORLD_85 = 245,
|
icculus@77
|
411 |
SDLK12_WORLD_86 = 246,
|
icculus@77
|
412 |
SDLK12_WORLD_87 = 247,
|
icculus@77
|
413 |
SDLK12_WORLD_88 = 248,
|
icculus@77
|
414 |
SDLK12_WORLD_89 = 249,
|
icculus@77
|
415 |
SDLK12_WORLD_90 = 250,
|
icculus@77
|
416 |
SDLK12_WORLD_91 = 251,
|
icculus@77
|
417 |
SDLK12_WORLD_92 = 252,
|
icculus@77
|
418 |
SDLK12_WORLD_93 = 253,
|
icculus@77
|
419 |
SDLK12_WORLD_94 = 254,
|
icculus@77
|
420 |
SDLK12_WORLD_95 = 255,
|
icculus@77
|
421 |
SDLK12_KP0 = 256,
|
icculus@77
|
422 |
SDLK12_KP1 = 257,
|
icculus@77
|
423 |
SDLK12_KP2 = 258,
|
icculus@77
|
424 |
SDLK12_KP3 = 259,
|
icculus@77
|
425 |
SDLK12_KP4 = 260,
|
icculus@77
|
426 |
SDLK12_KP5 = 261,
|
icculus@77
|
427 |
SDLK12_KP6 = 262,
|
icculus@77
|
428 |
SDLK12_KP7 = 263,
|
icculus@77
|
429 |
SDLK12_KP8 = 264,
|
icculus@77
|
430 |
SDLK12_KP9 = 265,
|
icculus@77
|
431 |
SDLK12_KP_PERIOD = 266,
|
icculus@77
|
432 |
SDLK12_KP_DIVIDE = 267,
|
icculus@77
|
433 |
SDLK12_KP_MULTIPLY = 268,
|
icculus@77
|
434 |
SDLK12_KP_MINUS = 269,
|
icculus@77
|
435 |
SDLK12_KP_PLUS = 270,
|
icculus@77
|
436 |
SDLK12_KP_ENTER = 271,
|
icculus@77
|
437 |
SDLK12_KP_EQUALS = 272,
|
icculus@77
|
438 |
SDLK12_UP = 273,
|
icculus@77
|
439 |
SDLK12_DOWN = 274,
|
icculus@77
|
440 |
SDLK12_RIGHT = 275,
|
icculus@77
|
441 |
SDLK12_LEFT = 276,
|
icculus@77
|
442 |
SDLK12_INSERT = 277,
|
icculus@77
|
443 |
SDLK12_HOME = 278,
|
icculus@77
|
444 |
SDLK12_END = 279,
|
icculus@77
|
445 |
SDLK12_PAGEUP = 280,
|
icculus@77
|
446 |
SDLK12_PAGEDOWN = 281,
|
icculus@77
|
447 |
SDLK12_F1 = 282,
|
icculus@77
|
448 |
SDLK12_F2 = 283,
|
icculus@77
|
449 |
SDLK12_F3 = 284,
|
icculus@77
|
450 |
SDLK12_F4 = 285,
|
icculus@77
|
451 |
SDLK12_F5 = 286,
|
icculus@77
|
452 |
SDLK12_F6 = 287,
|
icculus@77
|
453 |
SDLK12_F7 = 288,
|
icculus@77
|
454 |
SDLK12_F8 = 289,
|
icculus@77
|
455 |
SDLK12_F9 = 290,
|
icculus@77
|
456 |
SDLK12_F10 = 291,
|
icculus@77
|
457 |
SDLK12_F11 = 292,
|
icculus@77
|
458 |
SDLK12_F12 = 293,
|
icculus@77
|
459 |
SDLK12_F13 = 294,
|
icculus@77
|
460 |
SDLK12_F14 = 295,
|
icculus@77
|
461 |
SDLK12_F15 = 296,
|
icculus@77
|
462 |
SDLK12_NUMLOCK = 300,
|
icculus@77
|
463 |
SDLK12_CAPSLOCK = 301,
|
icculus@77
|
464 |
SDLK12_SCROLLOCK = 302,
|
icculus@77
|
465 |
SDLK12_RSHIFT = 303,
|
icculus@77
|
466 |
SDLK12_LSHIFT = 304,
|
icculus@77
|
467 |
SDLK12_RCTRL = 305,
|
icculus@77
|
468 |
SDLK12_LCTRL = 306,
|
icculus@77
|
469 |
SDLK12_RALT = 307,
|
icculus@77
|
470 |
SDLK12_LALT = 308,
|
icculus@77
|
471 |
SDLK12_RMETA = 309,
|
icculus@77
|
472 |
SDLK12_LMETA = 310,
|
icculus@77
|
473 |
SDLK12_LSUPER = 311,
|
icculus@77
|
474 |
SDLK12_RSUPER = 312,
|
icculus@77
|
475 |
SDLK12_MODE = 313,
|
icculus@77
|
476 |
SDLK12_COMPOSE = 314,
|
icculus@77
|
477 |
SDLK12_HELP = 315,
|
icculus@77
|
478 |
SDLK12_PRINT = 316,
|
icculus@77
|
479 |
SDLK12_SYSREQ = 317,
|
icculus@77
|
480 |
SDLK12_BREAK = 318,
|
icculus@77
|
481 |
SDLK12_MENU = 319,
|
icculus@77
|
482 |
SDLK12_POWER = 320,
|
icculus@77
|
483 |
SDLK12_EURO = 321,
|
icculus@77
|
484 |
SDLK12_UNDO = 322,
|
icculus@77
|
485 |
SDLK12_LAST
|
icculus@77
|
486 |
} SDL12Key;
|
icculus@77
|
487 |
|
icculus@77
|
488 |
typedef enum
|
icculus@77
|
489 |
{
|
icculus@77
|
490 |
KMOD12_NONE = 0x0000,
|
icculus@77
|
491 |
KMOD12_LSHIFT = 0x0001,
|
icculus@77
|
492 |
KMOD12_RSHIFT = 0x0002,
|
icculus@77
|
493 |
KMOD12_LCTRL = 0x0040,
|
icculus@77
|
494 |
KMOD12_RCTRL = 0x0080,
|
icculus@77
|
495 |
KMOD12_LALT = 0x0100,
|
icculus@77
|
496 |
KMOD12_RALT = 0x0200,
|
icculus@77
|
497 |
KMOD12_LMETA = 0x0400,
|
icculus@77
|
498 |
KMOD12_RMETA = 0x0800,
|
icculus@77
|
499 |
KMOD12_NUM = 0x1000,
|
icculus@77
|
500 |
KMOD12_CAPS = 0x2000,
|
icculus@77
|
501 |
KMOD12_MODE = 0x4000,
|
icculus@77
|
502 |
KMOD12_RESERVED = 0x8000
|
icculus@77
|
503 |
} SDL12Mod;
|
icculus@77
|
504 |
|
icculus@77
|
505 |
typedef struct SDL12_keysym
|
icculus@77
|
506 |
{
|
icculus@77
|
507 |
Uint8 scancode;
|
icculus@77
|
508 |
SDL12Key sym;
|
icculus@77
|
509 |
SDL12Mod mod;
|
icculus@77
|
510 |
Uint16 unicode;
|
icculus@77
|
511 |
} SDL12_keysym;
|
icculus@77
|
512 |
|
icculus@77
|
513 |
typedef enum
|
icculus@77
|
514 |
{
|
icculus@18
|
515 |
SDL12_NOEVENT = 0,
|
icculus@18
|
516 |
SDL12_ACTIVEEVENT,
|
icculus@18
|
517 |
SDL12_KEYDOWN,
|
icculus@18
|
518 |
SDL12_KEYUP,
|
icculus@18
|
519 |
SDL12_MOUSEMOTION,
|
icculus@18
|
520 |
SDL12_MOUSEBUTTONDOWN,
|
icculus@18
|
521 |
SDL12_MOUSEBUTTONUP,
|
icculus@18
|
522 |
SDL12_JOYAXISMOTION,
|
icculus@18
|
523 |
SDL12_JOYBALLMOTION,
|
icculus@18
|
524 |
SDL12_JOYHATMOTION,
|
icculus@18
|
525 |
SDL12_JOYBUTTONDOWN,
|
icculus@18
|
526 |
SDL12_JOYBUTTONUP,
|
icculus@18
|
527 |
SDL12_QUIT,
|
icculus@18
|
528 |
SDL12_SYSWMEVENT,
|
icculus@18
|
529 |
SDL12_EVENT_RESERVEDA,
|
icculus@18
|
530 |
SDL12_EVENT_RESERVEDB,
|
icculus@18
|
531 |
SDL12_VIDEORESIZE,
|
icculus@18
|
532 |
SDL12_VIDEOEXPOSE,
|
icculus@18
|
533 |
SDL12_USEREVENT = 24,
|
icculus@18
|
534 |
SDL12_NUMEVENTS = 32
|
icculus@18
|
535 |
} SDL12_EventType;
|
icculus@18
|
536 |
|
icculus@31
|
537 |
|
icculus@31
|
538 |
#define SDL12_APPMOUSEFOCUS (1<<0)
|
icculus@31
|
539 |
#define SDL12_APPINPUTFOCUS (1<<1)
|
icculus@31
|
540 |
#define SDL12_APPACTIVE (1<<2)
|
icculus@31
|
541 |
|
icculus@18
|
542 |
typedef struct
|
icculus@18
|
543 |
{
|
icculus@18
|
544 |
Uint8 type;
|
icculus@18
|
545 |
Uint8 gain;
|
icculus@18
|
546 |
Uint8 state;
|
icculus@18
|
547 |
} SDL12_ActiveEvent;
|
icculus@18
|
548 |
|
icculus@18
|
549 |
typedef struct
|
icculus@18
|
550 |
{
|
icculus@18
|
551 |
Uint8 type;
|
icculus@18
|
552 |
Uint8 which;
|
icculus@18
|
553 |
Uint8 state;
|
icculus@77
|
554 |
SDL12_keysym keysym;
|
icculus@18
|
555 |
} SDL12_KeyboardEvent;
|
icculus@18
|
556 |
|
icculus@18
|
557 |
typedef struct
|
icculus@18
|
558 |
{
|
icculus@18
|
559 |
Uint8 type;
|
icculus@18
|
560 |
Uint8 which;
|
icculus@18
|
561 |
Uint8 state;
|
icculus@18
|
562 |
Uint16 x, y;
|
icculus@18
|
563 |
Sint16 xrel;
|
icculus@18
|
564 |
Sint16 yrel;
|
icculus@18
|
565 |
} SDL12_MouseMotionEvent;
|
icculus@18
|
566 |
|
icculus@18
|
567 |
typedef struct
|
icculus@18
|
568 |
{
|
icculus@18
|
569 |
Uint8 type;
|
icculus@18
|
570 |
Uint8 which;
|
icculus@18
|
571 |
Uint8 button;
|
icculus@18
|
572 |
Uint8 state;
|
icculus@18
|
573 |
Uint16 x, y;
|
icculus@18
|
574 |
} SDL12_MouseButtonEvent;
|
icculus@18
|
575 |
|
icculus@18
|
576 |
typedef struct
|
icculus@18
|
577 |
{
|
icculus@18
|
578 |
Uint8 type;
|
icculus@18
|
579 |
Uint8 which;
|
icculus@18
|
580 |
Uint8 axis;
|
icculus@18
|
581 |
Sint16 value;
|
icculus@18
|
582 |
} SDL12_JoyAxisEvent;
|
icculus@18
|
583 |
|
icculus@18
|
584 |
typedef struct
|
icculus@18
|
585 |
{
|
icculus@18
|
586 |
Uint8 type;
|
icculus@18
|
587 |
Uint8 which;
|
icculus@18
|
588 |
Uint8 ball;
|
icculus@18
|
589 |
Sint16 xrel;
|
icculus@18
|
590 |
Sint16 yrel;
|
icculus@18
|
591 |
} SDL12_JoyBallEvent;
|
icculus@18
|
592 |
|
icculus@18
|
593 |
typedef struct
|
icculus@18
|
594 |
{
|
icculus@18
|
595 |
Uint8 type;
|
icculus@18
|
596 |
Uint8 which;
|
icculus@18
|
597 |
Uint8 hat;
|
icculus@18
|
598 |
Uint8 value;
|
icculus@18
|
599 |
} SDL12_JoyHatEvent;
|
icculus@18
|
600 |
|
icculus@18
|
601 |
typedef struct
|
icculus@18
|
602 |
{
|
icculus@18
|
603 |
Uint8 type;
|
icculus@18
|
604 |
Uint8 which;
|
icculus@18
|
605 |
Uint8 button;
|
icculus@18
|
606 |
Uint8 state;
|
icculus@18
|
607 |
} SDL12_JoyButtonEvent;
|
icculus@18
|
608 |
|
icculus@18
|
609 |
typedef struct
|
icculus@18
|
610 |
{
|
icculus@18
|
611 |
Uint8 type;
|
icculus@18
|
612 |
int w;
|
icculus@18
|
613 |
int h;
|
icculus@18
|
614 |
} SDL12_ResizeEvent;
|
icculus@18
|
615 |
|
icculus@18
|
616 |
typedef struct
|
icculus@18
|
617 |
{
|
icculus@18
|
618 |
Uint8 type;
|
icculus@18
|
619 |
} SDL12_ExposeEvent;
|
icculus@18
|
620 |
|
icculus@18
|
621 |
typedef struct
|
icculus@18
|
622 |
{
|
icculus@18
|
623 |
Uint8 type;
|
icculus@18
|
624 |
} SDL12_QuitEvent;
|
icculus@18
|
625 |
|
icculus@18
|
626 |
typedef struct
|
icculus@18
|
627 |
{
|
icculus@18
|
628 |
Uint8 type;
|
icculus@18
|
629 |
int code;
|
icculus@18
|
630 |
void *data1;
|
icculus@18
|
631 |
void *data2;
|
icculus@18
|
632 |
} SDL12_UserEvent;
|
icculus@18
|
633 |
|
icculus@18
|
634 |
typedef struct
|
icculus@18
|
635 |
{
|
icculus@18
|
636 |
Uint8 type;
|
icculus@18
|
637 |
void *msg;
|
icculus@18
|
638 |
} SDL12_SysWMEvent;
|
icculus@18
|
639 |
|
icculus@18
|
640 |
typedef union
|
icculus@18
|
641 |
{
|
icculus@18
|
642 |
Uint8 type;
|
icculus@18
|
643 |
SDL12_ActiveEvent active;
|
icculus@18
|
644 |
SDL12_KeyboardEvent key;
|
icculus@18
|
645 |
SDL12_MouseMotionEvent motion;
|
icculus@18
|
646 |
SDL12_MouseButtonEvent button;
|
icculus@18
|
647 |
SDL12_JoyAxisEvent jaxis;
|
icculus@18
|
648 |
SDL12_JoyBallEvent jball;
|
icculus@18
|
649 |
SDL12_JoyHatEvent jhat;
|
icculus@18
|
650 |
SDL12_JoyButtonEvent jbutton;
|
icculus@18
|
651 |
SDL12_ResizeEvent resize;
|
icculus@18
|
652 |
SDL12_ExposeEvent expose;
|
icculus@18
|
653 |
SDL12_QuitEvent quit;
|
icculus@18
|
654 |
SDL12_UserEvent user;
|
icculus@18
|
655 |
SDL12_SysWMEvent syswm;
|
icculus@18
|
656 |
} SDL12_Event;
|
icculus@9
|
657 |
|
icculus@31
|
658 |
typedef int (SDLCALL *SDL12_EventFilter)(const SDL12_Event *event12);
|
icculus@31
|
659 |
static int EventFilter20to12(void *data, SDL_Event *event20);
|
icculus@31
|
660 |
|
icculus@31
|
661 |
typedef Uint32 (SDLCALL *SDL12_TimerCallback)(Uint32 interval);
|
icculus@31
|
662 |
typedef SDL_TimerCallback SDL12_NewTimerCallback;
|
icculus@31
|
663 |
|
icculus@23
|
664 |
typedef struct
|
icculus@31
|
665 |
{
|
icculus@73
|
666 |
SDL12_Rect area;
|
icculus@23
|
667 |
Sint16 hot_x;
|
icculus@23
|
668 |
Sint16 hot_y;
|
icculus@23
|
669 |
Uint8 *data;
|
icculus@23
|
670 |
Uint8 *mask;
|
icculus@23
|
671 |
Uint8 *save[2];
|
icculus@23
|
672 |
SDL_Cursor *wm_cursor; /* the real SDL 1.2 has an opaque pointer to a platform-specific cursor here. */
|
icculus@23
|
673 |
} SDL12_Cursor;
|
icculus@23
|
674 |
|
icculus@30
|
675 |
typedef enum
|
icculus@30
|
676 |
{
|
icculus@30
|
677 |
SDL12_GL_RED_SIZE,
|
icculus@30
|
678 |
SDL12_GL_GREEN_SIZE,
|
icculus@30
|
679 |
SDL12_GL_BLUE_SIZE,
|
icculus@30
|
680 |
SDL12_GL_ALPHA_SIZE,
|
icculus@30
|
681 |
SDL12_GL_BUFFER_SIZE,
|
icculus@30
|
682 |
SDL12_GL_DOUBLEBUFFER,
|
icculus@30
|
683 |
SDL12_GL_DEPTH_SIZE,
|
icculus@30
|
684 |
SDL12_GL_STENCIL_SIZE,
|
icculus@30
|
685 |
SDL12_GL_ACCUM_RED_SIZE,
|
icculus@30
|
686 |
SDL12_GL_ACCUM_GREEN_SIZE,
|
icculus@30
|
687 |
SDL12_GL_ACCUM_BLUE_SIZE,
|
icculus@30
|
688 |
SDL12_GL_ACCUM_ALPHA_SIZE,
|
icculus@30
|
689 |
SDL12_GL_STEREO,
|
icculus@30
|
690 |
SDL12_GL_MULTISAMPLEBUFFERS,
|
icculus@30
|
691 |
SDL12_GL_MULTISAMPLESAMPLES,
|
icculus@30
|
692 |
SDL12_GL_ACCELERATED_VISUAL,
|
icculus@30
|
693 |
SDL12_GL_SWAP_CONTROL,
|
icculus@30
|
694 |
SDL12_GL_MAX_ATTRIBUTE
|
icculus@30
|
695 |
} SDL12_GLattr;
|
icculus@23
|
696 |
|
icculus@39
|
697 |
|
icculus@39
|
698 |
typedef struct
|
icculus@39
|
699 |
{
|
icculus@39
|
700 |
Uint32 format;
|
icculus@73
|
701 |
SDL12_Rect *modeslist12;
|
icculus@73
|
702 |
SDL12_Rect **modes12; /* ptrs to each item in modeslist, for SDL_ListModes() */
|
icculus@39
|
703 |
} VideoModeList;
|
icculus@39
|
704 |
|
icculus@82
|
705 |
typedef struct
|
icculus@82
|
706 |
{
|
icculus@82
|
707 |
int device_index;
|
icculus@82
|
708 |
SDL_Joystick *joystick;
|
icculus@82
|
709 |
} JoystickOpenedItem;
|
icculus@82
|
710 |
|
icculus@54
|
711 |
// !!! FIXME: go through all of these.
|
icculus@39
|
712 |
static VideoModeList *VideoModes = NULL;
|
icculus@39
|
713 |
static int VideoModesCount = 0;
|
icculus@56
|
714 |
static SDL12_VideoInfo VideoInfo12;
|
icculus@19
|
715 |
static SDL_Window *VideoWindow20 = NULL;
|
icculus@56
|
716 |
static SDL_Renderer *VideoRenderer20 = NULL;
|
icculus@56
|
717 |
static SDL_Texture *VideoTexture20 = NULL;
|
icculus@56
|
718 |
static SDL12_Surface *VideoSurface12 = NULL;
|
icculus@56
|
719 |
static SDL_Surface *VideoConvertSurface20 = NULL;
|
icculus@56
|
720 |
static SDL_GLContext *VideoGLContext20 = NULL;
|
icculus@16
|
721 |
static char *WindowTitle = NULL;
|
icculus@16
|
722 |
static char *WindowIconTitle = NULL;
|
icculus@56
|
723 |
static SDL12_Surface *VideoIcon12;
|
icculus@16
|
724 |
static int EnabledUnicode = 0;
|
icculus@16
|
725 |
static int VideoDisplayIndex = 0;
|
icculus@16
|
726 |
static int CDRomInit = 0;
|
icculus@18
|
727 |
static SDL12_EventFilter EventFilter12 = NULL;
|
icculus@56
|
728 |
static SDL12_Cursor *CurrentCursor12 = NULL;
|
icculus@27
|
729 |
static Uint8 EventStates[SDL12_NUMEVENTS];
|
icculus@30
|
730 |
static int SwapInterval = 0;
|
icculus@82
|
731 |
static JoystickOpenedItem JoystickOpenList[16];
|
icculus@18
|
732 |
|
icculus@18
|
733 |
// !!! FIXME: need a mutex for the event queue.
|
icculus@18
|
734 |
#define SDL12_MAXEVENTS 128
|
icculus@20
|
735 |
typedef struct EventQueueType
|
icculus@20
|
736 |
{
|
icculus@20
|
737 |
SDL12_Event event12;
|
icculus@20
|
738 |
struct EventQueueType *next;
|
icculus@20
|
739 |
} EventQueueType;
|
icculus@20
|
740 |
|
icculus@20
|
741 |
static EventQueueType EventQueuePool[SDL12_MAXEVENTS];
|
icculus@20
|
742 |
static EventQueueType *EventQueueHead = NULL;
|
icculus@20
|
743 |
static EventQueueType *EventQueueTail = NULL;
|
icculus@20
|
744 |
static EventQueueType *EventQueueAvailable = NULL;
|
icculus@9
|
745 |
|
icculus@33
|
746 |
|
icculus@9
|
747 |
/* Obviously we can't use SDL_LoadObject() to load SDL2. :) */
|
icculus@9
|
748 |
#if defined(_WINDOWS)
|
icculus@19
|
749 |
#define WIN32_LEAN_AND_MEAN 1
|
icculus@19
|
750 |
#include <windows.h>
|
icculus@9
|
751 |
#define SDL20_LIBNAME "SDL2.dll"
|
icculus@9
|
752 |
static HANDLE Loaded_SDL20 = NULL;
|
icculus@9
|
753 |
#define LoadSDL20Library() ((Loaded_SDL20 = LoadLibraryA(SDL20_LIBNAME)) != NULL)
|
icculus@9
|
754 |
#define LookupSDL20Sym(sym) GetProcAddress(Loaded_SDL20, sym)
|
icculus@9
|
755 |
#define CloseSDL20Library() { { if (Loaded_SDL20) { FreeLibrary(Loaded_SDL20); Loaded_SDL20 = NULL; } }
|
icculus@19
|
756 |
#elif defined(unix) || defined(__APPLE__)
|
icculus@19
|
757 |
#include <dlfcn.h>
|
icculus@9
|
758 |
#ifdef __APPLE__
|
icculus@9
|
759 |
#define SDL20_LIBNAME "libSDL2.dylib"
|
icculus@9
|
760 |
#else
|
icculus@9
|
761 |
#define SDL20_LIBNAME "libSDL2-2.0.so.0"
|
icculus@9
|
762 |
#endif
|
icculus@9
|
763 |
static void *Loaded_SDL20 = NULL;
|
icculus@85
|
764 |
#define LoadSDL20Library() ((Loaded_SDL20 = dlopen(SDL20_LIBNAME, RTLD_LOCAL|RTLD_NOW)) != NULL)
|
icculus@9
|
765 |
#define LookupSDL20Sym(sym) dlsym(Loaded_SDL20, sym)
|
icculus@9
|
766 |
#define CloseSDL20Library() { if (Loaded_SDL20) { dlclose(Loaded_SDL20); Loaded_SDL20 = NULL; } }
|
icculus@9
|
767 |
#else
|
icculus@9
|
768 |
#error Please define your platform.
|
icculus@9
|
769 |
#endif
|
icculus@9
|
770 |
|
icculus@9
|
771 |
static void *
|
icculus@9
|
772 |
LoadSDL20Symbol(const char *fn, int *okay)
|
icculus@9
|
773 |
{
|
icculus@9
|
774 |
void *retval = NULL;
|
icculus@84
|
775 |
if (*okay) { /* only bother trying if we haven't previously failed. */
|
icculus@9
|
776 |
retval = LookupSDL20Sym(fn);
|
icculus@84
|
777 |
if (retval == NULL) {
|
icculus@84
|
778 |
/* Flip to 1 to warn but maybe work if nothing calls that function, flip to zero to fail out. */
|
icculus@84
|
779 |
#if 0
|
icculus@84
|
780 |
fprintf(stderr, "WARNING: LOAD FAILED: %s\n", fn);
|
icculus@84
|
781 |
#else
|
icculus@84
|
782 |
*okay = 0;
|
icculus@84
|
783 |
#endif
|
icculus@84
|
784 |
}
|
icculus@9
|
785 |
}
|
icculus@9
|
786 |
return retval;
|
icculus@9
|
787 |
}
|
icculus@9
|
788 |
|
icculus@9
|
789 |
static void
|
icculus@9
|
790 |
UnloadSDL20(void)
|
icculus@9
|
791 |
{
|
icculus@9
|
792 |
#define SDL20_SYM(rc,fn,params,args,ret) SDL20_##fn = NULL;
|
icculus@9
|
793 |
#include "SDL20_syms.h"
|
icculus@9
|
794 |
CloseSDL20Library();
|
icculus@9
|
795 |
}
|
icculus@9
|
796 |
|
icculus@9
|
797 |
static int
|
icculus@9
|
798 |
LoadSDL20(void)
|
icculus@9
|
799 |
{
|
icculus@9
|
800 |
int okay = 1;
|
icculus@9
|
801 |
if (!Loaded_SDL20)
|
icculus@9
|
802 |
{
|
icculus@9
|
803 |
okay = LoadSDL20Library();
|
icculus@9
|
804 |
#define SDL20_SYM(rc,fn,params,args,ret) SDL20_##fn = (SDL20_##fn##_t) LoadSDL20Symbol("SDL_" #fn, &okay);
|
icculus@9
|
805 |
#include "SDL20_syms.h"
|
icculus@9
|
806 |
if (!okay)
|
icculus@9
|
807 |
UnloadSDL20();
|
icculus@9
|
808 |
}
|
icculus@9
|
809 |
return okay;
|
icculus@9
|
810 |
}
|
icculus@9
|
811 |
|
icculus@35
|
812 |
DECLSPEC const SDL_version * SDLCALL
|
icculus@35
|
813 |
SDL_Linked_Version(void)
|
icculus@35
|
814 |
{
|
icculus@35
|
815 |
static const SDL_version version = { 1, 2, SDL12_COMPAT_VERSION };
|
icculus@35
|
816 |
return &version;
|
icculus@35
|
817 |
}
|
icculus@9
|
818 |
|
icculus@60
|
819 |
DECLSPEC int SDLCALL
|
icculus@60
|
820 |
SDL_sscanf(const char *text, const char *fmt, ...)
|
icculus@60
|
821 |
{
|
icculus@60
|
822 |
int retval;
|
icculus@60
|
823 |
va_list ap;
|
icculus@60
|
824 |
va_start(ap, fmt);
|
icculus@60
|
825 |
retval = (int) SDL20_sscanf(text, fmt, ap);
|
icculus@60
|
826 |
va_end(ap);
|
icculus@60
|
827 |
return retval;
|
icculus@60
|
828 |
}
|
icculus@60
|
829 |
|
icculus@60
|
830 |
DECLSPEC int SDLCALL
|
icculus@60
|
831 |
SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...)
|
icculus@60
|
832 |
{
|
icculus@60
|
833 |
int retval;
|
icculus@60
|
834 |
va_list ap;
|
icculus@60
|
835 |
va_start(ap, fmt);
|
icculus@60
|
836 |
retval = (int) SDL20_vsnprintf(text, maxlen, fmt, ap);
|
icculus@60
|
837 |
va_end(ap);
|
icculus@60
|
838 |
return retval;
|
icculus@60
|
839 |
}
|
icculus@60
|
840 |
|
icculus@83
|
841 |
DECLSPEC void * SDLCALL
|
icculus@83
|
842 |
SDL_revcpy(void *dst, const void *src, size_t len)
|
icculus@83
|
843 |
{
|
icculus@83
|
844 |
/* this doesn't reverse the data...I think this was just a memcpy that
|
icculus@83
|
845 |
was meant to be CPU-cache friendly if you knew you were working with
|
icculus@83
|
846 |
data going backwards in memory, instead of jumping over pages to copy
|
icculus@83
|
847 |
from the start...? Whatever, just do a memcpy here. */
|
icculus@83
|
848 |
return SDL_memcpy(dst, src, len);
|
icculus@83
|
849 |
}
|
icculus@83
|
850 |
|
icculus@83
|
851 |
|
icculus@60
|
852 |
DECLSPEC SDL_bool SDLCALL
|
icculus@60
|
853 |
SDL_HasMMXExt(void)
|
icculus@60
|
854 |
{
|
icculus@60
|
855 |
/* this isn't accurate, but SDL2 doesn't have this for some reason.
|
icculus@60
|
856 |
MMXExt is available in all SSE1 machines, except early Athlon chips,
|
icculus@60
|
857 |
so we'll just say it's available if they have SSE1. Oh well. */
|
icculus@60
|
858 |
return SDL20_HasSSE();
|
icculus@60
|
859 |
}
|
icculus@60
|
860 |
|
icculus@60
|
861 |
DECLSPEC SDL_bool SDLCALL
|
icculus@60
|
862 |
SDL_Has3DNowExt(void)
|
icculus@60
|
863 |
{
|
icculus@60
|
864 |
FIXME("check this");
|
icculus@60
|
865 |
return SDL20_HasSSE();
|
icculus@60
|
866 |
}
|
icculus@60
|
867 |
|
icculus@82
|
868 |
DECLSPEC SDL_Joystick * SDLCALL
|
icculus@82
|
869 |
SDL_JoystickOpen(int device_index)
|
icculus@82
|
870 |
{
|
icculus@82
|
871 |
int i;
|
icculus@82
|
872 |
SDL20_LockJoysticks();
|
icculus@82
|
873 |
for (i = 0; i < SDL_arraysize(JoystickOpenList); i++) {
|
icculus@82
|
874 |
if (JoystickOpenList[i].joystick == NULL) {
|
icculus@82
|
875 |
break;
|
icculus@82
|
876 |
}
|
icculus@82
|
877 |
}
|
icculus@82
|
878 |
|
icculus@82
|
879 |
if (i == SDL_arraysize(JoystickOpenList)) {
|
icculus@82
|
880 |
SDL20_UnlockJoysticks();
|
icculus@82
|
881 |
SDL20_SetError("Too many open joysticks");
|
icculus@82
|
882 |
return NULL;
|
icculus@82
|
883 |
}
|
icculus@82
|
884 |
|
icculus@82
|
885 |
JoystickOpenList[i].joystick = SDL20_JoystickOpen(device_index);
|
icculus@82
|
886 |
if (JoystickOpenList[i].joystick) {
|
icculus@82
|
887 |
JoystickOpenList[i].device_index = device_index;
|
icculus@82
|
888 |
}
|
icculus@82
|
889 |
|
icculus@82
|
890 |
SDL20_UnlockJoysticks();
|
icculus@82
|
891 |
return JoystickOpenList[i].joystick;
|
icculus@82
|
892 |
}
|
icculus@82
|
893 |
|
icculus@82
|
894 |
DECLSPEC void SDLCALL
|
icculus@82
|
895 |
SDL_JoystickClose(SDL_Joystick *joystick)
|
icculus@82
|
896 |
{
|
icculus@82
|
897 |
int i;
|
icculus@82
|
898 |
SDL20_LockJoysticks();
|
icculus@82
|
899 |
for (i = 0; i < SDL_arraysize(JoystickOpenList); i++) {
|
icculus@82
|
900 |
if (JoystickOpenList[i].joystick == joystick) {
|
icculus@82
|
901 |
break;
|
icculus@82
|
902 |
}
|
icculus@82
|
903 |
}
|
icculus@82
|
904 |
|
icculus@82
|
905 |
if (i < SDL_arraysize(JoystickOpenList)) {
|
icculus@82
|
906 |
JoystickOpenList[i].joystick = NULL;
|
icculus@82
|
907 |
}
|
icculus@82
|
908 |
|
icculus@82
|
909 |
SDL20_UnlockJoysticks();
|
icculus@82
|
910 |
|
icculus@82
|
911 |
SDL20_JoystickClose(joystick);
|
icculus@82
|
912 |
}
|
icculus@82
|
913 |
|
icculus@82
|
914 |
DECLSPEC const char * SDLCALL
|
icculus@82
|
915 |
SDL_JoystickName(int device_index)
|
icculus@82
|
916 |
{
|
icculus@82
|
917 |
return SDL20_JoystickNameForIndex(device_index);
|
icculus@82
|
918 |
}
|
icculus@82
|
919 |
|
icculus@82
|
920 |
DECLSPEC int SDLCALL
|
icculus@82
|
921 |
SDL_JoystickIndex(SDL_Joystick *joystick)
|
icculus@82
|
922 |
{
|
icculus@82
|
923 |
int i;
|
icculus@82
|
924 |
|
icculus@82
|
925 |
SDL20_LockJoysticks(); {
|
icculus@82
|
926 |
for (i = 0; i < SDL_arraysize(JoystickOpenList); i++) {
|
icculus@82
|
927 |
if (JoystickOpenList[i].joystick == joystick) {
|
icculus@82
|
928 |
break;
|
icculus@82
|
929 |
}
|
icculus@82
|
930 |
}
|
icculus@82
|
931 |
|
icculus@82
|
932 |
if (i < SDL_arraysize(JoystickOpenList)) {
|
icculus@82
|
933 |
SDL20_UnlockJoysticks();
|
icculus@82
|
934 |
return JoystickOpenList[i].device_index;
|
icculus@82
|
935 |
}
|
icculus@82
|
936 |
|
icculus@82
|
937 |
}
|
icculus@82
|
938 |
SDL20_UnlockJoysticks();
|
icculus@82
|
939 |
return SDL20_SetError("Can't find joystick");
|
icculus@82
|
940 |
}
|
icculus@82
|
941 |
|
icculus@60
|
942 |
DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index)
|
icculus@60
|
943 |
{
|
icculus@82
|
944 |
int retval = 0;
|
icculus@82
|
945 |
int i;
|
icculus@82
|
946 |
SDL20_LockJoysticks();
|
icculus@82
|
947 |
for (i = 0; i < SDL_arraysize(JoystickOpenList); i++) {
|
icculus@82
|
948 |
if ((JoystickOpenList[i].joystick) && (JoystickOpenList[i].device_index == device_index)) {
|
icculus@82
|
949 |
retval = 1;
|
icculus@82
|
950 |
break;
|
icculus@82
|
951 |
}
|
icculus@82
|
952 |
}
|
icculus@82
|
953 |
SDL20_UnlockJoysticks();
|
icculus@82
|
954 |
return retval;
|
icculus@60
|
955 |
}
|
icculus@60
|
956 |
|
icculus@9
|
957 |
static int
|
icculus@9
|
958 |
GetVideoDisplay()
|
icculus@9
|
959 |
{
|
icculus@58
|
960 |
FIXME("cache this value during SDL_Init() so it doesn't change.");
|
icculus@58
|
961 |
const char *variable = SDL20_getenv("SDL_VIDEO_FULLSCREEN_DISPLAY");
|
icculus@9
|
962 |
if ( !variable ) {
|
icculus@58
|
963 |
variable = SDL20_getenv("SDL_VIDEO_FULLSCREEN_HEAD");
|
icculus@9
|
964 |
}
|
icculus@9
|
965 |
if ( variable ) {
|
icculus@34
|
966 |
return SDL20_atoi(variable);
|
icculus@9
|
967 |
} else {
|
icculus@9
|
968 |
return 0;
|
icculus@9
|
969 |
}
|
icculus@9
|
970 |
}
|
icculus@9
|
971 |
|
icculus@39
|
972 |
/* This sets up VideoModes and VideoModesCount. You end up with arrays by pixel
|
icculus@39
|
973 |
format, each with a value that 1.2's SDL_ListModes() can return. */
|
icculus@39
|
974 |
static int
|
icculus@39
|
975 |
Init12VidModes(void)
|
icculus@39
|
976 |
{
|
icculus@39
|
977 |
const int total = SDL20_GetNumDisplayModes(VideoDisplayIndex);
|
icculus@39
|
978 |
VideoModeList *vmode = NULL;
|
icculus@39
|
979 |
int num_modes = 0;
|
icculus@39
|
980 |
void *ptr = NULL;
|
icculus@39
|
981 |
int i, j;
|
icculus@39
|
982 |
|
icculus@39
|
983 |
SDL_assert(VideoModes == NULL);
|
icculus@39
|
984 |
SDL_assert(VideoModesCount == 0);
|
icculus@39
|
985 |
|
icculus@39
|
986 |
for (i = 0; i < total; ++i) {
|
icculus@39
|
987 |
SDL_DisplayMode mode;
|
icculus@39
|
988 |
|
icculus@39
|
989 |
if (SDL20_GetDisplayMode(VideoDisplayIndex, i, &mode) == -1) {
|
icculus@39
|
990 |
continue;
|
icculus@39
|
991 |
} else if (!mode.w || !mode.h) {
|
icculus@39
|
992 |
SDL_assert(0 && "Can this actually happen?");
|
icculus@39
|
993 |
continue;
|
icculus@39
|
994 |
}
|
icculus@39
|
995 |
|
icculus@39
|
996 |
if (!vmode || (mode.format != vmode->format)) { // SDL20_GetDisplayMode() sorts on bpp first. We know when to change arrays.
|
icculus@39
|
997 |
if (VideoModesCount > 0) {
|
icculus@73
|
998 |
VideoModes[VideoModesCount-1].modes12[num_modes] = NULL;
|
icculus@39
|
999 |
}
|
icculus@39
|
1000 |
ptr = (VideoModeList *) SDL20_realloc(VideoModes, sizeof (VideoModeList) * (VideoModesCount+1));
|
icculus@39
|
1001 |
if (!ptr) {
|
icculus@39
|
1002 |
return SDL20_OutOfMemory();
|
icculus@39
|
1003 |
}
|
icculus@39
|
1004 |
VideoModes = (VideoModeList *) ptr;
|
icculus@39
|
1005 |
vmode = &VideoModes[VideoModesCount];
|
icculus@39
|
1006 |
vmode->format = mode.format;
|
icculus@73
|
1007 |
vmode->modeslist12 = NULL;
|
icculus@73
|
1008 |
vmode->modes12 = NULL;
|
icculus@39
|
1009 |
VideoModesCount++;
|
icculus@39
|
1010 |
num_modes = 0;
|
icculus@39
|
1011 |
}
|
icculus@39
|
1012 |
|
icculus@39
|
1013 |
/* make sure we don't have this one already (with a different refresh rate, etc). */
|
icculus@39
|
1014 |
for (j = 0; j < num_modes; j++) {
|
icculus@73
|
1015 |
if ((vmode->modeslist12[j].w == mode.w) && (vmode->modeslist12[j].h == mode.h)) {
|
icculus@39
|
1016 |
break;
|
icculus@39
|
1017 |
}
|
icculus@39
|
1018 |
}
|
icculus@39
|
1019 |
|
icculus@39
|
1020 |
if (j < num_modes) {
|
icculus@39
|
1021 |
continue; /* already have this one. */
|
icculus@39
|
1022 |
}
|
icculus@39
|
1023 |
|
icculus@73
|
1024 |
FIXME("Make sure mode dimensions fit in 16-bits for SDL12_Rect");
|
icculus@73
|
1025 |
|
icculus@73
|
1026 |
ptr = SDL20_realloc(vmode->modes12, sizeof (SDL12_Rect *) * (num_modes + 2));
|
icculus@39
|
1027 |
if (ptr == NULL) {
|
icculus@39
|
1028 |
return SDL20_OutOfMemory();
|
icculus@39
|
1029 |
}
|
icculus@73
|
1030 |
vmode->modes12 = (SDL12_Rect **) ptr;
|
icculus@73
|
1031 |
|
icculus@73
|
1032 |
ptr = SDL20_realloc(vmode->modeslist12, sizeof (SDL12_Rect) * (num_modes + 1));
|
icculus@39
|
1033 |
if (ptr == NULL) {
|
icculus@39
|
1034 |
return SDL20_OutOfMemory();
|
icculus@39
|
1035 |
}
|
icculus@73
|
1036 |
vmode->modeslist12 = (SDL12_Rect *) ptr;
|
icculus@73
|
1037 |
|
icculus@73
|
1038 |
vmode->modeslist12[num_modes].x = 0;
|
icculus@73
|
1039 |
vmode->modeslist12[num_modes].y = 0;
|
icculus@73
|
1040 |
vmode->modeslist12[num_modes].w = mode.w;
|
icculus@73
|
1041 |
vmode->modeslist12[num_modes].h = mode.h;
|
icculus@73
|
1042 |
|
icculus@73
|
1043 |
vmode->modes12[num_modes] = &vmode->modeslist12[num_modes];
|
icculus@39
|
1044 |
|
icculus@39
|
1045 |
num_modes++;
|
icculus@39
|
1046 |
}
|
icculus@39
|
1047 |
|
icculus@39
|
1048 |
if (VideoModesCount > 0) {
|
icculus@73
|
1049 |
VideoModes[VideoModesCount-1].modes12[num_modes] = NULL;
|
icculus@39
|
1050 |
}
|
icculus@39
|
1051 |
|
icculus@39
|
1052 |
return 0;
|
icculus@39
|
1053 |
}
|
icculus@39
|
1054 |
|
icculus@39
|
1055 |
static int
|
icculus@39
|
1056 |
Init12Video(void)
|
icculus@39
|
1057 |
{
|
icculus@39
|
1058 |
int i;
|
icculus@39
|
1059 |
|
icculus@39
|
1060 |
for (i = 0; i < SDL12_MAXEVENTS-1; i++)
|
icculus@39
|
1061 |
EventQueuePool[i].next = &EventQueuePool[i+1];
|
icculus@39
|
1062 |
EventQueuePool[SDL12_MAXEVENTS-1].next = NULL;
|
icculus@39
|
1063 |
|
icculus@39
|
1064 |
EventQueueHead = EventQueueTail = NULL;
|
icculus@39
|
1065 |
EventQueueAvailable = EventQueuePool;
|
icculus@39
|
1066 |
|
icculus@39
|
1067 |
SDL_memset(EventStates, SDL_ENABLE, sizeof (EventStates)); /* on by default */
|
icculus@39
|
1068 |
EventStates[SDL12_SYSWMEVENT] = SDL_IGNORE; /* off by default. */
|
icculus@39
|
1069 |
|
icculus@39
|
1070 |
SDL20_SetEventFilter(EventFilter20to12, NULL);
|
icculus@39
|
1071 |
|
icculus@39
|
1072 |
VideoDisplayIndex = GetVideoDisplay();
|
icculus@39
|
1073 |
SwapInterval = 0;
|
icculus@39
|
1074 |
|
icculus@39
|
1075 |
if (Init12VidModes() == -1) {
|
icculus@39
|
1076 |
return -1;
|
icculus@39
|
1077 |
}
|
icculus@39
|
1078 |
|
icculus@39
|
1079 |
return 0;
|
icculus@39
|
1080 |
}
|
icculus@39
|
1081 |
|
icculus@39
|
1082 |
|
icculus@37
|
1083 |
DECLSPEC int SDLCALL
|
icculus@37
|
1084 |
SDL_InitSubSystem(Uint32 sdl12flags)
|
icculus@9
|
1085 |
{
|
icculus@54
|
1086 |
FIXME("there is never a parachute in SDL2, should we catch segfaults ourselves?");
|
icculus@40
|
1087 |
|
icculus@54
|
1088 |
FIXME("support event thread where it makes sense to do so?");
|
icculus@54
|
1089 |
|
icculus@75
|
1090 |
if ( (sdl12flags & SDL12_INIT_EVENTTHREAD) == SDL12_INIT_EVENTTHREAD ) {
|
icculus@75
|
1091 |
return SDL20_SetError("OS doesn't support threaded events");
|
icculus@75
|
1092 |
}
|
icculus@40
|
1093 |
|
icculus@9
|
1094 |
Uint32 sdl20flags = 0;
|
icculus@9
|
1095 |
int rc;
|
icculus@9
|
1096 |
|
icculus@9
|
1097 |
if (!LoadSDL20())
|
icculus@9
|
1098 |
return -1;
|
icculus@9
|
1099 |
|
icculus@62
|
1100 |
#ifdef __MACOSX__
|
icculus@62
|
1101 |
extern void sdl12_compat_macos_init(void);
|
icculus@62
|
1102 |
sdl12_compat_macos_init();
|
icculus@62
|
1103 |
#endif
|
icculus@62
|
1104 |
|
icculus@19
|
1105 |
#define SETFLAG(flag) if (sdl12flags & SDL12_INIT_##flag) sdl20flags |= SDL_INIT_##flag
|
icculus@9
|
1106 |
SETFLAG(TIMER);
|
icculus@9
|
1107 |
SETFLAG(AUDIO);
|
icculus@9
|
1108 |
SETFLAG(VIDEO);
|
icculus@9
|
1109 |
SETFLAG(JOYSTICK);
|
icculus@9
|
1110 |
SETFLAG(NOPARACHUTE);
|
icculus@11
|
1111 |
#undef SETFLAG
|
icculus@11
|
1112 |
|
icculus@11
|
1113 |
// There's no CDROM in 2.0, but we'll just pretend it succeeded.
|
icculus@11
|
1114 |
if (sdl12flags & SDL12_INIT_CDROM)
|
icculus@16
|
1115 |
CDRomInit = 1;
|
icculus@11
|
1116 |
|
icculus@54
|
1117 |
FIXME("do something about SDL12_INIT_EVENTTHREAD");
|
icculus@11
|
1118 |
|
icculus@37
|
1119 |
rc = SDL20_Init(sdl20flags);
|
icculus@39
|
1120 |
if ((rc == 0) && (sdl20flags & SDL_INIT_VIDEO)) {
|
icculus@39
|
1121 |
if (Init12Video() == -1) {
|
icculus@54
|
1122 |
FIXME("should we deinit other subsystems?");
|
icculus@54
|
1123 |
return -1;
|
icculus@39
|
1124 |
}
|
icculus@18
|
1125 |
}
|
icculus@18
|
1126 |
|
icculus@11
|
1127 |
return rc;
|
icculus@11
|
1128 |
}
|
icculus@11
|
1129 |
|
icculus@35
|
1130 |
DECLSPEC int SDLCALL
|
icculus@11
|
1131 |
SDL_Init(Uint32 sdl12flags)
|
icculus@11
|
1132 |
{
|
icculus@54
|
1133 |
FIXME("what was different in 1.2?");
|
icculus@41
|
1134 |
return SDL_InitSubSystem(sdl12flags); /* there's no difference betwee Init and InitSubSystem in SDL2. */
|
icculus@11
|
1135 |
}
|
icculus@11
|
1136 |
|
icculus@38
|
1137 |
|
icculus@38
|
1138 |
static void
|
icculus@38
|
1139 |
InitFlags12To20(const Uint32 flags12, Uint32 *_flags20, Uint32 *_extraflags)
|
icculus@11
|
1140 |
{
|
icculus@38
|
1141 |
Uint32 flags20 = 0;
|
icculus@11
|
1142 |
Uint32 extraflags = 0;
|
icculus@11
|
1143 |
|
icculus@38
|
1144 |
#define SETFLAG(flag) if (flags12 & SDL12_INIT_##flag) flags20 |= SDL_INIT_##flag
|
icculus@11
|
1145 |
SETFLAG(TIMER);
|
icculus@11
|
1146 |
SETFLAG(AUDIO);
|
icculus@11
|
1147 |
SETFLAG(VIDEO);
|
icculus@11
|
1148 |
SETFLAG(JOYSTICK);
|
icculus@11
|
1149 |
SETFLAG(NOPARACHUTE);
|
icculus@11
|
1150 |
#undef SETFLAG
|
icculus@11
|
1151 |
|
icculus@38
|
1152 |
if ((flags12 & SDL12_INIT_CDROM) && (CDRomInit)) {
|
icculus@11
|
1153 |
extraflags |= SDL12_INIT_CDROM;
|
icculus@38
|
1154 |
}
|
icculus@11
|
1155 |
|
icculus@54
|
1156 |
FIXME("do something about SDL12_INIT_EVENTTHREAD");
|
icculus@11
|
1157 |
|
icculus@38
|
1158 |
*_flags20 = flags20;
|
icculus@38
|
1159 |
*_extraflags = extraflags;
|
icculus@11
|
1160 |
}
|
icculus@11
|
1161 |
|
icculus@38
|
1162 |
static Uint32
|
icculus@38
|
1163 |
InitFlags20to12(const Uint32 flags20)
|
icculus@11
|
1164 |
{
|
icculus@38
|
1165 |
Uint32 flags12 = 0;
|
icculus@38
|
1166 |
|
icculus@38
|
1167 |
#define SETFLAG(flag) if (flags20 & SDL_INIT_##flag) flags12 |= SDL12_INIT_##flag
|
icculus@11
|
1168 |
SETFLAG(TIMER);
|
icculus@11
|
1169 |
SETFLAG(AUDIO);
|
icculus@11
|
1170 |
SETFLAG(VIDEO);
|
icculus@11
|
1171 |
SETFLAG(JOYSTICK);
|
icculus@11
|
1172 |
SETFLAG(NOPARACHUTE);
|
icculus@9
|
1173 |
#undef SETFLAG
|
icculus@9
|
1174 |
|
icculus@38
|
1175 |
return flags12;
|
icculus@38
|
1176 |
}
|
icculus@38
|
1177 |
|
icculus@38
|
1178 |
|
icculus@38
|
1179 |
DECLSPEC Uint32 SDLCALL
|
icculus@38
|
1180 |
SDL_WasInit(Uint32 sdl12flags)
|
icculus@38
|
1181 |
{
|
icculus@38
|
1182 |
Uint32 sdl20flags, extraflags;
|
icculus@38
|
1183 |
InitFlags12To20(sdl12flags, &sdl20flags, &extraflags);
|
icculus@38
|
1184 |
|
icculus@38
|
1185 |
return InitFlags20to12(SDL20_WasInit(sdl20flags)) | extraflags;
|
icculus@38
|
1186 |
}
|
icculus@38
|
1187 |
|
icculus@39
|
1188 |
static void
|
icculus@39
|
1189 |
Quit12Video(void)
|
icculus@39
|
1190 |
{
|
icculus@39
|
1191 |
int i;
|
icculus@39
|
1192 |
|
icculus@39
|
1193 |
for (i = 0; i < VideoModesCount; i++) {
|
icculus@73
|
1194 |
SDL20_free(VideoModes[i].modeslist12);
|
icculus@73
|
1195 |
SDL20_free(VideoModes[i].modes12);
|
icculus@39
|
1196 |
}
|
icculus@39
|
1197 |
SDL20_free(VideoModes);
|
icculus@39
|
1198 |
|
icculus@56
|
1199 |
SDL20_FreeFormat(VideoInfo12.vfmt);
|
icculus@56
|
1200 |
SDL20_zero(VideoInfo12);
|
icculus@39
|
1201 |
|
icculus@39
|
1202 |
EventFilter12 = NULL;
|
icculus@39
|
1203 |
EventQueueAvailable = EventQueueHead = EventQueueTail = NULL;
|
icculus@56
|
1204 |
CurrentCursor12 = NULL;
|
icculus@39
|
1205 |
VideoModes = NULL;
|
icculus@39
|
1206 |
VideoModesCount = 0;
|
icculus@39
|
1207 |
}
|
icculus@39
|
1208 |
|
icculus@38
|
1209 |
DECLSPEC void SDLCALL
|
icculus@38
|
1210 |
SDL_QuitSubSystem(Uint32 sdl12flags)
|
icculus@38
|
1211 |
{
|
icculus@38
|
1212 |
Uint32 sdl20flags, extraflags;
|
icculus@38
|
1213 |
InitFlags12To20(sdl12flags, &sdl20flags, &extraflags);
|
icculus@38
|
1214 |
|
icculus@38
|
1215 |
if (extraflags & SDL12_INIT_CDROM) {
|
icculus@16
|
1216 |
CDRomInit = 0;
|
icculus@38
|
1217 |
}
|
icculus@16
|
1218 |
|
icculus@54
|
1219 |
FIXME("reset a bunch of other global variables too.");
|
icculus@17
|
1220 |
if (sdl12flags & SDL12_INIT_VIDEO) {
|
icculus@39
|
1221 |
Quit12Video();
|
icculus@17
|
1222 |
}
|
icculus@17
|
1223 |
|
icculus@54
|
1224 |
FIXME("do something about SDL12_INIT_EVENTTHREAD");
|
icculus@11
|
1225 |
SDL20_QuitSubSystem(sdl20flags);
|
icculus@9
|
1226 |
|
icculus@42
|
1227 |
if ((SDL20_WasInit(0) == 0) && (!CDRomInit)) {
|
icculus@42
|
1228 |
SDL20_Quit();
|
icculus@42
|
1229 |
UnloadSDL20();
|
icculus@42
|
1230 |
}
|
icculus@9
|
1231 |
}
|
icculus@9
|
1232 |
|
icculus@35
|
1233 |
DECLSPEC void SDLCALL
|
icculus@9
|
1234 |
SDL_Quit(void)
|
icculus@9
|
1235 |
{
|
icculus@42
|
1236 |
SDL_QuitSubSystem(SDL_WasInit(0) | SDL12_INIT_CDROM);
|
icculus@9
|
1237 |
}
|
icculus@9
|
1238 |
|
icculus@35
|
1239 |
DECLSPEC void SDLCALL
|
icculus@11
|
1240 |
SDL_SetError(const char *fmt, ...)
|
icculus@11
|
1241 |
{
|
icculus@34
|
1242 |
char ch;
|
icculus@12
|
1243 |
char *str = NULL;
|
icculus@34
|
1244 |
size_t len = 0;
|
icculus@12
|
1245 |
va_list ap;
|
icculus@81
|
1246 |
|
icculus@81
|
1247 |
if (!LoadSDL20()) { /* SDL_SetError gets called before init sometimes. */
|
icculus@81
|
1248 |
return;
|
icculus@81
|
1249 |
}
|
icculus@81
|
1250 |
|
icculus@12
|
1251 |
va_start(ap, fmt);
|
icculus@34
|
1252 |
len = SDL20_vsnprintf(&ch, 1, fmt, ap);
|
icculus@12
|
1253 |
va_end(ap);
|
icculus@34
|
1254 |
|
icculus@34
|
1255 |
str = (char *) SDL20_malloc(len + 1);
|
icculus@12
|
1256 |
if (!str)
|
icculus@12
|
1257 |
SDL20_OutOfMemory();
|
icculus@12
|
1258 |
else
|
icculus@12
|
1259 |
{
|
icculus@34
|
1260 |
va_start(ap, fmt);
|
icculus@34
|
1261 |
SDL20_vsnprintf(str, len + 1, fmt, ap);
|
icculus@34
|
1262 |
va_end(ap);
|
icculus@12
|
1263 |
SDL20_SetError("%s", str);
|
icculus@34
|
1264 |
SDL20_free(str);
|
icculus@12
|
1265 |
}
|
icculus@11
|
1266 |
}
|
icculus@9
|
1267 |
|
icculus@35
|
1268 |
DECLSPEC const char * SDLCALL
|
icculus@9
|
1269 |
SDL_GetError(void)
|
icculus@9
|
1270 |
{
|
icculus@60
|
1271 |
if (SDL20_GetError == NULL)
|
icculus@9
|
1272 |
{
|
icculus@60
|
1273 |
static const char noload_errstr[] = "The SDL 2.0 library that the 1.2 compatibility layer needs isn't loaded";
|
icculus@9
|
1274 |
return noload_errstr;
|
icculus@9
|
1275 |
}
|
icculus@9
|
1276 |
return SDL20_GetError();
|
icculus@9
|
1277 |
}
|
icculus@9
|
1278 |
|
icculus@9
|
1279 |
|
icculus@9
|
1280 |
static const char *
|
icculus@9
|
1281 |
GetDriverName(const char *name, char *namebuf, int maxlen)
|
icculus@9
|
1282 |
{
|
icculus@9
|
1283 |
if (name) {
|
icculus@9
|
1284 |
if (namebuf) {
|
icculus@9
|
1285 |
SDL20_strlcpy(namebuf, name, maxlen);
|
icculus@9
|
1286 |
return namebuf;
|
icculus@9
|
1287 |
} else {
|
icculus@9
|
1288 |
return name;
|
icculus@9
|
1289 |
}
|
icculus@9
|
1290 |
}
|
icculus@9
|
1291 |
return NULL;
|
icculus@9
|
1292 |
}
|
icculus@9
|
1293 |
|
icculus@35
|
1294 |
DECLSPEC const char * SDLCALL
|
icculus@9
|
1295 |
SDL_AudioDriverName(char *namebuf, int maxlen)
|
icculus@9
|
1296 |
{
|
icculus@9
|
1297 |
return GetDriverName(SDL20_GetCurrentAudioDriver(), namebuf, maxlen);
|
icculus@9
|
1298 |
}
|
icculus@9
|
1299 |
|
icculus@35
|
1300 |
DECLSPEC const char * SDLCALL
|
icculus@9
|
1301 |
SDL_VideoDriverName(char *namebuf, int maxlen)
|
icculus@9
|
1302 |
{
|
icculus@9
|
1303 |
return GetDriverName(SDL20_GetCurrentVideoDriver(), namebuf, maxlen);
|
icculus@9
|
1304 |
}
|
icculus@9
|
1305 |
|
icculus@35
|
1306 |
DECLSPEC int SDLCALL
|
icculus@31
|
1307 |
SDL_PollEvent(SDL12_Event *event12)
|
icculus@31
|
1308 |
{
|
icculus@31
|
1309 |
EventQueueType *next;
|
icculus@31
|
1310 |
|
icculus@71
|
1311 |
SDL20_PumpEvents(); /* this will run our filter and build our 1.2 queue. */
|
icculus@31
|
1312 |
|
icculus@31
|
1313 |
if (EventQueueHead == NULL)
|
icculus@31
|
1314 |
return 0; /* no events at the moment. */
|
icculus@31
|
1315 |
|
icculus@31
|
1316 |
SDL_memcpy(event12, &EventQueueHead->event12, sizeof (SDL12_Event));
|
icculus@31
|
1317 |
next = EventQueueHead->next;
|
icculus@31
|
1318 |
EventQueueHead->next = EventQueueAvailable;
|
icculus@31
|
1319 |
EventQueueAvailable = EventQueueHead;
|
icculus@31
|
1320 |
EventQueueHead = next;
|
icculus@78
|
1321 |
if (!next) {
|
icculus@78
|
1322 |
EventQueueTail = NULL;
|
icculus@78
|
1323 |
}
|
icculus@75
|
1324 |
|
icculus@31
|
1325 |
return 1;
|
icculus@31
|
1326 |
}
|
icculus@31
|
1327 |
|
icculus@35
|
1328 |
DECLSPEC int SDLCALL
|
icculus@31
|
1329 |
SDL_PushEvent(SDL12_Event *event12)
|
icculus@31
|
1330 |
{
|
icculus@31
|
1331 |
EventQueueType *item = EventQueueAvailable;
|
icculus@31
|
1332 |
if (item == NULL)
|
icculus@31
|
1333 |
return -1; /* no space available at the moment. */
|
icculus@31
|
1334 |
|
icculus@31
|
1335 |
EventQueueAvailable = item->next;
|
icculus@31
|
1336 |
if (EventQueueTail)
|
icculus@31
|
1337 |
EventQueueTail->next = item;
|
icculus@31
|
1338 |
else
|
icculus@31
|
1339 |
EventQueueHead = EventQueueTail = item;
|
icculus@31
|
1340 |
item->next = NULL;
|
icculus@31
|
1341 |
|
icculus@31
|
1342 |
SDL_memcpy(&item->event12, event12, sizeof (SDL12_Event));
|
icculus@31
|
1343 |
return 0;
|
icculus@31
|
1344 |
}
|
icculus@31
|
1345 |
|
icculus@35
|
1346 |
DECLSPEC int SDLCALL
|
icculus@31
|
1347 |
SDL_PeepEvents(SDL12_Event *events12, int numevents, SDL_eventaction action, Uint32 mask)
|
icculus@31
|
1348 |
{
|
icculus@31
|
1349 |
if (action == SDL_ADDEVENT)
|
icculus@31
|
1350 |
{
|
icculus@31
|
1351 |
int i;
|
icculus@31
|
1352 |
for (i = 0; i < numevents; i++)
|
icculus@31
|
1353 |
{
|
icculus@31
|
1354 |
if (SDL_PushEvent(&events12[i]) == -1)
|
icculus@31
|
1355 |
break; /* out of space for more events. */
|
icculus@31
|
1356 |
}
|
icculus@31
|
1357 |
return i;
|
icculus@31
|
1358 |
}
|
icculus@31
|
1359 |
else if ((action == SDL_PEEKEVENT) || (action == SDL_GETEVENT))
|
icculus@31
|
1360 |
{
|
icculus@31
|
1361 |
const SDL_bool isGet = (action == SDL_GETEVENT);
|
icculus@31
|
1362 |
EventQueueType *prev = NULL;
|
icculus@31
|
1363 |
EventQueueType *item = EventQueueHead;
|
icculus@31
|
1364 |
EventQueueType *next = NULL;
|
icculus@31
|
1365 |
int chosen = 0;
|
icculus@31
|
1366 |
while (chosen < numevents)
|
icculus@31
|
1367 |
{
|
icculus@31
|
1368 |
EventQueueType *nextPrev = item;
|
icculus@31
|
1369 |
if (!item)
|
icculus@31
|
1370 |
break; /* no more events at the moment. */
|
icculus@31
|
1371 |
|
icculus@31
|
1372 |
next = item->next; /* copy, since we might overwrite item->next */
|
icculus@31
|
1373 |
|
icculus@31
|
1374 |
if (mask & (1<<item->event12.type))
|
icculus@31
|
1375 |
{
|
icculus@31
|
1376 |
SDL_memcpy(&events12[chosen++], &item->event12, sizeof (SDL12_Event));
|
icculus@31
|
1377 |
if (isGet) /* remove from list? */
|
icculus@31
|
1378 |
{
|
icculus@31
|
1379 |
if (prev != NULL)
|
icculus@31
|
1380 |
prev->next = next;
|
icculus@31
|
1381 |
if (item == EventQueueHead)
|
icculus@31
|
1382 |
EventQueueHead = next;
|
icculus@31
|
1383 |
if (item == EventQueueTail)
|
icculus@31
|
1384 |
EventQueueTail = prev;
|
icculus@31
|
1385 |
|
icculus@31
|
1386 |
/* put it back in the free pool. */
|
icculus@31
|
1387 |
item->next = EventQueueAvailable;
|
icculus@31
|
1388 |
EventQueueAvailable = item;
|
icculus@31
|
1389 |
nextPrev = prev; /* previous item doesn't change. */
|
icculus@31
|
1390 |
}
|
icculus@31
|
1391 |
}
|
icculus@31
|
1392 |
|
icculus@31
|
1393 |
item = next;
|
icculus@31
|
1394 |
prev = nextPrev;
|
icculus@31
|
1395 |
}
|
icculus@31
|
1396 |
return chosen;
|
icculus@31
|
1397 |
}
|
icculus@31
|
1398 |
|
icculus@31
|
1399 |
return 0;
|
icculus@31
|
1400 |
}
|
icculus@31
|
1401 |
|
icculus@35
|
1402 |
DECLSPEC int SDLCALL
|
icculus@31
|
1403 |
SDL_WaitEvent(SDL12_Event *event12)
|
icculus@31
|
1404 |
{
|
icculus@54
|
1405 |
FIXME("In 1.2, this only fails (-1) if you haven't SDL_Init()'d.");
|
icculus@31
|
1406 |
while (!SDL_PollEvent(event12))
|
icculus@51
|
1407 |
SDL20_Delay(10);
|
icculus@31
|
1408 |
return 1;
|
icculus@31
|
1409 |
}
|
icculus@31
|
1410 |
|
icculus@32
|
1411 |
static SDL_bool
|
icculus@32
|
1412 |
PushEventIfNotFiltered(SDL12_Event *event12)
|
icculus@32
|
1413 |
{
|
icculus@32
|
1414 |
if (event12->type != SDL12_NOEVENT)
|
icculus@32
|
1415 |
{
|
icculus@32
|
1416 |
if (EventStates[event12->type] != SDL_IGNORE)
|
icculus@32
|
1417 |
{
|
icculus@32
|
1418 |
if ((!EventFilter12) || (EventFilter12(event12)))
|
icculus@32
|
1419 |
return (SDL_PushEvent(event12) == 0);
|
icculus@32
|
1420 |
}
|
icculus@32
|
1421 |
}
|
icculus@32
|
1422 |
return SDL_FALSE;
|
icculus@32
|
1423 |
}
|
icculus@32
|
1424 |
|
icculus@35
|
1425 |
DECLSPEC Uint8 SDLCALL
|
icculus@31
|
1426 |
SDL_EventState(Uint8 type, int state)
|
icculus@31
|
1427 |
{
|
icculus@31
|
1428 |
/* the values of "state" match between 1.2 and 2.0 */
|
icculus@31
|
1429 |
const Uint8 retval = EventStates[type];
|
icculus@31
|
1430 |
SDL12_Event e;
|
icculus@31
|
1431 |
|
icculus@31
|
1432 |
if (state != SDL_QUERY)
|
icculus@31
|
1433 |
EventStates[type] = state;
|
icculus@31
|
1434 |
if (state == SDL_IGNORE) /* drop existing events of this type. */
|
icculus@31
|
1435 |
while (SDL_PeepEvents(&e, 1, SDL_GETEVENT, (1<<type))) {}
|
icculus@31
|
1436 |
|
icculus@31
|
1437 |
return retval;
|
icculus@31
|
1438 |
}
|
icculus@31
|
1439 |
|
icculus@35
|
1440 |
DECLSPEC Uint8 SDLCALL
|
icculus@35
|
1441 |
SDL_GetMouseState(int *x, int *y)
|
icculus@35
|
1442 |
{
|
icculus@35
|
1443 |
const Uint32 state20 = SDL20_GetMouseState(x, y);
|
icculus@35
|
1444 |
Uint8 retval = (state20 & 0x7); /* left, right, and middle will match. */
|
icculus@35
|
1445 |
|
icculus@35
|
1446 |
/* the X[12] buttons are different in 1.2; mousewheel was in the way. */
|
icculus@35
|
1447 |
if (state20 & SDL_BUTTON(SDL_BUTTON_X1))
|
icculus@35
|
1448 |
retval |= (1<<5);
|
icculus@35
|
1449 |
if (state20 & SDL_BUTTON(SDL_BUTTON_X2))
|
icculus@35
|
1450 |
retval |= (1<<6);
|
icculus@35
|
1451 |
|
icculus@35
|
1452 |
return retval;
|
icculus@35
|
1453 |
}
|
icculus@35
|
1454 |
|
icculus@77
|
1455 |
DECLSPEC char * SDLCALL
|
icculus@77
|
1456 |
SDL_GetKeyName(SDL12Key key)
|
icculus@77
|
1457 |
{
|
icculus@77
|
1458 |
switch (key) {
|
icculus@77
|
1459 |
#define CASESDLK12TONAME(k, n) case k: return (char *) n
|
icculus@77
|
1460 |
CASESDLK12TONAME(SDLK12_BACKSPACE, "backspace");
|
icculus@77
|
1461 |
CASESDLK12TONAME(SDLK12_TAB, "tab");
|
icculus@77
|
1462 |
CASESDLK12TONAME(SDLK12_CLEAR, "clear");
|
icculus@77
|
1463 |
CASESDLK12TONAME(SDLK12_RETURN, "return");
|
icculus@77
|
1464 |
CASESDLK12TONAME(SDLK12_PAUSE, "pause");
|
icculus@77
|
1465 |
CASESDLK12TONAME(SDLK12_ESCAPE, "escape");
|
icculus@77
|
1466 |
CASESDLK12TONAME(SDLK12_SPACE, "space");
|
icculus@77
|
1467 |
CASESDLK12TONAME(SDLK12_EXCLAIM, "!");
|
icculus@77
|
1468 |
CASESDLK12TONAME(SDLK12_QUOTEDBL, "\"");
|
icculus@77
|
1469 |
CASESDLK12TONAME(SDLK12_HASH, "#");
|
icculus@77
|
1470 |
CASESDLK12TONAME(SDLK12_DOLLAR, "$");
|
icculus@77
|
1471 |
CASESDLK12TONAME(SDLK12_AMPERSAND, "&");
|
icculus@77
|
1472 |
CASESDLK12TONAME(SDLK12_QUOTE, "'");
|
icculus@77
|
1473 |
CASESDLK12TONAME(SDLK12_LEFTPAREN, "(");
|
icculus@77
|
1474 |
CASESDLK12TONAME(SDLK12_RIGHTPAREN, ")");
|
icculus@77
|
1475 |
CASESDLK12TONAME(SDLK12_ASTERISK, "*");
|
icculus@77
|
1476 |
CASESDLK12TONAME(SDLK12_PLUS, "+");
|
icculus@77
|
1477 |
CASESDLK12TONAME(SDLK12_COMMA, ",");
|
icculus@77
|
1478 |
CASESDLK12TONAME(SDLK12_MINUS, "-");
|
icculus@77
|
1479 |
CASESDLK12TONAME(SDLK12_PERIOD, ".");
|
icculus@77
|
1480 |
CASESDLK12TONAME(SDLK12_SLASH, "/");
|
icculus@77
|
1481 |
CASESDLK12TONAME(SDLK12_0, "0");
|
icculus@77
|
1482 |
CASESDLK12TONAME(SDLK12_1, "1");
|
icculus@77
|
1483 |
CASESDLK12TONAME(SDLK12_2, "2");
|
icculus@77
|
1484 |
CASESDLK12TONAME(SDLK12_3, "3");
|
icculus@77
|
1485 |
CASESDLK12TONAME(SDLK12_4, "4");
|
icculus@77
|
1486 |
CASESDLK12TONAME(SDLK12_5, "5");
|
icculus@77
|
1487 |
CASESDLK12TONAME(SDLK12_6, "6");
|
icculus@77
|
1488 |
CASESDLK12TONAME(SDLK12_7, "7");
|
icculus@77
|
1489 |
CASESDLK12TONAME(SDLK12_8, "8");
|
icculus@77
|
1490 |
CASESDLK12TONAME(SDLK12_9, "9");
|
icculus@77
|
1491 |
CASESDLK12TONAME(SDLK12_COLON, ":");
|
icculus@77
|
1492 |
CASESDLK12TONAME(SDLK12_SEMICOLON, ");");
|
icculus@77
|
1493 |
CASESDLK12TONAME(SDLK12_LESS, "<");
|
icculus@77
|
1494 |
CASESDLK12TONAME(SDLK12_EQUALS, "=");
|
icculus@77
|
1495 |
CASESDLK12TONAME(SDLK12_GREATER, ">");
|
icculus@77
|
1496 |
CASESDLK12TONAME(SDLK12_QUESTION, "?");
|
icculus@77
|
1497 |
CASESDLK12TONAME(SDLK12_AT, "@");
|
icculus@77
|
1498 |
CASESDLK12TONAME(SDLK12_LEFTBRACKET, "[");
|
icculus@77
|
1499 |
CASESDLK12TONAME(SDLK12_BACKSLASH, "\\");
|
icculus@77
|
1500 |
CASESDLK12TONAME(SDLK12_RIGHTBRACKET, "]");
|
icculus@77
|
1501 |
CASESDLK12TONAME(SDLK12_CARET, "^");
|
icculus@77
|
1502 |
CASESDLK12TONAME(SDLK12_UNDERSCORE, "_");
|
icculus@77
|
1503 |
CASESDLK12TONAME(SDLK12_BACKQUOTE, "`");
|
icculus@77
|
1504 |
CASESDLK12TONAME(SDLK12_a, "a");
|
icculus@77
|
1505 |
CASESDLK12TONAME(SDLK12_b, "b");
|
icculus@77
|
1506 |
CASESDLK12TONAME(SDLK12_c, "c");
|
icculus@77
|
1507 |
CASESDLK12TONAME(SDLK12_d, "d");
|
icculus@77
|
1508 |
CASESDLK12TONAME(SDLK12_e, "e");
|
icculus@77
|
1509 |
CASESDLK12TONAME(SDLK12_f, "f");
|
icculus@77
|
1510 |
CASESDLK12TONAME(SDLK12_g, "g");
|
icculus@77
|
1511 |
CASESDLK12TONAME(SDLK12_h, "h");
|
icculus@77
|
1512 |
CASESDLK12TONAME(SDLK12_i, "i");
|
icculus@77
|
1513 |
CASESDLK12TONAME(SDLK12_j, "j");
|
icculus@77
|
1514 |
CASESDLK12TONAME(SDLK12_k, "k");
|
icculus@77
|
1515 |
CASESDLK12TONAME(SDLK12_l, "l");
|
icculus@77
|
1516 |
CASESDLK12TONAME(SDLK12_m, "m");
|
icculus@77
|
1517 |
CASESDLK12TONAME(SDLK12_n, "n");
|
icculus@77
|
1518 |
CASESDLK12TONAME(SDLK12_o, "o");
|
icculus@77
|
1519 |
CASESDLK12TONAME(SDLK12_p, "p");
|
icculus@77
|
1520 |
CASESDLK12TONAME(SDLK12_q, "q");
|
icculus@77
|
1521 |
CASESDLK12TONAME(SDLK12_r, "r");
|
icculus@77
|
1522 |
CASESDLK12TONAME(SDLK12_s, "s");
|
icculus@77
|
1523 |
CASESDLK12TONAME(SDLK12_t, "t");
|
icculus@77
|
1524 |
CASESDLK12TONAME(SDLK12_u, "u");
|
icculus@77
|
1525 |
CASESDLK12TONAME(SDLK12_v, "v");
|
icculus@77
|
1526 |
CASESDLK12TONAME(SDLK12_w, "w");
|
icculus@77
|
1527 |
CASESDLK12TONAME(SDLK12_x, "x");
|
icculus@77
|
1528 |
CASESDLK12TONAME(SDLK12_y, "y");
|
icculus@77
|
1529 |
CASESDLK12TONAME(SDLK12_z, "z");
|
icculus@77
|
1530 |
CASESDLK12TONAME(SDLK12_DELETE, "delete");
|
icculus@77
|
1531 |
|
icculus@77
|
1532 |
CASESDLK12TONAME(SDLK12_WORLD_0, "world 0");
|
icculus@77
|
1533 |
CASESDLK12TONAME(SDLK12_WORLD_1, "world 1");
|
icculus@77
|
1534 |
CASESDLK12TONAME(SDLK12_WORLD_2, "world 2");
|
icculus@77
|
1535 |
CASESDLK12TONAME(SDLK12_WORLD_3, "world 3");
|
icculus@77
|
1536 |
CASESDLK12TONAME(SDLK12_WORLD_4, "world 4");
|
icculus@77
|
1537 |
CASESDLK12TONAME(SDLK12_WORLD_5, "world 5");
|
icculus@77
|
1538 |
CASESDLK12TONAME(SDLK12_WORLD_6, "world 6");
|
icculus@77
|
1539 |
CASESDLK12TONAME(SDLK12_WORLD_7, "world 7");
|
icculus@77
|
1540 |
CASESDLK12TONAME(SDLK12_WORLD_8, "world 8");
|
icculus@77
|
1541 |
CASESDLK12TONAME(SDLK12_WORLD_9, "world 9");
|
icculus@77
|
1542 |
CASESDLK12TONAME(SDLK12_WORLD_10, "world 10");
|
icculus@77
|
1543 |
CASESDLK12TONAME(SDLK12_WORLD_11, "world 11");
|
icculus@77
|
1544 |
CASESDLK12TONAME(SDLK12_WORLD_12, "world 12");
|
icculus@77
|
1545 |
CASESDLK12TONAME(SDLK12_WORLD_13, "world 13");
|
icculus@77
|
1546 |
CASESDLK12TONAME(SDLK12_WORLD_14, "world 14");
|
icculus@77
|
1547 |
CASESDLK12TONAME(SDLK12_WORLD_15, "world 15");
|
icculus@77
|
1548 |
CASESDLK12TONAME(SDLK12_WORLD_16, "world 16");
|
icculus@77
|
1549 |
CASESDLK12TONAME(SDLK12_WORLD_17, "world 17");
|
icculus@77
|
1550 |
CASESDLK12TONAME(SDLK12_WORLD_18, "world 18");
|
icculus@77
|
1551 |
CASESDLK12TONAME(SDLK12_WORLD_19, "world 19");
|
icculus@77
|
1552 |
CASESDLK12TONAME(SDLK12_WORLD_20, "world 20");
|
icculus@77
|
1553 |
CASESDLK12TONAME(SDLK12_WORLD_21, "world 21");
|
icculus@77
|
1554 |
CASESDLK12TONAME(SDLK12_WORLD_22, "world 22");
|
icculus@77
|
1555 |
CASESDLK12TONAME(SDLK12_WORLD_23, "world 23");
|
icculus@77
|
1556 |
CASESDLK12TONAME(SDLK12_WORLD_24, "world 24");
|
icculus@77
|
1557 |
CASESDLK12TONAME(SDLK12_WORLD_25, "world 25");
|
icculus@77
|
1558 |
CASESDLK12TONAME(SDLK12_WORLD_26, "world 26");
|
icculus@77
|
1559 |
CASESDLK12TONAME(SDLK12_WORLD_27, "world 27");
|
icculus@77
|
1560 |
CASESDLK12TONAME(SDLK12_WORLD_28, "world 28");
|
icculus@77
|
1561 |
CASESDLK12TONAME(SDLK12_WORLD_29, "world 29");
|
icculus@77
|
1562 |
CASESDLK12TONAME(SDLK12_WORLD_30, "world 30");
|
icculus@77
|
1563 |
CASESDLK12TONAME(SDLK12_WORLD_31, "world 31");
|
icculus@77
|
1564 |
CASESDLK12TONAME(SDLK12_WORLD_32, "world 32");
|
icculus@77
|
1565 |
CASESDLK12TONAME(SDLK12_WORLD_33, "world 33");
|
icculus@77
|
1566 |
CASESDLK12TONAME(SDLK12_WORLD_34, "world 34");
|
icculus@77
|
1567 |
CASESDLK12TONAME(SDLK12_WORLD_35, "world 35");
|
icculus@77
|
1568 |
CASESDLK12TONAME(SDLK12_WORLD_36, "world 36");
|
icculus@77
|
1569 |
CASESDLK12TONAME(SDLK12_WORLD_37, "world 37");
|
icculus@77
|
1570 |
CASESDLK12TONAME(SDLK12_WORLD_38, "world 38");
|
icculus@77
|
1571 |
CASESDLK12TONAME(SDLK12_WORLD_39, "world 39");
|
icculus@77
|
1572 |
CASESDLK12TONAME(SDLK12_WORLD_40, "world 40");
|
icculus@77
|
1573 |
CASESDLK12TONAME(SDLK12_WORLD_41, "world 41");
|
icculus@77
|
1574 |
CASESDLK12TONAME(SDLK12_WORLD_42, "world 42");
|
icculus@77
|
1575 |
CASESDLK12TONAME(SDLK12_WORLD_43, "world 43");
|
icculus@77
|
1576 |
CASESDLK12TONAME(SDLK12_WORLD_44, "world 44");
|
icculus@77
|
1577 |
CASESDLK12TONAME(SDLK12_WORLD_45, "world 45");
|
icculus@77
|
1578 |
CASESDLK12TONAME(SDLK12_WORLD_46, "world 46");
|
icculus@77
|
1579 |
CASESDLK12TONAME(SDLK12_WORLD_47, "world 47");
|
icculus@77
|
1580 |
CASESDLK12TONAME(SDLK12_WORLD_48, "world 48");
|
icculus@77
|
1581 |
CASESDLK12TONAME(SDLK12_WORLD_49, "world 49");
|
icculus@77
|
1582 |
CASESDLK12TONAME(SDLK12_WORLD_50, "world 50");
|
icculus@77
|
1583 |
CASESDLK12TONAME(SDLK12_WORLD_51, "world 51");
|
icculus@77
|
1584 |
CASESDLK12TONAME(SDLK12_WORLD_52, "world 52");
|
icculus@77
|
1585 |
CASESDLK12TONAME(SDLK12_WORLD_53, "world 53");
|
icculus@77
|
1586 |
CASESDLK12TONAME(SDLK12_WORLD_54, "world 54");
|
icculus@77
|
1587 |
CASESDLK12TONAME(SDLK12_WORLD_55, "world 55");
|
icculus@77
|
1588 |
CASESDLK12TONAME(SDLK12_WORLD_56, "world 56");
|
icculus@77
|
1589 |
CASESDLK12TONAME(SDLK12_WORLD_57, "world 57");
|
icculus@77
|
1590 |
CASESDLK12TONAME(SDLK12_WORLD_58, "world 58");
|
icculus@77
|
1591 |
CASESDLK12TONAME(SDLK12_WORLD_59, "world 59");
|
icculus@77
|
1592 |
CASESDLK12TONAME(SDLK12_WORLD_60, "world 60");
|
icculus@77
|
1593 |
CASESDLK12TONAME(SDLK12_WORLD_61, "world 61");
|
icculus@77
|
1594 |
CASESDLK12TONAME(SDLK12_WORLD_62, "world 62");
|
icculus@77
|
1595 |
CASESDLK12TONAME(SDLK12_WORLD_63, "world 63");
|
icculus@77
|
1596 |
CASESDLK12TONAME(SDLK12_WORLD_64, "world 64");
|
icculus@77
|
1597 |
CASESDLK12TONAME(SDLK12_WORLD_65, "world 65");
|
icculus@77
|
1598 |
CASESDLK12TONAME(SDLK12_WORLD_66, "world 66");
|
icculus@77
|
1599 |
CASESDLK12TONAME(SDLK12_WORLD_67, "world 67");
|
icculus@77
|
1600 |
CASESDLK12TONAME(SDLK12_WORLD_68, "world 68");
|
icculus@77
|
1601 |
CASESDLK12TONAME(SDLK12_WORLD_69, "world 69");
|
icculus@77
|
1602 |
CASESDLK12TONAME(SDLK12_WORLD_70, "world 70");
|
icculus@77
|
1603 |
CASESDLK12TONAME(SDLK12_WORLD_71, "world 71");
|
icculus@77
|
1604 |
CASESDLK12TONAME(SDLK12_WORLD_72, "world 72");
|
icculus@77
|
1605 |
CASESDLK12TONAME(SDLK12_WORLD_73, "world 73");
|
icculus@77
|
1606 |
CASESDLK12TONAME(SDLK12_WORLD_74, "world 74");
|
icculus@77
|
1607 |
CASESDLK12TONAME(SDLK12_WORLD_75, "world 75");
|
icculus@77
|
1608 |
CASESDLK12TONAME(SDLK12_WORLD_76, "world 76");
|
icculus@77
|
1609 |
CASESDLK12TONAME(SDLK12_WORLD_77, "world 77");
|
icculus@77
|
1610 |
CASESDLK12TONAME(SDLK12_WORLD_78, "world 78");
|
icculus@77
|
1611 |
CASESDLK12TONAME(SDLK12_WORLD_79, "world 79");
|
icculus@77
|
1612 |
CASESDLK12TONAME(SDLK12_WORLD_80, "world 80");
|
icculus@77
|
1613 |
CASESDLK12TONAME(SDLK12_WORLD_81, "world 81");
|
icculus@77
|
1614 |
CASESDLK12TONAME(SDLK12_WORLD_82, "world 82");
|
icculus@77
|
1615 |
CASESDLK12TONAME(SDLK12_WORLD_83, "world 83");
|
icculus@77
|
1616 |
CASESDLK12TONAME(SDLK12_WORLD_84, "world 84");
|
icculus@77
|
1617 |
CASESDLK12TONAME(SDLK12_WORLD_85, "world 85");
|
icculus@77
|
1618 |
CASESDLK12TONAME(SDLK12_WORLD_86, "world 86");
|
icculus@77
|
1619 |
CASESDLK12TONAME(SDLK12_WORLD_87, "world 87");
|
icculus@77
|
1620 |
CASESDLK12TONAME(SDLK12_WORLD_88, "world 88");
|
icculus@77
|
1621 |
CASESDLK12TONAME(SDLK12_WORLD_89, "world 89");
|
icculus@77
|
1622 |
CASESDLK12TONAME(SDLK12_WORLD_90, "world 90");
|
icculus@77
|
1623 |
CASESDLK12TONAME(SDLK12_WORLD_91, "world 91");
|
icculus@77
|
1624 |
CASESDLK12TONAME(SDLK12_WORLD_92, "world 92");
|
icculus@77
|
1625 |
CASESDLK12TONAME(SDLK12_WORLD_93, "world 93");
|
icculus@77
|
1626 |
CASESDLK12TONAME(SDLK12_WORLD_94, "world 94");
|
icculus@77
|
1627 |
CASESDLK12TONAME(SDLK12_WORLD_95, "world 95");
|
icculus@77
|
1628 |
|
icculus@77
|
1629 |
CASESDLK12TONAME(SDLK12_KP0, "[0]");
|
icculus@77
|
1630 |
CASESDLK12TONAME(SDLK12_KP1, "[1]");
|
icculus@77
|
1631 |
CASESDLK12TONAME(SDLK12_KP2, "[2]");
|
icculus@77
|
1632 |
CASESDLK12TONAME(SDLK12_KP3, "[3]");
|
icculus@77
|
1633 |
CASESDLK12TONAME(SDLK12_KP4, "[4]");
|
icculus@77
|
1634 |
CASESDLK12TONAME(SDLK12_KP5, "[5]");
|
icculus@77
|
1635 |
CASESDLK12TONAME(SDLK12_KP6, "[6]");
|
icculus@77
|
1636 |
CASESDLK12TONAME(SDLK12_KP7, "[7]");
|
icculus@77
|
1637 |
CASESDLK12TONAME(SDLK12_KP8, "[8]");
|
icculus@77
|
1638 |
CASESDLK12TONAME(SDLK12_KP9, "[9]");
|
icculus@77
|
1639 |
CASESDLK12TONAME(SDLK12_KP_PERIOD, "[.]");
|
icculus@77
|
1640 |
CASESDLK12TONAME(SDLK12_KP_DIVIDE, "[/]");
|
icculus@77
|
1641 |
CASESDLK12TONAME(SDLK12_KP_MULTIPLY, "[*]");
|
icculus@77
|
1642 |
CASESDLK12TONAME(SDLK12_KP_MINUS, "[-]");
|
icculus@77
|
1643 |
CASESDLK12TONAME(SDLK12_KP_PLUS, "[+]");
|
icculus@77
|
1644 |
CASESDLK12TONAME(SDLK12_KP_ENTER, "enter");
|
icculus@77
|
1645 |
CASESDLK12TONAME(SDLK12_KP_EQUALS, "equals");
|
icculus@77
|
1646 |
|
icculus@77
|
1647 |
CASESDLK12TONAME(SDLK12_UP, "up");
|
icculus@77
|
1648 |
CASESDLK12TONAME(SDLK12_DOWN, "down");
|
icculus@77
|
1649 |
CASESDLK12TONAME(SDLK12_RIGHT, "right");
|
icculus@77
|
1650 |
CASESDLK12TONAME(SDLK12_LEFT, "left");
|
icculus@77
|
1651 |
CASESDLK12TONAME(SDLK12_INSERT, "insert");
|
icculus@77
|
1652 |
CASESDLK12TONAME(SDLK12_HOME, "home");
|
icculus@77
|
1653 |
CASESDLK12TONAME(SDLK12_END, "end");
|
icculus@77
|
1654 |
CASESDLK12TONAME(SDLK12_PAGEUP, "page up");
|
icculus@77
|
1655 |
CASESDLK12TONAME(SDLK12_PAGEDOWN, "page down");
|
icculus@77
|
1656 |
|
icculus@77
|
1657 |
CASESDLK12TONAME(SDLK12_F1, "f1");
|
icculus@77
|
1658 |
CASESDLK12TONAME(SDLK12_F2, "f2");
|
icculus@77
|
1659 |
CASESDLK12TONAME(SDLK12_F3, "f3");
|
icculus@77
|
1660 |
CASESDLK12TONAME(SDLK12_F4, "f4");
|
icculus@77
|
1661 |
CASESDLK12TONAME(SDLK12_F5, "f5");
|
icculus@77
|
1662 |
CASESDLK12TONAME(SDLK12_F6, "f6");
|
icculus@77
|
1663 |
CASESDLK12TONAME(SDLK12_F7, "f7");
|
icculus@77
|
1664 |
CASESDLK12TONAME(SDLK12_F8, "f8");
|
icculus@77
|
1665 |
CASESDLK12TONAME(SDLK12_F9, "f9");
|
icculus@77
|
1666 |
CASESDLK12TONAME(SDLK12_F10, "f10");
|
icculus@77
|
1667 |
CASESDLK12TONAME(SDLK12_F11, "f11");
|
icculus@77
|
1668 |
CASESDLK12TONAME(SDLK12_F12, "f12");
|
icculus@77
|
1669 |
CASESDLK12TONAME(SDLK12_F13, "f13");
|
icculus@77
|
1670 |
CASESDLK12TONAME(SDLK12_F14, "f14");
|
icculus@77
|
1671 |
CASESDLK12TONAME(SDLK12_F15, "f15");
|
icculus@77
|
1672 |
|
icculus@77
|
1673 |
CASESDLK12TONAME(SDLK12_NUMLOCK, "numlock");
|
icculus@77
|
1674 |
CASESDLK12TONAME(SDLK12_CAPSLOCK, "caps lock");
|
icculus@77
|
1675 |
CASESDLK12TONAME(SDLK12_SCROLLOCK, "scroll lock");
|
icculus@77
|
1676 |
CASESDLK12TONAME(SDLK12_RSHIFT, "right shift");
|
icculus@77
|
1677 |
CASESDLK12TONAME(SDLK12_LSHIFT, "left shift");
|
icculus@77
|
1678 |
CASESDLK12TONAME(SDLK12_RCTRL, "right ctrl");
|
icculus@77
|
1679 |
CASESDLK12TONAME(SDLK12_LCTRL, "left ctrl");
|
icculus@77
|
1680 |
CASESDLK12TONAME(SDLK12_RALT, "right alt");
|
icculus@77
|
1681 |
CASESDLK12TONAME(SDLK12_LALT, "left alt");
|
icculus@77
|
1682 |
CASESDLK12TONAME(SDLK12_RMETA, "right meta");
|
icculus@77
|
1683 |
CASESDLK12TONAME(SDLK12_LMETA, "left meta");
|
icculus@77
|
1684 |
CASESDLK12TONAME(SDLK12_LSUPER, "left super"); /* "Windows" keys */
|
icculus@77
|
1685 |
CASESDLK12TONAME(SDLK12_RSUPER, "right super");
|
icculus@77
|
1686 |
CASESDLK12TONAME(SDLK12_MODE, "alt gr");
|
icculus@77
|
1687 |
CASESDLK12TONAME(SDLK12_COMPOSE, "compose");
|
icculus@77
|
1688 |
|
icculus@77
|
1689 |
CASESDLK12TONAME(SDLK12_HELP, "help");
|
icculus@77
|
1690 |
CASESDLK12TONAME(SDLK12_PRINT, "print screen");
|
icculus@77
|
1691 |
CASESDLK12TONAME(SDLK12_SYSREQ, "sys req");
|
icculus@77
|
1692 |
CASESDLK12TONAME(SDLK12_BREAK, "break");
|
icculus@77
|
1693 |
CASESDLK12TONAME(SDLK12_MENU, "menu");
|
icculus@77
|
1694 |
CASESDLK12TONAME(SDLK12_POWER, "power");
|
icculus@77
|
1695 |
CASESDLK12TONAME(SDLK12_EURO, "euro");
|
icculus@77
|
1696 |
CASESDLK12TONAME(SDLK12_UNDO, "undo");
|
icculus@77
|
1697 |
#undef CASESDLK12TONAME
|
icculus@77
|
1698 |
default: break;
|
icculus@77
|
1699 |
}
|
icculus@77
|
1700 |
|
icculus@77
|
1701 |
return (char *) "unknown key";
|
icculus@77
|
1702 |
}
|
icculus@77
|
1703 |
|
icculus@77
|
1704 |
static SDL12Key
|
icculus@77
|
1705 |
Keysym20to12(const SDL_Keycode keysym20)
|
icculus@77
|
1706 |
{
|
icculus@77
|
1707 |
if ( ((int) keysym20) < 127 ) { /* (most of) low-ASCII maps directly */
|
icculus@77
|
1708 |
if (keysym20 == SDLK_PAUSE) {
|
icculus@77
|
1709 |
return SDLK12_PAUSE;
|
icculus@77
|
1710 |
} else if (keysym20 == SDLK_CLEAR) {
|
icculus@77
|
1711 |
return SDLK12_CLEAR;
|
icculus@77
|
1712 |
}
|
icculus@77
|
1713 |
return (SDL12Key) keysym20;
|
icculus@77
|
1714 |
}
|
icculus@77
|
1715 |
|
icculus@77
|
1716 |
switch (keysym20) {
|
icculus@77
|
1717 |
#define CASEKEYSYM20TO12(k20, k12) case SDLK_##k20: return SDLK12_##k12
|
icculus@77
|
1718 |
CASEKEYSYM20TO12(KP_0, KP0);
|
icculus@77
|
1719 |
CASEKEYSYM20TO12(KP_1, KP1);
|
icculus@77
|
1720 |
CASEKEYSYM20TO12(KP_2, KP2);
|
icculus@77
|
1721 |
CASEKEYSYM20TO12(KP_3, KP3);
|
icculus@77
|
1722 |
CASEKEYSYM20TO12(KP_4, KP4);
|
icculus@77
|
1723 |
CASEKEYSYM20TO12(KP_5, KP5);
|
icculus@77
|
1724 |
CASEKEYSYM20TO12(KP_6, KP6);
|
icculus@77
|
1725 |
CASEKEYSYM20TO12(KP_7, KP7);
|
icculus@77
|
1726 |
CASEKEYSYM20TO12(KP_8, KP8);
|
icculus@77
|
1727 |
CASEKEYSYM20TO12(KP_9, KP9);
|
icculus@77
|
1728 |
CASEKEYSYM20TO12(NUMLOCKCLEAR, NUMLOCK);
|
icculus@77
|
1729 |
CASEKEYSYM20TO12(SCROLLLOCK, SCROLLOCK);
|
icculus@77
|
1730 |
CASEKEYSYM20TO12(RGUI, RMETA);
|
icculus@77
|
1731 |
CASEKEYSYM20TO12(LGUI, LMETA);
|
icculus@77
|
1732 |
CASEKEYSYM20TO12(PRINTSCREEN, PRINT);
|
icculus@77
|
1733 |
#undef CASEKEYSYM20TO12
|
icculus@77
|
1734 |
|
icculus@77
|
1735 |
#define CASEKEYSYM20TO12(k) case SDLK_##k: return SDLK12_##k
|
icculus@77
|
1736 |
CASEKEYSYM20TO12(CLEAR);
|
icculus@77
|
1737 |
CASEKEYSYM20TO12(PAUSE);
|
icculus@77
|
1738 |
CASEKEYSYM20TO12(KP_PERIOD);
|
icculus@77
|
1739 |
CASEKEYSYM20TO12(KP_DIVIDE);
|
icculus@77
|
1740 |
CASEKEYSYM20TO12(KP_MULTIPLY);
|
icculus@77
|
1741 |
CASEKEYSYM20TO12(KP_MINUS);
|
icculus@77
|
1742 |
CASEKEYSYM20TO12(KP_PLUS);
|
icculus@77
|
1743 |
CASEKEYSYM20TO12(KP_ENTER);
|
icculus@77
|
1744 |
CASEKEYSYM20TO12(KP_EQUALS);
|
icculus@77
|
1745 |
CASEKEYSYM20TO12(UP);
|
icculus@77
|
1746 |
CASEKEYSYM20TO12(DOWN);
|
icculus@77
|
1747 |
CASEKEYSYM20TO12(RIGHT);
|
icculus@77
|
1748 |
CASEKEYSYM20TO12(LEFT);
|
icculus@77
|
1749 |
CASEKEYSYM20TO12(INSERT);
|
icculus@77
|
1750 |
CASEKEYSYM20TO12(HOME);
|
icculus@77
|
1751 |
CASEKEYSYM20TO12(END);
|
icculus@77
|
1752 |
CASEKEYSYM20TO12(PAGEUP);
|
icculus@77
|
1753 |
CASEKEYSYM20TO12(PAGEDOWN);
|
icculus@77
|
1754 |
CASEKEYSYM20TO12(F1);
|
icculus@77
|
1755 |
CASEKEYSYM20TO12(F2);
|
icculus@77
|
1756 |
CASEKEYSYM20TO12(F3);
|
icculus@77
|
1757 |
CASEKEYSYM20TO12(F4);
|
icculus@77
|
1758 |
CASEKEYSYM20TO12(F5);
|
icculus@77
|
1759 |
CASEKEYSYM20TO12(F6);
|
icculus@77
|
1760 |
CASEKEYSYM20TO12(F7);
|
icculus@77
|
1761 |
CASEKEYSYM20TO12(F8);
|
icculus@77
|
1762 |
CASEKEYSYM20TO12(F9);
|
icculus@77
|
1763 |
CASEKEYSYM20TO12(F10);
|
icculus@77
|
1764 |
CASEKEYSYM20TO12(F11);
|
icculus@77
|
1765 |
CASEKEYSYM20TO12(F12);
|
icculus@77
|
1766 |
CASEKEYSYM20TO12(F13);
|
icculus@77
|
1767 |
CASEKEYSYM20TO12(F14);
|
icculus@77
|
1768 |
CASEKEYSYM20TO12(F15);
|
icculus@77
|
1769 |
CASEKEYSYM20TO12(CAPSLOCK);
|
icculus@77
|
1770 |
CASEKEYSYM20TO12(RSHIFT);
|
icculus@77
|
1771 |
CASEKEYSYM20TO12(LSHIFT);
|
icculus@77
|
1772 |
CASEKEYSYM20TO12(RCTRL);
|
icculus@77
|
1773 |
CASEKEYSYM20TO12(LCTRL);
|
icculus@77
|
1774 |
CASEKEYSYM20TO12(RALT);
|
icculus@77
|
1775 |
CASEKEYSYM20TO12(LALT);
|
icculus@77
|
1776 |
CASEKEYSYM20TO12(MODE);
|
icculus@77
|
1777 |
CASEKEYSYM20TO12(HELP);
|
icculus@77
|
1778 |
CASEKEYSYM20TO12(SYSREQ);;
|
icculus@77
|
1779 |
CASEKEYSYM20TO12(MENU);
|
icculus@77
|
1780 |
CASEKEYSYM20TO12(POWER);
|
icculus@77
|
1781 |
CASEKEYSYM20TO12(UNDO);
|
icculus@77
|
1782 |
#undef CASEKEYSYM20TO12
|
icculus@77
|
1783 |
default: break;
|
icculus@77
|
1784 |
}
|
icculus@77
|
1785 |
|
icculus@77
|
1786 |
FIXME("nothing maps to SDLK12_COMPOSE, SDLK12_BREAK, or SDLK12_EURO ...?");
|
icculus@77
|
1787 |
FIXME("map some of the SDLK12_WORLD keys");
|
icculus@77
|
1788 |
return SDLK12_UNKNOWN;
|
icculus@77
|
1789 |
}
|
icculus@77
|
1790 |
|
icculus@18
|
1791 |
static int
|
icculus@18
|
1792 |
EventFilter20to12(void *data, SDL_Event *event20)
|
icculus@15
|
1793 |
{
|
icculus@43
|
1794 |
//const int maxUserEvents12 = SDL12_NUMEVENTS - SDL12_USEREVENT;
|
icculus@18
|
1795 |
SDL12_Event event12;
|
icculus@32
|
1796 |
int x, y;
|
icculus@18
|
1797 |
|
icculus@18
|
1798 |
SDL_assert(data == NULL); /* currently unused. */
|
icculus@18
|
1799 |
|
icculus@34
|
1800 |
SDL20_zero(event12);
|
icculus@18
|
1801 |
|
icculus@18
|
1802 |
switch (event20->type)
|
icculus@18
|
1803 |
{
|
icculus@18
|
1804 |
case SDL_QUIT:
|
icculus@31
|
1805 |
event12.type = SDL12_QUIT;
|
icculus@18
|
1806 |
break;
|
icculus@18
|
1807 |
|
icculus@18
|
1808 |
case SDL_WINDOWEVENT:
|
icculus@18
|
1809 |
switch (event20->window.event)
|
icculus@18
|
1810 |
{
|
icculus@18
|
1811 |
case SDL_WINDOWEVENT_CLOSE:
|
icculus@31
|
1812 |
event12.type = SDL12_QUIT;
|
icculus@18
|
1813 |
break;
|
icculus@18
|
1814 |
|
icculus@18
|
1815 |
case SDL_WINDOWEVENT_SHOWN:
|
icculus@18
|
1816 |
case SDL_WINDOWEVENT_EXPOSED:
|
icculus@31
|
1817 |
event12.type = SDL12_VIDEOEXPOSE;
|
icculus@18
|
1818 |
break;
|
icculus@18
|
1819 |
|
icculus@18
|
1820 |
case SDL_WINDOWEVENT_RESIZED:
|
icculus@54
|
1821 |
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
icculus@54
|
1822 |
FIXME("what's the difference between RESIZED and SIZE_CHANGED?");
|
icculus@31
|
1823 |
event12.type = SDL12_VIDEORESIZE;
|
icculus@31
|
1824 |
event12.resize.w = event20->window.data1;
|
icculus@31
|
1825 |
event12.resize.h = event20->window.data2;
|
icculus@18
|
1826 |
break;
|
icculus@18
|
1827 |
|
icculus@18
|
1828 |
case SDL_WINDOWEVENT_MINIMIZED:
|
icculus@31
|
1829 |
event12.type = SDL12_ACTIVEEVENT;
|
icculus@31
|
1830 |
event12.active.gain = 0;
|
icculus@31
|
1831 |
event12.active.state = SDL12_APPACTIVE;
|
icculus@18
|
1832 |
break;
|
icculus@18
|
1833 |
|
icculus@18
|
1834 |
case SDL_WINDOWEVENT_RESTORED:
|
icculus@31
|
1835 |
event12.type = SDL12_ACTIVEEVENT;
|
icculus@31
|
1836 |
event12.active.gain = 1;
|
icculus@31
|
1837 |
event12.active.state = SDL12_APPACTIVE;
|
icculus@18
|
1838 |
break;
|
icculus@18
|
1839 |
|
icculus@18
|
1840 |
case SDL_WINDOWEVENT_ENTER:
|
icculus@31
|
1841 |
event12.type = SDL12_ACTIVEEVENT;
|
icculus@31
|
1842 |
event12.active.gain = 1;
|
icculus@31
|
1843 |
event12.active.state = SDL12_APPMOUSEFOCUS;
|
icculus@18
|
1844 |
break;
|
icculus@18
|
1845 |
|
icculus@18
|
1846 |
case SDL_WINDOWEVENT_LEAVE:
|
icculus@31
|
1847 |
event12.type = SDL12_ACTIVEEVENT;
|
icculus@31
|
1848 |
event12.active.gain = 0;
|
icculus@31
|
1849 |
event12.active.state = SDL12_APPMOUSEFOCUS;
|
icculus@18
|
1850 |
break;
|
icculus@18
|
1851 |
|
icculus@18
|
1852 |
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
icculus@31
|
1853 |
event12.type = SDL12_ACTIVEEVENT;
|
icculus@31
|
1854 |
event12.active.gain = 1;
|
icculus@31
|
1855 |
event12.active.state = SDL12_APPINPUTFOCUS;
|
icculus@18
|
1856 |
break;
|
icculus@18
|
1857 |
|
icculus@18
|
1858 |
case SDL_WINDOWEVENT_FOCUS_LOST:
|
icculus@31
|
1859 |
event12.type = SDL12_ACTIVEEVENT;
|
icculus@31
|
1860 |
event12.active.gain = 0;
|
icculus@31
|
1861 |
event12.active.state = SDL12_APPINPUTFOCUS;
|
icculus@18
|
1862 |
break;
|
icculus@18
|
1863 |
}
|
icculus@18
|
1864 |
break;
|
icculus@18
|
1865 |
|
icculus@18
|
1866 |
// !!! FIXME: this is sort of a mess to convert.
|
icculus@77
|
1867 |
case SDL_SYSWMEVENT: FIXME("write me"); return 0;
|
icculus@77
|
1868 |
|
icculus@77
|
1869 |
case SDL_KEYUP:
|
icculus@77
|
1870 |
case SDL_KEYDOWN:
|
icculus@77
|
1871 |
if (event20->key.repeat) {
|
icculus@77
|
1872 |
return 0; /* ignore 2.0-style key repeat events */
|
icculus@77
|
1873 |
}
|
icculus@77
|
1874 |
event12.key.keysym.sym = Keysym20to12(event20->key.keysym.sym);
|
icculus@77
|
1875 |
if (event12.key.keysym.sym == SDLK12_UNKNOWN) {
|
icculus@77
|
1876 |
return 0; /* drop it if we can't map it */
|
icculus@77
|
1877 |
}
|
icculus@77
|
1878 |
event12.type = (event20->type == SDL_KEYDOWN) ? SDL12_KEYDOWN : SDL12_KEYUP;
|
icculus@77
|
1879 |
event12.key.which = 0;
|
icculus@77
|
1880 |
event12.key.state = event20->key.state;
|
icculus@77
|
1881 |
event12.key.keysym.scancode = (event20->key.keysym.scancode < 256) ? (Uint8) event20->key.keysym.scancode : 0;
|
icculus@77
|
1882 |
event12.key.keysym.mod = event20->key.keysym.mod; /* these match up between 1.2 and 2.0! */
|
icculus@77
|
1883 |
event12.key.keysym.unicode = 0; FIXME("unicode");
|
icculus@77
|
1884 |
break;
|
icculus@18
|
1885 |
|
icculus@54
|
1886 |
case SDL_TEXTEDITING: FIXME("write me"); return 0;
|
icculus@54
|
1887 |
case SDL_TEXTINPUT: FIXME("write me"); return 0;
|
icculus@18
|
1888 |
|
icculus@18
|
1889 |
case SDL_MOUSEMOTION:
|
icculus@31
|
1890 |
event12.type = SDL12_MOUSEMOTION;
|
icculus@31
|
1891 |
event12.motion.which = (Uint8) event20->motion.which;
|
icculus@31
|
1892 |
event12.motion.state = event20->motion.state;
|
icculus@31
|
1893 |
event12.motion.x = (Uint16) event20->motion.x;
|
icculus@31
|
1894 |
event12.motion.y = (Uint16) event20->motion.y;
|
icculus@31
|
1895 |
event12.motion.xrel = (Sint16) event20->motion.xrel;
|
icculus@31
|
1896 |
event12.motion.yrel = (Sint16) event20->motion.yrel;
|
icculus@18
|
1897 |
break;
|
icculus@18
|
1898 |
|
icculus@18
|
1899 |
case SDL_MOUSEBUTTONDOWN:
|
icculus@31
|
1900 |
event12.type = SDL12_MOUSEBUTTONDOWN;
|
icculus@31
|
1901 |
event12.button.which = (Uint8) event20->button.which;
|
icculus@31
|
1902 |
event12.button.button = event20->button.button;
|
icculus@31
|
1903 |
event12.button.state = event20->button.state;
|
icculus@31
|
1904 |
event12.button.x = (Uint16) event20->button.x;
|
icculus@31
|
1905 |
event12.button.y = (Uint16) event20->button.y;
|
icculus@18
|
1906 |
break;
|
icculus@18
|
1907 |
|
icculus@18
|
1908 |
case SDL_MOUSEBUTTONUP:
|
icculus@31
|
1909 |
event12.type = SDL12_MOUSEBUTTONUP;
|
icculus@31
|
1910 |
event12.button.which = (Uint8) event20->button.which;
|
icculus@31
|
1911 |
event12.button.button = event20->button.button;
|
icculus@31
|
1912 |
event12.button.state = event20->button.state;
|
icculus@31
|
1913 |
event12.button.x = (Uint16) event20->button.x;
|
icculus@31
|
1914 |
event12.button.y = (Uint16) event20->button.y;
|
icculus@18
|
1915 |
break;
|
icculus@18
|
1916 |
|
icculus@18
|
1917 |
case SDL_MOUSEWHEEL:
|
icculus@32
|
1918 |
if (event20->wheel.y == 0)
|
icculus@32
|
1919 |
break; /* don't support horizontal wheels in 1.2. */
|
icculus@32
|
1920 |
|
icculus@32
|
1921 |
event12.type = SDL12_MOUSEBUTTONDOWN;
|
icculus@32
|
1922 |
event12.button.which = (Uint8) event20->wheel.which;
|
icculus@32
|
1923 |
event12.button.button = (event20->wheel.y > 0) ? 4 : 5; /* wheelup is 4, down is 5. */
|
icculus@32
|
1924 |
event12.button.state = SDL_GetMouseState(&x, &y);
|
icculus@32
|
1925 |
event12.button.x = (Uint16) x;
|
icculus@32
|
1926 |
event12.button.y = (Uint16) y;
|
icculus@32
|
1927 |
PushEventIfNotFiltered(&event12);
|
icculus@32
|
1928 |
|
icculus@32
|
1929 |
event12.type = SDL12_MOUSEBUTTONUP; /* immediately release mouse "button" at the end of this switch. */
|
icculus@18
|
1930 |
break;
|
icculus@18
|
1931 |
|
icculus@18
|
1932 |
case SDL_JOYAXISMOTION:
|
icculus@31
|
1933 |
event12.type = SDL12_JOYAXISMOTION;
|
icculus@31
|
1934 |
event12.jaxis.which = (Uint8) event20->jaxis.which;
|
icculus@31
|
1935 |
event12.jaxis.axis = event20->jaxis.axis;
|
icculus@31
|
1936 |
event12.jaxis.value = event20->jaxis.value;
|
icculus@18
|
1937 |
break;
|
icculus@18
|
1938 |
|
icculus@18
|
1939 |
case SDL_JOYBALLMOTION:
|
icculus@31
|
1940 |
event12.type = SDL12_JOYBALLMOTION;
|
icculus@31
|
1941 |
event12.jball.which = (Uint8) event20->jball.which;
|
icculus@31
|
1942 |
event12.jball.ball = event20->jball.ball;
|
icculus@31
|
1943 |
event12.jball.xrel = event20->jball.xrel;
|
icculus@31
|
1944 |
event12.jball.yrel = event20->jball.yrel;
|
icculus@18
|
1945 |
break;
|
icculus@18
|
1946 |
|
icculus@18
|
1947 |
case SDL_JOYHATMOTION:
|
icculus@31
|
1948 |
event12.type = SDL12_JOYHATMOTION;
|
icculus@31
|
1949 |
event12.jhat.which = (Uint8) event20->jhat.which;
|
icculus@31
|
1950 |
event12.jhat.hat = event20->jhat.hat;
|
icculus@31
|
1951 |
event12.jhat.value = event20->jhat.value;
|
icculus@18
|
1952 |
break;
|
icculus@18
|
1953 |
|
icculus@18
|
1954 |
case SDL_JOYBUTTONDOWN:
|
icculus@31
|
1955 |
event12.type = SDL12_JOYBUTTONDOWN;
|
icculus@31
|
1956 |
event12.jbutton.which = (Uint8) event20->jbutton.which;
|
icculus@31
|
1957 |
event12.jbutton.button = event20->jbutton.button;
|
icculus@31
|
1958 |
event12.jbutton.state = event20->jbutton.state;
|
icculus@18
|
1959 |
break;
|
icculus@18
|
1960 |
|
icculus@18
|
1961 |
case SDL_JOYBUTTONUP:
|
icculus@31
|
1962 |
event12.type = SDL12_JOYBUTTONUP;
|
icculus@31
|
1963 |
event12.jbutton.which = (Uint8) event20->jbutton.which;
|
icculus@31
|
1964 |
event12.jbutton.button = event20->jbutton.button;
|
icculus@31
|
1965 |
event12.jbutton.state = event20->jbutton.state;
|
icculus@18
|
1966 |
break;
|
icculus@18
|
1967 |
|
icculus@18
|
1968 |
//case SDL_JOYDEVICEADDED:
|
icculus@18
|
1969 |
//case SDL_JOYDEVICEREMOVED:
|
icculus@18
|
1970 |
//case SDL_CONTROLLERAXISMOTION:
|
icculus@18
|
1971 |
//case SDL_CONTROLLERBUTTONDOWN:
|
icculus@18
|
1972 |
//case SDL_CONTROLLERBUTTONUP:
|
icculus@18
|
1973 |
//case SDL_CONTROLLERDEVICEADDED:
|
icculus@18
|
1974 |
//case SDL_CONTROLLERDEVICEREMOVED:
|
icculus@18
|
1975 |
//case SDL_CONTROLLERDEVICEREMAPPED:
|
icculus@18
|
1976 |
//case SDL_FINGERDOWN:
|
icculus@18
|
1977 |
//case SDL_FINGERUP:
|
icculus@18
|
1978 |
//case SDL_FINGERMOTION:
|
icculus@18
|
1979 |
//case SDL_DOLLARGESTURE:
|
icculus@18
|
1980 |
//case SDL_DOLLARRECORD:
|
icculus@18
|
1981 |
//case SDL_MULTIGESTURE:
|
icculus@18
|
1982 |
//case SDL_CLIPBOARDUPDATE:
|
icculus@18
|
1983 |
//case SDL_DROPFILE:
|
icculus@18
|
1984 |
|
icculus@18
|
1985 |
default:
|
icculus@18
|
1986 |
return 0; /* drop everything else. */
|
icculus@18
|
1987 |
}
|
icculus@18
|
1988 |
|
icculus@32
|
1989 |
PushEventIfNotFiltered(&event12);
|
icculus@18
|
1990 |
|
icculus@18
|
1991 |
return 0; /* always drop it from the 2.0 event queue. */
|
icculus@18
|
1992 |
}
|
icculus@18
|
1993 |
|
icculus@35
|
1994 |
DECLSPEC void SDLCALL
|
icculus@18
|
1995 |
SDL_SetEventFilter(SDL12_EventFilter filter12)
|
icculus@18
|
1996 |
{
|
icculus@18
|
1997 |
/* We always have a filter installed, but will call the app's too. */
|
icculus@18
|
1998 |
EventFilter12 = filter12;
|
icculus@18
|
1999 |
}
|
icculus@18
|
2000 |
|
icculus@35
|
2001 |
DECLSPEC SDL12_EventFilter SDLCALL
|
icculus@18
|
2002 |
SDL_GetEventFilter(void)
|
icculus@18
|
2003 |
{
|
icculus@18
|
2004 |
return EventFilter12;
|
icculus@18
|
2005 |
}
|
icculus@18
|
2006 |
|
icculus@15
|
2007 |
|
icculus@73
|
2008 |
static SDL12_Rect *
|
icculus@73
|
2009 |
Rect20to12(const SDL_Rect *rect20, SDL12_Rect *rect12)
|
icculus@73
|
2010 |
{
|
icculus@73
|
2011 |
rect12->x = (Sint16) rect20->x;
|
icculus@73
|
2012 |
rect12->y = (Sint16) rect20->y;
|
icculus@73
|
2013 |
rect12->w = (Uint16) rect20->w;
|
icculus@73
|
2014 |
rect12->h = (Uint16) rect20->h;
|
icculus@73
|
2015 |
return rect12;
|
icculus@73
|
2016 |
}
|
icculus@73
|
2017 |
|
icculus@73
|
2018 |
static SDL_Rect *
|
icculus@73
|
2019 |
Rect12to20(const SDL12_Rect *rect12, SDL_Rect *rect20)
|
icculus@73
|
2020 |
{
|
icculus@73
|
2021 |
rect20->x = (int) rect12->x;
|
icculus@73
|
2022 |
rect20->y = (int) rect12->y;
|
icculus@73
|
2023 |
rect20->w = (int) rect12->w;
|
icculus@73
|
2024 |
rect20->h = (int) rect12->h;
|
icculus@73
|
2025 |
return rect20;
|
icculus@73
|
2026 |
}
|
icculus@73
|
2027 |
|
icculus@34
|
2028 |
static SDL12_Surface *
|
icculus@15
|
2029 |
Surface20to12(SDL_Surface *surface20)
|
icculus@15
|
2030 |
{
|
icculus@15
|
2031 |
SDL12_Surface *surface12 = NULL;
|
icculus@15
|
2032 |
SDL12_Palette *palette12 = NULL;
|
icculus@15
|
2033 |
SDL12_PixelFormat *format12 = NULL;
|
icculus@31
|
2034 |
Uint32 flags = 0;
|
icculus@15
|
2035 |
|
icculus@15
|
2036 |
if (!surface20)
|
icculus@15
|
2037 |
return NULL;
|
icculus@15
|
2038 |
|
icculus@15
|
2039 |
surface12 = (SDL12_Surface *) SDL20_malloc(sizeof (SDL12_Surface));
|
icculus@15
|
2040 |
if (!surface12)
|
icculus@15
|
2041 |
goto failed;
|
icculus@15
|
2042 |
|
icculus@79
|
2043 |
if (surface20->format->palette) {
|
icculus@79
|
2044 |
palette12 = (SDL12_Palette *) SDL20_malloc(sizeof (SDL12_Palette));
|
icculus@79
|
2045 |
if (!palette12)
|
icculus@79
|
2046 |
goto failed;
|
icculus@79
|
2047 |
}
|
icculus@15
|
2048 |
|
icculus@15
|
2049 |
format12 = (SDL12_PixelFormat *) SDL20_malloc(sizeof (SDL12_PixelFormat));
|
icculus@15
|
2050 |
if (!format12)
|
icculus@15
|
2051 |
goto failed;
|
icculus@15
|
2052 |
|
icculus@79
|
2053 |
if (palette12) {
|
icculus@79
|
2054 |
SDL20_zerop(palette12);
|
icculus@79
|
2055 |
SDL_assert(surface20->format->palette);
|
icculus@79
|
2056 |
palette12->ncolors = surface20->format->palette->ncolors;
|
icculus@79
|
2057 |
palette12->colors = surface20->format->palette->colors;
|
icculus@79
|
2058 |
}
|
icculus@15
|
2059 |
|
icculus@34
|
2060 |
SDL20_zerop(format12);
|
icculus@15
|
2061 |
format12->palette = palette12;
|
icculus@15
|
2062 |
format12->BitsPerPixel = surface20->format->BitsPerPixel;
|
icculus@15
|
2063 |
format12->BytesPerPixel = surface20->format->BytesPerPixel;
|
icculus@15
|
2064 |
format12->Rloss = surface20->format->Rloss;
|
icculus@15
|
2065 |
format12->Gloss = surface20->format->Gloss;
|
icculus@15
|
2066 |
format12->Bloss = surface20->format->Bloss;
|
icculus@15
|
2067 |
format12->Aloss = surface20->format->Aloss;
|
icculus@15
|
2068 |
format12->Rshift = surface20->format->Rshift;
|
icculus@15
|
2069 |
format12->Gshift = surface20->format->Gshift;
|
icculus@15
|
2070 |
format12->Bshift = surface20->format->Bshift;
|
icculus@15
|
2071 |
format12->Ashift = surface20->format->Ashift;
|
icculus@15
|
2072 |
format12->Rmask = surface20->format->Rmask;
|
icculus@15
|
2073 |
format12->Gmask = surface20->format->Gmask;
|
icculus@15
|
2074 |
format12->Bmask = surface20->format->Bmask;
|
icculus@15
|
2075 |
format12->Amask = surface20->format->Amask;
|
icculus@54
|
2076 |
FIXME("format12->colorkey");
|
icculus@54
|
2077 |
FIXME("format12->alpha");
|
icculus@15
|
2078 |
|
icculus@34
|
2079 |
SDL20_zerop(surface12);
|
icculus@15
|
2080 |
flags = surface20->flags;
|
icculus@66
|
2081 |
#ifdef SDL_SIMD_ALIGNED
|
icculus@66
|
2082 |
flags &= ~SDL_SIMD_ALIGNED; /* we don't need to map this to 1.2 */
|
icculus@66
|
2083 |
#endif
|
icculus@15
|
2084 |
#define MAPSURFACEFLAGS(fl) { if (surface20->flags & SDL_##fl) { surface12->flags |= SDL12_##fl; flags &= ~SDL_##fl; } }
|
icculus@15
|
2085 |
MAPSURFACEFLAGS(PREALLOC);
|
icculus@15
|
2086 |
MAPSURFACEFLAGS(RLEACCEL);
|
icculus@34
|
2087 |
/*MAPSURFACEFLAGS(DONTFREE);*/
|
icculus@15
|
2088 |
#undef MAPSURFACEFLAGS
|
icculus@31
|
2089 |
SDL_assert(flags == 0); /* non-zero if there's a flag we didn't map. */
|
icculus@15
|
2090 |
|
icculus@15
|
2091 |
surface12->format = format12;
|
icculus@15
|
2092 |
surface12->w = surface20->w;
|
icculus@15
|
2093 |
surface12->h = surface20->h;
|
icculus@54
|
2094 |
surface12->pitch = (Uint16) surface20->pitch; FIXME("make sure this fits in a Uint16");
|
icculus@15
|
2095 |
surface12->pixels = surface20->pixels;
|
icculus@15
|
2096 |
surface12->offset = 0;
|
icculus@34
|
2097 |
surface12->surface20 = surface20;
|
icculus@73
|
2098 |
Rect20to12(&surface20->clip_rect, &surface12->clip_rect);
|
icculus@15
|
2099 |
surface12->refcount = surface20->refcount;
|
icculus@15
|
2100 |
|
icculus@15
|
2101 |
return surface12;
|
icculus@15
|
2102 |
|
icculus@15
|
2103 |
failed:
|
icculus@15
|
2104 |
SDL20_free(surface12);
|
icculus@15
|
2105 |
SDL20_free(palette12);
|
icculus@15
|
2106 |
SDL20_free(format12);
|
icculus@15
|
2107 |
return NULL;
|
icculus@15
|
2108 |
}
|
icculus@15
|
2109 |
|
icculus@35
|
2110 |
DECLSPEC SDL12_Surface * SDLCALL
|
icculus@15
|
2111 |
SDL_CreateRGBSurface(Uint32 sdl12flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
|
icculus@15
|
2112 |
{
|
icculus@15
|
2113 |
SDL_Surface *surface20 = SDL20_CreateRGBSurface(0, width, height, depth, Rmask, Gmask, Bmask, Amask);
|
icculus@15
|
2114 |
SDL12_Surface *surface12 = Surface20to12(surface20);
|
icculus@15
|
2115 |
if (!surface12) {
|
icculus@15
|
2116 |
SDL20_FreeSurface(surface20);
|
icculus@15
|
2117 |
return NULL;
|
icculus@15
|
2118 |
}
|
icculus@15
|
2119 |
|
icculus@31
|
2120 |
SDL_assert(surface12->flags == 0); // shouldn't have prealloc, rleaccel, or dontfree.
|
icculus@15
|
2121 |
return surface12;
|
icculus@15
|
2122 |
}
|
icculus@15
|
2123 |
|
icculus@35
|
2124 |
DECLSPEC SDL12_Surface * SDLCALL
|
icculus@15
|
2125 |
SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
|
icculus@15
|
2126 |
{
|
icculus@31
|
2127 |
SDL_Surface *surface20 = SDL20_CreateRGBSurfaceFrom(pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask);
|
icculus@15
|
2128 |
SDL12_Surface *surface12 = Surface20to12(surface20);
|
icculus@15
|
2129 |
if (!surface12) {
|
icculus@15
|
2130 |
SDL20_FreeSurface(surface20);
|
icculus@15
|
2131 |
return NULL;
|
icculus@15
|
2132 |
}
|
icculus@15
|
2133 |
|
icculus@31
|
2134 |
SDL_assert(surface12->flags == SDL12_PREALLOC); // should _only_ have prealloc.
|
icculus@15
|
2135 |
return surface12;
|
icculus@15
|
2136 |
}
|
icculus@15
|
2137 |
|
icculus@35
|
2138 |
DECLSPEC void SDLCALL
|
icculus@35
|
2139 |
SDL_FreeSurface(SDL12_Surface *surface12)
|
icculus@15
|
2140 |
{
|
icculus@15
|
2141 |
if (surface12) {
|
icculus@34
|
2142 |
SDL20_FreeSurface(surface12->surface20);
|
icculus@15
|
2143 |
if (surface12->format) {
|
icculus@15
|
2144 |
SDL20_free(surface12->format->palette);
|
icculus@15
|
2145 |
SDL20_free(surface12->format);
|
icculus@15
|
2146 |
}
|
icculus@15
|
2147 |
SDL20_free(surface12);
|
icculus@15
|
2148 |
}
|
icculus@15
|
2149 |
}
|
icculus@15
|
2150 |
|
icculus@35
|
2151 |
DECLSPEC void SDLCALL
|
icculus@73
|
2152 |
SDL_GetClipRect(SDL12_Surface *surface12, SDL12_Rect *rect)
|
icculus@24
|
2153 |
{
|
icculus@73
|
2154 |
if (surface12 && rect) {
|
icculus@73
|
2155 |
SDL_memcpy(rect, &surface12->clip_rect, sizeof (SDL12_Rect));
|
icculus@73
|
2156 |
}
|
icculus@24
|
2157 |
}
|
icculus@24
|
2158 |
|
icculus@35
|
2159 |
DECLSPEC SDL_bool SDLCALL
|
icculus@73
|
2160 |
SDL_SetClipRect(SDL12_Surface *surface12, const SDL12_Rect *rect12)
|
icculus@24
|
2161 |
{
|
icculus@24
|
2162 |
SDL_bool retval = SDL_FALSE;
|
icculus@24
|
2163 |
if (surface12)
|
icculus@24
|
2164 |
{
|
icculus@73
|
2165 |
SDL_Rect rect20;
|
icculus@73
|
2166 |
retval = SDL20_SetClipRect(surface12->surface20, rect12 ? Rect12to20(rect12, &rect20) : NULL);
|
icculus@73
|
2167 |
SDL20_GetClipRect(surface12->surface20, &rect20);
|
icculus@73
|
2168 |
Rect20to12(&rect20, &surface12->clip_rect);
|
icculus@24
|
2169 |
}
|
icculus@24
|
2170 |
return retval;
|
icculus@24
|
2171 |
}
|
icculus@24
|
2172 |
|
icculus@35
|
2173 |
DECLSPEC int SDLCALL
|
icculus@73
|
2174 |
SDL_FillRect(SDL12_Surface *dst, SDL12_Rect *dstrect12, Uint32 color)
|
icculus@25
|
2175 |
{
|
icculus@73
|
2176 |
SDL_Rect dstrect20;
|
icculus@73
|
2177 |
const int retval = SDL20_FillRect(dst->surface20, dstrect12 ? Rect12to20(dstrect12, &dstrect20) : NULL, color);
|
icculus@25
|
2178 |
if (retval != -1)
|
icculus@25
|
2179 |
{
|
icculus@73
|
2180 |
if (dstrect12) { /* 1.2 stores the clip intersection in dstrect */
|
icculus@73
|
2181 |
SDL_Rect intersected20;
|
icculus@73
|
2182 |
SDL20_IntersectRect(&dstrect20, &dst->surface20->clip_rect, &intersected20);
|
icculus@73
|
2183 |
Rect20to12(&intersected20, dstrect12);
|
icculus@67
|
2184 |
}
|
icculus@25
|
2185 |
}
|
icculus@25
|
2186 |
return retval;
|
icculus@25
|
2187 |
}
|
icculus@25
|
2188 |
|
icculus@25
|
2189 |
|
icculus@17
|
2190 |
static SDL_PixelFormat *
|
icculus@31
|
2191 |
PixelFormat12to20(SDL_PixelFormat *format20, SDL_Palette *palette20, const SDL12_PixelFormat *format12)
|
icculus@17
|
2192 |
{
|
icculus@81
|
2193 |
if (format12->palette) {
|
icculus@81
|
2194 |
palette20->ncolors = format12->palette->ncolors;
|
icculus@81
|
2195 |
palette20->colors = format12->palette->colors;
|
icculus@81
|
2196 |
palette20->version = 1;
|
icculus@81
|
2197 |
palette20->refcount = 1;
|
icculus@81
|
2198 |
format20->palette = palette20;
|
icculus@81
|
2199 |
} else {
|
icculus@81
|
2200 |
format20->palette = NULL;
|
icculus@81
|
2201 |
}
|
icculus@81
|
2202 |
|
icculus@34
|
2203 |
format20->format = SDL20_MasksToPixelFormatEnum(format12->BitsPerPixel, format12->Rmask, format12->Gmask, format12->Bmask, format12->Amask);
|
icculus@17
|
2204 |
format20->BitsPerPixel = format12->BitsPerPixel;
|
icculus@17
|
2205 |
format20->BytesPerPixel = format12->BytesPerPixel;
|
icculus@17
|
2206 |
format20->Rmask = format12->Rmask;
|
icculus@17
|
2207 |
format20->Gmask = format12->Gmask;
|
icculus@17
|
2208 |
format20->Bmask = format12->Bmask;
|
icculus@17
|
2209 |
format20->Amask = format12->Amask;
|
icculus@17
|
2210 |
format20->Rloss = format12->Rloss;
|
icculus@17
|
2211 |
format20->Gloss = format12->Gloss;
|
icculus@17
|
2212 |
format20->Bloss = format12->Bloss;
|
icculus@17
|
2213 |
format20->Aloss = format12->Aloss;
|
icculus@17
|
2214 |
format20->Rshift = format12->Rshift;
|
icculus@17
|
2215 |
format20->Gshift = format12->Gshift;
|
icculus@17
|
2216 |
format20->Bshift = format12->Bshift;
|
icculus@17
|
2217 |
format20->Ashift = format12->Ashift;
|
icculus@17
|
2218 |
format20->refcount = 1;
|
icculus@17
|
2219 |
format20->next = NULL;
|
icculus@17
|
2220 |
return format20;
|
icculus@17
|
2221 |
}
|
icculus@17
|
2222 |
|
icculus@35
|
2223 |
DECLSPEC Uint32 SDLCALL
|
icculus@17
|
2224 |
SDL_MapRGB(const SDL12_PixelFormat *format12, Uint8 r, Uint8 g, Uint8 b)
|
icculus@17
|
2225 |
{
|
icculus@17
|
2226 |
/* This is probably way slower than apps expect. */
|
icculus@17
|
2227 |
SDL_PixelFormat format20;
|
icculus@17
|
2228 |
SDL_Palette palette20;
|
icculus@17
|
2229 |
return SDL20_MapRGB(PixelFormat12to20(&format20, &palette20, format12), r, g, b);
|
icculus@17
|
2230 |
}
|
icculus@17
|
2231 |
|
icculus@35
|
2232 |
DECLSPEC Uint32 SDLCALL
|
icculus@17
|
2233 |
SDL_MapRGBA(const SDL12_PixelFormat *format12, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
icculus@17
|
2234 |
{
|
icculus@17
|
2235 |
/* This is probably way slower than apps expect. */
|
icculus@17
|
2236 |
SDL_PixelFormat format20;
|
icculus@17
|
2237 |
SDL_Palette palette20;
|
icculus@17
|
2238 |
return SDL20_MapRGBA(PixelFormat12to20(&format20, &palette20, format12), r, g, b, a);
|
icculus@17
|
2239 |
}
|
icculus@17
|
2240 |
|
icculus@35
|
2241 |
DECLSPEC void SDLCALL
|
icculus@17
|
2242 |
SDL_GetRGB(Uint32 pixel, const SDL12_PixelFormat *format12, Uint8 *r, Uint8 *g, Uint8 *b)
|
icculus@17
|
2243 |
{
|
icculus@17
|
2244 |
/* This is probably way slower than apps expect. */
|
icculus@17
|
2245 |
SDL_PixelFormat format20;
|
icculus@17
|
2246 |
SDL_Palette palette20;
|
icculus@17
|
2247 |
return SDL20_GetRGB(pixel, PixelFormat12to20(&format20, &palette20, format12), r, g, b);
|
icculus@17
|
2248 |
}
|
icculus@17
|
2249 |
|
icculus@35
|
2250 |
DECLSPEC void SDLCALL
|
icculus@17
|
2251 |
SDL_GetRGBA(Uint32 pixel, const SDL12_PixelFormat *format12, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
|
icculus@17
|
2252 |
{
|
icculus@17
|
2253 |
/* This is probably way slower than apps expect. */
|
icculus@17
|
2254 |
SDL_PixelFormat format20;
|
icculus@17
|
2255 |
SDL_Palette palette20;
|
icculus@31
|
2256 |
return SDL20_GetRGBA(pixel, PixelFormat12to20(&format20, &palette20, format12), r, g, b, a);
|
icculus@17
|
2257 |
}
|
icculus@15
|
2258 |
|
icculus@35
|
2259 |
DECLSPEC const SDL12_VideoInfo * SDLCALL
|
icculus@9
|
2260 |
SDL_GetVideoInfo(void)
|
icculus@9
|
2261 |
{
|
icculus@9
|
2262 |
SDL_DisplayMode mode;
|
icculus@9
|
2263 |
|
icculus@56
|
2264 |
FIXME("calculate this in Init12Video(), then this just does: return VideoInfo.vfmt ? &VideoInfo : NULL;");
|
icculus@39
|
2265 |
|
icculus@56
|
2266 |
if (!VideoInfo12.vfmt && SDL20_GetDesktopDisplayMode(VideoDisplayIndex, &mode) == 0) {
|
icculus@56
|
2267 |
VideoInfo12.vfmt = SDL20_AllocFormat(mode.format);
|
icculus@56
|
2268 |
VideoInfo12.current_w = mode.w;
|
icculus@56
|
2269 |
VideoInfo12.current_h = mode.h;
|
icculus@56
|
2270 |
FIXME("vidinfo details commented out");
|
icculus@56
|
2271 |
//VideoInfo12.wm_available = 1;
|
icculus@56
|
2272 |
//VideoInfo12.video_mem = 1024 * 256;
|
icculus@9
|
2273 |
}
|
icculus@56
|
2274 |
return &VideoInfo12;
|
icculus@9
|
2275 |
}
|
icculus@9
|
2276 |
|
icculus@35
|
2277 |
DECLSPEC int SDLCALL
|
icculus@9
|
2278 |
SDL_VideoModeOK(int width, int height, int bpp, Uint32 sdl12flags)
|
icculus@9
|
2279 |
{
|
icculus@9
|
2280 |
int i, nummodes, actual_bpp = 0;
|
icculus@9
|
2281 |
|
icculus@9
|
2282 |
if (!SDL20_WasInit(SDL_INIT_VIDEO)) {
|
icculus@9
|
2283 |
return 0;
|
icculus@9
|
2284 |
}
|
icculus@9
|
2285 |
|
icculus@9
|
2286 |
if (!(sdl12flags & SDL12_FULLSCREEN)) {
|
icculus@9
|
2287 |
SDL_DisplayMode mode;
|
icculus@16
|
2288 |
SDL20_GetDesktopDisplayMode(VideoDisplayIndex, &mode);
|
icculus@9
|
2289 |
return SDL_BITSPERPIXEL(mode.format);
|
icculus@9
|
2290 |
}
|
icculus@9
|
2291 |
|
icculus@16
|
2292 |
nummodes = SDL20_GetNumDisplayModes(VideoDisplayIndex);
|
icculus@9
|
2293 |
for (i = 0; i < nummodes; ++i) {
|
icculus@9
|
2294 |
SDL_DisplayMode mode;
|
icculus@16
|
2295 |
SDL20_GetDisplayMode(VideoDisplayIndex, i, &mode);
|
icculus@9
|
2296 |
if (!mode.w || !mode.h || (width == mode.w && height == mode.h)) {
|
icculus@9
|
2297 |
if (!mode.format) {
|
icculus@9
|
2298 |
return bpp;
|
icculus@9
|
2299 |
}
|
icculus@9
|
2300 |
if (SDL_BITSPERPIXEL(mode.format) >= (Uint32) bpp) {
|
icculus@9
|
2301 |
actual_bpp = SDL_BITSPERPIXEL(mode.format);
|
icculus@9
|
2302 |
}
|
icculus@9
|
2303 |
}
|
icculus@9
|
2304 |
}
|
icculus@9
|
2305 |
return actual_bpp;
|
icculus@9
|
2306 |
}
|
icculus@9
|
2307 |
|
icculus@73
|
2308 |
DECLSPEC SDL12_Rect ** SDLCALL
|
icculus@39
|
2309 |
SDL_ListModes(const SDL12_PixelFormat *format12, Uint32 flags)
|
icculus@9
|
2310 |
{
|
icculus@39
|
2311 |
Uint32 fmt;
|
icculus@39
|
2312 |
int i;
|
icculus@9
|
2313 |
|
icculus@9
|
2314 |
if (!SDL20_WasInit(SDL_INIT_VIDEO)) {
|
icculus@9
|
2315 |
return NULL;
|
icculus@9
|
2316 |
}
|
icculus@9
|
2317 |
|
icculus@56
|
2318 |
if ((!format12) && (!VideoInfo12.vfmt)) {
|
icculus@39
|
2319 |
SDL20_SetError("No pixel format specified");
|
icculus@39
|
2320 |
return NULL;
|
icculus@39
|
2321 |
}
|
icculus@39
|
2322 |
|
icculus@9
|
2323 |
if (!(flags & SDL12_FULLSCREEN)) {
|
icculus@73
|
2324 |
return (SDL12_Rect **) (-1); /* any resolution is fine. */
|
icculus@9
|
2325 |
}
|
icculus@9
|
2326 |
|
icculus@39
|
2327 |
if (format12) {
|
icculus@39
|
2328 |
fmt = SDL20_MasksToPixelFormatEnum(format12->BitsPerPixel, format12->Rmask, format12->Gmask, format12->Bmask, format12->Amask);
|
icculus@39
|
2329 |
} else {
|
icculus@56
|
2330 |
fmt = VideoInfo12.vfmt->format;
|
icculus@9
|
2331 |
}
|
icculus@9
|
2332 |
|
icculus@39
|
2333 |
for (i = 0; i < VideoModesCount; i++) {
|
icculus@39
|
2334 |
VideoModeList *modes = &VideoModes[i];
|
icculus@39
|
2335 |
if (modes->format == fmt) {
|
icculus@73
|
2336 |
return modes->modes12;
|
icculus@9
|
2337 |
}
|
icculus@9
|
2338 |
}
|
icculus@39
|
2339 |
|
icculus@39
|
2340 |
SDL20_SetError("No modes support requested pixel format");
|
icculus@39
|
2341 |
return NULL;
|
icculus@9
|
2342 |
}
|
icculus@9
|
2343 |
|
icculus@35
|
2344 |
DECLSPEC void SDLCALL
|
icculus@31
|
2345 |
SDL_FreeCursor(SDL12_Cursor *cursor12)
|
icculus@31
|
2346 |
{
|
icculus@51
|
2347 |
if (cursor12) {
|
icculus@31
|
2348 |
if (cursor12->wm_cursor)
|
icculus@31
|
2349 |
SDL20_FreeCursor(cursor12->wm_cursor);
|
icculus@31
|
2350 |
SDL20_free(cursor12->data);
|
icculus@31
|
2351 |
SDL20_free(cursor12->mask);
|
icculus@31
|
2352 |
SDL20_free(cursor12);
|
icculus@31
|
2353 |
}
|
icculus@31
|
2354 |
}
|
icculus@23
|
2355 |
|
icculus@35
|
2356 |
DECLSPEC SDL12_Cursor * SDLCALL
|
icculus@23
|
2357 |
SDL_CreateCursor(Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
|
icculus@23
|
2358 |
{
|
icculus@23
|
2359 |
const size_t datasize = h * (w / 8);
|
icculus@23
|
2360 |
SDL_Cursor *cursor20 = NULL;
|
icculus@23
|
2361 |
SDL12_Cursor *retval = NULL;
|
icculus@23
|
2362 |
|
icculus@23
|
2363 |
retval = (SDL12_Cursor *) SDL20_malloc(sizeof (SDL12_Cursor));
|
icculus@23
|
2364 |
if (!retval)
|
icculus@23
|
2365 |
goto outofmem;
|
icculus@23
|
2366 |
|
icculus@34
|
2367 |
SDL20_zerop(retval);
|
icculus@23
|
2368 |
|
icculus@23
|
2369 |
retval->data = (Uint8 *) SDL20_malloc(datasize);
|
icculus@31
|
2370 |
if (!retval->data)
|
icculus@23
|
2371 |
goto outofmem;
|
icculus@23
|
2372 |
|
icculus@23
|
2373 |
retval->mask = (Uint8 *) SDL20_malloc(datasize);
|
icculus@31
|
2374 |
if (!retval->mask)
|
icculus@23
|
2375 |
goto outofmem;
|
icculus@23
|
2376 |
|
icculus@23
|
2377 |
cursor20 = SDL20_CreateCursor(data, mask, w, h, hot_x, hot_y);
|
icculus@23
|
2378 |
if (!cursor20)
|
icculus@23
|
2379 |
goto failed;
|
icculus@23
|
2380 |
|
icculus@23
|
2381 |
retval->area.w = w;
|
icculus@23
|
2382 |
retval->area.h = h;
|
icculus@23
|
2383 |
retval->hot_x = hot_x;
|
icculus@23
|
2384 |
retval->hot_y = hot_y;
|
icculus@23
|
2385 |
retval->wm_cursor = cursor20;
|
icculus@23
|
2386 |
/* we always leave retval->save as null pointers. */
|
icculus@23
|
2387 |
|
icculus@23
|
2388 |
SDL20_memcpy(retval->data, data, datasize);
|
icculus@23
|
2389 |
SDL20_memcpy(retval->mask, mask, datasize);
|
icculus@23
|
2390 |
|
icculus@23
|
2391 |
return retval;
|
icculus@23
|
2392 |
|
icculus@23
|
2393 |
outofmem:
|
icculus@31
|
2394 |
SDL20_OutOfMemory();
|
icculus@23
|
2395 |
|
icculus@23
|
2396 |
failed:
|
icculus@23
|
2397 |
SDL_FreeCursor(retval);
|
icculus@23
|
2398 |
return NULL;
|
icculus@23
|
2399 |
}
|
icculus@23
|
2400 |
|
icculus@35
|
2401 |
DECLSPEC void SDLCALL
|
icculus@23
|
2402 |
SDL_SetCursor(SDL12_Cursor *cursor)
|
icculus@23
|
2403 |
{
|
icculus@56
|
2404 |
CurrentCursor12 = cursor;
|
icculus@23
|
2405 |
SDL20_SetCursor(cursor ? cursor->wm_cursor : NULL);
|
icculus@23
|
2406 |
}
|
icculus@23
|
2407 |
|
icculus@35
|
2408 |
DECLSPEC SDL12_Cursor * SDLCALL
|
icculus@23
|
2409 |
SDL_GetCursor(void)
|
icculus@23
|
2410 |
{
|
icculus@56
|
2411 |
return CurrentCursor12;
|
icculus@23
|
2412 |
}
|
icculus@23
|
2413 |
|
icculus@9
|
2414 |
static void
|
icculus@59
|
2415 |
GetEnvironmentWindowPosition(int *x, int *y)
|
icculus@9
|
2416 |
{
|
icculus@16
|
2417 |
int display = VideoDisplayIndex;
|
icculus@58
|
2418 |
const char *window = SDL20_getenv("SDL_VIDEO_WINDOW_POS");
|
icculus@58
|
2419 |
const char *center = SDL20_getenv("SDL_VIDEO_CENTERED");
|
icculus@9
|
2420 |
if (window) {
|
icculus@58
|
2421 |
if (SDL20_strcmp(window, "center") == 0) {
|
icculus@58
|
2422 |
center = window;
|
icculus@58
|
2423 |
} else if (SDL20_sscanf(window, "%d,%d", x, y) == 2) {
|
icculus@9
|
2424 |
return;
|
icculus@9
|
2425 |
}
|
icculus@9
|
2426 |
}
|
icculus@58
|
2427 |
|
icculus@9
|
2428 |
if (center) {
|
icculus@9
|
2429 |
*x = SDL_WINDOWPOS_CENTERED_DISPLAY(display);
|
icculus@9
|
2430 |
*y = SDL_WINDOWPOS_CENTERED_DISPLAY(display);
|
icculus@9
|
2431 |
}
|
icculus@9
|
2432 |
}
|
icculus@9
|
2433 |
|
icculus@9
|
2434 |
static void
|
icculus@49
|
2435 |
SetupScreenSaver(const int flags12)
|
icculus@9
|
2436 |
{
|
icculus@9
|
2437 |
const char *env;
|
icculus@9
|
2438 |
SDL_bool allow_screensaver;
|
icculus@9
|
2439 |
|
icculus@9
|
2440 |
/* Allow environment override of screensaver disable */
|
icculus@58
|
2441 |
env = SDL20_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
|
icculus@9
|
2442 |
if (env) {
|
icculus@34
|
2443 |
allow_screensaver = SDL20_atoi(env) ? SDL_TRUE : SDL_FALSE;
|
icculus@19
|
2444 |
} else if (flags12 & SDL12_FULLSCREEN) {
|
icculus@9
|
2445 |
allow_screensaver = SDL_FALSE;
|
icculus@9
|
2446 |
} else {
|
icculus@9
|
2447 |
allow_screensaver = SDL_TRUE;
|
icculus@9
|
2448 |
}
|
icculus@9
|
2449 |
if (allow_screensaver) {
|
icculus@17
|
2450 |
SDL20_EnableScreenSaver();
|
icculus@9
|
2451 |
} else {
|
icculus@17
|
2452 |
SDL20_DisableScreenSaver();
|
icculus@9
|
2453 |
}
|
icculus@9
|
2454 |
}
|
icculus@9
|
2455 |
|
icculus@9
|
2456 |
|
icculus@59
|
2457 |
static SDL12_Surface *
|
icculus@59
|
2458 |
EndVidModeCreate(void)
|
icculus@59
|
2459 |
{
|
icculus@59
|
2460 |
if (VideoTexture20) {
|
icculus@59
|
2461 |
SDL20_DestroyTexture(VideoTexture20);
|
icculus@59
|
2462 |
VideoTexture20 = NULL;
|
icculus@59
|
2463 |
}
|
icculus@59
|
2464 |
if (VideoRenderer20) {
|
icculus@59
|
2465 |
SDL20_DestroyRenderer(VideoRenderer20);
|
icculus@59
|
2466 |
VideoRenderer20 = NULL;
|
icculus@59
|
2467 |
}
|
icculus@59
|
2468 |
if (VideoGLContext20) {
|
icculus@59
|
2469 |
SDL20_GL_MakeCurrent(NULL, NULL);
|
icculus@59
|
2470 |
SDL20_GL_DeleteContext(VideoGLContext20);
|
icculus@59
|
2471 |
VideoGLContext20 = NULL;
|
icculus@59
|
2472 |
}
|
icculus@59
|
2473 |
if (VideoWindow20) {
|
icculus@59
|
2474 |
SDL20_DestroyWindow(VideoWindow20);
|
icculus@59
|
2475 |
VideoWindow20 = NULL;
|
icculus@59
|
2476 |
}
|
icculus@59
|
2477 |
if (VideoSurface12) {
|
icculus@59
|
2478 |
SDL20_free(VideoSurface12->pixels);
|
icculus@59
|
2479 |
VideoSurface12->pixels = NULL;
|
icculus@59
|
2480 |
SDL_FreeSurface(VideoSurface12);
|
icculus@59
|
2481 |
VideoSurface12 = NULL;
|
icculus@59
|
2482 |
}
|
icculus@59
|
2483 |
if (VideoConvertSurface20) {
|
icculus@59
|
2484 |
SDL20_FreeSurface(VideoConvertSurface20);
|
icculus@59
|
2485 |
VideoConvertSurface20 = NULL;
|
icculus@59
|
2486 |
}
|
icculus@59
|
2487 |
return NULL;
|
icculus@59
|
2488 |
}
|
icculus@59
|
2489 |
|
icculus@59
|
2490 |
|
icculus@59
|
2491 |
static SDL12_Surface *
|
icculus@59
|
2492 |
CreateSurface12WithFormat(const int w, const int h, const Uint32 fmt)
|
icculus@59
|
2493 |
{
|
icculus@59
|
2494 |
Uint32 rmask, gmask, bmask, amask;
|
icculus@59
|
2495 |
int bpp;
|
icculus@59
|
2496 |
if (!SDL20_PixelFormatEnumToMasks(fmt, &bpp, &rmask, &gmask, &bmask, &amask)) {
|
icculus@59
|
2497 |
return NULL;
|
icculus@59
|
2498 |
}
|
icculus@59
|
2499 |
return SDL_CreateRGBSurface(0, w, h, bpp, rmask, gmask, bmask, amask);
|
icculus@59
|
2500 |
}
|
icculus@59
|
2501 |
|
icculus@59
|
2502 |
static SDL_Surface *
|
icculus@59
|
2503 |
CreateNullPixelSurface20(const int width, const int height, const Uint32 fmt)
|
icculus@59
|
2504 |
{
|
icculus@59
|
2505 |
SDL_Surface *surface20 = SDL20_CreateRGBSurfaceWithFormat(0, 0, 0, SDL_BITSPERPIXEL(fmt), fmt);
|
icculus@59
|
2506 |
if (surface20) {
|
icculus@59
|
2507 |
surface20->flags |= SDL_PREALLOC;
|
icculus@59
|
2508 |
surface20->pixels = NULL;
|
icculus@59
|
2509 |
surface20->w = width;
|
icculus@59
|
2510 |
surface20->h = height;
|
icculus@59
|
2511 |
surface20->pitch = 0;
|
icculus@59
|
2512 |
SDL20_SetClipRect(surface20, NULL);
|
icculus@59
|
2513 |
}
|
icculus@59
|
2514 |
return surface20;
|
icculus@59
|
2515 |
}
|
icculus@59
|
2516 |
|
icculus@59
|
2517 |
|
icculus@35
|
2518 |
DECLSPEC SDL12_Surface * SDLCALL
|
icculus@19
|
2519 |
SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags12)
|
icculus@9
|
2520 |
{
|
icculus@59
|
2521 |
FIXME("currently ignores SDL_WINDOWID, which we could use with SDL_CreateWindowFrom ...?");
|
icculus@59
|
2522 |
SDL_DisplayMode dmode;
|
icculus@59
|
2523 |
Uint32 fullscreen_flags20 = 0;
|
icculus@59
|
2524 |
Uint32 appfmt;
|
icculus@59
|
2525 |
|
icculus@59
|
2526 |
/* SDL_SetVideoMode() implicitly inits if necessary. */
|
icculus@59
|
2527 |
if (SDL20_WasInit(SDL_INIT_VIDEO) == 0) {
|
icculus@59
|
2528 |
if (SDL20_Init(SDL_INIT_VIDEO) < 0) {
|
icculus@59
|
2529 |
return NULL;
|
icculus@59
|
2530 |
}
|
icculus@59
|
2531 |
}
|
icculus@59
|
2532 |
|
icculus@59
|
2533 |
if ((flags12 & SDL12_OPENGLBLIT) == SDL12_OPENGLBLIT) {
|
icculus@59
|
2534 |
FIXME("No OPENGLBLIT support at the moment");
|
icculus@59
|
2535 |
SDL20_SetError("SDL_OPENGLBLIT is (currently) unsupported");
|
icculus@59
|
2536 |
return NULL;
|
icculus@59
|
2537 |
}
|
icculus@59
|
2538 |
|
icculus@59
|
2539 |
FIXME("handle SDL_ANYFORMAT");
|
icculus@59
|
2540 |
|
icculus@59
|
2541 |
if ((width < 0) || (height < 0)) {
|
icculus@59
|
2542 |
SDL20_SetError("Invalid width or height");
|
icculus@59
|
2543 |
return NULL;
|
icculus@59
|
2544 |
}
|
icculus@59
|
2545 |
|
icculus@59
|
2546 |
FIXME("There's an environment variable to choose a display");
|
icculus@59
|
2547 |
if (SDL20_GetCurrentDisplayMode(0, &dmode) < 0) {
|
icculus@59
|
2548 |
return NULL;
|
icculus@59
|
2549 |
}
|
icculus@59
|
2550 |
|
icculus@59
|
2551 |
if (width == 0) {
|
icculus@59
|
2552 |
width = dmode.w;
|
icculus@59
|
2553 |
}
|
icculus@59
|
2554 |
|
icculus@59
|
2555 |
if (height == 0) {
|
icculus@59
|
2556 |
height = dmode.h;
|
icculus@59
|
2557 |
}
|
icculus@59
|
2558 |
|
icculus@59
|
2559 |
if (bpp == 0) {
|
icculus@59
|
2560 |
bpp = SDL_BITSPERPIXEL(dmode.format);
|
icculus@59
|
2561 |
}
|
icculus@59
|
2562 |
|
icculus@59
|
2563 |
switch (bpp) {
|
icculus@59
|
2564 |
case 8: appfmt = SDL_PIXELFORMAT_INDEX8; break;
|
icculus@59
|
2565 |
case 16: appfmt = SDL_PIXELFORMAT_RGB565; FIXME("bgr instead of rgb?"); break;
|
icculus@59
|
2566 |
case 24: appfmt = SDL_PIXELFORMAT_RGB24; FIXME("bgr instead of rgb?"); break;
|
icculus@59
|
2567 |
case 32: appfmt = SDL_PIXELFORMAT_ARGB8888; FIXME("bgr instead of rgb?"); break;
|
icculus@59
|
2568 |
default: SDL20_SetError("Unsupported bits-per-pixel"); return NULL;
|
icculus@59
|
2569 |
}
|
icculus@59
|
2570 |
|
icculus@59
|
2571 |
SDL_assert((VideoSurface12 != NULL) == (VideoWindow20 != NULL));
|
icculus@59
|
2572 |
|
icculus@59
|
2573 |
FIXME("don't do anything if the window's dimensions, etc haven't changed.");
|
icculus@59
|
2574 |
FIXME("we need to preserve VideoSurface12 (but not its pixels), I think...");
|
icculus@59
|
2575 |
|
icculus@59
|
2576 |
if ( VideoSurface12 && ((VideoSurface12->flags & SDL12_OPENGL) != (flags12 & SDL12_OPENGL)) ) {
|
icculus@59
|
2577 |
EndVidModeCreate(); /* rebuild the window if moving to/from a GL context */
|
icculus@59
|
2578 |
} else if ( VideoSurface12 && (VideoSurface12->surface20->format->format != appfmt)) {
|
icculus@59
|
2579 |
EndVidModeCreate(); /* rebuild the window if changing pixel format */
|
icculus@59
|
2580 |
} else if (VideoGLContext20) {
|
icculus@59
|
2581 |
/* SDL 1.2 (infuriatingly!) destroys the GL context on each resize, so we will too */
|
icculus@59
|
2582 |
SDL20_GL_MakeCurrent(NULL, NULL);
|
icculus@59
|
2583 |
SDL20_GL_DeleteContext(VideoGLContext20);
|
icculus@59
|
2584 |
VideoGLContext20 = NULL;
|
icculus@59
|
2585 |
}
|
icculus@59
|
2586 |
|
icculus@59
|
2587 |
if (flags12 & SDL12_FULLSCREEN) {
|
icculus@59
|
2588 |
// OpenGL tries to force the real resolution requested, but for
|
icculus@59
|
2589 |
// software rendering, we're just going to push it off onto the
|
icculus@59
|
2590 |
// GPU, so use FULLSCREEN_DESKTOP and logical scaling there.
|
icculus@59
|
2591 |
FIXME("OpenGL will still expect letterboxing and centering if it didn't get an exact resolution match.");
|
icculus@59
|
2592 |
if (flags12 & SDL12_OPENGL) {
|
icculus@59
|
2593 |
fullscreen_flags20 |= SDL_WINDOW_FULLSCREEN;
|
icculus@59
|
2594 |
} else {
|
icculus@59
|
2595 |
fullscreen_flags20 |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
icculus@59
|
2596 |
}
|
icculus@59
|
2597 |
}
|
icculus@59
|
2598 |
|
icculus@59
|
2599 |
if (!VideoWindow20) { /* create it */
|
icculus@59
|
2600 |
int x = SDL_WINDOWPOS_UNDEFINED, y = SDL_WINDOWPOS_UNDEFINED;
|
icculus@59
|
2601 |
Uint32 flags20 = fullscreen_flags20;
|
icculus@59
|
2602 |
if (flags12 & SDL12_OPENGL) { flags20 |= SDL_WINDOW_OPENGL; }
|
icculus@59
|
2603 |
if (flags12 & SDL12_RESIZABLE) { flags20 |= SDL_WINDOW_RESIZABLE; }
|
icculus@59
|
2604 |
if (flags12 & SDL12_NOFRAME) { flags20 |= SDL_WINDOW_BORDERLESS; }
|
icculus@59
|
2605 |
|
icculus@59
|
2606 |
/* most platforms didn't check these environment variables, but the major
|
icculus@59
|
2607 |
ones did (x11, windib, quartz), so we'll just offer it everywhere. */
|
icculus@59
|
2608 |
GetEnvironmentWindowPosition(&x, &y);
|
icculus@59
|
2609 |
|
icculus@59
|
2610 |
VideoWindow20 = SDL20_CreateWindow(WindowTitle, x, y, width, height, flags20);
|
icculus@59
|
2611 |
if (!VideoWindow20) {
|
icculus@59
|
2612 |
return EndVidModeCreate();
|
icculus@59
|
2613 |
}
|
icculus@59
|
2614 |
} else { /* resize it */
|
icculus@59
|
2615 |
SDL20_SetWindowSize(VideoWindow20, width, height);
|
icculus@59
|
2616 |
SDL20_SetWindowFullscreen(VideoWindow20, fullscreen_flags20);
|
icculus@59
|
2617 |
SDL20_SetWindowBordered(VideoWindow20, (flags12 & SDL12_NOFRAME) ? SDL_FALSE : SDL_TRUE);
|
icculus@59
|
2618 |
SDL20_SetWindowResizable(VideoWindow20, (flags12 & SDL12_RESIZABLE) ? SDL_TRUE : SDL_FALSE);
|
icculus@59
|
2619 |
}
|
icculus@59
|
2620 |
|
icculus@59
|
2621 |
if (VideoSurface12) {
|
icculus@59
|
2622 |
SDL20_free(VideoSurface12->pixels);
|
icculus@59
|
2623 |
} else {
|
icculus@59
|
2624 |
VideoSurface12 = CreateSurface12WithFormat(0, 0, appfmt);
|
icculus@59
|
2625 |
if (!VideoSurface12) {
|
icculus@59
|
2626 |
return EndVidModeCreate();
|
icculus@59
|
2627 |
}
|
icculus@59
|
2628 |
}
|
icculus@59
|
2629 |
|
icculus@59
|
2630 |
VideoSurface12->surface20->flags |= SDL_PREALLOC;
|
icculus@59
|
2631 |
VideoSurface12->flags |= SDL12_PREALLOC;
|
icculus@59
|
2632 |
VideoSurface12->pixels = VideoSurface12->surface20->pixels = NULL;
|
icculus@59
|
2633 |
VideoSurface12->w = VideoSurface12->surface20->w = width;
|
icculus@59
|
2634 |
VideoSurface12->h = VideoSurface12->surface20->h = height;
|
icculus@59
|
2635 |
VideoSurface12->pitch = VideoSurface12->surface20->pitch = width * SDL_BYTESPERPIXEL(appfmt);
|
icculus@59
|
2636 |
SDL_SetClipRect(VideoSurface12, NULL);
|
icculus@59
|
2637 |
|
icculus@59
|
2638 |
if (flags12 & SDL12_OPENGL) {
|
icculus@59
|
2639 |
SDL_assert(!VideoTexture20); /* either a new window or we destroyed all this */
|
icculus@59
|
2640 |
SDL_assert(!VideoRenderer20);
|
icculus@59
|
2641 |
VideoGLContext20 = SDL20_GL_CreateContext(VideoWindow20);
|
icculus@59
|
2642 |
if (!VideoGLContext20) {
|
icculus@59
|
2643 |
return EndVidModeCreate();
|
icculus@59
|
2644 |
}
|
icculus@59
|
2645 |
|
icculus@59
|
2646 |
VideoSurface12->flags |= SDL12_OPENGL;
|
icculus@59
|
2647 |
} else {
|
icculus@59
|
2648 |
/* always use a renderer for non-OpenGL windows. */
|
icculus@59
|
2649 |
SDL_RendererInfo rinfo;
|
icculus@59
|
2650 |
SDL_assert(!VideoGLContext20); /* either a new window or we destroyed all this */
|
icculus@59
|
2651 |
if (!VideoRenderer20) {
|
icculus@68
|
2652 |
VideoRenderer20 = SDL20_CreateRenderer(VideoWindow20, -1, SDL_RENDERER_ACCELERATED|SDL_RENDERER_PRESENTVSYNC);
|
icculus@68
|
2653 |
}
|
icculus@68
|
2654 |
if (!VideoRenderer20) {
|
icculus@68
|
2655 |
VideoRenderer20 = SDL20_CreateRenderer(VideoWindow20, -1, SDL_RENDERER_PRESENTVSYNC);
|
icculus@68
|
2656 |
}
|
icculus@68
|
2657 |
if (!VideoRenderer20) {
|
icculus@59
|
2658 |
VideoRenderer20 = SDL20_CreateRenderer(VideoWindow20, -1, 0);
|
icculus@68
|
2659 |
}
|
icculus@68
|
2660 |
if (!VideoRenderer20) {
|
icculus@68
|
2661 |
return EndVidModeCreate();
|
icculus@59
|
2662 |
}
|
icculus@59
|
2663 |
|
icculus@59
|
2664 |
SDL20_RenderSetLogicalSize(VideoRenderer20, width, height);
|
icculus@59
|
2665 |
SDL20_SetRenderDrawColor(VideoRenderer20, 0, 0, 0, 255);
|
icculus@59
|
2666 |
SDL20_RenderClear(VideoRenderer20);
|
icculus@59
|
2667 |
SDL20_RenderPresent(VideoRenderer20);
|
icculus@59
|
2668 |
SDL20_SetRenderDrawColor(VideoRenderer20, 255, 255, 255, 255);
|
icculus@59
|
2669 |
|
icculus@59
|
2670 |
if (SDL20_GetRendererInfo(VideoRenderer20, &rinfo) < 0) {
|
icculus@59
|
2671 |
return EndVidModeCreate();
|
icculus@59
|
2672 |
}
|
icculus@59
|
2673 |
|
icculus@59
|
2674 |
if (VideoTexture20) {
|
icculus@59
|
2675 |
SDL20_DestroyTexture(VideoTexture20);
|
icculus@59
|
2676 |
}
|
icculus@59
|
2677 |
|
icculus@59
|
2678 |
if (VideoConvertSurface20) {
|
icculus@59
|
2679 |
SDL20_FreeSurface(VideoConvertSurface20);
|
icculus@59
|
2680 |
VideoConvertSurface20 = NULL;
|
icculus@59
|
2681 |
}
|
icculus@59
|
2682 |
|
icculus@59
|
2683 |
VideoTexture20 = SDL20_CreateTexture(VideoRenderer20, rinfo.texture_formats[0], SDL_TEXTUREACCESS_STREAMING, width, height);
|
icculus@59
|
2684 |
if (!VideoTexture20) {
|
icculus@59
|
2685 |
return EndVidModeCreate();
|
icculus@59
|
2686 |
}
|
icculus@59
|
2687 |
|
icculus@59
|
2688 |
if (rinfo.texture_formats[0] != appfmt) {
|
icculus@59
|
2689 |
/* need to convert between app's format and texture format */
|
icculus@59
|
2690 |
VideoConvertSurface20 = CreateNullPixelSurface20(width, height, rinfo.texture_formats[0]);
|
icculus@59
|
2691 |
if (!VideoConvertSurface20) {
|
icculus@59
|
2692 |
return EndVidModeCreate();
|
icculus@59
|
2693 |
}
|
icculus@59
|
2694 |
}
|
icculus@59
|
2695 |
|
icculus@59
|
2696 |
VideoSurface12->flags &= ~SDL12_OPENGL;
|
icculus@71
|
2697 |
VideoSurface12->flags |= SDL12_DOUBLEBUF;
|
icculus@59
|
2698 |
VideoSurface12->surface20->pixels = SDL20_malloc(height * VideoSurface12->pitch);
|
icculus@59
|
2699 |
VideoSurface12->pixels = VideoSurface12->surface20->pixels;
|
icculus@59
|
2700 |
if (!VideoSurface12->pixels) {
|
icculus@59
|
2701 |
SDL20_OutOfMemory();
|
icculus@59
|
2702 |
return EndVidModeCreate();
|
icculus@59
|
2703 |
}
|
icculus@69
|
2704 |
|
icculus@69
|
|