Skip to content

Commit a50cb34

Browse files
committed
Update to OpenVR SDK 1.9.16
1 parent d224603 commit a50cb34

25 files changed

+11743
-3399
lines changed

OpenVR/FreeTrack/headers/openvr.h

Lines changed: 1232 additions & 328 deletions
Large diffs are not rendered by default.

OpenVR/FreeTrack/headers/openvr_api.cs

Lines changed: 1905 additions & 312 deletions
Large diffs are not rendered by default.

OpenVR/FreeTrack/headers/openvr_api.json

Lines changed: 970 additions & 264 deletions
Large diffs are not rendered by default.

OpenVR/FreeTrack/headers/openvr_capi.h

Lines changed: 668 additions & 150 deletions
Large diffs are not rendered by default.

OpenVR/FreeTrack/headers/openvr_driver.h

Lines changed: 1014 additions & 123 deletions
Large diffs are not rendered by default.

OpenVR/FreeTrack/samples/driver_sample/driver_sample.cpp

Lines changed: 46 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
#include <thread>
99
#include <chrono>
1010

11-
#include <Windows.h>
12-
//#include "Shlwapi.h"
11+
#if defined( _WINDOWS )
12+
#include <windows.h>
13+
#endif
1314

1415
using namespace vr;
1516

@@ -52,7 +53,7 @@ inline void HmdMatrix_SetIdentity( HmdMatrix34_t *pMatrix )
5253

5354

5455
// keys for use with the settings API
55-
static const char * const k_pch_Sample_Section = "driver_null";
56+
static const char * const k_pch_Sample_Section = "opentrack";
5657
static const char * const k_pch_Sample_SerialNumber_String = "serialNumber";
5758
static const char * const k_pch_Sample_ModelNumber_String = "modelNumber";
5859
static const char * const k_pch_Sample_WindowX_Int32 = "windowX";
@@ -63,6 +64,7 @@ static const char * const k_pch_Sample_RenderWidth_Int32 = "renderWidth";
6364
static const char * const k_pch_Sample_RenderHeight_Int32 = "renderHeight";
6465
static const char * const k_pch_Sample_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons";
6566
static const char * const k_pch_Sample_DisplayFrequency_Float = "displayFrequency";
67+
6668
static const char * const k_pch_Sample_DistortionK1_Float = "DistortionK1";
6769
static const char * const k_pch_Sample_DistortionK2_Float = "DistortionK2";
6870
static const char * const k_pch_Sample_ZoomWidth_Float = "ZoomWidth";
@@ -71,6 +73,7 @@ static const char * const k_pch_Sample_DistanceBetweenEyes_Int32 = "DistanceBetw
7173
static const char * const k_pch_Sample_ScreenOffsetX_Int32 = "ScreenOffsetX";
7274
static const char * const k_pch_Sample_DebugMode_Bool = "DebugMode";
7375

76+
7477
#define FREETRACK_HEAP "FT_SharedMem"
7578
#define FREETRACK_MUTEX "FT_Mutext"
7679

@@ -157,90 +160,6 @@ void FTRead()
157160
}
158161
}
159162

