include "fpxr/fpxr.h"

native enum fpxr::Result as Facepunch.XR.XRResult;
native enum fpxr::GraphicsAPI as Facepunch.XR.GraphicsAPI;
native enum fpxr::InputSource as Facepunch.XR.InputSource;

native struct fpxr::VulkanInfo as Facepunch.XR.VulkanInfo;
native struct fpxr::InstanceInfo as Facepunch.XR.InstanceInfo;
native struct fpxr::Event as Facepunch.XR.Event;
native struct fpxr::TextureSubmitInfo as Facepunch.XR.TextureSubmitInfo;
[small]
native struct fpxr::InputBooleanActionState as Facepunch.XR.InputBooleanActionState;
native struct fpxr::InputFloatActionState as Facepunch.XR.InputFloatActionState;
native struct fpxr::InputVector2ActionState as Facepunch.XR.InputVector2ActionState;
native struct fpxr::InputPoseActionState as Facepunch.XR.InputPoseActionState;
native struct fpxr::InputPoseHandState as Facepunch.XR.InputPoseHandState;
native struct fpxr::ViewInfo as Facepunch.XR.ViewInfo;
[small]
native struct fpxr::InstanceProperties as Facepunch.XR.InstanceProperties;
native struct fpxr::Matrix as Facepunch.XR.XrMatrix;

native enum fpxr::Finger as Sandbox.VR.FingerValue;
native enum fpxr::HandPoseMotionRange as Sandbox.VR.MotionRange;

native class fpxr::ApplicationConfig as Facepunch.XR.ApplicationConfig
{
    inline static void SetDebugCallback( IntPtr dbgCallback )
    {
        fpxr::ApplicationConfig::GetInstance().m_debugCallback = (fpxr::PFN_DebugCallback)dbgCallback;
    }

    inline static void SetErrorCallback( IntPtr errCallback )
    {
        fpxr::ApplicationConfig::GetInstance().m_errorCallback = (fpxr::PFN_ErrorCallback)errCallback;
    }
}

native class fpxr::EventManager as Facepunch.XR.EventManager
{
    inline XRResult PumpEvent( out Event ev )
    {
        return this->PumpEvent( *ev );
    }
}

native class fpxr::Compositor as Facepunch.XR.Compositor
{
    EventManager EventManager();

    XRResult Submit( TextureSubmitInfo info );

    XRResult BeginFrame();
    XRResult EndFrame();

    uint GetEyeWidth();
    uint GetEyeHeight();
    uint GetRenderTargetWidth();
    uint GetRenderTargetHeight();

    float GetDisplayRefreshRate();

    XRResult GetViewInfo( uint viewIndex, out ViewInfo outViewInfo );
    XRResult GetProjectionMatrix( uint viewIndex, float flNearZ, float flFarZ, out XrMatrix outViewInfo );
}

native class fpxr::Input as Facepunch.XR.Input
{
    XRResult GetBooleanActionState( string path, InputSource inputSource, out InputBooleanActionState outState );
    XRResult GetFloatActionState( string path, InputSource inputSource, out InputFloatActionState outState );
    XRResult GetVector2ActionState( string path, InputSource inputSource, out InputVector2ActionState outState );
    XRResult GetPoseActionState( string path, InputSource inputSource, out InputPoseActionState outState );

    XRResult TriggerHapticVibration(float duration, float frequency, float amplitude, InputSource inputSource);

    XRResult GetHandPoseState(InputSource inputSource, MotionRange motionRange, out InputPoseHandState outState);
    float GetFingerCurl(InputSource inputSource, FingerValue finger);
}

[WindowsOnly]
native class fpxr::Instance as Facepunch.XR.Instance
{
    inline static Instance Create(InstanceInfo instanceInfo) [new]
    {
        return fpxr::Init( instanceInfo );
    }

    inline static bool HasHeadset()
    {
        return fpxr::HasHeadset();
    }

    Compositor Compositor( VulkanInfo vulkanInfo );
    Input Input();

    inline string GetRequiredDeviceExtensions()
    {
        return this->GetDeviceExtensions();
    }

    inline string GetRequiredInstanceExtensions()
    {
        return this->GetInstanceExtensions();
    }

    InstanceProperties GetProperties();
}