This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
forked from ryancheung/MonoGame.IMEHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSDL2.cs
46 lines (40 loc) · 1.71 KB
/
SDL2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#if !WINDOWSDX
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace MonoGame.IMEHelper
{
internal static class Sdl
{
public static IntPtr NativeLibrary = GetNativeLibrary();
private static IntPtr GetNativeLibrary()
{
if (CurrentPlatform.OS == OS.Windows)
return FuncLoader.LoadLibraryExt("SDL2.dll");
else if (CurrentPlatform.OS == OS.Linux)
return FuncLoader.LoadLibraryExt("libSDL2-2.0.so.0");
else if (CurrentPlatform.OS == OS.MacOSX)
return FuncLoader.LoadLibraryExt("libSDL2-2.0.0.dylib");
else
return FuncLoader.LoadLibraryExt("sdl2");
}
[StructLayout(LayoutKind.Sequential)]
public struct Rectangle
{
public int X;
public int Y;
public int Width;
public int Height;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void d_sdl_starttextinput();
public static d_sdl_starttextinput StartTextInput = FuncLoader.LoadFunction<d_sdl_starttextinput>(NativeLibrary, "SDL_StartTextInput");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void d_sdl_stoptextinput();
public static d_sdl_stoptextinput StopTextInput = FuncLoader.LoadFunction<d_sdl_stoptextinput>(NativeLibrary, "SDL_StopTextInput");
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void d_sdl_settextinputrect(ref Rectangle rect);
public static d_sdl_settextinputrect SetTextInputRect = FuncLoader.LoadFunction<d_sdl_settextinputrect>(NativeLibrary, "SDL_SetTextInputRect");
}
}
#endif