make sdl.hidd build against recent iconv-aware sdls
[tangerine.git] / arch / all-hosted / hidd / sdl / sdl_hostlib.h
blob0b2d9272454639a38e7f7781d25c013daccc9e02
1 /*
2 * sdl.hidd - SDL graphics/sound/keyboard for AROS hosted
3 * Copyright (c) 2007 Robert Norris. All rights reserved.
4 * Copyright (c) 2007-2009 The AROS Development Team
6 * This program is free software; you can redistribute it and/or modify it
7 * under the same terms as AROS itself.
8 */
10 #define timeval sys_timeval
11 #include "SDL_platform.h"
12 #include "SDL_config.h"
13 #undef HAVE_CTYPE_H
14 #undef HAVE_ICONV_H
15 #undef HAVE_ICONV
16 #include "SDL.h"
17 #undef timeval
19 #include <exec/semaphores.h>
21 struct sdl_funcs {
22 void (*SDL_SetError) (const char *fmt, ...);
23 char * (*SDL_GetError) (void);
24 void (*SDL_ClearError) (void);
25 void (*SDL_Error) (SDL_errorcode code);
26 SDL_mutex * (*SDL_CreateMutex) (void);
27 int (*SDL_mutexP) (SDL_mutex *mutex);
28 int (*SDL_mutexV) (SDL_mutex *mutex);
29 void (*SDL_DestroyMutex) (SDL_mutex *mutex);
30 SDL_sem * (*SDL_CreateSemaphore) (Uint32 initial_value);
31 void (*SDL_DestroySemaphore) (SDL_sem *sem);
32 int (*SDL_SemWait) (SDL_sem *sem);
33 int (*SDL_SemTryWait) (SDL_sem *sem);
34 int (*SDL_SemWaitTimeout) (SDL_sem *sem, Uint32 ms);
35 int (*SDL_SemPost) (SDL_sem *sem);
36 Uint32 (*SDL_SemValue) (SDL_sem *sem);
37 SDL_cond * (*SDL_CreateCond) (void);
38 void (*SDL_DestroyCond) (SDL_cond *cond);
39 int (*SDL_CondSignal) (SDL_cond *cond);
40 int (*SDL_CondBroadcast) (SDL_cond *cond);
41 int (*SDL_CondWait) (SDL_cond *cond, SDL_mutex *mut);
42 int (*SDL_CondWaitTimeout) (SDL_cond *cond, SDL_mutex *mutex, Uint32 ms);
43 SDL_Thread * (*SDL_CreateThread) (int ( *fn)(void *), void *data);
44 Uint32 (*SDL_ThreadID) (void);
45 Uint32 (*SDL_GetThreadID) (SDL_Thread *thread);
46 void (*SDL_WaitThread) (SDL_Thread *thread, int *status);
47 void (*SDL_KillThread) (SDL_Thread *thread);
48 SDL_RWops * (*SDL_RWFromFile) (const char *file, const char *mode);
49 SDL_RWops * (*SDL_RWFromFP) (FILE *fp, int autoclose);
50 SDL_RWops * (*SDL_RWFromMem) (void *mem, int size);
51 SDL_RWops * (*SDL_RWFromConstMem) (const void *mem, int size);
52 SDL_RWops * (*SDL_AllocRW) (void);
53 void (*SDL_FreeRW) (SDL_RWops *area);
54 Uint16 (*SDL_ReadLE16) (SDL_RWops *src);
55 Uint16 (*SDL_ReadBE16) (SDL_RWops *src);
56 Uint32 (*SDL_ReadLE32) (SDL_RWops *src);
57 Uint32 (*SDL_ReadBE32) (SDL_RWops *src);
58 Uint64 (*SDL_ReadLE64) (SDL_RWops *src);
59 Uint64 (*SDL_ReadBE64) (SDL_RWops *src);
60 int (*SDL_WriteLE16) (SDL_RWops *dst, Uint16 value);
61 int (*SDL_WriteBE16) (SDL_RWops *dst, Uint16 value);
62 int (*SDL_WriteLE32) (SDL_RWops *dst, Uint32 value);
63 int (*SDL_WriteBE32) (SDL_RWops *dst, Uint32 value);
64 int (*SDL_WriteLE64) (SDL_RWops *dst, Uint64 value);
65 int (*SDL_WriteBE64) (SDL_RWops *dst, Uint64 value);
66 int (*SDL_AudioInit) (const char *driver_name);
67 void (*SDL_AudioQuit) (void);
68 char * (*SDL_AudioDriverName) (char *namebuf, int maxlen);
69 int (*SDL_OpenAudio) (SDL_AudioSpec *desired, SDL_AudioSpec *obtained);
70 SDL_audiostatus (*SDL_GetAudioStatus) (void);
71 void (*SDL_PauseAudio) (int pause_on);
72 SDL_AudioSpec * (*SDL_LoadWAV_RW) (SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
73 void (*SDL_FreeWAV) (Uint8 *audio_buf);
74 int (*SDL_BuildAudioCVT) (SDL_AudioCVT *cvt, Uint16 src_format, Uint8 src_channels, int src_rate, Uint16 dst_format, Uint8 dst_channels, int dst_rate);
75 int (*SDL_ConvertAudio) (SDL_AudioCVT *cvt);
76 void (*SDL_MixAudio) (Uint8 *dst, const Uint8 *src, Uint32 len, int volume);
77 void (*SDL_LockAudio) (void);
78 void (*SDL_UnlockAudio) (void);
79 void (*SDL_CloseAudio) (void);
80 int (*SDL_CDNumDrives) (void);
81 const char * (*SDL_CDName) (int drive);
82 SDL_CD * (*SDL_CDOpen) (int drive);
83 CDstatus (*SDL_CDStatus) (SDL_CD *cdrom);
84 int (*SDL_CDPlayTracks) (SDL_CD *cdrom, int start_track, int start_frame, int ntracks, int nframes);
85 int (*SDL_CDPlay) (SDL_CD *cdrom, int start, int length);
86 int (*SDL_CDPause) (SDL_CD *cdrom);
87 int (*SDL_CDResume) (SDL_CD *cdrom);
88 int (*SDL_CDStop) (SDL_CD *cdrom);
89 int (*SDL_CDEject) (SDL_CD *cdrom);
90 void (*SDL_CDClose) (SDL_CD *cdrom);
91 SDL_bool (*SDL_HasRDTSC) (void);
92 SDL_bool (*SDL_HasMMX) (void);
93 SDL_bool (*SDL_HasMMXExt) (void);
94 SDL_bool (*SDL_Has3DNow) (void);
95 SDL_bool (*SDL_Has3DNowExt) (void);
96 SDL_bool (*SDL_HasSSE) (void);
97 SDL_bool (*SDL_HasSSE2) (void);
98 SDL_bool (*SDL_HasAltiVec) (void);
99 Uint8 (*SDL_GetAppState) (void);
100 int (*SDL_EnableUNICODE) (int enable);
101 int (*SDL_EnableKeyRepeat) (int delay, int interval);
102 void (*SDL_GetKeyRepeat) (int *delay, int *interval);
103 Uint8 * (*SDL_GetKeyState) (int *numkeys);
104 SDLMod (*SDL_GetModState) (void);
105 void (*SDL_SetModState) (SDLMod modstate);
106 char * (*SDL_GetKeyName) (SDLKey key);
107 int (*SDL_VideoInit) (const char *driver_name, Uint32 flags);
108 void (*SDL_VideoQuit) (void);
109 char * (*SDL_VideoDriverName) (char *namebuf, int maxlen);
110 SDL_Surface * (*SDL_GetVideoSurface) (void);
111 const SDL_VideoInfo * (*SDL_GetVideoInfo) (void);
112 int (*SDL_VideoModeOK) (int width, int height, int bpp, Uint32 flags);
113 SDL_Rect ** (*SDL_ListModes) (SDL_PixelFormat *format, Uint32 flags);
114 SDL_Surface * (*SDL_SetVideoMode) (int width, int height, int bpp, Uint32 flags);
115 void (*SDL_UpdateRects) (SDL_Surface *screen, int numrects, SDL_Rect *rects);
116 void (*SDL_UpdateRect) (SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h);
117 int (*SDL_Flip) (SDL_Surface *screen);
118 int (*SDL_SetGamma) (float red, float green, float blue);
119 int (*SDL_SetGammaRamp) (const Uint16 *red, const Uint16 *green, const Uint16 *blue);
120 int (*SDL_GetGammaRamp) (Uint16 *red, Uint16 *green, Uint16 *blue);
121 int (*SDL_SetColors) (SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors);
122 int (*SDL_SetPalette) (SDL_Surface *surface, int flags, SDL_Color *colors, int firstcolor, int ncolors);
123 Uint32 (*SDL_MapRGB) (SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b);
124 Uint32 (*SDL_MapRGBA) (SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
125 void (*SDL_GetRGB) (Uint32 pixel, SDL_PixelFormat *fmt, Uint8 *r, Uint8 *g, Uint8 *b);
126 void (*SDL_GetRGBA) (Uint32 pixel, SDL_PixelFormat *fmt, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
127 SDL_Surface * (*SDL_CreateRGBSurface) (Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
128 SDL_Surface * (*SDL_CreateRGBSurfaceFrom) (void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
129 void (*SDL_FreeSurface) (SDL_Surface *surface);
130 int (*SDL_LockSurface) (SDL_Surface *surface);
131 void (*SDL_UnlockSurface) (SDL_Surface *surface);
132 SDL_Surface * (*SDL_LoadBMP_RW) (SDL_RWops *src, int freesrc);
133 int (*SDL_SaveBMP_RW) (SDL_Surface *surface, SDL_RWops *dst, int freedst);
134 int (*SDL_SetColorKey) (SDL_Surface *surface, Uint32 flag, Uint32 key);
135 int (*SDL_SetAlpha) (SDL_Surface *surface, Uint32 flag, Uint8 alpha);
136 SDL_bool (*SDL_SetClipRect) (SDL_Surface *surface, const SDL_Rect *rect);
137 void (*SDL_GetClipRect) (SDL_Surface *surface, SDL_Rect *rect);
138 SDL_Surface * (*SDL_ConvertSurface) (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags);
139 int (*SDL_UpperBlit) (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);
140 int (*SDL_LowerBlit) (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);
141 int (*SDL_FillRect) (SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
142 SDL_Surface * (*SDL_DisplayFormat) (SDL_Surface *surface);
143 SDL_Surface * (*SDL_DisplayFormatAlpha) (SDL_Surface *surface);
144 SDL_Overlay * (*SDL_CreateYUVOverlay) (int width, int height, Uint32 format, SDL_Surface *display);
145 int (*SDL_LockYUVOverlay) (SDL_Overlay *overlay);
146 void (*SDL_UnlockYUVOverlay) (SDL_Overlay *overlay);
147 int (*SDL_DisplayYUVOverlay) (SDL_Overlay *overlay, SDL_Rect *dstrect);
148 void (*SDL_FreeYUVOverlay) (SDL_Overlay *overlay);
149 int (*SDL_GL_LoadLibrary) (const char *path);
150 void * (*SDL_GL_GetProcAddress) (const char* proc);
151 int (*SDL_GL_SetAttribute) (SDL_GLattr attr, int value);
152 int (*SDL_GL_GetAttribute) (SDL_GLattr attr, int* value);
153 void (*SDL_GL_SwapBuffers) (void);
154 void (*SDL_GL_UpdateRects) (int numrects, SDL_Rect* rects);
155 void (*SDL_GL_Lock) (void);
156 void (*SDL_GL_Unlock) (void);
157 void (*SDL_WM_SetCaption) (const char *title, const char *icon);
158 void (*SDL_WM_GetCaption) (char **title, char **icon);
159 void (*SDL_WM_SetIcon) (SDL_Surface *icon, Uint8 *mask);
160 int (*SDL_WM_IconifyWindow) (void);
161 int (*SDL_WM_ToggleFullScreen) (SDL_Surface *surface);
162 SDL_GrabMode (*SDL_WM_GrabInput) (SDL_GrabMode mode);
163 int (*SDL_SoftStretch) (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);
164 Uint8 (*SDL_GetMouseState) (int *x, int *y);
165 Uint8 (*SDL_GetRelativeMouseState) (int *x, int *y);
166 void (*SDL_WarpMouse) (Uint16 x, Uint16 y);
167 SDL_Cursor * (*SDL_CreateCursor) (Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
168 void (*SDL_SetCursor) (SDL_Cursor *cursor);
169 SDL_Cursor * (*SDL_GetCursor) (void);
170 void (*SDL_FreeCursor) (SDL_Cursor *cursor);
171 int (*SDL_ShowCursor) (int toggle);
172 int (*SDL_NumJoysticks) (void);
173 const char * (*SDL_JoystickName) (int device_index);
174 SDL_Joystick * (*SDL_JoystickOpen) (int device_index);
175 int (*SDL_JoystickOpened) (int device_index);
176 int (*SDL_JoystickIndex) (SDL_Joystick *joystick);
177 int (*SDL_JoystickNumAxes) (SDL_Joystick *joystick);
178 int (*SDL_JoystickNumBalls) (SDL_Joystick *joystick);
179 int (*SDL_JoystickNumHats) (SDL_Joystick *joystick);
180 int (*SDL_JoystickNumButtons) (SDL_Joystick *joystick);
181 void (*SDL_JoystickUpdate) (void);
182 int (*SDL_JoystickEventState) (int state);
183 Sint16 (*SDL_JoystickGetAxis) (SDL_Joystick *joystick, int axis);
184 Uint8 (*SDL_JoystickGetHat) (SDL_Joystick *joystick, int hat);
185 int (*SDL_JoystickGetBall) (SDL_Joystick *joystick, int ball, int *dx, int *dy);
186 Uint8 (*SDL_JoystickGetButton) (SDL_Joystick *joystick, int button);
187 void (*SDL_JoystickClose) (SDL_Joystick *joystick);
188 void (*SDL_PumpEvents) (void);
189 int (*SDL_PeepEvents) (SDL_Event *events, int numevents, SDL_eventaction action, Uint32 mask);
190 int (*SDL_PollEvent) (SDL_Event *event);
191 int (*SDL_WaitEvent) (SDL_Event *event);
192 int (*SDL_PushEvent) (SDL_Event *event);
193 void (*SDL_SetEventFilter) (SDL_EventFilter filter);
194 SDL_EventFilter (*SDL_GetEventFilter) (void);
195 Uint8 (*SDL_EventState) (Uint8 type, int state);
196 void * (*SDL_LoadObject) (const char *sofile);
197 void * (*SDL_LoadFunction) (void *handle, const char *name);
198 void (*SDL_UnloadObject) (void *handle);
199 Uint32 (*SDL_GetTicks) (void);
200 void (*SDL_Delay) (Uint32 ms);
201 int (*SDL_SetTimer) (Uint32 interval, SDL_TimerCallback callback);
202 SDL_TimerID (*SDL_AddTimer) (Uint32 interval, SDL_NewTimerCallback callback, void *param);
203 SDL_bool (*SDL_RemoveTimer) (SDL_TimerID t);
204 const SDL_version * (*SDL_Linked_Version) (void);
205 int (*SDL_Init) (Uint32 flags);
206 int (*SDL_InitSubSystem) (Uint32 flags);
207 void (*SDL_QuitSubSystem) (Uint32 flags);
208 Uint32 (*SDL_WasInit) (Uint32 flags);
209 void (*SDL_Quit) (void);
212 extern struct sdl_funcs sdl_funcs;
214 #define SDL_SOFILE "libSDL.so"
215 #define SDL_DLLFILE "SDL.dll"
217 #define S(name, ...) \
218 ({ \
219 Forbid(); \
220 typeof (sdl_funcs.name) __sdlret = sdl_funcs.name(__VA_ARGS__); \
221 Permit(); \
222 __sdlret; \
225 #define SV(name, ...) \
226 do { \
227 Forbid(); \
228 sdl_funcs.name(__VA_ARGS__); \
229 Permit(); \
230 } while (0)