diff options
| author | Petr Mrázek | 2012-02-28 12:59:02 +0100 |
|---|---|---|
| committer | Petr Mrázek | 2012-02-28 12:59:02 +0100 |
| commit | 95ac3db54280f3a28f7d6076714aa8250c831eec (patch) | |
| tree | 9cc913f91139d3cd445ed0059671a366c61d3245 /library/Hooks-windows.cpp | |
| parent | 731472a4781f091ae313bd39d512207e920db10c (diff) | |
| download | dfhack-95ac3db54280f3a28f7d6076714aa8250c831eec.tar.gz dfhack-95ac3db54280f3a28f7d6076714aa8250c831eec.tar.bz2 dfhack-95ac3db54280f3a28f7d6076714aa8250c831eec.tar.xz | |
Fix normal hooks.
Diffstat (limited to 'library/Hooks-windows.cpp')
| -rw-r--r-- | library/Hooks-windows.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/library/Hooks-windows.cpp b/library/Hooks-windows.cpp index 920673c9..c4e0f0a3 100644 --- a/library/Hooks-windows.cpp +++ b/library/Hooks-windows.cpp @@ -413,17 +413,22 @@ DFhackCExport uint8_t * SDL_GetKeyState(int* numkeys) return _SDL_GetKeyState(numkeys); } -static int (*_SDL_PollEvent)(SDL::Event *) = 0; -DFhackCExport int SDL_PollEvent(SDL::Event * event) +// 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; } |
