diff options
author | Mary-nyan <mary@mary.zone> | 2022-11-17 00:18:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-17 00:18:29 +0100 |
commit | 5d73a9f5fce23b030821f5fb2d71855099f14ec2 (patch) | |
tree | f32d8c5b6e5e5702f91d963af107570fb2d6d9d9 /Ryujinx/Program.cs | |
parent | 2c9ab5e45fd45d45909b9b348580c44bdfc4d36f (diff) |
Fix Fedora support (#3815)1.1.351
For some reasons, my fresh installation of Fedora 36 (KDE) doesn't have a
symlink for libX11.so.
This commit fixes this by trying to import the library with its major
version or fallback to the normal way.
Diffstat (limited to 'Ryujinx/Program.cs')
-rw-r--r-- | Ryujinx/Program.cs | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/Ryujinx/Program.cs b/Ryujinx/Program.cs index a91f9aa5..be790a48 100644 --- a/Ryujinx/Program.cs +++ b/Ryujinx/Program.cs @@ -29,7 +29,11 @@ namespace Ryujinx public static string ConfigurationPath { get; set; } - [DllImport("libX11")] + public static string CommandLineProfile { get; set; } + + private const string X11LibraryName = "libX11"; + + [DllImport(X11LibraryName)] private extern static int XInitThreads(); [DllImport("user32.dll", SetLastError = true)] @@ -37,6 +41,30 @@ namespace Ryujinx private const uint MB_ICONWARNING = 0x30; + static Program() + { + if (OperatingSystem.IsLinux()) + { + NativeLibrary.SetDllImportResolver(typeof(Program).Assembly, (name, assembly, path) => + { + if (name != X11LibraryName) + { + return IntPtr.Zero; + } + + if (!NativeLibrary.TryLoad("libX11.so.6", assembly, path, out IntPtr result)) + { + if (!NativeLibrary.TryLoad("libX11.so", assembly, path, out result)) + { + return IntPtr.Zero; + } + } + + return result; + }); + } + } + static void Main(string[] args) { Version = ReleaseInformations.GetVersion(); |