blob: cfbac3e8d987a7f0ef81c75492e9b7a78e95631f (
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
using System;
using UnityEngine;
using XUpdater;
using XUtliPoolLib;
namespace XMainClient
{
internal class XSirJoystick : XSingleton<XSirJoystick>
{
private IXGameSirControl SirControl
{
get
{
return XSingleton<XUpdater.XUpdater>.singleton.GameSirControl;
}
}
public int touchCount
{
get
{
return this._touch_count_this_frame;
}
}
public bool Enabled
{
get
{
return this.SirControl != null && this.SirControl.IsConnected();
}
}
private XTouchItem[] _touches = new XTouchItem[XSirJoystick._touch_count_total_frame];
private Vector2 _RotatePos = new Vector2((float)Screen.width * 0.75f, (float)Screen.height * 0.5f);
private Vector2 _RockerPos = new Vector2((float)Screen.width * 0.2f, (float)Screen.height * 0.25f);
private Vector2 _RotateRangeX = new Vector2((float)Screen.width * 0.5f, (float)Screen.width * 1f);
private Vector2 _RotateRangeY = new Vector2((float)Screen.height * 0.2f, (float)Screen.height * 0.8f);
private int _touch_count_this_frame = 0;
private static int _touch_count_total_frame = 2;
private float _x = 0f;
private float _y = 0f;
private float _z = 0f;
private float _rz = 0f;
private Vector2 _tempPos;
private int _RotateStep = 10;
public XSirJoystick()
{
for (int i = 0; i < XSirJoystick._touch_count_total_frame; i++)
{
this._touches[i] = new XTouchItem();
}
}
public XTouchItem GetTouch(int touch)
{
return this._touches[touch];
}
public void Update()
{
this._touch_count_this_frame = 0;
this.OnTouch();
this.UpdateRocker();
this.UpdateRotate();
}
private void OnTouch()
{
bool button = this.SirControl.GetButton(XGameSirKeyCode.BTN_THUMBL);
if (button)
{
XSingleton<XScene>.singleton.GameCamera.BackToPlayer();
}
}
private void UpdateRocker()
{
float axis = this.SirControl.GetAxis(XGameSirKeyCode.AXIS_X);
float num = -this.SirControl.GetAxis(XGameSirKeyCode.AXIS_Y);
bool flag = axis != 0f || num != 0f;
if (flag)
{
this._touches[this._touch_count_this_frame].faketouch.fingerId = XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XJoystick_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) ? this._RockerPos : ((axis != 0f && num != 0f) ? new Vector2(this._RockerPos.x + axis * XSingleton<XVirtualTab>.singleton.MaxDistance * 0.707f, this._RockerPos.y + num * XSingleton<XVirtualTab>.singleton.MaxDistance * 0.707f) : new Vector2(this._RockerPos.x + axis * XSingleton<XVirtualTab>.singleton.MaxDistance, this._RockerPos.y + num * 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.XJoystick_1);
this._touches[this._touch_count_this_frame].faketouch.position = this._RockerPos;
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 = axis;
this._y = num;
}
private void UpdateRotate()
{
float axis = this.SirControl.GetAxis(XGameSirKeyCode.AXIS_Z);
float num = -this.SirControl.GetAxis(XGameSirKeyCode.AXIS_RZ);
bool flag = axis != 0f || num != 0f;
if (flag)
{
this._touches[this._touch_count_this_frame].faketouch.fingerId = XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XJoystick_0);
this._touches[this._touch_count_this_frame].faketouch.deltaTime = Time.smoothDeltaTime;
this._touches[this._touch_count_this_frame].faketouch.deltaPosition = new Vector2(axis, num);
bool flag2 = this._z == 0f && this._rz == 0f;
if (flag2)
{
this._touches[this._touch_count_this_frame].faketouch.phase = 0;
this._touches[this._touch_count_this_frame].faketouch.position = this._RotatePos;
this._tempPos = this._RotatePos;
}
else
{
bool flag3 = this._touches[this._touch_count_this_frame].faketouch.deltaPosition.sqrMagnitude >= 0.5f;
if (flag3)
{
this._tempPos += this._touches[this._touch_count_this_frame].faketouch.deltaPosition * (float)this._RotateStep;
this._tempPos.x = Mathf.Clamp(this._tempPos.x, this._RotateRangeX.x, this._RotateRangeX.y);
this._tempPos.y = Mathf.Clamp(this._tempPos.y, this._RotateRangeY.x, this._RotateRangeY.y);
this._touches[this._touch_count_this_frame].faketouch.phase = (TouchPhase)1;
this._touches[this._touch_count_this_frame].faketouch.position = this._tempPos;
}
}
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 flag4 = this._z != 0f || this._rz != 0f;
if (flag4)
{
this._touches[this._touch_count_this_frame].faketouch.fingerId = XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XJoystick_0);
this._touches[this._touch_count_this_frame].faketouch.position = this._tempPos;
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._z = axis;
this._rz = num;
}
}
}
|