[SDL2] Added JoystickGetGUID method

This commit is contained in:
thefiddler 2013-12-31 14:08:28 +01:00
parent 1687518ef5
commit cd143af60a

View file

@ -300,6 +300,10 @@ namespace OpenTK.Platform.SDL2
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_JoystickGetButton", ExactSpelling = true)] [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_JoystickGetButton", ExactSpelling = true)]
public static extern byte JoystickGetButton(IntPtr joystick, int button); public static extern byte JoystickGetButton(IntPtr joystick, int button);
[SuppressUnmanagedCodeSecurity]
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_JoystickGetGuid", ExactSpelling = true)]
public static extern JoystickGuid JoystickGetGUID(IntPtr joystick);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_JoystickName", ExactSpelling = true)] [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_JoystickName", ExactSpelling = true)]
static extern IntPtr JoystickNameInternal(IntPtr joystick); static extern IntPtr JoystickNameInternal(IntPtr joystick);
@ -1404,6 +1408,26 @@ namespace OpenTK.Platform.SDL2
byte padding2; byte padding2;
} }
struct JoystickGuid
{
unsafe fixed byte data[16];
public Guid ToGuid()
{
byte[] bytes = new byte[16];
unsafe
{
fixed (byte* pdata = data)
{
Marshal.Copy(new IntPtr(pdata), bytes, 0, bytes.Length);
}
}
return new Guid(bytes);
}
}
struct KeyboardEvent struct KeyboardEvent
{ {
public EventType Type; public EventType Type;