From e395a5114d45f7977d5e1ccf8e33590b0686245d Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Sat, 18 Oct 2014 12:39:00 -0400 Subject: [PATCH 01/13] 2.0.4 mouse additions --- src/SDL2.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/SDL2.cs b/src/SDL2.cs index 65d34b6..ed5c14a 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -4393,6 +4393,25 @@ namespace SDL2 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 SDL_GetMouseState(IntPtr x, IntPtr y); + /* Get the current state of the mouse, in relation to the desktop */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetGlobalMouseState(out int x, out int y); + + /* Get the current state of the mouse, in relation to the desktop */ + /* This overload allows for passing NULL to x */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetGlobalMouseState(IntPtr x, out int y); + + /* Get the current state of the mouse, in relation to the desktop */ + /* This overload allows for passing NULL to y */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetGlobalMouseState(out int x, IntPtr y); + + /* Get the current state of the mouse, in relation to the desktop */ + /* This overload allows for passing NULL to both x and y */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetGlobalMouseState(IntPtr x, IntPtr y); + /* Get the mouse state with relative coords*/ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 SDL_GetRelativeMouseState(out int x, out int y); @@ -4402,6 +4421,10 @@ namespace SDL2 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void SDL_WarpMouseInWindow(IntPtr window, int x, int y); + /* Set the mouse cursor's position in global screen space */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_WarpMouseGlobal(int x, int y); + /* Enable/Disable relative mouse mode (grabs mouse, rel coords) */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int SDL_SetRelativeMouseMode(SDL_bool enabled); From 9a1f823bcae2852b8797cfdcb86bbc74fa8e390d Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Sat, 18 Oct 2014 12:50:39 -0400 Subject: [PATCH 02/13] 2.0.4 GUI backend additions --- src/SDL2.cs | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/SDL2.cs b/src/SDL2.cs index ed5c14a..8c833bb 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -1003,7 +1003,26 @@ namespace SDL2 SDL_WINDOW_FULLSCREEN_DESKTOP = (SDL_WINDOW_FULLSCREEN | 0x00001000), SDL_WINDOW_FOREIGN = 0x00000800, - SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000 /* Only available in 2.0.1 */ + SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /* Only available in 2.0.1 */ + SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /* Only available in 2.0.4 */ + } + + /// + /// Possible return values from the SDL_HitTest callback. + /// This is only available in 2.0.4. + /// + public enum SDL_HitTestResult + { + SDL_HITTEST_NORMAL, /* Region is normal. No special properties. */ + SDL_HITTEST_DRAGGABLE, /* Region can drag entire window. */ + SDL_HITTEST_RESIZE_TOPLEFT, + SDL_HITTEST_RESIZE_TOP, + SDL_HITTEST_RESIZE_TOPRIGHT, + SDL_HITTEST_RESIZE_RIGHT, + SDL_HITTEST_RESIZE_BOTTOMRIGHT, + SDL_HITTEST_RESIZE_BOTTOM, + SDL_HITTEST_RESIZE_BOTTOMLEFT, + SDL_HITTEST_RESIZE_LEFT } public const int SDL_WINDOWPOS_UNDEFINED_MASK = 0x1FFF0000; @@ -1044,6 +1063,10 @@ namespace SDL2 public IntPtr driverdata; // void* } + /* win refers to an SDL_Window*, area to a cosnt SDL_Point*, data to a void* */ + /* Only available in 2.0.4 */ + public delegate SDL_HitTestResult SDL_HitTest(IntPtr win, IntPtr area, IntPtr data); + /// /// Use this function to create a window with the specified position, dimensions, and flags. /// @@ -1620,6 +1643,15 @@ namespace SDL2 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void SDL_VideoQuit(); + /* window refers to an SDL_Window*, callback_data to a void* */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_SetWindowHitTest( + IntPtr window, + SDL_HitTest callback, + IntPtr callback_data + ); + #endregion #region SDL_render.h @@ -2651,6 +2683,10 @@ namespace SDL2 public int h; } + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_PointInRect(ref SDL_Point p, ref SDL_Rect r); + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern SDL_bool SDL_EnclosePoints( [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Struct, SizeParamIndex = 1)] @@ -4394,20 +4430,24 @@ namespace SDL2 public static extern UInt32 SDL_GetMouseState(IntPtr x, IntPtr y); /* Get the current state of the mouse, in relation to the desktop */ + /* Only available in 2.0.4 */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 SDL_GetGlobalMouseState(out int x, out int y); /* Get the current state of the mouse, in relation to the desktop */ + /* Only available in 2.0.4 */ /* This overload allows for passing NULL to x */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 SDL_GetGlobalMouseState(IntPtr x, out int y); /* Get the current state of the mouse, in relation to the desktop */ + /* Only available in 2.0.4 */ /* This overload allows for passing NULL to y */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 SDL_GetGlobalMouseState(out int x, IntPtr y); /* Get the current state of the mouse, in relation to the desktop */ + /* Only available in 2.0.4 */ /* This overload allows for passing NULL to both x and y */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern UInt32 SDL_GetGlobalMouseState(IntPtr x, IntPtr y); @@ -4422,6 +4462,7 @@ namespace SDL2 public static extern void SDL_WarpMouseInWindow(IntPtr window, int x, int y); /* Set the mouse cursor's position in global screen space */ + /* Only available in 2.0.4 */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void SDL_WarpMouseGlobal(int x, int y); @@ -4429,6 +4470,11 @@ namespace SDL2 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int SDL_SetRelativeMouseMode(SDL_bool enabled); + /* Capture the mouse, to track input outside an SDL window */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_CaptureMouse(SDL_bool enabled); + /* Query if the relative mouse mode is enabled */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern SDL_bool SDL_GetRelativeMouseMode(); From 818a5cb6e08087956e899cedb4f9c998b299957b Mon Sep 17 00:00:00 2001 From: David Barnett Date: Sun, 26 Oct 2014 15:36:18 +1300 Subject: [PATCH 03/13] Fix SDL_GetScancodeFromKey signature --- src/SDL2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SDL2.cs b/src/SDL2.cs index 8c833bb..e6264bf 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -4330,7 +4330,7 @@ namespace SDL2 /* Get the scancode for the given keycode */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_GetScancodeFromKey(SDL_Keycode key); + public static extern SDL_Scancode SDL_GetScancodeFromKey(SDL_Keycode key); /* Wrapper for SDL_GetScancodeName */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] From 9c475e36fafb40f1fb795e0af994e6b2fc9f2012 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Tue, 18 Nov 2014 10:26:32 -0500 Subject: [PATCH 04/13] CreateSoftwareRenderer fix --- src/SDL2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SDL2.cs b/src/SDL2.cs index e6264bf..d1e5517 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -1709,7 +1709,7 @@ namespace SDL2 /* IntPtr refers to an SDL_Renderer*, surface to an SDL_Surface* */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr SDL_CreateRenderer(IntPtr surface); + public static extern IntPtr SDL_CreateSoftwareRenderer(IntPtr surface); /* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] From 784cda961f6e6d26c0f8a32bcc34da1682423a43 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Thu, 4 Dec 2014 20:01:57 -0500 Subject: [PATCH 05/13] SDL_Render rendertarget funcs --- src/SDL2.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/SDL2.cs b/src/SDL2.cs index d1e5517..a5185c2 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -2133,6 +2133,16 @@ namespace SDL2 int pitch ); + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_RenderTargetSupported( + IntPtr renderer + ); + + /* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GetRenderTarget(IntPtr renderer); + #endregion #region SDL_pixels.h From 7a248e26780f3df279cd44ca641a528e43f555a9 Mon Sep 17 00:00:00 2001 From: David Barnett Date: Sun, 7 Dec 2014 12:55:56 +1300 Subject: [PATCH 06/13] Added SDL_GetRendererOutputSize --- src/SDL2.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/SDL2.cs b/src/SDL2.cs index a5185c2..6c0a7a4 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -1776,6 +1776,14 @@ namespace SDL2 out SDL_RendererInfo info ); + /* renderer refers to an SDL_Renderer* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetRendererOutputSize( + IntPtr renderer, + out int w, + out int h + ); + /* texture refers to an SDL_Texture* */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int SDL_GetTextureAlphaMod( From a273ea9a18d4c9d8cdb4db35f986a956fa1fef99 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Fri, 26 Dec 2014 11:16:08 -0500 Subject: [PATCH 07/13] Render*Rect NULL overloads --- src/SDL2.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/SDL2.cs b/src/SDL2.cs index 6c0a7a4..9d31586 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -1973,6 +1973,15 @@ namespace SDL2 ref SDL_Rect rect ); + /* renderer refers to an SDL_Renderer*, rect to an SDL_Rect*. + * This overload allows for IntPtr.Zero (null) to be passed for rect. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderDrawRect( + IntPtr renderer, + IntPtr rect + ); + /* renderer refers to an SDL_Renderer* */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int SDL_RenderDrawRects( @@ -1989,6 +1998,15 @@ namespace SDL2 ref SDL_Rect rect ); + /* renderer refers to an SDL_Renderer*, rect to an SDL_Rect*. + * This overload allows for IntPtr.Zero (null) to be passed for rect. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_RenderFillRect( + IntPtr renderer, + IntPtr rect + ); + /* renderer refers to an SDL_Renderer* */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int SDL_RenderFillRects( From 6ca6862d7ed50c50a9271340fa10a48b419d1d6b Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Sat, 27 Dec 2014 22:14:52 -0500 Subject: [PATCH 08/13] A few SDL2_image RWops funcs --- src/SDL2_image.cs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/SDL2_image.cs b/src/SDL2_image.cs index 13308b4..cac3cab 100644 --- a/src/SDL2_image.cs +++ b/src/SDL2_image.cs @@ -102,6 +102,16 @@ namespace SDL2 int freesrc ); + /* src refers to an SDL_RWops*, IntPtr to an SDL_Surface* */ + /* THIS IS A PUBLIC RWops FUNCTION! */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr IMG_LoadTyped_RW( + IntPtr src, + int freesrc, + [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] + string type + ); + /* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr IMG_LoadTexture( @@ -110,6 +120,32 @@ namespace SDL2 string file ); + /* renderer refers to an SDL_Renderer*. + * src refers to an SDL_RWops*. + * IntPtr to an SDL_Texture*. + */ + /* THIS IS A PUBLIC RWops FUNCTION! */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr IMG_LoadTexture_RW( + IntPtr renderer, + IntPtr src, + int freesrc + ); + + /* renderer refers to an SDL_Renderer*. + * src refers to an SDL_RWops*. + * IntPtr to an SDL_Texture*. + */ + /* THIS IS A PUBLIC RWops FUNCTION! */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr IMG_LoadTextureTyped_RW( + IntPtr renderer, + IntPtr src, + int freesrc, + [In()] [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(LPUtf8StrMarshaler))] + string type + ); + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int IMG_InvertAlpha(int on); From 62a28724f219a1a620a7a34afd9b7a1ebdb339b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elis=C3=A9e?= Date: Tue, 6 Jan 2015 02:11:40 +0100 Subject: [PATCH 09/13] Fix SDLK_DELETE value: 0177 (octal), 127 (decimal) --- src/SDL2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SDL2.cs b/src/SDL2.cs index 9d31586..2733d8a 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -4132,7 +4132,7 @@ namespace SDL2 SDLK_INSERT = (int)SDL_Scancode.SDL_SCANCODE_INSERT | SDLK_SCANCODE_MASK, SDLK_HOME = (int)SDL_Scancode.SDL_SCANCODE_HOME | SDLK_SCANCODE_MASK, SDLK_PAGEUP = (int)SDL_Scancode.SDL_SCANCODE_PAGEUP | SDLK_SCANCODE_MASK, - SDLK_DELETE = 177, + SDLK_DELETE = 127, SDLK_END = (int)SDL_Scancode.SDL_SCANCODE_END | SDLK_SCANCODE_MASK, SDLK_PAGEDOWN = (int)SDL_Scancode.SDL_SCANCODE_PAGEDOWN | SDLK_SCANCODE_MASK, SDLK_RIGHT = (int)SDL_Scancode.SDL_SCANCODE_RIGHT | SDLK_SCANCODE_MASK, From 83012b9866aff26430ba36f1d3a9bc8651274ebe Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Thu, 21 May 2015 12:54:41 -0400 Subject: [PATCH 10/13] Happy New Year, wait what month is it --- LICENSE | 2 +- src/LPUtf8StrMarshaler.cs | 2 +- src/SDL2.cs | 2 +- src/SDL2_image.cs | 2 +- src/SDL2_mixer.cs | 2 +- src/SDL2_ttf.cs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/LICENSE b/LICENSE index 4eed3cc..1323765 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ /* SDL2# - C# Wrapper for SDL2 * - * Copyright (c) 2013-2014 Ethan Lee. + * Copyright (c) 2013-2015 Ethan Lee. * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from diff --git a/src/LPUtf8StrMarshaler.cs b/src/LPUtf8StrMarshaler.cs index ea51de1..bc28039 100644 --- a/src/LPUtf8StrMarshaler.cs +++ b/src/LPUtf8StrMarshaler.cs @@ -1,6 +1,6 @@ /* SDL2# - C# Wrapper for SDL2 * - * Copyright (c) 2013-2014 Ethan Lee. + * Copyright (c) 2013-2015 Ethan Lee. * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from diff --git a/src/SDL2.cs b/src/SDL2.cs index 2733d8a..a464d93 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -1,7 +1,7 @@ #region License /* SDL2# - C# Wrapper for SDL2 * - * Copyright (c) 2013-2014 Ethan Lee. + * Copyright (c) 2013-2015 Ethan Lee. * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from diff --git a/src/SDL2_image.cs b/src/SDL2_image.cs index cac3cab..e57c1b7 100644 --- a/src/SDL2_image.cs +++ b/src/SDL2_image.cs @@ -1,7 +1,7 @@ #region License /* SDL2# - C# Wrapper for SDL2 * - * Copyright (c) 2013-2014 Ethan Lee. + * Copyright (c) 2013-2015 Ethan Lee. * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from diff --git a/src/SDL2_mixer.cs b/src/SDL2_mixer.cs index 7c515c4..193c6df 100644 --- a/src/SDL2_mixer.cs +++ b/src/SDL2_mixer.cs @@ -1,7 +1,7 @@ #region License /* SDL2# - C# Wrapper for SDL2 * - * Copyright (c) 2013-2014 Ethan Lee. + * Copyright (c) 2013-2015 Ethan Lee. * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from diff --git a/src/SDL2_ttf.cs b/src/SDL2_ttf.cs index b404446..ef1cfe3 100644 --- a/src/SDL2_ttf.cs +++ b/src/SDL2_ttf.cs @@ -1,7 +1,7 @@ #region License /* SDL2# - C# Wrapper for SDL2 * - * Copyright (c) 2013-2014 Ethan Lee. + * Copyright (c) 2013-2015 Ethan Lee. * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from From dbffbe778be346467f91cb6da7b8356d0fa67cc0 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Sat, 13 Jun 2015 19:15:08 -0400 Subject: [PATCH 11/13] SDL 2.0.4 RC1 --- src/SDL2.cs | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/src/SDL2.cs b/src/SDL2.cs index a464d93..ce0ff09 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -252,6 +252,16 @@ namespace SDL2 public const string SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES = "SDL_VIDEO_MAC_FULLSCREEN_SPACES"; + /* Only available in SDL 2.0.4 or higher */ + public const string SDL_HINT_NO_SIGNAL_HANDLERS = + "SDL_NO_SIGNAL_HANDLERS"; + public const string SDL_HINT_IME_INTERNAL_EDITING = + "SDL_IME_INTERNAL_EDITING"; + public const string SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH = + "SDL_ANDROID_SEPARATE_MOUSE_AND_TOUCH"; + public const string SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT = + "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT"; + public enum SDL_HintPriority { SDL_HINT_DEFAULT, @@ -934,7 +944,8 @@ namespace SDL2 SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_SHARE_WITH_CURRENT_CONTEXT, - SDL_GL_FRAMEBUFFER_SRGB_CAPABLE + SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, + SDL_GL_CONTEXT_RELEASE_BEHAVIOR } /// @@ -1652,6 +1663,11 @@ namespace SDL2 IntPtr callback_data ); + /* IntPtr refers to an SDL_Window* */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GetGrabbedWindow(); + #endregion #region SDL_render.h @@ -2169,6 +2185,11 @@ namespace SDL2 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr SDL_GetRenderTarget(IntPtr renderer); + /* renderer refers to an SDL_Renderer* */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_bool SDL_RenderIsClipEnabled(IntPtr renderer); + #endregion #region SDL_pixels.h @@ -3241,9 +3262,16 @@ namespace SDL2 /* Drag and drop events */ SDL_DROPFILE = 0x1000, + /* Audio hotplug events */ + /* Only available in SDL 2.0.4 or higher */ + SDL_AUDIODEVICEADDED = 0x1100, + SDL_AUDIODEVICEREMOVED, + /* Render events */ /* Only available in SDL 2.0.2 or higher */ SDL_RENDER_TARGETS_RESET = 0x2000, + /* Only available in SDL 2.0.4 or higher */ + SDL_RENDER_DEVICE_RESET, /* Events SDL_USEREVENT through SDL_LASTEVENT are for * your use, and should be allocated with @@ -3255,6 +3283,13 @@ namespace SDL2 SDL_LASTEVENT = 0xFFFF } + /* Only available in 2.0.4 or higher */ + public enum SDL_MouseWheelDirection : uint + { + SDL_MOUSEHWEEL_NORMAL, + SDL_MOUSEWHEEL_FLIPPED + } + /* Fields shared by every event */ [StructLayout(LayoutKind.Sequential)] public struct SDL_GenericEvent @@ -3368,6 +3403,7 @@ namespace SDL2 public UInt32 which; public Int32 x; /* amount scrolled horizontally */ public Int32 y; /* amount scrolled vertically */ + public UInt32 direction; /* Set to one of the SDL_MOUSEWHEEL_* defines */ } // Ignore private members used for padding in this struct @@ -5530,6 +5566,25 @@ namespace SDL2 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void SDL_UnlockAudioDevice(uint dev); + /* dev refers to an SDL_AudioDeviceID, data to a void* */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_QueueAudio( + uint dev, + IntPtr data, + UInt32 len + ); + + /* dev refers to an SDL_AudioDeviceID */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UInt32 SDL_GetQueuedAudioSize(uint dev); + + /* dev refers to an SDL_AudioDeviceID */ + /* Only available in 2.0.4 */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void SDL_ClearQueuedAudio(uint dev); + #endregion #region SDL_timer.h @@ -5596,6 +5651,7 @@ namespace SDL2 public struct INTERNAL_windows_wminfo { public IntPtr window; // Refers to an HWND + public IntPtr hdc; // Refers to an HDC } [StructLayout(LayoutKind.Sequential)] @@ -5625,6 +5681,28 @@ namespace SDL2 public IntPtr window; // Refers to a UIWindow* } + [StructLayout(LayoutKind.Sequential)] + public struct INTERNAL_wayland_wminfo + { + public IntPtr display; // Refers to a wl_display* + public IntPtr surface; // Refers to a wl_surface* + public IntPtr shell_surface; // Refers to a wl_shell_surface* + } + + [StructLayout(LayoutKind.Sequential)] + public struct INTERNAL_mir_wminfo + { + public IntPtr connection; // Refers to a MirConnection* + public IntPtr surface; // Refers to a MirSurface* + } + + [StructLayout(LayoutKind.Sequential)] + public struct INTERNAL_android_wminfo + { + public IntPtr window; // Refers to an ANativeWindow + public IntPtr surface; // Refers to an EGLSurface + } + [StructLayout(LayoutKind.Explicit)] public struct INTERNAL_SysWMDriverUnion { @@ -5638,6 +5716,12 @@ namespace SDL2 public INTERNAL_cocoa_wminfo cocoa; [FieldOffset(0)] public INTERNAL_uikit_wminfo uikit; + [FieldOffset(0)] + public INTERNAL_wayland_wminfo wl; + [FieldOffset(0)] + public INTERNAL_mir_wminfo mir; + [FieldOffset(0)] + public INTERNAL_android_wminfo android; // private int dummy; } From 7f3d91e2e58388a5911944703d7da36d66dfb058 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Sun, 19 Jul 2015 14:31:39 -0400 Subject: [PATCH 12/13] Minor API change --- src/SDL2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SDL2.cs b/src/SDL2.cs index ce0ff09..d14f145 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -4536,7 +4536,7 @@ namespace SDL2 /* Set the mouse cursor's position in global screen space */ /* Only available in 2.0.4 */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern void SDL_WarpMouseGlobal(int x, int y); + public static extern int SDL_WarpMouseGlobal(int x, int y); /* Enable/Disable relative mouse mode (grabs mouse, rel coords) */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] From 23e25a3b2dafb24eb3fd0c902293f86de501c09e Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Mon, 4 Jan 2016 11:49:00 -0500 Subject: [PATCH 13/13] 2.0.4 --- src/SDL2.cs | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/src/SDL2.cs b/src/SDL2.cs index d14f145..c9f32c6 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -261,6 +261,24 @@ namespace SDL2 "SDL_ANDROID_SEPARATE_MOUSE_AND_TOUCH"; public const string SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT = "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT"; + public const string SDL_HINT_THREAD_STACK_SIZE = + "SDL_THREAD_STACK_SIZE"; + public const string SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN = + "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN"; + public const string SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP = + "SDL_WINDOWS_ENABLE_MESSAGELOOP"; + public const string SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 = + "SDL_WINDOWS_NO_CLOSE_ON_ALT_F4"; + public const string SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING = + "SDL_XINPUT_USE_OLD_JOYSTICK_MAPPING"; + public const string SDL_HINT_MAC_BACKGROUND_APP = + "SDL_MAC_BACKGROUND_APP"; + public const string SDL_HINT_VIDEO_X11_NET_WM_PING = + "SDL_VIDEO_X11_NET_WM_PING"; + public const string SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION = + "SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION"; + public const string SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION = + "SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION"; public enum SDL_HintPriority { @@ -808,7 +826,7 @@ namespace SDL2 */ public const int SDL_MAJOR_VERSION = 2; public const int SDL_MINOR_VERSION = 0; - public const int SDL_PATCHLEVEL = 3; + public const int SDL_PATCHLEVEL = 4; public static readonly int SDL_COMPILEDVERSION = SDL_VERSIONNUM( SDL_MAJOR_VERSION, @@ -1227,6 +1245,15 @@ namespace SDL2 out SDL_Rect rect ); + /* This function is only available in 2.0.4 or higher */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int SDL_GetDisplayDPI( + int displayIndex, + out float ddpi, + out float hdpi, + out float vdpi + ); + /// /// Use this function to get information about a specific display mode. /// @@ -4667,6 +4694,17 @@ namespace SDL2 public const byte SDL_HAT_LEFTUP = SDL_HAT_LEFT | SDL_HAT_UP; public const byte SDL_HAT_LEFTDOWN = SDL_HAT_LEFT | SDL_HAT_DOWN; + public enum SDL_JoystickPowerLevel + { + SDL_JOYSTICK_POWER_UNKNOWN = -1, + SDL_JOYSTICK_POWER_EMPTY, + SDL_JOYSTICK_POWER_LOW, + SDL_JOYSTICK_POWER_MEDIUM, + SDL_JOYSTICK_POWER_FULL, + SDL_JOYSTICK_POWER_WIRED, + SDL_JOYSTICK_POWER_MAX + } + /* joystick refers to an SDL_Joystick* */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void SDL_JoystickClose(IntPtr joystick); @@ -4781,6 +4819,20 @@ namespace SDL2 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern int SDL_JoystickInstanceID(IntPtr joystick); + /* joystick refers to an SDL_Joystick*. + * This function is only available in 2.0.4 or higher. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern SDL_JoystickPowerLevel SDL_JoystickCurrentPowerLevel( + IntPtr joystick + ); + + /* int refers to an SDL_JoystickID, IntPtr to an SDL_Joystick*. + * This function is only available in 2.0.4 or higher. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_JoystickFromInstanceID(int joyid); + #endregion #region SDL_gamecontroller.h @@ -4978,6 +5030,12 @@ namespace SDL2 IntPtr gamecontroller ); + /* int refers to an SDL_JoystickID, IntPtr to an SDL_GameController*. + * This function is only available in 2.0.4 or higher. + */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr SDL_GameControllerFromInstanceID(int joyid); + #endregion #region SDL_haptic.h @@ -5643,7 +5701,11 @@ namespace SDL2 SDL_SYSWM_X11, SDL_SYSWM_DIRECTFB, SDL_SYSWM_COCOA, - SDL_SYSWM_UIKIT + SDL_SYSWM_UIKIT, + SDL_SYSWM_WAYLAND, + SDL_SYSWM_MIR, + SDL_SYSWM_WINRT, + SDL_SYSWM_ANDROID } // FIXME: I wish these weren't public... @@ -5654,6 +5716,12 @@ namespace SDL2 public IntPtr hdc; // Refers to an HDC } + [StructLayout(LayoutKind.Sequential)] + public struct INTERNAL_winrt_wminfo + { + public IntPtr window; // Refers to an IInspectable* + } + [StructLayout(LayoutKind.Sequential)] public struct INTERNAL_x11_wminfo { @@ -5679,6 +5747,9 @@ namespace SDL2 public struct INTERNAL_uikit_wminfo { public IntPtr window; // Refers to a UIWindow* + public uint framebuffer; + public uint colorbuffer; + public uint resolveFramebuffer; } [StructLayout(LayoutKind.Sequential)] @@ -5709,6 +5780,8 @@ namespace SDL2 [FieldOffset(0)] public INTERNAL_windows_wminfo win; [FieldOffset(0)] + public INTERNAL_winrt_wminfo winrt; + [FieldOffset(0)] public INTERNAL_x11_wminfo x11; [FieldOffset(0)] public INTERNAL_directfb_wminfo dfb;