using System; using UnityEngine; using XUpdater; using XUtliPoolLib; namespace XMainClient { internal class XKeyboard : XSingleton { public bool Enabled { get { return XSingleton.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.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.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.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.singleton.MaxDistance, XSingleton.singleton.MaxDistance) : ((num != 0 && num2 != 0) ? new Vector2(XSingleton.singleton.MaxDistance + (float)num * XSingleton.singleton.MaxDistance * 0.707f, XSingleton.singleton.MaxDistance + (float)num2 * XSingleton.singleton.MaxDistance * 0.707f) : new Vector2(XSingleton.singleton.MaxDistance + (float)num * XSingleton.singleton.MaxDistance, XSingleton.singleton.MaxDistance + (float)num2 * XSingleton.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.singleton.MaxDistance, XSingleton.singleton.MaxDistance) : ((num != 0 && num2 != 0) ? new Vector2(XSingleton.singleton.MaxDistance + (float)num * XSingleton.singleton.MaxDistance * 0.707f, XSingleton.singleton.MaxDistance + (float)num2 * XSingleton.singleton.MaxDistance * 0.707f) : new Vector2(XSingleton.singleton.MaxDistance + (float)num * XSingleton.singleton.MaxDistance, XSingleton.singleton.MaxDistance + (float)num2 * XSingleton.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.ToInt(XFingerId.XCommon_1); this._touches[this._touch_count_this_frame].faketouch.position = new Vector2(XSingleton.singleton.MaxDistance, XSingleton.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; } } } }