blob: 16b5cf032517fa92b6be4bd9196721d018b312a0 (
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
using System;
using UnityEngine;
using XUpdater;
using XUtliPoolLib;
namespace XMainClient
{
internal class XGyroscope : XSingleton<XGyroscope>
{
public float Scale
{
get
{
return this._scale;
}
}
public float DeadZone
{
get
{
return this._deadzone;
}
}
public float Frequency
{
get
{
return this._frequency;
}
}
public bool Enabled
{
get
{
return this._enabled;
}
set
{
bool flag = this._enabled != value;
if (flag)
{
this._touch_count_this_frame = 0;
this._enabled = value;
}
Input.gyro.enabled = this._enabled;
bool enabled = this._enabled;
if (enabled)
{
this._scale = (XSingleton<XUpdater.XUpdater>.singleton.EditorMode ? 1f : XSingleton<XGlobalConfig>.singleton.GyroScale);
this._deadzone = XSingleton<XGlobalConfig>.singleton.GyroDeadZone;
this._frequency = XSingleton<XGlobalConfig>.singleton.GyroFrequency;
Input.gyro.updateInterval = 1f / this._frequency;
}
this.Cancel();
XSingleton<XGesture>.singleton.Cancel();
}
}
public int touchCount
{
get
{
return this._touch_count_this_frame;
}
}
private XTouchItem _touches = new XTouchItem();
private bool _enabled = false;
private static Vector2 _init_pos = new Vector2((float)Screen.width * 0.55f, (float)Screen.height * 0.55f);
private static Vector2 _last_pos = XGyroscope._init_pos;
private static Vector2 _curr_pos = XGyroscope._init_pos;
private int _touch_count_this_frame = 0;
private float _frequency = 30f;
private float _scale = 0.2f;
private float _deadzone = 0.01f;
public void OnEnterScene()
{
XOptionsDocument specificDocument = XDocuments.GetSpecificDocument<XOptionsDocument>(XOptionsDocument.uuID);
bool flag = specificDocument != null;
if (flag)
{
this.Enabled = (specificDocument.GetValue(XOptionsDefine.OD_Gyro) != 0);
}
}
public void Update()
{
this._touch_count_this_frame = 0;
bool currentPos = this.GetCurrentPos();
if (currentPos)
{
this._touches.faketouch.fingerId = XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XGyroscope_0);
this._touches.faketouch.position = XGyroscope._curr_pos;
this._touches.faketouch.deltaTime = Time.smoothDeltaTime;
this._touches.faketouch.deltaPosition = XGyroscope._curr_pos - XGyroscope._last_pos;
this._touches.faketouch.phase = ((XGyroscope._curr_pos == XGyroscope._init_pos) ? (TouchPhase)3 : ((XGyroscope._last_pos == XGyroscope._init_pos) ? (TouchPhase)0 : (TouchPhase)1));
this._touches.faketouch.tapCount = 1;
this._touches.Fake = true;
XGyroscope._last_pos = XGyroscope._curr_pos;
this._touch_count_this_frame++;
}
}
public XTouchItem GetTouch(int idx)
{
return this._touches;
}
public void Set(float scale, float times, float deadzone)
{
bool enabled = this.Enabled;
if (enabled)
{
this._scale = (XSingleton<XUpdater.XUpdater>.singleton.EditorMode ? 1f : scale);
this._deadzone = deadzone;
this._frequency = times;
Input.gyro.updateInterval = 1f / this._frequency;
}
}
private bool GetCurrentPos()
{
float num = 0f;
float num2 = 0f;
bool editorMode = XSingleton<XUpdater.XUpdater>.singleton.EditorMode;
if (editorMode)
{
bool key = Input.GetKey((KeyCode)276);
if (key)
{
num -= 1f;
}
bool key2 = Input.GetKey((KeyCode)275);
if (key2)
{
num += 1f;
}
bool key3 = Input.GetKey((KeyCode)274);
if (key3)
{
num2 -= 1f;
}
bool key4 = Input.GetKey((KeyCode)273);
if (key4)
{
num2 += 1f;
}
}
else
{
Vector3 rotationRateUnbiased = Input.gyro.rotationRateUnbiased;
rotationRateUnbiased.z = 0f;
bool flag = rotationRateUnbiased.sqrMagnitude < this._deadzone * this._deadzone;
if (flag)
{
num2 = (num = 0f);
}
else
{
num = -(rotationRateUnbiased.y * 57.29578f);
num2 = rotationRateUnbiased.x * 57.29578f;
}
}
bool flag2 = num != 0f || num2 != 0f;
bool result;
if (flag2)
{
XGyroscope._curr_pos = XGyroscope._last_pos + new Vector2(this._scale * num, this._scale * num2);
result = true;
}
else
{
bool flag3 = XGyroscope._curr_pos != XGyroscope._init_pos;
if (flag3)
{
XGyroscope._last_pos = XGyroscope._init_pos;
XGyroscope._curr_pos = XGyroscope._init_pos;
result = true;
}
else
{
result = false;
}
}
return result;
}
public void Cancel()
{
XGyroscope._last_pos = XGyroscope._init_pos;
XGyroscope._curr_pos = XGyroscope._init_pos;
}
}
}
|