From fd8b38932b3b8d333177bb4558e93cd95cffc3b6 Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Tue, 21 Feb 2023 18:47:10 +0100 Subject: [PATCH] 2nd potential fix for #7 and #8 --- Capy64/Capy64.csproj | 12 ++++++++++++ Capy64/Extensions/Bindings/SDL2.cs | 22 +++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Capy64/Capy64.csproj b/Capy64/Capy64.csproj index dd76ecf..e012d5b 100644 --- a/Capy64/Capy64.csproj +++ b/Capy64/Capy64.csproj @@ -58,4 +58,16 @@ + + + _WINDOWS + + + + _LINUX + + + + _OSX + \ No newline at end of file diff --git a/Capy64/Extensions/Bindings/SDL2.cs b/Capy64/Extensions/Bindings/SDL2.cs index 7fa3884..5f1a783 100644 --- a/Capy64/Extensions/Bindings/SDL2.cs +++ b/Capy64/Extensions/Bindings/SDL2.cs @@ -20,32 +20,40 @@ namespace Capy64.Extensions.Bindings; public partial class SDL2 { - private const string SDL = "SDL2"; +#if _WINDOWS + private const string LibraryName = "SDL2.dll"; +#elif _LINUX + private const string LibraryName = "libSDL2-2.0.so.0"; +#elif _OSX + private const string LibraryName = "libSDL2.dylib"; +#else + private const string LibraryName = "SDL2"; +#endif - [LibraryImport(SDL)] + [LibraryImport(LibraryName)] [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] internal static partial void SDL_MaximizeWindow(IntPtr window); - [LibraryImport(SDL)] + [LibraryImport(LibraryName)] [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] internal static partial uint SDL_GetWindowFlags(IntPtr window); - [LibraryImport(SDL, EntryPoint = "SDL_GetClipboardText")] + [LibraryImport(LibraryName, EntryPoint = "SDL_GetClipboardText")] [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] internal static partial IntPtr Native_SDL_GetClipboardText(); /// /// /// 0 is false; 1 is true - [LibraryImport(SDL)] + [LibraryImport(LibraryName)] [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] internal static partial int SDL_HasClipboardText(); - [LibraryImport(SDL, EntryPoint = "SDL_SetClipboardText", StringMarshalling = StringMarshalling.Utf8)] + [LibraryImport(LibraryName, EntryPoint = "SDL_SetClipboardText", StringMarshalling = StringMarshalling.Utf8)] [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] internal static partial int Native_SDL_SetClipboardText(string contents); - [LibraryImport(SDL)] + [LibraryImport(LibraryName)] [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] internal static partial void SDL_free(IntPtr memblock);