Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
wsdl.h
Go to the documentation of this file.
1 /* Copyright (c) 2012 Wildfire Games
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining
4  * a copy of this software and associated documentation files (the
5  * "Software"), to deal in the Software without restriction, including
6  * without limitation the rights to use, copy, modify, merge, publish,
7  * distribute, sublicense, and/or sell copies of the Software, and to
8  * permit persons to whom the Software is furnished to do so, subject to
9  * the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
23 /*
24  * emulate SDL on Windows.
25  */
26 
27 #ifndef INCLUDED_WSDL
28 #define INCLUDED_WSDL
29 
30 #include "lib/lib_api.h"
31 #include "lib/byte_order.h"
32 #ifndef WSDL_NO_KEYSYM
33 # include "SDL_keysym.h"
34 #endif
35 
36 typedef u8 Uint8;
37 typedef u16 Uint16;
38 typedef i16 Sint16;
39 typedef u32 Uint32;
40 
41 
42 // SDL_Init flags
43 #define SDL_INIT_VIDEO 0
44 #define SDL_INIT_AUDIO 0
45 #define SDL_INIT_TIMER 0
46 #define SDL_INIT_JOYSTICK 0
47 #define SDL_INIT_NOPARACHUTE 0
48 
49 LIB_API int SDL_Init(Uint32 flags);
50 LIB_API int SDL_InitSubSystem(Uint32 flags);
51 
52 LIB_API void SDL_Quit();
53 
54 
55 //
56 // video
57 //
58 
59 typedef enum
60 {
63  SDL_GL_DOUBLEBUFFER, // ignored - always double buffered
65 }
67 
68 LIB_API int SDL_GL_SetAttribute(SDL_GLattr attr, int value);
69 
70 // SDL_SetVideoMode() flags
71 #define SDL_OPENGL 0
72 #define SDL_FULLSCREEN 1
73 #define SDL_RESIZABLE 2
74 
76 {
78 };
79 
81 {
83  int w, h;
84 };
85 
86 LIB_API SDL_Surface* SDL_SetVideoMode(int w, int h, int bpp, Uint32 flags);
87 
89 
90 typedef struct
91 {
92  Uint32 video_mem; // total amount of video memory (in K)
93 }
95 
97 
98 LIB_API void* SDL_GL_GetProcAddress(const char*);
99 
100 LIB_API void SDL_GL_SwapBuffers();
101 
102 LIB_API int SDL_SetGamma(float r, float g, float b);
103 
104 
105 //
106 // semaphores
107 //
108 
109 typedef void SDL_sem;
110 LIB_API SDL_sem* SDL_CreateSemaphore(int cnt);
111 LIB_API void SDL_DestroySemaphore(SDL_sem*);
112 LIB_API int SDL_SemPost(SDL_sem*);
113 LIB_API int SDL_SemWait(SDL_sem* sem);
114 
115 
116 //
117 // time
118 //
119 
120 LIB_API u32 SDL_GetTicks();
121 LIB_API void SDL_Delay(u32 ms);
122 
123 
124 //
125 // mouse
126 //
127 
128 LIB_API void SDL_WarpMouse(int, int);
129 
131 {
135 };
136 LIB_API int SDL_ShowCursor(int toggle);
137 
138 LIB_API Uint8 SDL_GetMouseState(int* x, int* y);
139 
140 
141 //
142 // keyboard
143 //
144 
145 // from real SDL, but they're ignored anyway
146 #define SDL_DEFAULT_REPEAT_DELAY 500
147 #define SDL_DEFAULT_REPEAT_INTERVAL 30
148 #define SDL_EnableKeyRepeat(delay, interval)
149 
150 LIB_API Uint8* SDL_GetKeyState(int* num_keys);
151 
152 
153 //
154 // joystick
155 //
156 
157 typedef void* SDL_Joystick;
158 int SDL_NumJoysticks();
160 const char* SDL_JoystickName(int device_index);
161 SDL_Joystick* SDL_JoystickOpen(int device_index);
162 int SDL_JoystickNumAxes(SDL_Joystick* joystick);
163 Sint16 SDL_JoystickGetAxis(SDL_Joystick* joystick, int axis);
164 
165 
166 //
167 // byte swapping
168 //
169 
170 #define SDL_LIL_ENDIAN 1234
171 #define SDL_BIG_ENDIAN 4321
172 
173 #define SDL_BYTEORDER SDL_LIL_ENDIAN
174 
175 #define SDL_Swap16 swap16
176 #define SDL_Swap32 swap32
177 #define SDL_Swap64 swap64
178 
179 
180 //-----------------------------------------------------------------------------
181 // events
182 //-----------------------------------------------------------------------------
183 
184 #ifndef WSDL_NO_KEYSYM
185 
186 typedef struct
187 {
188  SDLKey sym;
190 }
191 SDL_keysym;
192 
193 typedef struct
194 {
197 }
199 
200 #endif // #ifndef WSDL_NO_KEYSYM
201 
202 typedef struct
203 {
205  u16 x, y;
206 }
208 
209 typedef struct
210 {
212 }
214 
215 typedef struct
216 {
218 }
220 
222 {
223  // to remain compatible with regular SDL, these values must not change!
231 };
232 
233 #define SDL_BUTTON(b) (1u << (b-1))
234 #define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT)
235 #define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE)
236 #define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT)
237 #define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1)
238 #define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2)
239 
241 {
244 };
245 
246 typedef struct
247 {
251  u16 x, y;
252 }
254 
256 {
260 };
261 
262 typedef struct
263 {
267 }
269 
270 typedef struct
271 {
273  int w;
274  int h;
275 }
277 
278 typedef struct
279 {
281  int code;
282  void* data1;
283 }
285 
287 {
298 };
299 
300 typedef union
301 {
304 #ifndef WSDL_NO_KEYSYM
306 #endif
313 }
314 SDL_Event;
315 
316 LIB_API int SDL_EnableUNICODE(int enable);
317 LIB_API int SDL_WaitEvent(SDL_Event*);
318 LIB_API int SDL_PollEvent(SDL_Event* ev);
319 LIB_API int SDL_PushEvent(SDL_Event* ev);
320 
321 
322 //
323 // misc
324 //
325 
327 {
331 };
333 
334 #define SDL_GetError() ""
335 
336 LIB_API void SDL_WM_SetCaption(const char *title, const char *icon);
337 
338 LIB_API Uint8 SDL_GetAppState();
339 
340 // Pretend that we always implement the latest version of SDL 1.2 (but not 1.3)
341 #define SDL_VERSION_ATLEAST(X, Y, Z) ((X) == 1 && (Y) <= 2)
342 
343 #endif // #ifndef INCLUDED_WSDL
int SDL_PollEvent(SDL_Event *ev)
Definition: wsdl.cpp:1343
void SDL_sem
Definition: wsdl.h:109
#define u8
Definition: types.h:39
int SDL_JoystickNumAxes(SDL_Joystick *joystick)
Definition: wsdl.cpp:746
SDL_GrabMode
Definition: wsdl.h:326
int SDL_ShowCursor(int toggle)
Definition: wsdl.cpp:1106
Uint8 SDL_GetMouseState(int *x, int *y)
Definition: wsdl.cpp:1083
int SDL_JoystickEventState(int state)
Definition: wsdl.cpp:731
SDL_KeyboardEvent key
Definition: wsdl.h:305
void SDL_WarpMouse(int x, int y)
Definition: wsdl.cpp:1093
SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode)
Definition: wsdl.cpp:1123
void SDL_Delay(Uint32 ms)
Definition: wsdl.cpp:1457
Definition: wsdl.h:294
SDL_VideoInfo * SDL_GetVideoInfo()
Definition: wsdl.cpp:484
Uint8 type
Definition: wsdl.h:264
Uint8 BitsPerPixel
Definition: wsdl.h:77
void * SDL_GL_GetProcAddress(const char *name)
Definition: wsdl.cpp:1463
SDL_MouseButtonEvent_state
Definition: wsdl.h:240
LIB_API int SDL_WaitEvent(SDL_Event *)
void * SDL_Joystick
Definition: wsdl.h:157
Uint8 SDL_GetAppState()
Definition: wsdl.cpp:844
SDL_MouseButtonEvent_button
Definition: wsdl.h:221
SDL_ExposeEvent expose
Definition: wsdl.h:310
Uint8 type
Definition: wsdl.h:195
SDL_GLattr
Definition: wsdl.h:59
SDL_ActiveEvent_state
Definition: wsdl.h:255
void SDL_GL_SwapBuffers()
Definition: wsdl.cpp:478
int SDL_GL_SetAttribute(SDL_GLattr attr, int value)
Definition: wsdl.cpp:286
#define i16
Definition: types.h:35
ShowCursorToggle
Definition: wsdl.h:130
void SDL_Quit()
Definition: wsdl.cpp:1505
u8 Uint8
Definition: wsdl.h:36
SDL_MouseMotionEvent motion
Definition: wsdl.h:307
SDL_QuitEvent quit
Definition: wsdl.h:311
void SDL_DestroySemaphore(SDL_sem *sem)
Definition: wsdl.cpp:1420
void SDL_WM_SetCaption(const char *title, const char *icon)
Definition: wsdl.cpp:1442
Uint8 type
Definition: wsdl.h:302
SDL_MouseButtonEvent button
Definition: wsdl.h:308
SDL_ActiveEvent active
Definition: wsdl.h:303
Uint8 * SDL_GetKeyState(int *num_keys)
Definition: wsdl.cpp:708
Sint16 SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis)
Definition: wsdl.cpp:751
i16 Sint16
Definition: wsdl.h:38
Uint8 type
Definition: wsdl.h:217
int h
Definition: wsdl.h:83
Uint8 type
Definition: wsdl.h:272
SDL_PixelFormat * format
Definition: wsdl.h:82
u16 unicode
Definition: wsdl.h:189
Uint32 video_mem
Definition: wsdl.h:92
SDL_Joystick * SDL_JoystickOpen(int device_index)
Definition: wsdl.cpp:741
SDL_Surface * SDL_GetVideoSurface()
Definition: wsdl.cpp:508
Uint8 type
Definition: wsdl.h:211
int w
Definition: wsdl.h:83
int SDL_Init(Uint32 flags)
Definition: wsdl.cpp:1495
#define u16
Definition: types.h:40
int SDL_EnableUNICODE(int enable)
Definition: wsdl.cpp:717
SDL_sem * SDL_CreateSemaphore(int cnt)
Definition: wsdl.cpp:1414
const char * SDL_JoystickName(int device_index)
Definition: wsdl.cpp:736
#define u32
Definition: types.h:41
u32 Uint32
Definition: wsdl.h:39
int code
Definition: wsdl.h:281
int SDL_PushEvent(SDL_Event *ev)
Definition: wsdl.cpp:1354
int SDL_InitSubSystem(Uint32 flags)
Definition: wsdl.cpp:1500
SDL_keysym keysym
Definition: wsdl.h:196
u32 SDL_GetTicks()
Definition: wsdl.cpp:1451
SDL_UserEvent user
Definition: wsdl.h:312
int SDL_SetGamma(float r, float g, float b)
Definition: wsdl.cpp:180
Uint8 type
Definition: wsdl.h:280
int SDL_SemPost(SDL_sem *sem)
Definition: wsdl.cpp:1426
SDL_Surface * SDL_SetVideoMode(int w, int h, int bpp, Uint32 flags)
Definition: wsdl.cpp:372
SDLKey sym
Definition: wsdl.h:188
SDL_Event_type
Definition: wsdl.h:286
u16 Uint16
Definition: wsdl.h:37
int SDL_SemWait(SDL_sem *sem)
Definition: wsdl.cpp:1432
SDL_ResizeEvent resize
Definition: wsdl.h:309
static enum @41 state
void * data1
Definition: wsdl.h:282
int SDL_NumJoysticks()
Definition: wsdl.cpp:726