Skip to content

Commit 0cb7ca3

Browse files
committed
OpenVR 1.3.22, self path
1 parent 556b540 commit 0cb7ca3

File tree

10 files changed

+2034
-429
lines changed

10 files changed

+2034
-429
lines changed

OpenVR/headers/openvr.h

Lines changed: 487 additions & 114 deletions
Large diffs are not rendered by default.

OpenVR/headers/openvr_api.cs

Lines changed: 438 additions & 93 deletions
Large diffs are not rendered by default.

OpenVR/headers/openvr_api.json

Lines changed: 373 additions & 82 deletions
Large diffs are not rendered by default.

OpenVR/headers/openvr_capi.h

Lines changed: 286 additions & 35 deletions
Large diffs are not rendered by default.

OpenVR/headers/openvr_driver.h

Lines changed: 333 additions & 59 deletions
Large diffs are not rendered by default.

OpenVR/samples/driver_sample/driver_sample.cpp

Lines changed: 73 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ inline void HmdMatrix_SetIdentity( HmdMatrix34_t *pMatrix )
5151

5252

5353
// keys for use with the settings API
54-
static const char * const k_pch_Sample_Section = "driver_null";
54+
static const char * const k_pch_Sample_Section = "tovr";
5555
static const char * const k_pch_Sample_SerialNumber_String = "serialNumber";
5656
static const char * const k_pch_Sample_ModelNumber_String = "modelNumber";
5757
static const char * const k_pch_Sample_WindowX_Int32 = "windowX";
@@ -173,7 +173,7 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
173173
public:
174174
CSampleDeviceDriver( )
175175
{
176-
m_unObjectId = vr::k_unTrackedDeviceIndexInvalid;
176+
HMDIndex_t = vr::k_unTrackedDeviceIndexInvalid;
177177
m_ulPropertyContainer = vr::k_ulInvalidPropertyContainer;
178178

179179
//DriverLog( "Using settings values\n" );
@@ -227,18 +227,23 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
227227

228228
if (status == ERROR_SUCCESS)
229229
{
230-
HMDConnected = true;
230+
231231
hDll = LoadLibrary(libPath);
232232
GetHMDData = (_GetHMDData)GetProcAddress(hDll, "GetHMDData");
233233
GetControllersData = (_GetControllersData)GetProcAddress(hDll, "GetControllersData");
234234
SetControllerData = (_SetControllerData)GetProcAddress(hDll, "SetControllerData");
235235
SetCentering = (_SetCentering)GetProcAddress(hDll, "SetCentering");
236236

237-
if (GetHMDData == NULL) HMDConnected = false;
238-
if (SetCentering == NULL) HMDConnected = false;
237+
if (GetHMDData != NULL && GetHMDData(&MyHMD) == TOVR_SUCCESS)
238+
HMDConnected = true;
239239

240240
if (GetControllersData != NULL && SetControllerData !=NULL && GetControllersData(&MyCtrl, &MyCtrl2) == TOVR_SUCCESS)
241241
ctrlsConnected = true;
242+
243+
if (SetCentering == NULL) {
244+
HMDConnected = false;
245+
ctrlsConnected = false;
246+
}
242247
}
243248
}
244249

@@ -252,9 +257,8 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
252257

253258
virtual EVRInitError Activate( vr::TrackedDeviceIndex_t unObjectId )
254259
{
255-
m_unObjectId = unObjectId;
256-
m_ulPropertyContainer = vr::VRProperties()->TrackedDeviceToPropertyContainer( m_unObjectId );
257-
260+
HMDIndex_t = unObjectId;
261+
m_ulPropertyContainer = vr::VRProperties()->TrackedDeviceToPropertyContainer( HMDIndex_t );
258262

259263
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, Prop_ModelNumber_String, m_sModelNumber.c_str() );
260264
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, Prop_RenderModelName_String, m_sModelNumber.c_str() );
@@ -295,7 +299,7 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
295299
// Thus "Prop_NamedIconPathDeviceAlertLow_String" in each model's block represent a specialization specific for that "model".
296300
// Keys in "Model-v Defaults" are an example of mapping to the same states, and here all map to "Prop_NamedIconPathDeviceOff_String".
297301
//
298-
bool bSetupIconUsingExternalResourceFile = true;
302+
/*bool bSetupIconUsingExternalResourceFile = true;
299303
if ( !bSetupIconUsingExternalResourceFile )
300304
{
301305
// Setup properties directly in code.
@@ -308,14 +312,14 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
308312
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceNotReady_String, "{null}/icons/headset_sample_status_error.png" );
309313
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceStandby_String, "{null}/icons/headset_sample_status_standby.png" );
310314
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, vr::Prop_NamedIconPathDeviceAlertLow_String, "{null}/icons/headset_sample_status_ready_low.png" );
311-
}
315+
}*/
312316

