From 452eceb3ba4bdbbc77786dc7f7235c03f1c62302 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 15 Nov 2021 01:19:35 +0800 Subject: *class --- Runtime/Events/InputEvent.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'Runtime/Events/InputEvent.cpp') diff --git a/Runtime/Events/InputEvent.cpp b/Runtime/Events/InputEvent.cpp index e741511..bfa7a1e 100644 --- a/Runtime/Events/InputEvent.cpp +++ b/Runtime/Events/InputEvent.cpp @@ -320,4 +320,36 @@ void InputEvent::RestoreFromTable(LuaBind::State& state, int idx) } state.SetTop(top); +} + +void InputEvent::Init() +{ + mousePosition = Vector2f(0.0F, 0.0F); + mouseDelta = Vector2f(0.0F, 0.0F); + type = InputEvent_Ignore; + keycode = 0; + character = 0; + button = 0; + clickCount = 0; + pressure = 0; + modifiers = 0; + commandString = NULL; +} + +InputEvent InputEvent::RepaintEvent(HWND window) +{ + InputEvent evt; + evt.Init(); + evt.type = InputEvent_Repaint; + + Vector2f p = GetInputMousePosition(window); + evt.mousePosition = p; + evt.button = 0; + bool swapped = GetSystemMetrics(SM_SWAPBUTTON); + if (GetAsyncKeyState(swapped ? VK_LBUTTON : VK_RBUTTON)) + evt.button = Mouse_RightButton; + if (GetAsyncKeyState(swapped ? VK_RBUTTON : VK_LBUTTON)) + evt.button = Mouse_LeftButton; + + return evt; } \ No newline at end of file -- cgit v1.1-26-g67d0