summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XKeyboard.cs
blob: c38a20424d1fd8ea71e64e6a75f17c4b50f08c48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
using System;
using UnityEngine;
using XUpdater;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XKeyboard : XSingleton<XKeyboard>
	{
		public bool Enabled
		{
			get
			{
				return XSingleton<XUpdater.XUpdater>.singleton.EditorMode;
			}
		}

		public int touchCount
		{
			get
			{
				return this._touch_count_this_frame;
			}
		}

		private XTouchItem[] _touches = new XTouchItem[XTouch.MultiTouchCount];

		private int _touch_count_this_frame = 0;

		private bool _bAxis = false;

		private float _x = 0f;

		private float _y = 0f;

		private Vector3 _lastMousePos = Vector3.zero;

		public XKeyboard()
		{
			for (int i = 0; i < XTouch.MultiTouchCount; i++)
			{
				this._touches[i] = new XTouchItem();
			}
		}

		public XTouchItem GetTouch(int idx)
		{
			return this._touches[idx];
		}

		public void Update()
		{
			this._touch_count_this_frame = 0;
			this._bAxis = false;
			bool mouseButton = Input.GetMouseButton(0);
			if (mouseButton)
			{
				this._touches[this._touch_count_this_frame].faketouch.fingerId = XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XCommon_0);
				this._touches[this._touch_count_this_frame].faketouch.position = Input.mousePosition;
				this._touches[this._touch_count_this_frame].faketouch.deltaTime = Time.smoothDeltaTime;
				this._touches[this._touch_count_this_frame].faketouch.deltaPosition = Input.mousePosition - this._lastMousePos;
				this._touches[this._touch_count_this_frame].faketouch.phase = (Input.GetMouseButtonDown(0) ? (TouchPhase) 0 : ((this._touches[this._touch_count_this_frame].faketouch.deltaPosition.sqrMagnitude > 1f) ? (TouchPhase)1 : (TouchPhase)2));
				this._touches[this._touch_count_this_frame].faketouch.tapCount = 1;
				this._touches[this._touch_count_this_frame].Fake = true;
				this._lastMousePos = Input.mousePosition;
				this._touch_count_this_frame++;
			}
			else
			{
				bool mouseButtonUp = Input.GetMouseButtonUp(0);
				if (mouseButtonUp)
				{
					this._touches[this._touch_count_this_frame].faketouch.fingerId = XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XCommon_0);
					this._touches[this._touch_count_this_frame].faketouch.position = Input.mousePosition;
					this._touches[this._touch_count_this_frame].faketouch.deltaTime = Time.smoothDeltaTime;
					this._touches[this._touch_count_this_frame].faketouch.phase = (TouchPhase)3;
					this._touches[this._touch_count_this_frame].faketouch.tapCount = 1;
					this._touches[this._touch_count_this_frame].Fake = true;
					this._touch_count_this_frame++;
				}
			}
			this._bAxis = true;
			int num = 0; // horizontal
			int num2 = 0; // verticle
			bool key = Input.GetKey((KeyCode) 97);
			if (key)
			{
				num--;
			}
			bool key2 = Input.GetKey((KeyCode)100);
			if (key2)
			{
				num++;
			}
			bool key3 = Input.GetKey((KeyCode)115);
			if (key3)
			{
				num2--;
			}
			bool key4 = Input.GetKey((KeyCode)119);
			if (key4)
			{
				num2++;
			}
			bool flag = num != 0 || num2 != 0;
			if (flag)
			{
				this._touches[this._touch_count_this_frame].faketouch.fingerId = XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XCommon_1);
				this._touches[this._touch_count_this_frame].faketouch.deltaTime = Time.smoothDeltaTime;
				this._touches[this._touch_count_this_frame].faketouch.phase = ((this._x == 0f && this._y == 0f) ? (TouchPhase)0 : (TouchPhase)1);
				//this._touches[this._touch_count_this_frame].faketouch.position = ((this._touches[this._touch_count_this_frame].faketouch.phase == null) ? new Vector2(XSingleton<XVirtualTab>.singleton.MaxDistance, XSingleton<XVirtualTab>.singleton.MaxDistance) : ((num != 0 && num2 != 0) ? new Vector2(XSingleton<XVirtualTab>.singleton.MaxDistance + (float)num * XSingleton<XVirtualTab>.singleton.MaxDistance * 0.707f, XSingleton<XVirtualTab>.singleton.MaxDistance + (float)num2 * XSingleton<XVirtualTab>.singleton.MaxDistance * 0.707f) : new Vector2(XSingleton<XVirtualTab>.singleton.MaxDistance + (float)num * XSingleton<XVirtualTab>.singleton.MaxDistance, XSingleton<XVirtualTab>.singleton.MaxDistance + (float)num2 * XSingleton<XVirtualTab>.singleton.MaxDistance)));
				this._touches[this._touch_count_this_frame].faketouch.position = ((this._touches[this._touch_count_this_frame].faketouch.phase == TouchPhase.Began) ? new Vector2(XSingleton<XVirtualTab>.singleton.MaxDistance, XSingleton<XVirtualTab>.singleton.MaxDistance) : ((num != 0 && num2 != 0) ? new Vector2(XSingleton<XVirtualTab>.singleton.MaxDistance + (float)num * XSingleton<XVirtualTab>.singleton.MaxDistance * 0.707f, XSingleton<XVirtualTab>.singleton.MaxDistance + (float)num2 * XSingleton<XVirtualTab>.singleton.MaxDistance * 0.707f) : new Vector2(XSingleton<XVirtualTab>.singleton.MaxDistance + (float)num * XSingleton<XVirtualTab>.singleton.MaxDistance, XSingleton<XVirtualTab>.singleton.MaxDistance + (float)num2 * XSingleton<XVirtualTab>.singleton.MaxDistance)));
				this._touches[this._touch_count_this_frame].faketouch.tapCount = 1;
				this._touches[this._touch_count_this_frame].Fake = true;
				this._touch_count_this_frame++;
			}
			else
			{
				bool flag2 = this._x != 0f || this._y != 0f;
				if (flag2)
				{
					this._touches[this._touch_count_this_frame].faketouch.fingerId = XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XCommon_1);
					this._touches[this._touch_count_this_frame].faketouch.position = new Vector2(XSingleton<XVirtualTab>.singleton.MaxDistance, XSingleton<XVirtualTab>.singleton.MaxDistance);
					this._touches[this._touch_count_this_frame].faketouch.deltaTime = Time.smoothDeltaTime;
					this._touches[this._touch_count_this_frame].faketouch.phase = (TouchPhase) 3;
					this._touches[this._touch_count_this_frame].faketouch.tapCount = 1;
					this._touches[this._touch_count_this_frame].Fake = true;
					this._touch_count_this_frame++;
				}
			}
			this._x = (float)num;
			this._y = (float)num2;
			bool flag3 = !this._bAxis;
			if (flag3)
			{
				this._x = 0f;
				this._y = 0f;
			}
		}
	}
}