313317
return VRInitError_None;
314318
}
315319

316320
virtual void Deactivate()
317321
{
318-
m_unObjectId = vr::k_unTrackedDeviceIndexInvalid;
322+
HMDIndex_t = vr::k_unTrackedDeviceIndexInvalid;
319323
}
320324

321325
virtual void EnterStandby()
@@ -477,16 +481,16 @@ class CSampleDeviceDriver : public vr::ITrackedDeviceServerDriver, public vr::IV
477481
// In a real driver, this should happen from some pose tracking thread.
478482
// The RunFrame interval is unspecified and can be very irregular if some other
479483
// driver blocks it for some periodic task.
480-
if ( m_unObjectId != vr::k_unTrackedDeviceIndexInvalid )
484+
if ( HMDIndex_t != vr::k_unTrackedDeviceIndexInvalid )
481485
{
482-
vr::VRServerDriverHost()->TrackedDevicePoseUpdated( m_unObjectId, GetPose(), sizeof( DriverPose_t ) );
486+
vr::VRServerDriverHost()->TrackedDevicePoseUpdated( HMDIndex_t , GetPose(), sizeof( DriverPose_t ) );
483487
}
484488
}
485489

486490
std::string GetSerialNumber() const { return m_sSerialNumber; }
487491

488492
private:
489-
vr::TrackedDeviceIndex_t m_unObjectId;
493+
vr::TrackedDeviceIndex_t HMDIndex_t;
490494
vr::PropertyContainerHandle_t m_ulPropertyContainer;
491495

492496
std::string m_sSerialNumber;
@@ -520,7 +524,8 @@ class CSampleControllerDriver : public vr::ITrackedDeviceServerDriver
520524
public:
521525
CSampleControllerDriver()
522526
{
523-
m_unObjectId = vr::k_unTrackedDeviceIndexInvalid;
527+
Ctrl1Index_t = vr::k_unTrackedDeviceIndexInvalid;
528+
Ctrl2Index_t = vr::k_unTrackedDeviceIndexInvalid;
524529
m_ulPropertyContainer = vr::k_ulInvalidPropertyContainer;
525530
}
526531

@@ -535,8 +540,17 @@ class CSampleControllerDriver : public vr::ITrackedDeviceServerDriver
535540

536541
virtual EVRInitError Activate( vr::TrackedDeviceIndex_t unObjectId )
537542
{
538-
m_unObjectId = unObjectId;
539-
m_ulPropertyContainer = vr::VRProperties()->TrackedDeviceToPropertyContainer( m_unObjectId );
543+
switch (ControllerIndex)
544+
{
545+
case 1:
546+
Ctrl1Index_t = unObjectId;
547+
Ctrl1Index_t = vr::VRProperties()->TrackedDeviceToPropertyContainer(Ctrl1Index_t);
548+
break;
549+
case 2:
550+
Ctrl2Index_t = unObjectId;
551+
Ctrl2Index_t = vr::VRProperties()->TrackedDeviceToPropertyContainer(Ctrl2Index_t);
552+
break;
553+
}
540554

541555
vr::VRProperties()->SetStringProperty(m_ulPropertyContainer, vr::Prop_ControllerType_String, "vive_controller");
542556
vr::VRProperties()->SetStringProperty(m_ulPropertyContainer, vr::Prop_LegacyInputProfile_String, "vive_controller");
@@ -585,7 +599,7 @@ class CSampleControllerDriver : public vr::ITrackedDeviceServerDriver
585599

586600
// this file tells the UI what to show the user for binding this controller as well as what default bindings should
587601
// be for legacy or other apps
588-
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, Prop_InputProfilePath_String, "{null}/input/mycontroller_profile.json" );
602+
vr::VRProperties()->SetStringProperty( m_ulPropertyContainer, Prop_InputProfilePath_String, "{tovr}/input/mycontroller_profile.json" );
589603

