return 1;
}
+/* this is only really needed for non-SDL targets to filter unwanted events;
+ when using SDL with properly installed event filter, this function can be
+ replaced with a simple "NextEvent()" call, but it doesn't hurt either */
+
+static boolean NextValidEvent(Event *event)
+{
+ while (PendingEvent())
+ {
+ NextEvent(event);
+
+ if (FilterMouseMotionEvents(event))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
void EventLoop(void)
{
while(1)
{
Event event;
- NextEvent(&event);
-
- if (FilterMouseMotionEvents(&event))
+ if (NextValidEvent(&event))
{
switch(event.type)
{
InitJoysticks();
InitRND(NEW_RANDOMIZE);
- InitEventFilter(FilterMouseMotionEvents);
-
InitVideoDisplay();
InitVideoBuffer(&backbuffer, &window, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH,
setup.fullscreen);
+ InitEventFilter(FilterMouseMotionEvents);
+
InitGfx();
InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */
inline void SDLInitVideoDisplay(void)
{
/* initialize SDL video */
- if (SDL_Init(SDL_INIT_VIDEO) < 0)
- Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError());
+ if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
+ Error(ERR_EXIT, "SDL_InitSubSystem() failed: %s", SDL_GetError());
/* set default SDL depth */
video.default_depth = SDL_GetVideoInfo()->vfmt->BitsPerPixel;
inline boolean SDLOpenAudio(void)
{
- if (SDL_Init(SDL_INIT_AUDIO) < 0)
+ if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
{
- Error(ERR_WARN, "SDL_Init() failed: %s", SDL_GetError());
+ Error(ERR_WARN, "SDL_InitSubSystem() failed: %s", SDL_GetError());
return FALSE;
}
#if !defined(PLATFORM_UNIX)
initErrorFile();
#endif
+
+#if defined(TARGET_SDL)
+ if (SDL_Init(SDL_INIT_EVENTTHREAD | SDL_INIT_NOPARACHUTE) < 0)
+ Error(ERR_EXIT, "SDL_Init() failed: %s", SDL_GetError());
+#endif
}
void ClosePlatformDependantStuff(void)