mirror of
https://github.com/ValveSoftware/openvr.git
synced 2026-11-17 02:11:36 +00:00
6
Driver Factory Function
Chanchana Sornsoontorn edited this page 2020-12-02 10:29:26 +07:00
Every driver dynamic library needs to implement the standard driver factory function and use it to return implementations of the OpenVR driver interfaces. This function is the entry-point for every driver.
A typical factory function looks like this:
#define HMD_DLL_EXPORT extern "C" __declspec( dllexport )
HMD_DLL_EXPORT
void *HmdDriverFactory( const char *pInterfaceName, int *pReturnCode )
{
if( 0 == strcmp( IServerTrackedDeviceProvider_Version, pInterfaceName ) )
{
return <global for server driver provider>;
}
if( 0 == strcmp( IVRWatchdogProvider_Version, pInterfaceName ) )
{
return <global for watchdog driver>;
}
if( pReturnCode )
*pReturnCode = HmdError_Init_InterfaceNotFound;
return NULL;
}
If you wish to implement IVRWatchdogProvider, please see the example code in the sample driver.