590604
// Buttons handles
591605
vr::VRDriverInput()->CreateBooleanComponent(m_ulPropertyContainer, "/input/application_menu/click", &HButtons[0]);
@@ -618,7 +632,15 @@ class CSampleControllerDriver : public vr::ITrackedDeviceServerDriver
618632

619633
virtual void Deactivate()
620634
{
621-
m_unObjectId = vr::k_unTrackedDeviceIndexInvalid;
635+
switch (ControllerIndex)
636+
{
637+
case 1:
638+
Ctrl1Index_t = vr::k_unTrackedDeviceIndexInvalid;
639+
break;
640+
case 2:
641+
Ctrl2Index_t = vr::k_unTrackedDeviceIndexInvalid;
642+
break;
643+
}
622644
}
623645

624646

@@ -736,9 +758,22 @@ class CSampleControllerDriver : public vr::ITrackedDeviceServerDriver
736758
SetCentering(2);
737759
}
738760

739-
if (m_unObjectId != vr::k_unTrackedDeviceIndexInvalid)
740-
{
741-
vr::VRServerDriverHost()->TrackedDevicePoseUpdated(m_unObjectId, GetPose(), sizeof(DriverPose_t));
761+
if (ControllerIndex == 1) {
762+
763+
if (Ctrl1Index_t != vr::k_unTrackedDeviceIndexInvalid)
764+
{
765+
vr::VRServerDriverHost()->TrackedDevicePoseUpdated(Ctrl1Index_t, GetPose(), sizeof(DriverPose_t));
766+
}
767+
768+
}
769+
770+
if (ControllerIndex == 2) {
771+
772+
if (Ctrl2Index_t != vr::k_unTrackedDeviceIndexInvalid)
773+
{
774+
vr::VRServerDriverHost()->TrackedDevicePoseUpdated(Ctrl2Index_t, GetPose(), sizeof(DriverPose_t));
775+
}
776+
742777
}
743778

744779
#endif
@@ -774,7 +809,8 @@ class CSampleControllerDriver : public vr::ITrackedDeviceServerDriver
774809
}
775810

776811
private:
777-
vr::TrackedDeviceIndex_t m_unObjectId;
812+
vr::TrackedDeviceIndex_t Ctrl1Index_t;
813+
vr::TrackedDeviceIndex_t Ctrl2Index_t;
778814
vr::PropertyContainerHandle_t m_ulPropertyContainer;
779815

780816
//vr::VRInputComponentHandle_t m_compA;
@@ -815,8 +851,11 @@ EVRInitError CServerDriver_Sample::Init( vr::IVRDriverContext *pDriverContext )
815851
VR_INIT_SERVER_DRIVER_CONTEXT( pDriverContext );
816852
//InitDriverLog( vr::VRDriverLog() );
817853

818-
m_pNullHmdLatest = new CSampleDeviceDriver();
819-
vr::VRServerDriverHost()->TrackedDeviceAdded( m_pNullHmdLatest->GetSerialNumber().c_str(), vr::TrackedDeviceClass_HMD, m_pNullHmdLatest );
854+
//if (HMDConnected)
855+
//{
856+
m_pNullHmdLatest = new CSampleDeviceDriver();
857+
vr::VRServerDriverHost()->TrackedDeviceAdded(m_pNullHmdLatest->GetSerialNumber().c_str(), vr::TrackedDeviceClass_HMD, m_pNullHmdLatest);
858+
//}
820859

