17using System.Runtime.InteropServices;
25#if (UNITY_IPHONE || UNITY_WEBGL) && !UNITY_EDITOR
31 #region Native Functions
41 [
return: MarshalAs(UnmanagedType.I4)]
61 [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] UInt64[] glassesHandle);
106 UInt64 glassesHandle,
122 [MarshalAs(UnmanagedType.LPArray, SizeConst = 2)]
int[] displayDimensions);
125 public static extern int GetGlassesIPD(UInt64 glassesHandle, ref
float glassesIPD);
130#if UNITY_WEBGL && !UNITY_EDITOR
131 [DllImport (
"__Internal")]
132 public static extern void RegisterPlugin();
135 #endregion Native Functions
152 public static implicit
operator bool(
T5_Bool t5_boolean)
153 => Convert.ToBoolean(t5_boolean.booleanByte);
162 [StructLayout(LayoutKind.Sequential)]
163 internal struct T5_Position
165 public float X, Y, Z;
167 public T5_Position(Vector3 position)
174 public static implicit
operator Vector3(T5_Position t5_position)
175 =>
new Vector3(t5_position.X, t5_position.Y, t5_position.Z);
176 public static implicit
operator T5_Position(Vector3 position) =>
new T5_Position(position);
184 [StructLayout(LayoutKind.Sequential)]
185 internal struct T5_Rotation
187 public float W, X, Y, Z;
189 public T5_Rotation(Quaternion rotation)
197 public static implicit
operator Quaternion(T5_Rotation t5_rotation)
198 =>
new Quaternion(t5_rotation.X, t5_rotation.Y, t5_rotation.Z, t5_rotation.W);
199 public static implicit
operator T5_Rotation(Quaternion rotation) =>
new T5_Rotation(rotation);
202 internal struct GlassesHandle : IEquatable<GlassesHandle>
204 private UInt64 glassesHandle;
205 public static implicit
operator UInt64(GlassesHandle handle) => handle.glassesHandle;
206 public static implicit
operator GlassesHandle(UInt64 handle) =>
new GlassesHandle() { glassesHandle = handle };
207 public override int GetHashCode() => glassesHandle.GetHashCode();
208 public bool Equals(GlassesHandle other) => glassesHandle == other.glassesHandle;
209 public override string ToString()
211 return glassesHandle.ToString();
218 [StructLayout(LayoutKind.Sequential)]
239 [StructLayout(LayoutKind.Sequential)]
252 public T5_CamImage(UInt16 bufferWidth, UInt16 bufferHeight, UInt16 bufferStride, UInt32 bufferSize)
267 [StructLayout(LayoutKind.Sequential)]
278 [StructLayout(LayoutKind.Sequential)]
281 [StructLayout(LayoutKind.Sequential)]
286 public static implicit
operator Vector2(
Joystick joystick) =>
new Vector2(joystick.X, joystick.Y);
289 [StructLayout(LayoutKind.Sequential)]
301 public bool T5 {
get =>
t5;
set =>
t5 = value; }
305 public bool A {
get =>
a;
set =>
a = value; }
306 public bool B {
get =>
b;
set =>
b = value; }
307 public bool X {
get =>
x;
set =>
x = value; }
308 public bool Y {
get =>
y;
set =>
y = value; }
309 [Obsolete(
"Buttons.System is deprecated, please use Wandbutton.T5 instead.")]
311 [Obsolete(
"Buttons.Z is deprecated, please use Wandbutton.Three instead.")]
350 [StructLayout(LayoutKind.Sequential)]
351 internal struct T5_VCI
353 public float StartX_VCI;
354 public float StartY_VCI;
355 public float Width_VCI;
356 public float Height_VCI;
358 public T5_VCI(Rect rect)
362 Width_VCI = rect.width;
363 Height_VCI = rect.height;
366 public static implicit
operator Rect(T5_VCI vci)
367 =>
new Rect(vci.StartX_VCI, vci.StartY_VCI, vci.Width_VCI, vci.Height_VCI);
368 public static implicit
operator T5_VCI(Rect rect) =>
new T5_VCI(rect);
374 [StructLayout(LayoutKind.Sequential)]
409 [StructLayout(LayoutKind.Explicit, Pack = 4)]
425 byte[] textBytesUTF8 = System.Text.Encoding.UTF8.GetBytes(text);
448 var managedBytes =
new byte[t5_StringUTF8.
length];
452 return System.Text.Encoding.UTF8.GetString(managedBytes);
456 Debug.LogError($
"Failed to copy string from unmanaged memory: {e}");
523 [Obsolete(
"ControllerIndex.Primary is deprecated, please update to use left/right based on user preference instead.")]
526 [Obsolete(
"ControllerIndex.Secondary is deprecated, please update to use left/right based on user preference instead.")]
562 [StructLayout(LayoutKind.Sequential)]
static void UnloadWorkaround()
static int GetWandAvailability(UInt64 glassesHandle, ref T5_Bool wandAvailable, [MarshalAs(UnmanagedType.I4)] ControllerIndex wandTarget)
static int GetGlassesPose(UInt64 glassesHandle, ref T5_GlassesPose glassesPose, [MarshalAs(UnmanagedType.I4)] T5_GlassesPoseUsage glassesPoseUsage)
static int CancelCamImageBuffer(UInt64 glassesHandle, IntPtr buffer)
static ServiceCompatibility GetServiceCompatibility()
static int GetGlassesIPD(UInt64 glassesHandle, ref float glassesIPD)
static int GetGameboardDimensions([MarshalAs(UnmanagedType.I4)] GameboardType gameboardType, ref T5_GameboardSize playableSpaceInMeters)
static int GetGlassesFriendlyName(UInt64 glassesHandle, ref T5_StringUTF8 glassesFriendlyName)
static int SetRumbleMotor(uint motor, float intensity)
static void SetMaxDesiredGlasses(byte maxCount)
static int QueueStereoImages(UInt64 glassesHandle, T5_FrameInfo frameInfo)
const string PLUGIN_LIBRARY
static IntPtr GetSendFrameCallback()
static int RefreshGlassesAvailable()
static int GetControllerState(UInt64 glassesHandle, [MarshalAs(UnmanagedType.I4)] ControllerIndex controllerIndex, ref T5_ControllerState controllerState)
static int ScanForWands()
static int GetGlassesHandles(ref byte handleCount, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] UInt64[] glassesHandle)
static int SubmitEmptyCamImageBuffer(UInt64 glassesHandle, IntPtr camImageBuffer, UInt32 bufferSize)
static int ConfigureCameraStream(UInt64 glassesHandle, T5_CameraStreamConfig cameraConfig)
static int GetMaxDisplayDimensions([MarshalAs(UnmanagedType.LPArray, SizeConst=2)] int[] displayDimensions)
static int GetFilledCamImageBuffer(UInt64 glassesHandle, ref T5_CamImage camImageBuffer)
static int SetApplicationInfo(T5_StringUTF8 appName, T5_StringUTF8 appId, T5_StringUTF8 appVersion)
ServiceCompatibility
Whether the running service is compatible.
ControllerPosition
Points of interest along the wand controller, such as the handle position or wand tip.
@ Fingertips
The typical resting position of the player's fingertips, near the wand joystick and trigger.
@ Aim
The tip of the wand.
@ Grip
The center of the wand handle.
ControllerIndex
Since wands are all physically identical (they have no "handedness"), it doesn't make sense to addres...
@ Right
The wand held in the player's right hand.
@ Left
The wand held in the player's left hand.
T5_GlassesPoseUsage
Glasses pose usage indicator.
@ SpectatorPresentation
The pose will be used to render images to be presented on a device other than the glasses,...
@ GlassesPresentation
The pose will be used to render images to be presented on the glasses.
GameboardType
The type of Gameboard being tracked by the glasses.
@ GameboardType_None
No Gameboard at all.
@ GameboardType_LE
The LE Gameboard.
@ GameboardType_XE
The XE Gameboard, laid out flat.
@ GameboardType_XE_Raised
The XE Gameboard, folded upward using its kickstand.
T5_Hand
Reported wand hand.
PlayerIndex
The Player index (e.g. Player One, Player Two, etc)
Represents a boolean value.
readonly byte booleanByte
Represents a wrapper on a buffer comtaining a camera image.
UInt32 ImageBufferSize_PIX
UInt16 ImageBufferStride_PIX
UInt16 ImageBufferWidth_PIX
UInt16 ImageBufferHeight_PIX
T5_CamImage(UInt16 bufferWidth, UInt16 bufferHeight, UInt16 bufferStride, UInt32 bufferSize)
Camera Stream Configuration.
Contains wand related information (Pose, Buttons, Trigger, Stick, Battery)
Vector3 FingertipsPos_GBD
T5_Position fingertipsPos_GBD
Render information to be used with NativePlugin.QueueStereoImages(T5_FrameInfo)
Physical dimensions of a gameboard, in meters.
T5_GameboardSize(float playableSpaceX, float playableSpaceY, float borderWidth)
Headset pose information to be retrieved with NativePlugin.GetGlassesPose(ref T5_GlassesPose)
T5_Rotation rotationToGLS_GBD
GameboardType GameboardType
Quaternion RotationToGLS_GBD
Represents a string value.
static string ToString(T5_StringUTF8 t5_StringUTF8)
T5_StringUTF8(string text)
void Dispose()
Safely disposes of this T5_StringUTF8 and any unmanaged memory allocated during its construction.