/****************************************************************************
* Copyright 2019 Nreal Techonology Limited. All rights reserved.
*
* This file is part of NRSDK.
*
* https://www.nreal.ai/
*
*****************************************************************************/
namespace NRKernal
{
using System;
using System.Runtime.InteropServices;
///
/// The callback method type which will be called when put on or take off nreal glasses.
/// glasses_control_handle The handle of GlassesControl.
/// wear_or_not , 1: put on glasses . 0: take off glasses.
/// The custom user data.
public delegate void NRGlassesControlWearCallback(UInt64 glasses_control_handle, int wearing_status, UInt64 user_data);
///
/// The callback method type which will be called when plug off nreal glasses.
/// glasses_control_handle The handle of GlassesControl.
/// The custom user data.
public delegate void NRGlassesControlPlugOffCallback(UInt64 glasses_control_handle, UInt64 user_data);
///
/// The callback method type which will be called when plug off nreal glasses.
/// glasses_control_handle The handle of GlassesControl.
/// user_data The custom user data.
/// The reason of glasses disconnect.
public delegate void NRGlassesControlNotifyQuitAppCallback(UInt64 glasses_control_handle, IntPtr user_data, GlassesDisconnectReason reason);
/// A controller for handling native glasses.
public partial class NativeGlassesController
{
/// Handle of the glasses controller.
private UInt64 m_GlassesControllerHandle = 0;
/// Gets the handle of the glasses controller.
/// The glasses controller handle.
public UInt64 GlassesControllerHandle
{
get
{
return m_GlassesControllerHandle;
}
}
/// Creates this object.
public void Create()
{
NativeResult result = NativeApi.NRGlassesControlCreate(ref m_GlassesControllerHandle);
NativeErrorListener.Check(result, this, "Create");
}
/// Back, called when the regis glasses wear.
/// The callback.
/// The userdata.
public void RegisGlassesWearCallBack(NRGlassesControlWearCallback callback, ulong userdata)
{
NativeResult result = NativeApi.NRGlassesControlSetGlassesWearingCallback(m_GlassesControllerHandle, callback, userdata);
NativeErrorListener.Check(result, this, "RegisGlassesWearCallBack");
}
/// Gets temprature level.
/// The temprature level.
public GlassesTemperatureLevel GetTempratureLevel()
{
GlassesTemperatureLevel level = GlassesTemperatureLevel.TEMPERATURE_LEVEL_NORMAL;
NativeResult result = NativeApi.NRGlassesControlGetTemperatureLevel(m_GlassesControllerHandle, ref level);
NativeErrorListener.Check(result, this, "GetTempratureLevel");
return level;
}
/// Back, called when the regis glasses plug out.
/// The callback.
/// The userdata.
public void RegisGlassesPlugOutCallBack(NRGlassesControlPlugOffCallback callback, ulong userdata)
{
NativeResult result = NativeApi.NRGlassesControlSetGlassesDisconnectedCallback(m_GlassesControllerHandle, callback, userdata);
NativeErrorListener.Check(result, this, "RegisGlassesPlugOutCallBack");
}
/// Back, called when the regist glasses event.
/// The callback.
public void RegistGlassesEventCallBack(NRGlassesControlNotifyQuitAppCallback callback)
{
NativeResult result = NativeApi.NRGlassesControlSetNotifyQuitAppCallback(m_GlassesControllerHandle, callback, 0);
NativeErrorListener.Check(result, this, "RegistGlassesEventCallBack");
}
/// Starts this object.
public void Start()
{
NativeResult result = NativeApi.NRGlassesControlStart(m_GlassesControllerHandle);
NativeErrorListener.Check(result, this, "Start", true);
}
/// Pauses this object.
public void Pause()
{
NativeResult result = NativeApi.NRGlassesControlPause(m_GlassesControllerHandle);
NativeErrorListener.Check(result, this, "Pause", true);
}
/// Resumes this object.
public void Resume()
{
NativeResult result = NativeApi.NRGlassesControlResume(m_GlassesControllerHandle);
NativeErrorListener.Check(result, this, "Resume", true);
}
/// Stops this object.
public void Stop()
{
NativeResult result = NativeApi.NRGlassesControlStop(m_GlassesControllerHandle);
NativeErrorListener.Check(result, this, "Stop");
}
/// Destroys this object.
public void Destroy()
{
NativeResult result = NativeApi.NRGlassesControlDestroy(m_GlassesControllerHandle);
NativeErrorListener.Check(result, this, "Destroy");
}
private partial struct NativeApi
{
/// Create the GlassesControl object.
/// [in,out] The handle of GlassesControl.
/// The result of operation.
[DllImport(NativeConstants.NRNativeLibrary)]
public static extern NativeResult NRGlassesControlCreate(ref UInt64 out_glasses_control_handle);
/// Start the GlassesControl system.
/// The handle of GlassesControl.
/// The result of operation.
[DllImport(NativeConstants.NRNativeLibrary)]
public static extern NativeResult NRGlassesControlStart(UInt64 glasses_control_handle);
/// Pause the GlassesControl system.
/// The handle of GlassesControl.
/// The result of operation.
[DllImport(NativeConstants.NRNativeLibrary)]
public static extern NativeResult NRGlassesControlPause(UInt64 glasses_control_handle);
/// Resume the GlassesControl system.
/// The handle of GlassesControl.
/// The result of operation.
[DllImport(NativeConstants.NRNativeLibrary)]
public static extern NativeResult NRGlassesControlResume(UInt64 glasses_control_handle);
/// Stop the GlassesControl system.
/// The handle of GlassesControl.
/// The result of operation.
[DllImport(NativeConstants.NRNativeLibrary)]
public static extern NativeResult NRGlassesControlStop(UInt64 glasses_control_handle);
/// Release memory used by the GlassesControl.
/// The handle of GlassesControl.
/// The result of operation.
[DllImport(NativeConstants.NRNativeLibrary)]
public static extern NativeResult NRGlassesControlDestroy(UInt64 glasses_control_handle);
/// Nr glasses control get temperature level.
/// The handle of GlassesControl.
/// [in,out] The temperature level.
/// A NativeResult.
[DllImport(NativeConstants.NRNativeLibrary)]
public static extern NativeResult NRGlassesControlGetTemperatureLevel(UInt64 glasses_control_handle, ref GlassesTemperatureLevel temperature_level);
/// Set the callback method when put on or take off glasses.
/// The handle of GlassesControl.
/// The callback method.
/// The data which will be returned when callback is
/// triggered.
/// The result of operation.
[DllImport(NativeConstants.NRNativeLibrary)]
public static extern NativeResult NRGlassesControlSetGlassesWearingCallback(
UInt64 glasses_control_handle, NRGlassesControlWearCallback data_callback, UInt64 user_data);
///
/// Callback, called when the nr glasses control set notify quit application.
/// The handle of GlassesControl.
/// The callback.
/// The data which will be returned when callback is
/// triggered.
/// A NativeResult.
[DllImport(NativeConstants.NRNativeLibrary)]
public static extern NativeResult NRGlassesControlSetNotifyQuitAppCallback(UInt64 glasses_control_handle,
NRGlassesControlNotifyQuitAppCallback callback, UInt64 user_data);
/// Set the callback method when plug off the glasses.
/// The handle of GlassesControl.
/// The callback method.
/// The data which will be returned when callback is
/// triggered.
/// The result of operation.
[DllImport(NativeConstants.NRNativeLibrary)]
public static extern NativeResult NRGlassesControlSetGlassesDisconnectedCallback(
UInt64 glasses_control_handle, NRGlassesControlPlugOffCallback data_callback, UInt64 user_data);
}
}
}