2 * sdl.hidd - SDL graphics/sound/keyboard for AROS hosted
3 * Copyright (c) 2007 Robert Norris. All rights reserved.
4 * Copyright (c) 2007-2011 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/kernel.h>
11 #include <aros/symbolsets.h>
12 #include <exec/semaphores.h>
14 #include <proto/bootloader.h>
15 #include <proto/exec.h>
16 #include <proto/hostlib.h>
17 #include <proto/kernel.h>
19 #include "sdl_intern.h"
22 #include <aros/debug.h>
24 struct sdl_funcs sdl_funcs
;
26 static const char *sdl_func_names
[] = {
28 "SDL_VideoDriverName",
29 "SDL_GetVideoSurface",
35 "SDL_CreateRGBSurface",
36 "SDL_CreateRGBSurfaceFrom",
55 static void *sdl_hostlib_load_so(const char *sofile
, const char **names
, void **funcptr
) {
60 D(bug("[sdl] loading functions from %s\n", sofile
));
62 if ((handle
= HostLib_Open(sofile
, &err
)) == NULL
) {
63 kprintf("[sdl] couldn't open '%s': %s\n", sofile
, err
);
67 for (i
= 0; names
[i
]; i
++) {
68 funcptr
[i
] = HostLib_GetPointer(handle
, names
[i
], &err
);
70 kprintf("[sdl] couldn't get symbol '%s' from '%s': %s\n", names
[i
], sofile
, err
);
71 HostLib_FreeErrorStr(err
);
72 HostLib_Close(handle
, NULL
);
77 D(bug("[sdl] done\n"));
82 int sdl_hostlib_init(LIBBASETYPEPTR LIBBASE
)
84 STRPTR LibraryFile
= SDL_SOFILE
;
88 D(bug("[sdl] hostlib init\n"));
90 if ((HostLibBase
= OpenResource("hostlib.resource")) == NULL
) {
91 kprintf("[sdl] couldn't open hostlib.resource\n");
95 KernelBase
= OpenResource("kernel.resource");
99 arch
= (const char *)KrnGetSystemAttr(KATTR_Architecture
);
100 D(bug("[sdl] Host operating system: %s\n", arch
));
102 if (!strcmp(arch
, "mingw32-i386"))
103 LibraryFile
= SDL_DLLFILE
;
105 if ((LIBBASE
->sdl_handle
= sdl_hostlib_load_so(LibraryFile
, sdl_func_names
, (void **) &sdl_funcs
)) == NULL
)
111 int sdl_hostlib_expunge(LIBBASETYPEPTR LIBBASE
) {
112 D(bug("[sdl] hostlib expunge\n"));
114 if (LIBBASE
->sdl_handle
!= NULL
)
115 HostLib_Close(LIBBASE
->sdl_handle
, NULL
);