ProjectArcade
8010 строк · 299.0 Кб
1
2#region License3/* SDL2# - C# Wrapper for SDL2
4*
5* Copyright (c) 2013-2020 Ethan Lee.
6*
7* This software is provided 'as-is', without any express or implied warranty.
8* In no event will the authors be held liable for any damages arising from
9* the use of this software.
10*
11* Permission is granted to anyone to use this software for any purpose,
12* including commercial applications, and to alter it and redistribute it
13* freely, subject to the following restrictions:
14*
15* 1. The origin of this software must not be misrepresented; you must not
16* claim that you wrote the original software. If you use this software in a
17* product, an acknowledgment in the product documentation would be
18* appreciated but is not required.
19*
20* 2. Altered source versions must be plainly marked as such, and must not be
21* misrepresented as being the original software.
22*
23* 3. This notice may not be removed or altered from any source distribution.
24*
25* Ethan "flibitijibibo" Lee <flibitijibibo@flibitijibibo.com>
26*
27*/
28#endregion29
30#region Using Statements31using System;32using System.Runtime.InteropServices;33using System.Collections.Generic;34#endregion35
36namespace EmulatorLauncher.Common37{
38public static class SDL39{40#region SDL2# Variables41
42private const string nativeLibName = "SDL2";43
44#endregion45
46#region UTF8 Marshaling47
48internal static byte[] UTF8_ToNative(string s)49{50if (s == null)51{52return null;53}54
55// Add a null terminator. That's kind of it... :/56return System.Text.Encoding.UTF8.GetBytes(s + '\0');57}58
59/* This is public because SDL_DropEvent needs it! */60public static string UTF8_ToManaged(IntPtr s, bool freePtr = false)61{62string result = Marshal.PtrToStringAnsi(s);63
64if (freePtr)65SDL_free(s);66
67return result;68}69
70#endregion71
72#region SDL_stdinc.h73
74public static uint SDL_FOURCC(byte A, byte B, byte C, byte D)75{76return (uint)(A | (B << 8) | (C << 16) | (D << 24));77}78
79public enum SDL_bool80{81SDL_FALSE = 0,82SDL_TRUE = 183}84
85/* malloc/free are used by the marshaler! -flibit */86
87[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]88internal static extern IntPtr SDL_malloc(IntPtr size);89
90[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]91internal static extern void SDL_free(IntPtr memblock);92
93/* Buffer.BlockCopy is not available in every runtime yet. Also,94* using memcpy directly can be a compatibility issue in other
95* strange ways. So, we expose this to get around all that.
96* -flibit
97*/
98[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]99public static extern IntPtr SDL_memcpy(IntPtr dst, IntPtr src, IntPtr len);100
101#endregion102
103#region SDL_rwops.h104
105public const int RW_SEEK_SET = 0;106public const int RW_SEEK_CUR = 1;107public const int RW_SEEK_END = 2;108
109public const UInt32 SDL_RWOPS_UNKNOWN = 0; /* Unknown stream type */110public const UInt32 SDL_RWOPS_WINFILE = 1; /* Win32 file */111public const UInt32 SDL_RWOPS_STDFILE = 2; /* Stdio file */112public const UInt32 SDL_RWOPS_JNIFILE = 3; /* Android asset */113public const UInt32 SDL_RWOPS_MEMORY = 4; /* Memory stream */114public const UInt32 SDL_RWOPS_MEMORY_RO = 5; /* Read-Only memory stream */115
116[UnmanagedFunctionPointer(CallingConvention.Cdecl)]117public delegate long SDLRWopsSizeCallback(IntPtr context);118
119[UnmanagedFunctionPointer(CallingConvention.Cdecl)]120public delegate long SDLRWopsSeekCallback(121IntPtr context,122long offset,123int whence124);125
126[UnmanagedFunctionPointer(CallingConvention.Cdecl)]127public delegate IntPtr SDLRWopsReadCallback(128IntPtr context,129IntPtr ptr,130IntPtr size,131IntPtr maxnum132);133
134[UnmanagedFunctionPointer(CallingConvention.Cdecl)]135public delegate IntPtr SDLRWopsWriteCallback(136IntPtr context,137IntPtr ptr,138IntPtr size,139IntPtr num140);141
142[UnmanagedFunctionPointer(CallingConvention.Cdecl)]143public delegate int SDLRWopsCloseCallback(144IntPtr context145);146
147[StructLayout(LayoutKind.Sequential)]148public struct SDL_RWops149{150public IntPtr size;151public IntPtr seek;152public IntPtr read;153public IntPtr write;154public IntPtr close;155
156public UInt32 type;157
158/* NOTE: This isn't the full structure since159* the native SDL_RWops contains a hidden union full of
160* internal information and platform-specific stuff depending
161* on what conditions the native library was built with
162*/
163}164
165/* IntPtr refers to an SDL_RWops* */166[DllImport(nativeLibName, EntryPoint = "SDL_RWFromFile", CallingConvention = CallingConvention.Cdecl)]167private static extern IntPtr INTERNAL_SDL_RWFromFile(168byte[] file,169byte[] mode170);171public static IntPtr SDL_RWFromFile(172string file,173string mode174)175{176return INTERNAL_SDL_RWFromFile(177UTF8_ToNative(file),178UTF8_ToNative(mode)179);180}181
182/* IntPtr refers to an SDL_RWops* */183[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]184public static extern IntPtr SDL_AllocRW();185
186/* area refers to an SDL_RWops* */187[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]188public static extern void SDL_FreeRW(IntPtr area);189
190/* fp refers to a void* */191[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]192public static extern IntPtr SDL_RWFromFP(IntPtr fp, SDL_bool autoclose);193
194/* mem refers to a void*, IntPtr to an SDL_RWops* */195[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]196public static extern IntPtr SDL_RWFromMem(IntPtr mem, int size);197
198/* mem refers to a const void*, IntPtr to an SDL_RWops* */199[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]200public static extern IntPtr SDL_RWFromConstMem(IntPtr mem, int size);201
202/* context refers to an SDL_RWops*.203* Only available in SDL 2.0.10 or higher.
204*/
205[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]206public static extern long SDL_RWsize(IntPtr context);207
208/* context refers to an SDL_RWops*.209* Only available in SDL 2.0.10 or higher.
210*/
211[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]212public static extern long SDL_RWseek(213IntPtr context,214long offset,215int whence216);217
218/* context refers to an SDL_RWops*.219* Only available in SDL 2.0.10 or higher.
220*/
221[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]222public static extern long SDL_RWtell(IntPtr context);223
224/* context refers to an SDL_RWops*, ptr refers to a void*.225* Only available in SDL 2.0.10 or higher.
226*/
227[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]228public static extern long SDL_RWread(229IntPtr context,230IntPtr ptr,231IntPtr size,232IntPtr maxnum233);234
235/* context refers to an SDL_RWops*, ptr refers to a const void*.236* Only available in SDL 2.0.10 or higher.
237*/
238[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]239public static extern long SDL_RWwrite(240IntPtr context,241IntPtr ptr,242IntPtr size,243IntPtr maxnum244);245
246/* Read endian functions */247
248[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]249public static extern byte SDL_ReadU8(IntPtr src);250
251[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]252public static extern UInt16 SDL_ReadLE16(IntPtr src);253
254[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]255public static extern UInt16 SDL_ReadBE16(IntPtr src);256
257[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]258public static extern UInt32 SDL_ReadLE32(IntPtr src);259
260[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]261public static extern UInt32 SDL_ReadBE32(IntPtr src);262
263[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]264public static extern UInt64 SDL_ReadLE64(IntPtr src);265
266[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]267public static extern UInt64 SDL_ReadBE64(IntPtr src);268
269/* Write endian functions */270
271[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]272public static extern uint SDL_WriteU8(IntPtr dst, byte value);273
274[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]275public static extern uint SDL_WriteLE16(IntPtr dst, UInt16 value);276
277[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]278public static extern uint SDL_WriteBE16(IntPtr dst, UInt16 value);279
280[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]281public static extern uint SDL_WriteLE32(IntPtr dst, UInt32 value);282
283[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]284public static extern uint SDL_WriteBE32(IntPtr dst, UInt32 value);285
286[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]287public static extern uint SDL_WriteLE64(IntPtr dst, UInt64 value);288
289[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]290public static extern uint SDL_WriteBE64(IntPtr dst, UInt64 value);291
292/* context refers to an SDL_RWops*293* Only available in SDL 2.0.10 or higher.
294*/
295[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]296public static extern long SDL_RWclose(IntPtr context);297
298/* file refers to a const char*, datasize to a size_t*299* IntPtr refers to a void*
300* Only available in SDL 2.0.10 or higher.
301*/
302[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]303public static extern IntPtr SDL_LoadFile(IntPtr file, IntPtr datasize);304
305#endregion306
307#region SDL_main.h308
309[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]310public static extern void SDL_SetMainReady();311
312/* This is used as a function pointer to a C main() function */313public delegate int SDL_main_func(int argc, IntPtr argv);314
315/* Use this function with UWP to call your C# Main() function! */316[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]317public static extern int SDL_WinRTRunApp(318SDL_main_func mainFunction,319IntPtr reserved320);321
322/* Use this function with iOS to call your C# Main() function!323* Only available in SDL 2.0.10 or higher.
324*/
325[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]326public static extern int SDL_UIKitRunApp(327int argc,328IntPtr argv,329SDL_main_func mainFunction330);331
332#endregion333
334#region SDL.h335
336public const uint SDL_INIT_TIMER = 0x00000001;337public const uint SDL_INIT_AUDIO = 0x00000010;338public const uint SDL_INIT_VIDEO = 0x00000020;339public const uint SDL_INIT_JOYSTICK = 0x00000200;340public const uint SDL_INIT_HAPTIC = 0x00001000;341public const uint SDL_INIT_GAMECONTROLLER = 0x00002000;342public const uint SDL_INIT_EVENTS = 0x00004000;343public const uint SDL_INIT_SENSOR = 0x00008000;344public const uint SDL_INIT_NOPARACHUTE = 0x00100000;345public const uint SDL_INIT_EVERYTHING = (346SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO |347SDL_INIT_EVENTS | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC |348SDL_INIT_GAMECONTROLLER | SDL_INIT_SENSOR349);350
351[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]352public static extern int SDL_Init(uint flags);353
354[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]355public static extern int SDL_InitSubSystem(uint flags);356
357[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]358public static extern void SDL_Quit();359
360[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]361public static extern void SDL_QuitSubSystem(uint flags);362
363[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]364public static extern uint SDL_WasInit(uint flags);365
366#endregion367
368#region SDL_platform.h369
370[DllImport(nativeLibName, EntryPoint = "SDL_GetPlatform", CallingConvention = CallingConvention.Cdecl)]371private static extern IntPtr INTERNAL_SDL_GetPlatform();372public static string SDL_GetPlatform()373{374return UTF8_ToManaged(INTERNAL_SDL_GetPlatform());375}376
377#endregion378
379#region SDL_hints.h380
381public const string SDL_HINT_FRAMEBUFFER_ACCELERATION =382"SDL_FRAMEBUFFER_ACCELERATION";383public const string SDL_HINT_RENDER_DRIVER =384"SDL_RENDER_DRIVER";385public const string SDL_HINT_RENDER_OPENGL_SHADERS =386"SDL_RENDER_OPENGL_SHADERS";387public const string SDL_HINT_RENDER_DIRECT3D_THREADSAFE =388"SDL_RENDER_DIRECT3D_THREADSAFE";389public const string SDL_HINT_RENDER_VSYNC =390"SDL_RENDER_VSYNC";391public const string SDL_HINT_VIDEO_X11_XVIDMODE =392"SDL_VIDEO_X11_XVIDMODE";393public const string SDL_HINT_VIDEO_X11_XINERAMA =394"SDL_VIDEO_X11_XINERAMA";395public const string SDL_HINT_VIDEO_X11_XRANDR =396"SDL_VIDEO_X11_XRANDR";397public const string SDL_HINT_GRAB_KEYBOARD =398"SDL_GRAB_KEYBOARD";399public const string SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS =400"SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS";401public const string SDL_HINT_IDLE_TIMER_DISABLED =402"SDL_IOS_IDLE_TIMER_DISABLED";403public const string SDL_HINT_ORIENTATIONS =404"SDL_IOS_ORIENTATIONS";405public const string SDL_HINT_XINPUT_ENABLED =406"SDL_XINPUT_ENABLED";407public const string SDL_HINT_GAMECONTROLLERCONFIG =408"SDL_GAMECONTROLLERCONFIG";409public const string SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS =410"SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS";411public const string SDL_HINT_ALLOW_TOPMOST =412"SDL_ALLOW_TOPMOST";413public const string SDL_HINT_TIMER_RESOLUTION =414"SDL_TIMER_RESOLUTION";415public const string SDL_HINT_RENDER_SCALE_QUALITY =416"SDL_RENDER_SCALE_QUALITY";417public const string SDL_HINT_JOYSTICK_RAWINPUT =418"SDL_HINT_JOYSTICK_RAWINPUT";419
420/* Only available in SDL 2.0.1 or higher. */421public const string SDL_HINT_VIDEO_HIGHDPI_DISABLED =422"SDL_VIDEO_HIGHDPI_DISABLED";423
424/* Only available in SDL 2.0.2 or higher. */425public const string SDL_HINT_CTRL_CLICK_EMULATE_RIGHT_CLICK =426"SDL_CTRL_CLICK_EMULATE_RIGHT_CLICK";427public const string SDL_HINT_VIDEO_WIN_D3DCOMPILER =428"SDL_VIDEO_WIN_D3DCOMPILER";429public const string SDL_HINT_MOUSE_RELATIVE_MODE_WARP =430"SDL_MOUSE_RELATIVE_MODE_WARP";431public const string SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT =432"SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT";433public const string SDL_HINT_VIDEO_ALLOW_SCREENSAVER =434"SDL_VIDEO_ALLOW_SCREENSAVER";435public const string SDL_HINT_ACCELEROMETER_AS_JOYSTICK =436"SDL_ACCELEROMETER_AS_JOYSTICK";437public const string SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES =438"SDL_VIDEO_MAC_FULLSCREEN_SPACES";439
440/* Only available in SDL 2.0.3 or higher. */441public const string SDL_HINT_WINRT_PRIVACY_POLICY_URL =442"SDL_WINRT_PRIVACY_POLICY_URL";443public const string SDL_HINT_WINRT_PRIVACY_POLICY_LABEL =444"SDL_WINRT_PRIVACY_POLICY_LABEL";445public const string SDL_HINT_WINRT_HANDLE_BACK_BUTTON =446"SDL_WINRT_HANDLE_BACK_BUTTON";447
448/* Only available in SDL 2.0.4 or higher. */449public const string SDL_HINT_NO_SIGNAL_HANDLERS =450"SDL_NO_SIGNAL_HANDLERS";451public const string SDL_HINT_IME_INTERNAL_EDITING =452"SDL_IME_INTERNAL_EDITING";453public const string SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH =454"SDL_ANDROID_SEPARATE_MOUSE_AND_TOUCH";455public const string SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT =456"SDL_EMSCRIPTEN_KEYBOARD_ELEMENT";457public const string SDL_HINT_THREAD_STACK_SIZE =458"SDL_THREAD_STACK_SIZE";459public const string SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN =460"SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN";461public const string SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP =462"SDL_WINDOWS_ENABLE_MESSAGELOOP";463public const string SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 =464"SDL_WINDOWS_NO_CLOSE_ON_ALT_F4";465public const string SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING =466"SDL_XINPUT_USE_OLD_JOYSTICK_MAPPING";467public const string SDL_HINT_MAC_BACKGROUND_APP =468"SDL_MAC_BACKGROUND_APP";469public const string SDL_HINT_VIDEO_X11_NET_WM_PING =470"SDL_VIDEO_X11_NET_WM_PING";471public const string SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION =472"SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION";473public const string SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION =474"SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION";475
476/* Only available in 2.0.5 or higher. */477public const string SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH =478"SDL_MOUSE_FOCUS_CLICKTHROUGH";479public const string SDL_HINT_BMP_SAVE_LEGACY_FORMAT =480"SDL_BMP_SAVE_LEGACY_FORMAT";481public const string SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING =482"SDL_WINDOWS_DISABLE_THREAD_NAMING";483public const string SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION =484"SDL_APPLE_TV_REMOTE_ALLOW_ROTATION";485
486/* Only available in 2.0.6 or higher. */487public const string SDL_HINT_AUDIO_RESAMPLING_MODE =488"SDL_AUDIO_RESAMPLING_MODE";489public const string SDL_HINT_RENDER_LOGICAL_SIZE_MODE =490"SDL_RENDER_LOGICAL_SIZE_MODE";491public const string SDL_HINT_MOUSE_NORMAL_SPEED_SCALE =492"SDL_MOUSE_NORMAL_SPEED_SCALE";493public const string SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE =494"SDL_MOUSE_RELATIVE_SPEED_SCALE";495public const string SDL_HINT_TOUCH_MOUSE_EVENTS =496"SDL_TOUCH_MOUSE_EVENTS";497public const string SDL_HINT_WINDOWS_INTRESOURCE_ICON =498"SDL_WINDOWS_INTRESOURCE_ICON";499public const string SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL =500"SDL_WINDOWS_INTRESOURCE_ICON_SMALL";501
502/* Only available in 2.0.8 or higher. */503public const string SDL_HINT_IOS_HIDE_HOME_INDICATOR =504"SDL_IOS_HIDE_HOME_INDICATOR";505public const string SDL_HINT_TV_REMOTE_AS_JOYSTICK =506"SDL_TV_REMOTE_AS_JOYSTICK";507
508/* Only available in 2.0.9 or higher. */509public const string SDL_HINT_MOUSE_DOUBLE_CLICK_TIME =510"SDL_MOUSE_DOUBLE_CLICK_TIME";511public const string SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS =512"SDL_MOUSE_DOUBLE_CLICK_RADIUS";513public const string SDL_HINT_JOYSTICK_HIDAPI =514"SDL_JOYSTICK_HIDAPI";515public const string SDL_HINT_JOYSTICK_HIDAPI_PS4 =516"SDL_JOYSTICK_HIDAPI_PS4";517public const string SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE =518"SDL_JOYSTICK_HIDAPI_PS4_RUMBLE";519public const string SDL_HINT_JOYSTICK_HIDAPI_STEAM =520"SDL_JOYSTICK_HIDAPI_STEAM";521public const string SDL_HINT_JOYSTICK_HIDAPI_SWITCH =522"SDL_JOYSTICK_HIDAPI_SWITCH";523public const string SDL_HINT_JOYSTICK_HIDAPI_XBOX =524"SDL_JOYSTICK_HIDAPI_XBOX";525public const string SDL_HINT_ENABLE_STEAM_CONTROLLERS =526"SDL_ENABLE_STEAM_CONTROLLERS";527public const string SDL_HINT_ANDROID_TRAP_BACK_BUTTON =528"SDL_ANDROID_TRAP_BACK_BUTTON";529public const string SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS =530"SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS";531
532/* Only available in 2.0.10 or higher. */533public const string SDL_HINT_MOUSE_TOUCH_EVENTS =534"SDL_MOUSE_TOUCH_EVENTS";535public const string SDL_HINT_GAMECONTROLLERCONFIG_FILE =536"SDL_GAMECONTROLLERCONFIG_FILE";537public const string SDL_HINT_ANDROID_BLOCK_ON_PAUSE =538"SDL_ANDROID_BLOCK_ON_PAUSE";539public const string SDL_HINT_RENDER_BATCHING =540"SDL_RENDER_BATCHING";541public const string SDL_HINT_EVENT_LOGGING =542"SDL_EVENT_LOGGING";543public const string SDL_HINT_WAVE_RIFF_CHUNK_SIZE =544"SDL_WAVE_RIFF_CHUNK_SIZE";545public const string SDL_HINT_WAVE_TRUNCATION =546"SDL_WAVE_TRUNCATION";547public const string SDL_HINT_WAVE_FACT_CHUNK =548"SDL_WAVE_FACT_CHUNK";549
550/* Only available in 2.0.11 or higher. */551public const string SDL_HINT_VIDO_X11_WINDOW_VISUALID =552"SDL_VIDEO_X11_WINDOW_VISUALID";553public const string SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS =554"SDL_GAMECONTROLLER_USE_BUTTON_LABELS";555public const string SDL_HINT_VIDEO_EXTERNAL_CONTEXT =556"SDL_VIDEO_EXTERNAL_CONTEXT";557public const string SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE =558"SDL_JOYSTICK_HIDAPI_GAMECUBE";559public const string SDL_HINT_DISPLAY_USABLE_BOUNDS =560"SDL_DISPLAY_USABLE_BOUNDS";561public const string SDL_HINT_VIDEO_X11_FORCE_EGL =562"SDL_VIDEO_X11_FORCE_EGL";563public const string SDL_HINT_GAMECONTROLLERTYPE =564"SDL_GAMECONTROLLERTYPE";565
566public enum SDL_HintPriority567{568SDL_HINT_DEFAULT,569SDL_HINT_NORMAL,570SDL_HINT_OVERRIDE
571}572
573[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]574public static extern void SDL_ClearHints();575
576[DllImport(nativeLibName, EntryPoint = "SDL_GetHint", CallingConvention = CallingConvention.Cdecl)]577private static extern IntPtr INTERNAL_SDL_GetHint(byte[] name);578public static string SDL_GetHint(string name)579{580return UTF8_ToManaged(581INTERNAL_SDL_GetHint(582UTF8_ToNative(name)583)584);585}586
587[DllImport(nativeLibName, EntryPoint = "SDL_SetHint", CallingConvention = CallingConvention.Cdecl)]588private static extern SDL_bool INTERNAL_SDL_SetHint(589byte[] name,590byte[] value591);592public static SDL_bool SDL_SetHint(string name, string value)593{594return INTERNAL_SDL_SetHint(595UTF8_ToNative(name),596UTF8_ToNative(value)597);598}599
600[DllImport(nativeLibName, EntryPoint = "SDL_SetHintWithPriority", CallingConvention = CallingConvention.Cdecl)]601private static extern SDL_bool INTERNAL_SDL_SetHintWithPriority(602byte[] name,603byte[] value,604SDL_HintPriority priority605);606public static SDL_bool SDL_SetHintWithPriority(607string name,608string value,609SDL_HintPriority priority610)611{612return INTERNAL_SDL_SetHintWithPriority(613UTF8_ToNative(name),614UTF8_ToNative(value),615priority
616);617}618
619/* Only available in 2.0.5 or higher. */620[DllImport(nativeLibName, EntryPoint = "SDL_GetHintBoolean", CallingConvention = CallingConvention.Cdecl)]621private static extern SDL_bool INTERNAL_SDL_GetHintBoolean(622byte[] name,623SDL_bool default_value624);625public static SDL_bool SDL_GetHintBoolean(626string name,627SDL_bool default_value628)629{630return INTERNAL_SDL_GetHintBoolean(631UTF8_ToNative(name),632default_value
633);634}635
636#endregion637
638#region SDL_error.h639
640[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]641public static extern void SDL_ClearError();642
643[DllImport(nativeLibName, EntryPoint = "SDL_GetError", CallingConvention = CallingConvention.Cdecl)]644private static extern IntPtr INTERNAL_SDL_GetError();645public static string SDL_GetError()646{647return UTF8_ToManaged(INTERNAL_SDL_GetError());648}649
650/* Use string.Format for arglists */651[DllImport(nativeLibName, EntryPoint = "SDL_SetError", CallingConvention = CallingConvention.Cdecl)]652private static extern void INTERNAL_SDL_SetError(byte[] fmtAndArglist);653public static void SDL_SetError(string fmtAndArglist)654{655INTERNAL_SDL_SetError(656UTF8_ToNative(fmtAndArglist)657);658}659
660#endregion661
662#region SDL_log.h663
664public enum SDL_LogCategory665{666SDL_LOG_CATEGORY_APPLICATION,667SDL_LOG_CATEGORY_ERROR,668SDL_LOG_CATEGORY_ASSERT,669SDL_LOG_CATEGORY_SYSTEM,670SDL_LOG_CATEGORY_AUDIO,671SDL_LOG_CATEGORY_VIDEO,672SDL_LOG_CATEGORY_RENDER,673SDL_LOG_CATEGORY_INPUT,674SDL_LOG_CATEGORY_TEST,675
676/* Reserved for future SDL library use */677SDL_LOG_CATEGORY_RESERVED1,678SDL_LOG_CATEGORY_RESERVED2,679SDL_LOG_CATEGORY_RESERVED3,680SDL_LOG_CATEGORY_RESERVED4,681SDL_LOG_CATEGORY_RESERVED5,682SDL_LOG_CATEGORY_RESERVED6,683SDL_LOG_CATEGORY_RESERVED7,684SDL_LOG_CATEGORY_RESERVED8,685SDL_LOG_CATEGORY_RESERVED9,686SDL_LOG_CATEGORY_RESERVED10,687
688/* Beyond this point is reserved for application use, e.g.689enum {
690MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM,
691MYAPP_CATEGORY_AWESOME2,
692MYAPP_CATEGORY_AWESOME3,
693...
694};
695*/
696SDL_LOG_CATEGORY_CUSTOM
697}698
699public enum SDL_LogPriority700{701SDL_LOG_PRIORITY_VERBOSE = 1,702SDL_LOG_PRIORITY_DEBUG,703SDL_LOG_PRIORITY_INFO,704SDL_LOG_PRIORITY_WARN,705SDL_LOG_PRIORITY_ERROR,706SDL_LOG_PRIORITY_CRITICAL,707SDL_NUM_LOG_PRIORITIES
708}709
710/* userdata refers to a void*, message to a const char* */711[UnmanagedFunctionPointer(CallingConvention.Cdecl)]712public delegate void SDL_LogOutputFunction(713IntPtr userdata,714int category,715SDL_LogPriority priority,716IntPtr message717);718
719/* Use string.Format for arglists */720[DllImport(nativeLibName, EntryPoint = "SDL_Log", CallingConvention = CallingConvention.Cdecl)]721private static extern void INTERNAL_SDL_Log(byte[] fmtAndArglist);722public static void SDL_Log(string fmtAndArglist)723{724INTERNAL_SDL_Log(725UTF8_ToNative(fmtAndArglist)726);727}728
729/* Use string.Format for arglists */730[DllImport(nativeLibName, EntryPoint = "SDL_LogVerbose", CallingConvention = CallingConvention.Cdecl)]731private static extern void INTERNAL_SDL_LogVerbose(732int category,733byte[] fmtAndArglist734);735public static void SDL_LogVerbose(736int category,737string fmtAndArglist738)739{740INTERNAL_SDL_LogVerbose(741category,742UTF8_ToNative(fmtAndArglist)743);744}745
746/* Use string.Format for arglists */747[DllImport(nativeLibName, EntryPoint = "SDL_LogDebug", CallingConvention = CallingConvention.Cdecl)]748private static extern void INTERNAL_SDL_LogDebug(749int category,750byte[] fmtAndArglist751);752public static void SDL_LogDebug(753int category,754string fmtAndArglist755)756{757INTERNAL_SDL_LogDebug(758category,759UTF8_ToNative(fmtAndArglist)760);761}762
763/* Use string.Format for arglists */764[DllImport(nativeLibName, EntryPoint = "SDL_LogInfo", CallingConvention = CallingConvention.Cdecl)]765private static extern void INTERNAL_SDL_LogInfo(766int category,767byte[] fmtAndArglist768);769public static void SDL_LogInfo(770int category,771string fmtAndArglist772)773{774INTERNAL_SDL_LogInfo(775category,776UTF8_ToNative(fmtAndArglist)777);778}779
780/* Use string.Format for arglists */781[DllImport(nativeLibName, EntryPoint = "SDL_LogWarn", CallingConvention = CallingConvention.Cdecl)]782private static extern void INTERNAL_SDL_LogWarn(783int category,784byte[] fmtAndArglist785);786public static void SDL_LogWarn(787int category,788string fmtAndArglist789)790{791INTERNAL_SDL_LogWarn(792category,793UTF8_ToNative(fmtAndArglist)794);795}796
797/* Use string.Format for arglists */798[DllImport(nativeLibName, EntryPoint = "SDL_LogError", CallingConvention = CallingConvention.Cdecl)]799private static extern void INTERNAL_SDL_LogError(800int category,801byte[] fmtAndArglist802);803public static void SDL_LogError(804int category,805string fmtAndArglist806)807{808INTERNAL_SDL_LogError(809category,810UTF8_ToNative(fmtAndArglist)811);812}813
814/* Use string.Format for arglists */815[DllImport(nativeLibName, EntryPoint = "SDL_LogCritical", CallingConvention = CallingConvention.Cdecl)]816private static extern void INTERNAL_SDL_LogCritical(817int category,818byte[] fmtAndArglist819);820public static void SDL_LogCritical(821int category,822string fmtAndArglist823)824{825INTERNAL_SDL_LogCritical(826category,827UTF8_ToNative(fmtAndArglist)828);829}830
831/* Use string.Format for arglists */832[DllImport(nativeLibName, EntryPoint = "SDL_LogMessage", CallingConvention = CallingConvention.Cdecl)]833private static extern void INTERNAL_SDL_LogMessage(834int category,835SDL_LogPriority priority,836byte[] fmtAndArglist837);838public static void SDL_LogMessage(839int category,840SDL_LogPriority priority,841string fmtAndArglist842)843{844INTERNAL_SDL_LogMessage(845category,846priority,847UTF8_ToNative(fmtAndArglist)848);849}850
851/* Use string.Format for arglists */852[DllImport(nativeLibName, EntryPoint = "SDL_LogMessageV", CallingConvention = CallingConvention.Cdecl)]853private static extern void INTERNAL_SDL_LogMessageV(854int category,855SDL_LogPriority priority,856byte[] fmtAndArglist857);858public static void SDL_LogMessageV(859int category,860SDL_LogPriority priority,861string fmtAndArglist862)863{864INTERNAL_SDL_LogMessageV(865category,866priority,867UTF8_ToNative(fmtAndArglist)868);869}870
871[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]872public static extern SDL_LogPriority SDL_LogGetPriority(873int category874);875
876[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]877public static extern void SDL_LogSetPriority(878int category,879SDL_LogPriority priority880);881
882[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]883public static extern void SDL_LogSetAllPriority(884SDL_LogPriority priority885);886
887[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]888public static extern void SDL_LogResetPriorities();889
890/* userdata refers to a void* */891[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]892private static extern void SDL_LogGetOutputFunction(893out IntPtr callback,894out IntPtr userdata895);896public static void SDL_LogGetOutputFunction(897out SDL_LogOutputFunction callback,898out IntPtr userdata899)900{901IntPtr result = IntPtr.Zero;902SDL_LogGetOutputFunction(903out result,904out userdata905);906if (result != IntPtr.Zero)907{908callback = (SDL_LogOutputFunction)Marshal.GetDelegateForFunctionPointer(909result,910typeof(SDL_LogOutputFunction)911);912}913else914{915callback = null;916}917}918
919/* userdata refers to a void* */920[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]921public static extern void SDL_LogSetOutputFunction(922SDL_LogOutputFunction callback,923IntPtr userdata924);925
926#endregion927
928#region SDL_messagebox.h929
930[Flags]931public enum SDL_MessageBoxFlags : uint932{933SDL_MESSAGEBOX_ERROR = 0x00000010,934SDL_MESSAGEBOX_WARNING = 0x00000020,935SDL_MESSAGEBOX_INFORMATION = 0x00000040936}937
938[Flags]939public enum SDL_MessageBoxButtonFlags : uint940{941SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001,942SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002943}944
945[StructLayout(LayoutKind.Sequential)]946private struct INTERNAL_SDL_MessageBoxButtonData947{948public SDL_MessageBoxButtonFlags flags;949public int buttonid;950public IntPtr text; /* The UTF-8 button text */951}952
953[StructLayout(LayoutKind.Sequential)]954public struct SDL_MessageBoxButtonData955{956public SDL_MessageBoxButtonFlags flags;957public int buttonid;958public string text; /* The UTF-8 button text */959}960
961[StructLayout(LayoutKind.Sequential)]962public struct SDL_MessageBoxColor963{964public byte r, g, b;965}966
967public enum SDL_MessageBoxColorType968{969SDL_MESSAGEBOX_COLOR_BACKGROUND,970SDL_MESSAGEBOX_COLOR_TEXT,971SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,972SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND,973SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED,974SDL_MESSAGEBOX_COLOR_MAX
975}976
977[StructLayout(LayoutKind.Sequential)]978public struct SDL_MessageBoxColorScheme979{980[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = (int)SDL_MessageBoxColorType.SDL_MESSAGEBOX_COLOR_MAX)]981public SDL_MessageBoxColor[] colors;982}983
984[StructLayout(LayoutKind.Sequential)]985private struct INTERNAL_SDL_MessageBoxData986{987public SDL_MessageBoxFlags flags;988public IntPtr window; /* Parent window, can be NULL */989public IntPtr title; /* UTF-8 title */990public IntPtr message; /* UTF-8 message text */991public int numbuttons;992public IntPtr buttons;993public IntPtr colorScheme; /* Can be NULL to use system settings */994}995
996[StructLayout(LayoutKind.Sequential)]997public struct SDL_MessageBoxData998{999public SDL_MessageBoxFlags flags;1000public IntPtr window; /* Parent window, can be NULL */1001public string title; /* UTF-8 title */1002public string message; /* UTF-8 message text */1003public int numbuttons;1004public SDL_MessageBoxButtonData[] buttons;1005public SDL_MessageBoxColorScheme? colorScheme; /* Can be NULL to use system settings */1006}1007
1008[DllImport(nativeLibName, EntryPoint = "SDL_ShowMessageBox", CallingConvention = CallingConvention.Cdecl)]1009private static extern int INTERNAL_SDL_ShowMessageBox([In()] ref INTERNAL_SDL_MessageBoxData messageboxdata, out int buttonid);1010
1011/* Ripped from Jameson's LpUtf8StrMarshaler */1012private static IntPtr INTERNAL_AllocUTF8(string str)1013{1014if (string.IsNullOrEmpty(str))1015{1016return IntPtr.Zero;1017}1018byte[] bytes = System.Text.Encoding.UTF8.GetBytes(str + '\0');1019IntPtr mem = SDL.SDL_malloc((IntPtr)bytes.Length);1020Marshal.Copy(bytes, 0, mem, bytes.Length);1021return mem;1022}1023/*1024public static unsafe int SDL_ShowMessageBox([In()] ref SDL_MessageBoxData messageboxdata, out int buttonid)
1025{
1026var data = new INTERNAL_SDL_MessageBoxData()
1027{
1028flags = messageboxdata.flags,
1029window = messageboxdata.window,
1030title = INTERNAL_AllocUTF8(messageboxdata.title),
1031message = INTERNAL_AllocUTF8(messageboxdata.message),
1032numbuttons = messageboxdata.numbuttons,
1033};
1034
1035var buttons = new INTERNAL_SDL_MessageBoxButtonData[messageboxdata.numbuttons];
1036for (int i = 0; i < messageboxdata.numbuttons; i++)
1037{
1038buttons[i] = new INTERNAL_SDL_MessageBoxButtonData()
1039{
1040flags = messageboxdata.buttons[i].flags,
1041buttonid = messageboxdata.buttons[i].buttonid,
1042text = INTERNAL_AllocUTF8(messageboxdata.buttons[i].text),
1043};
1044}
1045
1046if (messageboxdata.colorScheme != null)
1047{
1048data.colorScheme = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SDL_MessageBoxColorScheme)));
1049Marshal.StructureToPtr(messageboxdata.colorScheme.Value, data.colorScheme, false);
1050}
1051
1052int result;
1053fixed (INTERNAL_SDL_MessageBoxButtonData* buttonsPtr = &buttons[0])
1054{
1055data.buttons = (IntPtr)buttonsPtr;
1056result = INTERNAL_SDL_ShowMessageBox(ref data, out buttonid);
1057}
1058
1059Marshal.FreeHGlobal(data.colorScheme);
1060for (int i = 0; i < messageboxdata.numbuttons; i++)
1061{
1062SDL_free(buttons[i].text);
1063}
1064SDL_free(data.message);
1065SDL_free(data.title);
1066
1067return result;
1068}
1069*/
1070/* window refers to an SDL_Window* */1071[DllImport(nativeLibName, EntryPoint = "SDL_ShowSimpleMessageBox", CallingConvention = CallingConvention.Cdecl)]1072private static extern int INTERNAL_SDL_ShowSimpleMessageBox(1073SDL_MessageBoxFlags flags,1074byte[] title,1075byte[] message,1076IntPtr window1077);1078public static int SDL_ShowSimpleMessageBox(1079SDL_MessageBoxFlags flags,1080string title,1081string message,1082IntPtr window1083)1084{1085return INTERNAL_SDL_ShowSimpleMessageBox(1086flags,1087UTF8_ToNative(title),1088UTF8_ToNative(message),1089window
1090);1091}1092
1093#endregion1094
1095#region SDL_version.h, SDL_revision.h1096
1097/* Similar to the headers, this is the version we're expecting to be1098* running with. You will likely want to check this somewhere in your
1099* program!
1100*/
1101public const int SDL_MAJOR_VERSION = 2;1102public const int SDL_MINOR_VERSION = 0;1103public const int SDL_PATCHLEVEL = 12;1104
1105public static readonly int SDL_COMPILEDVERSION = SDL_VERSIONNUM(1106SDL_MAJOR_VERSION,1107SDL_MINOR_VERSION,1108SDL_PATCHLEVEL
1109);1110
1111[StructLayout(LayoutKind.Sequential)]1112public struct SDL_version1113{1114public byte major;1115public byte minor;1116public byte patch;1117}1118
1119public static void SDL_VERSION(out SDL_version x)1120{1121x.major = SDL_MAJOR_VERSION;1122x.minor = SDL_MINOR_VERSION;1123x.patch = SDL_PATCHLEVEL;1124}1125
1126public static int SDL_VERSIONNUM(int X, int Y, int Z)1127{1128return (X * 1000) + (Y * 100) + Z;1129}1130
1131public static bool SDL_VERSION_ATLEAST(int X, int Y, int Z)1132{1133return (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z));1134}1135
1136[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1137public static extern void SDL_GetVersion(out SDL_version ver);1138
1139static Version _version;1140
1141public static Version Version1142{1143get1144{1145if (_version == null)1146{1147SDL.SDL_version ver;1148SDL.SDL_GetVersion(out ver);1149_version = new Version(ver.major, ver.minor, ver.patch, 0);1150}1151
1152return _version;1153}1154}1155
1156[DllImport(nativeLibName, EntryPoint = "SDL_GetRevision", CallingConvention = CallingConvention.Cdecl)]1157private static extern IntPtr INTERNAL_SDL_GetRevision();1158public static string SDL_GetRevision()1159{1160return UTF8_ToManaged(INTERNAL_SDL_GetRevision());1161}1162
1163[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1164public static extern int SDL_GetRevisionNumber();1165
1166#endregion1167
1168#region SDL_video.h1169
1170public enum SDL_GLattr1171{1172SDL_GL_RED_SIZE,1173SDL_GL_GREEN_SIZE,1174SDL_GL_BLUE_SIZE,1175SDL_GL_ALPHA_SIZE,1176SDL_GL_BUFFER_SIZE,1177SDL_GL_DOUBLEBUFFER,1178SDL_GL_DEPTH_SIZE,1179SDL_GL_STENCIL_SIZE,1180SDL_GL_ACCUM_RED_SIZE,1181SDL_GL_ACCUM_GREEN_SIZE,1182SDL_GL_ACCUM_BLUE_SIZE,1183SDL_GL_ACCUM_ALPHA_SIZE,1184SDL_GL_STEREO,1185SDL_GL_MULTISAMPLEBUFFERS,1186SDL_GL_MULTISAMPLESAMPLES,1187SDL_GL_ACCELERATED_VISUAL,1188SDL_GL_RETAINED_BACKING,1189SDL_GL_CONTEXT_MAJOR_VERSION,1190SDL_GL_CONTEXT_MINOR_VERSION,1191SDL_GL_CONTEXT_EGL,1192SDL_GL_CONTEXT_FLAGS,1193SDL_GL_CONTEXT_PROFILE_MASK,1194SDL_GL_SHARE_WITH_CURRENT_CONTEXT,1195SDL_GL_FRAMEBUFFER_SRGB_CAPABLE,1196SDL_GL_CONTEXT_RELEASE_BEHAVIOR,1197SDL_GL_CONTEXT_RESET_NOTIFICATION, /* Requires >= 2.0.6 */1198SDL_GL_CONTEXT_NO_ERROR, /* Requires >= 2.0.6 */1199}1200
1201[Flags]1202public enum SDL_GLprofile1203{1204SDL_GL_CONTEXT_PROFILE_CORE = 0x0001,1205SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002,1206SDL_GL_CONTEXT_PROFILE_ES = 0x00041207}1208
1209[Flags]1210public enum SDL_GLcontext1211{1212SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001,1213SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002,1214SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004,1215SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x00081216}1217
1218public enum SDL_WindowEventID : byte1219{1220SDL_WINDOWEVENT_NONE,1221SDL_WINDOWEVENT_SHOWN,1222SDL_WINDOWEVENT_HIDDEN,1223SDL_WINDOWEVENT_EXPOSED,1224SDL_WINDOWEVENT_MOVED,1225SDL_WINDOWEVENT_RESIZED,1226SDL_WINDOWEVENT_SIZE_CHANGED,1227SDL_WINDOWEVENT_MINIMIZED,1228SDL_WINDOWEVENT_MAXIMIZED,1229SDL_WINDOWEVENT_RESTORED,1230SDL_WINDOWEVENT_ENTER,1231SDL_WINDOWEVENT_LEAVE,1232SDL_WINDOWEVENT_FOCUS_GAINED,1233SDL_WINDOWEVENT_FOCUS_LOST,1234SDL_WINDOWEVENT_CLOSE,1235/* Only available in 2.0.5 or higher. */1236SDL_WINDOWEVENT_TAKE_FOCUS,1237SDL_WINDOWEVENT_HIT_TEST
1238}1239
1240public enum SDL_DisplayEventID : byte1241{1242SDL_DISPLAYEVENT_NONE,1243SDL_DISPLAYEVENT_ORIENTATION
1244}1245
1246public enum SDL_DisplayOrientation1247{1248SDL_ORIENTATION_UNKNOWN,1249SDL_ORIENTATION_LANDSCAPE,1250SDL_ORIENTATION_LANDSCAPE_FLIPPED,1251SDL_ORIENTATION_PORTRAIT,1252SDL_ORIENTATION_PORTRAIT_FLIPPED
1253}1254
1255[Flags]1256public enum SDL_WindowFlags : uint1257{1258SDL_WINDOW_FULLSCREEN = 0x00000001,1259SDL_WINDOW_OPENGL = 0x00000002,1260SDL_WINDOW_SHOWN = 0x00000004,1261SDL_WINDOW_HIDDEN = 0x00000008,1262SDL_WINDOW_BORDERLESS = 0x00000010,1263SDL_WINDOW_RESIZABLE = 0x00000020,1264SDL_WINDOW_MINIMIZED = 0x00000040,1265SDL_WINDOW_MAXIMIZED = 0x00000080,1266SDL_WINDOW_INPUT_GRABBED = 0x00000100,1267SDL_WINDOW_INPUT_FOCUS = 0x00000200,1268SDL_WINDOW_MOUSE_FOCUS = 0x00000400,1269SDL_WINDOW_FULLSCREEN_DESKTOP =1270(SDL_WINDOW_FULLSCREEN | 0x00001000),1271SDL_WINDOW_FOREIGN = 0x00000800,1272SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /* Requires >= 2.0.1 */1273SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /* Requires >= 2.0.4 */1274SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /* Requires >= 2.0.5 */1275SDL_WINDOW_SKIP_TASKBAR = 0x00010000, /* Requires >= 2.0.5 */1276SDL_WINDOW_UTILITY = 0x00020000, /* Requires >= 2.0.5 */1277SDL_WINDOW_TOOLTIP = 0x00040000, /* Requires >= 2.0.5 */1278SDL_WINDOW_POPUP_MENU = 0x00080000, /* Requires >= 2.0.5 */1279SDL_WINDOW_VULKAN = 0x10000000, /* Requires >= 2.0.6 */1280}1281
1282/* Only available in 2.0.4 or higher. */1283public enum SDL_HitTestResult1284{1285SDL_HITTEST_NORMAL, /* Region is normal. No special properties. */1286SDL_HITTEST_DRAGGABLE, /* Region can drag entire window. */1287SDL_HITTEST_RESIZE_TOPLEFT,1288SDL_HITTEST_RESIZE_TOP,1289SDL_HITTEST_RESIZE_TOPRIGHT,1290SDL_HITTEST_RESIZE_RIGHT,1291SDL_HITTEST_RESIZE_BOTTOMRIGHT,1292SDL_HITTEST_RESIZE_BOTTOM,1293SDL_HITTEST_RESIZE_BOTTOMLEFT,1294SDL_HITTEST_RESIZE_LEFT
1295}1296
1297public const int SDL_WINDOWPOS_UNDEFINED_MASK = 0x1FFF0000;1298public const int SDL_WINDOWPOS_CENTERED_MASK = 0x2FFF0000;1299public const int SDL_WINDOWPOS_UNDEFINED = 0x1FFF0000;1300public const int SDL_WINDOWPOS_CENTERED = 0x2FFF0000;1301
1302public static int SDL_WINDOWPOS_UNDEFINED_DISPLAY(int X)1303{1304return (SDL_WINDOWPOS_UNDEFINED_MASK | X);1305}1306
1307public static bool SDL_WINDOWPOS_ISUNDEFINED(int X)1308{1309return (X & 0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK;1310}1311
1312public static int SDL_WINDOWPOS_CENTERED_DISPLAY(int X)1313{1314return (SDL_WINDOWPOS_CENTERED_MASK | X);1315}1316
1317public static bool SDL_WINDOWPOS_ISCENTERED(int X)1318{1319return (X & 0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK;1320}1321
1322[StructLayout(LayoutKind.Sequential)]1323public struct SDL_DisplayMode1324{1325public uint format;1326public int w;1327public int h;1328public int refresh_rate;1329public IntPtr driverdata; // void*1330}1331
1332/* win refers to an SDL_Window*, area to a const SDL_Point*, data to a void*.1333* Only available in 2.0.4 or higher.
1334*/
1335[UnmanagedFunctionPointer(CallingConvention.Cdecl)]1336public delegate SDL_HitTestResult SDL_HitTest(IntPtr win, IntPtr area, IntPtr data);1337
1338/* IntPtr refers to an SDL_Window* */1339[DllImport(nativeLibName, EntryPoint = "SDL_CreateWindow", CallingConvention = CallingConvention.Cdecl)]1340private static extern IntPtr INTERNAL_SDL_CreateWindow(1341byte[] title,1342int x,1343int y,1344int w,1345int h,1346SDL_WindowFlags flags1347);1348public static IntPtr SDL_CreateWindow(1349string title,1350int x,1351int y,1352int w,1353int h,1354SDL_WindowFlags flags1355)1356{1357return INTERNAL_SDL_CreateWindow(1358UTF8_ToNative(title),1359x, y, w, h,1360flags
1361);1362}1363
1364/* window refers to an SDL_Window*, renderer to an SDL_Renderer* */1365[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1366public static extern int SDL_CreateWindowAndRenderer(1367int width,1368int height,1369SDL_WindowFlags window_flags,1370out IntPtr window,1371out IntPtr renderer1372);1373
1374/* data refers to some native window type, IntPtr to an SDL_Window* */1375[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1376public static extern IntPtr SDL_CreateWindowFrom(IntPtr data);1377
1378/* window refers to an SDL_Window* */1379[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1380public static extern void SDL_DestroyWindow(IntPtr window);1381
1382[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1383public static extern void SDL_DisableScreenSaver();1384
1385[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1386public static extern void SDL_EnableScreenSaver();1387
1388/* IntPtr refers to an SDL_DisplayMode. Just use closest. */1389[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1390public static extern IntPtr SDL_GetClosestDisplayMode(1391int displayIndex,1392ref SDL_DisplayMode mode,1393out SDL_DisplayMode closest1394);1395
1396[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1397public static extern int SDL_GetCurrentDisplayMode(1398int displayIndex,1399out SDL_DisplayMode mode1400);1401
1402[DllImport(nativeLibName, EntryPoint = "SDL_GetCurrentVideoDriver", CallingConvention = CallingConvention.Cdecl)]1403private static extern IntPtr INTERNAL_SDL_GetCurrentVideoDriver();1404public static string SDL_GetCurrentVideoDriver()1405{1406return UTF8_ToManaged(INTERNAL_SDL_GetCurrentVideoDriver());1407}1408
1409[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1410public static extern int SDL_GetDesktopDisplayMode(1411int displayIndex,1412out SDL_DisplayMode mode1413);1414
1415[DllImport(nativeLibName, EntryPoint = "SDL_GetDisplayName", CallingConvention = CallingConvention.Cdecl)]1416private static extern IntPtr INTERNAL_SDL_GetDisplayName(int index);1417public static string SDL_GetDisplayName(int index)1418{1419return UTF8_ToManaged(INTERNAL_SDL_GetDisplayName(index));1420}1421
1422[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1423public static extern int SDL_GetDisplayBounds(1424int displayIndex,1425out SDL_Rect rect1426);1427
1428/* Only available in 2.0.4 or higher. */1429[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1430public static extern int SDL_GetDisplayDPI(1431int displayIndex,1432out float ddpi,1433out float hdpi,1434out float vdpi1435);1436
1437/* Only available in 2.0.9 or higher. */1438[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1439public static extern SDL_DisplayOrientation SDL_GetDisplayOrientation(1440int displayIndex1441);1442
1443[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1444public static extern int SDL_GetDisplayMode(1445int displayIndex,1446int modeIndex,1447out SDL_DisplayMode mode1448);1449
1450/* Only available in 2.0.5 or higher. */1451[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1452public static extern int SDL_GetDisplayUsableBounds(1453int displayIndex,1454out SDL_Rect rect1455);1456
1457[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1458public static extern int SDL_GetNumDisplayModes(1459int displayIndex1460);1461
1462[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1463public static extern int SDL_GetNumVideoDisplays();1464
1465[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1466public static extern int SDL_GetNumVideoDrivers();1467
1468[DllImport(nativeLibName, EntryPoint = "SDL_GetVideoDriver", CallingConvention = CallingConvention.Cdecl)]1469private static extern IntPtr INTERNAL_SDL_GetVideoDriver(1470int index1471);1472public static string SDL_GetVideoDriver(int index)1473{1474return UTF8_ToManaged(INTERNAL_SDL_GetVideoDriver(index));1475}1476
1477/* window refers to an SDL_Window* */1478[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1479public static extern float SDL_GetWindowBrightness(1480IntPtr window1481);1482
1483/* window refers to an SDL_Window*1484* Only available in 2.0.5 or higher.
1485*/
1486[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1487public static extern int SDL_SetWindowOpacity(1488IntPtr window,1489float opacity1490);1491
1492/* window refers to an SDL_Window*1493* Only available in 2.0.5 or higher.
1494*/
1495[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1496public static extern int SDL_GetWindowOpacity(1497IntPtr window,1498out float out_opacity1499);1500
1501/* modal_window and parent_window refer to an SDL_Window*s1502* Only available in 2.0.5 or higher.
1503*/
1504[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1505public static extern int SDL_SetWindowModalFor(1506IntPtr modal_window,1507IntPtr parent_window1508);1509
1510/* window refers to an SDL_Window*1511* Only available in 2.0.5 or higher.
1512*/
1513[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1514public static extern int SDL_SetWindowInputFocus(IntPtr window);1515
1516/* window refers to an SDL_Window*, IntPtr to a void* */1517[DllImport(nativeLibName, EntryPoint = "SDL_GetWindowData", CallingConvention = CallingConvention.Cdecl)]1518private static extern IntPtr INTERNAL_SDL_GetWindowData(1519IntPtr window,1520byte[] name1521);1522public static IntPtr SDL_GetWindowData(1523IntPtr window,1524string name1525)1526{1527return INTERNAL_SDL_GetWindowData(1528window,1529UTF8_ToNative(name)1530);1531}1532
1533/* window refers to an SDL_Window* */1534[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1535public static extern int SDL_GetWindowDisplayIndex(1536IntPtr window1537);1538
1539/* window refers to an SDL_Window* */1540[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1541public static extern int SDL_GetWindowDisplayMode(1542IntPtr window,1543out SDL_DisplayMode mode1544);1545
1546/* window refers to an SDL_Window* */1547[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1548public static extern uint SDL_GetWindowFlags(IntPtr window);1549
1550/* IntPtr refers to an SDL_Window* */1551[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1552public static extern IntPtr SDL_GetWindowFromID(uint id);1553
1554/* window refers to an SDL_Window* */1555[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1556public static extern int SDL_GetWindowGammaRamp(1557IntPtr window,1558[Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]1559ushort[] red,1560[Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]1561ushort[] green,1562[Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]1563ushort[] blue1564);1565
1566/* window refers to an SDL_Window* */1567[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1568public static extern SDL_bool SDL_GetWindowGrab(IntPtr window);1569
1570/* window refers to an SDL_Window* */1571[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1572public static extern uint SDL_GetWindowID(IntPtr window);1573
1574/* window refers to an SDL_Window* */1575[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1576public static extern uint SDL_GetWindowPixelFormat(1577IntPtr window1578);1579
1580/* window refers to an SDL_Window* */1581[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1582public static extern void SDL_GetWindowMaximumSize(1583IntPtr window,1584out int max_w,1585out int max_h1586);1587
1588/* window refers to an SDL_Window* */1589[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1590public static extern void SDL_GetWindowMinimumSize(1591IntPtr window,1592out int min_w,1593out int min_h1594);1595
1596/* window refers to an SDL_Window* */1597[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1598public static extern void SDL_GetWindowPosition(1599IntPtr window,1600out int x,1601out int y1602);1603
1604/* window refers to an SDL_Window* */1605[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1606public static extern void SDL_GetWindowSize(1607IntPtr window,1608out int w,1609out int h1610);1611
1612/* IntPtr refers to an SDL_Surface*, window to an SDL_Window* */1613[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1614public static extern IntPtr SDL_GetWindowSurface(IntPtr window);1615
1616/* window refers to an SDL_Window* */1617[DllImport(nativeLibName, EntryPoint = "SDL_GetWindowTitle", CallingConvention = CallingConvention.Cdecl)]1618private static extern IntPtr INTERNAL_SDL_GetWindowTitle(1619IntPtr window1620);1621public static string SDL_GetWindowTitle(IntPtr window)1622{1623return UTF8_ToManaged(1624INTERNAL_SDL_GetWindowTitle(window)1625);1626}1627
1628/* texture refers to an SDL_Texture* */1629[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1630public static extern int SDL_GL_BindTexture(1631IntPtr texture,1632out float texw,1633out float texh1634);1635
1636/* IntPtr and window refer to an SDL_GLContext and SDL_Window* */1637[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1638public static extern IntPtr SDL_GL_CreateContext(IntPtr window);1639
1640/* context refers to an SDL_GLContext */1641[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1642public static extern void SDL_GL_DeleteContext(IntPtr context);1643
1644/* IntPtr refers to a function pointer */1645[DllImport(nativeLibName, EntryPoint = "SDL_GL_GetProcAddress", CallingConvention = CallingConvention.Cdecl)]1646private static extern IntPtr INTERNAL_SDL_GL_GetProcAddress(1647byte[] proc1648);1649public static IntPtr SDL_GL_GetProcAddress(string proc)1650{1651return INTERNAL_SDL_GL_GetProcAddress(1652UTF8_ToNative(proc)1653);1654}1655
1656[DllImport(nativeLibName, EntryPoint = "SDL_GL_LoadLibrary", CallingConvention = CallingConvention.Cdecl)]1657private static extern int INTERNAL_SDL_GL_LoadLibrary(byte[] path);1658public static int SDL_GL_LoadLibrary(string path)1659{1660return INTERNAL_SDL_GL_LoadLibrary(1661UTF8_ToNative(path)1662);1663}1664
1665/* IntPtr refers to a function pointer, proc to a const char* */1666[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1667public static extern IntPtr SDL_GL_GetProcAddress(IntPtr proc);1668
1669[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1670public static extern void SDL_GL_UnloadLibrary();1671
1672[DllImport(nativeLibName, EntryPoint = "SDL_GL_ExtensionSupported", CallingConvention = CallingConvention.Cdecl)]1673private static extern SDL_bool INTERNAL_SDL_GL_ExtensionSupported(1674byte[] extension1675);1676public static SDL_bool SDL_GL_ExtensionSupported(string extension)1677{1678return INTERNAL_SDL_GL_ExtensionSupported(1679UTF8_ToNative(extension)1680);1681}1682
1683/* Only available in SDL 2.0.2 or higher. */1684[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1685public static extern void SDL_GL_ResetAttributes();1686
1687[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1688public static extern int SDL_GL_GetAttribute(1689SDL_GLattr attr,1690out int value1691);1692
1693[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1694public static extern int SDL_GL_GetSwapInterval();1695
1696/* window and context refer to an SDL_Window* and SDL_GLContext */1697[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1698public static extern int SDL_GL_MakeCurrent(1699IntPtr window,1700IntPtr context1701);1702
1703/* IntPtr refers to an SDL_Window* */1704[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1705public static extern IntPtr SDL_GL_GetCurrentWindow();1706
1707/* IntPtr refers to an SDL_Context */1708[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1709public static extern IntPtr SDL_GL_GetCurrentContext();1710
1711/* window refers to an SDL_Window*.1712* Only available in SDL 2.0.1 or higher.
1713*/
1714[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1715public static extern void SDL_GL_GetDrawableSize(1716IntPtr window,1717out int w,1718out int h1719);1720
1721[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1722public static extern int SDL_GL_SetAttribute(1723SDL_GLattr attr,1724int value1725);1726
1727public static int SDL_GL_SetAttribute(1728SDL_GLattr attr,1729SDL_GLprofile profile1730)1731{1732return SDL_GL_SetAttribute(attr, (int)profile);1733}1734
1735[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1736public static extern int SDL_GL_SetSwapInterval(int interval);1737
1738/* window refers to an SDL_Window* */1739[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1740public static extern void SDL_GL_SwapWindow(IntPtr window);1741
1742/* texture refers to an SDL_Texture* */1743[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1744public static extern int SDL_GL_UnbindTexture(IntPtr texture);1745
1746/* window refers to an SDL_Window* */1747[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1748public static extern void SDL_HideWindow(IntPtr window);1749
1750[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1751public static extern SDL_bool SDL_IsScreenSaverEnabled();1752
1753/* window refers to an SDL_Window* */1754[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1755public static extern void SDL_MaximizeWindow(IntPtr window);1756
1757/* window refers to an SDL_Window* */1758[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1759public static extern void SDL_MinimizeWindow(IntPtr window);1760
1761/* window refers to an SDL_Window* */1762[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1763public static extern void SDL_RaiseWindow(IntPtr window);1764
1765/* window refers to an SDL_Window* */1766[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1767public static extern void SDL_RestoreWindow(IntPtr window);1768
1769/* window refers to an SDL_Window* */1770[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1771public static extern int SDL_SetWindowBrightness(1772IntPtr window,1773float brightness1774);1775
1776/* IntPtr and userdata are void*, window is an SDL_Window* */1777[DllImport(nativeLibName, EntryPoint = "SDL_SetWindowData", CallingConvention = CallingConvention.Cdecl)]1778private static extern IntPtr INTERNAL_SDL_SetWindowData(1779IntPtr window,1780byte[] name,1781IntPtr userdata1782);1783public static IntPtr SDL_SetWindowData(1784IntPtr window,1785string name,1786IntPtr userdata1787)1788{1789return INTERNAL_SDL_SetWindowData(1790window,1791UTF8_ToNative(name),1792userdata
1793);1794}1795
1796/* window refers to an SDL_Window* */1797[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1798public static extern int SDL_SetWindowDisplayMode(1799IntPtr window,1800ref SDL_DisplayMode mode1801);1802
1803/* window refers to an SDL_Window* */1804[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1805public static extern int SDL_SetWindowFullscreen(1806IntPtr window,1807uint flags1808);1809
1810/* window refers to an SDL_Window* */1811[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1812public static extern int SDL_SetWindowGammaRamp(1813IntPtr window,1814[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]1815ushort[] red,1816[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]1817ushort[] green,1818[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]1819ushort[] blue1820);1821
1822/* window refers to an SDL_Window* */1823[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1824public static extern void SDL_SetWindowGrab(1825IntPtr window,1826SDL_bool grabbed1827);1828
1829/* window refers to an SDL_Window*, icon to an SDL_Surface* */1830[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1831public static extern void SDL_SetWindowIcon(1832IntPtr window,1833IntPtr icon1834);1835
1836/* window refers to an SDL_Window* */1837[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1838public static extern void SDL_SetWindowMaximumSize(1839IntPtr window,1840int max_w,1841int max_h1842);1843
1844/* window refers to an SDL_Window* */1845[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1846public static extern void SDL_SetWindowMinimumSize(1847IntPtr window,1848int min_w,1849int min_h1850);1851
1852/* window refers to an SDL_Window* */1853[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1854public static extern void SDL_SetWindowPosition(1855IntPtr window,1856int x,1857int y1858);1859
1860/* window refers to an SDL_Window* */1861[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1862public static extern void SDL_SetWindowSize(1863IntPtr window,1864int w,1865int h1866);1867
1868/* window refers to an SDL_Window* */1869[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1870public static extern void SDL_SetWindowBordered(1871IntPtr window,1872SDL_bool bordered1873);1874
1875/* window refers to an SDL_Window* */1876[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1877public static extern int SDL_GetWindowBordersSize(1878IntPtr window,1879out int top,1880out int left,1881out int bottom,1882out int right1883);1884
1885/* window refers to an SDL_Window*1886* Only available in 2.0.5 or higher.
1887*/
1888[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1889public static extern void SDL_SetWindowResizable(1890IntPtr window,1891SDL_bool resizable1892);1893
1894/* window refers to an SDL_Window* */1895[DllImport(nativeLibName, EntryPoint = "SDL_SetWindowTitle", CallingConvention = CallingConvention.Cdecl)]1896private static extern void INTERNAL_SDL_SetWindowTitle(1897IntPtr window,1898byte[] title1899);1900public static void SDL_SetWindowTitle(1901IntPtr window,1902string title1903)1904{1905INTERNAL_SDL_SetWindowTitle(1906window,1907UTF8_ToNative(title)1908);1909}1910
1911/* window refers to an SDL_Window* */1912[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1913public static extern void SDL_ShowWindow(IntPtr window);1914
1915/* window refers to an SDL_Window* */1916[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1917public static extern int SDL_UpdateWindowSurface(IntPtr window);1918
1919/* window refers to an SDL_Window* */1920[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1921public static extern int SDL_UpdateWindowSurfaceRects(1922IntPtr window,1923[In] SDL_Rect[] rects,1924int numrects1925);1926
1927[DllImport(nativeLibName, EntryPoint = "SDL_VideoInit", CallingConvention = CallingConvention.Cdecl)]1928private static extern int INTERNAL_SDL_VideoInit(1929byte[] driver_name1930);1931public static int SDL_VideoInit(string driver_name)1932{1933return INTERNAL_SDL_VideoInit(1934UTF8_ToNative(driver_name)1935);1936}1937
1938[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1939public static extern void SDL_VideoQuit();1940
1941/* window refers to an SDL_Window*, callback_data to a void*1942* Only available in 2.0.4 or higher.
1943*/
1944[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1945public static extern int SDL_SetWindowHitTest(1946IntPtr window,1947SDL_HitTest callback,1948IntPtr callback_data1949);1950
1951/* IntPtr refers to an SDL_Window*1952* Only available in 2.0.4 or higher.
1953*/
1954[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1955public static extern IntPtr SDL_GetGrabbedWindow();1956
1957#endregion1958
1959#region SDL_blendmode.h1960
1961[Flags]1962public enum SDL_BlendMode1963{1964SDL_BLENDMODE_NONE = 0x00000000,1965SDL_BLENDMODE_BLEND = 0x00000001,1966SDL_BLENDMODE_ADD = 0x00000002,1967SDL_BLENDMODE_MOD = 0x00000004,1968SDL_BLENDMODE_MUL = 0x00000008, /* >= 2.0.11 */1969SDL_BLENDMODE_INVALID = 0x7FFFFFFF1970}1971
1972public enum SDL_BlendOperation1973{1974SDL_BLENDOPERATION_ADD = 0x1,1975SDL_BLENDOPERATION_SUBTRACT = 0x2,1976SDL_BLENDOPERATION_REV_SUBTRACT = 0x3,1977SDL_BLENDOPERATION_MINIMUM = 0x4,1978SDL_BLENDOPERATION_MAXIMUM = 0x51979}1980
1981public enum SDL_BlendFactor1982{1983SDL_BLENDFACTOR_ZERO = 0x1,1984SDL_BLENDFACTOR_ONE = 0x2,1985SDL_BLENDFACTOR_SRC_COLOR = 0x3,1986SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4,1987SDL_BLENDFACTOR_SRC_ALPHA = 0x5,1988SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6,1989SDL_BLENDFACTOR_DST_COLOR = 0x7,1990SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8,1991SDL_BLENDFACTOR_DST_ALPHA = 0x9,1992SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA1993}1994
1995/* Only available in 2.0.6 or higher. */1996[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]1997public static extern SDL_BlendMode SDL_ComposeCustomBlendMode(1998SDL_BlendFactor srcColorFactor,1999SDL_BlendFactor dstColorFactor,2000SDL_BlendOperation colorOperation,2001SDL_BlendFactor srcAlphaFactor,2002SDL_BlendFactor dstAlphaFactor,2003SDL_BlendOperation alphaOperation2004);2005
2006#endregion2007
2008#region SDL_vulkan.h2009
2010/* Only available in 2.0.6 or higher. */2011[DllImport(nativeLibName, EntryPoint = "SDL_Vulkan_LoadLibrary", CallingConvention = CallingConvention.Cdecl)]2012private static extern int INTERNAL_SDL_Vulkan_LoadLibrary(2013byte[] path2014);2015public static int SDL_Vulkan_LoadLibrary(string path)2016{2017return INTERNAL_SDL_Vulkan_LoadLibrary(2018UTF8_ToNative(path)2019);2020}2021
2022/* Only available in 2.0.6 or higher. */2023[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2024public static extern IntPtr SDL_Vulkan_GetVkGetInstanceProcAddr();2025
2026/* Only available in 2.0.6 or higher. */2027[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2028public static extern void SDL_Vulkan_UnloadLibrary();2029
2030/* window refers to an SDL_Window*, pNames to a const char**.2031* Only available in 2.0.6 or higher.
2032*/
2033[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2034public static extern SDL_bool SDL_Vulkan_GetInstanceExtensions(2035IntPtr window,2036out uint pCount,2037IntPtr[] pNames2038);2039
2040/* window refers to an SDL_Window.2041* instance refers to a VkInstance.
2042* surface refers to a VkSurfaceKHR.
2043* Only available in 2.0.6 or higher.
2044*/
2045[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2046public static extern SDL_bool SDL_Vulkan_CreateSurface(2047IntPtr window,2048IntPtr instance,2049out ulong surface2050);2051
2052/* window refers to an SDL_Window*.2053* Only available in 2.0.6 or higher.
2054*/
2055[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2056public static extern void SDL_Vulkan_GetDrawableSize(2057IntPtr window,2058out int w,2059out int h2060);2061
2062#endregion2063
2064#region SDL_metal.h2065
2066/* Only available in 2.0.11 or higher. */2067[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2068public static extern IntPtr SDL_Metal_CreateView(2069IntPtr window2070);2071
2072/* Only available in 2.0.11 or higher. */2073[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2074public static extern void SDL_Metal_DestroyView(2075IntPtr view2076);2077
2078#endregion2079
2080#region SDL_render.h2081
2082[Flags]2083public enum SDL_RendererFlags : uint2084{2085SDL_RENDERER_SOFTWARE = 0x00000001,2086SDL_RENDERER_ACCELERATED = 0x00000002,2087SDL_RENDERER_PRESENTVSYNC = 0x00000004,2088SDL_RENDERER_TARGETTEXTURE = 0x000000082089}2090
2091[Flags]2092public enum SDL_RendererFlip2093{2094SDL_FLIP_NONE = 0x00000000,2095SDL_FLIP_HORIZONTAL = 0x00000001,2096SDL_FLIP_VERTICAL = 0x000000022097}2098
2099public enum SDL_TextureAccess2100{2101SDL_TEXTUREACCESS_STATIC,2102SDL_TEXTUREACCESS_STREAMING,2103SDL_TEXTUREACCESS_TARGET
2104}2105
2106[Flags]2107public enum SDL_TextureModulate2108{2109SDL_TEXTUREMODULATE_NONE = 0x00000000,2110SDL_TEXTUREMODULATE_HORIZONTAL = 0x00000001,2111SDL_TEXTUREMODULATE_VERTICAL = 0x000000022112}2113
2114[StructLayout(LayoutKind.Sequential)]2115public struct SDL_RendererInfo2116{2117public IntPtr name; // const char*2118public uint flags;2119public uint num_texture_formats;2120[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]2121public uint[] texture_formats;2122public int max_texture_width;2123public int max_texture_height;2124}2125
2126/* Only available in 2.0.11 or higher. */2127public enum SDL_ScaleMode2128{2129SDL_ScaleModeNearest,2130SDL_ScaleModeLinear,2131SDL_ScaleModeBest
2132}2133
2134/* IntPtr refers to an SDL_Renderer*, window to an SDL_Window* */2135[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2136public static extern IntPtr SDL_CreateRenderer(2137IntPtr window,2138int index,2139SDL_RendererFlags flags2140);2141
2142/* IntPtr refers to an SDL_Renderer*, surface to an SDL_Surface* */2143[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2144public static extern IntPtr SDL_CreateSoftwareRenderer(IntPtr surface);2145
2146/* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */2147[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2148public static extern IntPtr SDL_CreateTexture(2149IntPtr renderer,2150uint format,2151int access,2152int w,2153int h2154);2155
2156/* IntPtr refers to an SDL_Texture*2157* renderer refers to an SDL_Renderer*
2158* surface refers to an SDL_Surface*
2159*/
2160[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2161public static extern IntPtr SDL_CreateTextureFromSurface(2162IntPtr renderer,2163IntPtr surface2164);2165
2166/* renderer refers to an SDL_Renderer* */2167[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2168public static extern void SDL_DestroyRenderer(IntPtr renderer);2169
2170/* texture refers to an SDL_Texture* */2171[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2172public static extern void SDL_DestroyTexture(IntPtr texture);2173
2174[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2175public static extern int SDL_GetNumRenderDrivers();2176
2177/* renderer refers to an SDL_Renderer* */2178[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2179public static extern int SDL_GetRenderDrawBlendMode(2180IntPtr renderer,2181out SDL_BlendMode blendMode2182);2183
2184/* texture refers to an SDL_Texture*2185* Only available in 2.0.11 or higher.
2186*/
2187[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2188public static extern int SDL_SetTextureScaleMode(2189IntPtr texture,2190SDL_ScaleMode scaleMode2191);2192
2193/* texture refers to an SDL_Texture*2194* Only available in 2.0.11 or higher.
2195*/
2196[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2197public static extern int SDL_GetTextureScaleMode(2198IntPtr texture,2199out SDL_ScaleMode scaleMode2200);2201
2202/* renderer refers to an SDL_Renderer* */2203[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2204public static extern int SDL_GetRenderDrawColor(2205IntPtr renderer,2206out byte r,2207out byte g,2208out byte b,2209out byte a2210);2211
2212[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2213public static extern int SDL_GetRenderDriverInfo(2214int index,2215out SDL_RendererInfo info2216);2217
2218/* IntPtr refers to an SDL_Renderer*, window to an SDL_Window* */2219[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2220public static extern IntPtr SDL_GetRenderer(IntPtr window);2221
2222/* renderer refers to an SDL_Renderer* */2223[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2224public static extern int SDL_GetRendererInfo(2225IntPtr renderer,2226out SDL_RendererInfo info2227);2228
2229/* renderer refers to an SDL_Renderer* */2230[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2231public static extern int SDL_GetRendererOutputSize(2232IntPtr renderer,2233out int w,2234out int h2235);2236
2237/* texture refers to an SDL_Texture* */2238[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2239public static extern int SDL_GetTextureAlphaMod(2240IntPtr texture,2241out byte alpha2242);2243
2244/* texture refers to an SDL_Texture* */2245[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2246public static extern int SDL_GetTextureBlendMode(2247IntPtr texture,2248out SDL_BlendMode blendMode2249);2250
2251/* texture refers to an SDL_Texture* */2252[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2253public static extern int SDL_GetTextureColorMod(2254IntPtr texture,2255out byte r,2256out byte g,2257out byte b2258);2259
2260/* texture refers to an SDL_Texture*, pixels to a void* */2261[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2262public static extern int SDL_LockTexture(2263IntPtr texture,2264ref SDL_Rect rect,2265out IntPtr pixels,2266out int pitch2267);2268
2269/* texture refers to an SDL_Texture*, pixels to a void*.2270* Internally, this function contains logic to use default values when
2271* the rectangle is passed as NULL.
2272* This overload allows for IntPtr.Zero to be passed for rect.
2273*/
2274[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2275public static extern int SDL_LockTexture(2276IntPtr texture,2277IntPtr rect,2278out IntPtr pixels,2279out int pitch2280);2281
2282/* texture refers to an SDL_Texture*, surface to an SDL_Surface*2283* Only available in 2.0.11 or higher.
2284*/
2285[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2286public static extern int SDL_LockTextureToSurface(2287IntPtr texture,2288ref SDL_Rect rect,2289out IntPtr surface2290);2291
2292/* texture refers to an SDL_Texture*, surface to an SDL_Surface*2293* Internally, this function contains logic to use default values when
2294* the rectangle is passed as NULL.
2295* This overload allows for IntPtr.Zero to be passed for rect.
2296* Only available in 2.0.11 or higher.
2297*/
2298[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2299public static extern int SDL_LockTextureToSurface(2300IntPtr texture,2301IntPtr rect,2302out IntPtr surface2303);2304
2305/* texture refers to an SDL_Texture* */2306[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2307public static extern int SDL_QueryTexture(2308IntPtr texture,2309out uint format,2310out int access,2311out int w,2312out int h2313);2314
2315/* renderer refers to an SDL_Renderer* */2316[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2317public static extern int SDL_RenderClear(IntPtr renderer);2318
2319/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */2320[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2321public static extern int SDL_RenderCopy(2322IntPtr renderer,2323IntPtr texture,2324ref SDL_Rect srcrect,2325ref SDL_Rect dstrect2326);2327
2328/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2329* Internally, this function contains logic to use default values when
2330* source and destination rectangles are passed as NULL.
2331* This overload allows for IntPtr.Zero (null) to be passed for srcrect.
2332*/
2333[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2334public static extern int SDL_RenderCopy(2335IntPtr renderer,2336IntPtr texture,2337IntPtr srcrect,2338ref SDL_Rect dstrect2339);2340
2341/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2342* Internally, this function contains logic to use default values when
2343* source and destination rectangles are passed as NULL.
2344* This overload allows for IntPtr.Zero (null) to be passed for dstrect.
2345*/
2346[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2347public static extern int SDL_RenderCopy(2348IntPtr renderer,2349IntPtr texture,2350ref SDL_Rect srcrect,2351IntPtr dstrect2352);2353
2354/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2355* Internally, this function contains logic to use default values when
2356* source and destination rectangles are passed as NULL.
2357* This overload allows for IntPtr.Zero (null) to be passed for both SDL_Rects.
2358*/
2359[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2360public static extern int SDL_RenderCopy(2361IntPtr renderer,2362IntPtr texture,2363IntPtr srcrect,2364IntPtr dstrect2365);2366
2367/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */2368[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2369public static extern int SDL_RenderCopyEx(2370IntPtr renderer,2371IntPtr texture,2372ref SDL_Rect srcrect,2373ref SDL_Rect dstrect,2374double angle,2375ref SDL_Point center,2376SDL_RendererFlip flip2377);2378
2379/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2380* Internally, this function contains logic to use default values when
2381* source, destination, and/or center are passed as NULL.
2382* This overload allows for IntPtr.Zero (null) to be passed for srcrect.
2383*/
2384[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2385public static extern int SDL_RenderCopyEx(2386IntPtr renderer,2387IntPtr texture,2388IntPtr srcrect,2389ref SDL_Rect dstrect,2390double angle,2391ref SDL_Point center,2392SDL_RendererFlip flip2393);2394
2395/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2396* Internally, this function contains logic to use default values when
2397* source, destination, and/or center are passed as NULL.
2398* This overload allows for IntPtr.Zero (null) to be passed for dstrect.
2399*/
2400[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2401public static extern int SDL_RenderCopyEx(2402IntPtr renderer,2403IntPtr texture,2404ref SDL_Rect srcrect,2405IntPtr dstrect,2406double angle,2407ref SDL_Point center,2408SDL_RendererFlip flip2409);2410
2411/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2412* Internally, this function contains logic to use default values when
2413* source, destination, and/or center are passed as NULL.
2414* This overload allows for IntPtr.Zero (null) to be passed for center.
2415*/
2416[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2417public static extern int SDL_RenderCopyEx(2418IntPtr renderer,2419IntPtr texture,2420ref SDL_Rect srcrect,2421ref SDL_Rect dstrect,2422double angle,2423IntPtr center,2424SDL_RendererFlip flip2425);2426
2427/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2428* Internally, this function contains logic to use default values when
2429* source, destination, and/or center are passed as NULL.
2430* This overload allows for IntPtr.Zero (null) to be passed for both
2431* srcrect and dstrect.
2432*/
2433[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2434public static extern int SDL_RenderCopyEx(2435IntPtr renderer,2436IntPtr texture,2437IntPtr srcrect,2438IntPtr dstrect,2439double angle,2440ref SDL_Point center,2441SDL_RendererFlip flip2442);2443
2444/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2445* Internally, this function contains logic to use default values when
2446* source, destination, and/or center are passed as NULL.
2447* This overload allows for IntPtr.Zero (null) to be passed for both
2448* srcrect and center.
2449*/
2450[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2451public static extern int SDL_RenderCopyEx(2452IntPtr renderer,2453IntPtr texture,2454IntPtr srcrect,2455ref SDL_Rect dstrect,2456double angle,2457IntPtr center,2458SDL_RendererFlip flip2459);2460
2461/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2462* Internally, this function contains logic to use default values when
2463* source, destination, and/or center are passed as NULL.
2464* This overload allows for IntPtr.Zero (null) to be passed for both
2465* dstrect and center.
2466*/
2467[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2468public static extern int SDL_RenderCopyEx(2469IntPtr renderer,2470IntPtr texture,2471ref SDL_Rect srcrect,2472IntPtr dstrect,2473double angle,2474IntPtr center,2475SDL_RendererFlip flip2476);2477
2478/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2479* Internally, this function contains logic to use default values when
2480* source, destination, and/or center are passed as NULL.
2481* This overload allows for IntPtr.Zero (null) to be passed for all
2482* three parameters.
2483*/
2484[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2485public static extern int SDL_RenderCopyEx(2486IntPtr renderer,2487IntPtr texture,2488IntPtr srcrect,2489IntPtr dstrect,2490double angle,2491IntPtr center,2492SDL_RendererFlip flip2493);2494
2495/* renderer refers to an SDL_Renderer* */2496[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2497public static extern int SDL_RenderDrawLine(2498IntPtr renderer,2499int x1,2500int y1,2501int x2,2502int y22503);2504
2505/* renderer refers to an SDL_Renderer* */2506[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2507public static extern int SDL_RenderDrawLines(2508IntPtr renderer,2509[In] SDL_Point[] points,2510int count2511);2512
2513/* renderer refers to an SDL_Renderer* */2514[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2515public static extern int SDL_RenderDrawPoint(2516IntPtr renderer,2517int x,2518int y2519);2520
2521/* renderer refers to an SDL_Renderer* */2522[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2523public static extern int SDL_RenderDrawPoints(2524IntPtr renderer,2525[In] SDL_Point[] points,2526int count2527);2528
2529/* renderer refers to an SDL_Renderer* */2530[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2531public static extern int SDL_RenderDrawRect(2532IntPtr renderer,2533ref SDL_Rect rect2534);2535
2536/* renderer refers to an SDL_Renderer*, rect to an SDL_Rect*.2537* This overload allows for IntPtr.Zero (null) to be passed for rect.
2538*/
2539[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2540public static extern int SDL_RenderDrawRect(2541IntPtr renderer,2542IntPtr rect2543);2544
2545/* renderer refers to an SDL_Renderer* */2546[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2547public static extern int SDL_RenderDrawRects(2548IntPtr renderer,2549[In] SDL_Rect[] rects,2550int count2551);2552
2553/* renderer refers to an SDL_Renderer* */2554[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2555public static extern int SDL_RenderFillRect(2556IntPtr renderer,2557ref SDL_Rect rect2558);2559
2560/* renderer refers to an SDL_Renderer*, rect to an SDL_Rect*.2561* This overload allows for IntPtr.Zero (null) to be passed for rect.
2562*/
2563[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2564public static extern int SDL_RenderFillRect(2565IntPtr renderer,2566IntPtr rect2567);2568
2569/* renderer refers to an SDL_Renderer* */2570[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2571public static extern int SDL_RenderFillRects(2572IntPtr renderer,2573[In] SDL_Rect[] rects,2574int count2575);2576
2577#region Floating Point Render Functions2578
2579/* This region only available in SDL 2.0.10 or higher. */2580
2581/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */2582[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2583public static extern int SDL_RenderCopyF(2584IntPtr renderer,2585IntPtr texture,2586ref SDL_Rect srcrect,2587ref SDL_FRect dstrect2588);2589
2590/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2591* Internally, this function contains logic to use default values when
2592* source and destination rectangles are passed as NULL.
2593* This overload allows for IntPtr.Zero (null) to be passed for srcrect.
2594*/
2595[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2596public static extern int SDL_RenderCopyF(2597IntPtr renderer,2598IntPtr texture,2599IntPtr srcrect,2600ref SDL_FRect dstrect2601);2602
2603/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2604* Internally, this function contains logic to use default values when
2605* source and destination rectangles are passed as NULL.
2606* This overload allows for IntPtr.Zero (null) to be passed for dstrect.
2607*/
2608[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2609public static extern int SDL_RenderCopyF(2610IntPtr renderer,2611IntPtr texture,2612ref SDL_Rect srcrect,2613IntPtr dstrect2614);2615
2616/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2617* Internally, this function contains logic to use default values when
2618* source and destination rectangles are passed as NULL.
2619* This overload allows for IntPtr.Zero (null) to be passed for both SDL_Rects.
2620*/
2621[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2622public static extern int SDL_RenderCopyF(2623IntPtr renderer,2624IntPtr texture,2625IntPtr srcrect,2626IntPtr dstrect2627);2628
2629/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */2630[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2631public static extern int SDL_RenderCopyEx(2632IntPtr renderer,2633IntPtr texture,2634ref SDL_Rect srcrect,2635ref SDL_FRect dstrect,2636double angle,2637ref SDL_FPoint center,2638SDL_RendererFlip flip2639);2640
2641/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2642* Internally, this function contains logic to use default values when
2643* source, destination, and/or center are passed as NULL.
2644* This overload allows for IntPtr.Zero (null) to be passed for srcrect.
2645*/
2646[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2647public static extern int SDL_RenderCopyEx(2648IntPtr renderer,2649IntPtr texture,2650IntPtr srcrect,2651ref SDL_FRect dstrect,2652double angle,2653ref SDL_FPoint center,2654SDL_RendererFlip flip2655);2656
2657/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2658* Internally, this function contains logic to use default values when
2659* source, destination, and/or center are passed as NULL.
2660* This overload allows for IntPtr.Zero (null) to be passed for dstrect.
2661*/
2662[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2663public static extern int SDL_RenderCopyExF(2664IntPtr renderer,2665IntPtr texture,2666ref SDL_Rect srcrect,2667IntPtr dstrect,2668double angle,2669ref SDL_FPoint center,2670SDL_RendererFlip flip2671);2672
2673/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2674* Internally, this function contains logic to use default values when
2675* source, destination, and/or center are passed as NULL.
2676* This overload allows for IntPtr.Zero (null) to be passed for center.
2677*/
2678[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2679public static extern int SDL_RenderCopyExF(2680IntPtr renderer,2681IntPtr texture,2682ref SDL_Rect srcrect,2683ref SDL_FRect dstrect,2684double angle,2685IntPtr center,2686SDL_RendererFlip flip2687);2688
2689/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2690* Internally, this function contains logic to use default values when
2691* source, destination, and/or center are passed as NULL.
2692* This overload allows for IntPtr.Zero (null) to be passed for both
2693* srcrect and dstrect.
2694*/
2695[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2696public static extern int SDL_RenderCopyExF(2697IntPtr renderer,2698IntPtr texture,2699IntPtr srcrect,2700IntPtr dstrect,2701double angle,2702ref SDL_FPoint center,2703SDL_RendererFlip flip2704);2705
2706/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2707* Internally, this function contains logic to use default values when
2708* source, destination, and/or center are passed as NULL.
2709* This overload allows for IntPtr.Zero (null) to be passed for both
2710* srcrect and center.
2711*/
2712[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2713public static extern int SDL_RenderCopyExF(2714IntPtr renderer,2715IntPtr texture,2716IntPtr srcrect,2717ref SDL_FRect dstrect,2718double angle,2719IntPtr center,2720SDL_RendererFlip flip2721);2722
2723/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2724* Internally, this function contains logic to use default values when
2725* source, destination, and/or center are passed as NULL.
2726* This overload allows for IntPtr.Zero (null) to be passed for both
2727* dstrect and center.
2728*/
2729[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2730public static extern int SDL_RenderCopyExF(2731IntPtr renderer,2732IntPtr texture,2733ref SDL_Rect srcrect,2734IntPtr dstrect,2735double angle,2736IntPtr center,2737SDL_RendererFlip flip2738);2739
2740/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.2741* Internally, this function contains logic to use default values when
2742* source, destination, and/or center are passed as NULL.
2743* This overload allows for IntPtr.Zero (null) to be passed for all
2744* three parameters.
2745*/
2746[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2747public static extern int SDL_RenderCopyExF(2748IntPtr renderer,2749IntPtr texture,2750IntPtr srcrect,2751IntPtr dstrect,2752double angle,2753IntPtr center,2754SDL_RendererFlip flip2755);2756
2757/* renderer refers to an SDL_Renderer* */2758[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2759public static extern int SDL_RenderDrawPointF(2760IntPtr renderer,2761float x,2762float y2763);2764
2765/* renderer refers to an SDL_Renderer* */2766[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2767public static extern int SDL_RenderDrawPointsF(2768IntPtr renderer,2769[In] SDL_FPoint[] points,2770int count2771);2772
2773/* renderer refers to an SDL_Renderer* */2774[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2775public static extern int SDL_RenderDrawLineF(2776IntPtr renderer,2777float x1,2778float y1,2779float x2,2780float y22781);2782
2783/* renderer refers to an SDL_Renderer* */2784[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2785public static extern int SDL_RenderDrawLinesF(2786IntPtr renderer,2787[In] SDL_FPoint[] points,2788int count2789);2790
2791/* renderer refers to an SDL_Renderer* */2792[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2793public static extern int SDL_RenderDrawRectF(2794IntPtr renderer,2795ref SDL_FRect rect2796);2797
2798/* renderer refers to an SDL_Renderer*, rect to an SDL_Rect*.2799* This overload allows for IntPtr.Zero (null) to be passed for rect.
2800*/
2801[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2802public static extern int SDL_RenderDrawRectF(2803IntPtr renderer,2804IntPtr rect2805);2806
2807/* renderer refers to an SDL_Renderer* */2808[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2809public static extern int SDL_RenderDrawRectsF(2810IntPtr renderer,2811[In] SDL_FRect[] rects,2812int count2813);2814
2815/* renderer refers to an SDL_Renderer* */2816[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2817public static extern int SDL_RenderFillRectF(2818IntPtr renderer,2819ref SDL_FRect rect2820);2821
2822/* renderer refers to an SDL_Renderer*, rect to an SDL_Rect*.2823* This overload allows for IntPtr.Zero (null) to be passed for rect.
2824*/
2825[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2826public static extern int SDL_RenderFillRectF(2827IntPtr renderer,2828IntPtr rect2829);2830
2831/* renderer refers to an SDL_Renderer* */2832[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2833public static extern int SDL_RenderFillRectsF(2834IntPtr renderer,2835[In] SDL_FRect[] rects,2836int count2837);2838
2839#endregion2840
2841/* renderer refers to an SDL_Renderer* */2842[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2843public static extern void SDL_RenderGetClipRect(2844IntPtr renderer,2845out SDL_Rect rect2846);2847
2848/* renderer refers to an SDL_Renderer* */2849[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2850public static extern void SDL_RenderGetLogicalSize(2851IntPtr renderer,2852out int w,2853out int h2854);2855
2856/* renderer refers to an SDL_Renderer* */2857[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2858public static extern void SDL_RenderGetScale(2859IntPtr renderer,2860out float scaleX,2861out float scaleY2862);2863
2864/* renderer refers to an SDL_Renderer* */2865[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2866public static extern int SDL_RenderGetViewport(2867IntPtr renderer,2868out SDL_Rect rect2869);2870
2871/* renderer refers to an SDL_Renderer* */2872[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2873public static extern void SDL_RenderPresent(IntPtr renderer);2874
2875/* renderer refers to an SDL_Renderer* */2876[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2877public static extern int SDL_RenderReadPixels(2878IntPtr renderer,2879ref SDL_Rect rect,2880uint format,2881IntPtr pixels,2882int pitch2883);2884
2885/* renderer refers to an SDL_Renderer* */2886[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2887public static extern int SDL_RenderSetClipRect(2888IntPtr renderer,2889ref SDL_Rect rect2890);2891
2892/* renderer refers to an SDL_Renderer*2893* This overload allows for IntPtr.Zero (null) to be passed for rect.
2894*/
2895[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2896public static extern int SDL_RenderSetClipRect(2897IntPtr renderer,2898IntPtr rect2899);2900
2901/* renderer refers to an SDL_Renderer* */2902[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2903public static extern int SDL_RenderSetLogicalSize(2904IntPtr renderer,2905int w,2906int h2907);2908
2909/* renderer refers to an SDL_Renderer* */2910[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2911public static extern int SDL_RenderSetScale(2912IntPtr renderer,2913float scaleX,2914float scaleY2915);2916
2917/* renderer refers to an SDL_Renderer*2918* Only available in 2.0.5 or higher.
2919*/
2920[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2921public static extern int SDL_RenderSetIntegerScale(2922IntPtr renderer,2923SDL_bool enable2924);2925
2926/* renderer refers to an SDL_Renderer* */2927[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2928public static extern int SDL_RenderSetViewport(2929IntPtr renderer,2930ref SDL_Rect rect2931);2932
2933/* renderer refers to an SDL_Renderer* */2934[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2935public static extern int SDL_SetRenderDrawBlendMode(2936IntPtr renderer,2937SDL_BlendMode blendMode2938);2939
2940/* renderer refers to an SDL_Renderer* */2941[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2942public static extern int SDL_SetRenderDrawColor(2943IntPtr renderer,2944byte r,2945byte g,2946byte b,2947byte a2948);2949
2950/* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */2951[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2952public static extern int SDL_SetRenderTarget(2953IntPtr renderer,2954IntPtr texture2955);2956
2957/* texture refers to an SDL_Texture* */2958[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2959public static extern int SDL_SetTextureAlphaMod(2960IntPtr texture,2961byte alpha2962);2963
2964/* texture refers to an SDL_Texture* */2965[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2966public static extern int SDL_SetTextureBlendMode(2967IntPtr texture,2968SDL_BlendMode blendMode2969);2970
2971/* texture refers to an SDL_Texture* */2972[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2973public static extern int SDL_SetTextureColorMod(2974IntPtr texture,2975byte r,2976byte g,2977byte b2978);2979
2980/* texture refers to an SDL_Texture* */2981[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2982public static extern void SDL_UnlockTexture(IntPtr texture);2983
2984/* texture refers to an SDL_Texture* */2985[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2986public static extern int SDL_UpdateTexture(2987IntPtr texture,2988ref SDL_Rect rect,2989IntPtr pixels,2990int pitch2991);2992
2993/* texture refers to an SDL_Texture* */2994[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]2995public static extern int SDL_UpdateTexture(2996IntPtr texture,2997IntPtr rect,2998IntPtr pixels,2999int pitch3000);3001
3002/* texture refers to an SDL_Texture*3003* Only available in 2.0.1 or higher.
3004*/
3005[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3006public static extern int SDL_UpdateYUVTexture(3007IntPtr texture,3008ref SDL_Rect rect,3009IntPtr yPlane,3010int yPitch,3011IntPtr uPlane,3012int uPitch,3013IntPtr vPlane,3014int vPitch3015);3016
3017/* renderer refers to an SDL_Renderer* */3018[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3019public static extern SDL_bool SDL_RenderTargetSupported(3020IntPtr renderer3021);3022
3023/* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */3024[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3025public static extern IntPtr SDL_GetRenderTarget(IntPtr renderer);3026
3027/* renderer refers to an SDL_Renderer*3028* Only available in 2.0.8 or higher.
3029*/
3030[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3031public static extern IntPtr SDL_RenderGetMetalLayer(3032IntPtr renderer3033);3034
3035/* renderer refers to an SDL_Renderer*3036* Only available in 2.0.8 or higher.
3037*/
3038[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3039public static extern IntPtr SDL_RenderGetMetalCommandEncoder(3040IntPtr renderer3041);3042
3043/* renderer refers to an SDL_Renderer*3044* Only available in 2.0.4 or higher.
3045*/
3046[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3047public static extern SDL_bool SDL_RenderIsClipEnabled(IntPtr renderer);3048
3049/* renderer refers to an SDL_Renderer*3050* Only available in 2.0.10 or higher.
3051*/
3052[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3053public static extern int SDL_RenderFlush(IntPtr renderer);3054
3055#endregion3056
3057#region SDL_pixels.h3058
3059public static uint SDL_DEFINE_PIXELFOURCC(byte A, byte B, byte C, byte D)3060{3061return SDL_FOURCC(A, B, C, D);3062}3063
3064public static uint SDL_DEFINE_PIXELFORMAT(3065SDL_PixelType type,3066uint order,3067SDL_PackedLayout layout,3068byte bits,3069byte bytes3070)3071{3072return (uint)(3073(1 << 28) |3074(((byte)type) << 24) |3075(((byte)order) << 20) |3076(((byte)layout) << 16) |3077(bits << 8) |3078(bytes)3079);3080}3081
3082public static byte SDL_PIXELFLAG(uint X)3083{3084return (byte)((X >> 28) & 0x0F);3085}3086
3087public static byte SDL_PIXELTYPE(uint X)3088{3089return (byte)((X >> 24) & 0x0F);3090}3091
3092public static byte SDL_PIXELORDER(uint X)3093{3094return (byte)((X >> 20) & 0x0F);3095}3096
3097public static byte SDL_PIXELLAYOUT(uint X)3098{3099return (byte)((X >> 16) & 0x0F);3100}3101
3102public static byte SDL_BITSPERPIXEL(uint X)3103{3104return (byte)((X >> 8) & 0xFF);3105}3106
3107public static byte SDL_BYTESPERPIXEL(uint X)3108{3109if (SDL_ISPIXELFORMAT_FOURCC(X))3110{3111if ((X == SDL_PIXELFORMAT_YUY2) ||3112(X == SDL_PIXELFORMAT_UYVY) ||3113(X == SDL_PIXELFORMAT_YVYU))3114{3115return 2;3116}3117return 1;3118}3119return (byte)(X & 0xFF);3120}3121
3122public static bool SDL_ISPIXELFORMAT_INDEXED(uint format)3123{3124if (SDL_ISPIXELFORMAT_FOURCC(format))3125{3126return false;3127}3128SDL_PixelType pType =3129(SDL_PixelType)SDL_PIXELTYPE(format);3130return (3131pType == SDL_PixelType.SDL_PIXELTYPE_INDEX1 ||3132pType == SDL_PixelType.SDL_PIXELTYPE_INDEX4 ||3133pType == SDL_PixelType.SDL_PIXELTYPE_INDEX83134);3135}3136
3137public static bool SDL_ISPIXELFORMAT_PACKED(uint format)3138{3139if (SDL_ISPIXELFORMAT_FOURCC(format))3140{3141return false;3142}3143SDL_PixelType pType =3144(SDL_PixelType)SDL_PIXELTYPE(format);3145return (3146pType == SDL_PixelType.SDL_PIXELTYPE_PACKED8 ||3147pType == SDL_PixelType.SDL_PIXELTYPE_PACKED16 ||3148pType == SDL_PixelType.SDL_PIXELTYPE_PACKED323149);3150}3151
3152public static bool SDL_ISPIXELFORMAT_ARRAY(uint format)3153{3154if (SDL_ISPIXELFORMAT_FOURCC(format))3155{3156return false;3157}3158SDL_PixelType pType =3159(SDL_PixelType)SDL_PIXELTYPE(format);3160return (3161pType == SDL_PixelType.SDL_PIXELTYPE_ARRAYU8 ||3162pType == SDL_PixelType.SDL_PIXELTYPE_ARRAYU16 ||3163pType == SDL_PixelType.SDL_PIXELTYPE_ARRAYU32 ||3164pType == SDL_PixelType.SDL_PIXELTYPE_ARRAYF16 ||3165pType == SDL_PixelType.SDL_PIXELTYPE_ARRAYF323166);3167}3168
3169public static bool SDL_ISPIXELFORMAT_ALPHA(uint format)3170{3171if (SDL_ISPIXELFORMAT_PACKED(format))3172{3173SDL_PackedOrder pOrder =3174(SDL_PackedOrder)SDL_PIXELORDER(format);3175return (3176pOrder == SDL_PackedOrder.SDL_PACKEDORDER_ARGB ||3177pOrder == SDL_PackedOrder.SDL_PACKEDORDER_RGBA ||3178pOrder == SDL_PackedOrder.SDL_PACKEDORDER_ABGR ||3179pOrder == SDL_PackedOrder.SDL_PACKEDORDER_BGRA3180);3181}3182else if (SDL_ISPIXELFORMAT_ARRAY(format))3183{3184SDL_ArrayOrder aOrder =3185(SDL_ArrayOrder)SDL_PIXELORDER(format);3186return (3187aOrder == SDL_ArrayOrder.SDL_ARRAYORDER_ARGB ||3188aOrder == SDL_ArrayOrder.SDL_ARRAYORDER_RGBA ||3189aOrder == SDL_ArrayOrder.SDL_ARRAYORDER_ABGR ||3190aOrder == SDL_ArrayOrder.SDL_ARRAYORDER_BGRA3191);3192}3193return false;3194}3195
3196public static bool SDL_ISPIXELFORMAT_FOURCC(uint format)3197{3198return (format == 0) && (SDL_PIXELFLAG(format) != 1);3199}3200
3201public enum SDL_PixelType3202{3203SDL_PIXELTYPE_UNKNOWN,3204SDL_PIXELTYPE_INDEX1,3205SDL_PIXELTYPE_INDEX4,3206SDL_PIXELTYPE_INDEX8,3207SDL_PIXELTYPE_PACKED8,3208SDL_PIXELTYPE_PACKED16,3209SDL_PIXELTYPE_PACKED32,3210SDL_PIXELTYPE_ARRAYU8,3211SDL_PIXELTYPE_ARRAYU16,3212SDL_PIXELTYPE_ARRAYU32,3213SDL_PIXELTYPE_ARRAYF16,3214SDL_PIXELTYPE_ARRAYF32
3215}3216
3217public enum SDL_BitmapOrder3218{3219SDL_BITMAPORDER_NONE,3220SDL_BITMAPORDER_4321,3221SDL_BITMAPORDER_1234
3222}3223
3224public enum SDL_PackedOrder3225{3226SDL_PACKEDORDER_NONE,3227SDL_PACKEDORDER_XRGB,3228SDL_PACKEDORDER_RGBX,3229SDL_PACKEDORDER_ARGB,3230SDL_PACKEDORDER_RGBA,3231SDL_PACKEDORDER_XBGR,3232SDL_PACKEDORDER_BGRX,3233SDL_PACKEDORDER_ABGR,3234SDL_PACKEDORDER_BGRA
3235}3236
3237public enum SDL_ArrayOrder3238{3239SDL_ARRAYORDER_NONE,3240SDL_ARRAYORDER_RGB,3241SDL_ARRAYORDER_RGBA,3242SDL_ARRAYORDER_ARGB,3243SDL_ARRAYORDER_BGR,3244SDL_ARRAYORDER_BGRA,3245SDL_ARRAYORDER_ABGR
3246}3247
3248public enum SDL_PackedLayout3249{3250SDL_PACKEDLAYOUT_NONE,3251SDL_PACKEDLAYOUT_332,3252SDL_PACKEDLAYOUT_4444,3253SDL_PACKEDLAYOUT_1555,3254SDL_PACKEDLAYOUT_5551,3255SDL_PACKEDLAYOUT_565,3256SDL_PACKEDLAYOUT_8888,3257SDL_PACKEDLAYOUT_2101010,3258SDL_PACKEDLAYOUT_1010102
3259}3260
3261public static readonly uint SDL_PIXELFORMAT_UNKNOWN = 0;3262public static readonly uint SDL_PIXELFORMAT_INDEX1LSB =3263SDL_DEFINE_PIXELFORMAT(3264SDL_PixelType.SDL_PIXELTYPE_INDEX1,3265(uint)SDL_BitmapOrder.SDL_BITMAPORDER_4321,32660,32671, 03268);3269public static readonly uint SDL_PIXELFORMAT_INDEX1MSB =3270SDL_DEFINE_PIXELFORMAT(3271SDL_PixelType.SDL_PIXELTYPE_INDEX1,3272(uint)SDL_BitmapOrder.SDL_BITMAPORDER_1234,32730,32741, 03275);3276public static readonly uint SDL_PIXELFORMAT_INDEX4LSB =3277SDL_DEFINE_PIXELFORMAT(3278SDL_PixelType.SDL_PIXELTYPE_INDEX4,3279(uint)SDL_BitmapOrder.SDL_BITMAPORDER_4321,32800,32814, 03282);3283public static readonly uint SDL_PIXELFORMAT_INDEX4MSB =3284SDL_DEFINE_PIXELFORMAT(3285SDL_PixelType.SDL_PIXELTYPE_INDEX4,3286(uint)SDL_BitmapOrder.SDL_BITMAPORDER_1234,32870,32884, 03289);3290public static readonly uint SDL_PIXELFORMAT_INDEX8 =3291SDL_DEFINE_PIXELFORMAT(3292SDL_PixelType.SDL_PIXELTYPE_INDEX8,32930,32940,32958, 13296);3297public static readonly uint SDL_PIXELFORMAT_RGB332 =3298SDL_DEFINE_PIXELFORMAT(3299SDL_PixelType.SDL_PIXELTYPE_PACKED8,3300(uint)SDL_PackedOrder.SDL_PACKEDORDER_XRGB,3301SDL_PackedLayout.SDL_PACKEDLAYOUT_332,33028, 13303);3304public static readonly uint SDL_PIXELFORMAT_RGB444 =3305SDL_DEFINE_PIXELFORMAT(3306SDL_PixelType.SDL_PIXELTYPE_PACKED16,3307(uint)SDL_PackedOrder.SDL_PACKEDORDER_XRGB,3308SDL_PackedLayout.SDL_PACKEDLAYOUT_4444,330912, 23310);3311public static readonly uint SDL_PIXELFORMAT_BGR444 =3312SDL_DEFINE_PIXELFORMAT(3313SDL_PixelType.SDL_PIXELTYPE_PACKED16,3314(uint)SDL_PackedOrder.SDL_PACKEDORDER_XBGR,3315SDL_PackedLayout.SDL_PACKEDLAYOUT_4444,331612, 23317);3318public static readonly uint SDL_PIXELFORMAT_RGB555 =3319SDL_DEFINE_PIXELFORMAT(3320SDL_PixelType.SDL_PIXELTYPE_PACKED16,3321(uint)SDL_PackedOrder.SDL_PACKEDORDER_XRGB,3322SDL_PackedLayout.SDL_PACKEDLAYOUT_1555,332315, 23324);3325public static readonly uint SDL_PIXELFORMAT_BGR555 =3326SDL_DEFINE_PIXELFORMAT(3327SDL_PixelType.SDL_PIXELTYPE_INDEX1,3328(uint)SDL_BitmapOrder.SDL_BITMAPORDER_4321,3329SDL_PackedLayout.SDL_PACKEDLAYOUT_1555,333015, 23331);3332public static readonly uint SDL_PIXELFORMAT_ARGB4444 =3333SDL_DEFINE_PIXELFORMAT(3334SDL_PixelType.SDL_PIXELTYPE_PACKED16,3335(uint)SDL_PackedOrder.SDL_PACKEDORDER_ARGB,3336SDL_PackedLayout.SDL_PACKEDLAYOUT_4444,333716, 23338);3339public static readonly uint SDL_PIXELFORMAT_RGBA4444 =3340SDL_DEFINE_PIXELFORMAT(3341SDL_PixelType.SDL_PIXELTYPE_PACKED16,3342(uint)SDL_PackedOrder.SDL_PACKEDORDER_RGBA,3343SDL_PackedLayout.SDL_PACKEDLAYOUT_4444,334416, 23345);3346public static readonly uint SDL_PIXELFORMAT_ABGR4444 =3347SDL_DEFINE_PIXELFORMAT(3348SDL_PixelType.SDL_PIXELTYPE_PACKED16,3349(uint)SDL_PackedOrder.SDL_PACKEDORDER_ABGR,3350SDL_PackedLayout.SDL_PACKEDLAYOUT_4444,335116, 23352);3353public static readonly uint SDL_PIXELFORMAT_BGRA4444 =3354SDL_DEFINE_PIXELFORMAT(3355SDL_PixelType.SDL_PIXELTYPE_PACKED16,3356(uint)SDL_PackedOrder.SDL_PACKEDORDER_BGRA,3357SDL_PackedLayout.SDL_PACKEDLAYOUT_4444,335816, 23359);3360public static readonly uint SDL_PIXELFORMAT_ARGB1555 =3361SDL_DEFINE_PIXELFORMAT(3362SDL_PixelType.SDL_PIXELTYPE_PACKED16,3363(uint)SDL_PackedOrder.SDL_PACKEDORDER_ARGB,3364SDL_PackedLayout.SDL_PACKEDLAYOUT_1555,336516, 23366);3367public static readonly uint SDL_PIXELFORMAT_RGBA5551 =3368SDL_DEFINE_PIXELFORMAT(3369SDL_PixelType.SDL_PIXELTYPE_PACKED16,3370(uint)SDL_PackedOrder.SDL_PACKEDORDER_RGBA,3371SDL_PackedLayout.SDL_PACKEDLAYOUT_5551,337216, 23373);3374public static readonly uint SDL_PIXELFORMAT_ABGR1555 =3375SDL_DEFINE_PIXELFORMAT(3376SDL_PixelType.SDL_PIXELTYPE_PACKED16,3377(uint)SDL_PackedOrder.SDL_PACKEDORDER_ABGR,3378SDL_PackedLayout.SDL_PACKEDLAYOUT_1555,337916, 23380);3381public static readonly uint SDL_PIXELFORMAT_BGRA5551 =3382SDL_DEFINE_PIXELFORMAT(3383SDL_PixelType.SDL_PIXELTYPE_PACKED16,3384(uint)SDL_PackedOrder.SDL_PACKEDORDER_BGRA,3385SDL_PackedLayout.SDL_PACKEDLAYOUT_5551,338616, 23387);3388public static readonly uint SDL_PIXELFORMAT_RGB565 =3389SDL_DEFINE_PIXELFORMAT(3390SDL_PixelType.SDL_PIXELTYPE_PACKED16,3391(uint)SDL_PackedOrder.SDL_PACKEDORDER_XRGB,3392SDL_PackedLayout.SDL_PACKEDLAYOUT_565,339316, 23394);3395public static readonly uint SDL_PIXELFORMAT_BGR565 =3396SDL_DEFINE_PIXELFORMAT(3397SDL_PixelType.SDL_PIXELTYPE_PACKED16,3398(uint)SDL_PackedOrder.SDL_PACKEDORDER_XBGR,3399SDL_PackedLayout.SDL_PACKEDLAYOUT_565,340016, 23401);3402public static readonly uint SDL_PIXELFORMAT_RGB24 =3403SDL_DEFINE_PIXELFORMAT(3404SDL_PixelType.SDL_PIXELTYPE_ARRAYU8,3405(uint)SDL_ArrayOrder.SDL_ARRAYORDER_RGB,34060,340724, 33408);3409public static readonly uint SDL_PIXELFORMAT_BGR24 =3410SDL_DEFINE_PIXELFORMAT(3411SDL_PixelType.SDL_PIXELTYPE_ARRAYU8,3412(uint)SDL_ArrayOrder.SDL_ARRAYORDER_BGR,34130,341424, 33415);3416public static readonly uint SDL_PIXELFORMAT_RGB888 =3417SDL_DEFINE_PIXELFORMAT(3418SDL_PixelType.SDL_PIXELTYPE_PACKED32,3419(uint)SDL_PackedOrder.SDL_PACKEDORDER_XRGB,3420SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,342124, 43422);3423public static readonly uint SDL_PIXELFORMAT_RGBX8888 =3424SDL_DEFINE_PIXELFORMAT(3425SDL_PixelType.SDL_PIXELTYPE_PACKED32,3426(uint)SDL_PackedOrder.SDL_PACKEDORDER_RGBX,3427SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,342824, 43429);3430public static readonly uint SDL_PIXELFORMAT_BGR888 =3431SDL_DEFINE_PIXELFORMAT(3432SDL_PixelType.SDL_PIXELTYPE_PACKED32,3433(uint)SDL_PackedOrder.SDL_PACKEDORDER_XBGR,3434SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,343524, 43436);3437public static readonly uint SDL_PIXELFORMAT_BGRX8888 =3438SDL_DEFINE_PIXELFORMAT(3439SDL_PixelType.SDL_PIXELTYPE_PACKED32,3440(uint)SDL_PackedOrder.SDL_PACKEDORDER_BGRX,3441SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,344224, 43443);3444public static readonly uint SDL_PIXELFORMAT_ARGB8888 =3445SDL_DEFINE_PIXELFORMAT(3446SDL_PixelType.SDL_PIXELTYPE_PACKED32,3447(uint)SDL_PackedOrder.SDL_PACKEDORDER_ARGB,3448SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,344932, 43450);3451public static readonly uint SDL_PIXELFORMAT_RGBA8888 =3452SDL_DEFINE_PIXELFORMAT(3453SDL_PixelType.SDL_PIXELTYPE_PACKED32,3454(uint)SDL_PackedOrder.SDL_PACKEDORDER_RGBA,3455SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,345632, 43457);3458public static readonly uint SDL_PIXELFORMAT_ABGR8888 =3459SDL_DEFINE_PIXELFORMAT(3460SDL_PixelType.SDL_PIXELTYPE_PACKED32,3461(uint)SDL_PackedOrder.SDL_PACKEDORDER_ABGR,3462SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,346332, 43464);3465public static readonly uint SDL_PIXELFORMAT_BGRA8888 =3466SDL_DEFINE_PIXELFORMAT(3467SDL_PixelType.SDL_PIXELTYPE_PACKED32,3468(uint)SDL_PackedOrder.SDL_PACKEDORDER_BGRA,3469SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,347032, 43471);3472public static readonly uint SDL_PIXELFORMAT_ARGB2101010 =3473SDL_DEFINE_PIXELFORMAT(3474SDL_PixelType.SDL_PIXELTYPE_PACKED32,3475(uint)SDL_PackedOrder.SDL_PACKEDORDER_ARGB,3476SDL_PackedLayout.SDL_PACKEDLAYOUT_2101010,347732, 43478);3479public static readonly uint SDL_PIXELFORMAT_YV12 =3480SDL_DEFINE_PIXELFOURCC(3481(byte)'Y', (byte)'V', (byte)'1', (byte)'2'3482);3483public static readonly uint SDL_PIXELFORMAT_IYUV =3484SDL_DEFINE_PIXELFOURCC(3485(byte)'I', (byte)'Y', (byte)'U', (byte)'V'3486);3487public static readonly uint SDL_PIXELFORMAT_YUY2 =3488SDL_DEFINE_PIXELFOURCC(3489(byte)'Y', (byte)'U', (byte)'Y', (byte)'2'3490);3491public static readonly uint SDL_PIXELFORMAT_UYVY =3492SDL_DEFINE_PIXELFOURCC(3493(byte)'U', (byte)'Y', (byte)'V', (byte)'Y'3494);3495public static readonly uint SDL_PIXELFORMAT_YVYU =3496SDL_DEFINE_PIXELFOURCC(3497(byte)'Y', (byte)'V', (byte)'Y', (byte)'U'3498);3499
3500[StructLayout(LayoutKind.Sequential)]3501public struct SDL_Color3502{3503public byte r;3504public byte g;3505public byte b;3506public byte a;3507}3508
3509[StructLayout(LayoutKind.Sequential)]3510public struct SDL_Palette3511{3512public int ncolors;3513public IntPtr colors;3514public int version;3515public int refcount;3516}3517
3518[StructLayout(LayoutKind.Sequential)]3519public struct SDL_PixelFormat3520{3521public uint format;3522public IntPtr palette; // SDL_Palette*3523public byte BitsPerPixel;3524public byte BytesPerPixel;3525public uint Rmask;3526public uint Gmask;3527public uint Bmask;3528public uint Amask;3529public byte Rloss;3530public byte Gloss;3531public byte Bloss;3532public byte Aloss;3533public byte Rshift;3534public byte Gshift;3535public byte Bshift;3536public byte Ashift;3537public int refcount;3538public IntPtr next; // SDL_PixelFormat*3539}3540
3541/* IntPtr refers to an SDL_PixelFormat* */3542[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3543public static extern IntPtr SDL_AllocFormat(uint pixel_format);3544
3545/* IntPtr refers to an SDL_Palette* */3546[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3547public static extern IntPtr SDL_AllocPalette(int ncolors);3548
3549[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3550public static extern void SDL_CalculateGammaRamp(3551float gamma,3552[Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]3553ushort[] ramp3554);3555
3556/* format refers to an SDL_PixelFormat* */3557[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3558public static extern void SDL_FreeFormat(IntPtr format);3559
3560/* palette refers to an SDL_Palette* */3561[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3562public static extern void SDL_FreePalette(IntPtr palette);3563
3564[DllImport(nativeLibName, EntryPoint = "SDL_GetPixelFormatName", CallingConvention = CallingConvention.Cdecl)]3565private static extern IntPtr INTERNAL_SDL_GetPixelFormatName(3566uint format3567);3568public static string SDL_GetPixelFormatName(uint format)3569{3570return UTF8_ToManaged(3571INTERNAL_SDL_GetPixelFormatName(format)3572);3573}3574
3575/* format refers to an SDL_PixelFormat* */3576[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3577public static extern void SDL_GetRGB(3578uint pixel,3579IntPtr format,3580out byte r,3581out byte g,3582out byte b3583);3584
3585/* format refers to an SDL_PixelFormat* */3586[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3587public static extern void SDL_GetRGBA(3588uint pixel,3589IntPtr format,3590out byte r,3591out byte g,3592out byte b,3593out byte a3594);3595
3596/* format refers to an SDL_PixelFormat* */3597[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3598public static extern uint SDL_MapRGB(3599IntPtr format,3600byte r,3601byte g,3602byte b3603);3604
3605/* format refers to an SDL_PixelFormat* */3606[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3607public static extern uint SDL_MapRGBA(3608IntPtr format,3609byte r,3610byte g,3611byte b,3612byte a3613);3614
3615[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3616public static extern uint SDL_MasksToPixelFormatEnum(3617int bpp,3618uint Rmask,3619uint Gmask,3620uint Bmask,3621uint Amask3622);3623
3624[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3625public static extern SDL_bool SDL_PixelFormatEnumToMasks(3626uint format,3627out int bpp,3628out uint Rmask,3629out uint Gmask,3630out uint Bmask,3631out uint Amask3632);3633
3634/* palette refers to an SDL_Palette* */3635[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3636public static extern int SDL_SetPaletteColors(3637IntPtr palette,3638[In] SDL_Color[] colors,3639int firstcolor,3640int ncolors3641);3642
3643/* format and palette refer to an SDL_PixelFormat* and SDL_Palette* */3644[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3645public static extern int SDL_SetPixelFormatPalette(3646IntPtr format,3647IntPtr palette3648);3649
3650#endregion3651
3652#region SDL_rect.h3653
3654[StructLayout(LayoutKind.Sequential)]3655public struct SDL_Point3656{3657public int x;3658public int y;3659}3660
3661[StructLayout(LayoutKind.Sequential)]3662public struct SDL_Rect3663{3664public int x;3665public int y;3666public int w;3667public int h;3668}3669
3670/* Only available in 2.0.10 or higher. */3671[StructLayout(LayoutKind.Sequential)]3672public struct SDL_FPoint3673{3674public float x;3675public float y;3676}3677
3678/* Only available in 2.0.10 or higher. */3679[StructLayout(LayoutKind.Sequential)]3680public struct SDL_FRect3681{3682public float x;3683public float y;3684public float w;3685public float h;3686}3687
3688/* Only available in 2.0.4 or higher. */3689public static SDL_bool SDL_PointInRect(ref SDL_Point p, ref SDL_Rect r)3690{3691return ((p.x >= r.x) &&3692(p.x < (r.x + r.w)) &&3693(p.y >= r.y) &&3694(p.y < (r.y + r.h))) ?3695SDL_bool.SDL_TRUE :3696SDL_bool.SDL_FALSE;3697}3698
3699[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3700public static extern SDL_bool SDL_EnclosePoints(3701[In] SDL_Point[] points,3702int count,3703ref SDL_Rect clip,3704out SDL_Rect result3705);3706
3707[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3708public static extern SDL_bool SDL_HasIntersection(3709ref SDL_Rect A,3710ref SDL_Rect B3711);3712
3713[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3714public static extern SDL_bool SDL_IntersectRect(3715ref SDL_Rect A,3716ref SDL_Rect B,3717out SDL_Rect result3718);3719
3720[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3721public static extern SDL_bool SDL_IntersectRectAndLine(3722ref SDL_Rect rect,3723ref int X1,3724ref int Y1,3725ref int X2,3726ref int Y23727);3728
3729public static SDL_bool SDL_RectEmpty(ref SDL_Rect r)3730{3731return ((r.w <= 0) || (r.h <= 0)) ?3732SDL_bool.SDL_TRUE :3733SDL_bool.SDL_FALSE;3734}3735
3736public static SDL_bool SDL_RectEquals(3737ref SDL_Rect a,3738ref SDL_Rect b3739)3740{3741return ((a.x == b.x) &&3742(a.y == b.y) &&3743(a.w == b.w) &&3744(a.h == b.h)) ?3745SDL_bool.SDL_TRUE :3746SDL_bool.SDL_FALSE;3747}3748
3749[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3750public static extern void SDL_UnionRect(3751ref SDL_Rect A,3752ref SDL_Rect B,3753out SDL_Rect result3754);3755
3756#endregion3757
3758#region SDL_surface.h3759
3760public const uint SDL_SWSURFACE = 0x00000000;3761public const uint SDL_PREALLOC = 0x00000001;3762public const uint SDL_RLEACCEL = 0x00000002;3763public const uint SDL_DONTFREE = 0x00000004;3764
3765[StructLayout(LayoutKind.Sequential)]3766public struct SDL_Surface3767{3768public uint flags;3769public IntPtr format; // SDL_PixelFormat*3770public int w;3771public int h;3772public int pitch;3773public IntPtr pixels; // void*3774public IntPtr userdata; // void*3775public int locked;3776public IntPtr lock_data; // void*3777public SDL_Rect clip_rect;3778public IntPtr map; // SDL_BlitMap*3779public int refcount;3780}3781
3782/* surface refers to an SDL_Surface* */3783public static bool SDL_MUSTLOCK(IntPtr surface)3784{3785SDL_Surface sur;3786sur = (SDL_Surface)Marshal.PtrToStructure(3787surface,3788typeof(SDL_Surface)3789);3790return (sur.flags & SDL_RLEACCEL) != 0;3791}3792
3793/* src and dst refer to an SDL_Surface* */3794[DllImport(nativeLibName, EntryPoint = "SDL_UpperBlit", CallingConvention = CallingConvention.Cdecl)]3795public static extern int SDL_BlitSurface(3796IntPtr src,3797ref SDL_Rect srcrect,3798IntPtr dst,3799ref SDL_Rect dstrect3800);3801
3802/* src and dst refer to an SDL_Surface*3803* Internally, this function contains logic to use default values when
3804* source and destination rectangles are passed as NULL.
3805* This overload allows for IntPtr.Zero (null) to be passed for srcrect.
3806*/
3807[DllImport(nativeLibName, EntryPoint = "SDL_UpperBlit", CallingConvention = CallingConvention.Cdecl)]3808public static extern int SDL_BlitSurface(3809IntPtr src,3810IntPtr srcrect,3811IntPtr dst,3812ref SDL_Rect dstrect3813);3814
3815/* src and dst refer to an SDL_Surface*3816* Internally, this function contains logic to use default values when
3817* source and destination rectangles are passed as NULL.
3818* This overload allows for IntPtr.Zero (null) to be passed for dstrect.
3819*/
3820[DllImport(nativeLibName, EntryPoint = "SDL_UpperBlit", CallingConvention = CallingConvention.Cdecl)]3821public static extern int SDL_BlitSurface(3822IntPtr src,3823ref SDL_Rect srcrect,3824IntPtr dst,3825IntPtr dstrect3826);3827
3828/* src and dst refer to an SDL_Surface*3829* Internally, this function contains logic to use default values when
3830* source and destination rectangles are passed as NULL.
3831* This overload allows for IntPtr.Zero (null) to be passed for both SDL_Rects.
3832*/
3833[DllImport(nativeLibName, EntryPoint = "SDL_UpperBlit", CallingConvention = CallingConvention.Cdecl)]3834public static extern int SDL_BlitSurface(3835IntPtr src,3836IntPtr srcrect,3837IntPtr dst,3838IntPtr dstrect3839);3840
3841/* src and dst refer to an SDL_Surface* */3842[DllImport(nativeLibName, EntryPoint = "SDL_UpperBlitScaled", CallingConvention = CallingConvention.Cdecl)]3843public static extern int SDL_BlitScaled(3844IntPtr src,3845ref SDL_Rect srcrect,3846IntPtr dst,3847ref SDL_Rect dstrect3848);3849
3850/* src and dst refer to an SDL_Surface*3851* Internally, this function contains logic to use default values when
3852* source and destination rectangles are passed as NULL.
3853* This overload allows for IntPtr.Zero (null) to be passed for srcrect.
3854*/
3855[DllImport(nativeLibName, EntryPoint = "SDL_UpperBlitScaled", CallingConvention = CallingConvention.Cdecl)]3856public static extern int SDL_BlitScaled(3857IntPtr src,3858IntPtr srcrect,3859IntPtr dst,3860ref SDL_Rect dstrect3861);3862
3863/* src and dst refer to an SDL_Surface*3864* Internally, this function contains logic to use default values when
3865* source and destination rectangles are passed as NULL.
3866* This overload allows for IntPtr.Zero (null) to be passed for dstrect.
3867*/
3868[DllImport(nativeLibName, EntryPoint = "SDL_UpperBlitScaled", CallingConvention = CallingConvention.Cdecl)]3869public static extern int SDL_BlitScaled(3870IntPtr src,3871ref SDL_Rect srcrect,3872IntPtr dst,3873IntPtr dstrect3874);3875
3876/* src and dst refer to an SDL_Surface*3877* Internally, this function contains logic to use default values when
3878* source and destination rectangles are passed as NULL.
3879* This overload allows for IntPtr.Zero (null) to be passed for both SDL_Rects.
3880*/
3881[DllImport(nativeLibName, EntryPoint = "SDL_UpperBlitScaled", CallingConvention = CallingConvention.Cdecl)]3882public static extern int SDL_BlitScaled(3883IntPtr src,3884IntPtr srcrect,3885IntPtr dst,3886IntPtr dstrect3887);3888
3889/* src and dst are void* pointers */3890[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3891public static extern int SDL_ConvertPixels(3892int width,3893int height,3894uint src_format,3895IntPtr src,3896int src_pitch,3897uint dst_format,3898IntPtr dst,3899int dst_pitch3900);3901
3902/* IntPtr refers to an SDL_Surface*3903* src refers to an SDL_Surface*
3904* fmt refers to an SDL_PixelFormat*
3905*/
3906[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3907public static extern IntPtr SDL_ConvertSurface(3908IntPtr src,3909IntPtr fmt,3910uint flags3911);3912
3913/* IntPtr refers to an SDL_Surface*, src to an SDL_Surface* */3914[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3915public static extern IntPtr SDL_ConvertSurfaceFormat(3916IntPtr src,3917uint pixel_format,3918uint flags3919);3920
3921/* IntPtr refers to an SDL_Surface* */3922[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3923public static extern IntPtr SDL_CreateRGBSurface(3924uint flags,3925int width,3926int height,3927int depth,3928uint Rmask,3929uint Gmask,3930uint Bmask,3931uint Amask3932);3933
3934/* IntPtr refers to an SDL_Surface*, pixels to a void* */3935[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3936public static extern IntPtr SDL_CreateRGBSurfaceFrom(3937IntPtr pixels,3938int width,3939int height,3940int depth,3941int pitch,3942uint Rmask,3943uint Gmask,3944uint Bmask,3945uint Amask3946);3947
3948/* IntPtr refers to an SDL_Surface*3949* Only available in 2.0.5 or higher.
3950*/
3951[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3952public static extern IntPtr SDL_CreateRGBSurfaceWithFormat(3953uint flags,3954int width,3955int height,3956int depth,3957uint format3958);3959
3960/* IntPtr refers to an SDL_Surface*, pixels to a void*3961* Only available in 2.0.5 or higher.
3962*/
3963[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3964public static extern IntPtr SDL_CreateRGBSurfaceWithFormatFrom(3965IntPtr pixels,3966int width,3967int height,3968int depth,3969int pitch,3970uint format3971);3972
3973/* dst refers to an SDL_Surface* */3974[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3975public static extern int SDL_FillRect(3976IntPtr dst,3977ref SDL_Rect rect,3978uint color3979);3980
3981/* dst refers to an SDL_Surface*.3982* This overload allows passing NULL to rect.
3983*/
3984[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3985public static extern int SDL_FillRect(3986IntPtr dst,3987IntPtr rect,3988uint color3989);3990
3991/* dst refers to an SDL_Surface* */3992[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]3993public static extern int SDL_FillRects(3994IntPtr dst,3995[In] SDL_Rect[] rects,3996int count,3997uint color3998);3999
4000/* surface refers to an SDL_Surface* */4001[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4002public static extern void SDL_FreeSurface(IntPtr surface);4003
4004/* surface refers to an SDL_Surface* */4005[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4006public static extern void SDL_GetClipRect(4007IntPtr surface,4008out SDL_Rect rect4009);4010
4011/* surface refers to an SDL_Surface*.4012* Only available in 2.0.9 or higher.
4013*/
4014[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4015public static extern SDL_bool SDL_HasColorKey(IntPtr surface);4016
4017/* surface refers to an SDL_Surface* */4018[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4019public static extern int SDL_GetColorKey(4020IntPtr surface,4021out uint key4022);4023
4024/* surface refers to an SDL_Surface* */4025[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4026public static extern int SDL_GetSurfaceAlphaMod(4027IntPtr surface,4028out byte alpha4029);4030
4031/* surface refers to an SDL_Surface* */4032[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4033public static extern int SDL_GetSurfaceBlendMode(4034IntPtr surface,4035out SDL_BlendMode blendMode4036);4037
4038/* surface refers to an SDL_Surface* */4039[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4040public static extern int SDL_GetSurfaceColorMod(4041IntPtr surface,4042out byte r,4043out byte g,4044out byte b4045);4046
4047/* These are for SDL_LoadBMP, which is a macro in the SDL headers. */4048/* IntPtr refers to an SDL_Surface* */4049/* THIS IS AN RWops FUNCTION! */4050[DllImport(nativeLibName, EntryPoint = "SDL_LoadBMP_RW", CallingConvention = CallingConvention.Cdecl)]4051private static extern IntPtr INTERNAL_SDL_LoadBMP_RW(4052IntPtr src,4053int freesrc4054);4055public static IntPtr SDL_LoadBMP(string file)4056{4057IntPtr rwops = SDL_RWFromFile(file, "rb");4058return INTERNAL_SDL_LoadBMP_RW(rwops, 1);4059}4060
4061/* surface refers to an SDL_Surface* */4062[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4063public static extern int SDL_LockSurface(IntPtr surface);4064
4065/* src and dst refer to an SDL_Surface* */4066[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4067public static extern int SDL_LowerBlit(4068IntPtr src,4069ref SDL_Rect srcrect,4070IntPtr dst,4071ref SDL_Rect dstrect4072);4073
4074/* src and dst refer to an SDL_Surface* */4075[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4076public static extern int SDL_LowerBlitScaled(4077IntPtr src,4078ref SDL_Rect srcrect,4079IntPtr dst,4080ref SDL_Rect dstrect4081);4082
4083/* These are for SDL_SaveBMP, which is a macro in the SDL headers. */4084/* IntPtr refers to an SDL_Surface* */4085/* THIS IS AN RWops FUNCTION! */4086[DllImport(nativeLibName, EntryPoint = "SDL_SaveBMP_RW", CallingConvention = CallingConvention.Cdecl)]4087private static extern int INTERNAL_SDL_SaveBMP_RW(4088IntPtr surface,4089IntPtr src,4090int freesrc4091);4092public static int SDL_SaveBMP(IntPtr surface, string file)4093{4094IntPtr rwops = SDL_RWFromFile(file, "wb");4095return INTERNAL_SDL_SaveBMP_RW(surface, rwops, 1);4096}4097
4098/* surface refers to an SDL_Surface* */4099[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4100public static extern SDL_bool SDL_SetClipRect(4101IntPtr surface,4102ref SDL_Rect rect4103);4104
4105/* surface refers to an SDL_Surface* */4106[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4107public static extern int SDL_SetColorKey(4108IntPtr surface,4109int flag,4110uint key4111);4112
4113/* surface refers to an SDL_Surface* */4114[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4115public static extern int SDL_SetSurfaceAlphaMod(4116IntPtr surface,4117byte alpha4118);4119
4120/* surface refers to an SDL_Surface* */4121[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4122public static extern int SDL_SetSurfaceBlendMode(4123IntPtr surface,4124SDL_BlendMode blendMode4125);4126
4127/* surface refers to an SDL_Surface* */4128[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4129public static extern int SDL_SetSurfaceColorMod(4130IntPtr surface,4131byte r,4132byte g,4133byte b4134);4135
4136/* surface refers to an SDL_Surface*, palette to an SDL_Palette* */4137[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4138public static extern int SDL_SetSurfacePalette(4139IntPtr surface,4140IntPtr palette4141);4142
4143/* surface refers to an SDL_Surface* */4144[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4145public static extern int SDL_SetSurfaceRLE(4146IntPtr surface,4147int flag4148);4149
4150/* src and dst refer to an SDL_Surface* */4151[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4152public static extern int SDL_SoftStretch(4153IntPtr src,4154ref SDL_Rect srcrect,4155IntPtr dst,4156ref SDL_Rect dstrect4157);4158
4159/* surface refers to an SDL_Surface* */4160[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4161public static extern void SDL_UnlockSurface(IntPtr surface);4162
4163/* src and dst refer to an SDL_Surface* */4164[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4165public static extern int SDL_UpperBlit(4166IntPtr src,4167ref SDL_Rect srcrect,4168IntPtr dst,4169ref SDL_Rect dstrect4170);4171
4172/* src and dst refer to an SDL_Surface* */4173[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4174public static extern int SDL_UpperBlitScaled(4175IntPtr src,4176ref SDL_Rect srcrect,4177IntPtr dst,4178ref SDL_Rect dstrect4179);4180
4181/* surface and IntPtr refer to an SDL_Surface* */4182[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4183public static extern IntPtr SDL_DuplicateSurface(IntPtr surface);4184
4185#endregion4186
4187#region SDL_clipboard.h4188
4189[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4190public static extern SDL_bool SDL_HasClipboardText();4191
4192[DllImport(nativeLibName, EntryPoint = "SDL_GetClipboardText", CallingConvention = CallingConvention.Cdecl)]4193private static extern IntPtr INTERNAL_SDL_GetClipboardText();4194public static string SDL_GetClipboardText()4195{4196return UTF8_ToManaged(INTERNAL_SDL_GetClipboardText(), true);4197}4198
4199[DllImport(nativeLibName, EntryPoint = "SDL_SetClipboardText", CallingConvention = CallingConvention.Cdecl)]4200private static extern int INTERNAL_SDL_SetClipboardText(4201byte[] text4202);4203public static int SDL_SetClipboardText(4204string text4205)4206{4207return INTERNAL_SDL_SetClipboardText(4208UTF8_ToNative(text)4209);4210}4211
4212#endregion4213
4214#region SDL_events.h4215
4216/* General keyboard/mouse state definitions. */4217public const byte SDL_PRESSED = 1;4218public const byte SDL_RELEASED = 0;4219
4220/* Default size is according to SDL2 default. */4221public const int SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32;4222public const int SDL_TEXTINPUTEVENT_TEXT_SIZE = 32;4223
4224/* The types of events that can be delivered. */4225public enum SDL_EventType : uint4226{4227SDL_FIRSTEVENT = 0,4228
4229/* Application events */4230SDL_QUIT = 0x100,4231
4232/* iOS/Android/WinRT app events */4233SDL_APP_TERMINATING,4234SDL_APP_LOWMEMORY,4235SDL_APP_WILLENTERBACKGROUND,4236SDL_APP_DIDENTERBACKGROUND,4237SDL_APP_WILLENTERFOREGROUND,4238SDL_APP_DIDENTERFOREGROUND,4239
4240/* Display events */4241/* Only available in SDL 2.0.9 or higher. */4242SDL_DISPLAYEVENT = 0x150,4243
4244/* Window events */4245SDL_WINDOWEVENT = 0x200,4246SDL_SYSWMEVENT,4247
4248/* Keyboard events */4249SDL_KEYDOWN = 0x300,4250SDL_KEYUP,4251SDL_TEXTEDITING,4252SDL_TEXTINPUT,4253SDL_KEYMAPCHANGED,4254
4255/* Mouse events */4256SDL_MOUSEMOTION = 0x400,4257SDL_MOUSEBUTTONDOWN,4258SDL_MOUSEBUTTONUP,4259SDL_MOUSEWHEEL,4260
4261/* Joystick events */4262SDL_JOYAXISMOTION = 0x600,4263SDL_JOYBALLMOTION,4264SDL_JOYHATMOTION,4265SDL_JOYBUTTONDOWN,4266SDL_JOYBUTTONUP,4267SDL_JOYDEVICEADDED,4268SDL_JOYDEVICEREMOVED,4269SDL_JOYBATTERYUPDATED, // 15434270
4271/* Game controller events */4272SDL_CONTROLLERAXISMOTION = 0x650,4273SDL_CONTROLLERBUTTONDOWN,4274SDL_CONTROLLERBUTTONUP,4275SDL_CONTROLLERDEVICEADDED,4276SDL_CONTROLLERDEVICEREMOVED,4277SDL_CONTROLLERDEVICEREMAPPED,4278
4279/* Touch events */4280SDL_FINGERDOWN = 0x700,4281SDL_FINGERUP,4282SDL_FINGERMOTION,4283
4284/* Gesture events */4285SDL_DOLLARGESTURE = 0x800,4286SDL_DOLLARRECORD,4287SDL_MULTIGESTURE,4288
4289/* Clipboard events */4290SDL_CLIPBOARDUPDATE = 0x900,4291
4292/* Drag and drop events */4293SDL_DROPFILE = 0x1000,4294/* Only available in 2.0.4 or higher. */4295SDL_DROPTEXT,4296SDL_DROPBEGIN,4297SDL_DROPCOMPLETE,4298
4299/* Audio hotplug events */4300/* Only available in SDL 2.0.4 or higher. */4301SDL_AUDIODEVICEADDED = 0x1100,4302SDL_AUDIODEVICEREMOVED,4303
4304/* Sensor events */4305/* Only available in SDL 2.0.9 or higher. */4306SDL_SENSORUPDATE = 0x1200,4307
4308/* Render events */4309/* Only available in SDL 2.0.2 or higher. */4310SDL_RENDER_TARGETS_RESET = 0x2000,4311/* Only available in SDL 2.0.4 or higher. */4312SDL_RENDER_DEVICE_RESET,4313
4314/* Events SDL_USEREVENT through SDL_LASTEVENT are for4315* your use, and should be allocated with
4316* SDL_RegisterEvents()
4317*/
4318SDL_USEREVENT = 0x8000,4319
4320/* The last event, used for bouding arrays. */4321SDL_LASTEVENT = 0xFFFF4322}4323
4324/* Only available in 2.0.4 or higher. */4325public enum SDL_MouseWheelDirection : uint4326{4327SDL_MOUSEWHEEL_NORMAL,4328SDL_MOUSEWHEEL_FLIPPED
4329}4330
4331/* Fields shared by every event */4332[StructLayout(LayoutKind.Sequential)]4333public struct SDL_GenericEvent4334{4335public SDL_EventType type;4336public UInt32 timestamp;4337}4338
4339// Ignore private members used for padding in this struct4340#pragma warning disable 01694341[StructLayout(LayoutKind.Sequential)]4342public struct SDL_DisplayEvent4343{4344public SDL_EventType type;4345public UInt32 timestamp;4346public UInt32 display;4347public SDL_DisplayEventID displayEvent; // event, lolC#4348private byte padding1;4349private byte padding2;4350private byte padding3;4351public Int32 data1;4352}4353#pragma warning restore 01694354
4355// Ignore private members used for padding in this struct4356#pragma warning disable 01694357/* Window state change event data (event.window.*) */4358[StructLayout(LayoutKind.Sequential)]4359public struct SDL_WindowEvent4360{4361public SDL_EventType type;4362public UInt32 timestamp;4363public UInt32 windowID;4364public SDL_WindowEventID windowEvent; // event, lolC#4365private byte padding1;4366private byte padding2;4367private byte padding3;4368public Int32 data1;4369public Int32 data2;4370}4371#pragma warning restore 01694372
4373// Ignore private members used for padding in this struct4374#pragma warning disable 01694375/* Keyboard button event structure (event.key.*) */4376[StructLayout(LayoutKind.Sequential)]4377public struct SDL_KeyboardEvent4378{4379public SDL_EventType type;4380public UInt32 timestamp;4381public UInt32 windowID;4382public byte state;4383public byte repeat; /* non-zero if this is a repeat */4384private byte padding2;4385private byte padding3;4386public SDL_Keysym keysym;4387}4388#pragma warning restore 01694389
4390[StructLayout(LayoutKind.Sequential)]4391public struct SDL_TextEditingEvent4392{4393public SDL_EventType type;4394public UInt32 timestamp;4395public UInt32 windowID;4396[MarshalAs(UnmanagedType.ByValArray, SizeConst = SDL_TEXTEDITINGEVENT_TEXT_SIZE, ArraySubType = UnmanagedType.I1)]4397public byte[] text;4398public Int32 start;4399public Int32 length;4400}4401
4402[StructLayout(LayoutKind.Sequential)]4403public struct SDL_TextInputEvent4404{4405public SDL_EventType type;4406public UInt32 timestamp;4407public UInt32 windowID;4408[MarshalAs(UnmanagedType.ByValArray, SizeConst = SDL_TEXTINPUTEVENT_TEXT_SIZE, ArraySubType = UnmanagedType.I1)]4409public byte[] text;4410}4411
4412// Ignore private members used for padding in this struct4413#pragma warning disable 01694414/* Mouse motion event structure (event.motion.*) */4415[StructLayout(LayoutKind.Sequential)]4416public struct SDL_MouseMotionEvent4417{4418public SDL_EventType type;4419public UInt32 timestamp;4420public UInt32 windowID;4421public UInt32 which;4422public byte state; /* bitmask of buttons */4423private byte padding1;4424private byte padding2;4425private byte padding3;4426public Int32 x;4427public Int32 y;4428public Int32 xrel;4429public Int32 yrel;4430}4431#pragma warning restore 01694432
4433// Ignore private members used for padding in this struct4434#pragma warning disable 01694435/* Mouse button event structure (event.button.*) */4436[StructLayout(LayoutKind.Sequential)]4437public struct SDL_MouseButtonEvent4438{4439public SDL_EventType type;4440public UInt32 timestamp;4441public UInt32 windowID;4442public UInt32 which;4443public byte button; /* button id */4444public byte state; /* SDL_PRESSED or SDL_RELEASED */4445public byte clicks; /* 1 for single-click, 2 for double-click, etc. */4446private byte padding1;4447public Int32 x;4448public Int32 y;4449}4450#pragma warning restore 01694451
4452/* Mouse wheel event structure (event.wheel.*) */4453[StructLayout(LayoutKind.Sequential)]4454public struct SDL_MouseWheelEvent4455{4456public SDL_EventType type;4457public UInt32 timestamp;4458public UInt32 windowID;4459public UInt32 which;4460public Int32 x; /* amount scrolled horizontally */4461public Int32 y; /* amount scrolled vertically */4462public UInt32 direction; /* Set to one of the SDL_MOUSEWHEEL_* defines */4463}4464
4465// Ignore private members used for padding in this struct4466#pragma warning disable 01694467/* Joystick axis motion event structure (event.jaxis.*) */4468[StructLayout(LayoutKind.Sequential)]4469public struct SDL_JoyAxisEvent4470{4471public SDL_EventType type;4472public UInt32 timestamp;4473public Int32 which; /* SDL_JoystickID */4474public byte axis;4475private byte padding1;4476private byte padding2;4477private byte padding3;4478public Int16 axisValue; /* value, lolC# */4479public UInt16 padding4;4480}4481#pragma warning restore 01694482
4483// Ignore private members used for padding in this struct4484#pragma warning disable 01694485/* Joystick trackball motion event structure (event.jball.*) */4486[StructLayout(LayoutKind.Sequential)]4487public struct SDL_JoyBallEvent4488{4489public SDL_EventType type;4490public UInt32 timestamp;4491public Int32 which; /* SDL_JoystickID */4492public byte ball;4493private byte padding1;4494private byte padding2;4495private byte padding3;4496public Int16 xrel;4497public Int16 yrel;4498}4499#pragma warning restore 01694500
4501// Ignore private members used for padding in this struct4502#pragma warning disable 01694503/* Joystick hat position change event struct (event.jhat.*) */4504[StructLayout(LayoutKind.Sequential)]4505public struct SDL_JoyHatEvent4506{4507public SDL_EventType type;4508public UInt32 timestamp;4509public Int32 which; /* SDL_JoystickID */4510public byte hat; /* index of the hat */4511public byte hatValue; /* value, lolC# */4512private byte padding1;4513private byte padding2;4514}4515#pragma warning restore 01694516
4517// Ignore private members used for padding in this struct4518#pragma warning disable 01694519/* Joystick button event structure (event.jbutton.*) */4520[StructLayout(LayoutKind.Sequential)]4521public struct SDL_JoyButtonEvent4522{4523public SDL_EventType type;4524public UInt32 timestamp;4525public Int32 which; /* SDL_JoystickID */4526public byte button;4527public byte state; /* SDL_PRESSED or SDL_RELEASED */4528private byte padding1;4529private byte padding2;4530}4531#pragma warning restore 01694532
4533/* Joystick device event structure (event.jdevice.*) */4534[StructLayout(LayoutKind.Sequential)]4535public struct SDL_JoyDeviceEvent4536{4537public SDL_EventType type;4538public UInt32 timestamp;4539public Int32 which; /* SDL_JoystickID */4540}4541
4542// Ignore private members used for padding in this struct4543#pragma warning disable 01694544/* Game controller axis motion event (event.caxis.*) */4545[StructLayout(LayoutKind.Sequential)]4546public struct SDL_ControllerAxisEvent4547{4548public SDL_EventType type;4549public UInt32 timestamp;4550public Int32 which; /* SDL_JoystickID */4551public byte axis;4552private byte padding1;4553private byte padding2;4554private byte padding3;4555public Int16 axisValue; /* value, lolC# */4556private UInt16 padding4;4557}4558#pragma warning restore 01694559
4560// Ignore private members used for padding in this struct4561#pragma warning disable 01694562/* Game controller button event (event.cbutton.*) */4563[StructLayout(LayoutKind.Sequential)]4564public struct SDL_ControllerButtonEvent4565{4566public SDL_EventType type;4567public UInt32 timestamp;4568public Int32 which; /* SDL_JoystickID */4569public byte button;4570public byte state;4571private byte padding1;4572private byte padding2;4573}4574#pragma warning restore 01694575
4576/* Game controller device event (event.cdevice.*) */4577[StructLayout(LayoutKind.Sequential)]4578public struct SDL_ControllerDeviceEvent4579{4580public SDL_EventType type;4581public UInt32 timestamp;4582public Int32 which; /* joystick id for ADDED,4583* else instance id
4584*/
4585}4586
4587// Ignore private members used for padding in this struct4588#pragma warning disable 01694589/* Audio device event (event.adevice.*) */4590[StructLayout(LayoutKind.Sequential)]4591public struct SDL_AudioDeviceEvent4592{4593public UInt32 type;4594public UInt32 timestamp;4595public UInt32 which;4596public byte iscapture;4597private byte padding1;4598private byte padding2;4599private byte padding3;4600}4601#pragma warning restore 01694602
4603[StructLayout(LayoutKind.Sequential)]4604public struct SDL_TouchFingerEvent4605{4606public UInt32 type;4607public UInt32 timestamp;4608public Int64 touchId; // SDL_TouchID4609public Int64 fingerId; // SDL_GestureID4610public float x;4611public float y;4612public float dx;4613public float dy;4614public float pressure;4615public uint windowID;4616}4617
4618[StructLayout(LayoutKind.Sequential)]4619public struct SDL_MultiGestureEvent4620{4621public UInt32 type;4622public UInt32 timestamp;4623public Int64 touchId; // SDL_TouchID4624public float dTheta;4625public float dDist;4626public float x;4627public float y;4628public UInt16 numFingers;4629public UInt16 padding;4630}4631
4632[StructLayout(LayoutKind.Sequential)]4633public struct SDL_DollarGestureEvent4634{4635public UInt32 type;4636public UInt32 timestamp;4637public Int64 touchId; // SDL_TouchID4638public Int64 gestureId; // SDL_GestureID4639public UInt32 numFingers;4640public float error;4641public float x;4642public float y;4643}4644
4645/* File open request by system (event.drop.*), enabled by4646* default
4647*/
4648[StructLayout(LayoutKind.Sequential)]4649public struct SDL_DropEvent4650{4651public SDL_EventType type;4652public UInt32 timestamp;4653
4654/* char* filename, to be freed.4655* Access the variable EXACTLY ONCE like this:
4656* string s = SDL.UTF8_ToManaged(evt.drop.file, true);
4657*/
4658public IntPtr file;4659public UInt32 windowID;4660}4661
4662[StructLayout(LayoutKind.Sequential)]4663public struct SDL_SensorEvent4664{4665public SDL_EventType type;4666public UInt32 timestamp;4667public Int32 which;4668[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]4669public float data;4670}4671
4672/* The "quit requested" event */4673[StructLayout(LayoutKind.Sequential)]4674public struct SDL_QuitEvent4675{4676public SDL_EventType type;4677public UInt32 timestamp;4678}4679
4680/* A user defined event (event.user.*) */4681[StructLayout(LayoutKind.Sequential)]4682public struct SDL_UserEvent4683{4684public UInt32 type;4685public UInt32 timestamp;4686public UInt32 windowID;4687public Int32 code;4688public IntPtr data1; /* user-defined */4689public IntPtr data2; /* user-defined */4690}4691
4692/* A video driver dependent event (event.syswm.*), disabled */4693[StructLayout(LayoutKind.Sequential)]4694public struct SDL_SysWMEvent4695{4696public SDL_EventType type;4697public UInt32 timestamp;4698public IntPtr msg; /* SDL_SysWMmsg*, system-dependent*/4699}4700
4701/* General event structure */4702// C# doesn't do unions, so we do this ugly thing. */4703[StructLayout(LayoutKind.Explicit, Size = 56)]4704public struct SDL_Event4705{4706[FieldOffset(0)]4707public SDL_EventType type;4708[FieldOffset(0)]4709public SDL_DisplayEvent display;4710[FieldOffset(0)]4711public SDL_WindowEvent window;4712[FieldOffset(0)]4713public SDL_KeyboardEvent key;4714// [FieldOffset(0)]4715// public SDL_TextEditingEvent edit;4716// [FieldOffset(0)]4717// public SDL_TextInputEvent text;4718[FieldOffset(0)]4719public SDL_MouseMotionEvent motion;4720[FieldOffset(0)]4721public SDL_MouseButtonEvent button;4722[FieldOffset(0)]4723public SDL_MouseWheelEvent wheel;4724[FieldOffset(0)]4725public SDL_JoyAxisEvent jaxis;4726[FieldOffset(0)]4727public SDL_JoyBallEvent jball;4728[FieldOffset(0)]4729public SDL_JoyHatEvent jhat;4730[FieldOffset(0)]4731public SDL_JoyButtonEvent jbutton;4732[FieldOffset(0)]4733public SDL_JoyDeviceEvent jdevice;4734[FieldOffset(0)]4735public SDL_ControllerAxisEvent caxis;4736[FieldOffset(0)]4737public SDL_ControllerButtonEvent cbutton;4738[FieldOffset(0)]4739public SDL_ControllerDeviceEvent cdevice;4740[FieldOffset(0)]4741public SDL_AudioDeviceEvent adevice;4742// [FieldOffset(0)]4743// public SDL_SensorEvent sensor;4744[FieldOffset(0)]4745public SDL_QuitEvent quit;4746[FieldOffset(0)]4747public SDL_UserEvent user;4748[FieldOffset(0)]4749public SDL_SysWMEvent syswm;4750[FieldOffset(0)]4751public SDL_TouchFingerEvent tfinger;4752[FieldOffset(0)]4753public SDL_MultiGestureEvent mgesture;4754[FieldOffset(0)]4755public SDL_DollarGestureEvent dgesture;4756[FieldOffset(0)]4757public SDL_DropEvent drop;4758}4759
4760[UnmanagedFunctionPointer(CallingConvention.Cdecl)]4761public delegate int SDL_EventFilter(4762IntPtr userdata, // void*4763IntPtr sdlevent // SDL_Event* event, lolC#4764);4765
4766/* Pump the event loop, getting events from the input devices*/4767[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4768public static extern void SDL_PumpEvents();4769
4770public enum SDL_eventaction4771{4772SDL_ADDEVENT,4773SDL_PEEKEVENT,4774SDL_GETEVENT
4775}4776
4777[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4778public static extern int SDL_PeepEvents(4779[Out] SDL_Event[] events,4780int numevents,4781SDL_eventaction action,4782SDL_EventType minType,4783SDL_EventType maxType4784);4785
4786/* Checks to see if certain events are in the event queue */4787[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4788public static extern SDL_bool SDL_HasEvent(SDL_EventType type);4789
4790[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4791public static extern SDL_bool SDL_HasEvents(4792SDL_EventType minType,4793SDL_EventType maxType4794);4795
4796/* Clears events from the event queue */4797[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4798public static extern void SDL_FlushEvent(SDL_EventType type);4799
4800[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4801public static extern void SDL_FlushEvents(4802SDL_EventType min,4803SDL_EventType max4804);4805
4806/* Polls for currently pending events */4807[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4808public static extern int SDL_PollEvent(out SDL_Event _event);4809
4810/* Waits indefinitely for the next event */4811[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4812public static extern int SDL_WaitEvent(out SDL_Event _event);4813
4814/* Waits until the specified timeout (in ms) for the next event4815*/
4816[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4817public static extern int SDL_WaitEventTimeout(out SDL_Event _event, int timeout);4818
4819/* Add an event to the event queue */4820[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4821public static extern int SDL_PushEvent(ref SDL_Event _event);4822
4823/* userdata refers to a void* */4824[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4825public static extern void SDL_SetEventFilter(4826SDL_EventFilter filter,4827IntPtr userdata4828);4829
4830/* userdata refers to a void* */4831[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4832private static extern SDL_bool SDL_GetEventFilter(4833out IntPtr filter,4834out IntPtr userdata4835);4836public static SDL_bool SDL_GetEventFilter(4837out SDL_EventFilter filter,4838out IntPtr userdata4839)4840{4841IntPtr result = IntPtr.Zero;4842SDL_bool retval = SDL_GetEventFilter(out result, out userdata);4843if (result != IntPtr.Zero)4844{4845filter = (SDL_EventFilter)Marshal.GetDelegateForFunctionPointer(4846result,4847typeof(SDL_EventFilter)4848);4849}4850else4851{4852filter = null;4853}4854return retval;4855}4856
4857/* userdata refers to a void* */4858[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4859public static extern void SDL_AddEventWatch(4860SDL_EventFilter filter,4861IntPtr userdata4862);4863
4864/* userdata refers to a void* */4865[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4866public static extern void SDL_DelEventWatch(4867SDL_EventFilter filter,4868IntPtr userdata4869);4870
4871/* userdata refers to a void* */4872[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4873public static extern void SDL_FilterEvents(4874SDL_EventFilter filter,4875IntPtr userdata4876);4877
4878/* These are for SDL_EventState() */4879public const int SDL_QUERY = -1;4880public const int SDL_IGNORE = 0;4881public const int SDL_DISABLE = 0;4882public const int SDL_ENABLE = 1;4883
4884/* This function allows you to enable/disable certain events */4885[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4886public static extern byte SDL_EventState(SDL_EventType type, int state);4887
4888/* Get the state of an event */4889public static byte SDL_GetEventState(SDL_EventType type)4890{4891return SDL_EventState(type, SDL_QUERY);4892}4893
4894/* Allocate a set of user-defined events */4895[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]4896public static extern UInt32 SDL_RegisterEvents(int numevents);4897#endregion4898
4899#region SDL_scancode.h4900
4901/* Scancodes based off USB keyboard page (0x07) */4902public enum SDL_Scancode4903{4904SDL_SCANCODE_UNKNOWN = 0,4905
4906SDL_SCANCODE_A = 4,4907SDL_SCANCODE_B = 5,4908SDL_SCANCODE_C = 6,4909SDL_SCANCODE_D = 7,4910SDL_SCANCODE_E = 8,4911SDL_SCANCODE_F = 9,4912SDL_SCANCODE_G = 10,4913SDL_SCANCODE_H = 11,4914SDL_SCANCODE_I = 12,4915SDL_SCANCODE_J = 13,4916SDL_SCANCODE_K = 14,4917SDL_SCANCODE_L = 15,4918SDL_SCANCODE_M = 16,4919SDL_SCANCODE_N = 17,4920SDL_SCANCODE_O = 18,4921SDL_SCANCODE_P = 19,4922SDL_SCANCODE_Q = 20,4923SDL_SCANCODE_R = 21,4924SDL_SCANCODE_S = 22,4925SDL_SCANCODE_T = 23,4926SDL_SCANCODE_U = 24,4927SDL_SCANCODE_V = 25,4928SDL_SCANCODE_W = 26,4929SDL_SCANCODE_X = 27,4930SDL_SCANCODE_Y = 28,4931SDL_SCANCODE_Z = 29,4932
4933SDL_SCANCODE_1 = 30,4934SDL_SCANCODE_2 = 31,4935SDL_SCANCODE_3 = 32,4936SDL_SCANCODE_4 = 33,4937SDL_SCANCODE_5 = 34,4938SDL_SCANCODE_6 = 35,4939SDL_SCANCODE_7 = 36,4940SDL_SCANCODE_8 = 37,4941SDL_SCANCODE_9 = 38,4942SDL_SCANCODE_0 = 39,4943
4944SDL_SCANCODE_RETURN = 40,4945SDL_SCANCODE_ESCAPE = 41,4946SDL_SCANCODE_BACKSPACE = 42,4947SDL_SCANCODE_TAB = 43,4948SDL_SCANCODE_SPACE = 44,4949
4950SDL_SCANCODE_MINUS = 45,4951SDL_SCANCODE_EQUALS = 46,4952SDL_SCANCODE_LEFTBRACKET = 47,4953SDL_SCANCODE_RIGHTBRACKET = 48,4954SDL_SCANCODE_BACKSLASH = 49,4955SDL_SCANCODE_NONUSHASH = 50,4956SDL_SCANCODE_SEMICOLON = 51,4957SDL_SCANCODE_APOSTROPHE = 52,4958SDL_SCANCODE_GRAVE = 53,4959SDL_SCANCODE_COMMA = 54,4960SDL_SCANCODE_PERIOD = 55,4961SDL_SCANCODE_SLASH = 56,4962
4963SDL_SCANCODE_CAPSLOCK = 57,4964
4965SDL_SCANCODE_F1 = 58,4966SDL_SCANCODE_F2 = 59,4967SDL_SCANCODE_F3 = 60,4968SDL_SCANCODE_F4 = 61,4969SDL_SCANCODE_F5 = 62,4970SDL_SCANCODE_F6 = 63,4971SDL_SCANCODE_F7 = 64,4972SDL_SCANCODE_F8 = 65,4973SDL_SCANCODE_F9 = 66,4974SDL_SCANCODE_F10 = 67,4975SDL_SCANCODE_F11 = 68,4976SDL_SCANCODE_F12 = 69,4977
4978SDL_SCANCODE_PRINTSCREEN = 70,4979SDL_SCANCODE_SCROLLLOCK = 71,4980SDL_SCANCODE_PAUSE = 72,4981SDL_SCANCODE_INSERT = 73,4982SDL_SCANCODE_HOME = 74,4983SDL_SCANCODE_PAGEUP = 75,4984SDL_SCANCODE_DELETE = 76,4985SDL_SCANCODE_END = 77,4986SDL_SCANCODE_PAGEDOWN = 78,4987SDL_SCANCODE_RIGHT = 79,4988SDL_SCANCODE_LEFT = 80,4989SDL_SCANCODE_DOWN = 81,4990SDL_SCANCODE_UP = 82,4991
4992SDL_SCANCODE_NUMLOCKCLEAR = 83,4993SDL_SCANCODE_KP_DIVIDE = 84,4994SDL_SCANCODE_KP_MULTIPLY = 85,4995SDL_SCANCODE_KP_MINUS = 86,4996SDL_SCANCODE_KP_PLUS = 87,4997SDL_SCANCODE_KP_ENTER = 88,4998SDL_SCANCODE_KP_1 = 89,4999SDL_SCANCODE_KP_2 = 90,5000SDL_SCANCODE_KP_3 = 91,5001SDL_SCANCODE_KP_4 = 92,5002SDL_SCANCODE_KP_5 = 93,5003SDL_SCANCODE_KP_6 = 94,5004SDL_SCANCODE_KP_7 = 95,5005SDL_SCANCODE_KP_8 = 96,5006SDL_SCANCODE_KP_9 = 97,5007SDL_SCANCODE_KP_0 = 98,5008SDL_SCANCODE_KP_PERIOD = 99,5009
5010SDL_SCANCODE_NONUSBACKSLASH = 100,5011SDL_SCANCODE_APPLICATION = 101,5012SDL_SCANCODE_POWER = 102,5013SDL_SCANCODE_KP_EQUALS = 103,5014SDL_SCANCODE_F13 = 104,5015SDL_SCANCODE_F14 = 105,5016SDL_SCANCODE_F15 = 106,5017SDL_SCANCODE_F16 = 107,5018SDL_SCANCODE_F17 = 108,5019SDL_SCANCODE_F18 = 109,5020SDL_SCANCODE_F19 = 110,5021SDL_SCANCODE_F20 = 111,5022SDL_SCANCODE_F21 = 112,5023SDL_SCANCODE_F22 = 113,5024SDL_SCANCODE_F23 = 114,5025SDL_SCANCODE_F24 = 115,5026SDL_SCANCODE_EXECUTE = 116,5027SDL_SCANCODE_HELP = 117,5028SDL_SCANCODE_MENU = 118,5029SDL_SCANCODE_SELECT = 119,5030SDL_SCANCODE_STOP = 120,5031SDL_SCANCODE_AGAIN = 121,5032SDL_SCANCODE_UNDO = 122,5033SDL_SCANCODE_CUT = 123,5034SDL_SCANCODE_COPY = 124,5035SDL_SCANCODE_PASTE = 125,5036SDL_SCANCODE_FIND = 126,5037SDL_SCANCODE_MUTE = 127,5038SDL_SCANCODE_VOLUMEUP = 128,5039SDL_SCANCODE_VOLUMEDOWN = 129,5040/* not sure whether there's a reason to enable these */5041/* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */5042/* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */5043/* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */5044SDL_SCANCODE_KP_COMMA = 133,5045SDL_SCANCODE_KP_EQUALSAS400 = 134,5046
5047SDL_SCANCODE_INTERNATIONAL1 = 135,5048SDL_SCANCODE_INTERNATIONAL2 = 136,5049SDL_SCANCODE_INTERNATIONAL3 = 137,5050SDL_SCANCODE_INTERNATIONAL4 = 138,5051SDL_SCANCODE_INTERNATIONAL5 = 139,5052SDL_SCANCODE_INTERNATIONAL6 = 140,5053SDL_SCANCODE_INTERNATIONAL7 = 141,5054SDL_SCANCODE_INTERNATIONAL8 = 142,5055SDL_SCANCODE_INTERNATIONAL9 = 143,5056SDL_SCANCODE_LANG1 = 144,5057SDL_SCANCODE_LANG2 = 145,5058SDL_SCANCODE_LANG3 = 146,5059SDL_SCANCODE_LANG4 = 147,5060SDL_SCANCODE_LANG5 = 148,5061SDL_SCANCODE_LANG6 = 149,5062SDL_SCANCODE_LANG7 = 150,5063SDL_SCANCODE_LANG8 = 151,5064SDL_SCANCODE_LANG9 = 152,5065
5066SDL_SCANCODE_ALTERASE = 153,5067SDL_SCANCODE_SYSREQ = 154,5068SDL_SCANCODE_CANCEL = 155,5069SDL_SCANCODE_CLEAR = 156,5070SDL_SCANCODE_PRIOR = 157,5071SDL_SCANCODE_RETURN2 = 158,5072SDL_SCANCODE_SEPARATOR = 159,5073SDL_SCANCODE_OUT = 160,5074SDL_SCANCODE_OPER = 161,5075SDL_SCANCODE_CLEARAGAIN = 162,5076SDL_SCANCODE_CRSEL = 163,5077SDL_SCANCODE_EXSEL = 164,5078
5079SDL_SCANCODE_KP_00 = 176,5080SDL_SCANCODE_KP_000 = 177,5081SDL_SCANCODE_THOUSANDSSEPARATOR = 178,5082SDL_SCANCODE_DECIMALSEPARATOR = 179,5083SDL_SCANCODE_CURRENCYUNIT = 180,5084SDL_SCANCODE_CURRENCYSUBUNIT = 181,5085SDL_SCANCODE_KP_LEFTPAREN = 182,5086SDL_SCANCODE_KP_RIGHTPAREN = 183,5087SDL_SCANCODE_KP_LEFTBRACE = 184,5088SDL_SCANCODE_KP_RIGHTBRACE = 185,5089SDL_SCANCODE_KP_TAB = 186,5090SDL_SCANCODE_KP_BACKSPACE = 187,5091SDL_SCANCODE_KP_A = 188,5092SDL_SCANCODE_KP_B = 189,5093SDL_SCANCODE_KP_C = 190,5094SDL_SCANCODE_KP_D = 191,5095SDL_SCANCODE_KP_E = 192,5096SDL_SCANCODE_KP_F = 193,5097SDL_SCANCODE_KP_XOR = 194,5098SDL_SCANCODE_KP_POWER = 195,5099SDL_SCANCODE_KP_PERCENT = 196,5100SDL_SCANCODE_KP_LESS = 197,5101SDL_SCANCODE_KP_GREATER = 198,5102SDL_SCANCODE_KP_AMPERSAND = 199,5103SDL_SCANCODE_KP_DBLAMPERSAND = 200,5104SDL_SCANCODE_KP_VERTICALBAR = 201,5105SDL_SCANCODE_KP_DBLVERTICALBAR = 202,5106SDL_SCANCODE_KP_COLON = 203,5107SDL_SCANCODE_KP_HASH = 204,5108SDL_SCANCODE_KP_SPACE = 205,5109SDL_SCANCODE_KP_AT = 206,5110SDL_SCANCODE_KP_EXCLAM = 207,5111SDL_SCANCODE_KP_MEMSTORE = 208,5112SDL_SCANCODE_KP_MEMRECALL = 209,5113SDL_SCANCODE_KP_MEMCLEAR = 210,5114SDL_SCANCODE_KP_MEMADD = 211,5115SDL_SCANCODE_KP_MEMSUBTRACT = 212,5116SDL_SCANCODE_KP_MEMMULTIPLY = 213,5117SDL_SCANCODE_KP_MEMDIVIDE = 214,5118SDL_SCANCODE_KP_PLUSMINUS = 215,5119SDL_SCANCODE_KP_CLEAR = 216,5120SDL_SCANCODE_KP_CLEARENTRY = 217,5121SDL_SCANCODE_KP_BINARY = 218,5122SDL_SCANCODE_KP_OCTAL = 219,5123SDL_SCANCODE_KP_DECIMAL = 220,5124SDL_SCANCODE_KP_HEXADECIMAL = 221,5125
5126SDL_SCANCODE_LCTRL = 224,5127SDL_SCANCODE_LSHIFT = 225,5128SDL_SCANCODE_LALT = 226,5129SDL_SCANCODE_LGUI = 227,5130SDL_SCANCODE_RCTRL = 228,5131SDL_SCANCODE_RSHIFT = 229,5132SDL_SCANCODE_RALT = 230,5133SDL_SCANCODE_RGUI = 231,5134
5135SDL_SCANCODE_MODE = 257,5136
5137/* These come from the USB consumer page (0x0C) */5138SDL_SCANCODE_AUDIONEXT = 258,5139SDL_SCANCODE_AUDIOPREV = 259,5140SDL_SCANCODE_AUDIOSTOP = 260,5141SDL_SCANCODE_AUDIOPLAY = 261,5142SDL_SCANCODE_AUDIOMUTE = 262,5143SDL_SCANCODE_MEDIASELECT = 263,5144SDL_SCANCODE_WWW = 264,5145SDL_SCANCODE_MAIL = 265,5146SDL_SCANCODE_CALCULATOR = 266,5147SDL_SCANCODE_COMPUTER = 267,5148SDL_SCANCODE_AC_SEARCH = 268,5149SDL_SCANCODE_AC_HOME = 269,5150SDL_SCANCODE_AC_BACK = 270,5151SDL_SCANCODE_AC_FORWARD = 271,5152SDL_SCANCODE_AC_STOP = 272,5153SDL_SCANCODE_AC_REFRESH = 273,5154SDL_SCANCODE_AC_BOOKMARKS = 274,5155
5156/* These come from other sources, and are mostly mac related */5157SDL_SCANCODE_BRIGHTNESSDOWN = 275,5158SDL_SCANCODE_BRIGHTNESSUP = 276,5159SDL_SCANCODE_DISPLAYSWITCH = 277,5160SDL_SCANCODE_KBDILLUMTOGGLE = 278,5161SDL_SCANCODE_KBDILLUMDOWN = 279,5162SDL_SCANCODE_KBDILLUMUP = 280,5163SDL_SCANCODE_EJECT = 281,5164SDL_SCANCODE_SLEEP = 282,5165
5166SDL_SCANCODE_APP1 = 283,5167SDL_SCANCODE_APP2 = 284,5168
5169/* These come from the USB consumer page (0x0C) */5170SDL_SCANCODE_AUDIOREWIND = 285,5171SDL_SCANCODE_AUDIOFASTFORWARD = 286,5172
5173/* This is not a key, simply marks the number of scancodes5174* so that you know how big to make your arrays. */
5175SDL_NUM_SCANCODES = 5125176}5177
5178#endregion5179
5180#region SDL_keycode.h5181
5182public const int SDLK_SCANCODE_MASK = (1 << 30);5183public static SDL_Keycode SDL_SCANCODE_TO_KEYCODE(SDL_Scancode X)5184{5185return (SDL_Keycode)((int)X | SDLK_SCANCODE_MASK);5186}5187
5188public enum SDL_Keycode5189{5190SDLK_UNKNOWN = 0,5191
5192SDLK_RETURN = '\r',5193SDLK_ESCAPE = 27, // '\033'5194SDLK_BACKSPACE = '\b',5195SDLK_TAB = '\t',5196SDLK_SPACE = ' ',5197SDLK_EXCLAIM = '!',5198SDLK_QUOTEDBL = '"',5199SDLK_HASH = '#',5200SDLK_PERCENT = '%',5201SDLK_DOLLAR = '$',5202SDLK_AMPERSAND = '&',5203SDLK_QUOTE = '\'',5204SDLK_LEFTPAREN = '(',5205SDLK_RIGHTPAREN = ')',5206SDLK_ASTERISK = '*',5207SDLK_PLUS = '+',5208SDLK_COMMA = ',',5209SDLK_MINUS = '-',5210SDLK_PERIOD = '.',5211SDLK_SLASH = '/',5212SDLK_0 = '0',5213SDLK_1 = '1',5214SDLK_2 = '2',5215SDLK_3 = '3',5216SDLK_4 = '4',5217SDLK_5 = '5',5218SDLK_6 = '6',5219SDLK_7 = '7',5220SDLK_8 = '8',5221SDLK_9 = '9',5222SDLK_COLON = ':',5223SDLK_SEMICOLON = ';',5224SDLK_LESS = '<',5225SDLK_EQUALS = '=',5226SDLK_GREATER = '>',5227SDLK_QUESTION = '?',5228SDLK_AT = '@',5229/*5230Skip uppercase letters
5231*/
5232SDLK_LEFTBRACKET = '[',5233SDLK_BACKSLASH = '\\',5234SDLK_RIGHTBRACKET = ']',5235SDLK_CARET = '^',5236SDLK_UNDERSCORE = '_',5237SDLK_BACKQUOTE = '`',5238SDLK_a = 'a',5239SDLK_b = 'b',5240SDLK_c = 'c',5241SDLK_d = 'd',5242SDLK_e = 'e',5243SDLK_f = 'f',5244SDLK_g = 'g',5245SDLK_h = 'h',5246SDLK_i = 'i',5247SDLK_j = 'j',5248SDLK_k = 'k',5249SDLK_l = 'l',5250SDLK_m = 'm',5251SDLK_n = 'n',5252SDLK_o = 'o',5253SDLK_p = 'p',5254SDLK_q = 'q',5255SDLK_r = 'r',5256SDLK_s = 's',5257SDLK_t = 't',5258SDLK_u = 'u',5259SDLK_v = 'v',5260SDLK_w = 'w',5261SDLK_x = 'x',5262SDLK_y = 'y',5263SDLK_z = 'z',5264
5265SDLK_CAPSLOCK = (int)SDL_Scancode.SDL_SCANCODE_CAPSLOCK | SDLK_SCANCODE_MASK,5266
5267SDLK_F1 = (int)SDL_Scancode.SDL_SCANCODE_F1 | SDLK_SCANCODE_MASK,5268SDLK_F2 = (int)SDL_Scancode.SDL_SCANCODE_F2 | SDLK_SCANCODE_MASK,5269SDLK_F3 = (int)SDL_Scancode.SDL_SCANCODE_F3 | SDLK_SCANCODE_MASK,5270SDLK_F4 = (int)SDL_Scancode.SDL_SCANCODE_F4 | SDLK_SCANCODE_MASK,5271SDLK_F5 = (int)SDL_Scancode.SDL_SCANCODE_F5 | SDLK_SCANCODE_MASK,5272SDLK_F6 = (int)SDL_Scancode.SDL_SCANCODE_F6 | SDLK_SCANCODE_MASK,5273SDLK_F7 = (int)SDL_Scancode.SDL_SCANCODE_F7 | SDLK_SCANCODE_MASK,5274SDLK_F8 = (int)SDL_Scancode.SDL_SCANCODE_F8 | SDLK_SCANCODE_MASK,5275SDLK_F9 = (int)SDL_Scancode.SDL_SCANCODE_F9 | SDLK_SCANCODE_MASK,5276SDLK_F10 = (int)SDL_Scancode.SDL_SCANCODE_F10 | SDLK_SCANCODE_MASK,5277SDLK_F11 = (int)SDL_Scancode.SDL_SCANCODE_F11 | SDLK_SCANCODE_MASK,5278SDLK_F12 = (int)SDL_Scancode.SDL_SCANCODE_F12 | SDLK_SCANCODE_MASK,5279
5280SDLK_PRINTSCREEN = (int)SDL_Scancode.SDL_SCANCODE_PRINTSCREEN | SDLK_SCANCODE_MASK,5281SDLK_SCROLLLOCK = (int)SDL_Scancode.SDL_SCANCODE_SCROLLLOCK | SDLK_SCANCODE_MASK,5282SDLK_PAUSE = (int)SDL_Scancode.SDL_SCANCODE_PAUSE | SDLK_SCANCODE_MASK,5283SDLK_INSERT = (int)SDL_Scancode.SDL_SCANCODE_INSERT | SDLK_SCANCODE_MASK,5284SDLK_HOME = (int)SDL_Scancode.SDL_SCANCODE_HOME | SDLK_SCANCODE_MASK,5285SDLK_PAGEUP = (int)SDL_Scancode.SDL_SCANCODE_PAGEUP | SDLK_SCANCODE_MASK,5286SDLK_DELETE = 127,5287SDLK_END = (int)SDL_Scancode.SDL_SCANCODE_END | SDLK_SCANCODE_MASK,5288SDLK_PAGEDOWN = (int)SDL_Scancode.SDL_SCANCODE_PAGEDOWN | SDLK_SCANCODE_MASK,5289SDLK_RIGHT = (int)SDL_Scancode.SDL_SCANCODE_RIGHT | SDLK_SCANCODE_MASK,5290SDLK_LEFT = (int)SDL_Scancode.SDL_SCANCODE_LEFT | SDLK_SCANCODE_MASK,5291SDLK_DOWN = (int)SDL_Scancode.SDL_SCANCODE_DOWN | SDLK_SCANCODE_MASK,5292SDLK_UP = (int)SDL_Scancode.SDL_SCANCODE_UP | SDLK_SCANCODE_MASK,5293
5294SDLK_NUMLOCKCLEAR = (int)SDL_Scancode.SDL_SCANCODE_NUMLOCKCLEAR | SDLK_SCANCODE_MASK,5295SDLK_KP_DIVIDE = (int)SDL_Scancode.SDL_SCANCODE_KP_DIVIDE | SDLK_SCANCODE_MASK,5296SDLK_KP_MULTIPLY = (int)SDL_Scancode.SDL_SCANCODE_KP_MULTIPLY | SDLK_SCANCODE_MASK,5297SDLK_KP_MINUS = (int)SDL_Scancode.SDL_SCANCODE_KP_MINUS | SDLK_SCANCODE_MASK,5298SDLK_KP_PLUS = (int)SDL_Scancode.SDL_SCANCODE_KP_PLUS | SDLK_SCANCODE_MASK,5299SDLK_KP_ENTER = (int)SDL_Scancode.SDL_SCANCODE_KP_ENTER | SDLK_SCANCODE_MASK,5300SDLK_KP_1 = (int)SDL_Scancode.SDL_SCANCODE_KP_1 | SDLK_SCANCODE_MASK,5301SDLK_KP_2 = (int)SDL_Scancode.SDL_SCANCODE_KP_2 | SDLK_SCANCODE_MASK,5302SDLK_KP_3 = (int)SDL_Scancode.SDL_SCANCODE_KP_3 | SDLK_SCANCODE_MASK,5303SDLK_KP_4 = (int)SDL_Scancode.SDL_SCANCODE_KP_4 | SDLK_SCANCODE_MASK,5304SDLK_KP_5 = (int)SDL_Scancode.SDL_SCANCODE_KP_5 | SDLK_SCANCODE_MASK,5305SDLK_KP_6 = (int)SDL_Scancode.SDL_SCANCODE_KP_6 | SDLK_SCANCODE_MASK,5306SDLK_KP_7 = (int)SDL_Scancode.SDL_SCANCODE_KP_7 | SDLK_SCANCODE_MASK,5307SDLK_KP_8 = (int)SDL_Scancode.SDL_SCANCODE_KP_8 | SDLK_SCANCODE_MASK,5308SDLK_KP_9 = (int)SDL_Scancode.SDL_SCANCODE_KP_9 | SDLK_SCANCODE_MASK,5309SDLK_KP_0 = (int)SDL_Scancode.SDL_SCANCODE_KP_0 | SDLK_SCANCODE_MASK,5310SDLK_KP_PERIOD = (int)SDL_Scancode.SDL_SCANCODE_KP_PERIOD | SDLK_SCANCODE_MASK,5311
5312SDLK_APPLICATION = (int)SDL_Scancode.SDL_SCANCODE_APPLICATION | SDLK_SCANCODE_MASK,5313SDLK_POWER = (int)SDL_Scancode.SDL_SCANCODE_POWER | SDLK_SCANCODE_MASK,5314SDLK_KP_EQUALS = (int)SDL_Scancode.SDL_SCANCODE_KP_EQUALS | SDLK_SCANCODE_MASK,5315SDLK_F13 = (int)SDL_Scancode.SDL_SCANCODE_F13 | SDLK_SCANCODE_MASK,5316SDLK_F14 = (int)SDL_Scancode.SDL_SCANCODE_F14 | SDLK_SCANCODE_MASK,5317SDLK_F15 = (int)SDL_Scancode.SDL_SCANCODE_F15 | SDLK_SCANCODE_MASK,5318SDLK_F16 = (int)SDL_Scancode.SDL_SCANCODE_F16 | SDLK_SCANCODE_MASK,5319SDLK_F17 = (int)SDL_Scancode.SDL_SCANCODE_F17 | SDLK_SCANCODE_MASK,5320SDLK_F18 = (int)SDL_Scancode.SDL_SCANCODE_F18 | SDLK_SCANCODE_MASK,5321SDLK_F19 = (int)SDL_Scancode.SDL_SCANCODE_F19 | SDLK_SCANCODE_MASK,5322SDLK_F20 = (int)SDL_Scancode.SDL_SCANCODE_F20 | SDLK_SCANCODE_MASK,5323SDLK_F21 = (int)SDL_Scancode.SDL_SCANCODE_F21 | SDLK_SCANCODE_MASK,5324SDLK_F22 = (int)SDL_Scancode.SDL_SCANCODE_F22 | SDLK_SCANCODE_MASK,5325SDLK_F23 = (int)SDL_Scancode.SDL_SCANCODE_F23 | SDLK_SCANCODE_MASK,5326SDLK_F24 = (int)SDL_Scancode.SDL_SCANCODE_F24 | SDLK_SCANCODE_MASK,5327SDLK_EXECUTE = (int)SDL_Scancode.SDL_SCANCODE_EXECUTE | SDLK_SCANCODE_MASK,5328SDLK_HELP = (int)SDL_Scancode.SDL_SCANCODE_HELP | SDLK_SCANCODE_MASK,5329SDLK_MENU = (int)SDL_Scancode.SDL_SCANCODE_MENU | SDLK_SCANCODE_MASK,5330SDLK_SELECT = (int)SDL_Scancode.SDL_SCANCODE_SELECT | SDLK_SCANCODE_MASK,5331SDLK_STOP = (int)SDL_Scancode.SDL_SCANCODE_STOP | SDLK_SCANCODE_MASK,5332SDLK_AGAIN = (int)SDL_Scancode.SDL_SCANCODE_AGAIN | SDLK_SCANCODE_MASK,5333SDLK_UNDO = (int)SDL_Scancode.SDL_SCANCODE_UNDO | SDLK_SCANCODE_MASK,5334SDLK_CUT = (int)SDL_Scancode.SDL_SCANCODE_CUT | SDLK_SCANCODE_MASK,5335SDLK_COPY = (int)SDL_Scancode.SDL_SCANCODE_COPY | SDLK_SCANCODE_MASK,5336SDLK_PASTE = (int)SDL_Scancode.SDL_SCANCODE_PASTE | SDLK_SCANCODE_MASK,5337SDLK_FIND = (int)SDL_Scancode.SDL_SCANCODE_FIND | SDLK_SCANCODE_MASK,5338SDLK_MUTE = (int)SDL_Scancode.SDL_SCANCODE_MUTE | SDLK_SCANCODE_MASK,5339SDLK_VOLUMEUP = (int)SDL_Scancode.SDL_SCANCODE_VOLUMEUP | SDLK_SCANCODE_MASK,5340SDLK_VOLUMEDOWN = (int)SDL_Scancode.SDL_SCANCODE_VOLUMEDOWN | SDLK_SCANCODE_MASK,5341SDLK_KP_COMMA = (int)SDL_Scancode.SDL_SCANCODE_KP_COMMA | SDLK_SCANCODE_MASK,5342SDLK_KP_EQUALSAS400 =5343(int)SDL_Scancode.SDL_SCANCODE_KP_EQUALSAS400 | SDLK_SCANCODE_MASK,5344
5345SDLK_ALTERASE = (int)SDL_Scancode.SDL_SCANCODE_ALTERASE | SDLK_SCANCODE_MASK,5346SDLK_SYSREQ = (int)SDL_Scancode.SDL_SCANCODE_SYSREQ | SDLK_SCANCODE_MASK,5347SDLK_CANCEL = (int)SDL_Scancode.SDL_SCANCODE_CANCEL | SDLK_SCANCODE_MASK,5348SDLK_CLEAR = (int)SDL_Scancode.SDL_SCANCODE_CLEAR | SDLK_SCANCODE_MASK,5349SDLK_PRIOR = (int)SDL_Scancode.SDL_SCANCODE_PRIOR | SDLK_SCANCODE_MASK,5350SDLK_RETURN2 = (int)SDL_Scancode.SDL_SCANCODE_RETURN2 | SDLK_SCANCODE_MASK,5351SDLK_SEPARATOR = (int)SDL_Scancode.SDL_SCANCODE_SEPARATOR | SDLK_SCANCODE_MASK,5352SDLK_OUT = (int)SDL_Scancode.SDL_SCANCODE_OUT | SDLK_SCANCODE_MASK,5353SDLK_OPER = (int)SDL_Scancode.SDL_SCANCODE_OPER | SDLK_SCANCODE_MASK,5354SDLK_CLEARAGAIN = (int)SDL_Scancode.SDL_SCANCODE_CLEARAGAIN | SDLK_SCANCODE_MASK,5355SDLK_CRSEL = (int)SDL_Scancode.SDL_SCANCODE_CRSEL | SDLK_SCANCODE_MASK,5356SDLK_EXSEL = (int)SDL_Scancode.SDL_SCANCODE_EXSEL | SDLK_SCANCODE_MASK,5357
5358SDLK_KP_00 = (int)SDL_Scancode.SDL_SCANCODE_KP_00 | SDLK_SCANCODE_MASK,5359SDLK_KP_000 = (int)SDL_Scancode.SDL_SCANCODE_KP_000 | SDLK_SCANCODE_MASK,5360SDLK_THOUSANDSSEPARATOR =5361(int)SDL_Scancode.SDL_SCANCODE_THOUSANDSSEPARATOR | SDLK_SCANCODE_MASK,5362SDLK_DECIMALSEPARATOR =5363(int)SDL_Scancode.SDL_SCANCODE_DECIMALSEPARATOR | SDLK_SCANCODE_MASK,5364SDLK_CURRENCYUNIT = (int)SDL_Scancode.SDL_SCANCODE_CURRENCYUNIT | SDLK_SCANCODE_MASK,5365SDLK_CURRENCYSUBUNIT =5366(int)SDL_Scancode.SDL_SCANCODE_CURRENCYSUBUNIT | SDLK_SCANCODE_MASK,5367SDLK_KP_LEFTPAREN = (int)SDL_Scancode.SDL_SCANCODE_KP_LEFTPAREN | SDLK_SCANCODE_MASK,5368SDLK_KP_RIGHTPAREN = (int)SDL_Scancode.SDL_SCANCODE_KP_RIGHTPAREN | SDLK_SCANCODE_MASK,5369SDLK_KP_LEFTBRACE = (int)SDL_Scancode.SDL_SCANCODE_KP_LEFTBRACE | SDLK_SCANCODE_MASK,5370SDLK_KP_RIGHTBRACE = (int)SDL_Scancode.SDL_SCANCODE_KP_RIGHTBRACE | SDLK_SCANCODE_MASK,5371SDLK_KP_TAB = (int)SDL_Scancode.SDL_SCANCODE_KP_TAB | SDLK_SCANCODE_MASK,5372SDLK_KP_BACKSPACE = (int)SDL_Scancode.SDL_SCANCODE_KP_BACKSPACE | SDLK_SCANCODE_MASK,5373SDLK_KP_A = (int)SDL_Scancode.SDL_SCANCODE_KP_A | SDLK_SCANCODE_MASK,5374SDLK_KP_B = (int)SDL_Scancode.SDL_SCANCODE_KP_B | SDLK_SCANCODE_MASK,5375SDLK_KP_C = (int)SDL_Scancode.SDL_SCANCODE_KP_C | SDLK_SCANCODE_MASK,5376SDLK_KP_D = (int)SDL_Scancode.SDL_SCANCODE_KP_D | SDLK_SCANCODE_MASK,5377SDLK_KP_E = (int)SDL_Scancode.SDL_SCANCODE_KP_E | SDLK_SCANCODE_MASK,5378SDLK_KP_F = (int)SDL_Scancode.SDL_SCANCODE_KP_F | SDLK_SCANCODE_MASK,5379SDLK_KP_XOR = (int)SDL_Scancode.SDL_SCANCODE_KP_XOR | SDLK_SCANCODE_MASK,5380SDLK_KP_POWER = (int)SDL_Scancode.SDL_SCANCODE_KP_POWER | SDLK_SCANCODE_MASK,5381SDLK_KP_PERCENT = (int)SDL_Scancode.SDL_SCANCODE_KP_PERCENT | SDLK_SCANCODE_MASK,5382SDLK_KP_LESS = (int)SDL_Scancode.SDL_SCANCODE_KP_LESS | SDLK_SCANCODE_MASK,5383SDLK_KP_GREATER = (int)SDL_Scancode.SDL_SCANCODE_KP_GREATER | SDLK_SCANCODE_MASK,5384SDLK_KP_AMPERSAND = (int)SDL_Scancode.SDL_SCANCODE_KP_AMPERSAND | SDLK_SCANCODE_MASK,5385SDLK_KP_DBLAMPERSAND =5386(int)SDL_Scancode.SDL_SCANCODE_KP_DBLAMPERSAND | SDLK_SCANCODE_MASK,5387SDLK_KP_VERTICALBAR =5388(int)SDL_Scancode.SDL_SCANCODE_KP_VERTICALBAR | SDLK_SCANCODE_MASK,5389SDLK_KP_DBLVERTICALBAR =5390(int)SDL_Scancode.SDL_SCANCODE_KP_DBLVERTICALBAR | SDLK_SCANCODE_MASK,5391SDLK_KP_COLON = (int)SDL_Scancode.SDL_SCANCODE_KP_COLON | SDLK_SCANCODE_MASK,5392SDLK_KP_HASH = (int)SDL_Scancode.SDL_SCANCODE_KP_HASH | SDLK_SCANCODE_MASK,5393SDLK_KP_SPACE = (int)SDL_Scancode.SDL_SCANCODE_KP_SPACE | SDLK_SCANCODE_MASK,5394SDLK_KP_AT = (int)SDL_Scancode.SDL_SCANCODE_KP_AT | SDLK_SCANCODE_MASK,5395SDLK_KP_EXCLAM = (int)SDL_Scancode.SDL_SCANCODE_KP_EXCLAM | SDLK_SCANCODE_MASK,5396SDLK_KP_MEMSTORE = (int)SDL_Scancode.SDL_SCANCODE_KP_MEMSTORE | SDLK_SCANCODE_MASK,5397SDLK_KP_MEMRECALL = (int)SDL_Scancode.SDL_SCANCODE_KP_MEMRECALL | SDLK_SCANCODE_MASK,5398SDLK_KP_MEMCLEAR = (int)SDL_Scancode.SDL_SCANCODE_KP_MEMCLEAR | SDLK_SCANCODE_MASK,5399SDLK_KP_MEMADD = (int)SDL_Scancode.SDL_SCANCODE_KP_MEMADD | SDLK_SCANCODE_MASK,5400SDLK_KP_MEMSUBTRACT =5401(int)SDL_Scancode.SDL_SCANCODE_KP_MEMSUBTRACT | SDLK_SCANCODE_MASK,5402SDLK_KP_MEMMULTIPLY =5403(int)SDL_Scancode.SDL_SCANCODE_KP_MEMMULTIPLY | SDLK_SCANCODE_MASK,5404SDLK_KP_MEMDIVIDE = (int)SDL_Scancode.SDL_SCANCODE_KP_MEMDIVIDE | SDLK_SCANCODE_MASK,5405SDLK_KP_PLUSMINUS = (int)SDL_Scancode.SDL_SCANCODE_KP_PLUSMINUS | SDLK_SCANCODE_MASK,5406SDLK_KP_CLEAR = (int)SDL_Scancode.SDL_SCANCODE_KP_CLEAR | SDLK_SCANCODE_MASK,5407SDLK_KP_CLEARENTRY = (int)SDL_Scancode.SDL_SCANCODE_KP_CLEARENTRY | SDLK_SCANCODE_MASK,5408SDLK_KP_BINARY = (int)SDL_Scancode.SDL_SCANCODE_KP_BINARY | SDLK_SCANCODE_MASK,5409SDLK_KP_OCTAL = (int)SDL_Scancode.SDL_SCANCODE_KP_OCTAL | SDLK_SCANCODE_MASK,5410SDLK_KP_DECIMAL = (int)SDL_Scancode.SDL_SCANCODE_KP_DECIMAL | SDLK_SCANCODE_MASK,5411SDLK_KP_HEXADECIMAL =5412(int)SDL_Scancode.SDL_SCANCODE_KP_HEXADECIMAL | SDLK_SCANCODE_MASK,5413
5414SDLK_LCTRL = (int)SDL_Scancode.SDL_SCANCODE_LCTRL | SDLK_SCANCODE_MASK,5415SDLK_LSHIFT = (int)SDL_Scancode.SDL_SCANCODE_LSHIFT | SDLK_SCANCODE_MASK,5416SDLK_LALT = (int)SDL_Scancode.SDL_SCANCODE_LALT | SDLK_SCANCODE_MASK,5417SDLK_LGUI = (int)SDL_Scancode.SDL_SCANCODE_LGUI | SDLK_SCANCODE_MASK,5418SDLK_RCTRL = (int)SDL_Scancode.SDL_SCANCODE_RCTRL | SDLK_SCANCODE_MASK,5419SDLK_RSHIFT = (int)SDL_Scancode.SDL_SCANCODE_RSHIFT | SDLK_SCANCODE_MASK,5420SDLK_RALT = (int)SDL_Scancode.SDL_SCANCODE_RALT | SDLK_SCANCODE_MASK,5421SDLK_RGUI = (int)SDL_Scancode.SDL_SCANCODE_RGUI | SDLK_SCANCODE_MASK,5422
5423SDLK_MODE = (int)SDL_Scancode.SDL_SCANCODE_MODE | SDLK_SCANCODE_MASK,5424
5425SDLK_AUDIONEXT = (int)SDL_Scancode.SDL_SCANCODE_AUDIONEXT | SDLK_SCANCODE_MASK,5426SDLK_AUDIOPREV = (int)SDL_Scancode.SDL_SCANCODE_AUDIOPREV | SDLK_SCANCODE_MASK,5427SDLK_AUDIOSTOP = (int)SDL_Scancode.SDL_SCANCODE_AUDIOSTOP | SDLK_SCANCODE_MASK,5428SDLK_AUDIOPLAY = (int)SDL_Scancode.SDL_SCANCODE_AUDIOPLAY | SDLK_SCANCODE_MASK,5429SDLK_AUDIOMUTE = (int)SDL_Scancode.SDL_SCANCODE_AUDIOMUTE | SDLK_SCANCODE_MASK,5430SDLK_MEDIASELECT = (int)SDL_Scancode.SDL_SCANCODE_MEDIASELECT | SDLK_SCANCODE_MASK,5431SDLK_WWW = (int)SDL_Scancode.SDL_SCANCODE_WWW | SDLK_SCANCODE_MASK,5432SDLK_MAIL = (int)SDL_Scancode.SDL_SCANCODE_MAIL | SDLK_SCANCODE_MASK,5433SDLK_CALCULATOR = (int)SDL_Scancode.SDL_SCANCODE_CALCULATOR | SDLK_SCANCODE_MASK,5434SDLK_COMPUTER = (int)SDL_Scancode.SDL_SCANCODE_COMPUTER | SDLK_SCANCODE_MASK,5435SDLK_AC_SEARCH = (int)SDL_Scancode.SDL_SCANCODE_AC_SEARCH | SDLK_SCANCODE_MASK,5436SDLK_AC_HOME = (int)SDL_Scancode.SDL_SCANCODE_AC_HOME | SDLK_SCANCODE_MASK,5437SDLK_AC_BACK = (int)SDL_Scancode.SDL_SCANCODE_AC_BACK | SDLK_SCANCODE_MASK,5438SDLK_AC_FORWARD = (int)SDL_Scancode.SDL_SCANCODE_AC_FORWARD | SDLK_SCANCODE_MASK,5439SDLK_AC_STOP = (int)SDL_Scancode.SDL_SCANCODE_AC_STOP | SDLK_SCANCODE_MASK,5440SDLK_AC_REFRESH = (int)SDL_Scancode.SDL_SCANCODE_AC_REFRESH | SDLK_SCANCODE_MASK,5441SDLK_AC_BOOKMARKS = (int)SDL_Scancode.SDL_SCANCODE_AC_BOOKMARKS | SDLK_SCANCODE_MASK,5442
5443SDLK_BRIGHTNESSDOWN =5444(int)SDL_Scancode.SDL_SCANCODE_BRIGHTNESSDOWN | SDLK_SCANCODE_MASK,5445SDLK_BRIGHTNESSUP = (int)SDL_Scancode.SDL_SCANCODE_BRIGHTNESSUP | SDLK_SCANCODE_MASK,5446SDLK_DISPLAYSWITCH = (int)SDL_Scancode.SDL_SCANCODE_DISPLAYSWITCH | SDLK_SCANCODE_MASK,5447SDLK_KBDILLUMTOGGLE =5448(int)SDL_Scancode.SDL_SCANCODE_KBDILLUMTOGGLE | SDLK_SCANCODE_MASK,5449SDLK_KBDILLUMDOWN = (int)SDL_Scancode.SDL_SCANCODE_KBDILLUMDOWN | SDLK_SCANCODE_MASK,5450SDLK_KBDILLUMUP = (int)SDL_Scancode.SDL_SCANCODE_KBDILLUMUP | SDLK_SCANCODE_MASK,5451SDLK_EJECT = (int)SDL_Scancode.SDL_SCANCODE_EJECT | SDLK_SCANCODE_MASK,5452SDLK_SLEEP = (int)SDL_Scancode.SDL_SCANCODE_SLEEP | SDLK_SCANCODE_MASK,5453SDLK_APP1 = (int)SDL_Scancode.SDL_SCANCODE_APP1 | SDLK_SCANCODE_MASK,5454SDLK_APP2 = (int)SDL_Scancode.SDL_SCANCODE_APP2 | SDLK_SCANCODE_MASK,5455
5456SDLK_AUDIOREWIND = (int)SDL_Scancode.SDL_SCANCODE_AUDIOREWIND | SDLK_SCANCODE_MASK,5457SDLK_AUDIOFASTFORWARD = (int)SDL_Scancode.SDL_SCANCODE_AUDIOFASTFORWARD | SDLK_SCANCODE_MASK5458}5459
5460/* Key modifiers (bitfield) */5461[Flags]5462public enum SDL_Keymod : ushort5463{5464KMOD_NONE = 0x0000,5465KMOD_LSHIFT = 0x0001,5466KMOD_RSHIFT = 0x0002,5467KMOD_LCTRL = 0x0040,5468KMOD_RCTRL = 0x0080,5469KMOD_LALT = 0x0100,5470KMOD_RALT = 0x0200,5471KMOD_LGUI = 0x0400,5472KMOD_RGUI = 0x0800,5473KMOD_NUM = 0x1000,5474KMOD_CAPS = 0x2000,5475KMOD_MODE = 0x4000,5476KMOD_RESERVED = 0x8000,5477
5478/* These are defines in the SDL headers */5479KMOD_CTRL = (KMOD_LCTRL | KMOD_RCTRL),5480KMOD_SHIFT = (KMOD_LSHIFT | KMOD_RSHIFT),5481KMOD_ALT = (KMOD_LALT | KMOD_RALT),5482KMOD_GUI = (KMOD_LGUI | KMOD_RGUI)5483}5484
5485#endregion5486
5487#region SDL_keyboard.h5488
5489[StructLayout(LayoutKind.Sequential)]5490public struct SDL_Keysym5491{5492public SDL_Scancode scancode;5493public SDL_Keycode sym;5494public SDL_Keymod mod; /* UInt16 */5495public UInt32 unicode; /* Deprecated */5496}5497
5498/* Get the window which has kbd focus */5499/* Return type is an SDL_Window pointer */5500[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5501public static extern IntPtr SDL_GetKeyboardFocus();5502
5503/* Get a snapshot of the keyboard state. */5504/* Return value is a pointer to a UInt8 array */5505/* Numkeys returns the size of the array if non-null */5506[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5507public static extern IntPtr SDL_GetKeyboardState(out int numkeys);5508
5509/* Get the current key modifier state for the keyboard. */5510[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5511public static extern SDL_Keymod SDL_GetModState();5512
5513/* Set the current key modifier state */5514[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5515public static extern void SDL_SetModState(SDL_Keymod modstate);5516
5517/* Get the key code corresponding to the given scancode5518* with the current keyboard layout.
5519*/
5520[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5521public static extern SDL_Keycode SDL_GetKeyFromScancode(SDL_Scancode scancode);5522
5523/* Get the scancode for the given keycode */5524[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5525public static extern SDL_Scancode SDL_GetScancodeFromKey(SDL_Keycode key);5526
5527/* Wrapper for SDL_GetScancodeName */5528[DllImport(nativeLibName, EntryPoint = "SDL_GetScancodeName", CallingConvention = CallingConvention.Cdecl)]5529private static extern IntPtr INTERNAL_SDL_GetScancodeName(SDL_Scancode scancode);5530public static string SDL_GetScancodeName(SDL_Scancode scancode)5531{5532return UTF8_ToManaged(5533INTERNAL_SDL_GetScancodeName(scancode)5534);5535}5536
5537/* Get a scancode from a human-readable name */5538[DllImport(nativeLibName, EntryPoint = "SDL_GetScancodeFromName", CallingConvention = CallingConvention.Cdecl)]5539private static extern SDL_Scancode INTERNAL_SDL_GetScancodeFromName(5540byte[] name5541);5542public static SDL_Scancode SDL_GetScancodeFromName(string name)5543{5544return INTERNAL_SDL_GetScancodeFromName(5545UTF8_ToNative(name)5546);5547}5548
5549/* Wrapper for SDL_GetKeyName */5550[DllImport(nativeLibName, EntryPoint = "SDL_GetKeyName", CallingConvention = CallingConvention.Cdecl)]5551private static extern IntPtr INTERNAL_SDL_GetKeyName(SDL_Keycode key);5552public static string SDL_GetKeyName(SDL_Keycode key)5553{5554return UTF8_ToManaged(INTERNAL_SDL_GetKeyName(key));5555}5556
5557/* Get a key code from a human-readable name */5558[DllImport(nativeLibName, EntryPoint = "SDL_GetKeyFromName", CallingConvention = CallingConvention.Cdecl)]5559private static extern SDL_Keycode INTERNAL_SDL_GetKeyFromName(5560byte[] name5561);5562public static SDL_Keycode SDL_GetKeyFromName(string name)5563{5564return INTERNAL_SDL_GetKeyFromName(UTF8_ToNative(name));5565}5566
5567/* Start accepting Unicode text input events, show keyboard */5568[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5569public static extern void SDL_StartTextInput();5570
5571/* Check if unicode input events are enabled */5572[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5573public static extern SDL_bool SDL_IsTextInputActive();5574
5575/* Stop receiving any text input events, hide onscreen kbd */5576[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5577public static extern void SDL_StopTextInput();5578
5579/* Set the rectangle used for text input, hint for IME */5580[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5581public static extern void SDL_SetTextInputRect(ref SDL_Rect rect);5582
5583/* Does the platform support an on-screen keyboard? */5584[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5585public static extern SDL_bool SDL_HasScreenKeyboardSupport();5586
5587/* Is the on-screen keyboard shown for a given window? */5588/* window is an SDL_Window pointer */5589[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5590public static extern SDL_bool SDL_IsScreenKeyboardShown(IntPtr window);5591
5592#endregion5593
5594#region SDL_mouse.c5595
5596/* Note: SDL_Cursor is a typedef normally. We'll treat it as5597* an IntPtr, because C# doesn't do typedefs. Yay!
5598*/
5599
5600/* System cursor types */5601public enum SDL_SystemCursor5602{5603SDL_SYSTEM_CURSOR_ARROW, // Arrow5604SDL_SYSTEM_CURSOR_IBEAM, // I-beam5605SDL_SYSTEM_CURSOR_WAIT, // Wait5606SDL_SYSTEM_CURSOR_CROSSHAIR, // Crosshair5607SDL_SYSTEM_CURSOR_WAITARROW, // Small wait cursor (or Wait if not available)5608SDL_SYSTEM_CURSOR_SIZENWSE, // Double arrow pointing northwest and southeast5609SDL_SYSTEM_CURSOR_SIZENESW, // Double arrow pointing northeast and southwest5610SDL_SYSTEM_CURSOR_SIZEWE, // Double arrow pointing west and east5611SDL_SYSTEM_CURSOR_SIZENS, // Double arrow pointing north and south5612SDL_SYSTEM_CURSOR_SIZEALL, // Four pointed arrow pointing north, south, east, and west5613SDL_SYSTEM_CURSOR_NO, // Slashed circle or crossbones5614SDL_SYSTEM_CURSOR_HAND, // Hand5615SDL_NUM_SYSTEM_CURSORS
5616}5617
5618/* Get the window which currently has mouse focus */5619/* Return value is an SDL_Window pointer */5620[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5621public static extern IntPtr SDL_GetMouseFocus();5622
5623/* Get the current state of the mouse */5624[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5625public static extern UInt32 SDL_GetMouseState(out int x, out int y);5626
5627/* Get the current state of the mouse */5628/* This overload allows for passing NULL to x */5629[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5630public static extern UInt32 SDL_GetMouseState(IntPtr x, out int y);5631
5632/* Get the current state of the mouse */5633/* This overload allows for passing NULL to y */5634[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5635public static extern UInt32 SDL_GetMouseState(out int x, IntPtr y);5636
5637/* Get the current state of the mouse */5638/* This overload allows for passing NULL to both x and y */5639[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5640public static extern UInt32 SDL_GetMouseState(IntPtr x, IntPtr y);5641
5642/* Get the current state of the mouse, in relation to the desktop.5643* Only available in 2.0.4 or higher.
5644*/
5645[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5646public static extern UInt32 SDL_GetGlobalMouseState(out int x, out int y);5647
5648/* Get the current state of the mouse, in relation to the desktop.5649* Only available in 2.0.4 or higher.
5650* This overload allows for passing NULL to x.
5651*/
5652[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5653public static extern UInt32 SDL_GetGlobalMouseState(IntPtr x, out int y);5654
5655/* Get the current state of the mouse, in relation to the desktop.5656* Only available in 2.0.4 or higher.
5657* This overload allows for passing NULL to y.
5658*/
5659[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5660public static extern UInt32 SDL_GetGlobalMouseState(out int x, IntPtr y);5661
5662/* Get the current state of the mouse, in relation to the desktop.5663* Only available in 2.0.4 or higher.
5664* This overload allows for passing NULL to both x and y
5665*/
5666[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5667public static extern UInt32 SDL_GetGlobalMouseState(IntPtr x, IntPtr y);5668
5669/* Get the mouse state with relative coords*/5670[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5671public static extern UInt32 SDL_GetRelativeMouseState(out int x, out int y);5672
5673/* Set the mouse cursor's position (within a window) */5674/* window is an SDL_Window pointer */5675[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5676public static extern void SDL_WarpMouseInWindow(IntPtr window, int x, int y);5677
5678/* Set the mouse cursor's position in global screen space.5679* Only available in 2.0.4 or higher.
5680*/
5681[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5682public static extern int SDL_WarpMouseGlobal(int x, int y);5683
5684/* Enable/Disable relative mouse mode (grabs mouse, rel coords) */5685[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5686public static extern int SDL_SetRelativeMouseMode(SDL_bool enabled);5687
5688/* Capture the mouse, to track input outside an SDL window.5689* Only available in 2.0.4 or higher.
5690*/
5691[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5692public static extern int SDL_CaptureMouse(SDL_bool enabled);5693
5694/* Query if the relative mouse mode is enabled */5695[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5696public static extern SDL_bool SDL_GetRelativeMouseMode();5697
5698/* Create a cursor from bitmap data (amd mask) in MSB format.5699* data and mask are byte arrays, and w must be a multiple of 8.
5700* return value is an SDL_Cursor pointer.
5701*/
5702[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5703public static extern IntPtr SDL_CreateCursor(5704IntPtr data,5705IntPtr mask,5706int w,5707int h,5708int hot_x,5709int hot_y5710);5711
5712/* Create a cursor from an SDL_Surface.5713* IntPtr refers to an SDL_Cursor*, surface to an SDL_Surface*
5714*/
5715[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5716public static extern IntPtr SDL_CreateColorCursor(5717IntPtr surface,5718int hot_x,5719int hot_y5720);5721
5722/* Create a cursor from a system cursor id.5723* return value is an SDL_Cursor pointer
5724*/
5725[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5726public static extern IntPtr SDL_CreateSystemCursor(SDL_SystemCursor id);5727
5728/* Set the active cursor.5729* cursor is an SDL_Cursor pointer
5730*/
5731[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5732public static extern void SDL_SetCursor(IntPtr cursor);5733
5734/* Return the active cursor5735* return value is an SDL_Cursor pointer
5736*/
5737[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5738public static extern IntPtr SDL_GetCursor();5739
5740/* Frees a cursor created with one of the CreateCursor functions.5741* cursor in an SDL_Cursor pointer
5742*/
5743[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5744public static extern void SDL_FreeCursor(IntPtr cursor);5745
5746/* Toggle whether or not the cursor is shown */5747[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5748public static extern int SDL_ShowCursor(int toggle);5749
5750public static uint SDL_BUTTON(uint X)5751{5752// If only there were a better way of doing this in C#5753return (uint)(1 << ((int)X - 1));5754}5755
5756public const uint SDL_BUTTON_LEFT = 1;5757public const uint SDL_BUTTON_MIDDLE = 2;5758public const uint SDL_BUTTON_RIGHT = 3;5759public const uint SDL_BUTTON_X1 = 4;5760public const uint SDL_BUTTON_X2 = 5;5761public static readonly UInt32 SDL_BUTTON_LMASK = SDL_BUTTON(SDL_BUTTON_LEFT);5762public static readonly UInt32 SDL_BUTTON_MMASK = SDL_BUTTON(SDL_BUTTON_MIDDLE);5763public static readonly UInt32 SDL_BUTTON_RMASK = SDL_BUTTON(SDL_BUTTON_RIGHT);5764public static readonly UInt32 SDL_BUTTON_X1MASK = SDL_BUTTON(SDL_BUTTON_X1);5765public static readonly UInt32 SDL_BUTTON_X2MASK = SDL_BUTTON(SDL_BUTTON_X2);5766
5767#endregion5768
5769#region SDL_touch.h5770
5771public const uint SDL_TOUCH_MOUSEID = uint.MaxValue;5772
5773public struct SDL_Finger5774{5775public long id; // SDL_FingerID5776public float x;5777public float y;5778public float pressure;5779}5780
5781/* Only available in 2.0.10 or higher. */5782public enum SDL_TouchDeviceType5783{5784SDL_TOUCH_DEVICE_INVALID = -1,5785SDL_TOUCH_DEVICE_DIRECT, /* touch screen with window-relative coordinates */5786SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, /* trackpad with absolute device coordinates */5787SDL_TOUCH_DEVICE_INDIRECT_RELATIVE /* trackpad with screen cursor-relative coordinates */5788}5789
5790/**5791* \brief Get the number of registered touch devices.
5792*/
5793[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5794public static extern int SDL_GetNumTouchDevices();5795
5796/**5797* \brief Get the touch ID with the given index, or 0 if the index is invalid.
5798*/
5799[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5800public static extern long SDL_GetTouchDevice(int index);5801
5802/**5803* \brief Get the number of active fingers for a given touch device.
5804*/
5805[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5806public static extern int SDL_GetNumTouchFingers(long touchID);5807
5808/**5809* \brief Get the finger object of the given touch, with the given index.
5810* Returns pointer to SDL_Finger.
5811*/
5812[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5813public static extern IntPtr SDL_GetTouchFinger(long touchID, int index);5814
5815/* Only available in 2.0.10 or higher. */5816[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5817public static extern SDL_TouchDeviceType SDL_GetTouchDeviceType(Int64 touchID);5818
5819#endregion5820
5821#region SDL_joystick.h5822
5823public const byte SDL_HAT_CENTERED = 0x00;5824public const byte SDL_HAT_UP = 0x01;5825public const byte SDL_HAT_RIGHT = 0x02;5826public const byte SDL_HAT_DOWN = 0x04;5827public const byte SDL_HAT_LEFT = 0x08;5828public const byte SDL_HAT_RIGHTUP = SDL_HAT_RIGHT | SDL_HAT_UP;5829public const byte SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT | SDL_HAT_DOWN;5830public const byte SDL_HAT_LEFTUP = SDL_HAT_LEFT | SDL_HAT_UP;5831public const byte SDL_HAT_LEFTDOWN = SDL_HAT_LEFT | SDL_HAT_DOWN;5832
5833public enum SDL_JoystickPowerLevel5834{5835SDL_JOYSTICK_POWER_UNKNOWN = -1,5836SDL_JOYSTICK_POWER_EMPTY,5837SDL_JOYSTICK_POWER_LOW,5838SDL_JOYSTICK_POWER_MEDIUM,5839SDL_JOYSTICK_POWER_FULL,5840SDL_JOYSTICK_POWER_WIRED,5841SDL_JOYSTICK_POWER_MAX
5842}5843
5844public enum SDL_JoystickType5845{5846SDL_JOYSTICK_TYPE_UNKNOWN,5847SDL_JOYSTICK_TYPE_GAMECONTROLLER,5848SDL_JOYSTICK_TYPE_WHEEL,5849SDL_JOYSTICK_TYPE_ARCADE_STICK,5850SDL_JOYSTICK_TYPE_FLIGHT_STICK,5851SDL_JOYSTICK_TYPE_DANCE_PAD,5852SDL_JOYSTICK_TYPE_GUITAR,5853SDL_JOYSTICK_TYPE_DRUM_KIT,5854SDL_JOYSTICK_TYPE_ARCADE_PAD
5855}5856
5857/* joystick refers to an SDL_Joystick*.5858* Only available in 2.0.9 or higher.
5859*/
5860[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5861public static extern int SDL_JoystickRumble(5862IntPtr joystick,5863UInt16 low_frequency_rumble,5864UInt16 high_frequency_rumble,5865UInt32 duration_ms5866);5867
5868/* joystick refers to an SDL_Joystick* */5869[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5870public static extern void SDL_JoystickClose(IntPtr joystick);5871
5872[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5873public static extern int SDL_JoystickEventState(int state);5874
5875/* joystick refers to an SDL_Joystick* */5876[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5877public static extern short SDL_JoystickGetAxis(5878IntPtr joystick,5879int axis5880);5881
5882/* joystick refers to an SDL_Joystick*.5883* Only available in 2.0.6 or higher.
5884*/
5885[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5886public static extern SDL_bool SDL_JoystickGetAxisInitialState(5887IntPtr joystick,5888int axis,5889out ushort state5890);5891
5892/* joystick refers to an SDL_Joystick* */5893[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5894public static extern int SDL_JoystickGetBall(5895IntPtr joystick,5896int ball,5897out int dx,5898out int dy5899);5900
5901/* joystick refers to an SDL_Joystick* */5902[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5903public static extern byte SDL_JoystickGetButton(5904IntPtr joystick,5905int button5906);5907
5908/* joystick refers to an SDL_Joystick* */5909[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5910public static extern byte SDL_JoystickGetHat(5911IntPtr joystick,5912int hat5913);5914
5915/* joystick refers to an SDL_Joystick* */5916[DllImport(nativeLibName, EntryPoint = "SDL_JoystickName", CallingConvention = CallingConvention.Cdecl)]5917private static extern IntPtr INTERNAL_SDL_JoystickName(5918IntPtr joystick5919);5920public static string SDL_JoystickName(IntPtr joystick)5921{5922return UTF8_ToManaged(5923INTERNAL_SDL_JoystickName(joystick)5924);5925}5926
5927[DllImport(nativeLibName, EntryPoint = "SDL_JoystickNameForIndex", CallingConvention = CallingConvention.Cdecl)]5928private static extern IntPtr INTERNAL_SDL_JoystickNameForIndex(5929int device_index5930);5931public static string SDL_JoystickNameForIndex(int device_index)5932{5933return UTF8_ToManaged(5934INTERNAL_SDL_JoystickNameForIndex(device_index)5935);5936}5937
5938/* joystick refers to an SDL_Joystick* */5939[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5940public static extern int SDL_JoystickNumAxes(IntPtr joystick);5941
5942/* joystick refers to an SDL_Joystick* */5943[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5944public static extern int SDL_JoystickNumBalls(IntPtr joystick);5945
5946/* joystick refers to an SDL_Joystick* */5947[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5948public static extern int SDL_JoystickNumButtons(IntPtr joystick);5949
5950/* joystick refers to an SDL_Joystick* */5951[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5952public static extern int SDL_JoystickNumHats(IntPtr joystick);5953
5954/* IntPtr refers to an SDL_Joystick* */5955[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5956public static extern IntPtr SDL_JoystickOpen(int device_index);5957
5958/* joystick refers to an SDL_Joystick* */5959[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5960public static extern void SDL_JoystickUpdate();5961
5962/* joystick refers to an SDL_Joystick* */5963[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5964public static extern int SDL_NumJoysticks();5965
5966[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5967public static extern Guid SDL_JoystickGetDeviceGUID(5968int device_index5969);5970
5971/* joystick refers to an SDL_Joystick* */5972[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5973public static extern Guid SDL_JoystickGetGUID(5974IntPtr joystick5975);5976
5977[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5978public static extern void SDL_JoystickGetGUIDString(5979Guid guid,5980byte[] pszGUID,5981int cbGUID5982);5983
5984[DllImport(nativeLibName, EntryPoint = "SDL_JoystickGetGUIDFromString", CallingConvention = CallingConvention.Cdecl)]5985private static extern Guid INTERNAL_SDL_JoystickGetGUIDFromString(5986byte[] pchGUID5987);5988public static Guid SDL_JoystickGetGUIDFromString(string pchGuid)5989{5990return INTERNAL_SDL_JoystickGetGUIDFromString(5991UTF8_ToNative(pchGuid)5992);5993}5994
5995/* Only available in 2.0.6 or higher. */5996[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]5997public static extern ushort SDL_JoystickGetDeviceVendor(int device_index);5998
5999/* Only available in 2.0.6 or higher. */6000[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6001public static extern ushort SDL_JoystickGetDeviceProduct(int device_index);6002
6003/* Only available in 2.0.6 or higher. */6004[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6005public static extern ushort SDL_JoystickGetDeviceProductVersion(int device_index);6006
6007/* Only available in 2.0.6 or higher. */6008[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6009public static extern SDL_JoystickType SDL_JoystickGetDeviceType(int device_index);6010
6011/* int refers to an SDL_JoystickID.6012* Only available in 2.0.6 or higher.
6013*/
6014[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6015public static extern int SDL_JoystickGetDeviceInstanceID(int device_index);6016
6017/* joystick refers to an SDL_Joystick*.6018* Only available in 2.0.6 or higher.
6019*/
6020[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6021public static extern ushort SDL_JoystickGetVendor(IntPtr joystick);6022
6023/* joystick refers to an SDL_Joystick*.6024* Only available in 2.0.6 or higher.
6025*/
6026[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6027public static extern ushort SDL_JoystickGetProduct(IntPtr joystick);6028
6029/* joystick refers to an SDL_Joystick*.6030* Only available in 2.0.6 or higher.
6031*/
6032[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6033public static extern ushort SDL_JoystickGetProductVersion(IntPtr joystick);6034
6035/* joystick refers to an SDL_Joystick*.6036* Only available in 2.0.6 or higher.
6037*/
6038[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6039public static extern SDL_JoystickType SDL_JoystickGetType(IntPtr joystick);6040
6041/* joystick refers to an SDL_Joystick* */6042[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6043public static extern SDL_bool SDL_JoystickGetAttached(IntPtr joystick);6044
6045/* int refers to an SDL_JoystickID, joystick to an SDL_Joystick* */6046[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6047public static extern int SDL_JoystickInstanceID(IntPtr joystick);6048
6049/* joystick refers to an SDL_Joystick*.6050* Only available in 2.0.4 or higher.
6051*/
6052[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6053public static extern SDL_JoystickPowerLevel SDL_JoystickCurrentPowerLevel(6054IntPtr joystick6055);6056
6057/* int refers to an SDL_JoystickID, IntPtr to an SDL_Joystick*.6058* Only available in 2.0.4 or higher.
6059*/
6060[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6061public static extern IntPtr SDL_JoystickFromInstanceID(int instance_id);6062
6063/* Only available in 2.0.7 or higher. */6064[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6065public static extern void SDL_LockJoysticks();6066
6067/* Only available in 2.0.7 or higher. */6068[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6069public static extern void SDL_UnlockJoysticks();6070
6071/* IntPtr refers to an SDL_Joystick*.6072* Only available in 2.0.11 or higher.
6073*/
6074[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6075public static extern IntPtr SDL_JoystickFromPlayerIndex(int player_index);6076
6077/* IntPtr refers to an SDL_Joystick*.6078* Only available in 2.0.11 or higher.
6079*/
6080[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6081public static extern void SDL_JoystickSetPlayerIndex(6082IntPtr joystick,6083int player_index6084);6085
6086[DllImport(nativeLibName, EntryPoint = "SDL_JoystickPathForIndex", CallingConvention = CallingConvention.Cdecl)]6087private static extern IntPtr INTERNAL_SDL_JoystickPathForIndex(int device_index);6088
6089public static string SDL_JoystickPathForIndex(int device_index)6090{6091if (Version >= new Version(2, 24, 0 , 0))6092return UTF8_ToManaged(INTERNAL_SDL_JoystickPathForIndex(device_index));6093
6094return null;6095}6096
6097[DllImport(nativeLibName, EntryPoint = "SDL_JoystickPath", CallingConvention = CallingConvention.Cdecl)]6098private static extern IntPtr INTERNAL_SDL_JoystickPath(IntPtr joystick);6099
6100public static string SDL_JoystickPath(IntPtr joystick)6101{6102if (Version >= new Version(2, 24, 0, 0))6103return UTF8_ToManaged(INTERNAL_SDL_JoystickPath(joystick));6104
6105return null;6106}6107
6108
6109#endregion6110
6111#region SDL_gamecontroller.h6112
6113public enum SDL_GameControllerBindType6114{6115SDL_CONTROLLER_BINDTYPE_NONE,6116SDL_CONTROLLER_BINDTYPE_BUTTON,6117SDL_CONTROLLER_BINDTYPE_AXIS,6118SDL_CONTROLLER_BINDTYPE_HAT
6119}6120
6121public enum SDL_GameControllerAxis6122{6123SDL_CONTROLLER_AXIS_INVALID = -1,6124SDL_CONTROLLER_AXIS_LEFTX,6125SDL_CONTROLLER_AXIS_LEFTY,6126SDL_CONTROLLER_AXIS_RIGHTX,6127SDL_CONTROLLER_AXIS_RIGHTY,6128SDL_CONTROLLER_AXIS_TRIGGERLEFT,6129SDL_CONTROLLER_AXIS_TRIGGERRIGHT,6130SDL_CONTROLLER_AXIS_MAX
6131}6132
6133public enum SDL_GameControllerButton6134{6135SDL_CONTROLLER_BUTTON_INVALID = -1,6136SDL_CONTROLLER_BUTTON_A,6137SDL_CONTROLLER_BUTTON_B,6138SDL_CONTROLLER_BUTTON_X,6139SDL_CONTROLLER_BUTTON_Y,6140SDL_CONTROLLER_BUTTON_BACK,6141SDL_CONTROLLER_BUTTON_GUIDE,6142SDL_CONTROLLER_BUTTON_START,6143SDL_CONTROLLER_BUTTON_LEFTSTICK,6144SDL_CONTROLLER_BUTTON_RIGHTSTICK,6145SDL_CONTROLLER_BUTTON_LEFTSHOULDER,6146SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,6147SDL_CONTROLLER_BUTTON_DPAD_UP,6148SDL_CONTROLLER_BUTTON_DPAD_DOWN,6149SDL_CONTROLLER_BUTTON_DPAD_LEFT,6150SDL_CONTROLLER_BUTTON_DPAD_RIGHT,6151SDL_CONTROLLER_BUTTON_MAX,6152}6153
6154public enum SDL_GameControllerType6155{6156SDL_CONTROLLER_TYPE_UNKNOWN = 0,6157SDL_CONTROLLER_TYPE_XBOX360,6158SDL_CONTROLLER_TYPE_XBOXONE,6159SDL_CONTROLLER_TYPE_PS3,6160SDL_CONTROLLER_TYPE_PS4,6161SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO
6162}6163
6164// FIXME: I'd rather this somehow be private...6165[StructLayout(LayoutKind.Sequential)]6166public struct INTERNAL_GameControllerButtonBind_hat6167{6168public int hat;6169public int hat_mask;6170}6171
6172// FIXME: I'd rather this somehow be private...6173[StructLayout(LayoutKind.Explicit)]6174public struct INTERNAL_GameControllerButtonBind_union6175{6176[FieldOffset(0)]6177public int button;6178[FieldOffset(0)]6179public int axis;6180[FieldOffset(0)]6181public INTERNAL_GameControllerButtonBind_hat hat;6182}6183
6184[StructLayout(LayoutKind.Sequential)]6185public struct SDL_GameControllerButtonBind6186{6187public SDL_GameControllerBindType bindType;6188public INTERNAL_GameControllerButtonBind_union value;6189}6190
6191/* This exists to deal with C# being stupid about blittable types. */6192[StructLayout(LayoutKind.Sequential)]6193private struct INTERNAL_SDL_GameControllerButtonBind6194{6195public int bindType;6196/* Largest data type in the union is two ints in size */6197public int unionVal0;6198public int unionVal1;6199}6200
6201[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerAddMapping", CallingConvention = CallingConvention.Cdecl)]6202private static extern int INTERNAL_SDL_GameControllerAddMapping(6203byte[] mappingString6204);6205public static int SDL_GameControllerAddMapping(6206string mappingString6207)6208{6209return INTERNAL_SDL_GameControllerAddMapping(6210UTF8_ToNative(mappingString)6211);6212}6213
6214/* Only available in 2.0.6 or higher. */6215[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6216public static extern int SDL_GameControllerNumMappings();6217
6218/* Only available in 2.0.6 or higher. */6219[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerMappingForIndex", CallingConvention = CallingConvention.Cdecl)]6220private static extern IntPtr INTERNAL_SDL_GameControllerMappingForIndex(int mapping_index);6221public static string SDL_GameControllerMappingForIndex(int mapping_index)6222{6223return UTF8_ToManaged(6224INTERNAL_SDL_GameControllerMappingForIndex(6225mapping_index
6226)6227);6228}6229
6230/* THIS IS AN RWops FUNCTION! */6231[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerAddMappingsFromRW", CallingConvention = CallingConvention.Cdecl)]6232private static extern int INTERNAL_SDL_GameControllerAddMappingsFromRW(6233IntPtr rw,6234int freerw6235);6236public static int SDL_GameControllerAddMappingsFromFile(string file)6237{6238IntPtr rwops = SDL_RWFromFile(file, "rb");6239return INTERNAL_SDL_GameControllerAddMappingsFromRW(rwops, 1);6240}6241
6242[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerMappingForGUID", CallingConvention = CallingConvention.Cdecl)]6243private static extern IntPtr INTERNAL_SDL_GameControllerMappingForGUID(6244Guid guid6245);6246public static string SDL_GameControllerMappingForGUID(Guid guid)6247{6248return UTF8_ToManaged(6249INTERNAL_SDL_GameControllerMappingForGUID(guid)6250);6251}6252
6253/* gamecontroller refers to an SDL_GameController* */6254[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerMapping", CallingConvention = CallingConvention.Cdecl)]6255private static extern IntPtr INTERNAL_SDL_GameControllerMapping(6256IntPtr gamecontroller6257);6258public static string SDL_GameControllerMapping(6259IntPtr gamecontroller6260)6261{6262return UTF8_ToManaged(6263INTERNAL_SDL_GameControllerMapping(6264gamecontroller
6265)6266);6267}6268
6269[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6270public static extern SDL_bool SDL_IsGameController(int joystick_index);6271
6272[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerNameForIndex", CallingConvention = CallingConvention.Cdecl)]6273private static extern IntPtr INTERNAL_SDL_GameControllerNameForIndex(6274int joystick_index6275);6276public static string SDL_GameControllerNameForIndex(6277int joystick_index6278)6279{6280return UTF8_ToManaged(6281INTERNAL_SDL_GameControllerNameForIndex(joystick_index)6282);6283}6284
6285/* Only available in 2.0.9 or higher. */6286[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerMappingForDeviceIndex", CallingConvention = CallingConvention.Cdecl)]6287private static extern IntPtr INTERNAL_SDL_GameControllerMappingForDeviceIndex(6288int joystick_index6289);6290public static string SDL_GameControllerMappingForDeviceIndex(6291int joystick_index6292)6293{6294return UTF8_ToManaged(6295INTERNAL_SDL_GameControllerMappingForDeviceIndex(joystick_index)6296);6297}6298
6299/* IntPtr refers to an SDL_GameController* */6300[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6301public static extern IntPtr SDL_GameControllerOpen(int joystick_index);6302
6303/* gamecontroller refers to an SDL_GameController* */6304[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerName", CallingConvention = CallingConvention.Cdecl)]6305private static extern IntPtr INTERNAL_SDL_GameControllerName(6306IntPtr gamecontroller6307);6308public static string SDL_GameControllerName(6309IntPtr gamecontroller6310)6311{6312return UTF8_ToManaged(6313INTERNAL_SDL_GameControllerName(gamecontroller)6314);6315}6316
6317/* gamecontroller refers to an SDL_GameController*.6318* Only available in 2.0.6 or higher.
6319*/
6320[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6321public static extern ushort SDL_GameControllerGetVendor(6322IntPtr gamecontroller6323);6324
6325/* gamecontroller refers to an SDL_GameController*.6326* Only available in 2.0.6 or higher.
6327*/
6328[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6329public static extern ushort SDL_GameControllerGetProduct(6330IntPtr gamecontroller6331);6332
6333/* gamecontroller refers to an SDL_GameController*.6334* Only available in 2.0.6 or higher.
6335*/
6336[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6337public static extern ushort SDL_GameControllerGetProductVersion(6338IntPtr gamecontroller6339);6340
6341/* gamecontroller refers to an SDL_GameController* */6342[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6343public static extern SDL_bool SDL_GameControllerGetAttached(6344IntPtr gamecontroller6345);6346
6347/* IntPtr refers to an SDL_Joystick*6348* gamecontroller refers to an SDL_GameController*
6349*/
6350[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6351public static extern IntPtr SDL_GameControllerGetJoystick(6352IntPtr gamecontroller6353);6354
6355[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6356public static extern int SDL_GameControllerEventState(int state);6357
6358[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6359public static extern void SDL_GameControllerUpdate();6360
6361[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetAxisFromString", CallingConvention = CallingConvention.Cdecl)]6362private static extern SDL_GameControllerAxis INTERNAL_SDL_GameControllerGetAxisFromString(6363byte[] pchString6364);6365public static SDL_GameControllerAxis SDL_GameControllerGetAxisFromString(6366string pchString6367)6368{6369return INTERNAL_SDL_GameControllerGetAxisFromString(6370UTF8_ToNative(pchString)6371);6372}6373
6374[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetStringForAxis", CallingConvention = CallingConvention.Cdecl)]6375private static extern IntPtr INTERNAL_SDL_GameControllerGetStringForAxis(6376SDL_GameControllerAxis axis6377);6378public static string SDL_GameControllerGetStringForAxis(6379SDL_GameControllerAxis axis6380)6381{6382return UTF8_ToManaged(6383INTERNAL_SDL_GameControllerGetStringForAxis(6384axis
6385)6386);6387}6388
6389/* gamecontroller refers to an SDL_GameController* */6390[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetBindForAxis", CallingConvention = CallingConvention.Cdecl)]6391private static extern INTERNAL_SDL_GameControllerButtonBind INTERNAL_SDL_GameControllerGetBindForAxis(6392IntPtr gamecontroller,6393SDL_GameControllerAxis axis6394);6395public static SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis(6396IntPtr gamecontroller,6397SDL_GameControllerAxis axis6398)6399{6400// This is guaranteed to never be null6401INTERNAL_SDL_GameControllerButtonBind dumb = INTERNAL_SDL_GameControllerGetBindForAxis(6402gamecontroller,6403axis
6404);6405SDL_GameControllerButtonBind result = new SDL_GameControllerButtonBind();6406result.bindType = (SDL_GameControllerBindType)dumb.bindType;6407result.value.hat.hat = dumb.unionVal0;6408result.value.hat.hat_mask = dumb.unionVal1;6409return result;6410}6411
6412/* gamecontroller refers to an SDL_GameController* */6413[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6414public static extern short SDL_GameControllerGetAxis(6415IntPtr gamecontroller,6416SDL_GameControllerAxis axis6417);6418
6419[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetButtonFromString", CallingConvention = CallingConvention.Cdecl)]6420private static extern SDL_GameControllerButton INTERNAL_SDL_GameControllerGetButtonFromString(6421byte[] pchString6422);6423public static SDL_GameControllerButton SDL_GameControllerGetButtonFromString(6424string pchString6425)6426{6427return INTERNAL_SDL_GameControllerGetButtonFromString(6428UTF8_ToNative(pchString)6429);6430}6431
6432[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetStringForButton", CallingConvention = CallingConvention.Cdecl)]6433private static extern IntPtr INTERNAL_SDL_GameControllerGetStringForButton(6434SDL_GameControllerButton button6435);6436public static string SDL_GameControllerGetStringForButton(6437SDL_GameControllerButton button6438)6439{6440return UTF8_ToManaged(6441INTERNAL_SDL_GameControllerGetStringForButton(button)6442);6443}6444
6445/* gamecontroller refers to an SDL_GameController* */6446[DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetBindForButton", CallingConvention = CallingConvention.Cdecl)]6447private static extern INTERNAL_SDL_GameControllerButtonBind INTERNAL_SDL_GameControllerGetBindForButton(6448IntPtr gamecontroller,6449SDL_GameControllerButton button6450);6451public static SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(6452IntPtr gamecontroller,6453SDL_GameControllerButton button6454)6455{6456// This is guaranteed to never be null6457INTERNAL_SDL_GameControllerButtonBind dumb = INTERNAL_SDL_GameControllerGetBindForButton(6458gamecontroller,6459button
6460);6461SDL_GameControllerButtonBind result = new SDL_GameControllerButtonBind();6462result.bindType = (SDL_GameControllerBindType)dumb.bindType;6463result.value.hat.hat = dumb.unionVal0;6464result.value.hat.hat_mask = dumb.unionVal1;6465return result;6466}6467
6468/* gamecontroller refers to an SDL_GameController* */6469[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6470public static extern byte SDL_GameControllerGetButton(6471IntPtr gamecontroller,6472SDL_GameControllerButton button6473);6474
6475/* gamecontroller refers to an SDL_GameController*.6476* Only available in 2.0.9 or higher.
6477*/
6478[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6479public static extern int SDL_GameControllerRumble(6480IntPtr gamecontroller,6481UInt16 low_frequency_rumble,6482UInt16 high_frequency_rumble,6483UInt32 duration_ms6484);6485
6486/* gamecontroller refers to an SDL_GameController* */6487[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6488public static extern void SDL_GameControllerClose(6489IntPtr gamecontroller6490);6491
6492/* int refers to an SDL_JoystickID, IntPtr to an SDL_GameController*.6493* Only available in 2.0.4 or higher.
6494*/
6495[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6496public static extern IntPtr SDL_GameControllerFromInstanceID(int joyid);6497
6498/* Only available in 2.0.11 or higher. */6499[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6500public static extern SDL_GameControllerType SDL_GameControllerTypeForIndex(6501int joystick_index6502);6503
6504/* IntPtr refers to an SDL_GameController*.6505* Only available in 2.0.11 or higher.
6506*/
6507[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6508public static extern SDL_GameControllerType SDL_GameControllerGetType(6509IntPtr gamecontroller6510);6511
6512/* IntPtr refers to an SDL_GameController*.6513* Only available in 2.0.11 or higher.
6514*/
6515[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6516public static extern IntPtr SDL_GameControllerFromPlayerIndex(6517int player_index6518);6519
6520/* IntPtr refers to an SDL_GameController*.6521* Only available in 2.0.11 or higher.
6522*/
6523[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6524public static extern void SDL_GameControllerSetPlayerIndex(6525IntPtr gamecontroller,6526int player_index6527);6528
6529#endregion6530
6531#region SDL_haptic.h6532
6533/* SDL_HapticEffect type */6534public const ushort SDL_HAPTIC_CONSTANT = (1 << 0);6535public const ushort SDL_HAPTIC_SINE = (1 << 1);6536public const ushort SDL_HAPTIC_LEFTRIGHT = (1 << 2);6537public const ushort SDL_HAPTIC_TRIANGLE = (1 << 3);6538public const ushort SDL_HAPTIC_SAWTOOTHUP = (1 << 4);6539public const ushort SDL_HAPTIC_SAWTOOTHDOWN = (1 << 5);6540public const ushort SDL_HAPTIC_SPRING = (1 << 7);6541public const ushort SDL_HAPTIC_DAMPER = (1 << 8);6542public const ushort SDL_HAPTIC_INERTIA = (1 << 9);6543public const ushort SDL_HAPTIC_FRICTION = (1 << 10);6544public const ushort SDL_HAPTIC_CUSTOM = (1 << 11);6545public const ushort SDL_HAPTIC_GAIN = (1 << 12);6546public const ushort SDL_HAPTIC_AUTOCENTER = (1 << 13);6547public const ushort SDL_HAPTIC_STATUS = (1 << 14);6548public const ushort SDL_HAPTIC_PAUSE = (1 << 15);6549
6550/* SDL_HapticDirection type */6551public const byte SDL_HAPTIC_POLAR = 0;6552public const byte SDL_HAPTIC_CARTESIAN = 1;6553public const byte SDL_HAPTIC_SPHERICAL = 2;6554
6555/* SDL_HapticRunEffect */6556public const uint SDL_HAPTIC_INFINITY = 4294967295U;6557
6558[StructLayout(LayoutKind.Sequential)]6559public struct SDL_HapticDirection6560{6561public byte type;6562[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]6563public int[] dir;6564}6565
6566[StructLayout(LayoutKind.Sequential)]6567public struct SDL_HapticConstant6568{6569// Header6570public ushort type;6571public SDL_HapticDirection direction;6572// Replay6573public uint length;6574public ushort delay;6575// Trigger6576public ushort button;6577public ushort interval;6578// Constant6579public short level;6580// Envelope6581public ushort attack_length;6582public ushort attack_level;6583public ushort fade_length;6584public ushort fade_level;6585}6586
6587[StructLayout(LayoutKind.Sequential)]6588public struct SDL_HapticPeriodic6589{6590// Header6591public ushort type;6592public SDL_HapticDirection direction;6593// Replay6594public uint length;6595public ushort delay;6596// Trigger6597public ushort button;6598public ushort interval;6599// Periodic6600public ushort period;6601public short magnitude;6602public short offset;6603public ushort phase;6604// Envelope6605public ushort attack_length;6606public ushort attack_level;6607public ushort fade_length;6608public ushort fade_level;6609}6610
6611[StructLayout(LayoutKind.Sequential)]6612public struct SDL_HapticCondition6613{6614// Header6615public ushort type;6616public SDL_HapticDirection direction;6617// Replay6618public uint length;6619public ushort delay;6620// Trigger6621public ushort button;6622public ushort interval;6623// Condition6624[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]6625public ushort[] right_sat;6626[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]6627public ushort[] left_sat;6628[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]6629public short[] right_coeff;6630[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]6631public short[] left_coeff;6632[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]6633public ushort[] deadband;6634[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]6635public short[] center;6636}6637
6638[StructLayout(LayoutKind.Sequential)]6639public struct SDL_HapticRamp6640{6641// Header6642public ushort type;6643public SDL_HapticDirection direction;6644// Replay6645public uint length;6646public ushort delay;6647// Trigger6648public ushort button;6649public ushort interval;6650// Ramp6651public short start;6652public short end;6653// Envelope6654public ushort attack_length;6655public ushort attack_level;6656public ushort fade_length;6657public ushort fade_level;6658}6659
6660[StructLayout(LayoutKind.Sequential)]6661public struct SDL_HapticLeftRight6662{6663// Header6664public ushort type;6665// Replay6666public uint length;6667// Rumble6668public ushort large_magnitude;6669public ushort small_magnitude;6670}6671
6672[StructLayout(LayoutKind.Sequential)]6673public struct SDL_HapticCustom6674{6675// Header6676public ushort type;6677public SDL_HapticDirection direction;6678// Replay6679public uint length;6680public ushort delay;6681// Trigger6682public ushort button;6683public ushort interval;6684// Custom6685public byte channels;6686public ushort period;6687public ushort samples;6688public IntPtr data; // Uint16*6689// Envelope6690public ushort attack_length;6691public ushort attack_level;6692public ushort fade_length;6693public ushort fade_level;6694}6695
6696[StructLayout(LayoutKind.Explicit)]6697public struct SDL_HapticEffect6698{6699[FieldOffset(0)]6700public ushort type;6701[FieldOffset(0)]6702public SDL_HapticConstant constant;6703[FieldOffset(0)]6704public SDL_HapticPeriodic periodic;6705[FieldOffset(0)]6706public SDL_HapticCondition condition;6707[FieldOffset(0)]6708public SDL_HapticRamp ramp;6709[FieldOffset(0)]6710public SDL_HapticLeftRight leftright;6711[FieldOffset(0)]6712public SDL_HapticCustom custom;6713}6714
6715/* haptic refers to an SDL_Haptic* */6716[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6717public static extern void SDL_HapticClose(IntPtr haptic);6718
6719/* haptic refers to an SDL_Haptic* */6720[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6721public static extern void SDL_HapticDestroyEffect(6722IntPtr haptic,6723int effect6724);6725
6726/* haptic refers to an SDL_Haptic* */6727[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6728public static extern int SDL_HapticEffectSupported(6729IntPtr haptic,6730ref SDL_HapticEffect effect6731);6732
6733/* haptic refers to an SDL_Haptic* */6734[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6735public static extern int SDL_HapticGetEffectStatus(6736IntPtr haptic,6737int effect6738);6739
6740/* haptic refers to an SDL_Haptic* */6741[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6742public static extern int SDL_HapticIndex(IntPtr haptic);6743
6744/* haptic refers to an SDL_Haptic* */6745[DllImport(nativeLibName, EntryPoint = "SDL_HapticName", CallingConvention = CallingConvention.Cdecl)]6746private static extern IntPtr INTERNAL_SDL_HapticName(int device_index);6747public static string SDL_HapticName(int device_index)6748{6749return UTF8_ToManaged(INTERNAL_SDL_HapticName(device_index));6750}6751
6752/* haptic refers to an SDL_Haptic* */6753[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6754public static extern int SDL_HapticNewEffect(6755IntPtr haptic,6756ref SDL_HapticEffect effect6757);6758
6759/* haptic refers to an SDL_Haptic* */6760[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6761public static extern int SDL_HapticNumAxes(IntPtr haptic);6762
6763/* haptic refers to an SDL_Haptic* */6764[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6765public static extern int SDL_HapticNumEffects(IntPtr haptic);6766
6767/* haptic refers to an SDL_Haptic* */6768[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6769public static extern int SDL_HapticNumEffectsPlaying(IntPtr haptic);6770
6771/* IntPtr refers to an SDL_Haptic* */6772[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6773public static extern IntPtr SDL_HapticOpen(int device_index);6774
6775[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6776public static extern int SDL_HapticOpened(int device_index);6777
6778/* IntPtr refers to an SDL_Haptic*, joystick to an SDL_Joystick* */6779[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6780public static extern IntPtr SDL_HapticOpenFromJoystick(6781IntPtr joystick6782);6783
6784/* IntPtr refers to an SDL_Haptic* */6785[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6786public static extern IntPtr SDL_HapticOpenFromMouse();6787
6788/* haptic refers to an SDL_Haptic* */6789[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6790public static extern int SDL_HapticPause(IntPtr haptic);6791
6792/* haptic refers to an SDL_Haptic* */6793[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6794public static extern uint SDL_HapticQuery(IntPtr haptic);6795
6796/* haptic refers to an SDL_Haptic* */6797[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6798public static extern int SDL_HapticRumbleInit(IntPtr haptic);6799
6800/* haptic refers to an SDL_Haptic* */6801[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6802public static extern int SDL_HapticRumblePlay(6803IntPtr haptic,6804float strength,6805uint length6806);6807
6808/* haptic refers to an SDL_Haptic* */6809[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6810public static extern int SDL_HapticRumbleStop(IntPtr haptic);6811
6812/* haptic refers to an SDL_Haptic* */6813[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6814public static extern int SDL_HapticRumbleSupported(IntPtr haptic);6815
6816/* haptic refers to an SDL_Haptic* */6817[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6818public static extern int SDL_HapticRunEffect(6819IntPtr haptic,6820int effect,6821uint iterations6822);6823
6824/* haptic refers to an SDL_Haptic* */6825[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6826public static extern int SDL_HapticSetAutocenter(6827IntPtr haptic,6828int autocenter6829);6830
6831/* haptic refers to an SDL_Haptic* */6832[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6833public static extern int SDL_HapticSetGain(6834IntPtr haptic,6835int gain6836);6837
6838/* haptic refers to an SDL_Haptic* */6839[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6840public static extern int SDL_HapticStopAll(IntPtr haptic);6841
6842/* haptic refers to an SDL_Haptic* */6843[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6844public static extern int SDL_HapticStopEffect(6845IntPtr haptic,6846int effect6847);6848
6849/* haptic refers to an SDL_Haptic* */6850[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6851public static extern int SDL_HapticUnpause(IntPtr haptic);6852
6853/* haptic refers to an SDL_Haptic* */6854[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6855public static extern int SDL_HapticUpdateEffect(6856IntPtr haptic,6857int effect,6858ref SDL_HapticEffect data6859);6860
6861/* joystick refers to an SDL_Joystick* */6862[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6863public static extern int SDL_JoystickIsHaptic(IntPtr joystick);6864
6865[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6866public static extern int SDL_MouseIsHaptic();6867
6868[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6869public static extern int SDL_NumHaptics();6870
6871#endregion6872
6873#region SDL_sensor.h6874
6875/* This region is only available in 2.0.9 or higher. */6876
6877public enum SDL_SensorType6878{6879SDL_SENSOR_INVALID = -1,6880SDL_SENSOR_UNKNOWN,6881SDL_SENSOR_ACCEL,6882SDL_SENSOR_GYRO
6883}6884
6885public const float SDL_STANDARD_GRAVITY = 9.80665f;6886
6887[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6888public static extern int SDL_NumSensors();6889
6890[DllImport(nativeLibName, EntryPoint = "SDL_SensorGetDeviceName", CallingConvention = CallingConvention.Cdecl)]6891private static extern IntPtr INTERNAL_SDL_SensorGetDeviceName(int device_index);6892public static string SDL_SensorGetDeviceName(int device_index)6893{6894return UTF8_ToManaged(INTERNAL_SDL_SensorGetDeviceName(device_index));6895}6896
6897[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6898public static extern SDL_SensorType SDL_SensorGetDeviceType(int device_index);6899
6900[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6901public static extern int SDL_SensorGetDeviceNonPortableType(int device_index);6902
6903[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6904public static extern Int32 SDL_SensorGetDeviceInstanceID(int device_index);6905
6906/* IntPtr refers to an SDL_Sensor* */6907[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6908public static extern IntPtr SDL_SensorOpen(int device_index);6909
6910/* IntPtr refers to an SDL_Sensor* */6911[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6912public static extern IntPtr SDL_SensorFromInstanceID(6913Int32 instance_id6914);6915
6916/* sensor refers to an SDL_Sensor* */6917[DllImport(nativeLibName, EntryPoint = "SDL_SensorGetName", CallingConvention = CallingConvention.Cdecl)]6918private static extern IntPtr INTERNAL_SDL_SensorGetName(IntPtr sensor);6919public static string SDL_SensorGetName(IntPtr sensor)6920{6921return UTF8_ToManaged(INTERNAL_SDL_SensorGetName(sensor));6922}6923
6924/* sensor refers to an SDL_Sensor* */6925[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6926public static extern SDL_SensorType SDL_SensorGetType(IntPtr sensor);6927
6928/* sensor refers to an SDL_Sensor* */6929[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6930public static extern int SDL_SensorGetNonPortableType(IntPtr sensor);6931
6932/* sensor refers to an SDL_Sensor* */6933[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6934public static extern Int32 SDL_SensorGetInstanceID(IntPtr sensor);6935
6936/* sensor refers to an SDL_Sensor* */6937[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6938public static extern int SDL_SensorGetData(6939IntPtr sensor,6940float[] data,6941int num_values6942);6943
6944/* sensor refers to an SDL_Sensor* */6945[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6946public static extern void SDL_SensorClose(IntPtr sensor);6947
6948[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]6949public static extern void SDL_SensorUpdate();6950
6951#endregion6952
6953#region SDL_audio.h6954
6955public const ushort SDL_AUDIO_MASK_BITSIZE = 0xFF;6956public const ushort SDL_AUDIO_MASK_DATATYPE = (1 << 8);6957public const ushort SDL_AUDIO_MASK_ENDIAN = (1 << 12);6958public const ushort SDL_AUDIO_MASK_SIGNED = (1 << 15);6959
6960public static ushort SDL_AUDIO_BITSIZE(ushort x)6961{6962return (ushort)(x & SDL_AUDIO_MASK_BITSIZE);6963}6964
6965public static bool SDL_AUDIO_ISFLOAT(ushort x)6966{6967return (x & SDL_AUDIO_MASK_DATATYPE) != 0;6968}6969
6970public static bool SDL_AUDIO_ISBIGENDIAN(ushort x)6971{6972return (x & SDL_AUDIO_MASK_ENDIAN) != 0;6973}6974
6975public static bool SDL_AUDIO_ISSIGNED(ushort x)6976{6977return (x & SDL_AUDIO_MASK_SIGNED) != 0;6978}6979
6980public static bool SDL_AUDIO_ISINT(ushort x)6981{6982return (x & SDL_AUDIO_MASK_DATATYPE) == 0;6983}6984
6985public static bool SDL_AUDIO_ISLITTLEENDIAN(ushort x)6986{6987return (x & SDL_AUDIO_MASK_ENDIAN) == 0;6988}6989
6990public static bool SDL_AUDIO_ISUNSIGNED(ushort x)6991{6992return (x & SDL_AUDIO_MASK_SIGNED) == 0;6993}6994
6995public const ushort AUDIO_U8 = 0x0008;6996public const ushort AUDIO_S8 = 0x8008;6997public const ushort AUDIO_U16LSB = 0x0010;6998public const ushort AUDIO_S16LSB = 0x8010;6999public const ushort AUDIO_U16MSB = 0x1010;7000public const ushort AUDIO_S16MSB = 0x9010;7001public const ushort AUDIO_U16 = AUDIO_U16LSB;7002public const ushort AUDIO_S16 = AUDIO_S16LSB;7003public const ushort AUDIO_S32LSB = 0x8020;7004public const ushort AUDIO_S32MSB = 0x9020;7005public const ushort AUDIO_S32 = AUDIO_S32LSB;7006public const ushort AUDIO_F32LSB = 0x8120;7007public const ushort AUDIO_F32MSB = 0x9120;7008public const ushort AUDIO_F32 = AUDIO_F32LSB;7009
7010public static readonly ushort AUDIO_U16SYS =7011BitConverter.IsLittleEndian ? AUDIO_U16LSB : AUDIO_U16MSB;7012public static readonly ushort AUDIO_S16SYS =7013BitConverter.IsLittleEndian ? AUDIO_S16LSB : AUDIO_S16MSB;7014public static readonly ushort AUDIO_S32SYS =7015BitConverter.IsLittleEndian ? AUDIO_S32LSB : AUDIO_S32MSB;7016public static readonly ushort AUDIO_F32SYS =7017BitConverter.IsLittleEndian ? AUDIO_F32LSB : AUDIO_F32MSB;7018
7019public const uint SDL_AUDIO_ALLOW_FREQUENCY_CHANGE = 0x00000001;7020public const uint SDL_AUDIO_ALLOW_FORMAT_CHANGE = 0x00000002;7021public const uint SDL_AUDIO_ALLOW_CHANNELS_CHANGE = 0x00000004;7022public const uint SDL_AUDIO_ALLOW_SAMPLES_CHANGE = 0x00000008;7023public const uint SDL_AUDIO_ALLOW_ANY_CHANGE = (7024SDL_AUDIO_ALLOW_FREQUENCY_CHANGE |7025SDL_AUDIO_ALLOW_FORMAT_CHANGE |7026SDL_AUDIO_ALLOW_CHANNELS_CHANGE |7027SDL_AUDIO_ALLOW_SAMPLES_CHANGE
7028);7029
7030public const int SDL_MIX_MAXVOLUME = 128;7031
7032public enum SDL_AudioStatus7033{7034SDL_AUDIO_STOPPED,7035SDL_AUDIO_PLAYING,7036SDL_AUDIO_PAUSED
7037}7038
7039[StructLayout(LayoutKind.Sequential)]7040public struct SDL_AudioSpec7041{7042public int freq;7043public ushort format; // SDL_AudioFormat7044public byte channels;7045public byte silence;7046public ushort samples;7047public uint size;7048public SDL_AudioCallback callback;7049public IntPtr userdata; // void*7050}7051
7052/* userdata refers to a void*, stream to a Uint8 */7053[UnmanagedFunctionPointer(CallingConvention.Cdecl)]7054public delegate void SDL_AudioCallback(7055IntPtr userdata,7056IntPtr stream,7057int len7058);7059
7060[DllImport(nativeLibName, EntryPoint = "SDL_AudioInit", CallingConvention = CallingConvention.Cdecl)]7061private static extern int INTERNAL_SDL_AudioInit(7062byte[] driver_name7063);7064public static int SDL_AudioInit(string driver_name)7065{7066return INTERNAL_SDL_AudioInit(7067UTF8_ToNative(driver_name)7068);7069}7070
7071[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7072public static extern void SDL_AudioQuit();7073
7074[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7075public static extern void SDL_CloseAudio();7076
7077/* dev refers to an SDL_AudioDeviceID */7078[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7079public static extern void SDL_CloseAudioDevice(uint dev);7080
7081/* audio_buf refers to a malloc()'d buffer from SDL_LoadWAV */7082[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7083public static extern void SDL_FreeWAV(IntPtr audio_buf);7084
7085[DllImport(nativeLibName, EntryPoint = "SDL_GetAudioDeviceName", CallingConvention = CallingConvention.Cdecl)]7086private static extern IntPtr INTERNAL_SDL_GetAudioDeviceName(7087int index,7088int iscapture7089);7090public static string SDL_GetAudioDeviceName(7091int index,7092int iscapture7093)7094{7095return UTF8_ToManaged(7096INTERNAL_SDL_GetAudioDeviceName(index, iscapture)7097);7098}7099
7100/* dev refers to an SDL_AudioDeviceID */7101[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7102public static extern SDL_AudioStatus SDL_GetAudioDeviceStatus(7103uint dev7104);7105
7106[DllImport(nativeLibName, EntryPoint = "SDL_GetAudioDriver", CallingConvention = CallingConvention.Cdecl)]7107private static extern IntPtr INTERNAL_SDL_GetAudioDriver(int index);7108public static string SDL_GetAudioDriver(int index)7109{7110return UTF8_ToManaged(7111INTERNAL_SDL_GetAudioDriver(index)7112);7113}7114
7115[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7116public static extern SDL_AudioStatus SDL_GetAudioStatus();7117
7118[DllImport(nativeLibName, EntryPoint = "SDL_GetCurrentAudioDriver", CallingConvention = CallingConvention.Cdecl)]7119private static extern IntPtr INTERNAL_SDL_GetCurrentAudioDriver();7120public static string SDL_GetCurrentAudioDriver()7121{7122return UTF8_ToManaged(INTERNAL_SDL_GetCurrentAudioDriver());7123}7124
7125[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7126public static extern int SDL_GetNumAudioDevices(int iscapture);7127
7128[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7129public static extern int SDL_GetNumAudioDrivers();7130
7131/* audio_buf will refer to a malloc()'d byte buffer */7132/* THIS IS AN RWops FUNCTION! */7133[DllImport(nativeLibName, EntryPoint = "SDL_LoadWAV_RW", CallingConvention = CallingConvention.Cdecl)]7134private static extern IntPtr INTERNAL_SDL_LoadWAV_RW(7135IntPtr src,7136int freesrc,7137ref SDL_AudioSpec spec,7138out IntPtr audio_buf,7139out uint audio_len7140);7141public static SDL_AudioSpec SDL_LoadWAV(7142string file,7143ref SDL_AudioSpec spec,7144out IntPtr audio_buf,7145out uint audio_len7146)7147{7148SDL_AudioSpec result;7149IntPtr rwops = SDL_RWFromFile(file, "rb");7150IntPtr result_ptr = INTERNAL_SDL_LoadWAV_RW(7151rwops,71521,7153ref spec,7154out audio_buf,7155out audio_len7156);7157result = (SDL_AudioSpec)Marshal.PtrToStructure(7158result_ptr,7159typeof(SDL_AudioSpec)7160);7161return result;7162}7163
7164[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7165public static extern void SDL_LockAudio();7166
7167/* dev refers to an SDL_AudioDeviceID */7168[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7169public static extern void SDL_LockAudioDevice(uint dev);7170
7171[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7172public static extern void SDL_MixAudio(7173[Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 2)]7174byte[] dst,7175[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 2)]7176byte[] src,7177uint len,7178int volume7179);7180
7181/* format refers to an SDL_AudioFormat */7182[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7183public static extern void SDL_MixAudioFormat(7184[Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 3)]7185byte[] dst,7186[In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 3)]7187byte[] src,7188ushort format,7189uint len,7190int volume7191);7192
7193[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7194public static extern int SDL_OpenAudio(7195ref SDL_AudioSpec desired,7196out SDL_AudioSpec obtained7197);7198
7199[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7200public static extern int SDL_OpenAudio(7201ref SDL_AudioSpec desired,7202IntPtr obtained7203);7204
7205/* uint refers to an SDL_AudioDeviceID */7206[DllImport(nativeLibName, EntryPoint = "SDL_OpenAudioDevice", CallingConvention = CallingConvention.Cdecl)]7207private static extern uint INTERNAL_SDL_OpenAudioDevice(7208byte[] device,7209int iscapture,7210ref SDL_AudioSpec desired,7211out SDL_AudioSpec obtained,7212int allowed_changes7213);7214public static uint SDL_OpenAudioDevice(7215string device,7216int iscapture,7217ref SDL_AudioSpec desired,7218out SDL_AudioSpec obtained,7219int allowed_changes7220)7221{7222return INTERNAL_SDL_OpenAudioDevice(7223UTF8_ToNative(device),7224iscapture,7225ref desired,7226out obtained,7227allowed_changes
7228);7229}7230
7231[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7232public static extern void SDL_PauseAudio(int pause_on);7233
7234/* dev refers to an SDL_AudioDeviceID */7235[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7236public static extern void SDL_PauseAudioDevice(7237uint dev,7238int pause_on7239);7240
7241[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7242public static extern void SDL_UnlockAudio();7243
7244/* dev refers to an SDL_AudioDeviceID */7245[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7246public static extern void SDL_UnlockAudioDevice(uint dev);7247
7248/* dev refers to an SDL_AudioDeviceID, data to a void*7249* Only available in 2.0.4 or higher.
7250*/
7251[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7252public static extern int SDL_QueueAudio(7253uint dev,7254IntPtr data,7255UInt32 len7256);7257
7258/* dev refers to an SDL_AudioDeviceID, data to a void*7259* Only available in 2.0.5 or higher.
7260*/
7261[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7262public static extern uint SDL_DequeueAudio(7263uint dev,7264IntPtr data,7265uint len7266);7267
7268/* dev refers to an SDL_AudioDeviceID7269* Only available in 2.0.4 or higher.
7270*/
7271[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7272public static extern UInt32 SDL_GetQueuedAudioSize(uint dev);7273
7274/* dev refers to an SDL_AudioDeviceID7275* Only available in 2.0.4 or higher.
7276*/
7277[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7278public static extern void SDL_ClearQueuedAudio(uint dev);7279
7280/* src_format and dst_format refer to SDL_AudioFormats.7281* IntPtr refers to an SDL_AudioStream*.
7282* Only available in 2.0.7 or higher.
7283*/
7284[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7285public static extern IntPtr SDL_NewAudioStream(7286ushort src_format,7287byte src_channels,7288int src_rate,7289ushort dst_format,7290byte dst_channels,7291int dst_rate7292);7293
7294/* stream refers to an SDL_AudioStream*, buf to a void*.7295* Only available in 2.0.7 or higher.
7296*/
7297[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7298public static extern int SDL_AudioStreamPut(7299IntPtr stream,7300IntPtr buf,7301int len7302);7303
7304/* stream refers to an SDL_AudioStream*, buf to a void*.7305* Only available in 2.0.7 or higher.
7306*/
7307[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7308public static extern int SDL_AudioStreamGet(7309IntPtr stream,7310IntPtr buf,7311int len7312);7313
7314/* stream refers to an SDL_AudioStream*.7315* Only available in 2.0.7 or higher.
7316*/
7317[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7318public static extern int SDL_AudioStreamAvailable(IntPtr stream);7319
7320/* stream refers to an SDL_AudioStream*.7321* Only available in 2.0.7 or higher.
7322*/
7323[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7324public static extern void SDL_AudioStreamClear(IntPtr stream);7325
7326/* stream refers to an SDL_AudioStream*.7327* Only available in 2.0.7 or higher.
7328*/
7329[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7330public static extern void SDL_FreeAudioStream(IntPtr stream);7331
7332#endregion7333
7334#region SDL_timer.h7335
7336/* System timers rely on different OS mechanisms depending on7337* which operating system SDL2 is compiled against.
7338*/
7339
7340/* Compare tick values, return true if A has passed B. Introduced in SDL 2.0.1,7341* but does not require it (it was a macro).
7342*/
7343public static bool SDL_TICKS_PASSED(UInt32 A, UInt32 B)7344{7345return ((Int32)(B - A) <= 0);7346}7347
7348/* Delays the thread's processing based on the milliseconds parameter */7349[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7350public static extern void SDL_Delay(UInt32 ms);7351
7352/* Returns the milliseconds that have passed since SDL was initialized */7353[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7354public static extern UInt32 SDL_GetTicks();7355
7356/* Get the current value of the high resolution counter */7357[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7358public static extern UInt64 SDL_GetPerformanceCounter();7359
7360/* Get the count per second of the high resolution counter */7361[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7362public static extern UInt64 SDL_GetPerformanceFrequency();7363
7364/* param refers to a void* */7365[UnmanagedFunctionPointer(CallingConvention.Cdecl)]7366public delegate UInt32 SDL_TimerCallback(UInt32 interval, IntPtr param);7367
7368/* int refers to an SDL_TimerID, param to a void* */7369[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7370public static extern int SDL_AddTimer(7371UInt32 interval,7372SDL_TimerCallback callback,7373IntPtr param7374);7375
7376/* id refers to an SDL_TimerID */7377[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7378public static extern SDL_bool SDL_RemoveTimer(int id);7379
7380#endregion7381
7382#region SDL_system.h7383
7384/* Windows */7385
7386[UnmanagedFunctionPointer(CallingConvention.Cdecl)]7387public delegate IntPtr SDL_WindowsMessageHook(7388IntPtr userdata,7389IntPtr hWnd,7390uint message,7391ulong wParam,7392long lParam7393);7394
7395[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7396public static extern void SDL_SetWindowsMessageHook(7397SDL_WindowsMessageHook callback,7398IntPtr userdata7399);7400
7401/* iOS */7402
7403[UnmanagedFunctionPointer(CallingConvention.Cdecl)]7404public delegate void SDL_iPhoneAnimationCallback(IntPtr p);7405
7406[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7407public static extern int SDL_iPhoneSetAnimationCallback(7408IntPtr window, /* SDL_Window* */7409int interval,7410SDL_iPhoneAnimationCallback callback,7411IntPtr callbackParam7412);7413
7414[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7415public static extern void SDL_iPhoneSetEventPump(SDL_bool enabled);7416
7417/* Android */7418
7419public const int SDL_ANDROID_EXTERNAL_STORAGE_READ = 0x01;7420public const int SDL_ANDROID_EXTERNAL_STORAGE_WRITE = 0x02;7421
7422/* IntPtr refers to a JNIEnv* */7423[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7424public static extern IntPtr SDL_AndroidGetJNIEnv();7425
7426/* IntPtr refers to a jobject */7427[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7428public static extern IntPtr SDL_AndroidGetActivity();7429
7430[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7431public static extern SDL_bool SDL_IsAndroidTV();7432
7433[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7434public static extern SDL_bool SDL_IsChromebook();7435
7436[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7437public static extern SDL_bool SDL_IsDeXMode();7438
7439[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7440public static extern void SDL_AndroidBackButton();7441
7442[DllImport(nativeLibName, EntryPoint = "SDL_AndroidGetInternalStoragePath", CallingConvention = CallingConvention.Cdecl)]7443private static extern IntPtr INTERNAL_SDL_AndroidGetInternalStoragePath();7444
7445public static string SDL_AndroidGetInternalStoragePath()7446{7447return UTF8_ToManaged(7448INTERNAL_SDL_AndroidGetInternalStoragePath()7449);7450}7451
7452[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7453public static extern int SDL_AndroidGetExternalStorageState();7454
7455[DllImport(nativeLibName, EntryPoint = "SDL_AndroidGetExternalStorageState", CallingConvention = CallingConvention.Cdecl)]7456private static extern IntPtr INTERNAL_SDL_AndroidGetExternalStoragePath();7457
7458public static string SDL_AndroidGetExternalStoragePath()7459{7460return UTF8_ToManaged(7461INTERNAL_SDL_AndroidGetExternalStoragePath()7462);7463}7464
7465[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7466public static extern int SDL_GetAndroidSDKVersion();7467
7468/* WinRT */7469
7470public enum SDL_WinRT_DeviceFamily7471{7472SDL_WINRT_DEVICEFAMILY_UNKNOWN,7473SDL_WINRT_DEVICEFAMILY_DESKTOP,7474SDL_WINRT_DEVICEFAMILY_MOBILE,7475SDL_WINRT_DEVICEFAMILY_XBOX
7476}7477
7478[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7479public static extern SDL_WinRT_DeviceFamily SDL_WinRTGetDeviceFamily();7480
7481[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7482public static extern SDL_bool SDL_IsTablet();7483
7484#endregion7485
7486#region SDL_syswm.h7487
7488public enum SDL_SYSWM_TYPE7489{7490SDL_SYSWM_UNKNOWN,7491SDL_SYSWM_WINDOWS,7492SDL_SYSWM_X11,7493SDL_SYSWM_DIRECTFB,7494SDL_SYSWM_COCOA,7495SDL_SYSWM_UIKIT,7496SDL_SYSWM_WAYLAND,7497SDL_SYSWM_MIR,7498SDL_SYSWM_WINRT,7499SDL_SYSWM_ANDROID,7500SDL_SYSWM_VIVANTE,7501SDL_SYSWM_OS2,7502SDL_SYSWM_HAIKU
7503}7504
7505// FIXME: I wish these weren't public...7506[StructLayout(LayoutKind.Sequential)]7507public struct INTERNAL_windows_wminfo7508{7509public IntPtr window; // Refers to an HWND7510public IntPtr hdc; // Refers to an HDC7511public IntPtr hinstance; // Refers to an HINSTANCE7512}7513
7514[StructLayout(LayoutKind.Sequential)]7515public struct INTERNAL_winrt_wminfo7516{7517public IntPtr window; // Refers to an IInspectable*7518}7519
7520[StructLayout(LayoutKind.Sequential)]7521public struct INTERNAL_x11_wminfo7522{7523public IntPtr display; // Refers to a Display*7524public IntPtr window; // Refers to a Window (XID, use ToInt64!)7525}7526
7527[StructLayout(LayoutKind.Sequential)]7528public struct INTERNAL_directfb_wminfo7529{7530public IntPtr dfb; // Refers to an IDirectFB*7531public IntPtr window; // Refers to an IDirectFBWindow*7532public IntPtr surface; // Refers to an IDirectFBSurface*7533}7534
7535[StructLayout(LayoutKind.Sequential)]7536public struct INTERNAL_cocoa_wminfo7537{7538public IntPtr window; // Refers to an NSWindow*7539}7540
7541[StructLayout(LayoutKind.Sequential)]7542public struct INTERNAL_uikit_wminfo7543{7544public IntPtr window; // Refers to a UIWindow*7545public uint framebuffer;7546public uint colorbuffer;7547public uint resolveFramebuffer;7548}7549
7550[StructLayout(LayoutKind.Sequential)]7551public struct INTERNAL_wayland_wminfo7552{7553public IntPtr display; // Refers to a wl_display*7554public IntPtr surface; // Refers to a wl_surface*7555public IntPtr shell_surface; // Refers to a wl_shell_surface*7556}7557
7558[StructLayout(LayoutKind.Sequential)]7559public struct INTERNAL_mir_wminfo7560{7561public IntPtr connection; // Refers to a MirConnection*7562public IntPtr surface; // Refers to a MirSurface*7563}7564
7565[StructLayout(LayoutKind.Sequential)]7566public struct INTERNAL_android_wminfo7567{7568public IntPtr window; // Refers to an ANativeWindow7569public IntPtr surface; // Refers to an EGLSurface7570}7571
7572[StructLayout(LayoutKind.Sequential)]7573public struct INTERNAL_vivante_wminfo7574{7575public IntPtr display; // Refers to an EGLNativeDisplayType7576public IntPtr window; // Refers to an EGLNativeWindowType7577}7578
7579[StructLayout(LayoutKind.Explicit)]7580public struct INTERNAL_SysWMDriverUnion7581{7582[FieldOffset(0)]7583public INTERNAL_windows_wminfo win;7584[FieldOffset(0)]7585public INTERNAL_winrt_wminfo winrt;7586[FieldOffset(0)]7587public INTERNAL_x11_wminfo x11;7588[FieldOffset(0)]7589public INTERNAL_directfb_wminfo dfb;7590[FieldOffset(0)]7591public INTERNAL_cocoa_wminfo cocoa;7592[FieldOffset(0)]7593public INTERNAL_uikit_wminfo uikit;7594[FieldOffset(0)]7595public INTERNAL_wayland_wminfo wl;7596[FieldOffset(0)]7597public INTERNAL_mir_wminfo mir;7598[FieldOffset(0)]7599public INTERNAL_android_wminfo android;7600[FieldOffset(0)]7601public INTERNAL_vivante_wminfo vivante;7602// private int dummy;7603}7604
7605[StructLayout(LayoutKind.Sequential)]7606public struct SDL_SysWMinfo7607{7608public SDL_version version;7609public SDL_SYSWM_TYPE subsystem;7610public INTERNAL_SysWMDriverUnion info;7611}7612
7613/* window refers to an SDL_Window* */7614[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7615public static extern SDL_bool SDL_GetWindowWMInfo(7616IntPtr window,7617ref SDL_SysWMinfo info7618);7619
7620#endregion7621
7622#region SDL_filesystem.h7623
7624/* Only available in 2.0.1 or higher. */7625[DllImport(nativeLibName, EntryPoint = "SDL_GetBasePath", CallingConvention = CallingConvention.Cdecl)]7626private static extern IntPtr INTERNAL_SDL_GetBasePath();7627public static string SDL_GetBasePath()7628{7629return UTF8_ToManaged(INTERNAL_SDL_GetBasePath(), true);7630}7631
7632/* Only available in 2.0.1 or higher. */7633[DllImport(nativeLibName, EntryPoint = "SDL_GetPrefPath", CallingConvention = CallingConvention.Cdecl)]7634private static extern IntPtr INTERNAL_SDL_GetPrefPath(7635byte[] org,7636byte[] app7637);7638public static string SDL_GetPrefPath(string org, string app)7639{7640return UTF8_ToManaged(7641INTERNAL_SDL_GetPrefPath(7642UTF8_ToNative(org),7643UTF8_ToNative(app)7644),7645true7646);7647}7648
7649#endregion7650
7651#region SDL_power.h7652
7653public enum SDL_PowerState7654{7655SDL_POWERSTATE_UNKNOWN = 0,7656SDL_POWERSTATE_ON_BATTERY,7657SDL_POWERSTATE_NO_BATTERY,7658SDL_POWERSTATE_CHARGING,7659SDL_POWERSTATE_CHARGED
7660}7661
7662[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7663public static extern SDL_PowerState SDL_GetPowerInfo(7664out int secs,7665out int pct7666);7667
7668#endregion7669
7670#region SDL_cpuinfo.h7671
7672[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7673public static extern int SDL_GetCPUCount();7674
7675[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7676public static extern int SDL_GetCPUCacheLineSize();7677
7678[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7679public static extern SDL_bool SDL_HasRDTSC();7680
7681[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7682public static extern SDL_bool SDL_HasAltiVec();7683
7684[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7685public static extern SDL_bool SDL_HasMMX();7686
7687[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7688public static extern SDL_bool SDL_Has3DNow();7689
7690[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7691public static extern SDL_bool SDL_HasSSE();7692
7693[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7694public static extern SDL_bool SDL_HasSSE2();7695
7696[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7697public static extern SDL_bool SDL_HasSSE3();7698
7699[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7700public static extern SDL_bool SDL_HasSSE41();7701
7702[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7703public static extern SDL_bool SDL_HasSSE42();7704
7705[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7706public static extern SDL_bool SDL_HasAVX();7707
7708[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7709public static extern SDL_bool SDL_HasAVX2();7710
7711[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7712public static extern SDL_bool SDL_HasAVX512F();7713
7714[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7715public static extern SDL_bool SDL_HasNEON();7716
7717/* Only available in 2.0.1 or higher. */7718[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7719public static extern int SDL_GetSystemRAM();7720
7721/* Only available in SDL 2.0.10 or higher. */7722[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7723public static extern uint SDL_SIMDGetAlignment();7724
7725/* Only available in SDL 2.0.10 or higher. */7726[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7727public static extern IntPtr SDL_SIMDAlloc(uint len);7728
7729/* Only available in SDL 2.0.10 or higher. */7730[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7731public static extern void SDL_SIMDFree(IntPtr ptr);7732
7733/* Only available in SDL 2.0.11 or higher. */7734[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]7735public static extern void SDL_HasARMSIMD();7736
7737#endregion7738
7739#region SDL_default_keymap7740public static List<object> SDL_default_keymap = new List<object>()7741{77420, 0, 0, 0,7743'a',7744'b',7745'c',7746'd',7747'e',7748'f',7749'g',7750'h',7751'i',7752'j',7753'k',7754'l',7755'm',7756'n',7757'o',7758'p',7759'q',7760'r',7761's',7762't',7763'u',7764'v',7765'w',7766'x',7767'y',7768'z',7769'1',7770'2',7771'3',7772'4',7773'5',7774'6',7775'7',7776'8',7777'9',7778'0',7779SDL_Keycode.SDLK_RETURN,7780SDL_Keycode.SDLK_ESCAPE,7781SDL_Keycode.SDLK_BACKSPACE,7782SDL_Keycode.SDLK_TAB,7783SDL_Keycode.SDLK_SPACE,7784'-',7785'=',7786'[',7787']',7788'\\',7789'#',7790';',7791'\'',7792'`',7793',',7794'.',7795'/',7796SDL_Keycode.SDLK_CAPSLOCK,7797SDL_Keycode.SDLK_F1,7798SDL_Keycode.SDLK_F2,7799SDL_Keycode.SDLK_F3,7800SDL_Keycode.SDLK_F4,7801SDL_Keycode.SDLK_F5,7802SDL_Keycode.SDLK_F6,7803SDL_Keycode.SDLK_F7,7804SDL_Keycode.SDLK_F8,7805SDL_Keycode.SDLK_F9,7806SDL_Keycode.SDLK_F10,7807SDL_Keycode.SDLK_F11,7808SDL_Keycode.SDLK_F12,7809SDL_Keycode.SDLK_PRINTSCREEN,7810SDL_Keycode.SDLK_SCROLLLOCK,7811SDL_Keycode.SDLK_PAUSE,7812SDL_Keycode.SDLK_INSERT,7813SDL_Keycode.SDLK_HOME,7814SDL_Keycode.SDLK_PAGEUP,7815SDL_Keycode.SDLK_DELETE,7816SDL_Keycode.SDLK_END,7817SDL_Keycode.SDLK_PAGEDOWN,7818SDL_Keycode.SDLK_RIGHT,7819SDL_Keycode.SDLK_LEFT,7820SDL_Keycode.SDLK_DOWN,7821SDL_Keycode.SDLK_UP,7822SDL_Keycode.SDLK_NUMLOCKCLEAR,7823SDL_Keycode.SDLK_KP_DIVIDE,7824SDL_Keycode.SDLK_KP_MULTIPLY,7825SDL_Keycode.SDLK_KP_MINUS,7826SDL_Keycode.SDLK_KP_PLUS,7827SDL_Keycode.SDLK_KP_ENTER,7828SDL_Keycode.SDLK_KP_1,7829SDL_Keycode.SDLK_KP_2,7830SDL_Keycode.SDLK_KP_3,7831SDL_Keycode.SDLK_KP_4,7832SDL_Keycode.SDLK_KP_5,7833SDL_Keycode.SDLK_KP_6,7834SDL_Keycode.SDLK_KP_7,7835SDL_Keycode.SDLK_KP_8,7836SDL_Keycode.SDLK_KP_9,7837SDL_Keycode.SDLK_KP_0,7838SDL_Keycode.SDLK_KP_PERIOD,78390,7840SDL_Keycode.SDLK_APPLICATION,7841SDL_Keycode.SDLK_POWER,7842SDL_Keycode.SDLK_KP_EQUALS,7843SDL_Keycode.SDLK_F13,7844SDL_Keycode.SDLK_F14,7845SDL_Keycode.SDLK_F15,7846SDL_Keycode.SDLK_F16,7847SDL_Keycode.SDLK_F17,7848SDL_Keycode.SDLK_F18,7849SDL_Keycode.SDLK_F19,7850SDL_Keycode.SDLK_F20,7851SDL_Keycode.SDLK_F21,7852SDL_Keycode.SDLK_F22,7853SDL_Keycode.SDLK_F23,7854SDL_Keycode.SDLK_F24,7855SDL_Keycode.SDLK_EXECUTE,7856SDL_Keycode.SDLK_HELP,7857SDL_Keycode.SDLK_MENU,7858SDL_Keycode.SDLK_SELECT,7859SDL_Keycode.SDLK_STOP,7860SDL_Keycode.SDLK_AGAIN,7861SDL_Keycode.SDLK_UNDO,7862SDL_Keycode.SDLK_CUT,7863SDL_Keycode.SDLK_COPY,7864SDL_Keycode.SDLK_PASTE,7865SDL_Keycode.SDLK_FIND,7866SDL_Keycode.SDLK_MUTE,7867SDL_Keycode.SDLK_VOLUMEUP,7868SDL_Keycode.SDLK_VOLUMEDOWN,78690, 0, 0,7870SDL_Keycode.SDLK_KP_COMMA,7871SDL_Keycode.SDLK_KP_EQUALSAS400,78720, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,7873SDL_Keycode.SDLK_ALTERASE,7874SDL_Keycode.SDLK_SYSREQ,7875SDL_Keycode.SDLK_CANCEL,7876SDL_Keycode.SDLK_CLEAR,7877SDL_Keycode.SDLK_PRIOR,7878SDL_Keycode.SDLK_RETURN2,7879SDL_Keycode.SDLK_SEPARATOR,7880SDL_Keycode.SDLK_OUT,7881SDL_Keycode.SDLK_OPER,7882SDL_Keycode.SDLK_CLEARAGAIN,7883SDL_Keycode.SDLK_CRSEL,7884SDL_Keycode.SDLK_EXSEL,78850, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,7886SDL_Keycode.SDLK_KP_00,7887SDL_Keycode.SDLK_KP_000,7888SDL_Keycode.SDLK_THOUSANDSSEPARATOR,7889SDL_Keycode.SDLK_DECIMALSEPARATOR,7890SDL_Keycode.SDLK_CURRENCYUNIT,7891SDL_Keycode.SDLK_CURRENCYSUBUNIT,7892SDL_Keycode.SDLK_KP_LEFTPAREN,7893SDL_Keycode.SDLK_KP_RIGHTPAREN,7894SDL_Keycode.SDLK_KP_LEFTBRACE,7895SDL_Keycode.SDLK_KP_RIGHTBRACE,7896SDL_Keycode.SDLK_KP_TAB,7897SDL_Keycode.SDLK_KP_BACKSPACE,7898SDL_Keycode.SDLK_KP_A,7899SDL_Keycode.SDLK_KP_B,7900SDL_Keycode.SDLK_KP_C,7901SDL_Keycode.SDLK_KP_D,7902SDL_Keycode.SDLK_KP_E,7903SDL_Keycode.SDLK_KP_F,7904SDL_Keycode.SDLK_KP_XOR,7905SDL_Keycode.SDLK_KP_POWER,7906SDL_Keycode.SDLK_KP_PERCENT,7907SDL_Keycode.SDLK_KP_LESS,7908SDL_Keycode.SDLK_KP_GREATER,7909SDL_Keycode.SDLK_KP_AMPERSAND,7910SDL_Keycode.SDLK_KP_DBLAMPERSAND,7911SDL_Keycode.SDLK_KP_VERTICALBAR,7912SDL_Keycode.SDLK_KP_DBLVERTICALBAR,7913SDL_Keycode.SDLK_KP_COLON,7914SDL_Keycode.SDLK_KP_HASH,7915SDL_Keycode.SDLK_KP_SPACE,7916SDL_Keycode.SDLK_KP_AT,7917SDL_Keycode.SDLK_KP_EXCLAM,7918SDL_Keycode.SDLK_KP_MEMSTORE,7919SDL_Keycode.SDLK_KP_MEMRECALL,7920SDL_Keycode.SDLK_KP_MEMCLEAR,7921SDL_Keycode.SDLK_KP_MEMADD,7922SDL_Keycode.SDLK_KP_MEMSUBTRACT,7923SDL_Keycode.SDLK_KP_MEMMULTIPLY,7924SDL_Keycode.SDLK_KP_MEMDIVIDE,7925SDL_Keycode.SDLK_KP_PLUSMINUS,7926SDL_Keycode.SDLK_KP_CLEAR,7927SDL_Keycode.SDLK_KP_CLEARENTRY,7928SDL_Keycode.SDLK_KP_BINARY,7929SDL_Keycode.SDLK_KP_OCTAL,7930SDL_Keycode.SDLK_KP_DECIMAL,7931SDL_Keycode.SDLK_KP_HEXADECIMAL,79320, 0,7933SDL_Keycode.SDLK_LCTRL,7934SDL_Keycode.SDLK_LSHIFT,7935SDL_Keycode.SDLK_LALT,7936SDL_Keycode.SDLK_LGUI,7937SDL_Keycode.SDLK_RCTRL,7938SDL_Keycode.SDLK_RSHIFT,7939SDL_Keycode.SDLK_RALT,7940SDL_Keycode.SDLK_RGUI,79410, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,7942SDL_Keycode.SDLK_MODE,7943SDL_Keycode.SDLK_AUDIONEXT,7944SDL_Keycode.SDLK_AUDIOPREV,7945SDL_Keycode.SDLK_AUDIOSTOP,7946SDL_Keycode.SDLK_AUDIOPLAY,7947SDL_Keycode.SDLK_AUDIOMUTE,7948SDL_Keycode.SDLK_MEDIASELECT,7949SDL_Keycode.SDLK_WWW,7950SDL_Keycode.SDLK_MAIL,7951SDL_Keycode.SDLK_CALCULATOR,7952SDL_Keycode.SDLK_COMPUTER,7953SDL_Keycode.SDLK_AC_SEARCH,7954SDL_Keycode.SDLK_AC_HOME,7955SDL_Keycode.SDLK_AC_BACK,7956SDL_Keycode.SDLK_AC_FORWARD,7957SDL_Keycode.SDLK_AC_STOP,7958SDL_Keycode.SDLK_AC_REFRESH,7959SDL_Keycode.SDLK_AC_BOOKMARKS,7960SDL_Keycode.SDLK_BRIGHTNESSDOWN,7961SDL_Keycode.SDLK_BRIGHTNESSUP,7962SDL_Keycode.SDLK_DISPLAYSWITCH,7963SDL_Keycode.SDLK_KBDILLUMTOGGLE,7964SDL_Keycode.SDLK_KBDILLUMDOWN,7965SDL_Keycode.SDLK_KBDILLUMUP,7966SDL_Keycode.SDLK_EJECT,7967SDL_Keycode.SDLK_SLEEP,7968SDL_Keycode.SDLK_APP1,7969SDL_Keycode.SDLK_APP2,7970SDL_Keycode.SDLK_AUDIOREWIND,7971SDL_Keycode.SDLK_AUDIOFASTFORWARD7972};7973#endregion7974
7975#region SDL_crc167976static ushort crc16_for_byte(byte r)7977{7978ushort crc = 0;7979
7980for (int i = 0; i < 8; ++i)7981{7982if (((crc ^ r) & 1) != 0)7983crc = (ushort)(0xA001 ^ crc >> 1);7984else7985crc = (ushort)(0 ^ crc >> 1);7986
7987r >>= 1;7988}7989return crc;7990}7991
7992public static ushort SDL_crc16(byte[] data, ushort crc = 0)7993{7994// As an optimization we can precalculate a 256 entry table for each byte7995for (int i = 0; i < data.Length; ++i)7996{7997byte bt = (byte) (((byte)crc) ^ data[i]);7998
7999ushort us = crc16_for_byte(bt);8000crc = (ushort)(us ^ crc >> 8);8001}8002return crc;8003}8004
8005public static ushort SDL_Swap16(ushort x)8006{8007return (ushort)((ushort)((x & 0xff) << 8) | ((x >> 8) & 0xff));8008}8009#endregion8010}8011}
8012