| 27 | std::map<Hack, HackInfo> g_hacks; |
| 28 | |
| 29 | ovrHmdStruct::ovrHmdStruct() |
| 30 | : AppKey() |
| 31 | , StringBuffer() |
| 32 | , TrackerCount(0) |
| 33 | , Status() |
| 34 | , ChaperoneBuffer() |
| 35 | , HmdDesc() |
| 36 | , RenderDesc() |
| 37 | , TrackerDesc() |
| 38 | , FrameIndex(0) |
| 39 | , StatsIndex(0) |
| 40 | , BaseStats() |
| 41 | , Compositor(nullptr) |
| 42 | , Input(new InputManager()) |
| 43 | { |
| 44 | Status.HmdPresent = vr::VR_IsHmdPresent(); |
| 45 | Status.HmdMounted = true; |
| 46 | Status.HasInputFocus = vr::VRSystem()->IsInputAvailable(); |
| 47 | Status.OverlayPresent = vr::VROverlay()->IsDashboardVisible(); |
| 48 | |
| 49 | char filepath[MAX_PATH]; |
| 50 | GetModuleFileNameA(NULL, filepath, MAX_PATH); |
| 51 | char* filename = PathFindFileNameA(filepath); |
| 52 | |
| 53 | vr::VRSystem()->GetStringTrackedDeviceProperty(vr::k_unTrackedDeviceIndex_Hmd, |
| 54 | vr::Prop_TrackingSystemName_String, StringBuffer, sizeof(StringBuffer)); |
| 55 | |
| 56 | for (auto& hack : g_known_hacks) |
| 57 | { |
| 58 | if ((!hack.m_filename || _stricmp(filename, hack.m_filename) == 0) && |
| 59 | (!hack.m_driver || strcmp(StringBuffer, hack.m_driver) == 0)) |
| 60 | { |
| 61 | if (hack.m_usehack) |
| 62 | g_hacks.emplace(hack.m_hack, hack); |
| 63 | } |
| 64 | else if (!hack.m_usehack) |
| 65 | { |
| 66 | g_hacks.emplace(hack.m_hack, hack); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | vr::VRApplications()->GetApplicationKeyByProcessId(GetCurrentProcessId(), AppKey, sizeof(AppKey)); |
| 71 | |
| 72 | // Export the chaperone buffer so we can reset the tracking origin on graceful shutdown |
| 73 | uint32_t size = 0; |
| 74 | vr::VRChaperoneSetup()->ExportLiveToBuffer(nullptr, &size); |
| 75 | ChaperoneBuffer.resize(size); |
| 76 | vr::VRChaperoneSetup()->ExportLiveToBuffer(ChaperoneBuffer.data(), &size); |
| 77 | assert(size == ChaperoneBuffer.size()); |
| 78 | |
| 79 | // Oculus games expect a seated tracking space by default |
| 80 | vr::VRCompositor()->SetTrackingSpace(vr::TrackingUniverseSeated); |
| 81 | |
| 82 | UpdateHmdDesc(); |
| 83 | UpdateTrackerDesc(); |
| 84 | } |
| 85 | |
| 86 | ovrHmdStruct::~ovrHmdStruct() |