diff --git a/src/mods/VR.cpp b/src/mods/VR.cpp index acdb0e66..3b4a5e3d 100644 --- a/src/mods/VR.cpp +++ b/src/mods/VR.cpp @@ -118,8 +118,25 @@ std::optional VR::initialize_openvr() { m_openvr->error = "OpenXR already loaded"; return Mod::on_initialize(); } + if (GetModuleHandleW(L"openvr_api.dll") == nullptr) { + HMODULE openvr_handle = nullptr; + const auto module_path = Framework::get_persistent_dir("..\\uevr\\openvr_api.dll"); + //SetDllDirectoryW(module_path.parent_path().c_str()); + openvr_handle = LoadLibraryW(module_path.c_str()); + + if (GetModuleHandleW(L"openvr_api.dll") == nullptr && GetModuleHandleW( module_path.c_str() ) == nullptr) { + if (utility::load_module_from_current_directory(L"openvr_api.dll") == nullptr) { + spdlog::info("[VR] Could not load openvr_api.dll"); + m_openvr->loaded = false; + m_openvr->error = "Could not load openvr_api.dll"; + return std::nullopt; + } + } + //else + //SetDllDirectoryW(nullptr); + } if (utility::load_module_from_current_directory(L"openvr_api.dll") == nullptr) { spdlog::info("[VR] Could not load openvr_api.dll"); @@ -249,6 +266,15 @@ std::optional VR::initialize_openxr() { spdlog::info("[VR] Initializing OpenXR"); if (GetModuleHandleW(L"openxr_loader.dll") == nullptr) { + HMODULE openxr_handle = nullptr; + // Glad that this just works + const auto module_path = Framework::get_persistent_dir("..\\uevr\\openxr_loader.dll"); + // temporarily set override dir to mod path. will experiment with doing this earlier to see if we can just ignore any game engine plugins without the nullifier + // SetDllDirectoryW(module_path.parent_path().c_str()); + // must use this flag to use set or add directory + openxr_handle = LoadLibraryW(module_path.c_str()); + // one might be tempted to use GetModuleHandleExW here but that's actually for loading from memory locations + if (GetModuleHandleW(L"openxr_loader.dll") == nullptr && GetModuleHandleW(module_path.c_str()) == nullptr) { if (utility::load_module_from_current_directory(L"openxr_loader.dll") == nullptr) { spdlog::info("[VR] Could not load openxr_loader.dll"); @@ -256,7 +282,10 @@ std::optional VR::initialize_openxr() { m_openxr->error = "Could not load openxr_loader.dll"; return std::nullopt; + } } + // unset override to restore normal dll path searching + // SetDllDirectoryW(nullptr); } if (g_framework->is_dx12()) { @@ -2398,7 +2427,8 @@ void VR::on_draw_sidebar_entry(std::string_view name) { ImGui::TextWrapped("Render Resolution (per-eye): %d x %d", get_runtime()->get_width(), get_runtime()->get_height()); ImGui::TextWrapped("Total Render Resolution: %d x %d", get_runtime()->get_width() * 2, get_runtime()->get_height()); - + ImGui::TextWrapped("Total Render Width: %d", get_runtime()->get_width() * 2); + ImGui::TextWrapped("Total Render Height: %d", get_runtime()->get_height()); if (get_runtime()->is_openvr()) { ImGui::TextWrapped("Resolution can be changed in SteamVR"); }