forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput.bindings.cs
More file actions
469 lines (430 loc) · 16.6 KB
/
Input.bindings.cs
File metadata and controls
469 lines (430 loc) · 16.6 KB
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using System.Runtime.InteropServices;
using UnityEngine.Bindings;
using UnityEngine.Scripting;
namespace UnityEngine
{
public enum TouchPhase
{
Began = 0,
Moved = 1,
Stationary = 2,
Ended = 3,
Canceled = 4
}
// Controls IME input
public enum IMECompositionMode
{
Auto = 0,
On = 1,
Off = 2
}
public enum TouchType
{
Direct,
Indirect,
Stylus
}
[NativeHeader("Runtime/Input/InputBindings.h")]
public struct Touch
{
private int m_FingerId;
private Vector2 m_Position;
private Vector2 m_RawPosition;
private Vector2 m_PositionDelta;
private float m_TimeDelta;
private int m_TapCount;
private TouchPhase m_Phase;
private TouchType m_Type;
private float m_Pressure;
private float m_maximumPossiblePressure;
private float m_Radius;
private float m_RadiusVariance;
private float m_AltitudeAngle;
private float m_AzimuthAngle;
public int fingerId { get { return m_FingerId; } set { m_FingerId = value; } }
public Vector2 position { get { return m_Position; } set { m_Position = value; } }
public Vector2 rawPosition { get { return m_RawPosition; } set { m_RawPosition = value; } }
public Vector2 deltaPosition { get { return m_PositionDelta; } set { m_PositionDelta = value; } }
public float deltaTime { get { return m_TimeDelta; } set { m_TimeDelta = value; } }
public int tapCount { get { return m_TapCount; } set { m_TapCount = value; } }
public TouchPhase phase { get { return m_Phase; } set { m_Phase = value; } }
public float pressure { get { return m_Pressure; } set { m_Pressure = value; } }
public float maximumPossiblePressure { get { return m_maximumPossiblePressure; } set { m_maximumPossiblePressure = value; } }
public TouchType type { get { return m_Type; } set { m_Type = value; } }
public float altitudeAngle { get { return m_AltitudeAngle; } set { m_AltitudeAngle = value; } }
public float azimuthAngle { get { return m_AzimuthAngle; } set { m_AzimuthAngle = value; } }
public float radius { get { return m_Radius; } set { m_Radius = value; } }
public float radiusVariance { get { return m_RadiusVariance; } set { m_RadiusVariance = value; } }
}
public enum DeviceOrientation
{
Unknown = 0,
Portrait = 1,
PortraitUpsideDown = 2,
LandscapeLeft = 3,
LandscapeRight = 4,
FaceUp = 5,
FaceDown = 6
}
public struct AccelerationEvent
{
internal float x, y, z;
internal float m_TimeDelta;
public Vector3 acceleration { get { return new Vector3(x, y, z); } }
public float deltaTime { get { return m_TimeDelta; } }
}
[NativeHeader("Runtime/Input/GetInput.h")]
public class Gyroscope
{
internal Gyroscope(int index)
{
m_GyroIndex = index;
}
private int m_GyroIndex;
[FreeFunction("GetGyroRotationRate")]
extern private static Vector3 rotationRate_Internal(int idx);
[FreeFunction("GetGyroRotationRateUnbiased")]
extern private static Vector3 rotationRateUnbiased_Internal(int idx);
[FreeFunction("GetGravity")]
extern private static Vector3 gravity_Internal(int idx);
[FreeFunction("GetUserAcceleration")]
extern private static Vector3 userAcceleration_Internal(int idx);
[FreeFunction("GetAttitude")]
extern private static Quaternion attitude_Internal(int idx);
[FreeFunction("IsGyroEnabled")]
extern private static bool getEnabled_Internal(int idx);
[FreeFunction("SetGyroEnabled")]
extern private static void setEnabled_Internal(int idx, bool enabled);
[FreeFunction("GetGyroUpdateInterval")]
extern private static float getUpdateInterval_Internal(int idx);
[FreeFunction("SetGyroUpdateInterval")]
extern private static void setUpdateInterval_Internal(int idx, float interval);
public Vector3 rotationRate { get { return rotationRate_Internal(m_GyroIndex); } }
public Vector3 rotationRateUnbiased { get { return rotationRateUnbiased_Internal(m_GyroIndex); } }
public Vector3 gravity { get { return gravity_Internal(m_GyroIndex); } }
public Vector3 userAcceleration { get { return userAcceleration_Internal(m_GyroIndex); } }
public Quaternion attitude { get { return attitude_Internal(m_GyroIndex); } }
public bool enabled { get { return getEnabled_Internal(m_GyroIndex); } set { setEnabled_Internal(m_GyroIndex, value); } }
public float updateInterval { get { return getUpdateInterval_Internal(m_GyroIndex); } set { setUpdateInterval_Internal(m_GyroIndex, value); } }
}
public struct LocationInfo
{
internal double m_Timestamp;
internal float m_Latitude;
internal float m_Longitude;
internal float m_Altitude;
internal float m_HorizontalAccuracy;
internal float m_VerticalAccuracy;
public float latitude { get { return m_Latitude; } }
public float longitude { get { return m_Longitude; } }
public float altitude { get { return m_Altitude; } }
public float horizontalAccuracy { get { return m_HorizontalAccuracy; } }
public float verticalAccuracy { get { return m_VerticalAccuracy; } }
public double timestamp { get { return m_Timestamp; } }
}
public enum LocationServiceStatus
{
Stopped = 0,
Initializing = 1,
Running = 2,
Failed = 3
}
[NativeHeader("Runtime/Input/LocationService.h")]
[NativeHeader("Runtime/Input/InputBindings.h")]
public class LocationService
{
internal struct HeadingInfo
{
public float magneticHeading;
public float trueHeading;
public float headingAccuracy;
public Vector3 raw;
public double timestamp;
}
[FreeFunction("LocationService::IsServiceEnabledByUser")]
internal extern static bool IsServiceEnabledByUser();
[FreeFunction("LocationService::GetLocationStatus")]
internal extern static LocationServiceStatus GetLocationStatus();
[FreeFunction("LocationService::GetLastLocation")]
internal extern static LocationInfo GetLastLocation();
[FreeFunction("LocationService::SetDesiredAccuracy")]
internal extern static void SetDesiredAccuracy(float value);
[FreeFunction("LocationService::SetDistanceFilter")]
internal extern static void SetDistanceFilter(float value);
[FreeFunction("LocationService::StartUpdatingLocation")]
internal extern static void StartUpdatingLocation();
[FreeFunction("LocationService::StopUpdatingLocation")]
internal extern static void StopUpdatingLocation();
[FreeFunction("LocationService::GetLastHeading")]
internal extern static HeadingInfo GetLastHeading();
[FreeFunction("LocationService::IsHeadingUpdatesEnabled")]
internal extern static bool IsHeadingUpdatesEnabled();
[FreeFunction("LocationService::SetHeadingUpdatesEnabled")]
internal extern static void SetHeadingUpdatesEnabled(bool value);
public bool isEnabledByUser { get { return IsServiceEnabledByUser(); } }
public LocationServiceStatus status { get { return GetLocationStatus(); } }
public LocationInfo lastData
{
get
{
if (status != LocationServiceStatus.Running)
Debug.Log("Location service updates are not enabled. Check LocationService.status before querying last location.");
return GetLastLocation();
}
}
public void Start(float desiredAccuracyInMeters, float updateDistanceInMeters)
{
SetDesiredAccuracy(desiredAccuracyInMeters);
SetDistanceFilter(updateDistanceInMeters);
StartUpdatingLocation();
}
public void Start(float desiredAccuracyInMeters)
{
Start(desiredAccuracyInMeters, 10f);
}
public void Start()
{
Start(10f, 10f);
}
public void Stop()
{
StopUpdatingLocation();
}
}
public class Compass
{
public float magneticHeading
{
get { return LocationService.GetLastHeading().magneticHeading; }
}
public float trueHeading
{
get { return LocationService.GetLastHeading().trueHeading; }
}
public float headingAccuracy
{
get { return LocationService.GetLastHeading().headingAccuracy; }
}
public Vector3 rawVector
{
get { return LocationService.GetLastHeading().raw; }
}
public double timestamp
{
get { return LocationService.GetLastHeading().timestamp; }
}
public bool enabled
{
get { return LocationService.IsHeadingUpdatesEnabled(); }
set { LocationService.SetHeadingUpdatesEnabled(value); }
}
}
[NativeHeader("Runtime/Camera/Camera.h")]
// This is needed to internally call Physics/Physics2D using an interface if available, so we don't have a hard dependency on Physics.
internal class CameraRaycastHelper
{
[FreeFunction("CameraScripting::RaycastTry")] extern internal static GameObject RaycastTry(Camera cam, Ray ray, float distance, int layerMask);
[FreeFunction("CameraScripting::RaycastTry2D")] extern internal static GameObject RaycastTry2D(Camera cam, Ray ray, float distance, int layerMask);
}
[NativeHeader("Runtime/Input/InputBindings.h")]
public class Input
{
[NativeThrows]
private extern static bool GetKeyInt(KeyCode key);
[NativeThrows]
private extern static bool GetKeyString(string name);
[NativeThrows]
private extern static bool GetKeyUpInt(KeyCode key);
[NativeThrows]
private extern static bool GetKeyUpString(string name);
[NativeThrows]
private extern static bool GetKeyDownInt(KeyCode key);
[NativeThrows]
private extern static bool GetKeyDownString(string name);
[NativeThrows]
public extern static float GetAxis(string axisName);
[NativeThrows]
public extern static float GetAxisRaw(string axisName);
[NativeThrows]
public extern static bool GetButton(string buttonName);
[NativeThrows]
public extern static bool GetButtonDown(string buttonName);
[NativeThrows]
public extern static bool GetButtonUp(string buttonName);
[NativeThrows]
public extern static bool GetMouseButton(int button);
[NativeThrows]
public extern static bool GetMouseButtonDown(int button);
[NativeThrows]
public extern static bool GetMouseButtonUp(int button);
[FreeFunction("ResetInput")]
public extern static void ResetInputAxes();
public extern static bool IsJoystickPreconfigured(string joystickName);
public extern static string[] GetJoystickNames();
[NativeThrows]
public extern static Touch GetTouch(int index);
[NativeThrows]
public extern static AccelerationEvent GetAccelerationEvent(int index);
public static bool GetKey(KeyCode key)
{
return GetKeyInt(key);
}
public static bool GetKey(string name)
{
return GetKeyString(name);
}
public static bool GetKeyUp(KeyCode key)
{
return GetKeyUpInt(key);
}
public static bool GetKeyUp(string name)
{
return GetKeyUpString(name);
}
public static bool GetKeyDown(KeyCode key)
{
return GetKeyDownInt(key);
}
public static bool GetKeyDown(string name)
{
return GetKeyDownString(name);
}
public extern static bool simulateMouseWithTouches { get; set; }
public extern static bool anyKey { get; }
public extern static bool anyKeyDown { get; }
public extern static string inputString { get; }
public extern static Vector3 mousePosition { get; }
public extern static Vector2 mouseScrollDelta { get; }
public extern static IMECompositionMode imeCompositionMode { get; set; }
public extern static string compositionString { get; }
public extern static bool imeIsSelected { get; }
public extern static Vector2 compositionCursorPos { get; set; }
[Obsolete("eatKeyPressOnTextFieldFocus property is deprecated, and only provided to support legacy behavior.")]
public extern static bool eatKeyPressOnTextFieldFocus { get; set; }
public extern static bool mousePresent
{
[FreeFunction("GetMousePresent")]
get;
}
public extern static int touchCount
{
[FreeFunction("GetTouchCount")]
get;
}
public extern static bool touchPressureSupported
{
[FreeFunction("IsTouchPressureSupported")]
get;
}
public extern static bool stylusTouchSupported
{
[FreeFunction("IsStylusTouchSupported")]
get;
}
public extern static bool touchSupported
{
[FreeFunction("IsTouchSupported")]
get;
}
public extern static bool multiTouchEnabled
{
[FreeFunction("IsMultiTouchEnabled")]
get;
[FreeFunction("SetMultiTouchEnabled")]
set;
}
[Obsolete("isGyroAvailable property is deprecated. Please use SystemInfo.supportsGyroscope instead.")]
public extern static bool isGyroAvailable
{
[FreeFunction("IsGyroAvailable")]
get;
}
public extern static DeviceOrientation deviceOrientation
{
[FreeFunction("GetOrientation")]
get;
}
public extern static Vector3 acceleration
{
[FreeFunction("GetAcceleration")]
get;
}
public extern static bool compensateSensors
{
[FreeFunction("IsCompensatingSensors")]
get;
[FreeFunction("SetCompensatingSensors")]
set;
}
public extern static int accelerationEventCount
{
[FreeFunction("GetAccelerationCount")]
get;
}
public extern static bool backButtonLeavesApp
{
[FreeFunction("GetBackButtonLeavesApp")]
get;
[FreeFunction("SetBackButtonLeavesApp")]
set;
}
private static LocationService locationServiceInstance;
public static LocationService location
{
get
{
if (locationServiceInstance == null)
locationServiceInstance = new LocationService();
return locationServiceInstance;
}
}
private static Compass compassInstance;
public static Compass compass
{
get
{
if (compassInstance == null)
compassInstance = new Compass();
return compassInstance;
}
}
[FreeFunction("GetGyro")]
private extern static int GetGyroInternal();
private static Gyroscope s_MainGyro;
public static Gyroscope gyro
{
get
{
if (s_MainGyro == null)
s_MainGyro = new Gyroscope(GetGyroInternal());
return s_MainGyro;
}
}
public static Touch[] touches
{
get
{
int count = touchCount;
Touch[] touches = new Touch[count];
for (int q = 0; q < count; ++q)
touches[q] = GetTouch(q);
return touches;
}
}
public static AccelerationEvent[] accelerationEvents
{
get
{
int count = accelerationEventCount;
AccelerationEvent[] events = new AccelerationEvent[count];
for (int q = 0; q < count; ++q)
events[q] = GetAccelerationEvent(q);
return events;
}
}
}
}