From f1b5269d7336a1e059a2bc287b4d0808415883d5 Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Thu, 2 Jul 2020 12:51:08 -0700 Subject: [PATCH] keydown/mousedown events that get processed by imgui will no longer be processed by the engine. --- code/redalert/io/userinput.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/code/redalert/io/userinput.cpp b/code/redalert/io/userinput.cpp index 1d3ce53..60d3bf1 100644 --- a/code/redalert/io/userinput.cpp +++ b/code/redalert/io/userinput.cpp @@ -61,6 +61,16 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags) while (SDL_PollEvent(&event)) { const Uint8* state = SDL_GetKeyboardState(NULL); + if (Debug_Map || renderConsole) + { + // If Imgui has processed a KEYDOWN or MOUSEDOWN event, then we are going to ignore it. + if(ImGui_ImplSDL2_ProcessEvent(&event)) { + if(event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_KEYDOWN) { + continue; + } + } + } + switch (event.type) { case SDL_SYSWMEVENT: @@ -216,11 +226,6 @@ void UserInputClass::Process_Input(KeyNumType& key, int& flags) KeyB.ASCII = (char)event.text.text[0]; } } - - if (Debug_Map || renderConsole) - { - ImGui_ImplSDL2_ProcessEvent(&event); - } } if (!leftMouseProcessed && numFramesLMouse != 0)