diff --git a/source/gui/GUIManager.cpp b/source/gui/GUIManager.cpp index 72edb79750..8b818a2a6d 100644 --- a/source/gui/GUIManager.cpp +++ b/source/gui/GUIManager.cpp @@ -78,17 +78,11 @@ CGUIManager* g_GUI = nullptr; // multiple pages, instead of treating them as completely independent, to save // memory and loading time. - -// called from main loop when (input) events are received. -// event is passed to other handlers if false is returned. // trampoline: we don't want to make the HandleEvent implementation static -Input::Reaction gui_handler(const SDL_Event& ev) +Input::Reaction CGUIManager::InputHandler::operator()(const SDL_Event& ev) { - if (!g_GUI) - return Input::Reaction::PASS; - PROFILE("GUI event handler"); - return g_GUI->HandleEvent(ev); + return gui.HandleEvent(ev); } static Status ReloadChangedFileCB(void* param, const VfsPath& path) @@ -98,7 +92,8 @@ static Status ReloadChangedFileCB(void* param, const VfsPath& path) CGUIManager::CGUIManager(ScriptContext& scriptContext, ScriptInterface& scriptInterface) : m_ScriptContext{scriptContext}, - m_ScriptInterface{scriptInterface} + m_ScriptInterface{scriptInterface}, + m_InputHandler{g_VideoMode.m_InputManager, Input::Slot::GUI, {*this}} { m_ScriptInterface.SetCallbackData(this); m_ScriptInterface.LoadGlobalScripts(); diff --git a/source/gui/GUIManager.h b/source/gui/GUIManager.h index ecfbbb4c4b..a06903b4e2 100644 --- a/source/gui/GUIManager.h +++ b/source/gui/GUIManager.h @@ -237,10 +237,15 @@ private: PS::StaticVector GetCopyOfFrozenStack() const; CTemplateLoader m_TemplateLoader; + + struct InputHandler + { + CGUIManager& gui; + Input::Reaction operator()(const SDL_Event& ev); + }; + Input::Handler m_InputHandler; }; extern CGUIManager* g_GUI; -extern Input::Reaction gui_handler(const SDL_Event& ev); - #endif // INCLUDED_GUIMANAGER diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index a6191ad7f1..1ef5f8b770 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -264,11 +264,6 @@ static void InitPs(bool setup_gui, const CStrW& gui_page, ScriptInterface* srcSc handlers->emplace(g_VideoMode.m_InputManager, Input::Slot::HOTKEY_INPUT, HotkeyInputActualHandler); - // gui_handler needs to be registered after (i.e. called before!) the - // hotkey handler so that input boxes can be typed in without - // setting off hotkeys. - handlers->emplace(g_VideoMode.m_InputManager, Input::Slot::GUI, gui_handler); - handlers->emplace(g_VideoMode.m_InputManager, Input::Slot::TOUCH_INPUT, touch_input_handler); // Should be called after scancode map update (i.e. after the global input, but before UI).