2nd potential fix for #7 and #8

This commit is contained in:
Alessandro Proto 2023-02-21 18:47:10 +01:00
parent 1c6419ff10
commit fd8b38932b
2 changed files with 27 additions and 7 deletions

View file

@ -58,4 +58,16 @@
<ItemGroup> <ItemGroup>
<EditorConfigFiles Remove="C:\Users\Alex\source\repos\Capy64\Capy64\Capy64\.editorconfig" /> <EditorConfigFiles Remove="C:\Users\Alex\source\repos\Capy64\Capy64\Capy64\.editorconfig" />
</ItemGroup> </ItemGroup>
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<DefineConstants>_WINDOWS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' ">
<DefineConstants>_LINUX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' ">
<DefineConstants>_OSX</DefineConstants>
</PropertyGroup>
</Project> </Project>

View file

@ -20,32 +20,40 @@ namespace Capy64.Extensions.Bindings;
public partial class SDL2 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) })] [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
internal static partial void SDL_MaximizeWindow(IntPtr window); internal static partial void SDL_MaximizeWindow(IntPtr window);
[LibraryImport(SDL)] [LibraryImport(LibraryName)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
internal static partial uint SDL_GetWindowFlags(IntPtr window); 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) })] [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
internal static partial IntPtr Native_SDL_GetClipboardText(); internal static partial IntPtr Native_SDL_GetClipboardText();
/// <summary> /// <summary>
/// </summary> /// </summary>
/// <returns>0 is false; 1 is true</returns> /// <returns>0 is false; 1 is true</returns>
[LibraryImport(SDL)] [LibraryImport(LibraryName)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
internal static partial int SDL_HasClipboardText(); 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) })] [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
internal static partial int Native_SDL_SetClipboardText(string contents); internal static partial int Native_SDL_SetClipboardText(string contents);
[LibraryImport(SDL)] [LibraryImport(LibraryName)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
internal static partial void SDL_free(IntPtr memblock); internal static partial void SDL_free(IntPtr memblock);