diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2023-07-17 10:57:41 +0200 |
---|---|---|
committer | Sefa Eyeoglu <contact@scrumplex.net> | 2023-08-15 10:50:38 +0200 |
commit | ff67fd10c33fa99423b5a43dcbd30494b4c40dc5 (patch) | |
tree | 067fc32fabe8249bdd40cd4a79de5dbcaaaa27d6 /launcher/MangoHud.cpp | |
parent | 7ba1e7d3569fcb04cb49d16247703bf2862172ba (diff) | |
download | PrismLauncher-ff67fd10c33fa99423b5a43dcbd30494b4c40dc5.tar.gz PrismLauncher-ff67fd10c33fa99423b5a43dcbd30494b4c40dc5.tar.bz2 PrismLauncher-ff67fd10c33fa99423b5a43dcbd30494b4c40dc5.zip |
feat: implement override for GLFW/OpenAL with split natives
Fixes PrismLauncher/PrismLauncher#513
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
Diffstat (limited to 'launcher/MangoHud.cpp')
-rw-r--r-- | launcher/MangoHud.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/launcher/MangoHud.cpp b/launcher/MangoHud.cpp index 5758da3a..ab79f418 100644 --- a/launcher/MangoHud.cpp +++ b/launcher/MangoHud.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ +#include <QDebug> #include <QDir> #include <QString> #include <QStringList> @@ -26,6 +27,15 @@ #include "Json.h" #include "MangoHud.h" +#ifdef __GLIBC__ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#define UNDEF_GNU_SOURCE +#endif +#include <dlfcn.h> +#include <linux/limits.h> +#endif + namespace MangoHud { QString getLibraryString() @@ -106,4 +116,37 @@ QString getLibraryString() return QString(); } + +QString findLibrary(QString libName) +{ +#ifdef __GLIBC__ + const char* library = libName.toLocal8Bit().constData(); + + void* handle = dlopen(library, RTLD_NOW); + if (!handle) { + qCritical() << "dlopen() failed:" << dlerror(); + return {}; + } + + char path[PATH_MAX]; + if (dlinfo(handle, RTLD_DI_ORIGIN, path) == -1) { + qCritical() << "dlinfo() failed:" << dlerror(); + dlclose(handle); + return {}; + } + + auto fullPath = FS::PathCombine(QString(path), libName); + + dlclose(handle); + return fullPath; +#else + qWarning() << "MangoHud::findLibrary is not implemented on this platform"; + return {}; +#endif +} } // namespace MangoHud + +#ifdef UNDEF_GNU_SOURCE +#undef _GNU_SOURCE +#undef UNDEF_GNU_SOURCE +#endif |