Open lukexi opened 8 years ago
I had to make some modifications to get openvr_capi.h to compile as a C file.
openvr_capi.h
I'd do a pull request but I know the file is autogenerated, so I'll just list the changes here:
S_API
extern "C"
vr::
VREvent_t
VR_IVRControlPanel_GetCurrentCompositorInterface
class IVRCompositor *
intptr_t
const
Along with the already reported:
VR_Event_Data_t
VREvent_Overlay_t
VREvent_Status_t
VREvent_Keyboard_t
VREvent_Chaperone_t
VREvent_Ipd_t
ButtonMaskFromId
Here's the diff
diff --git a/headers/openvr_capi.h b/headers/openvr_capi.h index a2fbff3..bc2bbba 100644 --- a/headers/openvr_capi.h +++ b/headers/openvr_capi.h @@ -14,23 +14,23 @@ // OPENVR API export macro #if defined( _WIN32 ) && !defined( _X360 ) #if defined( OPENVR_API_EXPORTS ) - #define S_API extern "C" __declspec( dllexport ) + #define S_API __declspec( dllexport ) #elif defined( OPENVR_API_NODLL ) - #define S_API extern "C" + #define S_API #else - #define S_API extern "C" __declspec( dllimport ) + #define S_API __declspec( dllimport ) #endif // OPENVR_API_EXPORTS #elif defined( GNUC ) #if defined( OPENVR_API_EXPORTS ) - #define S_API extern "C" __attribute__ ((visibility("default"))) + #define S_API __attribute__ ((visibility("default"))) #else - #define S_API extern "C" + #define S_API #endif // OPENVR_API_EXPORTS #else // !WIN32 #if defined( OPENVR_API_EXPORTS ) - #define S_API extern "C" + #define S_API #else - #define S_API extern "C" + #define S_API #endif // OPENVR_API_EXPORTS #endif @@ -38,6 +38,18 @@ typedef char bool; +/** Status of the overall system or tracked objects */ +typedef enum EVRState +{ + VRState_Undefined = -1, + VRState_Off = 0, + VRState_Searching = 1, + VRState_Searching_Alert = 2, + VRState_Ready = 3, + VRState_Ready_Alert = 4, + VRState_NotReady = 5, +} EVRState; + typedef uint32_t TrackedDeviceIndex_t; typedef uint32_t VRNotificationId; @@ -62,6 +74,38 @@ typedef struct VREvent_Process_t unsigned int oldPid; } VREvent_Process_t; + +/** Used for a few events about overlays */ +typedef struct VREvent_Overlay_t +{ + uint64_t overlayHandle; +} VREvent_Overlay_t; + + +/** Used for a few events about overlays */ +typedef struct VREvent_Status_t +{ + EVRState statusState; +} VREvent_Status_t; + +/** Used for keyboard events **/ +typedef struct VREvent_Keyboard_t +{ + char cNewInput[8]; // Up to 11 bytes of new input + uint64_t uUserValue; // Possible flags about the new input +} VREvent_Keyboard_t; + +typedef struct VREvent_Ipd_t +{ + float ipdMeters; +} VREvent_Ipd_t; + +typedef struct VREvent_Chaperone_t +{ + uint64_t m_nPreviousUniverse; + uint64_t m_nCurrentUniverse; +} VREvent_Chaperone_t; + typedef struct VREvent_Reserved_t { unsigned long reserved0; @@ -74,29 +118,21 @@ typedef union VREvent_Controller_t controller; VREvent_Mouse_t mouse; VREvent_Process_t process; + VREvent_Overlay_t overlay; + VREvent_Status_t status; + VREvent_Keyboard_t keyboard; + VREvent_Ipd_t ipd; + VREvent_Chaperone_t chaperone; } VREvent_Data_t; + typedef uint32_t TrackedDeviceIndex_t; typedef uint64_t VROverlayHandle_t; typedef uint32_t VRComponentProperties; typedef int32_t TextureID_t; typedef uint32_t VRNotificationId; -typedef enum vr::EVRInitError HmdError; -typedef enum vr::EVREye Hmd_Eye; -typedef enum vr::EGraphicsAPIConvention GraphicsAPIConvention; -typedef enum vr::EColorSpace ColorSpace; -typedef enum vr::ETrackingResult HmdTrackingResult; -typedef enum vr::ETrackedDeviceClass TrackedDeviceClass; -typedef enum vr::ETrackingUniverseOrigin TrackingUniverseOrigin; -typedef enum vr::ETrackedDeviceProperty TrackedDeviceProperty; -typedef enum vr::ETrackedPropertyError TrackedPropertyError; -typedef enum vr::EVRSubmitFlags VRSubmitFlags_t; -typedef enum vr::EVRState VRState_t; -typedef enum vr::ECollisionBoundsStyle CollisionBoundsStyle_t; -typedef enum vr::EVROverlayError VROverlayError; -typedef enum vr::EVRFirmwareError VRFirmwareError; -typedef enum vr::EVRCompositorError VRCompositorError; + // OpenVR Constants unsigned int k_unTrackingStringSize = 32; unsigned int k_unMaxDriverDebugResponseSize = 32768; @@ -106,75 +142,75 @@ unsigned int k_unTrackedDeviceIndexInvalid = 4294967295; unsigned int k_unMaxPropertyStringSize = 32768; unsigned int k_unControllerStateAxisCount = 5; unsigned long k_ulOverlayHandleInvalid = 0; -char * IVRSystem_Version = "IVRSystem_009"; -char * IVRExtendedDisplay_Version = "IVRExtendedDisplay_001"; +const char * IVRSystem_Version = "IVRSystem_009"; +const char * IVRExtendedDisplay_Version = "IVRExtendedDisplay_001"; unsigned int k_unMaxApplicationKeyLength = 128; -char * IVRApplications_Version = "IVRApplications_002"; -char * IVRChaperone_Version = "IVRChaperone_003"; -char * IVRChaperoneSetup_Version = "IVRChaperoneSetup_004"; -char * IVRCompositor_Version = "IVRCompositor_009"; +const char * IVRApplications_Version = "IVRApplications_002"; +const char * IVRChaperone_Version = "IVRChaperone_003"; +const char * IVRChaperoneSetup_Version = "IVRChaperoneSetup_004"; +const char * IVRCompositor_Version = "IVRCompositor_009"; unsigned int k_unVROverlayMaxKeyLength = 128; unsigned int k_unVROverlayMaxNameLength = 128; unsigned int k_unMaxOverlayCount = 32; -char * IVROverlay_Version = "IVROverlay_007"; -char * k_pch_Controller_Component_GDC2015 = "gdc2015"; -char * k_pch_Controller_Component_Base = "base"; -char * k_pch_Controller_Component_Tip = "tip"; -char * k_pch_Controller_Component_HandGrip = "handgrip"; -char * IVRRenderModels_Version = "IVRRenderModels_002"; -char * IVRControlPanel_Version = "IVRControlPanel_001"; +const char * IVROverlay_Version = "IVROverlay_007"; +const char * k_pch_Controller_Component_GDC2015 = "gdc2015"; +const char * k_pch_Controller_Component_Base = "base"; +const char * k_pch_Controller_Component_Tip = "tip"; +const char * k_pch_Controller_Component_HandGrip = "handgrip"; +const char * IVRRenderModels_Version = "IVRRenderModels_002"; +const char * IVRControlPanel_Version = "IVRControlPanel_001"; unsigned int k_unNotificationTextMaxSize = 256; -char * IVRNotifications_Version = "IVRNotifications_002"; +const char * IVRNotifications_Version = "IVRNotifications_002"; unsigned int k_unMaxSettingsKeyLength = 128; -char * k_pch_SteamVR_Section = "steamvr"; -char * k_pch_SteamVR_RequireHmd_String = "requireHmd"; -char * k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver"; -char * k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd"; -char * k_pch_SteamVR_DisplayDebug_Bool = "displayDebug"; -char * k_pch_SteamVR_EnableDistortion_Bool = "enableDistortion"; -char * k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX"; -char * k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY"; -char * k_pch_SteamVR_SendSystemButtonToAllApps_Bool = "sendSystemButtonToAllApps"; -char * k_pch_SteamVR_LogLevel_Int32 = "loglevel"; -char * k_pch_SteamVR_IPD_Float = "ipd"; -char * k_pch_SteamVR_Background_String = "background"; -char * k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers"; -char * k_pch_Lighthouse_Section = "driver_lighthouse"; -char * k_pch_Lighthouse_DisableIMU_Bool = "disableimu"; -char * k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation"; -char * k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug"; -char * k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation"; -char * k_pch_Lighthouse_LighthouseName_String = "lighthousename"; -char * k_pch_Lighthouse_MaxIncidenceAngleDegrees_Float = "maxincidenceangledegrees"; -char * k_pch_Lighthouse_UseLighthouseDirect_Bool = "uselighthousedirect"; -char * k_pch_Lighthouse_DBHistory_Bool = "dbhistory"; -char * k_pch_Lighthouse_OriginOffsetX_Float = "originoffsetx"; -char * k_pch_Lighthouse_OriginOffsetY_Float = "originoffsety"; -char * k_pch_Lighthouse_OriginOffsetZ_Float = "originoffsetz"; -char * k_pch_Lighthouse_HeadingOffset_Float = "headingoffset"; -char * k_pch_Null_Section = "driver_null"; -char * k_pch_Null_EnableNullDriver_Bool = "enable"; -char * k_pch_Null_Id_String = "id"; -char * k_pch_Null_SerialNumber_String = "serialNumber"; -char * k_pch_Null_ModelNumber_String = "modelNumber"; -char * k_pch_Null_WindowX_Int32 = "windowX"; -char * k_pch_Null_WindowY_Int32 = "windowY"; -char * k_pch_Null_WindowWidth_Int32 = "windowWidth"; -char * k_pch_Null_WindowHeight_Int32 = "windowHeight"; -char * k_pch_Null_RenderWidth_Int32 = "renderWidth"; -char * k_pch_Null_RenderHeight_Int32 = "renderHeight"; -char * k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons"; -char * k_pch_Null_DisplayFrequency_Float = "displayFrequency"; -char * k_pch_Notifications_Section = "notifications"; -char * k_pch_Notifications_DoNotDisturb_Bool = "DoNotDisturb"; -char * k_pch_Perf_Section = "perfcheck"; -char * k_pch_Perf_HeuristicActive_Bool = "heuristicActive"; -char * k_pch_Perf_NotifyInHMD_Bool = "warnInHMD"; -char * k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce"; -char * k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore"; -char * k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit"; -char * IVRSettings_Version = "IVRSettings_001"; -char * IVRTrackedCamera_Version = "IVRTrackedCamera_001"; +const char * k_pch_SteamVR_Section = "steamvr"; +const char * k_pch_SteamVR_RequireHmd_String = "requireHmd"; +const char * k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver"; +const char * k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd"; +const char * k_pch_SteamVR_DisplayDebug_Bool = "displayDebug"; +const char * k_pch_SteamVR_EnableDistortion_Bool = "enableDistortion"; +const char * k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX"; +const char * k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY"; +const char * k_pch_SteamVR_SendSystemButtonToAllApps_Bool = "sendSystemButtonToAllApps"; +const char * k_pch_SteamVR_LogLevel_Int32 = "loglevel"; +const char * k_pch_SteamVR_IPD_Float = "ipd"; +const char * k_pch_SteamVR_Background_String = "background"; +const char * k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers"; +const char * k_pch_Lighthouse_Section = "driver_lighthouse"; +const char * k_pch_Lighthouse_DisableIMU_Bool = "disableimu"; +const char * k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation"; +const char * k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug"; +const char * k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation"; +const char * k_pch_Lighthouse_LighthouseName_String = "lighthousename"; +const char * k_pch_Lighthouse_MaxIncidenceAngleDegrees_Float = "maxincidenceangledegrees"; +const char * k_pch_Lighthouse_UseLighthouseDirect_Bool = "uselighthousedirect"; +const char * k_pch_Lighthouse_DBHistory_Bool = "dbhistory"; +const char * k_pch_Lighthouse_OriginOffsetX_Float = "originoffsetx"; +const char * k_pch_Lighthouse_OriginOffsetY_Float = "originoffsety"; +const char * k_pch_Lighthouse_OriginOffsetZ_Float = "originoffsetz"; +const char * k_pch_Lighthouse_HeadingOffset_Float = "headingoffset"; +const char * k_pch_Null_Section = "driver_null"; +const char * k_pch_Null_EnableNullDriver_Bool = "enable"; +const char * k_pch_Null_Id_String = "id"; +const char * k_pch_Null_SerialNumber_String = "serialNumber"; +const char * k_pch_Null_ModelNumber_String = "modelNumber"; +const char * k_pch_Null_WindowX_Int32 = "windowX"; +const char * k_pch_Null_WindowY_Int32 = "windowY"; +const char * k_pch_Null_WindowWidth_Int32 = "windowWidth"; +const char * k_pch_Null_WindowHeight_Int32 = "windowHeight"; +const char * k_pch_Null_RenderWidth_Int32 = "renderWidth"; +const char * k_pch_Null_RenderHeight_Int32 = "renderHeight"; +const char * k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons"; +const char * k_pch_Null_DisplayFrequency_Float = "displayFrequency"; +const char * k_pch_Notifications_Section = "notifications"; +const char * k_pch_Notifications_DoNotDisturb_Bool = "DoNotDisturb"; +const char * k_pch_Perf_Section = "perfcheck"; +const char * k_pch_Perf_HeuristicActive_Bool = "heuristicActive"; +const char * k_pch_Perf_NotifyInHMD_Bool = "warnInHMD"; +const char * k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce"; +const char * k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore"; +const char * k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit"; +const char * IVRSettings_Version = "IVRSettings_001"; +const char * IVRTrackedCamera_Version = "IVRTrackedCamera_001"; @@ -307,17 +343,6 @@ typedef enum EVRSubmitFlags EVRSubmitFlags_Submit_GlRenderBuffer = 2, } EVRSubmitFlags; -typedef enum EVRState -{ - EVRState_VRState_Undefined = -1, - EVRState_VRState_Off = 0, - EVRState_VRState_Searching = 1, - EVRState_VRState_Searching_Alert = 2, - EVRState_VRState_Ready = 3, - EVRState_VRState_Ready_Alert = 4, - EVRState_VRState_NotReady = 5, -} EVRState; - typedef enum EVREventType { EVREventType_VREvent_None = 0, @@ -386,6 +411,15 @@ typedef enum EVREventType EVREventType_VREvent_VendorSpecific_Reserved_End = 19999, } EVREventType; +/** An event posted by the server to all running applications */ +typedef struct VREvent_t +{ + EVREventType eventType; + TrackedDeviceIndex_t trackedDeviceIndex; + VREvent_Data_t data; + float eventAgeSeconds; +} VREvent_t; + typedef enum EDeviceActivityLevel { EDeviceActivityLevel_k_EDeviceActivityLevel_Unknown = -1, @@ -922,8 +956,23 @@ typedef struct CameraVideoStreamFrame_t void * m_pImageData; // void * } CameraVideoStreamFrame_t; - - +inline uint64_t ButtonMaskFromId( EVRButtonId id ) { return 1ull << id; } + +typedef enum EVRInitError HmdError; +typedef enum EVREye Hmd_Eye; +typedef enum EGraphicsAPIConvention GraphicsAPIConvention; +typedef enum EColorSpace ColorSpace; +typedef enum ETrackingResult HmdTrackingResult; +typedef enum ETrackedDeviceClass TrackedDeviceClass; +typedef enum ETrackingUniverseOrigin TrackingUniverseOrigin; +typedef enum ETrackedDeviceProperty TrackedDeviceProperty; +typedef enum ETrackedPropertyError TrackedPropertyError; +typedef enum EVRSubmitFlags VRSubmitFlags_t; +typedef enum EVRState VRState_t; +typedef enum ECollisionBoundsStyle CollisionBoundsStyle_t; +typedef enum EVROverlayError VROverlayError; +typedef enum EVRFirmwareError VRFirmwareError; +typedef enum EVRCompositorError VRCompositorError; S_API void VR_IVRSystem_GetRecommendedRenderTargetSize(intptr_t instancePtr, uint32_t * pnWidth, uint32_t * pnHeight); S_API struct HmdMatrix44_t VR_IVRSystem_GetProjectionMatrix(intptr_t instancePtr, EVREye eEye, float fNearZ, float fFarZ, EGraphicsAPIConvention eProjType); @@ -1113,7 +1162,7 @@ S_API uint32_t VR_IVRControlPanel_GetDriverDisplaySerialNumber(intptr_t instance S_API uint32_t VR_IVRControlPanel_LoadSharedResource(intptr_t instancePtr, const char * pchResourceName, char * pchBuffer, uint32_t unBufferLen); S_API float VR_IVRControlPanel_GetIPD(intptr_t instancePtr); S_API void VR_IVRControlPanel_SetIPD(intptr_t instancePtr, float fIPD); -S_API class IVRCompositor * VR_IVRControlPanel_GetCurrentCompositorInterface(intptr_t instancePtr, const char * pchInterfaceVersion); +// S_API class IVRCompositor * VR_IVRControlPanel_GetCurrentCompositorInterface(intptr_t instancePtr, const char * pchInterfaceVersion); S_API bool VR_IVRControlPanel_QuitProcess(intptr_t instancePtr, uint32_t pidProcessToQuit); S_API uint32_t VR_IVRControlPanel_StartVRProcess(intptr_t instancePtr, const char * pchExecutable, const char ** pchArguments, uint32_t unArgumentCount, const char * pchWorkingDirectory); S_API void VR_IVRControlPanel_SetMasterProcessToThis(intptr_t instancePtr);
(oops, was still editing the issue the first time — in case you're reading these by email, I just updated with the right info)
I had to make some modifications to get
openvr_capi.h
to compile as a C file.I'd do a pull request but I know the file is autogenerated, so I'll just list the changes here:
S_API
macro are usingextern "C"
which doesn't make sense for an already C filevr::
namespace)VREvent_t
is missingVR_IVRControlPanel_GetCurrentCompositorInterface
returns aclass IVRCompositor *
- is it meant to return anintptr_t
? I commented this one out.const
(just a warning cleanup)Along with the already reported:
VR_Event_Data_t
missing overlay, status, keyboard, ipd and chaperone fieldsVREvent_Overlay_t
,VREvent_Status_t
,VREvent_Keyboard_t
,VREvent_Chaperone_t
, andVREvent_Ipd_t
structs are missingButtonMaskFromId
declaration is missingHere's the diff