160-
//-----------------------------------------------------------------------------
161-
// Purpose:
162-
//-----------------------------------------------------------------------------
163-
164-
class CWatchdogDriver_Sample : public IVRWatchdogProvider
165-
{
166-
public:
167-
CWatchdogDriver_Sample()
168-
{
169-
m_pWatchdogThread = nullptr;
170-
}
171-
172-
virtual EVRInitError Init( vr::IVRDriverContext *pDriverContext ) ;
173-
virtual void Cleanup() ;
174-
175-
private:
176-
std::thread *m_pWatchdogThread;
177-
};
178-
179-
CWatchdogDriver_Sample g_watchdogDriverNull;
180-
181-
182-
bool g_bExiting = false;
183-
184-
void WatchdogThreadFunction( )
185-
{
186-
while ( !g_bExiting )
187-
{
188-
#if defined( _WINDOWS )
189-
// on windows send the event when the Y key is pressed.
190-
//if ( (0x01 & GetAsyncKeyState( 'Y' )) != 0 )
191-
//{
192-
// Y key was pressed.
193-
// vr::VRWatchdogHost()->WatchdogWakeUp();
194-
// }
195-
std::this_thread::sleep_for( std::chrono::microseconds( 500 ) );
196-
#else
197-
// for the other platforms, just send one every five seconds
198-
std::this_thread::sleep_for( std::chrono::seconds( 5 ) );
199-
vr::VRWatchdogHost()->WatchdogWakeUp();
200-
#endif
201-
}
202-
}
203-
204-
EVRInitError CWatchdogDriver_Sample::Init( vr::IVRDriverContext *pDriverContext )
205-
{
206-
VR_INIT_WATCHDOG_DRIVER_CONTEXT( pDriverContext );
207-
// InitDriverLog( vr::VRDriverLog() );
208-
209-
// Watchdog mode on Windows starts a thread that listens for the 'Y' key on the keyboard to
210-
// be pressed. A real driver should wait for a system button event or something else from the
211-
// the hardware that signals that the VR system should start up.
212-
g_bExiting = false;
213-
m_pWatchdogThread = new std::thread( WatchdogThreadFunction );
214-
if ( !m_pWatchdogThread )
215-
{
216-
// DriverLog( "Unable to create watchdog thread\n");
217-
return VRInitError_Driver_Failed;
218-
}
219-
220-
return VRInitError_None;
221-
}
222-
223-
224-
void CWatchdogDriver_Sample::Cleanup()
225-
{
226-
if (HMDConnected) {
227-
HMDConnected = false;
228-
if (pFTthread) {
229-
pFTthread->join();
230-
delete pFTthread;
231-
pFTthread = nullptr;
232-
}
233-
}
234-
g_bExiting = true;
235-
if ( m_pWatchdogThread )
236-
{
237-
m_pWatchdogThread->join();
238-
delete m_pWatchdogThread;
239-
m_pWatchdogThread = nullptr;
240-
}
241-
}
242-
243-
244163
//-----------------------------------------------------------------------------
245164
// Purpose:
246165
//-----------------------------------------------------------------------------
@@ -262,14 +181,14 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
262181
vr::VRSettings()->GetString( k_pch_Sample_Section, k_pch_Sample_ModelNumber_String, buf, sizeof( buf ) );
263182
m_sModelNumber = buf;
264183

265-
m_nWindowX = vr::VRSettings()->GetInt32(k_pch_Sample_Section, k_pch_Sample_WindowX_Int32);
266-
m_nWindowY = vr::VRSettings()->GetInt32(k_pch_Sample_Section, k_pch_Sample_WindowY_Int32);
267-
m_nWindowWidth = vr::VRSettings()->GetInt32(k_pch_Sample_Section, k_pch_Sample_WindowWidth_Int32);
268-
m_nWindowHeight = vr::VRSettings()->GetInt32(k_pch_Sample_Section, k_pch_Sample_WindowHeight_Int32);
269-
m_nRenderWidth = vr::VRSettings()->GetInt32(k_pch_Sample_Section, k_pch_Sample_RenderWidth_Int32);
270-
m_nRenderHeight = vr::VRSettings()->GetInt32(k_pch_Sample_Section, k_pch_Sample_RenderHeight_Int32);
271-
m_flSecondsFromVsyncToPhotons = vr::VRSettings()->GetFloat(k_pch_Sample_Section, k_pch_Sample_SecondsFromVsyncToPhotons_Float);
272-
m_flDisplayFrequency = vr::VRSettings()->GetFloat(k_pch_Sample_Section, k_pch_Sample_DisplayFrequency_Float);
184+
m_nWindowX = vr::VRSettings()->GetInt32( k_pch_Sample_Section, k_pch_Sample_WindowX_Int32 );
185+
m_nWindowY = vr::VRSettings()->GetInt32( k_pch_Sample_Section, k_pch_Sample_WindowY_Int32 );
186+
m_nWindowWidth = vr::VRSettings()->GetInt32( k_pch_Sample_Section, k_pch_Sample_WindowWidth_Int32 );
187+
m_nWindowHeight = vr::VRSettings()->GetInt32( k_pch_Sample_Section, k_pch_Sample_WindowHeight_Int32 );
188+
m_nRenderWidth = vr::VRSettings()->GetInt32( k_pch_Sample_Section, k_pch_Sample_RenderWidth_Int32 );
189+
m_nRenderHeight = vr::VRSettings()->GetInt32( k_pch_Sample_Section, k_pch_Sample_RenderHeight_Int32 );
190+
m_flSecondsFromVsyncToPhotons = vr::VRSettings()->GetFloat( k_pch_Sample_Section, k_pch_Sample_SecondsFromVsyncToPhotons_Float );
191+
m_flDisplayFrequency = vr::VRSettings()->GetFloat( k_pch_Sample_Section, k_pch_Sample_DisplayFrequency_Float );
273192