821860
if (ctrlsConnected) {
822861
m_pController = new CSampleControllerDriver();
@@ -834,17 +873,22 @@ EVRInitError CServerDriver_Sample::Init( vr::IVRDriverContext *pDriverContext )
834873

835874
void CServerDriver_Sample::Cleanup()
836875
{
837-
if (hDll != NULL) FreeLibrary(hDll);
838-
hDll = nullptr;
839876
//CleanupDriverLog();
840-
delete m_pNullHmdLatest;
841-
m_pNullHmdLatest = NULL;
877+
//if (HMDConnected) {
878+
delete m_pNullHmdLatest;
879+
m_pNullHmdLatest = NULL;
880+
//}
881+
842882
if (ctrlsConnected) {
843883
delete m_pController;
844884
m_pController = NULL;
845885
delete m_pController2;
846886
m_pController2 = NULL;
847887
}
888+
if (hDll != NULL) {
889+
FreeLibrary(hDll);
890+
hDll = nullptr;
891+
}
848892
}
849893

850894

OpenVR/samples/driver_sample/driver_sample.vcxproj

Lines changed: 5 additions & 1 deletion
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.17134.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">
@@ -70,18 +70,22 @@
7070
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7171
<LinkIncremental>true</LinkIncremental>
7272
<OutDir>$(SolutionDir)\bin\drivers\sample\bin\win32\</OutDir>
73+
<TargetName>driver_tovr</TargetName>
7374
</PropertyGroup>
7475
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
7576
<LinkIncremental>true</LinkIncremental>
7677
<OutDir>$(SolutionDir)\bin\drivers\sample\bin\win64\</OutDir>
78+
<TargetName>driver_tovr</TargetName>
7779
</PropertyGroup>
7880
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
7981
<LinkIncremental>false</LinkIncremental>
8082
<OutDir>$(SolutionDir)\bin\drivers\sample\bin\win32\</OutDir>
83+
<TargetName>driver_tovr</TargetName>
8184
</PropertyGroup>
8285
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
8386
<LinkIncremental>false</LinkIncremental>
8487
<OutDir>$(SolutionDir)\bin\drivers\sample\bin\win64\</OutDir>
88+
<TargetName>driver_tovr</TargetName>
8589
</PropertyGroup>
8690
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
8791
<ClCompile>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"alwaysActivate": true,
3+
"name" : "tovr"
4+
}
5+

TrueOpenVR SteamVR/OpenVR/steamvr.vrsettings

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22
"dashboard" : {
33
"enableDashboard" : false
44
},
5-
"driver_null" : {
6-
"enable" : true,
7-
"id" : "Null Driver",
8-
"secondsFromVsyncToPhotons" : 0.10000000149011612,
9-
"serialNumber" : "Null 4711",
5+
"steamvr" : {
6+
"activateMultipleDrivers" : true,
7+
"allowAsyncReprojection" : false,
8+
"directMode" : false,
9+
"enableHomeApp" : false,
10+
"startMonitorFromAppLaunch" : false
11+
},
12+
"tovr" : {
13+
"secondsFromVsyncToPhotons" : 0.004999999888241291,
14+
"serialNumber" : "1000",
1015
"renderWidth" : <RENDERWIDTH>,
1116
"renderHeight" : <RENDERHEIGHT>,
1217
"windowWidth" : <WINDOWWIDTH>,
@@ -22,13 +27,5 @@
2227
"DistanceBetweenEyes" : 0,
2328
"ScreenOffsetX" : 0,
2429
"DebugMode" : <DEBUGMODE>
25-
},
26-
"steamvr" : {
27-
"activateMultipleDrivers" : true,
28-
"allowAsyncReprojection" : false,
29-
"directMode" : false,
30-
"enableHomeApp" : false,
31-
"forcedDriver" : "null",
32-
"startMonitorFromAppLaunch" : false
3330
}
3431
}

TrueOpenVR SteamVR/Unit1.pas

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ procedure TMain.InstallBtnClick(Sender: TObject);
103103

104104
if DirectoryExists(SteamPath) then begin
105105

106+
if FileExists(SteamPath + '\config\steamvr.vrsettings') then
107+
CopyFile(PChar(SteamPath + '\config\steamvr.vrsettings'), PChar(SteamPath + '\config\steamvr.vrsettings.bak'), false);
108+
106109
if FileExists(ExtractFilePath(ParamStr(0)) + 'OpenVR\steamvr.vrsettings') then begin
110+
107111
Config:=TStringList.Create;
108112
Config.LoadFromFile(ExtractFilePath(ParamStr(0)) + 'OpenVR\steamvr.vrsettings');
109113
Config.Text:=StringReplace(Config.Text, '<RENDERWIDTH>', IntToStr(RenderWidth), [rfReplaceAll]);
@@ -128,13 +132,20 @@ procedure TMain.InstallBtnClick(Sender: TObject);
128132
Config.SaveToFile(SteamPath + '\config\steamvr.vrsettings');
129133

