From 452eceb3ba4bdbbc77786dc7f7235c03f1c62302 Mon Sep 17 00:00:00 2001
From: chai <chaifix@163.com>
Date: Mon, 15 Nov 2021 01:19:35 +0800
Subject: *class

---
 Runtime/Events/InputEvent.cpp | 32 ++++++++++++++++++++++++++++++++
 Runtime/Events/InputEvent.h   |  5 ++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

(limited to 'Runtime')

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
diff --git a/Runtime/Events/InputEvent.h b/Runtime/Events/InputEvent.h
index d19fbea..5502aea 100644
--- a/Runtime/Events/InputEvent.h
+++ b/Runtime/Events/InputEvent.h
@@ -46,7 +46,7 @@ enum EMouseButton {
     Mouse_MiddleButton = 3
 };
 
-// �����¼�
+// �����¼����ǽű�������պʹ������¼�
 struct InputEvent : public LuaBind::INativeTable
 {
 	EInputEventType type;
@@ -66,8 +66,11 @@ struct InputEvent : public LuaBind::INativeTable
 
 	bool use;
 
+	static InputEvent RepaintEvent(HWND window);
+
     InputEvent();
     InputEvent(UINT message, WPARAM wParam, LPARAM lParam, HWND window);
+	void Init();
 
 	void CastToTable(LuaBind::State& state) const override;
     void RestoreFromTable(LuaBind::State& state, int index) override;
-- 
cgit v1.1-26-g67d0