MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / enable

Method enable

Engine/source/platform/input/openVR/openVRProvider.cpp:539–632  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

537}
538
539bool OpenVRProvider::enable()
540{
541 mOpenVRNS = Namespace::find(StringTable->insert("OpenVR"));
542
543 disable();
544
545 // Load openvr runtime
546 vr::EVRInitError eError = vr::VRInitError_None;
547 mHMD = vr::VR_Init(&eError, vr::VRApplication_Scene);
548
549 dMemset(mDeviceClassChar, '\0', sizeof(mDeviceClassChar));
550
551 if (eError != vr::VRInitError_None)
552 {
553 mHMD = NULL;
554 char buf[1024];
555 sprintf_s(buf, sizeof(buf), "Unable to init VR runtime: %s", vr::VR_GetVRInitErrorAsEnglishDescription(eError));
556 Con::printf(buf);
557 return false;
558 }
559
560 dMemset(&mLUID, '\0', sizeof(mLUID));
561
562#ifdef TORQUE_OS_WIN32
563
564 // For windows we need to lookup the DXGI record for this and grab the LUID for the display adapter. We need the LUID since
565 // T3D uses EnumAdapters1 not EnumAdapters whereas openvr uses EnumAdapters.
566 int32_t AdapterIdx;
567 IDXGIAdapter* EnumAdapter;
568 IDXGIFactory1* DXGIFactory;
569 mHMD->GetDXGIOutputInfo(&AdapterIdx);
570 // Get the LUID of the device
571
572 HRESULT hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), reinterpret_cast<void**>(&DXGIFactory));
573
574 if (FAILED(hr))
575 AssertFatal(false, "OpenVRProvider::enable -> CreateDXGIFactory1 call failure");
576
577 hr = DXGIFactory->EnumAdapters(AdapterIdx, &EnumAdapter);
578
579 if (FAILED(hr))
580 {
581 Con::warnf("VR: HMD device has an invalid adapter.");
582 }
583 else
584 {
585 DXGI_ADAPTER_DESC desc;
586 hr = EnumAdapter->GetDesc(&desc);
587 if (FAILED(hr))
588 {
589 Con::warnf("VR: HMD device has an invalid adapter.");
590 }
591 else
592 {
593 dMemcpy(&mLUID, &desc.AdapterLuid, sizeof(mLUID));
594 }
595 SAFE_RELEASE(EnumAdapter);
596 }

Callers 2

TESTFunction · 0.45
openVRProvider.cppFile · 0.45

Calls 9

findFunction · 0.85
printfFunction · 0.85
warnfFunction · 0.85
GetTrackedDeviceStringFunction · 0.85
dMemsetFunction · 0.50
dMemcpyFunction · 0.50
MatrixFClass · 0.50
insertMethod · 0.45
resetMethod · 0.45

Tested by 1

TESTFunction · 0.36