Index: sdl-game.cpp
===================================================================
--- sdl-game.cpp	(revision 8d96e95153a861c5e24ebad99d37fcd5710e8b9c)
+++ sdl-game.cpp	(revision 6053b248fd378ce997606b9b51298eab557d107c)
@@ -154,16 +154,32 @@
    done = false;
    while (!done) {
-      // Poll and handle events (inputs, window resize, etc.)
-      // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
-      // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
-      // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
-      // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
-      SDL_Event event;
-      while (SDL_PollEvent(&event)) {
-         ImGui_ImplSDL2_ProcessEvent(&event);
-         if (event.type == SDL_QUIT)
+
+      gui->processEvents();
+
+      UIEvent uiEvent;
+      while (gui->pollEvent(&uiEvent)) {
+         GameEvent& e = uiEvent.event;
+         SDL_Event sdlEvent = uiEvent.rawEvent.sdl;
+
+         ImGui_ImplSDL2_ProcessEvent(&sdlEvent);
+         if (io.WantCaptureMouse &&
+               (e.type == UI_EVENT_MOUSEBUTTONDOWN || e.type == UI_EVENT_MOUSEBUTTONUP || e.type == UI_EVENT_UNKNOWN)) {
+            if (sdlEvent.type == SDL_MOUSEWHEEL || sdlEvent.type == SDL_MOUSEBUTTONDOWN || sdlEvent.type == SDL_MOUSEBUTTONUP) {
+               continue;
+            }
+         }
+         if (io.WantCaptureKeyboard &&
+               (e.type == UI_EVENT_KEYDOWN || e.type == UI_EVENT_KEYUP)) {
+            if (sdlEvent.type == SDL_KEYDOWN || sdlEvent.type == SDL_KEYUP) {
+               continue;
+            }
+         }
+         if (io.WantTextInput) {
+            // show onscreen keyboard if on mobile
+         }
+
+         if (e.type == UI_EVENT_QUIT) {
             done = true;
-         if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window))
-            done = true;
+         }
       }
 
Index: vulkan-game.cpp
===================================================================
--- vulkan-game.cpp	(revision 8d96e95153a861c5e24ebad99d37fcd5710e8b9c)
+++ vulkan-game.cpp	(revision 6053b248fd378ce997606b9b51298eab557d107c)
@@ -781,4 +781,6 @@
    lastSpawn_asteroid = curTime;
 
+   ImGuiIO& io = ImGui::GetIO();
+
    done = false;
    while (!done) {
@@ -802,4 +804,22 @@
       while (gui->pollEvent(&uiEvent)) {
          GameEvent& e = uiEvent.event;
+         SDL_Event sdlEvent = uiEvent.rawEvent.sdl;
+
+         ImGui_ImplSDL2_ProcessEvent(&sdlEvent);
+         if (io.WantCaptureMouse &&
+               (e.type == UI_EVENT_MOUSEBUTTONDOWN || e.type == UI_EVENT_MOUSEBUTTONUP || e.type == UI_EVENT_UNKNOWN)) {
+            if (sdlEvent.type == SDL_MOUSEWHEEL || sdlEvent.type == SDL_MOUSEBUTTONDOWN || sdlEvent.type == SDL_MOUSEBUTTONUP) {
+               continue;
+            }
+         }
+         if (io.WantCaptureKeyboard &&
+               (e.type == UI_EVENT_KEYDOWN || e.type == UI_EVENT_KEYUP)) {
+            if (sdlEvent.type == SDL_KEYDOWN || sdlEvent.type == SDL_KEYUP) {
+               continue;
+            }
+         }
+         if (io.WantTextInput) {
+            // show onscreen keyboard if on mobile
+         }
 
          switch(e.type) {
