2 * sdl.hidd - SDL graphics/sound/keyboard for AROS hosted
3 * Copyright (c) 2007 Robert Norris. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the same terms as AROS itself.
9 #include <aros/symbolsets.h>
11 #include <exec/types.h>
12 #include <exec/semaphores.h>
14 #include <proto/exec.h>
15 #include <proto/hostlib.h>
17 #include LC_LIBDEFS_FILE
19 #include "sdl_intern.h"
22 #include <aros/debug.h>
24 void *sdl_handle
= NULL
;
26 struct sdl_funcs sdl_funcs
;
28 static const char *sdl_func_names
[] = {
48 "SDL_CreateSemaphore",
49 "SDL_DestroySemaphore",
60 "SDL_CondWaitTimeout",
86 "SDL_AudioDriverName",
119 "SDL_EnableKeyRepeat",
127 "SDL_VideoDriverName",
128 "SDL_GetVideoSurface",
145 "SDL_CreateRGBSurface",
146 "SDL_CreateRGBSurfaceFrom",
156 "SDL_ConvertSurface",
161 "SDL_DisplayFormatAlpha",
162 "SDL_CreateYUVOverlay",
163 "SDL_LockYUVOverlay",
164 "SDL_UnlockYUVOverlay",
165 "SDL_DisplayYUVOverlay",
166 "SDL_FreeYUVOverlay",
167 "SDL_GL_LoadLibrary",
168 "SDL_GL_GetProcAddress",
169 "SDL_GL_SetAttribute",
170 "SDL_GL_GetAttribute",
171 "SDL_GL_SwapBuffers",
172 "SDL_GL_UpdateRects",
178 "SDL_WM_IconifyWindow",
179 "SDL_WM_ToggleFullScreen",
183 "SDL_GetRelativeMouseState",
193 "SDL_JoystickOpened",
195 "SDL_JoystickNumAxes",
196 "SDL_JoystickNumBalls",
197 "SDL_JoystickNumHats",
198 "SDL_JoystickNumButtons",
199 "SDL_JoystickUpdate",
200 "SDL_JoystickEventState",
201 "SDL_JoystickGetAxis",
202 "SDL_JoystickGetHat",
203 "SDL_JoystickGetBall",
204 "SDL_JoystickGetButton",
211 "SDL_SetEventFilter",
212 "SDL_GetEventFilter",
222 "SDL_Linked_Version",
230 #define SDL_NUM_FUNCS (199)
234 struct SignalSemaphore sdl_lock
;
236 static void *sdl_hostlib_load_so(const char *sofile
, const char **names
, int nfuncs
, void **funcptr
) {
241 D(bug("[sdl] loading %d functions from %s\n", nfuncs
, sofile
));
243 if ((handle
= HostLib_Open(sofile
, &err
)) == NULL
) {
244 kprintf("[sdl] couldn't open '%s': %s\n", sofile
, err
);
248 for (i
= 0; i
< nfuncs
; i
++) {
249 funcptr
[i
] = HostLib_GetPointer(handle
, names
[i
], &err
);
251 kprintf("[sdl] couldn't get symbol '%s' from '%s': %s\n");
252 HostLib_Close(handle
, NULL
);
257 D(bug("[sdl] done\n"));
262 static int sdl_hostlib_init(LIBBASETYPEPTR LIBBASE
) {
263 D(bug("[sdl] hostlib init\n"));
265 InitSemaphore(&sdl_lock
);
267 if ((HostLibBase
= OpenResource("hostlib.resource")) == NULL
) {
268 kprintf("[sdl] couldn't open hostlib.resource\n");
272 if ((sdl_handle
= sdl_hostlib_load_so(SDL_SOFILE
, sdl_func_names
, SDL_NUM_FUNCS
, (void **) &sdl_funcs
)) == NULL
)
278 static int sdl_hostlib_expunge(LIBBASETYPEPTR LIBBASE
) {
279 D(bug("[sdl] hostlib expunge\n"));
281 if (sdl_handle
!= NULL
)
282 HostLib_Close(sdl_handle
, NULL
);
287 ADD2INITLIB(sdl_hostlib_init
, 0)
288 ADD2EXPUNGELIB(sdl_hostlib_expunge
, 0)