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.
10 #include <aros/bootloader.h>
11 #include <aros/symbolsets.h>
13 #include <exec/types.h>
14 #include <exec/semaphores.h>
16 #include <proto/bootloader.h>
17 #include <proto/exec.h>
18 #include <proto/hostlib.h>
20 #include LC_LIBDEFS_FILE
22 #include "sdl_intern.h"
25 #include <aros/debug.h>
27 struct sdl_funcs sdl_funcs
;
29 static const char *sdl_func_names
[] = {
38 "SDL_CreateSemaphore",
39 "SDL_DestroySemaphore",
50 "SDL_CondWaitTimeout",
76 "SDL_AudioDriverName",
109 "SDL_EnableKeyRepeat",
117 "SDL_VideoDriverName",
118 "SDL_GetVideoSurface",
135 "SDL_CreateRGBSurface",
136 "SDL_CreateRGBSurfaceFrom",
146 "SDL_ConvertSurface",
151 "SDL_DisplayFormatAlpha",
152 "SDL_CreateYUVOverlay",
153 "SDL_LockYUVOverlay",
154 "SDL_UnlockYUVOverlay",
155 "SDL_DisplayYUVOverlay",
156 "SDL_FreeYUVOverlay",
157 "SDL_GL_LoadLibrary",
158 "SDL_GL_GetProcAddress",
159 "SDL_GL_SetAttribute",
160 "SDL_GL_GetAttribute",
161 "SDL_GL_SwapBuffers",
162 "SDL_GL_UpdateRects",
168 "SDL_WM_IconifyWindow",
169 "SDL_WM_ToggleFullScreen",
173 "SDL_GetRelativeMouseState",
183 "SDL_JoystickOpened",
185 "SDL_JoystickNumAxes",
186 "SDL_JoystickNumBalls",
187 "SDL_JoystickNumHats",
188 "SDL_JoystickNumButtons",
189 "SDL_JoystickUpdate",
190 "SDL_JoystickEventState",
191 "SDL_JoystickGetAxis",
192 "SDL_JoystickGetHat",
193 "SDL_JoystickGetBall",
194 "SDL_JoystickGetButton",
201 "SDL_SetEventFilter",
202 "SDL_GetEventFilter",
212 "SDL_Linked_Version",
223 static void *sdl_hostlib_load_so(const char *sofile
, const char **names
, void **funcptr
) {
228 D(bug("[sdl] loading functions from %s\n", sofile
));
230 if ((handle
= HostLib_Open(sofile
, &err
)) == NULL
) {
231 kprintf("[sdl] couldn't open '%s': %s\n", sofile
, err
);
235 for (i
= 0; names
[i
]; i
++) {
236 funcptr
[i
] = HostLib_GetPointer(handle
, names
[i
], &err
);
238 kprintf("[sdl] couldn't get symbol '%s' from '%s': %s\n", names
[i
], sofile
, err
);
239 HostLib_FreeErrorStr(err
);
240 HostLib_Close(handle
, NULL
);
245 D(bug("[sdl] done\n"));
250 static int sdl_hostlib_init(LIBBASETYPEPTR LIBBASE
)
252 STRPTR LibraryFile
= SDL_SOFILE
;
254 STRPTR BootLoaderName
;
256 D(bug("[sdl] hostlib init\n"));
258 if ((HostLibBase
= OpenResource("hostlib.resource")) == NULL
) {
259 kprintf("[sdl] couldn't open hostlib.resource\n");
263 BootLoaderBase
= OpenResource("bootloader.resource");
264 if (BootLoaderBase
) {
265 BootLoaderName
= GetBootInfo(BL_LoaderName
);
266 if (BootLoaderName
) {
267 D(bug("[sdl] Host operating system: %s\n", BootLoaderName
));
268 if (!strncasecmp(BootLoaderName
, "Windows", 7))
269 LibraryFile
= SDL_DLLFILE
;
273 if ((LIBBASE
->sdl_handle
= sdl_hostlib_load_so(LibraryFile
, sdl_func_names
, (void **) &sdl_funcs
)) == NULL
)
279 static int sdl_hostlib_expunge(LIBBASETYPEPTR LIBBASE
) {
280 D(bug("[sdl] hostlib expunge\n"));
282 if (LIBBASE
->sdl_handle
!= NULL
)
283 HostLib_Close(LIBBASE
->sdl_handle
, NULL
);
288 ADD2INITLIB(sdl_hostlib_init
, 0)
289 ADD2EXPUNGELIB(sdl_hostlib_expunge
, 0)