130134
Config.Free;
135+
136+
CreateDir(SteamPath + '\steamapps\common\SteamVR\drivers\tovr');
137+
CreateDir(SteamPath + '\steamapps\common\SteamVR\drivers\tovr\bin');
138+
CreateDir(SteamPath + '\steamapps\common\SteamVR\drivers\tovr\bin\win32');
139+
CreateDir(SteamPath + '\steamapps\common\SteamVR\drivers\tovr\bin\win64');
140+
131141
end else begin
132142
Application.MessageBox('File "steamvr.vrsettings" not found.', PChar(Caption), MB_ICONERROR);
133143
Error:=true;
134144
end;
135145

136-
if not ((CopyFile(PChar(ExtractFilePath(ParamStr(0)) + 'OpenVR\DriverTOVR32.dll'), PChar(SteamPath + '\steamapps\common\SteamVR\drivers\null\bin\win32\driver_null.dll'), false)) and
137-
(CopyFile(PChar(ExtractFilePath(ParamStr(0)) + 'OpenVR\DriverTOVR64.dll'), PChar(SteamPath + '\steamapps\common\SteamVR\drivers\null\bin\win64\driver_null.dll'), false))) then begin
146+
if not ((CopyFile(PChar(ExtractFilePath(ParamStr(0)) + 'OpenVR\driver.vrdrivermanifest'), PChar(SteamPath + '\steamapps\common\SteamVR\drivers\tovr\driver.vrdrivermanifest'), false)) and
147+
(CopyFile(PChar(ExtractFilePath(ParamStr(0)) + 'OpenVR\bin\win32\driver_tovr.dll'), PChar(SteamPath + '\steamapps\common\SteamVR\drivers\tovr\bin\win32\driver_tovr.dll'), false)) and
148+
(CopyFile(PChar(ExtractFilePath(ParamStr(0)) + 'OpenVR\bin\win64\driver_tovr.dll'), PChar(SteamPath + '\steamapps\common\SteamVR\drivers\tovr\bin\win64\driver_tovr.dll'), false))) then begin
138149
Application.MessageBox('Error copy driver files. Please close Steam and SteamVR.', PChar(Caption), MB_ICONERROR);
139150
Error:=true;
140151
end;
@@ -158,7 +169,17 @@ procedure TMain.UninstallBtnClick(Sender: TObject);
158169
begin
159170
if DirectoryExists(SteamPath) then begin
160171
if FileExists(SteamPath + '\config\steamvr.vrsettings') then
161-
DeleteFile(SteamPath + '\config\steamvr.vrsettings');
172+
if FileExists(SteamPath + '\config\steamvr.vrsettings.bak') then begin
173+
CopyFile(PChar(SteamPath + '\config\steamvr.vrsettings.bak'), PChar(SteamPath + '\config\steamvr.vrsettings'), false);
174+
DeleteFile(SteamPath + '\config\steamvr.vrsettings.bak');
175+
end;
176+
DeleteFile(SteamPath + '\steamapps\common\SteamVR\drivers\tovr\driver.vrdrivermanifest');
177+
DeleteFile(SteamPath + '\steamapps\common\SteamVR\drivers\tovr\bin\win32\driver_tovr.dll');
178+
DeleteFile(SteamPath + '\steamapps\common\SteamVR\drivers\tovr\bin\win64\driver_tovr.dll');
179+
RemoveDir(SteamPath + '\steamapps\common\SteamVR\drivers\tovr\bin\win32');
180+
RemoveDir(SteamPath + '\steamapps\common\SteamVR\drivers\tovr\bin\win64');
181+
RemoveDir(SteamPath + '\steamapps\common\SteamVR\drivers\tovr\bin');
182+
RemoveDir(SteamPath + '\steamapps\common\SteamVR\drivers\tovr');
162183
Application.MessageBox('Uninstalled', PChar(Caption), MB_ICONINFORMATION);
163184
end else
164185
Application.MessageBox('Steam not found. Please install Steam and SteamVR', PChar(Caption), MB_ICONERROR);

0 commit comments

Comments
 (0)