// %BANNER_BEGIN%
// ---------------------------------------------------------------------
// %COPYRIGHT_BEGIN%
// Copyright (c) (2018-2022) Magic Leap, Inc. All Rights Reserved.
// Use of this file is governed by the Software License Agreement, located here: https://www.magicleap.com/software-license-agreement-ml2
// Terms and conditions applicable to third-party materials accompanying this distribution may also be found in the top-level NOTICE file appearing herein.
// %COPYRIGHT_END%
// ---------------------------------------------------------------------
// %BANNER_END%
namespace UnityEngine.XR.MagicLeap
{
using System.Runtime.InteropServices;
public partial class MLGazeRecognition
{
///
/// See ml_gaze_recognition.h for additional comments.
///
internal class NativeBindings : Native.MagicLeapNativeBindings
{
///
/// Static information about the Gaze Recognition system. Populate with MLGazeRecognitionGetStaticData().
///
[StructLayout(LayoutKind.Sequential)]
public readonly struct MLGazeRecognitionStaticData
{
///
/// Version of this structure.
///
public readonly uint Version;
///
/// The maximum value for the height of the eye_left and eye_right vector.
///
public readonly float EyeHeightMax;
///
/// The maximum value for the width of the eye_left and eye_right vector.
///
public readonly float EyeWidthMax;
///
/// Location of the 3D vergence point, intersection of 3D gaze vectors.
///
public readonly NativeBindings.MLCoordinateFrameUID Vergence;
public MLGazeRecognitionStaticData(uint setVersion)
{
Version = setVersion;
Vergence = MLCoordinateFrameUID.EmptyFrame;
EyeHeightMax = 0;
EyeWidthMax = 0;
}
};
///
/// Information about the state of the Gaze Recognition system. This structure must be initialized by calling
/// MLGazeRecognitionStateInit() before use.
///
[StructLayout(LayoutKind.Sequential)]
public readonly struct MLGazeRecognitionState
{
///
/// Version of this structure.
///
public readonly uint Version;
///
/// The timestamp accociated with all data fields in this struct, giving the headset clock.
///
public readonly long Timestamp;
///
/// Represents what gaze Recognition error (if any) is present.
///
public readonly Error Error;
///
/// Represents what known gaze Recognition behavior is present.
///
public readonly Behavior Behavior;
///
/// A vector for eye-in-skull position of left eye, even if right eye is closed
///
public readonly MLVec2f EyeLeft;
///
/// A vector for eye-in-skull position of right eye, even if left eye is closed.
///
public readonly MLVec2f EyeRight;
///
/// Metadata field for onset of the current behavior, in seconds. Onset applies to all behaviors and marks the time when the current behavior began.
///
public readonly float OnsetS;
///
/// Metadata field for duration of the current behavior, in seconds. Duration applies to all gaze types.
///
public readonly float DurationS;
///
/// Metadata field for velocity of the current movement, in degrees per second. Velocity field applies to saccades and
/// pursuit, otherwise NaN
///
public readonly float VelocityDegps;
///
/// Metadata field for amplitude of the current movement, which is eye-position displacement in degrees of visual angle. Amplitude applies to saccades and pursuit,
/// otherwise NaN
///
public readonly float AmplitudeDeg;
///
/// Metadata field for direction of the current movement, in radial degrees (0-360). Direction field applies to saccades
/// and pursuit, otherwise NaN
///
public readonly float DirectionRadial;
public MLGazeRecognitionState(uint setVersion)
{
Version = setVersion;
Timestamp = 0;
Error = Error.None;
Behavior = Behavior.Unknown;
EyeLeft.X = 0.0f;
EyeLeft.Y = 0.0f;
EyeRight.X = 0.0f;
EyeRight.Y = 0.0f;
OnsetS = 0.0f;
DurationS = 0.0f;
VelocityDegps = 0.0f;
AmplitudeDeg = 0.0f;
DirectionRadial = 0.0f;
}
};
///
/// Create Gaze Recognition.
///
/// A pointer to an #MLHandle which will contain a handle to Gaze Recognition.
/// If this operation fails, out_handle will be #ML_INVALID_HANDLE.
///
///
/// MLResult_InvalidParam The out_handle parameter was not valid (null).
/// MLResult_Ok Gaze Recognition was successfully created.
/// MLResult_UnspecifiedFaiure Gaze Recognition was not created successfully.
/// MLResult_PermissionDenied
///
[DllImport(MLGazeRecognitionDll, CallingConvention = CallingConvention.Cdecl)]
public static extern MLResult.Code MLGazeRecognitionCreate(out ulong handle);
///
/// Destroy Gaze Recognition.
///
/// A handle to Gaze Recognition created by MLGazeRecognitionCreate()
///
/// MLResult_Ok The Gaze Recognition was successfully destroyed.
/// MLResult_UnspecifiedFailure The Gaze Recognition was not successfully destroyed.
/// MLResult_InvalidParam The Gaze Recognition handle was not valid.
///
[DllImport(MLGazeRecognitionDll, CallingConvention = CallingConvention.Cdecl)]
public static extern MLResult.Code MLGazeRecognitionDestroy(ulong handle);
///
/// Get information about the user's gaze.
///
/// A handle to Gaze Recognition created byvMLGazeRecognitionCreate().
/// Information about the gaze.
///
/// MLResult_InvalidParam The state parameter was not valid (null).
/// MLResult_Ok gaze Recognition static was successfully received.
/// MLResult_UnspecifiedFailure Failed to receive gaze Recognition state data.
///
[DllImport(MLGazeRecognitionDll, CallingConvention = CallingConvention.Cdecl)]
public static extern MLResult.Code MLGazeRecognitionGetState(ulong handle, ref MLGazeRecognitionState state);
///
/// Get static information about Gaze Recognition.
///
/// A handle to Gaze Recognition created by MLGazeRecognitionCreate().
/// Target to populate the data about Gaze Recognition..
///
/// MLResult_InvalidParam The data parameter was not valid (null).
/// MLResult_Ok gaze Recognition data was successfully received.
/// MLResult_UnspecifiedFailure Failed to receive gaze Recognition static data.
///
[DllImport(MLGazeRecognitionDll, CallingConvention = CallingConvention.Cdecl)]
public static extern MLResult.Code MLGazeRecognitionGetStaticData(ulong handle, ref MLGazeRecognitionStaticData data);
}
}
}