Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make code NativeAOT compatible #1609

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions headers/openvr_api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2023,7 +2023,7 @@ public class CVRSystem
IVRSystem FnTable;
internal CVRSystem(IntPtr pInterface)
{
FnTable = (IVRSystem)Marshal.PtrToStructure(pInterface, typeof(IVRSystem));
FnTable = Marshal.PtrToStructure<IVRSystem>(pInterface);
}
public void GetRecommendedRenderTargetSize(ref uint pnWidth,ref uint pnHeight)
{
Expand Down Expand Up @@ -2196,7 +2196,7 @@ public bool PollNextEvent(ref VREvent_t pEvent,uint uncbVREvent)
VREvent_t_Packed event_packed = new VREvent_t_Packed();
u.pPollNextEventPacked = null;
u.pPollNextEvent = FnTable.PollNextEvent;
bool packed_result = u.pPollNextEventPacked(ref event_packed,(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VREvent_t_Packed)));
bool packed_result = u.pPollNextEventPacked(ref event_packed,(uint)System.Runtime.InteropServices.Marshal.SizeOf<VREvent_t_Packed>());

event_packed.Unpack(ref pEvent);
return packed_result;
Expand Down Expand Up @@ -2242,7 +2242,7 @@ public bool GetControllerState(uint unControllerDeviceIndex,ref VRControllerStat
VRControllerState_t_Packed state_packed = new VRControllerState_t_Packed(pControllerState);
u.pGetControllerStatePacked = null;
u.pGetControllerState = FnTable.GetControllerState;
bool packed_result = u.pGetControllerStatePacked(unControllerDeviceIndex,ref state_packed,(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VRControllerState_t_Packed)));
bool packed_result = u.pGetControllerStatePacked(unControllerDeviceIndex,ref state_packed,(uint)System.Runtime.InteropServices.Marshal.SizeOf<VRControllerState_t_Packed>());

state_packed.Unpack(ref pControllerState);
return packed_result;
Expand Down Expand Up @@ -2273,7 +2273,7 @@ public bool GetControllerStateWithPose(ETrackingUniverseOrigin eOrigin,uint unCo
VRControllerState_t_Packed state_packed = new VRControllerState_t_Packed(pControllerState);
u.pGetControllerStateWithPosePacked = null;
u.pGetControllerStateWithPose = FnTable.GetControllerStateWithPose;
bool packed_result = u.pGetControllerStateWithPosePacked(eOrigin,unControllerDeviceIndex,ref state_packed,(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VRControllerState_t_Packed)),ref pTrackedDevicePose);
bool packed_result = u.pGetControllerStateWithPosePacked(eOrigin,unControllerDeviceIndex,ref state_packed,(uint)System.Runtime.InteropServices.Marshal.SizeOf<VRControllerState_t_Packed>(),ref pTrackedDevicePose);

