Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added global plugins and profiles #223

Merged
merged 4 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/mods/PluginLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,8 @@ void PluginLoader::early_init() try {
spdlog::info("[PluginLoader] Module path {}", utility::narrow(module_path));

const auto plugin_path = Framework::get_persistent_dir() / "plugins";

const auto global_plugins_path = Framework::get_persistent_dir() / ".." / "UEVR" / "plugins";

spdlog::info("[PluginLoader] Creating directories {}", plugin_path.string());

if (!fs::create_directories(plugin_path) && !fs::exists(plugin_path)) {
Expand All @@ -1272,6 +1273,24 @@ void PluginLoader::early_init() try {

spdlog::info("[PluginLoader] Loading plugins...");

// Load all dlls in the global UEVR\plugins directory
for (auto&& entry : fs::directory_iterator{global_plugins_path}) {
auto&& path = entry.path();

if (path.has_extension() && path.extension() == ".dll") {
auto module = LoadLibrary(path.string().c_str());

if (module == nullptr) {
spdlog::error("[PluginLoader] Failed to load {}", path.string());
m_plugin_load_errors.emplace(path.stem().string(), "Failed to load");
continue;
}

spdlog::info("[PluginLoader] Loaded {}", path.string());
m_plugins.emplace(path.stem().string(), module);
}
}

// Load all dlls in the plugins directory.
for (auto&& entry : fs::directory_iterator{plugin_path}) {
auto&& path = entry.path();
Expand Down Expand Up @@ -1777,4 +1796,4 @@ bool PluginLoader::add_on_post_viewport_client_draw(UEVR_ViewportClient_DrawCb c

m_on_post_viewport_client_draw_cbs.push_back(cb);
return true;
}
}
13 changes: 10 additions & 3 deletions src/mods/vr/runtimes/OpenXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,12 +983,19 @@ std::optional<std::string> OpenXR::initialize_actions(const std::string& json_st
}
}

auto filename = controller + ".json";
auto profile_file = controller + ".json";

// replace the slashes with underscores
std::replace(filename.begin(), filename.end(), '/', '_');
std::replace(profile_file.begin(), profile_file.end(), '/', '_');

// If the json exists in the game's profile dir, use that.
auto filename = (Framework::get_persistent_dir() / profile_file).string();

filename = (Framework::get_persistent_dir() / filename).string();
// If not, check for global profile in UEVR\Profiles dir
if (!std::filesystem::exists(filename)) {
filename = (Framework::get_persistent_dir() / ".." / "UEVR" / "Profiles" / profile_file).string();
spdlog::info("[VR] Setting bindings file to {}", filename);
}

// check if the file exists
if (std::filesystem::exists(filename)) {
Expand Down