int SDL_StartEventLoop(Uint32 flags) { int retcode; SDL_EventThread = NULL; SDL_EventQ.lock = NULL; SDL_StopEventLoop(); SDL_EventOK = NULL; SDL_memset(SDL_ProcessEvents,SDL_ENABLE,sizeof(SDL_ProcessEvents)); SDL_eventstate = ~0; SDL_eventstate &= ~(0x00000001 << SDL_SYSWMEVENT); SDL_ProcessEvents[SDL_SYSWMEVENT] = SDL_IGNORE; retcode = 0; retcode += SDL_AppActiveInit(); retcode += SDL_KeyboardInit(); retcode += SDL_MouseInit(); retcode += SDL_QuitInit(); if ( retcode < 0 ) { return(-1); } if ( SDL_StartEventThread(flags) < 0 ) { SDL_StopEventLoop(); return(-1); } return(0); }
/* This function (and associated calls) may be called more than once */ int SDL_StartEventLoop(Uint32 flags) { int retcode; /* Clean out the event queue */ SDL_EventThread = NULL; SDL_EventQ.lock = NULL; SDL_StopEventLoop(); /* No filter to start with, process most event types */ SDL_EventOK = NULL; SDL_memset(SDL_ProcessEvents,SDL_ENABLE,sizeof(SDL_ProcessEvents)); SDL_eventstate = ~0; /* It's not save to call SDL_EventState() yet */ SDL_eventstate &= ~(0x00000001 << SDL_SYSWMEVENT); SDL_ProcessEvents[SDL_SYSWMEVENT] = SDL_IGNORE; /* Initialize event handlers */ retcode = 0; retcode += SDL_AppActiveInit(); retcode += SDL_KeyboardInit(); retcode += SDL_MouseInit(); retcode += SDL_QuitInit(); if ( retcode < 0 ) { /* We don't expect them to fail, but... */ return(-1); } /* Create the lock and event thread */ if ( SDL_StartEventThread(flags) < 0 ) { SDL_StopEventLoop(); return(-1); } return(0); }