blob: 7667f158cd3339491221d6e232469c046e0e4b28 (
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
|
C++RAW
#include "UnityPrefix.h"
#include "Runtime/Scripting/ScriptingUtility.h"
#include "Runtime/Input/GetInput.h"
#include "Runtime/Mono/MonoBehaviour.h"
#if UNITY_ANDROID
#include <PlatformDependent/AndroidPlayer/AndroidInput.h>
#include <PlatformDependent/AndroidPlayer/TouchInput.h>
#include <android/input.h>
#endif
CSRAW
namespace UnityEngine
{
// AndroidInput provides support for off-screen touch input, such as a touchpad.
CONDITIONAL UNITY_ANDROID || UNITY_EDITOR
CLASS AndroidInput
// Hide constructor
CSRAW private AndroidInput() {}
// Returns object representing status of a specific touch on a secondary touchpad (Does not allocate temporary variables).
CUSTOM static Touch GetSecondaryTouch (int index)
{
Touch touch;
#if UNITY_ANDROID
if (index >= 0 && index < GetTouchCount ((int)AINPUT_SOURCE_TOUCHPAD))
{
if (!GetTouch ((int)AINPUT_SOURCE_TOUCHPAD, index, touch))
Scripting::RaiseMonoException ("Internal error.");
}
else
Scripting::RaiseMonoException ("Index out of bounds.");
#endif
return touch;
}
// Number of secondary touches. Guaranteed not to change throughout the frame. (RO).
CUSTOM_PROP static int touchCountSecondary
{
#if UNITY_ANDROID
return GetTouchCount((int)AINPUT_SOURCE_TOUCHPAD);
#else
return 0;
#endif
}
// Property indicating whether the system provides secondary touch input.
CUSTOM_PROP static bool secondaryTouchEnabled
{
#if UNITY_ANDROID
return IsInputDeviceEnabled((int)AINPUT_SOURCE_TOUCHPAD);
#else
return false;
#endif
}
// Property indicating the width of the secondary touchpad.
CUSTOM_PROP static int secondaryTouchWidth
{
#if UNITY_ANDROID
return GetTouchpadWidth();
#else
return 0;
#endif
}
// Property indicating the height of the secondary touchpad.
CUSTOM_PROP static int secondaryTouchHeight
{
#if UNITY_ANDROID
return GetTouchpadHeight();
#else
return 0;
#endif
}
END
CSRAW
}
|