274193
m_fDistortionK1 = vr::VRSettings()->GetFloat(k_pch_Sample_Section, k_pch_Sample_DistortionK1_Float);
275194
m_fDistortionK2 = vr::VRSettings()->GetFloat(k_pch_Sample_Section, k_pch_Sample_DistortionK2_Float);
@@ -279,22 +198,14 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
279198
m_nScreenOffsetX = vr::VRSettings()->GetFloat(k_pch_Sample_Section, k_pch_Sample_ScreenOffsetX_Int32);
280199
m_bDebugMode = vr::VRSettings()->GetBool(k_pch_Sample_Section, k_pch_Sample_DebugMode_Bool);
281200

282-
//DriverLog( "driver_null: Serial Number: %s\n", m_sSerialNumber.c_str() );
283-
//DriverLog( "driver_null: Model Number: %s\n", m_sModelNumber.c_str() );
284-
//DriverLog( "driver_null: Window: %d %d %d %d\n", m_nWindowX, m_nWindowY, m_nWindowWidth, m_nWindowHeight );
285-
//DriverLog( "driver_null: Render Target: %d %d\n", m_nRenderWidth, m_nRenderHeight );
286-
//DriverLog( "driver_null: Seconds from Vsync to Photons: %f\n", m_flSecondsFromVsyncToPhotons );
287-
//DriverLog( "driver_null: Display Frequency: %f\n", m_flDisplayFrequency );
288-
//DriverLog( "driver_null: IPD: %f\n", m_flIPD );
289-
290-
291-
if (impl_create_mapping() == false) {
292-
HMDConnected = false;
293-
}
294-
else {
295-
HMDConnected = true;
296-
pFTthread = new std::thread(FTRead);
297-
}
201+
202+
/*DriverLog( "driver_null: Serial Number: %s\n", m_sSerialNumber.c_str() );
203+
DriverLog( "driver_null: Model Number: %s\n", m_sModelNumber.c_str() );
204+
DriverLog( "driver_null: Window: %d %d %d %d\n", m_nWindowX, m_nWindowY, m_nWindowWidth, m_nWindowHeight );
205+
DriverLog( "driver_null: Render Target: %d %d\n", m_nRenderWidth, m_nRenderHeight );
206+
DriverLog( "driver_null: Seconds from Vsync to Photons: %f\n", m_flSecondsFromVsyncToPhotons );
207+
DriverLog( "driver_null: Display Frequency: %f\n", m_flDisplayFrequency );
208+
DriverLog( "driver_null: IPD: %f\n", m_flIPD );*/
298209
}
299210

300211
virtual ~CSampleDeviceDriver()
@@ -323,6 +234,7 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
323234

