From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Export/AndroidInput.txt | 85 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Runtime/Export/AndroidInput.txt (limited to 'Runtime/Export/AndroidInput.txt') 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 + #include + #include +#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 +} -- cgit v1.1-26-g67d0