|
|
|
@ -413,17 +413,22 @@ DFhackCExport uint8_t * SDL_GetKeyState(int* numkeys)
|
|
|
|
|
return _SDL_GetKeyState(numkeys);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int (*_SDL_PollEvent)(SDL::Event *) = 0;
|
|
|
|
|
// called by DF to check input events
|
|
|
|
|
static int (*_SDL_PollEvent)(SDL::Event* event) = 0;
|
|
|
|
|
DFhackCExport int SDL_PollEvent(SDL::Event* event)
|
|
|
|
|
{
|
|
|
|
|
pollevent_again:
|
|
|
|
|
// if SDL returns 0 here, it means there are no more events. return 0
|
|
|
|
|
int orig_return = _SDL_PollEvent(event);
|
|
|
|
|
// only send events to Core after we get first SDL_NumJoysticks call
|
|
|
|
|
// DF event loop is possibly polling for SDL events before things get inited properly
|
|
|
|
|
// SDL handles it. We don't, because we use some other parts of SDL too.
|
|
|
|
|
if(event != 0)
|
|
|
|
|
if(!orig_return)
|
|
|
|
|
return 0;
|
|
|
|
|
// otherwise we have an event to filter
|
|
|
|
|
else if( event != 0 )
|
|
|
|
|
{
|
|
|
|
|
DFHack::Core & c = DFHack::Core::getInstance();
|
|
|
|
|
return c.SDL_Event(event, orig_return);
|
|
|
|
|
// if we consume the event, ask SDL for more.
|
|
|
|
|
if(!c.SDL_Event(event))
|
|
|
|
|
goto pollevent_again;
|
|
|
|
|
}
|
|
|
|
|
return orig_return;
|
|
|
|
|
}
|
|
|
|
|