324235
//Debug mode activate Windowed Mode (borderless fullscreen), lock to 30 FPS
325236
vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_DisplayDebugMode_Bool, m_bDebugMode);
237+
326238
// Icons can be configured in code or automatically configured by an external file "drivername\resources\driver.vrresources".
327239
// Icon properties NOT configured in code (post Activate) are then auto-configured by the optional presence of a driver's "drivername\resources\driver.vrresources".
328240
// In this manner a driver can configure their icons in a flexible data driven fashion by using an external file.
@@ -346,20 +258,20 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
346258
// Thus "Prop_NamedIconPathDeviceAlertLow_String" in each model's block represent a specialization specific for that "model".
347259
// Keys in "Model-v Defaults" are an example of mapping to the same states, and here all map to "Prop_NamedIconPathDeviceOff_String".
348260
//
349-
bool bSetupIconUsingExternalResourceFile = true;
261+
/*bool bSetupIconUsingExternalResourceFile = true;
350262
if ( !bSetupIconUsingExternalResourceFile )
351263
{
352264
// Setup properties directly in code.
353265
// Path values are of the form {drivername}\icons\some_icon_filename.png
354-
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceOff_String, "{null}/icons/headset_sample_status_off.png" );
355-
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceSearching_String, "{null}/icons/headset_sample_status_searching.gif" );
356-
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceSearchingAlert_String, "{null}/icons/headset_sample_status_searching_alert.gif" );
357-
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceReady_String, "{null}/icons/headset_sample_status_ready.png" );
358-
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceReadyAlert_String, "{null}/icons/headset_sample_status_ready_alert.png" );
359-
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceNotReady_String, "{null}/icons/headset_sample_status_error.png" );
360-
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceStandby_String, "{null}/icons/headset_sample_status_standby.png" );
361-
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceAlertLow_String, "{null}/icons/headset_sample_status_ready_low.png" );
362-
}
266+
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceOff_String, "{sample}/icons/headset_sample_status_off.png" );
267+
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceSearching_String, "{sample}/icons/headset_sample_status_searching.gif" );
268+
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceSearchingAlert_String, "{sample}/icons/headset_sample_status_searching_alert.gif" );
269+
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceReady_String, "{sample}/icons/headset_sample_status_ready.png" );
270+
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceReadyAlert_String, "{sample}/icons/headset_sample_status_ready_alert.png" );
271+
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceNotReady_String, "{sample}/icons/headset_sample_status_error.png" );
272+
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceStandby_String, "{sample}/icons/headset_sample_status_standby.png" );
273+
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceAlertLow_String, "{sample}/icons/headset_sample_status_ready_low.png" );
274+
}*/
363275

364276
return VRInitError_None;
365277
}
@@ -456,7 +368,7 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
456368
double theta;
457369

458370
rr = sqrt((fU - 0.5f)*(fU - 0.5f) + (fV - 0.5f)*(fV - 0.5f));
459-
r2 = rr * (1 + m_fDistortionK1*(rr*rr) + m_fDistortionK2*(rr*rr*rr*rr));
371+
r2 = rr * (1 + m_fDistortionK1 * (rr*rr) + m_fDistortionK2 * (rr*rr*rr*rr));
460372
theta = atan2(fU - 0.5f, fV - 0.5f);
461373
hX = sin(theta)*r2*m_fZoomWidth;
462374
hY = cos(theta)*r2*m_fZoomHeight;
@@ -534,6 +446,7 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
534446
float m_flSecondsFromVsyncToPhotons;
535447
float m_flDisplayFrequency;
536448
float m_flIPD;
449+
537450
float m_fDistortionK1;
538451
float m_fDistortionK2;
539452
float m_fZoomWidth;
@@ -549,12 +462,6 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
549462
class CServerDriver_Sample: public IServerTrackedDeviceProvider
550463
{
551464
public:
552-
CServerDriver_Sample()
553-
: m_pNullHmdLatest( NULL )
554-
, m_bEnableNullDriver( false )
555-
{
556-
}
557-
558465
virtual EVRInitError Init( vr::IVRDriverContext *pDriverContext ) ;
559466
virtual void Cleanup() ;
560467
virtual const char * const *GetInterfaceVersions() { return vr::k_InterfaceVersions; }
@@ -564,9 +471,7 @@ class CServerDriver_Sample: public IServerTrackedDeviceProvider
564471
virtual void LeaveStandby() {}
565472

566473
private:
567-
CSampleDeviceDriver *m_pNullHmdLatest;
568-
569-
bool m_bEnableNullDriver;
474+
CSampleDeviceDriver *m_pNullHmdLatest = nullptr;
570475
};
571476

