From e4b75e355f9a28cbffb9c2b5002526d83fd67317 Mon Sep 17 00:00:00 2001 From: sheaf Date: Tue, 26 Jan 2021 12:23:05 +0100 Subject: [PATCH] Add pollEventsWithImGui (#13) --- src/DearImGui/SDL.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/DearImGui/SDL.hs b/src/DearImGui/SDL.hs index 6fb7b30..76aa126 100644 --- a/src/DearImGui/SDL.hs +++ b/src/DearImGui/SDL.hs @@ -20,6 +20,7 @@ module DearImGui.SDL ( sdl2NewFrame , sdl2Shutdown , pollEventWithImGui + , pollEventsWithImGui ) where @@ -81,3 +82,12 @@ pollEventWithImGui = liftIO do [C.exp| void { ImGui_ImplSDL2_ProcessEvent((SDL_Event*) $(void* evPtr')) } |] pollEvent + +-- | Like the SDL2 'pollEvents' function, while also dispatching the events to +-- Dear ImGui. See 'pollEventWithImGui'. +pollEventsWithImGui :: MonadIO m => m [Event] +pollEventsWithImGui = do + e <- pollEventWithImGui + case e of + Nothing -> pure [] + Just e' -> ( e' : ) <$> pollEventsWithImGui