diff --git a/src/gui/game/GameControllerEvents.h b/src/gui/game/GameControllerEvents.h index f93f24ca5..7c9905e54 100644 --- a/src/gui/game/GameControllerEvents.h +++ b/src/gui/game/GameControllerEvents.h @@ -4,16 +4,19 @@ struct TextInputEvent { + static constexpr bool simEvent = false; String text; }; struct TextEditingEvent { + static constexpr bool simEvent = false; String text; }; struct KeyEvent { + static constexpr bool simEvent = false; int key; int scan; bool repeat; @@ -24,14 +27,17 @@ struct KeyEvent struct KeyPressEvent : public KeyEvent { + static constexpr bool simEvent = false; }; struct KeyReleaseEvent : public KeyEvent { + static constexpr bool simEvent = false; }; struct MouseDownEvent { + static constexpr bool simEvent = false; int x; int y; unsigned int button; @@ -39,6 +45,7 @@ struct MouseDownEvent struct MouseUpEvent { + static constexpr bool simEvent = false; int x; int y; unsigned int button; @@ -47,6 +54,7 @@ struct MouseUpEvent struct MouseMoveEvent { + static constexpr bool simEvent = false; int x; int y; int dx; @@ -55,6 +63,7 @@ struct MouseMoveEvent struct MouseWheelEvent { + static constexpr bool simEvent = false; int x; int y; int d; @@ -62,22 +71,27 @@ struct MouseWheelEvent struct TickEvent { + static constexpr bool simEvent = false; }; struct BlurEvent { + static constexpr bool simEvent = false; }; struct CloseEvent { + static constexpr bool simEvent = false; }; struct BeforeSimEvent { + static constexpr bool simEvent = true; }; struct AfterSimEvent { + static constexpr bool simEvent = true; }; using GameControllerEvent = std::variant< diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index f3e12645b..1bc7b0730 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -4672,8 +4672,9 @@ bool LuaScriptInterface::HandleEvent(const GameControllerEvent &event) { lua_rawgeti(l, -1, i); int numArgs = PushGameControllerEvent(l, event); - auto simEvent = std::get_if(&event) || - std::get_if(&event); + auto simEvent = std::visit([](auto &event) { + return event.simEvent; + }, event); int callret = tpt_lua_pcall(l, numArgs, 1, 0, simEvent); if (callret) {