572477
CServerDriver_Sample g_serverDriverNull;
@@ -577,8 +482,17 @@ EVRInitError CServerDriver_Sample::Init( vr::IVRDriverContext *pDriverContext )
577482
VR_INIT_SERVER_DRIVER_CONTEXT( pDriverContext );
578483
//InitDriverLog( vr::VRDriverLog() );
579484

485+
if (impl_create_mapping() == false) {
486+
HMDConnected = false;
487+
}
488+
else {
489+
HMDConnected = true;
490+
pFTthread = new std::thread(FTRead);
491+
}
492+
580493
m_pNullHmdLatest = new CSampleDeviceDriver();
581494
vr::VRServerDriverHost()->TrackedDeviceAdded( m_pNullHmdLatest->GetSerialNumber().c_str(), vr::TrackedDeviceClass_HMD, m_pNullHmdLatest );
495+
582496
return VRInitError_None;
583497
}
584498

@@ -592,6 +506,7 @@ void CServerDriver_Sample::Cleanup()
592506
pFTthread = nullptr;
593507
}
594508
}
509+
//CleanupDriverLog();
595510
delete m_pNullHmdLatest;
596511
m_pNullHmdLatest = NULL;
597512
}
@@ -614,10 +529,6 @@ HMD_DLL_EXPORT void *HmdDriverFactory( const char *pInterfaceName, int *pReturnC
614529
{
615530
return &g_serverDriverNull;
616531
}
617-
if( 0 == strcmp( IVRWatchdogProvider_Version, pInterfaceName ) )
618-
{
619-
return &g_watchdogDriverNull;
620-
}
621532

622533
if( pReturnCode )
623534
*pReturnCode = VRInitError_Init_InterfaceNotFound;

OpenVR/FreeTrack/samples/driver_sample/driver_sample.vcxproj

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<ProjectGuid>{A47C788B-1BDA-4057-87A9-FC35ED711B44}</ProjectGuid>
2323
<Keyword>Win32Proj</Keyword>
2424
<RootNamespace>driver_sample</RootNamespace>
25-
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
25+
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
2626
</PropertyGroup>
2727
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
2828
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -69,19 +69,23 @@
6969
<PropertyGroup Label="UserMacros" />
7070
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7171
<LinkIncremental>true</LinkIncremental>
72-
<OutDir>$(SolutionDir)\..\bin\drivers\sample\bin\win32\</OutDir>
72+
<OutDir>$(SolutionDir)\bin\drivers\sample\bin\win32\</OutDir>
73+
<TargetName>driver_opentrack</TargetName>
7374
</PropertyGroup>
7475
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
7576
<LinkIncremental>true</LinkIncremental>
76-
<OutDir>$(SolutionDir)\..\bin\drivers\sample\bin\win64\</OutDir>
77+
<OutDir>$(SolutionDir)\bin\drivers\sample\bin\win64\</OutDir>
78+
<TargetName>driver_opentrack</TargetName>
7779
</PropertyGroup>
7880
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
7981
<LinkIncremental>false</LinkIncremental>
80-
<OutDir>$(SolutionDir)\..\bin\drivers\sample\bin\win32\</OutDir>
82+
<OutDir>$(SolutionDir)\bin\drivers\sample\bin\win32\</OutDir>
83+
<TargetName>driver_opentrack</TargetName>
8184
</PropertyGroup>
8285
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
8386
<LinkIncremental>false</LinkIncremental>
84-
<OutDir>$(SolutionDir)\..\bin\drivers\sample\bin\win64\</OutDir>
87+
<OutDir>$(SolutionDir)\bin\drivers\sample\bin\win64\</OutDir>
88+
<TargetName>driver_opentrack</TargetName>
8589
</PropertyGroup>
8690
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
8791
<ClCompile>

0 commit comments

Comments
 (0)