diff options
Diffstat (limited to 'Runtime/Export/AndroidInput.txt')
-rw-r--r-- | Runtime/Export/AndroidInput.txt | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/Runtime/Export/AndroidInput.txt b/Runtime/Export/AndroidInput.txt new file mode 100644 index 0000000..7667f15 --- /dev/null +++ b/Runtime/Export/AndroidInput.txt @@ -0,0 +1,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 +} |