state_packed.Unpack(ref pControllerState);
return packed_result;
Expand Down Expand Up @@ -2343,7 +2343,7 @@ public class CVRExtendedDisplay
IVRExtendedDisplay FnTable;
internal CVRExtendedDisplay(IntPtr pInterface)
{
FnTable = (IVRExtendedDisplay)Marshal.PtrToStructure(pInterface, typeof(IVRExtendedDisplay));
FnTable = Marshal.PtrToStructure<IVRExtendedDisplay>(pInterface);
}
public void GetWindowBounds(ref int pnX,ref int pnY,ref uint pnWidth,ref uint pnHeight)
{
Expand Down Expand Up @@ -2375,7 +2375,7 @@ public class CVRTrackedCamera
IVRTrackedCamera FnTable;
internal CVRTrackedCamera(IntPtr pInterface)
{
FnTable = (IVRTrackedCamera)Marshal.PtrToStructure(pInterface, typeof(IVRTrackedCamera));
FnTable = Marshal.PtrToStructure<IVRTrackedCamera>(pInterface);
}
public string GetCameraErrorNameFromEnum(EVRTrackedCameraError eCameraError)
{
Expand Down Expand Up @@ -2462,7 +2462,7 @@ public class CVRApplications
IVRApplications FnTable;
internal CVRApplications(IntPtr pInterface)
{
FnTable = (IVRApplications)Marshal.PtrToStructure(pInterface, typeof(IVRApplications));
FnTable = Marshal.PtrToStructure<IVRApplications>(pInterface);
}
public EVRApplicationError AddApplicationManifest(string pchApplicationManifestFullPath,bool bTemporary)
{
Expand Down Expand Up @@ -2674,7 +2674,7 @@ public class CVRChaperone
IVRChaperone FnTable;
internal CVRChaperone(IntPtr pInterface)
{
FnTable = (IVRChaperone)Marshal.PtrToStructure(pInterface, typeof(IVRChaperone));
FnTable = Marshal.PtrToStructure<IVRChaperone>(pInterface);
}
public ChaperoneCalibrationState GetCalibrationState()
{
Expand Down Expand Up @@ -2726,7 +2726,7 @@ public class CVRChaperoneSetup
IVRChaperoneSetup FnTable;
internal CVRChaperoneSetup(IntPtr pInterface)
{
FnTable = (IVRChaperoneSetup)Marshal.PtrToStructure(pInterface, typeof(IVRChaperoneSetup));
FnTable = Marshal.PtrToStructure<IVRChaperoneSetup>(pInterface);
}
public bool CommitWorkingCopy(EChaperoneConfigFile configFile)
{
Expand Down Expand Up @@ -2837,7 +2837,7 @@ public class CVRCompositor
IVRCompositor FnTable;
internal CVRCompositor(IntPtr pInterface)
{
FnTable = (IVRCompositor)Marshal.PtrToStructure(pInterface, typeof(IVRCompositor));
FnTable = Marshal.PtrToStructure<IVRCompositor>(pInterface);
}
public void SetTrackingSpace(ETrackingUniverseOrigin eOrigin)
{
Expand Down Expand Up @@ -3086,7 +3086,7 @@ public class CVROverlay
IVROverlay FnTable;
internal CVROverlay(IntPtr pInterface)
{
FnTable = (IVROverlay)Marshal.PtrToStructure(pInterface, typeof(IVROverlay));
FnTable = Marshal.PtrToStructure<IVROverlay>(pInterface);
}
public EVROverlayError FindOverlay(string pchOverlayKey,ref ulong pOverlayHandle)
{
Expand Down Expand Up @@ -3362,7 +3362,7 @@ public bool PollNextOverlayEvent(ulong ulOverlayHandle,ref VREvent_t pEvent,uint
VREvent_t_Packed event_packed = new VREvent_t_Packed();
u.pPollNextOverlayEventPacked = null;
u.pPollNextOverlayEvent = FnTable.PollNextOverlayEvent;
bool packed_result = u.pPollNextOverlayEventPacked(ulOverlayHandle,ref event_packed,(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VREvent_t_Packed)));
bool packed_result = u.pPollNextOverlayEventPacked(ulOverlayHandle,ref event_packed,(uint)System.Runtime.InteropServices.Marshal.SizeOf<VREvent_t_Packed>());

event_packed.Unpack(ref pEvent);
return packed_result;
Expand Down Expand Up @@ -3575,7 +3575,7 @@ public class CVROverlayView
IVROverlayView FnTable;
internal CVROverlayView(IntPtr pInterface)
{
FnTable = (IVROverlayView)Marshal.PtrToStructure(pInterface, typeof(IVROverlayView));
FnTable = Marshal.PtrToStructure<IVROverlayView>(pInterface);
}
public EVROverlayError AcquireOverlayView(ulong ulOverlayHandle,ref VRNativeDevice_t pNativeDevice,ref VROverlayView_t pOverlayView,uint unOverlayViewSize)
{
Expand Down Expand Up @@ -3604,7 +3604,7 @@ public class CVRHeadsetView
IVRHeadsetView FnTable;
internal CVRHeadsetView(IntPtr pInterface)
{
FnTable = (IVRHeadsetView)Marshal.PtrToStructure(pInterface, typeof(IVRHeadsetView));
FnTable = Marshal.PtrToStructure<IVRHeadsetView>(pInterface);
}
public void SetHeadsetViewSize(uint nWidth,uint nHeight)
{
Expand Down Expand Up @@ -3657,7 +3657,7 @@ public class CVRRenderModels
IVRRenderModels FnTable;
internal CVRRenderModels(IntPtr pInterface)
{
FnTable = (IVRRenderModels)Marshal.PtrToStructure(pInterface, typeof(IVRRenderModels));
FnTable = Marshal.PtrToStructure<IVRRenderModels>(pInterface);
}
public EVRRenderModelError LoadRenderModel_Async(string pchRenderModelName,ref IntPtr ppRenderModel)
{
Expand Down Expand Up @@ -3815,7 +3815,7 @@ public class CVRNotifications
IVRNotifications FnTable;
internal CVRNotifications(IntPtr pInterface)
{
FnTable = (IVRNotifications)Marshal.PtrToStructure(pInterface, typeof(IVRNotifications));
FnTable = Marshal.PtrToStructure<IVRNotifications>(pInterface);
}
public EVRNotificationError CreateNotification(ulong ulOverlayHandle,ulong ulUserValue,EVRNotificationType type,string pchText,EVRNotificationStyle style,ref NotificationBitmap_t pImage,ref uint pNotificationId)
{
Expand All @@ -3838,7 +3838,7 @@ public class CVRSettings
IVRSettings FnTable;
internal CVRSettings(IntPtr pInterface)
{
FnTable = (IVRSettings)Marshal.PtrToStructure(pInterface, typeof(IVRSettings));
FnTable = Marshal.PtrToStructure<IVRSettings>(pInterface);
}
public string GetSettingsErrorNameFromEnum(EVRSettingsError eError)
{
Expand Down Expand Up @@ -3936,7 +3936,7 @@ public class CVRScreenshots
IVRScreenshots FnTable;
internal CVRScreenshots(IntPtr pInterface)
{
FnTable = (IVRScreenshots)Marshal.PtrToStructure(pInterface, typeof(IVRScreenshots));
FnTable = Marshal.PtrToStructure<IVRScreenshots>(pInterface);
}
public EVRScreenshotError RequestScreenshot(ref uint pOutScreenshotHandle,EVRScreenshotType type,string pchPreviewFilename,string pchVRFilename)
{
Expand Down Expand Up @@ -3995,7 +3995,7 @@ public class CVRResources
IVRResources FnTable;
internal CVRResources(IntPtr pInterface)
{
FnTable = (IVRResources)Marshal.PtrToStructure(pInterface, typeof(IVRResources));
FnTable = Marshal.PtrToStructure<IVRResources>(pInterface);
}
public uint LoadSharedResource(string pchResourceName,string pchBuffer,uint unBufferLen)
{
Expand All @@ -4021,7 +4021,7 @@ public class CVRDriverManager
IVRDriverManager FnTable;
internal CVRDriverManager(IntPtr pInterface)
{
FnTable = (IVRDriverManager)Marshal.PtrToStructure(pInterface, typeof(IVRDriverManager));
FnTable = Marshal.PtrToStructure<IVRDriverManager>(pInterface);
}
public uint GetDriverCount()
{
Expand Down Expand Up @@ -4053,7 +4053,7 @@ public class CVRInput
IVRInput FnTable;
internal CVRInput(IntPtr pInterface)
{
FnTable = (IVRInput)Marshal.PtrToStructure(pInterface, typeof(IVRInput));
FnTable = Marshal.PtrToStructure<IVRInput>(pInterface);
}
public EVRInputError SetActionManifestPath(string pchActionManifestPath)
{
Expand Down Expand Up @@ -4243,7 +4243,7 @@ public class CVRIOBuffer
IVRIOBuffer FnTable;
internal CVRIOBuffer(IntPtr pInterface)
{
FnTable = (IVRIOBuffer)Marshal.PtrToStructure(pInterface, typeof(IVRIOBuffer));
FnTable = Marshal.PtrToStructure<IVRIOBuffer>(pInterface);
}
public EIOBufferError Open(string pchPath,EIOBufferMode mode,uint unElementSize,uint unElements,ref ulong pulBuffer)
{
Expand Down Expand Up @@ -4287,7 +4287,7 @@ public class CVRSpatialAnchors
IVRSpatialAnchors FnTable;
internal CVRSpatialAnchors(IntPtr pInterface)
{
FnTable = (IVRSpatialAnchors)Marshal.PtrToStructure(pInterface, typeof(IVRSpatialAnchors));
FnTable = Marshal.PtrToStructure<IVRSpatialAnchors>(pInterface);
}
public EVRSpatialAnchorError CreateSpatialAnchorFromDescriptor(string pchDescriptor,ref uint pHandleOut)
{
Expand Down Expand Up @@ -4322,7 +4322,7 @@ public class CVRDebug
IVRDebug FnTable;
internal CVRDebug(IntPtr pInterface)
{
FnTable = (IVRDebug)Marshal.PtrToStructure(pInterface, typeof(IVRDebug));
FnTable = Marshal.PtrToStructure<IVRDebug>(pInterface);
}
public EVRDebugError EmitVrProfilerEvent(string pchMessage)
{
Expand Down Expand Up @@ -4359,7 +4359,7 @@ public class CVRProperties
IVRProperties FnTable;
internal CVRProperties(IntPtr pInterface)
{
FnTable = (IVRProperties)Marshal.PtrToStructure(pInterface, typeof(IVRProperties));
FnTable = Marshal.PtrToStructure<IVRProperties>(pInterface);
}
public ETrackedPropertyError ReadPropertyBatch(ulong ulContainerHandle,ref PropertyRead_t pBatch,uint unBatchEntryCount)
{
Expand Down Expand Up @@ -4389,7 +4389,7 @@ public class CVRPaths
IVRPaths FnTable;
internal CVRPaths(IntPtr pInterface)
{
FnTable = (IVRPaths)Marshal.PtrToStructure(pInterface, typeof(IVRPaths));
FnTable = Marshal.PtrToStructure<IVRPaths>(pInterface);
}
public ETrackedPropertyError ReadPathBatch(ulong ulRootHandle,ref PathRead_t pBatch,uint unBatchEntryCount)
{
Expand Down Expand Up @@ -4423,7 +4423,7 @@ public class CVRBlockQueue
IVRBlockQueue FnTable;
internal CVRBlockQueue(IntPtr pInterface)
{
FnTable = (IVRBlockQueue)Marshal.PtrToStructure(pInterface, typeof(IVRBlockQueue));
FnTable = Marshal.PtrToStructure<IVRBlockQueue>(pInterface);
}
public EBlockQueueError Create(ref ulong pulQueueHandle,string pchPath,uint unBlockDataSize,uint unBlockHeaderSize,uint unBlockCount)
{
Expand Down
36 changes: 18 additions & 18 deletions samples/unity_keyboard_sample/Assets/Plugins/openvr_api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ public class CVRSystem
IVRSystem FnTable;
internal CVRSystem(IntPtr pInterface)
{
FnTable = (IVRSystem)Marshal.PtrToStructure(pInterface, typeof(IVRSystem));
FnTable = Marshal.PtrToStructure<IVRSystem>(pInterface);
}
public void GetRecommendedRenderTargetSize(ref uint pnWidth,ref uint pnHeight)
{
Expand Down Expand Up @@ -1331,7 +1331,7 @@ public uint GetStringTrackedDeviceProperty(uint unDeviceIndex,ETrackedDeviceProp
public string GetPropErrorNameFromEnum(ETrackedPropertyError error)
{
IntPtr result = FnTable.GetPropErrorNameFromEnum(error);
return (string) Marshal.PtrToStructure(result, typeof(string));
return Marshal.PtrToStringAnsi(result);
}
public bool PollNextEvent(ref VREvent_t pEvent,uint uncbVREvent)
{
Expand All @@ -1346,7 +1346,7 @@ public bool PollNextEventWithPose(ETrackingUniverseOrigin eOrigin,ref VREvent_t
public string GetEventTypeNameFromEnum(EVREventType eType)
{
IntPtr result = FnTable.GetEventTypeNameFromEnum(eType);
return (string) Marshal.PtrToStructure(result, typeof(string));
return Marshal.PtrToStringAnsi(result);
}
public HiddenAreaMesh_t GetHiddenAreaMesh(EVREye eEye)
{
Expand All @@ -1370,12 +1370,12 @@ public void TriggerHapticPulse(uint unControllerDeviceIndex,uint unAxisId,char u
public string GetButtonIdNameFromEnum(EVRButtonId eButtonId)
{
IntPtr result = FnTable.GetButtonIdNameFromEnum(eButtonId);
return (string) Marshal.PtrToStructure(result, typeof(string));
return Marshal.PtrToStringAnsi(result);
}
public string GetControllerAxisTypeNameFromEnum(EVRControllerAxisType eAxisType)
{
IntPtr result = FnTable.GetControllerAxisTypeNameFromEnum(eAxisType);
return (string) Marshal.PtrToStructure(result, typeof(string));
return Marshal.PtrToStringAnsi(result);
}
public bool CaptureInputFocus()
{
Expand Down Expand Up @@ -1417,7 +1417,7 @@ public class CVRExtendedDisplay
IVRExtendedDisplay FnTable;
internal CVRExtendedDisplay(IntPtr pInterface)
{
FnTable = (IVRExtendedDisplay)Marshal.PtrToStructure(pInterface, typeof(IVRExtendedDisplay));
FnTable = Marshal.PtrToStructure<IVRExtendedDisplay>(pInterface);
}
public void GetWindowBounds(ref int pnX,ref int pnY,ref uint pnWidth,ref uint pnHeight)
{
Expand Down Expand Up @@ -1449,7 +1449,7 @@ public class CVRApplications
IVRApplications FnTable;
internal CVRApplications(IntPtr pInterface)
{
FnTable = (IVRApplications)Marshal.PtrToStructure(pInterface, typeof(IVRApplications));
FnTable = Marshal.PtrToStructure<IVRApplications>(pInterface);
}
public EVRApplicationError AddApplicationManifest(string pchApplicationManifestFullPath,bool bTemporary)
{
Expand Down Expand Up @@ -1514,7 +1514,7 @@ public uint GetApplicationProcessId(string pchAppKey)
public string GetApplicationsErrorNameFromEnum(EVRApplicationError error)
{
IntPtr result = FnTable.GetApplicationsErrorNameFromEnum(error);
return (string) Marshal.PtrToStructure(result, typeof(string));
return Marshal.PtrToStringAnsi(result);
}
public uint GetApplicationPropertyString(string pchAppKey,EVRApplicationProperty eProperty,string pchPropertyValueBuffer,uint unPropertyValueBufferLen,ref EVRApplicationError peError)
{
Expand Down Expand Up @@ -1559,7 +1559,7 @@ public EVRApplicationError PerformApplicationPrelaunchCheck(string pchAppKey)
public string GetApplicationsTransitionStateNameFromEnum(EVRApplicationTransitionState state)
{
IntPtr result = FnTable.GetApplicationsTransitionStateNameFromEnum(state);
return (string) Marshal.PtrToStructure(result, typeof(string));
return Marshal.PtrToStringAnsi(result);
}
public bool IsQuitUserPromptRequested()
{
Expand All @@ -1579,7 +1579,7 @@ public class CVRChaperone
IVRChaperone FnTable;
internal CVRChaperone(IntPtr pInterface)
{
FnTable = (IVRChaperone)Marshal.PtrToStructure(pInterface, typeof(IVRChaperone));
FnTable = Marshal.PtrToStructure<IVRChaperone>(pInterface);
}
public ChaperoneCalibrationState GetCalibrationState()
{
Expand Down Expand Up @@ -1627,7 +1627,7 @@ public class CVRChaperoneSetup
IVRChaperoneSetup FnTable;
internal CVRChaperoneSetup(IntPtr pInterface)
{
FnTable = (IVRChaperoneSetup)Marshal.PtrToStructure(pInterface, typeof(IVRChaperoneSetup));
FnTable = Marshal.PtrToStructure<IVRChaperoneSetup>(pInterface);
}
public bool CommitWorkingCopy(EChaperoneConfigFile configFile)
{
Expand Down Expand Up @@ -1745,7 +1745,7 @@ public class CVRCompositor
IVRCompositor FnTable;
internal CVRCompositor(IntPtr pInterface)
{
FnTable = (IVRCompositor)Marshal.PtrToStructure(pInterface, typeof(IVRCompositor));
FnTable = Marshal.PtrToStructure<IVRCompositor>(pInterface);
}
public void SetTrackingSpace(ETrackingUniverseOrigin eOrigin)
{
Expand Down Expand Up @@ -1885,7 +1885,7 @@ public class CVROverlay
IVROverlay FnTable;
internal CVROverlay(IntPtr pInterface)
{
FnTable = (IVROverlay)Marshal.PtrToStructure(pInterface, typeof(IVROverlay));
FnTable = Marshal.PtrToStructure<IVROverlay>(pInterface);
}
public EVROverlayError FindOverlay(string pchOverlayKey,ref ulong pOverlayHandle)
{
Expand Down Expand Up @@ -1934,7 +1934,7 @@ public EVROverlayError GetOverlayImageData(ulong ulOverlayHandle,IntPtr pvBuffer
public string GetOverlayErrorNameFromEnum(EVROverlayError error)
{
IntPtr result = FnTable.GetOverlayErrorNameFromEnum(error);
return (string) Marshal.PtrToStructure(result, typeof(string));
return Marshal.PtrToStringAnsi(result);
}
public EVROverlayError SetOverlayRenderingPid(ulong ulOverlayHandle,uint unPID)
{
Expand Down Expand Up @@ -2246,7 +2246,7 @@ public class CVRRenderModels
IVRRenderModels FnTable;
internal CVRRenderModels(IntPtr pInterface)
{
FnTable = (IVRRenderModels)Marshal.PtrToStructure(pInterface, typeof(IVRRenderModels));
FnTable = Marshal.PtrToStructure<IVRRenderModels>(pInterface);
}
public EVRRenderModelError LoadRenderModel_Async(string pchRenderModelName,ref IntPtr ppRenderModel)
{
Expand Down Expand Up @@ -2328,7 +2328,7 @@ public class CVRNotifications
IVRNotifications FnTable;
internal CVRNotifications(IntPtr pInterface)
{
FnTable = (IVRNotifications)Marshal.PtrToStructure(pInterface, typeof(IVRNotifications));
FnTable = Marshal.PtrToStructure<IVRNotifications>(pInterface);
}
public EVRNotificationError CreateNotification(ulong ulOverlayHandle,ulong ulUserValue,EVRNotificationType type,string pchText,EVRNotificationStyle style,ref NotificationBitmap_t pImage,ref uint pNotificationId)
{
Expand All @@ -2349,12 +2349,12 @@ public class CVRSettings
IVRSettings FnTable;
internal CVRSettings(IntPtr pInterface)
{
FnTable = (IVRSettings)Marshal.PtrToStructure(pInterface, typeof(IVRSettings));
FnTable = Marshal.PtrToStructure<IVRSettings>(pInterface);
}
public string GetSettingsErrorNameFromEnum(EVRSettingsError eError)
{
IntPtr result = FnTable.GetSettingsErrorNameFromEnum(eError);
return (string) Marshal.PtrToStructure(result, typeof(string));
return Marshal.PtrToStringAnsi(result);
}
public bool Sync(bool bForce,ref EVRSettingsError peError)
{
Expand Down
Loading