using System; using MagicLeap.OpenXR.Futures; using UnityEngine; using UnityEngine.XR.OpenXR.NativeTypes; namespace MagicLeap.OpenXR.Features.PixelSensors { internal unsafe class PixelSensorNativeFunctions : FuturesNativeFunctions { internal delegate* unmanaged [Cdecl] XrEnumeratePixelSensors; internal delegate* unmanaged [Cdecl] XrCreatePixelSensor; internal delegate* unmanaged [Cdecl] XrDestroyPixelSensor; internal delegate* unmanaged [Cdecl] XrGetPixelSensorStreamCount; internal delegate* unmanaged [Cdecl] XrEnumeratePixelSensorCapabilities; internal delegate* unmanaged [Cdecl] XrQueryPixelSensorCapabilities; internal delegate* unmanaged [Cdecl] XrConfigurePixelSensorAsync; internal delegate* unmanaged [Cdecl] XrConfigurePixelSensorComplete; internal delegate* unmanaged [Cdecl] XrEnumeratePixelSensorMetadata; internal delegate* unmanaged [Cdecl] XrStartPixelSensorAsync; internal delegate* unmanaged [Cdecl] XrStartPixelSensorComplete; internal delegate* unmanaged [Cdecl] XrStopPixelSensorAsync; internal delegate* unmanaged [Cdecl] XrStopPixelSensorComplete; internal delegate* unmanaged [Cdecl] XrGetPixelSensorBufferProperties; internal delegate* unmanaged [Cdecl] XrGetPixelSensorData; internal delegate* unmanaged [Cdecl] XrCreatePixelSensorSpace; protected override void Validate() { base.Validate(); if (XrEnumeratePixelSensors == null) { Debug.LogError("Unable to find XrEnumeratePixelSensors"); } if (XrCreatePixelSensor == null) { Debug.LogError("Unable to find XrCreatePixelSensor"); } if (XrDestroyPixelSensor == null) { Debug.LogError("Unable to find XrDestroyPixelSensor"); } if (XrGetPixelSensorStreamCount == null) { Debug.LogError("Unable to find XrGetPixelSensorStreamCount"); } if (XrEnumeratePixelSensorCapabilities == null) { Debug.LogError("Unable to find XrEnumeratePixelSensorCapabilities"); } if (XrQueryPixelSensorCapabilities == null) { Debug.LogError("Unable to find XrQueryPixelSensorCapabilities"); } if (XrConfigurePixelSensorAsync == null) { Debug.LogError("Unable to find XrConfigurePixelSensorAsync"); } if (XrConfigurePixelSensorComplete == null) { Debug.LogError("Unable to find XrConfigurePixelSensorComplete"); } if (XrEnumeratePixelSensorMetadata == null) { Debug.LogError("Unable to find XrEnumeratePixelSensorMetaData"); } if (XrStartPixelSensorAsync == null) { Debug.LogError("Unable to find XrStartPixelSensorAsync"); } if (XrStartPixelSensorComplete == null) { Debug.LogError("Unable to find XrStartPixelSensorComplete"); } if (XrStopPixelSensorAsync == null) { Debug.LogError("Unable to find XrStopPixelSensorAsync"); } if (XrStopPixelSensorComplete == null) { Debug.LogError("Unable to find XrStopPixelSensorComplete"); } if (XrGetPixelSensorBufferProperties == null) { Debug.LogError("Unable to find XrGetPixelSensorBufferProperties"); } if (XrGetPixelSensorData == null) { Debug.LogError("Unable to find XrGetPixelSensorData"); } if (XrCreatePixelSensorSpace == null) { Debug.LogError("Unable to find XrCreatePixelSensorSpace"); } } private string SanitizeFunctionName(string input) { return $"{input.Replace("Xr", "xr")}ML"; } protected override void LocateNativeFunctions() { base.LocateNativeFunctions(); XrEnumeratePixelSensors = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrEnumeratePixelSensors))); XrCreatePixelSensor = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrCreatePixelSensor))); XrDestroyPixelSensor = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrDestroyPixelSensor))); XrGetPixelSensorStreamCount = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrGetPixelSensorStreamCount))); XrEnumeratePixelSensorCapabilities = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrEnumeratePixelSensorCapabilities))); XrQueryPixelSensorCapabilities = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrQueryPixelSensorCapabilities))); XrConfigurePixelSensorAsync = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrConfigurePixelSensorAsync))); XrConfigurePixelSensorComplete = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrConfigurePixelSensorComplete))); XrEnumeratePixelSensorMetadata = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrEnumeratePixelSensorMetadata))); XrStartPixelSensorAsync = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrStartPixelSensorAsync))); XrStartPixelSensorComplete = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrStartPixelSensorComplete))); XrStopPixelSensorAsync = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrStopPixelSensorAsync))); XrStopPixelSensorComplete = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrStopPixelSensorComplete))); XrGetPixelSensorBufferProperties = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrGetPixelSensorBufferProperties))); XrGetPixelSensorData = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrGetPixelSensorData))); XrCreatePixelSensorSpace = (delegate* unmanaged[Cdecl])LocateNativeFunction(SanitizeFunctionName(nameof(XrCreatePixelSensorSpace))); } } }