1#region License
2/* SDL2# - C# Wrapper for SDL2
3 *
4 * Copyright (c) 2013-2021 Ethan Lee.
5 *
6 * This software is provided 'as-is', without any express or implied warranty.
7 * In no event will the authors be held liable for any damages arising from
8 * the use of this software.
9 *
10 * Permission is granted to anyone to use this software for any purpose,
11 * including commercial applications, and to alter it and redistribute it
12 * freely, subject to the following restrictions:
13 *
14 * 1. The origin of this software must not be misrepresented; you must not
15 * claim that you wrote the original software. If you use this software in a
16 * product, an acknowledgment in the product documentation would be
17 * appreciated but is not required.
18 *
19 * 2. Altered source versions must be plainly marked as such, and must not be
20 * misrepresented as being the original software.
21 *
22 * 3. This notice may not be removed or altered from any source distribution.
23 *
24 * Ethan "flibitijibibo" Lee <flibitijibibo@flibitijibibo.com>
25 *
26 */
27#endregion
28
29#region Using Statements
30using System;
31using System.Diagnostics;
32#if NET6_0_OR_GREATER
33using System.Diagnostics.CodeAnalysis;
34#endif
35using System.Runtime.InteropServices;
36using System.Text;
37#endregion
38
39namespace SDL2
40{
41 public static class SDL
42 {
43 #region SDL2# Variables
44
45 private const string nativeLibName = "SDL2";
46
47 #endregion
48
49 #region Marshaling
50
51#if NET6_0_OR_GREATER
52 internal static T PtrToStructure<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(IntPtr ptr)
53 {
54 return Marshal.PtrToStructure<T>(ptr)!;
55 }
56
57 internal static T GetDelegateForFunctionPointer<T>(IntPtr ptr) where T : Delegate
58 {
59 return Marshal.GetDelegateForFunctionPointer<T>(ptr);
60 }
61#else
62 internal static T PtrToStructure<T>(IntPtr ptr)
63 {
64 return (T) Marshal.PtrToStructure(ptr, typeof(T));
65 }
66
67 internal static Delegate GetDelegateForFunctionPointer<T>(IntPtr ptr)
68 {
69 return Marshal.GetDelegateForFunctionPointer(ptr, typeof(T));
70 }
71#endif
72
73 internal static int SizeOf<T>()
74 {
75#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
76 return Marshal.SizeOf<T>();
77#else
78 return Marshal.SizeOf(typeof(T));
79#endif
80 }
81
82 #endregion
83
84 #region UTF8 Marshaling
85
86 /* Used for stack allocated string marshaling. */
87 internal static int Utf8Size(string str)
88 {
89 if (str == null)
90 {
91 return 0;
92 }
93 return (str.Length * 4) + 1;
94 }
95 internal static unsafe byte* Utf8Encode(string str, byte* buffer, int bufferSize)
96 {
97 if (str == null)
98 {
99 return (byte*) 0;
100 }
101 fixed (char* strPtr = str)
102 {
103 Encoding.UTF8.GetBytes(strPtr, str.Length + 1, buffer, bufferSize);
104 }
105 return buffer;
106 }
107
108 /* Used for heap allocated string marshaling.
109 * Returned byte* must be free'd with FreeHGlobal.
110 */
111 internal static unsafe byte* Utf8EncodeHeap(string str)
112 {
113 if (str == null)
114 {
115 return (byte*) 0;
116 }
117
118 int bufferSize = Utf8Size(str);
119 byte* buffer = (byte*) Marshal.AllocHGlobal(bufferSize);
120 fixed (char* strPtr = str)
121 {
122 Encoding.UTF8.GetBytes(strPtr, str.Length + 1, buffer, bufferSize);
123 }
124 return buffer;
125 }
126
127 /* This is public because SDL_DropEvent needs it! */
128 public static unsafe string UTF8_ToManaged(IntPtr s, bool freePtr = false)
129 {
130 if (s == IntPtr.Zero)
131 {
132 return null!;
133 }
134
135 /* We get to do strlen ourselves! */
136 byte* ptr = (byte*) s;
137 while (*ptr != 0)
138 {
139 ptr++;
140 }
141
142 /* TODO: This #ifdef is only here because the equivalent
143 * .NET 2.0 constructor appears to be less efficient?
144 * Here's the pretty version, maybe steal this instead:
145 *
146 string result = new string(
147 (sbyte*) s, // Also, why sbyte???
148 0,
149 (int) (ptr - (byte*) s),
150 System.Text.Encoding.UTF8
151 );
152 * See the CoreCLR source for more info.
153 * -flibit
154 */
155#if NETSTANDARD2_0
156 /* Modern C# lets you just send the byte*, nice! */
157 string result = System.Text.Encoding.UTF8.GetString(
158 (byte*) s,
159 (int) (ptr - (byte*) s)
160 );
161#else
162 /* Old C# requires an extra memcpy, bleh! */
163 int len = (int) (ptr - (byte*) s);
164 if (len == 0)
165 {
166 return string.Empty;
167 }
168 char* chars = stackalloc char[len];
169 int strLen = System.Text.Encoding.UTF8.GetChars((byte*) s, len, chars, len);
170 string result = new string(chars, 0, strLen);
171#endif
172
173 /* Some SDL functions will malloc, we have to free! */
174 if (freePtr)
175 {
176 SDL_free(s);
177 }
178 return result;
179 }
180
181 #endregion
182
183 #region SDL_stdinc.h
184
185 public static uint SDL_FOURCC(byte A, byte B, byte C, byte D)
186 {
187 return (uint) (A | (B << 8) | (C << 16) | (D << 24));
188 }
189
190 public enum SDL_bool
191 {
192 SDL_FALSE = 0,
193 SDL_TRUE = 1
194 }
195
196 /* malloc/free are used by the marshaler! -flibit */
197
198 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
199 internal static extern IntPtr SDL_malloc(IntPtr size);
200
201 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
202 internal static extern void SDL_free(IntPtr memblock);
203
204 /* Buffer.BlockCopy is not available in every runtime yet. Also,
205 * using memcpy directly can be a compatibility issue in other
206 * strange ways. So, we expose this to get around all that.
207 * -flibit
208 */
209 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
210 public static extern IntPtr SDL_memcpy(IntPtr dst, IntPtr src, IntPtr len);
211
212 #endregion
213
214 #region SDL_rwops.h
215
216 public const int RW_SEEK_SET = 0;
217 public const int RW_SEEK_CUR = 1;
218 public const int RW_SEEK_END = 2;
219
220 public const UInt32 SDL_RWOPS_UNKNOWN = 0; /* Unknown stream type */
221 public const UInt32 SDL_RWOPS_WINFILE = 1; /* Win32 file */
222 public const UInt32 SDL_RWOPS_STDFILE = 2; /* Stdio file */
223 public const UInt32 SDL_RWOPS_JNIFILE = 3; /* Android asset */
224 public const UInt32 SDL_RWOPS_MEMORY = 4; /* Memory stream */
225 public const UInt32 SDL_RWOPS_MEMORY_RO = 5; /* Read-Only memory stream */
226
227 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
228 public delegate long SDLRWopsSizeCallback(IntPtr context);
229
230 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
231 public delegate long SDLRWopsSeekCallback(
232 IntPtr context,
233 long offset,
234 int whence
235 );
236
237 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
238 public delegate IntPtr SDLRWopsReadCallback(
239 IntPtr context,
240 IntPtr ptr,
241 IntPtr size,
242 IntPtr maxnum
243 );
244
245 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
246 public delegate IntPtr SDLRWopsWriteCallback(
247 IntPtr context,
248 IntPtr ptr,
249 IntPtr size,
250 IntPtr num
251 );
252
253 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
254 public delegate int SDLRWopsCloseCallback(
255 IntPtr context
256 );
257
258 [StructLayout(LayoutKind.Sequential)]
259 public struct SDL_RWops
260 {
261 public IntPtr size;
262 public IntPtr seek;
263 public IntPtr read;
264 public IntPtr write;
265 public IntPtr close;
266
267 public UInt32 type;
268
269 /* NOTE: This isn't the full structure since
270 * the native SDL_RWops contains a hidden union full of
271 * internal information and platform-specific stuff depending
272 * on what conditions the native library was built with
273 */
274 }
275
276 /* IntPtr refers to an SDL_RWops* */
277 [DllImport(nativeLibName, EntryPoint = "SDL_RWFromFile", CallingConvention = CallingConvention.Cdecl)]
278 private static extern unsafe IntPtr INTERNAL_SDL_RWFromFile(
279 byte* file,
280 byte* mode
281 );
282 public static unsafe IntPtr SDL_RWFromFile(
283 string file,
284 string mode
285 ) {
286 byte* utf8File = Utf8EncodeHeap(file);
287 byte* utf8Mode = Utf8EncodeHeap(mode);
288 IntPtr rwOps = INTERNAL_SDL_RWFromFile(
289 utf8File,
290 utf8Mode
291 );
292 Marshal.FreeHGlobal((IntPtr) utf8Mode);
293 Marshal.FreeHGlobal((IntPtr) utf8File);
294 return rwOps;
295 }
296
297 /* IntPtr refers to an SDL_RWops* */
298 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
299 public static extern IntPtr SDL_AllocRW();
300
301 /* area refers to an SDL_RWops* */
302 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
303 public static extern void SDL_FreeRW(IntPtr area);
304
305 /* fp refers to a void* */
306 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
307 public static extern IntPtr SDL_RWFromFP(IntPtr fp, SDL_bool autoclose);
308
309 /* mem refers to a void*, IntPtr to an SDL_RWops* */
310 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
311 public static extern IntPtr SDL_RWFromMem(IntPtr mem, int size);
312
313 /* mem refers to a const void*, IntPtr to an SDL_RWops* */
314 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
315 public static extern IntPtr SDL_RWFromConstMem(IntPtr mem, int size);
316
317 /* context refers to an SDL_RWops*.
318 * Only available in SDL 2.0.10 or higher.
319 */
320 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
321 public static extern long SDL_RWsize(IntPtr context);
322
323 /* context refers to an SDL_RWops*.
324 * Only available in SDL 2.0.10 or higher.
325 */
326 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
327 public static extern long SDL_RWseek(
328 IntPtr context,
329 long offset,
330 int whence
331 );
332
333 /* context refers to an SDL_RWops*.
334 * Only available in SDL 2.0.10 or higher.
335 */
336 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
337 public static extern long SDL_RWtell(IntPtr context);
338
339 /* context refers to an SDL_RWops*, ptr refers to a void*.
340 * Only available in SDL 2.0.10 or higher.
341 */
342 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
343 public static extern long SDL_RWread(
344 IntPtr context,
345 IntPtr ptr,
346 IntPtr size,
347 IntPtr maxnum
348 );
349
350 /* context refers to an SDL_RWops*, ptr refers to a const void*.
351 * Only available in SDL 2.0.10 or higher.
352 */
353 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
354 public static extern long SDL_RWwrite(
355 IntPtr context,
356 IntPtr ptr,
357 IntPtr size,
358 IntPtr maxnum
359 );
360
361 /* Read endian functions */
362
363 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
364 public static extern byte SDL_ReadU8(IntPtr src);
365
366 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
367 public static extern UInt16 SDL_ReadLE16(IntPtr src);
368
369 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
370 public static extern UInt16 SDL_ReadBE16(IntPtr src);
371
372 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
373 public static extern UInt32 SDL_ReadLE32(IntPtr src);
374
375 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
376 public static extern UInt32 SDL_ReadBE32(IntPtr src);
377
378 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
379 public static extern UInt64 SDL_ReadLE64(IntPtr src);
380
381 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
382 public static extern UInt64 SDL_ReadBE64(IntPtr src);
383
384 /* Write endian functions */
385
386 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
387 public static extern uint SDL_WriteU8(IntPtr dst, byte value);
388
389 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
390 public static extern uint SDL_WriteLE16(IntPtr dst, UInt16 value);
391
392 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
393 public static extern uint SDL_WriteBE16(IntPtr dst, UInt16 value);
394
395 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
396 public static extern uint SDL_WriteLE32(IntPtr dst, UInt32 value);
397
398 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
399 public static extern uint SDL_WriteBE32(IntPtr dst, UInt32 value);
400
401 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
402 public static extern uint SDL_WriteLE64(IntPtr dst, UInt64 value);
403
404 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
405 public static extern uint SDL_WriteBE64(IntPtr dst, UInt64 value);
406
407 /* context refers to an SDL_RWops*
408 * Only available in SDL 2.0.10 or higher.
409 */
410 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
411 public static extern long SDL_RWclose(IntPtr context);
412
413 /* datasize refers to a size_t*
414 * IntPtr refers to a void*
415 * Only available in SDL 2.0.10 or higher.
416 */
417 [DllImport(nativeLibName, EntryPoint = "SDL_LoadFile", CallingConvention = CallingConvention.Cdecl)]
418 private static extern unsafe IntPtr INTERNAL_SDL_LoadFile(byte* file, out IntPtr datasize);
419 public static unsafe IntPtr SDL_LoadFile(string file, out IntPtr datasize)
420 {
421 byte* utf8File = Utf8EncodeHeap(file);
422 IntPtr result = INTERNAL_SDL_LoadFile(utf8File, out datasize);
423 Marshal.FreeHGlobal((IntPtr) utf8File);
424 return result;
425 }
426
427 #endregion
428
429 #region SDL_main.h
430
431 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
432 public static extern void SDL_SetMainReady();
433
434 /* This is used as a function pointer to a C main() function */
435 public delegate int SDL_main_func(int argc, IntPtr argv);
436
437 /* Use this function with UWP to call your C# Main() function! */
438 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
439 public static extern int SDL_WinRTRunApp(
440 SDL_main_func mainFunction,
441 IntPtr reserved
442 );
443
444 /* Use this function with GDK/GDKX to call your C# Main() function!
445 * Only available in SDL 2.24.0 or higher.
446 */
447 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
448 public static extern int SDL_GDKRunApp(
449 SDL_main_func mainFunction,
450 IntPtr reserved
451 );
452
453 /* Use this function with iOS to call your C# Main() function!
454 * Only available in SDL 2.0.10 or higher.
455 */
456 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
457 public static extern int SDL_UIKitRunApp(
458 int argc,
459 IntPtr argv,
460 SDL_main_func mainFunction
461 );
462
463 #endregion
464
465 #region SDL.h
466
467 public const uint SDL_INIT_TIMER = 0x00000001;
468 public const uint SDL_INIT_AUDIO = 0x00000010;
469 public const uint SDL_INIT_VIDEO = 0x00000020;
470 public const uint SDL_INIT_JOYSTICK = 0x00000200;
471 public const uint SDL_INIT_HAPTIC = 0x00001000;
472 public const uint SDL_INIT_GAMECONTROLLER = 0x00002000;
473 public const uint SDL_INIT_EVENTS = 0x00004000;
474 public const uint SDL_INIT_SENSOR = 0x00008000;
475 public const uint SDL_INIT_NOPARACHUTE = 0x00100000;
476 public const uint SDL_INIT_EVERYTHING = (
477 SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO |
478 SDL_INIT_EVENTS | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC |
479 SDL_INIT_GAMECONTROLLER | SDL_INIT_SENSOR
480 );
481
482 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
483 public static extern int SDL_Init(uint flags);
484
485 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
486 public static extern int SDL_InitSubSystem(uint flags);
487
488 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
489 public static extern void SDL_Quit();
490
491 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
492 public static extern void SDL_QuitSubSystem(uint flags);
493
494 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
495 public static extern uint SDL_WasInit(uint flags);
496
497 #endregion
498
499 #region SDL_platform.h
500
501 [DllImport(nativeLibName, EntryPoint = "SDL_GetPlatform", CallingConvention = CallingConvention.Cdecl)]
502 private static extern IntPtr INTERNAL_SDL_GetPlatform();
503 public static string SDL_GetPlatform()
504 {
505 return UTF8_ToManaged(INTERNAL_SDL_GetPlatform());
506 }
507
508 #endregion
509
510 #region SDL_hints.h
511
512 public const string SDL_HINT_FRAMEBUFFER_ACCELERATION =
513 "SDL_FRAMEBUFFER_ACCELERATION";
514 public const string SDL_HINT_RENDER_DRIVER =
515 "SDL_RENDER_DRIVER";
516 public const string SDL_HINT_RENDER_OPENGL_SHADERS =
517 "SDL_RENDER_OPENGL_SHADERS";
518 public const string SDL_HINT_RENDER_DIRECT3D_THREADSAFE =
519 "SDL_RENDER_DIRECT3D_THREADSAFE";
520 public const string SDL_HINT_RENDER_VSYNC =
521 "SDL_RENDER_VSYNC";
522 public const string SDL_HINT_VIDEO_X11_XVIDMODE =
523 "SDL_VIDEO_X11_XVIDMODE";
524 public const string SDL_HINT_VIDEO_X11_XINERAMA =
525 "SDL_VIDEO_X11_XINERAMA";
526 public const string SDL_HINT_VIDEO_X11_XRANDR =
527 "SDL_VIDEO_X11_XRANDR";
528 public const string SDL_HINT_GRAB_KEYBOARD =
529 "SDL_GRAB_KEYBOARD";
530 public const string SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS =
531 "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS";
532 public const string SDL_HINT_IDLE_TIMER_DISABLED =
533 "SDL_IOS_IDLE_TIMER_DISABLED";
534 public const string SDL_HINT_ORIENTATIONS =
535 "SDL_IOS_ORIENTATIONS";
536 public const string SDL_HINT_XINPUT_ENABLED =
537 "SDL_XINPUT_ENABLED";
538 public const string SDL_HINT_GAMECONTROLLERCONFIG =
539 "SDL_GAMECONTROLLERCONFIG";
540 public const string SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS =
541 "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS";
542 public const string SDL_HINT_ALLOW_TOPMOST =
543 "SDL_ALLOW_TOPMOST";
544 public const string SDL_HINT_TIMER_RESOLUTION =
545 "SDL_TIMER_RESOLUTION";
546 public const string SDL_HINT_RENDER_SCALE_QUALITY =
547 "SDL_RENDER_SCALE_QUALITY";
548
549 /* Only available in SDL 2.0.1 or higher. */
550 public const string SDL_HINT_VIDEO_HIGHDPI_DISABLED =
551 "SDL_VIDEO_HIGHDPI_DISABLED";
552
553 /* Only available in SDL 2.0.2 or higher. */
554 public const string SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK =
555 "SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK";
556 public const string SDL_HINT_VIDEO_WIN_D3DCOMPILER =
557 "SDL_VIDEO_WIN_D3DCOMPILER";
558 public const string SDL_HINT_MOUSE_RELATIVE_MODE_WARP =
559 "SDL_MOUSE_RELATIVE_MODE_WARP";
560 public const string SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT =
561 "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT";
562 public const string SDL_HINT_VIDEO_ALLOW_SCREENSAVER =
563 "SDL_VIDEO_ALLOW_SCREENSAVER";
564 public const string SDL_HINT_ACCELEROMETER_AS_JOYSTICK =
565 "SDL_ACCELEROMETER_AS_JOYSTICK";
566 public const string SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES =
567 "SDL_VIDEO_MAC_FULLSCREEN_SPACES";
568
569 /* Only available in SDL 2.0.3 or higher. */
570 public const string SDL_HINT_WINRT_PRIVACY_POLICY_URL =
571 "SDL_WINRT_PRIVACY_POLICY_URL";
572 public const string SDL_HINT_WINRT_PRIVACY_POLICY_LABEL =
573 "SDL_WINRT_PRIVACY_POLICY_LABEL";
574 public const string SDL_HINT_WINRT_HANDLE_BACK_BUTTON =
575 "SDL_WINRT_HANDLE_BACK_BUTTON";
576
577 /* Only available in SDL 2.0.4 or higher. */
578 public const string SDL_HINT_NO_SIGNAL_HANDLERS =
579 "SDL_NO_SIGNAL_HANDLERS";
580 public const string SDL_HINT_IME_INTERNAL_EDITING =
581 "SDL_IME_INTERNAL_EDITING";
582 public const string SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH =
583 "SDL_ANDROID_SEPARATE_MOUSE_AND_TOUCH";
584 public const string SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT =
585 "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT";
586 public const string SDL_HINT_THREAD_STACK_SIZE =
587 "SDL_THREAD_STACK_SIZE";
588 public const string SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN =
589 "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN";
590 public const string SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP =
591 "SDL_WINDOWS_ENABLE_MESSAGELOOP";
592 public const string SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 =
593 "SDL_WINDOWS_NO_CLOSE_ON_ALT_F4";
594 public const string SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING =
595 "SDL_XINPUT_USE_OLD_JOYSTICK_MAPPING";
596 public const string SDL_HINT_MAC_BACKGROUND_APP =
597 "SDL_MAC_BACKGROUND_APP";
598 public const string SDL_HINT_VIDEO_X11_NET_WM_PING =
599 "SDL_VIDEO_X11_NET_WM_PING";
600 public const string SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION =
601 "SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION";
602 public const string SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION =
603 "SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION";
604
605 /* Only available in 2.0.5 or higher. */
606 public const string SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH =
607 "SDL_MOUSE_FOCUS_CLICKTHROUGH";
608 public const string SDL_HINT_BMP_SAVE_LEGACY_FORMAT =
609 "SDL_BMP_SAVE_LEGACY_FORMAT";
610 public const string SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING =
611 "SDL_WINDOWS_DISABLE_THREAD_NAMING";
612 public const string SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION =
613 "SDL_APPLE_TV_REMOTE_ALLOW_ROTATION";
614
615 /* Only available in 2.0.6 or higher. */
616 public const string SDL_HINT_AUDIO_RESAMPLING_MODE =
617 "SDL_AUDIO_RESAMPLING_MODE";
618 public const string SDL_HINT_RENDER_LOGICAL_SIZE_MODE =
619 "SDL_RENDER_LOGICAL_SIZE_MODE";
620 public const string SDL_HINT_MOUSE_NORMAL_SPEED_SCALE =
621 "SDL_MOUSE_NORMAL_SPEED_SCALE";
622 public const string SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE =
623 "SDL_MOUSE_RELATIVE_SPEED_SCALE";
624 public const string SDL_HINT_TOUCH_MOUSE_EVENTS =
625 "SDL_TOUCH_MOUSE_EVENTS";
626 public const string SDL_HINT_WINDOWS_INTRESOURCE_ICON =
627 "SDL_WINDOWS_INTRESOURCE_ICON";
628 public const string SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL =
629 "SDL_WINDOWS_INTRESOURCE_ICON_SMALL";
630
631 /* Only available in 2.0.8 or higher. */
632 public const string SDL_HINT_IOS_HIDE_HOME_INDICATOR =
633 "SDL_IOS_HIDE_HOME_INDICATOR";
634 public const string SDL_HINT_TV_REMOTE_AS_JOYSTICK =
635 "SDL_TV_REMOTE_AS_JOYSTICK";
636 public const string SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR =
637 "SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR";
638
639 /* Only available in 2.0.9 or higher. */
640 public const string SDL_HINT_MOUSE_DOUBLE_CLICK_TIME =
641 "SDL_MOUSE_DOUBLE_CLICK_TIME";
642 public const string SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS =
643 "SDL_MOUSE_DOUBLE_CLICK_RADIUS";
644 public const string SDL_HINT_JOYSTICK_HIDAPI =
645 "SDL_JOYSTICK_HIDAPI";
646 public const string SDL_HINT_JOYSTICK_HIDAPI_PS4 =
647 "SDL_JOYSTICK_HIDAPI_PS4";
648 public const string SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE =
649 "SDL_JOYSTICK_HIDAPI_PS4_RUMBLE";
650 public const string SDL_HINT_JOYSTICK_HIDAPI_STEAM =
651 "SDL_JOYSTICK_HIDAPI_STEAM";
652 public const string SDL_HINT_JOYSTICK_HIDAPI_SWITCH =
653 "SDL_JOYSTICK_HIDAPI_SWITCH";
654 public const string SDL_HINT_JOYSTICK_HIDAPI_XBOX =
655 "SDL_JOYSTICK_HIDAPI_XBOX";
656 public const string SDL_HINT_ENABLE_STEAM_CONTROLLERS =
657 "SDL_ENABLE_STEAM_CONTROLLERS";
658 public const string SDL_HINT_ANDROID_TRAP_BACK_BUTTON =
659 "SDL_ANDROID_TRAP_BACK_BUTTON";
660
661 /* Only available in 2.0.10 or higher. */
662 public const string SDL_HINT_MOUSE_TOUCH_EVENTS =
663 "SDL_MOUSE_TOUCH_EVENTS";
664 public const string SDL_HINT_GAMECONTROLLERCONFIG_FILE =
665 "SDL_GAMECONTROLLERCONFIG_FILE";
666 public const string SDL_HINT_ANDROID_BLOCK_ON_PAUSE =
667 "SDL_ANDROID_BLOCK_ON_PAUSE";
668 public const string SDL_HINT_RENDER_BATCHING =
669 "SDL_RENDER_BATCHING";
670 public const string SDL_HINT_EVENT_LOGGING =
671 "SDL_EVENT_LOGGING";
672 public const string SDL_HINT_WAVE_RIFF_CHUNK_SIZE =
673 "SDL_WAVE_RIFF_CHUNK_SIZE";
674 public const string SDL_HINT_WAVE_TRUNCATION =
675 "SDL_WAVE_TRUNCATION";
676 public const string SDL_HINT_WAVE_FACT_CHUNK =
677 "SDL_WAVE_FACT_CHUNK";
678
679 /* Only available in 2.0.11 or higher. */
680 public const string SDL_HINT_VIDO_X11_WINDOW_VISUALID =
681 "SDL_VIDEO_X11_WINDOW_VISUALID";
682 public const string SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS =
683 "SDL_GAMECONTROLLER_USE_BUTTON_LABELS";
684 public const string SDL_HINT_VIDEO_EXTERNAL_CONTEXT =
685 "SDL_VIDEO_EXTERNAL_CONTEXT";
686 public const string SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE =
687 "SDL_JOYSTICK_HIDAPI_GAMECUBE";
688 public const string SDL_HINT_DISPLAY_USABLE_BOUNDS =
689 "SDL_DISPLAY_USABLE_BOUNDS";
690 public const string SDL_HINT_VIDEO_X11_FORCE_EGL =
691 "SDL_VIDEO_X11_FORCE_EGL";
692 public const string SDL_HINT_GAMECONTROLLERTYPE =
693 "SDL_GAMECONTROLLERTYPE";
694
695 /* Only available in 2.0.14 or higher. */
696 public const string SDL_HINT_JOYSTICK_HIDAPI_CORRELATE_XINPUT =
697 "SDL_JOYSTICK_HIDAPI_CORRELATE_XINPUT"; /* NOTE: This was removed in 2.0.16. */
698 public const string SDL_HINT_JOYSTICK_RAWINPUT =
699 "SDL_JOYSTICK_RAWINPUT";
700 public const string SDL_HINT_AUDIO_DEVICE_APP_NAME =
701 "SDL_AUDIO_DEVICE_APP_NAME";
702 public const string SDL_HINT_AUDIO_DEVICE_STREAM_NAME =
703 "SDL_AUDIO_DEVICE_STREAM_NAME";
704 public const string SDL_HINT_PREFERRED_LOCALES =
705 "SDL_PREFERRED_LOCALES";
706 public const string SDL_HINT_THREAD_PRIORITY_POLICY =
707 "SDL_THREAD_PRIORITY_POLICY";
708 public const string SDL_HINT_EMSCRIPTEN_ASYNCIFY =
709 "SDL_EMSCRIPTEN_ASYNCIFY";
710 public const string SDL_HINT_LINUX_JOYSTICK_DEADZONES =
711 "SDL_LINUX_JOYSTICK_DEADZONES";
712 public const string SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO =
713 "SDL_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO";
714 public const string SDL_HINT_JOYSTICK_HIDAPI_PS5 =
715 "SDL_JOYSTICK_HIDAPI_PS5";
716 public const string SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL =
717 "SDL_THREAD_FORCE_REALTIME_TIME_CRITICAL";
718 public const string SDL_HINT_JOYSTICK_THREAD =
719 "SDL_JOYSTICK_THREAD";
720 public const string SDL_HINT_AUTO_UPDATE_JOYSTICKS =
721 "SDL_AUTO_UPDATE_JOYSTICKS";
722 public const string SDL_HINT_AUTO_UPDATE_SENSORS =
723 "SDL_AUTO_UPDATE_SENSORS";
724 public const string SDL_HINT_MOUSE_RELATIVE_SCALING =
725 "SDL_MOUSE_RELATIVE_SCALING";
726 public const string SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE =
727 "SDL_JOYSTICK_HIDAPI_PS5_RUMBLE";
728
729 /* Only available in 2.0.16 or higher. */
730 public const string SDL_HINT_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS =
731 "SDL_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS";
732 public const string SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL =
733 "SDL_WINDOWS_FORCE_SEMAPHORE_KERNEL";
734 public const string SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED =
735 "SDL_JOYSTICK_HIDAPI_PS5_PLAYER_LED";
736 public const string SDL_HINT_WINDOWS_USE_D3D9EX =
737 "SDL_WINDOWS_USE_D3D9EX";
738 public const string SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS =
739 "SDL_JOYSTICK_HIDAPI_JOY_CONS";
740 public const string SDL_HINT_JOYSTICK_HIDAPI_STADIA =
741 "SDL_JOYSTICK_HIDAPI_STADIA";
742 public const string SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED =
743 "SDL_JOYSTICK_HIDAPI_SWITCH_HOME_LED";
744 public const string SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED =
745 "SDL_ALLOW_ALT_TAB_WHILE_GRABBED";
746 public const string SDL_HINT_KMSDRM_REQUIRE_DRM_MASTER =
747 "SDL_KMSDRM_REQUIRE_DRM_MASTER";
748 public const string SDL_HINT_AUDIO_DEVICE_STREAM_ROLE =
749 "SDL_AUDIO_DEVICE_STREAM_ROLE";
750 public const string SDL_HINT_X11_FORCE_OVERRIDE_REDIRECT =
751 "SDL_X11_FORCE_OVERRIDE_REDIRECT";
752 public const string SDL_HINT_JOYSTICK_HIDAPI_LUNA =
753 "SDL_JOYSTICK_HIDAPI_LUNA";
754 public const string SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT =
755 "SDL_JOYSTICK_RAWINPUT_CORRELATE_XINPUT";
756 public const string SDL_HINT_AUDIO_INCLUDE_MONITORS =
757 "SDL_AUDIO_INCLUDE_MONITORS";
758 public const string SDL_HINT_VIDEO_WAYLAND_ALLOW_LIBDECOR =
759 "SDL_VIDEO_WAYLAND_ALLOW_LIBDECOR";
760
761 /* Only available in 2.0.18 or higher. */
762 public const string SDL_HINT_VIDEO_EGL_ALLOW_TRANSPARENCY =
763 "SDL_VIDEO_EGL_ALLOW_TRANSPARENCY";
764 public const string SDL_HINT_APP_NAME =
765 "SDL_APP_NAME";
766 public const string SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME =
767 "SDL_SCREENSAVER_INHIBIT_ACTIVITY_NAME";
768 public const string SDL_HINT_IME_SHOW_UI =
769 "SDL_IME_SHOW_UI";
770 public const string SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN =
771 "SDL_WINDOW_NO_ACTIVATION_WHEN_SHOWN";
772 public const string SDL_HINT_POLL_SENTINEL =
773 "SDL_POLL_SENTINEL";
774 public const string SDL_HINT_JOYSTICK_DEVICE =
775 "SDL_JOYSTICK_DEVICE";
776 public const string SDL_HINT_LINUX_JOYSTICK_CLASSIC =
777 "SDL_LINUX_JOYSTICK_CLASSIC";
778
779 /* Only available in 2.0.20 or higher. */
780 public const string SDL_HINT_RENDER_LINE_METHOD =
781 "SDL_RENDER_LINE_METHOD";
782
783 /* Only available in 2.0.22 or higher. */
784 public const string SDL_HINT_FORCE_RAISEWINDOW =
785 "SDL_HINT_FORCE_RAISEWINDOW";
786 public const string SDL_HINT_IME_SUPPORT_EXTENDED_TEXT =
787 "SDL_IME_SUPPORT_EXTENDED_TEXT";
788 public const string SDL_HINT_JOYSTICK_GAMECUBE_RUMBLE_BRAKE =
789 "SDL_JOYSTICK_GAMECUBE_RUMBLE_BRAKE";
790 public const string SDL_HINT_JOYSTICK_ROG_CHAKRAM =
791 "SDL_JOYSTICK_ROG_CHAKRAM";
792 public const string SDL_HINT_MOUSE_RELATIVE_MODE_CENTER =
793 "SDL_MOUSE_RELATIVE_MODE_CENTER";
794 public const string SDL_HINT_MOUSE_AUTO_CAPTURE =
795 "SDL_MOUSE_AUTO_CAPTURE";
796 public const string SDL_HINT_VITA_TOUCH_MOUSE_DEVICE =
797 "SDL_HINT_VITA_TOUCH_MOUSE_DEVICE";
798 public const string SDL_HINT_VIDEO_WAYLAND_PREFER_LIBDECOR =
799 "SDL_VIDEO_WAYLAND_PREFER_LIBDECOR";
800 public const string SDL_HINT_VIDEO_FOREIGN_WINDOW_OPENGL =
801 "SDL_VIDEO_FOREIGN_WINDOW_OPENGL";
802 public const string SDL_HINT_VIDEO_FOREIGN_WINDOW_VULKAN =
803 "SDL_VIDEO_FOREIGN_WINDOW_VULKAN";
804 public const string SDL_HINT_X11_WINDOW_TYPE =
805 "SDL_X11_WINDOW_TYPE";
806 public const string SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE =
807 "SDL_QUIT_ON_LAST_WINDOW_CLOSE";
808
809 public enum SDL_HintPriority
810 {
811 SDL_HINT_DEFAULT,
812 SDL_HINT_NORMAL,
813 SDL_HINT_OVERRIDE
814 }
815
816 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
817 public static extern void SDL_ClearHints();
818
819 [DllImport(nativeLibName, EntryPoint = "SDL_GetHint", CallingConvention = CallingConvention.Cdecl)]
820 private static extern unsafe IntPtr INTERNAL_SDL_GetHint(byte* name);
821 public static unsafe string SDL_GetHint(string name)
822 {
823 int utf8NameBufSize = Utf8Size(name);
824 byte* utf8Name = stackalloc byte[utf8NameBufSize];
825 return UTF8_ToManaged(
826 INTERNAL_SDL_GetHint(
827 Utf8Encode(name, utf8Name, utf8NameBufSize)
828 )
829 );
830 }
831
832 [DllImport(nativeLibName, EntryPoint = "SDL_SetHint", CallingConvention = CallingConvention.Cdecl)]
833 private static extern unsafe SDL_bool INTERNAL_SDL_SetHint(
834 byte* name,
835 byte* value
836 );
837 public static unsafe SDL_bool SDL_SetHint(string name, string value)
838 {
839 int utf8NameBufSize = Utf8Size(name);
840 byte* utf8Name = stackalloc byte[utf8NameBufSize];
841
842 int utf8ValueBufSize = Utf8Size(value);
843 byte* utf8Value = stackalloc byte[utf8ValueBufSize];
844
845 return INTERNAL_SDL_SetHint(
846 Utf8Encode(name, utf8Name, utf8NameBufSize),
847 Utf8Encode(value, utf8Value, utf8ValueBufSize)
848 );
849 }
850
851 [DllImport(nativeLibName, EntryPoint = "SDL_SetHintWithPriority", CallingConvention = CallingConvention.Cdecl)]
852 private static extern unsafe SDL_bool INTERNAL_SDL_SetHintWithPriority(
853 byte* name,
854 byte* value,
855 SDL_HintPriority priority
856 );
857 public static unsafe SDL_bool SDL_SetHintWithPriority(
858 string name,
859 string value,
860 SDL_HintPriority priority
861 ) {
862 int utf8NameBufSize = Utf8Size(name);
863 byte* utf8Name = stackalloc byte[utf8NameBufSize];
864
865 int utf8ValueBufSize = Utf8Size(value);
866 byte* utf8Value = stackalloc byte[utf8ValueBufSize];
867
868 return INTERNAL_SDL_SetHintWithPriority(
869 Utf8Encode(name, utf8Name, utf8NameBufSize),
870 Utf8Encode(value, utf8Value, utf8ValueBufSize),
871 priority
872 );
873 }
874
875 /* Only available in 2.0.5 or higher. */
876 [DllImport(nativeLibName, EntryPoint = "SDL_GetHintBoolean", CallingConvention = CallingConvention.Cdecl)]
877 private static extern unsafe SDL_bool INTERNAL_SDL_GetHintBoolean(
878 byte* name,
879 SDL_bool default_value
880 );
881 public static unsafe SDL_bool SDL_GetHintBoolean(
882 string name,
883 SDL_bool default_value
884 ) {
885 int utf8NameBufSize = Utf8Size(name);
886 byte* utf8Name = stackalloc byte[utf8NameBufSize];
887 return INTERNAL_SDL_GetHintBoolean(
888 Utf8Encode(name, utf8Name, utf8NameBufSize),
889 default_value
890 );
891 }
892
893 #endregion
894
895 #region SDL_error.h
896
897 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
898 public static extern void SDL_ClearError();
899
900 [DllImport(nativeLibName, EntryPoint = "SDL_GetError", CallingConvention = CallingConvention.Cdecl)]
901 private static extern IntPtr INTERNAL_SDL_GetError();
902 public static string SDL_GetError()
903 {
904 return UTF8_ToManaged(INTERNAL_SDL_GetError());
905 }
906
907 /* Use string.Format for arglists */
908 [DllImport(nativeLibName, EntryPoint = "SDL_SetError", CallingConvention = CallingConvention.Cdecl)]
909 private static extern unsafe void INTERNAL_SDL_SetError(byte* fmtAndArglist);
910 public static unsafe void SDL_SetError(string fmtAndArglist)
911 {
912 int utf8FmtAndArglistBufSize = Utf8Size(fmtAndArglist);
913 byte* utf8FmtAndArglist = stackalloc byte[utf8FmtAndArglistBufSize];
914 INTERNAL_SDL_SetError(
915 Utf8Encode(fmtAndArglist, utf8FmtAndArglist, utf8FmtAndArglistBufSize)
916 );
917 }
918
919 /* IntPtr refers to a char*.
920 * Only available in 2.0.14 or higher.
921 */
922 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
923 public static extern IntPtr SDL_GetErrorMsg(IntPtr errstr, int maxlength);
924
925 #endregion
926
927 #region SDL_log.h
928
929 public enum SDL_LogCategory
930 {
931 SDL_LOG_CATEGORY_APPLICATION,
932 SDL_LOG_CATEGORY_ERROR,
933 SDL_LOG_CATEGORY_ASSERT,
934 SDL_LOG_CATEGORY_SYSTEM,
935 SDL_LOG_CATEGORY_AUDIO,
936 SDL_LOG_CATEGORY_VIDEO,
937 SDL_LOG_CATEGORY_RENDER,
938 SDL_LOG_CATEGORY_INPUT,
939 SDL_LOG_CATEGORY_TEST,
940
941 /* Reserved for future SDL library use */
942 SDL_LOG_CATEGORY_RESERVED1,
943 SDL_LOG_CATEGORY_RESERVED2,
944 SDL_LOG_CATEGORY_RESERVED3,
945 SDL_LOG_CATEGORY_RESERVED4,
946 SDL_LOG_CATEGORY_RESERVED5,
947 SDL_LOG_CATEGORY_RESERVED6,
948 SDL_LOG_CATEGORY_RESERVED7,
949 SDL_LOG_CATEGORY_RESERVED8,
950 SDL_LOG_CATEGORY_RESERVED9,
951 SDL_LOG_CATEGORY_RESERVED10,
952
953 /* Beyond this point is reserved for application use, e.g.
954 enum {
955 MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM,
956 MYAPP_CATEGORY_AWESOME2,
957 MYAPP_CATEGORY_AWESOME3,
958 ...
959 };
960 */
961 SDL_LOG_CATEGORY_CUSTOM
962 }
963
964 public enum SDL_LogPriority
965 {
966 SDL_LOG_PRIORITY_VERBOSE = 1,
967 SDL_LOG_PRIORITY_DEBUG,
968 SDL_LOG_PRIORITY_INFO,
969 SDL_LOG_PRIORITY_WARN,
970 SDL_LOG_PRIORITY_ERROR,
971 SDL_LOG_PRIORITY_CRITICAL,
972 SDL_NUM_LOG_PRIORITIES
973 }
974
975 /* userdata refers to a void*, message to a const char* */
976 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
977 public delegate void SDL_LogOutputFunction(
978 IntPtr userdata,
979 int category,
980 SDL_LogPriority priority,
981 IntPtr message
982 );
983
984 /* Use string.Format for arglists */
985 [DllImport(nativeLibName, EntryPoint = "SDL_Log", CallingConvention = CallingConvention.Cdecl)]
986 private static extern unsafe void INTERNAL_SDL_Log(byte* fmtAndArglist);
987 public static unsafe void SDL_Log(string fmtAndArglist)
988 {
989 int utf8FmtAndArglistBufSize = Utf8Size(fmtAndArglist);
990 byte* utf8FmtAndArglist = stackalloc byte[utf8FmtAndArglistBufSize];
991 INTERNAL_SDL_Log(
992 Utf8Encode(fmtAndArglist, utf8FmtAndArglist, utf8FmtAndArglistBufSize)
993 );
994 }
995
996 /* Use string.Format for arglists */
997 [DllImport(nativeLibName, EntryPoint = "SDL_LogVerbose", CallingConvention = CallingConvention.Cdecl)]
998 private static extern unsafe void INTERNAL_SDL_LogVerbose(
999 int category,
1000 byte* fmtAndArglist
1001 );
1002 public static unsafe void SDL_LogVerbose(
1003 int category,
1004 string fmtAndArglist
1005 ) {
1006 int utf8FmtAndArglistBufSize = Utf8Size(fmtAndArglist);
1007 byte* utf8FmtAndArglist = stackalloc byte[utf8FmtAndArglistBufSize];
1008 INTERNAL_SDL_LogVerbose(
1009 category,
1010 Utf8Encode(fmtAndArglist, utf8FmtAndArglist, utf8FmtAndArglistBufSize)
1011 );
1012 }
1013
1014 /* Use string.Format for arglists */
1015 [DllImport(nativeLibName, EntryPoint = "SDL_LogDebug", CallingConvention = CallingConvention.Cdecl)]
1016 private static extern unsafe void INTERNAL_SDL_LogDebug(
1017 int category,
1018 byte* fmtAndArglist
1019 );
1020 public static unsafe void SDL_LogDebug(
1021 int category,
1022 string fmtAndArglist
1023 ) {
1024 int utf8FmtAndArglistBufSize = Utf8Size(fmtAndArglist);
1025 byte* utf8FmtAndArglist = stackalloc byte[utf8FmtAndArglistBufSize];
1026 INTERNAL_SDL_LogDebug(
1027 category,
1028 Utf8Encode(fmtAndArglist, utf8FmtAndArglist, utf8FmtAndArglistBufSize)
1029 );
1030 }
1031
1032 /* Use string.Format for arglists */
1033 [DllImport(nativeLibName, EntryPoint = "SDL_LogInfo", CallingConvention = CallingConvention.Cdecl)]
1034 private static extern unsafe void INTERNAL_SDL_LogInfo(
1035 int category,
1036 byte* fmtAndArglist
1037 );
1038 public static unsafe void SDL_LogInfo(
1039 int category,
1040 string fmtAndArglist
1041 ) {
1042 int utf8FmtAndArglistBufSize = Utf8Size(fmtAndArglist);
1043 byte* utf8FmtAndArglist = stackalloc byte[utf8FmtAndArglistBufSize];
1044 INTERNAL_SDL_LogInfo(
1045 category,
1046 Utf8Encode(fmtAndArglist, utf8FmtAndArglist, utf8FmtAndArglistBufSize)
1047 );
1048 }
1049
1050 /* Use string.Format for arglists */
1051 [DllImport(nativeLibName, EntryPoint = "SDL_LogWarn", CallingConvention = CallingConvention.Cdecl)]
1052 private static extern unsafe void INTERNAL_SDL_LogWarn(
1053 int category,
1054 byte* fmtAndArglist
1055 );
1056 public static unsafe void SDL_LogWarn(
1057 int category,
1058 string fmtAndArglist
1059 ) {
1060 int utf8FmtAndArglistBufSize = Utf8Size(fmtAndArglist);
1061 byte* utf8FmtAndArglist = stackalloc byte[utf8FmtAndArglistBufSize];
1062 INTERNAL_SDL_LogWarn(
1063 category,
1064 Utf8Encode(fmtAndArglist, utf8FmtAndArglist, utf8FmtAndArglistBufSize)
1065 );
1066 }
1067
1068 /* Use string.Format for arglists */
1069 [DllImport(nativeLibName, EntryPoint = "SDL_LogError", CallingConvention = CallingConvention.Cdecl)]
1070 private static extern unsafe void INTERNAL_SDL_LogError(
1071 int category,
1072 byte* fmtAndArglist
1073 );
1074 public static unsafe void SDL_LogError(
1075 int category,
1076 string fmtAndArglist
1077 ) {
1078 int utf8FmtAndArglistBufSize = Utf8Size(fmtAndArglist);
1079 byte* utf8FmtAndArglist = stackalloc byte[utf8FmtAndArglistBufSize];
1080 INTERNAL_SDL_LogError(
1081 category,
1082 Utf8Encode(fmtAndArglist, utf8FmtAndArglist, utf8FmtAndArglistBufSize)
1083 );
1084 }
1085
1086 /* Use string.Format for arglists */
1087 [DllImport(nativeLibName, EntryPoint = "SDL_LogCritical", CallingConvention = CallingConvention.Cdecl)]
1088 private static extern unsafe void INTERNAL_SDL_LogCritical(
1089 int category,
1090 byte* fmtAndArglist
1091 );
1092 public static unsafe void SDL_LogCritical(
1093 int category,
1094 string fmtAndArglist
1095 ) {
1096 int utf8FmtAndArglistBufSize = Utf8Size(fmtAndArglist);
1097 byte* utf8FmtAndArglist = stackalloc byte[utf8FmtAndArglistBufSize];
1098 INTERNAL_SDL_LogCritical(
1099 category,
1100 Utf8Encode(fmtAndArglist, utf8FmtAndArglist, utf8FmtAndArglistBufSize)
1101 );
1102 }
1103
1104 /* Use string.Format for arglists */
1105 [DllImport(nativeLibName, EntryPoint = "SDL_LogMessage", CallingConvention = CallingConvention.Cdecl)]
1106 private static extern unsafe void INTERNAL_SDL_LogMessage(
1107 int category,
1108 SDL_LogPriority priority,
1109 byte* fmtAndArglist
1110 );
1111 public static unsafe void SDL_LogMessage(
1112 int category,
1113 SDL_LogPriority priority,
1114 string fmtAndArglist
1115 ) {
1116 int utf8FmtAndArglistBufSize = Utf8Size(fmtAndArglist);
1117 byte* utf8FmtAndArglist = stackalloc byte[utf8FmtAndArglistBufSize];
1118 INTERNAL_SDL_LogMessage(
1119 category,
1120 priority,
1121 Utf8Encode(fmtAndArglist, utf8FmtAndArglist, utf8FmtAndArglistBufSize)
1122 );
1123 }
1124
1125 /* Use string.Format for arglists */
1126 [DllImport(nativeLibName, EntryPoint = "SDL_LogMessageV", CallingConvention = CallingConvention.Cdecl)]
1127 private static extern unsafe void INTERNAL_SDL_LogMessageV(
1128 int category,
1129 SDL_LogPriority priority,
1130 byte* fmtAndArglist
1131 );
1132 public static unsafe void SDL_LogMessageV(
1133 int category,
1134 SDL_LogPriority priority,
1135 string fmtAndArglist
1136 ) {
1137 int utf8FmtAndArglistBufSize = Utf8Size(fmtAndArglist);
1138 byte* utf8FmtAndArglist = stackalloc byte[utf8FmtAndArglistBufSize];
1139 INTERNAL_SDL_LogMessageV(
1140 category,
1141 priority,
1142 Utf8Encode(fmtAndArglist, utf8FmtAndArglist, utf8FmtAndArglistBufSize)
1143 );
1144 }
1145
1146 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1147 public static extern SDL_LogPriority SDL_LogGetPriority(
1148 int category
1149 );
1150
1151 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1152 public static extern void SDL_LogSetPriority(
1153 int category,
1154 SDL_LogPriority priority
1155 );
1156
1157 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1158 public static extern void SDL_LogSetAllPriority(
1159 SDL_LogPriority priority
1160 );
1161
1162 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1163 public static extern void SDL_LogResetPriorities();
1164
1165 /* userdata refers to a void* */
1166 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1167 private static extern void SDL_LogGetOutputFunction(
1168 out IntPtr callback,
1169 out IntPtr userdata
1170 );
1171 public static void SDL_LogGetOutputFunction(
1172 out SDL_LogOutputFunction callback,
1173 out IntPtr userdata
1174 ) {
1175 IntPtr result = IntPtr.Zero;
1176 SDL_LogGetOutputFunction(
1177 out result,
1178 out userdata
1179 );
1180 if (result != IntPtr.Zero)
1181 {
1182 callback = (SDL_LogOutputFunction) GetDelegateForFunctionPointer<SDL_LogOutputFunction>(
1183 result
1184 );
1185 }
1186 else
1187 {
1188 callback = null!;
1189 }
1190 }
1191
1192 /* userdata refers to a void* */
1193 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1194 public static extern void SDL_LogSetOutputFunction(
1195 SDL_LogOutputFunction callback,
1196 IntPtr userdata
1197 );
1198
1199 #endregion
1200
1201 #region SDL_messagebox.h
1202
1203 [Flags]
1204 public enum SDL_MessageBoxFlags : uint
1205 {
1206 SDL_MESSAGEBOX_ERROR = 0x00000010,
1207 SDL_MESSAGEBOX_WARNING = 0x00000020,
1208 SDL_MESSAGEBOX_INFORMATION = 0x00000040
1209 }
1210
1211 [Flags]
1212 public enum SDL_MessageBoxButtonFlags : uint
1213 {
1214 SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001,
1215 SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002
1216 }
1217
1218 [StructLayout(LayoutKind.Sequential)]
1219 private struct INTERNAL_SDL_MessageBoxButtonData
1220 {
1221 public SDL_MessageBoxButtonFlags flags;
1222 public int buttonid;
1223 public IntPtr text; /* The UTF-8 button text */
1224 }
1225
1226 [StructLayout(LayoutKind.Sequential)]
1227 public struct SDL_MessageBoxButtonData
1228 {
1229 public SDL_MessageBoxButtonFlags flags;
1230 public int buttonid;
1231 public string text; /* The UTF-8 button text */
1232 }
1233
1234 [StructLayout(LayoutKind.Sequential)]
1235 public struct SDL_MessageBoxColor
1236 {
1237 public byte r, g, b;
1238 }
1239
1240 public enum SDL_MessageBoxColorType
1241 {
1242 SDL_MESSAGEBOX_COLOR_BACKGROUND,
1243 SDL_MESSAGEBOX_COLOR_TEXT,
1244 SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,
1245 SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND,
1246 SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED,
1247 SDL_MESSAGEBOX_COLOR_MAX
1248 }
1249
1250 [StructLayout(LayoutKind.Sequential)]
1251 public struct SDL_MessageBoxColorScheme
1252 {
1253 [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = (int)SDL_MessageBoxColorType.SDL_MESSAGEBOX_COLOR_MAX)]
1254 public SDL_MessageBoxColor[] colors;
1255 }
1256
1257 [StructLayout(LayoutKind.Sequential)]
1258 private struct INTERNAL_SDL_MessageBoxData
1259 {
1260 public SDL_MessageBoxFlags flags;
1261 public IntPtr window; /* Parent window, can be NULL */
1262 public IntPtr title; /* UTF-8 title */
1263 public IntPtr message; /* UTF-8 message text */
1264 public int numbuttons;
1265 public IntPtr buttons;
1266 public IntPtr colorScheme; /* Can be NULL to use system settings */
1267 }
1268
1269 [StructLayout(LayoutKind.Sequential)]
1270 public struct SDL_MessageBoxData
1271 {
1272 public SDL_MessageBoxFlags flags;
1273 public IntPtr window; /* Parent window, can be NULL */
1274 public string title; /* UTF-8 title */
1275 public string message; /* UTF-8 message text */
1276 public int numbuttons;
1277 public SDL_MessageBoxButtonData[] buttons;
1278 public SDL_MessageBoxColorScheme? colorScheme; /* Can be NULL to use system settings */
1279 }
1280
1281 [DllImport(nativeLibName, EntryPoint = "SDL_ShowMessageBox", CallingConvention = CallingConvention.Cdecl)]
1282 private static extern int INTERNAL_SDL_ShowMessageBox([In()] ref INTERNAL_SDL_MessageBoxData messageboxdata, out int buttonid);
1283
1284 /* Ripped from Jameson's LpUtf8StrMarshaler */
1285 private static IntPtr INTERNAL_AllocUTF8(string str)
1286 {
1287 if (string.IsNullOrEmpty(str))
1288 {
1289 return IntPtr.Zero;
1290 }
1291 byte[] bytes = System.Text.Encoding.UTF8.GetBytes(str + '\0');
1292 IntPtr mem = SDL.SDL_malloc((IntPtr) bytes.Length);
1293 Marshal.Copy(bytes, 0, mem, bytes.Length);
1294 return mem;
1295 }
1296
1297 public static unsafe int SDL_ShowMessageBox([In()] ref SDL_MessageBoxData messageboxdata, out int buttonid)
1298 {
1299 var data = new INTERNAL_SDL_MessageBoxData()
1300 {
1301 flags = messageboxdata.flags,
1302 window = messageboxdata.window,
1303 title = INTERNAL_AllocUTF8(messageboxdata.title),
1304 message = INTERNAL_AllocUTF8(messageboxdata.message),
1305 numbuttons = messageboxdata.numbuttons,
1306 };
1307
1308 var buttons = new INTERNAL_SDL_MessageBoxButtonData[messageboxdata.numbuttons];
1309 for (int i = 0; i < messageboxdata.numbuttons; i++)
1310 {
1311 buttons[i] = new INTERNAL_SDL_MessageBoxButtonData()
1312 {
1313 flags = messageboxdata.buttons[i].flags,
1314 buttonid = messageboxdata.buttons[i].buttonid,
1315 text = INTERNAL_AllocUTF8(messageboxdata.buttons[i].text),
1316 };
1317 }
1318
1319 if (messageboxdata.colorScheme != null)
1320 {
1321 data.colorScheme = Marshal.AllocHGlobal(SizeOf<SDL_MessageBoxColorScheme>());
1322 Marshal.StructureToPtr(messageboxdata.colorScheme.Value, data.colorScheme, false);
1323 }
1324
1325 int result;
1326 fixed (INTERNAL_SDL_MessageBoxButtonData* buttonsPtr = &buttons[0])
1327 {
1328 data.buttons = (IntPtr)buttonsPtr;
1329 result = INTERNAL_SDL_ShowMessageBox(ref data, out buttonid);
1330 }
1331
1332 Marshal.FreeHGlobal(data.colorScheme);
1333 for (int i = 0; i < messageboxdata.numbuttons; i++)
1334 {
1335 SDL_free(buttons[i].text);
1336 }
1337 SDL_free(data.message);
1338 SDL_free(data.title);
1339
1340 return result;
1341 }
1342
1343 /* window refers to an SDL_Window* */
1344 [DllImport(nativeLibName, EntryPoint = "SDL_ShowSimpleMessageBox", CallingConvention = CallingConvention.Cdecl)]
1345 private static extern unsafe int INTERNAL_SDL_ShowSimpleMessageBox(
1346 SDL_MessageBoxFlags flags,
1347 byte* title,
1348 byte* message,
1349 IntPtr window
1350 );
1351 public static unsafe int SDL_ShowSimpleMessageBox(
1352 SDL_MessageBoxFlags flags,
1353 string title,
1354 string message,
1355 IntPtr window
1356 ) {
1357 int utf8TitleBufSize = Utf8Size(title);
1358 byte* utf8Title = stackalloc byte[utf8TitleBufSize];
1359
1360 int utf8MessageBufSize = Utf8Size(message);
1361 byte* utf8Message = stackalloc byte[utf8MessageBufSize];
1362
1363 return INTERNAL_SDL_ShowSimpleMessageBox(
1364 flags,
1365 Utf8Encode(title, utf8Title, utf8TitleBufSize),
1366 Utf8Encode(message, utf8Message, utf8MessageBufSize),
1367 window
1368 );
1369 }
1370
1371 #endregion
1372
1373 #region SDL_version.h, SDL_revision.h
1374
1375 /* Similar to the headers, this is the version we're expecting to be
1376 * running with. You will likely want to check this somewhere in your
1377 * program!
1378 */
1379 public const int SDL_MAJOR_VERSION = 2;
1380 public const int SDL_MINOR_VERSION = 0;
1381 public const int SDL_PATCHLEVEL = 22;
1382
1383 public static readonly int SDL_COMPILEDVERSION = SDL_VERSIONNUM(
1384 SDL_MAJOR_VERSION,
1385 SDL_MINOR_VERSION,
1386 SDL_PATCHLEVEL
1387 );
1388
1389 [StructLayout(LayoutKind.Sequential)]
1390 public struct SDL_version
1391 {
1392 public byte major;
1393 public byte minor;
1394 public byte patch;
1395 }
1396
1397 public static void SDL_VERSION(out SDL_version x)
1398 {
1399 x.major = SDL_MAJOR_VERSION;
1400 x.minor = SDL_MINOR_VERSION;
1401 x.patch = SDL_PATCHLEVEL;
1402 }
1403
1404 public static int SDL_VERSIONNUM(int X, int Y, int Z)
1405 {
1406 return (X * 1000) + (Y * 100) + Z;
1407 }
1408
1409 public static bool SDL_VERSION_ATLEAST(int X, int Y, int Z)
1410 {
1411 return (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z));
1412 }
1413
1414 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1415 public static extern void SDL_GetVersion(out SDL_version ver);
1416
1417 [DllImport(nativeLibName, EntryPoint = "SDL_GetRevision", CallingConvention = CallingConvention.Cdecl)]
1418 private static extern IntPtr INTERNAL_SDL_GetRevision();
1419 public static string SDL_GetRevision()
1420 {
1421 return UTF8_ToManaged(INTERNAL_SDL_GetRevision());
1422 }
1423
1424 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1425 public static extern int SDL_GetRevisionNumber();
1426
1427 #endregion
1428
1429 #region SDL_video.h
1430
1431 public enum SDL_GLattr
1432 {
1433 SDL_GL_RED_SIZE,
1434 SDL_GL_GREEN_SIZE,
1435 SDL_GL_BLUE_SIZE,
1436 SDL_GL_ALPHA_SIZE,
1437 SDL_GL_BUFFER_SIZE,
1438 SDL_GL_DOUBLEBUFFER,
1439 SDL_GL_DEPTH_SIZE,
1440 SDL_GL_STENCIL_SIZE,
1441 SDL_GL_ACCUM_RED_SIZE,
1442 SDL_GL_ACCUM_GREEN_SIZE,
1443 SDL_GL_ACCUM_BLUE_SIZE,
1444 SDL_GL_ACCUM_ALPHA_SIZE,
1445 SDL_GL_STEREO,
1446 SDL_GL_MULTISAMPLEBUFFERS,
1447 SDL_GL_MULTISAMPLESAMPLES,
1448 SDL_GL_ACCELERATED_VISUAL,
1449 SDL_GL_RETAINED_BACKING,
1450 SDL_GL_CONTEXT_MAJOR_VERSION,
1451 SDL_GL_CONTEXT_MINOR_VERSION,
1452 SDL_GL_CONTEXT_EGL,
1453 SDL_GL_CONTEXT_FLAGS,
1454 SDL_GL_CONTEXT_PROFILE_MASK,
1455 SDL_GL_SHARE_WITH_CURRENT_CONTEXT,
1456 SDL_GL_FRAMEBUFFER_SRGB_CAPABLE,
1457 SDL_GL_CONTEXT_RELEASE_BEHAVIOR,
1458 SDL_GL_CONTEXT_RESET_NOTIFICATION, /* Requires >= 2.0.6 */
1459 SDL_GL_CONTEXT_NO_ERROR, /* Requires >= 2.0.6 */
1460 }
1461
1462 [Flags]
1463 public enum SDL_GLprofile
1464 {
1465 SDL_GL_CONTEXT_PROFILE_CORE = 0x0001,
1466 SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002,
1467 SDL_GL_CONTEXT_PROFILE_ES = 0x0004
1468 }
1469
1470 [Flags]
1471 public enum SDL_GLcontext
1472 {
1473 SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001,
1474 SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002,
1475 SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004,
1476 SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008
1477 }
1478
1479 public enum SDL_WindowEventID : byte
1480 {
1481 SDL_WINDOWEVENT_NONE,
1482 SDL_WINDOWEVENT_SHOWN,
1483 SDL_WINDOWEVENT_HIDDEN,
1484 SDL_WINDOWEVENT_EXPOSED,
1485 SDL_WINDOWEVENT_MOVED,
1486 SDL_WINDOWEVENT_RESIZED,
1487 SDL_WINDOWEVENT_SIZE_CHANGED,
1488 SDL_WINDOWEVENT_MINIMIZED,
1489 SDL_WINDOWEVENT_MAXIMIZED,
1490 SDL_WINDOWEVENT_RESTORED,
1491 SDL_WINDOWEVENT_ENTER,
1492 SDL_WINDOWEVENT_LEAVE,
1493 SDL_WINDOWEVENT_FOCUS_GAINED,
1494 SDL_WINDOWEVENT_FOCUS_LOST,
1495 SDL_WINDOWEVENT_CLOSE,
1496 /* Only available in 2.0.5 or higher. */
1497 SDL_WINDOWEVENT_TAKE_FOCUS,
1498 SDL_WINDOWEVENT_HIT_TEST,
1499 /* Only available in 2.0.18 or higher. */
1500 SDL_WINDOWEVENT_ICCPROF_CHANGED,
1501 SDL_WINDOWEVENT_DISPLAY_CHANGED
1502 }
1503
1504 public enum SDL_DisplayEventID : byte
1505 {
1506 SDL_DISPLAYEVENT_NONE,
1507 SDL_DISPLAYEVENT_ORIENTATION,
1508 SDL_DISPLAYEVENT_CONNECTED, /* Requires >= 2.0.14 */
1509 SDL_DISPLAYEVENT_DISCONNECTED /* Requires >= 2.0.14 */
1510 }
1511
1512 public enum SDL_DisplayOrientation
1513 {
1514 SDL_ORIENTATION_UNKNOWN,
1515 SDL_ORIENTATION_LANDSCAPE,
1516 SDL_ORIENTATION_LANDSCAPE_FLIPPED,
1517 SDL_ORIENTATION_PORTRAIT,
1518 SDL_ORIENTATION_PORTRAIT_FLIPPED
1519 }
1520
1521 /* Only available in 2.0.16 or higher. */
1522 public enum SDL_FlashOperation
1523 {
1524 SDL_FLASH_CANCEL,
1525 SDL_FLASH_BRIEFLY,
1526 SDL_FLASH_UNTIL_FOCUSED
1527 }
1528
1529 [Flags]
1530 public enum SDL_WindowFlags : uint
1531 {
1532 SDL_WINDOW_FULLSCREEN = 0x00000001,
1533 SDL_WINDOW_OPENGL = 0x00000002,
1534 SDL_WINDOW_SHOWN = 0x00000004,
1535 SDL_WINDOW_HIDDEN = 0x00000008,
1536 SDL_WINDOW_BORDERLESS = 0x00000010,
1537 SDL_WINDOW_RESIZABLE = 0x00000020,
1538 SDL_WINDOW_MINIMIZED = 0x00000040,
1539 SDL_WINDOW_MAXIMIZED = 0x00000080,
1540 SDL_WINDOW_MOUSE_GRABBED = 0x00000100,
1541 SDL_WINDOW_INPUT_FOCUS = 0x00000200,
1542 SDL_WINDOW_MOUSE_FOCUS = 0x00000400,
1543 SDL_WINDOW_FULLSCREEN_DESKTOP =
1544 (SDL_WINDOW_FULLSCREEN | 0x00001000),
1545 SDL_WINDOW_FOREIGN = 0x00000800,
1546 SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /* Requires >= 2.0.1 */
1547 SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /* Requires >= 2.0.4 */
1548 SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /* Requires >= 2.0.5 */
1549 SDL_WINDOW_SKIP_TASKBAR = 0x00010000, /* Requires >= 2.0.5 */
1550 SDL_WINDOW_UTILITY = 0x00020000, /* Requires >= 2.0.5 */
1551 SDL_WINDOW_TOOLTIP = 0x00040000, /* Requires >= 2.0.5 */
1552 SDL_WINDOW_POPUP_MENU = 0x00080000, /* Requires >= 2.0.5 */
1553 SDL_WINDOW_KEYBOARD_GRABBED = 0x00100000, /* Requires >= 2.0.16 */
1554 SDL_WINDOW_VULKAN = 0x10000000, /* Requires >= 2.0.6 */
1555 SDL_WINDOW_METAL = 0x2000000, /* Requires >= 2.0.14 */
1556
1557 SDL_WINDOW_INPUT_GRABBED =
1558 SDL_WINDOW_MOUSE_GRABBED,
1559 }
1560
1561 /* Only available in 2.0.4 or higher. */
1562 public enum SDL_HitTestResult
1563 {
1564 SDL_HITTEST_NORMAL, /* Region is normal. No special properties. */
1565 SDL_HITTEST_DRAGGABLE, /* Region can drag entire window. */
1566 SDL_HITTEST_RESIZE_TOPLEFT,
1567 SDL_HITTEST_RESIZE_TOP,
1568 SDL_HITTEST_RESIZE_TOPRIGHT,
1569 SDL_HITTEST_RESIZE_RIGHT,
1570 SDL_HITTEST_RESIZE_BOTTOMRIGHT,
1571 SDL_HITTEST_RESIZE_BOTTOM,
1572 SDL_HITTEST_RESIZE_BOTTOMLEFT,
1573 SDL_HITTEST_RESIZE_LEFT
1574 }
1575
1576 public const int SDL_WINDOWPOS_UNDEFINED_MASK = 0x1FFF0000;
1577 public const int SDL_WINDOWPOS_CENTERED_MASK = 0x2FFF0000;
1578 public const int SDL_WINDOWPOS_UNDEFINED = 0x1FFF0000;
1579 public const int SDL_WINDOWPOS_CENTERED = 0x2FFF0000;
1580
1581 public static int SDL_WINDOWPOS_UNDEFINED_DISPLAY(int X)
1582 {
1583 return (SDL_WINDOWPOS_UNDEFINED_MASK | X);
1584 }
1585
1586 public static bool SDL_WINDOWPOS_ISUNDEFINED(int X)
1587 {
1588 return (X & 0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK;
1589 }
1590
1591 public static int SDL_WINDOWPOS_CENTERED_DISPLAY(int X)
1592 {
1593 return (SDL_WINDOWPOS_CENTERED_MASK | X);
1594 }
1595
1596 public static bool SDL_WINDOWPOS_ISCENTERED(int X)
1597 {
1598 return (X & 0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK;
1599 }
1600
1601 [StructLayout(LayoutKind.Sequential)]
1602 public struct SDL_DisplayMode
1603 {
1604 public uint format;
1605 public int w;
1606 public int h;
1607 public int refresh_rate;
1608 public IntPtr driverdata; // void*
1609 }
1610
1611 /* win refers to an SDL_Window*, area to a const SDL_Point*, data to a void*.
1612 * Only available in 2.0.4 or higher.
1613 */
1614 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
1615 public delegate SDL_HitTestResult SDL_HitTest(IntPtr win, IntPtr area, IntPtr data);
1616
1617 /* IntPtr refers to an SDL_Window* */
1618 [DllImport(nativeLibName, EntryPoint = "SDL_CreateWindow", CallingConvention = CallingConvention.Cdecl)]
1619 private static extern unsafe IntPtr INTERNAL_SDL_CreateWindow(
1620 byte* title,
1621 int x,
1622 int y,
1623 int w,
1624 int h,
1625 SDL_WindowFlags flags
1626 );
1627 public static unsafe IntPtr SDL_CreateWindow(
1628 string title,
1629 int x,
1630 int y,
1631 int w,
1632 int h,
1633 SDL_WindowFlags flags
1634 ) {
1635 int utf8TitleBufSize = Utf8Size(title);
1636 byte* utf8Title = stackalloc byte[utf8TitleBufSize];
1637 return INTERNAL_SDL_CreateWindow(
1638 Utf8Encode(title, utf8Title, utf8TitleBufSize),
1639 x, y, w, h,
1640 flags
1641 );
1642 }
1643
1644 /* window refers to an SDL_Window*, renderer to an SDL_Renderer* */
1645 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1646 public static extern int SDL_CreateWindowAndRenderer(
1647 int width,
1648 int height,
1649 SDL_WindowFlags window_flags,
1650 out IntPtr window,
1651 out IntPtr renderer
1652 );
1653
1654 /* data refers to some native window type, IntPtr to an SDL_Window* */
1655 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1656 public static extern IntPtr SDL_CreateWindowFrom(IntPtr data);
1657
1658 /* window refers to an SDL_Window* */
1659 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1660 public static extern void SDL_DestroyWindow(IntPtr window);
1661
1662 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1663 public static extern void SDL_DisableScreenSaver();
1664
1665 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1666 public static extern void SDL_EnableScreenSaver();
1667
1668 /* IntPtr refers to an SDL_DisplayMode. Just use closest. */
1669 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1670 public static extern IntPtr SDL_GetClosestDisplayMode(
1671 int displayIndex,
1672 ref SDL_DisplayMode mode,
1673 out SDL_DisplayMode closest
1674 );
1675
1676 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1677 public static extern int SDL_GetCurrentDisplayMode(
1678 int displayIndex,
1679 out SDL_DisplayMode mode
1680 );
1681
1682 [DllImport(nativeLibName, EntryPoint = "SDL_GetCurrentVideoDriver", CallingConvention = CallingConvention.Cdecl)]
1683 private static extern IntPtr INTERNAL_SDL_GetCurrentVideoDriver();
1684 public static string SDL_GetCurrentVideoDriver()
1685 {
1686 return UTF8_ToManaged(INTERNAL_SDL_GetCurrentVideoDriver());
1687 }
1688
1689 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1690 public static extern int SDL_GetDesktopDisplayMode(
1691 int displayIndex,
1692 out SDL_DisplayMode mode
1693 );
1694
1695 [DllImport(nativeLibName, EntryPoint = "SDL_GetDisplayName", CallingConvention = CallingConvention.Cdecl)]
1696 private static extern IntPtr INTERNAL_SDL_GetDisplayName(int index);
1697 public static string SDL_GetDisplayName(int index)
1698 {
1699 return UTF8_ToManaged(INTERNAL_SDL_GetDisplayName(index));
1700 }
1701
1702 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1703 public static extern int SDL_GetDisplayBounds(
1704 int displayIndex,
1705 out SDL_Rect rect
1706 );
1707
1708 /* Only available in 2.0.4 or higher. */
1709 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1710 public static extern int SDL_GetDisplayDPI(
1711 int displayIndex,
1712 out float ddpi,
1713 out float hdpi,
1714 out float vdpi
1715 );
1716
1717 /* Only available in 2.0.9 or higher. */
1718 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1719 public static extern SDL_DisplayOrientation SDL_GetDisplayOrientation(
1720 int displayIndex
1721 );
1722
1723 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1724 public static extern int SDL_GetDisplayMode(
1725 int displayIndex,
1726 int modeIndex,
1727 out SDL_DisplayMode mode
1728 );
1729
1730 /* Only available in 2.0.5 or higher. */
1731 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1732 public static extern int SDL_GetDisplayUsableBounds(
1733 int displayIndex,
1734 out SDL_Rect rect
1735 );
1736
1737 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1738 public static extern int SDL_GetNumDisplayModes(
1739 int displayIndex
1740 );
1741
1742 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1743 public static extern int SDL_GetNumVideoDisplays();
1744
1745 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1746 public static extern int SDL_GetNumVideoDrivers();
1747
1748 [DllImport(nativeLibName, EntryPoint = "SDL_GetVideoDriver", CallingConvention = CallingConvention.Cdecl)]
1749 private static extern IntPtr INTERNAL_SDL_GetVideoDriver(
1750 int index
1751 );
1752 public static string SDL_GetVideoDriver(int index)
1753 {
1754 return UTF8_ToManaged(INTERNAL_SDL_GetVideoDriver(index));
1755 }
1756
1757 /* window refers to an SDL_Window* */
1758 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1759 public static extern float SDL_GetWindowBrightness(
1760 IntPtr window
1761 );
1762
1763 /* window refers to an SDL_Window*
1764 * Only available in 2.0.5 or higher.
1765 */
1766 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1767 public static extern int SDL_SetWindowOpacity(
1768 IntPtr window,
1769 float opacity
1770 );
1771
1772 /* window refers to an SDL_Window*
1773 * Only available in 2.0.5 or higher.
1774 */
1775 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1776 public static extern int SDL_GetWindowOpacity(
1777 IntPtr window,
1778 out float out_opacity
1779 );
1780
1781 /* modal_window and parent_window refer to an SDL_Window*s
1782 * Only available in 2.0.5 or higher.
1783 */
1784 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1785 public static extern int SDL_SetWindowModalFor(
1786 IntPtr modal_window,
1787 IntPtr parent_window
1788 );
1789
1790 /* window refers to an SDL_Window*
1791 * Only available in 2.0.5 or higher.
1792 */
1793 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1794 public static extern int SDL_SetWindowInputFocus(IntPtr window);
1795
1796 /* window refers to an SDL_Window*, IntPtr to a void* */
1797 [DllImport(nativeLibName, EntryPoint = "SDL_GetWindowData", CallingConvention = CallingConvention.Cdecl)]
1798 private static extern unsafe IntPtr INTERNAL_SDL_GetWindowData(
1799 IntPtr window,
1800 byte* name
1801 );
1802 public static unsafe IntPtr SDL_GetWindowData(
1803 IntPtr window,
1804 string name
1805 ) {
1806 int utf8NameBufSize = Utf8Size(name);
1807 byte* utf8Name = stackalloc byte[utf8NameBufSize];
1808 return INTERNAL_SDL_GetWindowData(
1809 window,
1810 Utf8Encode(name, utf8Name, utf8NameBufSize)
1811 );
1812 }
1813
1814 /* window refers to an SDL_Window* */
1815 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1816 public static extern int SDL_GetWindowDisplayIndex(
1817 IntPtr window
1818 );
1819
1820 /* window refers to an SDL_Window* */
1821 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1822 public static extern int SDL_GetWindowDisplayMode(
1823 IntPtr window,
1824 out SDL_DisplayMode mode
1825 );
1826
1827 /* IntPtr refers to a void*
1828 * window refers to an SDL_Window*
1829 * mode refers to a size_t*
1830 * Only available in 2.0.18 or higher.
1831 */
1832 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1833 public static extern IntPtr SDL_GetWindowICCProfile(
1834 IntPtr window,
1835 out IntPtr mode
1836 );
1837
1838 /* window refers to an SDL_Window* */
1839 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1840 public static extern uint SDL_GetWindowFlags(IntPtr window);
1841
1842 /* IntPtr refers to an SDL_Window* */
1843 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1844 public static extern IntPtr SDL_GetWindowFromID(uint id);
1845
1846 /* window refers to an SDL_Window* */
1847 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1848 public static extern int SDL_GetWindowGammaRamp(
1849 IntPtr window,
1850 [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]
1851 ushort[] red,
1852 [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]
1853 ushort[] green,
1854 [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]
1855 ushort[] blue
1856 );
1857
1858 /* window refers to an SDL_Window* */
1859 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1860 public static extern SDL_bool SDL_GetWindowGrab(IntPtr window);
1861
1862 /* window refers to an SDL_Window*
1863 * Only available in 2.0.16 or higher.
1864 */
1865 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1866 public static extern SDL_bool SDL_GetWindowKeyboardGrab(IntPtr window);
1867
1868 /* window refers to an SDL_Window*
1869 * Only available in 2.0.16 or higher.
1870 */
1871 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1872 public static extern SDL_bool SDL_GetWindowMouseGrab(IntPtr window);
1873
1874 /* window refers to an SDL_Window* */
1875 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1876 public static extern uint SDL_GetWindowID(IntPtr window);
1877
1878 /* window refers to an SDL_Window* */
1879 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1880 public static extern uint SDL_GetWindowPixelFormat(
1881 IntPtr window
1882 );
1883
1884 /* window refers to an SDL_Window* */
1885 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1886 public static extern void SDL_GetWindowMaximumSize(
1887 IntPtr window,
1888 out int max_w,
1889 out int max_h
1890 );
1891
1892 /* window refers to an SDL_Window* */
1893 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1894 public static extern void SDL_GetWindowMinimumSize(
1895 IntPtr window,
1896 out int min_w,
1897 out int min_h
1898 );
1899
1900 /* window refers to an SDL_Window* */
1901 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1902 public static extern void SDL_GetWindowPosition(
1903 IntPtr window,
1904 out int x,
1905 out int y
1906 );
1907
1908 /* window refers to an SDL_Window* */
1909 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1910 public static extern void SDL_GetWindowSize(
1911 IntPtr window,
1912 out int w,
1913 out int h
1914 );
1915
1916 /* IntPtr refers to an SDL_Surface*, window to an SDL_Window* */
1917 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1918 public static extern IntPtr SDL_GetWindowSurface(IntPtr window);
1919
1920 /* window refers to an SDL_Window* */
1921 [DllImport(nativeLibName, EntryPoint = "SDL_GetWindowTitle", CallingConvention = CallingConvention.Cdecl)]
1922 private static extern IntPtr INTERNAL_SDL_GetWindowTitle(
1923 IntPtr window
1924 );
1925 public static string SDL_GetWindowTitle(IntPtr window)
1926 {
1927 return UTF8_ToManaged(
1928 INTERNAL_SDL_GetWindowTitle(window)
1929 );
1930 }
1931
1932 /* texture refers to an SDL_Texture* */
1933 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1934 public static extern int SDL_GL_BindTexture(
1935 IntPtr texture,
1936 out float texw,
1937 out float texh
1938 );
1939
1940 /* IntPtr and window refer to an SDL_GLContext and SDL_Window* */
1941 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1942 public static extern IntPtr SDL_GL_CreateContext(IntPtr window);
1943
1944 /* context refers to an SDL_GLContext */
1945 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1946 public static extern void SDL_GL_DeleteContext(IntPtr context);
1947
1948 [DllImport(nativeLibName, EntryPoint = "SDL_GL_LoadLibrary", CallingConvention = CallingConvention.Cdecl)]
1949 private static extern unsafe int INTERNAL_SDL_GL_LoadLibrary(byte* path);
1950 public static unsafe int SDL_GL_LoadLibrary(string path)
1951 {
1952 byte* utf8Path = Utf8EncodeHeap(path);
1953 int result = INTERNAL_SDL_GL_LoadLibrary(
1954 utf8Path
1955 );
1956 Marshal.FreeHGlobal((IntPtr) utf8Path);
1957 return result;
1958 }
1959
1960 /* IntPtr refers to a function pointer, proc to a const char* */
1961 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1962 public static extern IntPtr SDL_GL_GetProcAddress(IntPtr proc);
1963
1964 /* IntPtr refers to a function pointer */
1965 public static unsafe IntPtr SDL_GL_GetProcAddress(string proc)
1966 {
1967 int utf8ProcBufSize = Utf8Size(proc);
1968 byte* utf8Proc = stackalloc byte[utf8ProcBufSize];
1969 return SDL_GL_GetProcAddress(
1970 (IntPtr) Utf8Encode(proc, utf8Proc, utf8ProcBufSize)
1971 );
1972 }
1973
1974 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1975 public static extern void SDL_GL_UnloadLibrary();
1976
1977 [DllImport(nativeLibName, EntryPoint = "SDL_GL_ExtensionSupported", CallingConvention = CallingConvention.Cdecl)]
1978 private static extern unsafe SDL_bool INTERNAL_SDL_GL_ExtensionSupported(
1979 byte* extension
1980 );
1981 public static unsafe SDL_bool SDL_GL_ExtensionSupported(string extension)
1982 {
1983 int utf8ExtensionBufSize = Utf8Size(extension);
1984 byte* utf8Extension = stackalloc byte[utf8ExtensionBufSize];
1985 return INTERNAL_SDL_GL_ExtensionSupported(
1986 Utf8Encode(extension, utf8Extension, utf8ExtensionBufSize)
1987 );
1988 }
1989
1990 /* Only available in SDL 2.0.2 or higher. */
1991 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1992 public static extern void SDL_GL_ResetAttributes();
1993
1994 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
1995 public static extern int SDL_GL_GetAttribute(
1996 SDL_GLattr attr,
1997 out int value
1998 );
1999
2000 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2001 public static extern int SDL_GL_GetSwapInterval();
2002
2003 /* window and context refer to an SDL_Window* and SDL_GLContext */
2004 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2005 public static extern int SDL_GL_MakeCurrent(
2006 IntPtr window,
2007 IntPtr context
2008 );
2009
2010 /* IntPtr refers to an SDL_Window* */
2011 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2012 public static extern IntPtr SDL_GL_GetCurrentWindow();
2013
2014 /* IntPtr refers to an SDL_Context */
2015 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2016 public static extern IntPtr SDL_GL_GetCurrentContext();
2017
2018 /* window refers to an SDL_Window*.
2019 * Only available in SDL 2.0.1 or higher.
2020 */
2021 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2022 public static extern void SDL_GL_GetDrawableSize(
2023 IntPtr window,
2024 out int w,
2025 out int h
2026 );
2027
2028 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2029 public static extern int SDL_GL_SetAttribute(
2030 SDL_GLattr attr,
2031 int value
2032 );
2033
2034 public static int SDL_GL_SetAttribute(
2035 SDL_GLattr attr,
2036 SDL_GLprofile profile
2037 ) {
2038 return SDL_GL_SetAttribute(attr, (int)profile);
2039 }
2040
2041 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2042 public static extern int SDL_GL_SetSwapInterval(int interval);
2043
2044 /* window refers to an SDL_Window* */
2045 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2046 public static extern void SDL_GL_SwapWindow(IntPtr window);
2047
2048 /* texture refers to an SDL_Texture* */
2049 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2050 public static extern int SDL_GL_UnbindTexture(IntPtr texture);
2051
2052 /* window refers to an SDL_Window* */
2053 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2054 public static extern void SDL_HideWindow(IntPtr window);
2055
2056 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2057 public static extern SDL_bool SDL_IsScreenSaverEnabled();
2058
2059 /* window refers to an SDL_Window* */
2060 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2061 public static extern void SDL_MaximizeWindow(IntPtr window);
2062
2063 /* window refers to an SDL_Window* */
2064 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2065 public static extern void SDL_MinimizeWindow(IntPtr window);
2066
2067 /* window refers to an SDL_Window* */
2068 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2069 public static extern void SDL_RaiseWindow(IntPtr window);
2070
2071 /* window refers to an SDL_Window* */
2072 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2073 public static extern void SDL_RestoreWindow(IntPtr window);
2074
2075 /* window refers to an SDL_Window* */
2076 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2077 public static extern int SDL_SetWindowBrightness(
2078 IntPtr window,
2079 float brightness
2080 );
2081
2082 /* IntPtr and userdata are void*, window is an SDL_Window* */
2083 [DllImport(nativeLibName, EntryPoint = "SDL_SetWindowData", CallingConvention = CallingConvention.Cdecl)]
2084 private static extern unsafe IntPtr INTERNAL_SDL_SetWindowData(
2085 IntPtr window,
2086 byte* name,
2087 IntPtr userdata
2088 );
2089 public static unsafe IntPtr SDL_SetWindowData(
2090 IntPtr window,
2091 string name,
2092 IntPtr userdata
2093 ) {
2094 int utf8NameBufSize = Utf8Size(name);
2095 byte* utf8Name = stackalloc byte[utf8NameBufSize];
2096 return INTERNAL_SDL_SetWindowData(
2097 window,
2098 Utf8Encode(name, utf8Name, utf8NameBufSize),
2099 userdata
2100 );
2101 }
2102
2103 /* window refers to an SDL_Window* */
2104 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2105 public static extern int SDL_SetWindowDisplayMode(
2106 IntPtr window,
2107 ref SDL_DisplayMode mode
2108 );
2109
2110 /* window refers to an SDL_Window* */
2111 /* NULL overload - use the window's dimensions and the desktop's format and refresh rate */
2112 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2113 public static extern int SDL_SetWindowDisplayMode(
2114 IntPtr window,
2115 IntPtr mode
2116 );
2117
2118 /* window refers to an SDL_Window* */
2119 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2120 public static extern int SDL_SetWindowFullscreen(
2121 IntPtr window,
2122 uint flags
2123 );
2124
2125 /* window refers to an SDL_Window* */
2126 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2127 public static extern int SDL_SetWindowGammaRamp(
2128 IntPtr window,
2129 [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]
2130 ushort[] red,
2131 [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]
2132 ushort[] green,
2133 [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]
2134 ushort[] blue
2135 );
2136
2137 /* window refers to an SDL_Window* */
2138 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2139 public static extern void SDL_SetWindowGrab(
2140 IntPtr window,
2141 SDL_bool grabbed
2142 );
2143
2144 /* window refers to an SDL_Window*
2145 * Only available in 2.0.16 or higher.
2146 */
2147 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2148 public static extern void SDL_SetWindowKeyboardGrab(
2149 IntPtr window,
2150 SDL_bool grabbed
2151 );
2152
2153 /* window refers to an SDL_Window*
2154 * Only available in 2.0.16 or higher.
2155 */
2156 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2157 public static extern void SDL_SetWindowMouseGrab(
2158 IntPtr window,
2159 SDL_bool grabbed
2160 );
2161
2162
2163 /* window refers to an SDL_Window*, icon to an SDL_Surface* */
2164 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2165 public static extern void SDL_SetWindowIcon(
2166 IntPtr window,
2167 IntPtr icon
2168 );
2169
2170 /* window refers to an SDL_Window* */
2171 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2172 public static extern void SDL_SetWindowMaximumSize(
2173 IntPtr window,
2174 int max_w,
2175 int max_h
2176 );
2177
2178 /* window refers to an SDL_Window* */
2179 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2180 public static extern void SDL_SetWindowMinimumSize(
2181 IntPtr window,
2182 int min_w,
2183 int min_h
2184 );
2185
2186 /* window refers to an SDL_Window* */
2187 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2188 public static extern void SDL_SetWindowPosition(
2189 IntPtr window,
2190 int x,
2191 int y
2192 );
2193
2194 /* window refers to an SDL_Window* */
2195 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2196 public static extern void SDL_SetWindowSize(
2197 IntPtr window,
2198 int w,
2199 int h
2200 );
2201
2202 /* window refers to an SDL_Window* */
2203 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2204 public static extern void SDL_SetWindowBordered(
2205 IntPtr window,
2206 SDL_bool bordered
2207 );
2208
2209 /* window refers to an SDL_Window* */
2210 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2211 public static extern int SDL_GetWindowBordersSize(
2212 IntPtr window,
2213 out int top,
2214 out int left,
2215 out int bottom,
2216 out int right
2217 );
2218
2219 /* window refers to an SDL_Window*
2220 * Only available in 2.0.5 or higher.
2221 */
2222 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2223 public static extern void SDL_SetWindowResizable(
2224 IntPtr window,
2225 SDL_bool resizable
2226 );
2227
2228 /* window refers to an SDL_Window*
2229 * Only available in 2.0.16 or higher.
2230 */
2231 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2232 public static extern void SDL_SetWindowAlwaysOnTop(
2233 IntPtr window,
2234 SDL_bool on_top
2235 );
2236
2237 /* window refers to an SDL_Window* */
2238 [DllImport(nativeLibName, EntryPoint = "SDL_SetWindowTitle", CallingConvention = CallingConvention.Cdecl)]
2239 private static extern unsafe void INTERNAL_SDL_SetWindowTitle(
2240 IntPtr window,
2241 byte* title
2242 );
2243 public static unsafe void SDL_SetWindowTitle(
2244 IntPtr window,
2245 string title
2246 ) {
2247 int utf8TitleBufSize = Utf8Size(title);
2248 byte* utf8Title = stackalloc byte[utf8TitleBufSize];
2249 INTERNAL_SDL_SetWindowTitle(
2250 window,
2251 Utf8Encode(title, utf8Title, utf8TitleBufSize)
2252 );
2253 }
2254
2255 /* window refers to an SDL_Window* */
2256 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2257 public static extern void SDL_ShowWindow(IntPtr window);
2258
2259 /* window refers to an SDL_Window* */
2260 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2261 public static extern int SDL_UpdateWindowSurface(IntPtr window);
2262
2263 /* window refers to an SDL_Window* */
2264 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2265 public static extern int SDL_UpdateWindowSurfaceRects(
2266 IntPtr window,
2267 [In] SDL_Rect[] rects,
2268 int numrects
2269 );
2270
2271 [DllImport(nativeLibName, EntryPoint = "SDL_VideoInit", CallingConvention = CallingConvention.Cdecl)]
2272 private static extern unsafe int INTERNAL_SDL_VideoInit(
2273 byte* driver_name
2274 );
2275 public static unsafe int SDL_VideoInit(string driver_name)
2276 {
2277 int utf8DriverNameBufSize = Utf8Size(driver_name);
2278 byte* utf8DriverName = stackalloc byte[utf8DriverNameBufSize];
2279 return INTERNAL_SDL_VideoInit(
2280 Utf8Encode(driver_name, utf8DriverName, utf8DriverNameBufSize)
2281 );
2282 }
2283
2284 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2285 public static extern void SDL_VideoQuit();
2286
2287 /* window refers to an SDL_Window*, callback_data to a void*
2288 * Only available in 2.0.4 or higher.
2289 */
2290 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2291 public static extern int SDL_SetWindowHitTest(
2292 IntPtr window,
2293 SDL_HitTest callback,
2294 IntPtr callback_data
2295 );
2296
2297 /* IntPtr refers to an SDL_Window*
2298 * Only available in 2.0.4 or higher.
2299 */
2300 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2301 public static extern IntPtr SDL_GetGrabbedWindow();
2302
2303 /* window refers to an SDL_Window*
2304 * Only available in 2.0.18 or higher.
2305 */
2306 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2307 public static extern int SDL_SetWindowMouseRect(
2308 IntPtr window,
2309 ref SDL_Rect rect
2310 );
2311
2312 /* window refers to an SDL_Window*
2313 * rect refers to an SDL_Rect*
2314 * This overload allows for IntPtr.Zero (null) to be passed for rect.
2315 * Only available in 2.0.18 or higher.
2316 */
2317 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2318 public static extern int SDL_SetWindowMouseRect(
2319 IntPtr window,
2320 IntPtr rect
2321 );
2322
2323 /* window refers to an SDL_Window*
2324 * IntPtr refers to an SDL_Rect*
2325 * Only available in 2.0.18 or higher.
2326 */
2327 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2328 public static extern IntPtr SDL_GetWindowMouseRect(
2329 IntPtr window
2330 );
2331
2332 /* window refers to an SDL_Window*
2333 * Only available in 2.0.16 or higher.
2334 */
2335 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2336 public static extern int SDL_FlashWindow(
2337 IntPtr window,
2338 SDL_FlashOperation operation
2339 );
2340
2341 #endregion
2342
2343 #region SDL_blendmode.h
2344
2345 [Flags]
2346 public enum SDL_BlendMode
2347 {
2348 SDL_BLENDMODE_NONE = 0x00000000,
2349 SDL_BLENDMODE_BLEND = 0x00000001,
2350 SDL_BLENDMODE_ADD = 0x00000002,
2351 SDL_BLENDMODE_MOD = 0x00000004,
2352 SDL_BLENDMODE_MUL = 0x00000008, /* >= 2.0.11 */
2353 SDL_BLENDMODE_INVALID = 0x7FFFFFFF
2354 }
2355
2356 public enum SDL_BlendOperation
2357 {
2358 SDL_BLENDOPERATION_ADD = 0x1,
2359 SDL_BLENDOPERATION_SUBTRACT = 0x2,
2360 SDL_BLENDOPERATION_REV_SUBTRACT = 0x3,
2361 SDL_BLENDOPERATION_MINIMUM = 0x4,
2362 SDL_BLENDOPERATION_MAXIMUM = 0x5
2363 }
2364
2365 public enum SDL_BlendFactor
2366 {
2367 SDL_BLENDFACTOR_ZERO = 0x1,
2368 SDL_BLENDFACTOR_ONE = 0x2,
2369 SDL_BLENDFACTOR_SRC_COLOR = 0x3,
2370 SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4,
2371 SDL_BLENDFACTOR_SRC_ALPHA = 0x5,
2372 SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6,
2373 SDL_BLENDFACTOR_DST_COLOR = 0x7,
2374 SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8,
2375 SDL_BLENDFACTOR_DST_ALPHA = 0x9,
2376 SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA
2377 }
2378
2379 /* Only available in 2.0.6 or higher. */
2380 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2381 public static extern SDL_BlendMode SDL_ComposeCustomBlendMode(
2382 SDL_BlendFactor srcColorFactor,
2383 SDL_BlendFactor dstColorFactor,
2384 SDL_BlendOperation colorOperation,
2385 SDL_BlendFactor srcAlphaFactor,
2386 SDL_BlendFactor dstAlphaFactor,
2387 SDL_BlendOperation alphaOperation
2388 );
2389
2390 #endregion
2391
2392 #region SDL_vulkan.h
2393
2394 /* Only available in 2.0.6 or higher. */
2395 [DllImport(nativeLibName, EntryPoint = "SDL_Vulkan_LoadLibrary", CallingConvention = CallingConvention.Cdecl)]
2396 private static extern unsafe int INTERNAL_SDL_Vulkan_LoadLibrary(
2397 byte* path
2398 );
2399 public static unsafe int SDL_Vulkan_LoadLibrary(string path)
2400 {
2401 byte* utf8Path = Utf8EncodeHeap(path);
2402 int result = INTERNAL_SDL_Vulkan_LoadLibrary(
2403 utf8Path
2404 );
2405 Marshal.FreeHGlobal((IntPtr) utf8Path);
2406 return result;
2407 }
2408
2409 /* Only available in 2.0.6 or higher. */
2410 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2411 public static extern IntPtr SDL_Vulkan_GetVkGetInstanceProcAddr();
2412
2413 /* Only available in 2.0.6 or higher. */
2414 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2415 public static extern void SDL_Vulkan_UnloadLibrary();
2416
2417 /* window refers to an SDL_Window*, pNames to a const char**.
2418 * Only available in 2.0.6 or higher.
2419 * This overload allows for IntPtr.Zero (null) to be passed for pNames.
2420 */
2421 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2422 public static extern SDL_bool SDL_Vulkan_GetInstanceExtensions(
2423 IntPtr window,
2424 out uint pCount,
2425 IntPtr pNames
2426 );
2427
2428 /* window refers to an SDL_Window*, pNames to a const char**.
2429 * Only available in 2.0.6 or higher.
2430 */
2431 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2432 public static extern SDL_bool SDL_Vulkan_GetInstanceExtensions(
2433 IntPtr window,
2434 out uint pCount,
2435 IntPtr[] pNames
2436 );
2437
2438 /* window refers to an SDL_Window.
2439 * instance refers to a VkInstance.
2440 * surface refers to a VkSurfaceKHR.
2441 * Only available in 2.0.6 or higher.
2442 */
2443 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2444 public static extern SDL_bool SDL_Vulkan_CreateSurface(
2445 IntPtr window,
2446 IntPtr instance,
2447 out ulong surface
2448 );
2449
2450 /* window refers to an SDL_Window*.
2451 * Only available in 2.0.6 or higher.
2452 */
2453 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2454 public static extern void SDL_Vulkan_GetDrawableSize(
2455 IntPtr window,
2456 out int w,
2457 out int h
2458 );
2459
2460 #endregion
2461
2462 #region SDL_metal.h
2463
2464 /* Only available in 2.0.11 or higher. */
2465 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2466 public static extern IntPtr SDL_Metal_CreateView(
2467 IntPtr window
2468 );
2469
2470 /* Only available in 2.0.11 or higher. */
2471 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2472 public static extern void SDL_Metal_DestroyView(
2473 IntPtr view
2474 );
2475
2476 /* view refers to an SDL_MetalView.
2477 * Only available in 2.0.14 or higher. */
2478 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2479 public static extern IntPtr SDL_Metal_GetLayer(
2480 IntPtr view
2481 );
2482
2483 /* window refers to an SDL_Window*.
2484 * Only available in 2.0.14 or higher.
2485 */
2486 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2487 public static extern void SDL_Metal_GetDrawableSize(
2488 IntPtr window,
2489 out int w,
2490 out int h
2491 );
2492
2493 #endregion
2494
2495 #region SDL_render.h
2496
2497 [Flags]
2498 public enum SDL_RendererFlags : uint
2499 {
2500 SDL_RENDERER_SOFTWARE = 0x00000001,
2501 SDL_RENDERER_ACCELERATED = 0x00000002,
2502 SDL_RENDERER_PRESENTVSYNC = 0x00000004,
2503 SDL_RENDERER_TARGETTEXTURE = 0x00000008
2504 }
2505
2506 [Flags]
2507 public enum SDL_RendererFlip
2508 {
2509 SDL_FLIP_NONE = 0x00000000,
2510 SDL_FLIP_HORIZONTAL = 0x00000001,
2511 SDL_FLIP_VERTICAL = 0x00000002
2512 }
2513
2514 public enum SDL_TextureAccess
2515 {
2516 SDL_TEXTUREACCESS_STATIC,
2517 SDL_TEXTUREACCESS_STREAMING,
2518 SDL_TEXTUREACCESS_TARGET
2519 }
2520
2521 [Flags]
2522 public enum SDL_TextureModulate
2523 {
2524 SDL_TEXTUREMODULATE_NONE = 0x00000000,
2525 SDL_TEXTUREMODULATE_HORIZONTAL = 0x00000001,
2526 SDL_TEXTUREMODULATE_VERTICAL = 0x00000002
2527 }
2528
2529 [StructLayout(LayoutKind.Sequential)]
2530 public unsafe struct SDL_RendererInfo
2531 {
2532 public IntPtr name; // const char*
2533 public uint flags;
2534 public uint num_texture_formats;
2535 public fixed uint texture_formats[16];
2536 public int max_texture_width;
2537 public int max_texture_height;
2538 }
2539
2540 /* Only available in 2.0.11 or higher. */
2541 public enum SDL_ScaleMode
2542 {
2543 SDL_ScaleModeNearest,
2544 SDL_ScaleModeLinear,
2545 SDL_ScaleModeBest
2546 }
2547
2548 /* Only available in 2.0.18 or higher. */
2549 [StructLayout(LayoutKind.Sequential)]
2550 public struct SDL_Vertex
2551 {
2552 public SDL_FPoint position;
2553 public SDL_Color color;
2554 public SDL_FPoint tex_coord;
2555 }
2556
2557 /* IntPtr refers to an SDL_Renderer*, window to an SDL_Window* */
2558 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2559 public static extern IntPtr SDL_CreateRenderer(
2560 IntPtr window,
2561 int index,
2562 SDL_RendererFlags flags
2563 );
2564
2565 /* IntPtr refers to an SDL_Renderer*, surface to an SDL_Surface* */
2566 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2567 public static extern IntPtr SDL_CreateSoftwareRenderer(IntPtr surface);
2568
2569 /* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */
2570 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2571 public static extern IntPtr SDL_CreateTexture(
2572 IntPtr renderer,
2573 uint format,
2574 int access,
2575 int w,
2576 int h
2577 );
2578
2579 /* IntPtr refers to an SDL_Texture*
2580 * renderer refers to an SDL_Renderer*
2581 * surface refers to an SDL_Surface*
2582 */
2583 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2584 public static extern IntPtr SDL_CreateTextureFromSurface(
2585 IntPtr renderer,
2586 IntPtr surface
2587 );
2588
2589 /* renderer refers to an SDL_Renderer* */
2590 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2591 public static extern void SDL_DestroyRenderer(IntPtr renderer);
2592
2593 /* texture refers to an SDL_Texture* */
2594 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2595 public static extern void SDL_DestroyTexture(IntPtr texture);
2596
2597 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2598 public static extern int SDL_GetNumRenderDrivers();
2599
2600 /* renderer refers to an SDL_Renderer* */
2601 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2602 public static extern int SDL_GetRenderDrawBlendMode(
2603 IntPtr renderer,
2604 out SDL_BlendMode blendMode
2605 );
2606
2607 /* texture refers to an SDL_Texture*
2608 * Only available in 2.0.11 or higher.
2609 */
2610 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2611 public static extern int SDL_SetTextureScaleMode(
2612 IntPtr texture,
2613 SDL_ScaleMode scaleMode
2614 );
2615
2616 /* texture refers to an SDL_Texture*
2617 * Only available in 2.0.11 or higher.
2618 */
2619 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2620 public static extern int SDL_GetTextureScaleMode(
2621 IntPtr texture,
2622 out SDL_ScaleMode scaleMode
2623 );
2624
2625 /* texture refers to an SDL_Texture*
2626 * userdata refers to a void*
2627 * Only available in 2.0.18 or higher.
2628 */
2629 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2630 public static extern int SDL_SetTextureUserData(
2631 IntPtr texture,
2632 IntPtr userdata
2633 );
2634
2635 /* IntPtr refers to a void*, texture refers to an SDL_Texture*
2636 * Only available in 2.0.18 or higher.
2637 */
2638 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2639 public static extern IntPtr SDL_GetTextureUserData(IntPtr texture);
2640
2641 /* renderer refers to an SDL_Renderer* */
2642 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2643 public static extern int SDL_GetRenderDrawColor(
2644 IntPtr renderer,
2645 out byte r,
2646 out byte g,
2647 out byte b,
2648 out byte a
2649 );
2650
2651 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2652 public static extern int SDL_GetRenderDriverInfo(
2653 int index,
2654 out SDL_RendererInfo info
2655 );
2656
2657 /* IntPtr refers to an SDL_Renderer*, window to an SDL_Window* */
2658 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2659 public static extern IntPtr SDL_GetRenderer(IntPtr window);
2660
2661 /* renderer refers to an SDL_Renderer* */
2662 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2663 public static extern int SDL_GetRendererInfo(
2664 IntPtr renderer,
2665 out SDL_RendererInfo info
2666 );
2667
2668 /* renderer refers to an SDL_Renderer* */
2669 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2670 public static extern int SDL_GetRendererOutputSize(
2671 IntPtr renderer,
2672 out int w,
2673 out int h
2674 );
2675
2676 /* texture refers to an SDL_Texture* */
2677 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2678 public static extern int SDL_GetTextureAlphaMod(
2679 IntPtr texture,
2680 out byte alpha
2681 );
2682
2683 /* texture refers to an SDL_Texture* */
2684 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2685 public static extern int SDL_GetTextureBlendMode(
2686 IntPtr texture,
2687 out SDL_BlendMode blendMode
2688 );
2689
2690 /* texture refers to an SDL_Texture* */
2691 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2692 public static extern int SDL_GetTextureColorMod(
2693 IntPtr texture,
2694 out byte r,
2695 out byte g,
2696 out byte b
2697 );
2698
2699 /* texture refers to an SDL_Texture*, pixels to a void* */
2700 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2701 public static extern int SDL_LockTexture(
2702 IntPtr texture,
2703 ref SDL_Rect rect,
2704 out IntPtr pixels,
2705 out int pitch
2706 );
2707
2708 /* texture refers to an SDL_Texture*, pixels to a void*.
2709 * Internally, this function contains logic to use default values when
2710 * the rectangle is passed as NULL.
2711 * This overload allows for IntPtr.Zero to be passed for rect.
2712 */
2713 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2714 public static extern int SDL_LockTexture(
2715 IntPtr texture,
2716 IntPtr rect,
2717 out IntPtr pixels,
2718 out int pitch
2719 );
2720
2721 /* texture refers to an SDL_Texture*, surface to an SDL_Surface*
2722 * Only available in 2.0.11 or higher.
2723 */
2724 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2725 public static extern int SDL_LockTextureToSurface(
2726 IntPtr texture,
2727 ref SDL_Rect rect,
2728 out IntPtr surface
2729 );
2730
2731 /* texture refers to an SDL_Texture*, surface to an SDL_Surface*
2732 * Internally, this function contains logic to use default values when
2733 * the rectangle is passed as NULL.
2734 * This overload allows for IntPtr.Zero to be passed for rect.
2735 * Only available in 2.0.11 or higher.
2736 */
2737 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2738 public static extern int SDL_LockTextureToSurface(
2739 IntPtr texture,
2740 IntPtr rect,
2741 out IntPtr surface
2742 );
2743
2744 /* texture refers to an SDL_Texture* */
2745 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2746 public static extern int SDL_QueryTexture(
2747 IntPtr texture,
2748 out uint format,
2749 out int access,
2750 out int w,
2751 out int h
2752 );
2753
2754 /* renderer refers to an SDL_Renderer* */
2755 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2756 public static extern int SDL_RenderClear(IntPtr renderer);
2757
2758 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */
2759 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2760 public static extern int SDL_RenderCopy(
2761 IntPtr renderer,
2762 IntPtr texture,
2763 ref SDL_Rect srcrect,
2764 ref SDL_Rect dstrect
2765 );
2766
2767 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
2768 * Internally, this function contains logic to use default values when
2769 * source and destination rectangles are passed as NULL.
2770 * This overload allows for IntPtr.Zero (null) to be passed for srcrect.
2771 */
2772 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2773 public static extern int SDL_RenderCopy(
2774 IntPtr renderer,
2775 IntPtr texture,
2776 IntPtr srcrect,
2777 ref SDL_Rect dstrect
2778 );
2779
2780 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
2781 * Internally, this function contains logic to use default values when
2782 * source and destination rectangles are passed as NULL.
2783 * This overload allows for IntPtr.Zero (null) to be passed for dstrect.
2784 */
2785 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2786 public static extern int SDL_RenderCopy(
2787 IntPtr renderer,
2788 IntPtr texture,
2789 ref SDL_Rect srcrect,
2790 IntPtr dstrect
2791 );
2792
2793 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
2794 * Internally, this function contains logic to use default values when
2795 * source and destination rectangles are passed as NULL.
2796 * This overload allows for IntPtr.Zero (null) to be passed for both SDL_Rects.
2797 */
2798 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2799 public static extern int SDL_RenderCopy(
2800 IntPtr renderer,
2801 IntPtr texture,
2802 IntPtr srcrect,
2803 IntPtr dstrect
2804 );
2805
2806 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */
2807 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2808 public static extern int SDL_RenderCopyEx(
2809 IntPtr renderer,
2810 IntPtr texture,
2811 ref SDL_Rect srcrect,
2812 ref SDL_Rect dstrect,
2813 double angle,
2814 ref SDL_Point center,
2815 SDL_RendererFlip flip
2816 );
2817
2818 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
2819 * Internally, this function contains logic to use default values when
2820 * source, destination, and/or center are passed as NULL.
2821 * This overload allows for IntPtr.Zero (null) to be passed for srcrect.
2822 */
2823 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2824 public static extern int SDL_RenderCopyEx(
2825 IntPtr renderer,
2826 IntPtr texture,
2827 IntPtr srcrect,
2828 ref SDL_Rect dstrect,
2829 double angle,
2830 ref SDL_Point center,
2831 SDL_RendererFlip flip
2832 );
2833
2834 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
2835 * Internally, this function contains logic to use default values when
2836 * source, destination, and/or center are passed as NULL.
2837 * This overload allows for IntPtr.Zero (null) to be passed for dstrect.
2838 */
2839 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2840 public static extern int SDL_RenderCopyEx(
2841 IntPtr renderer,
2842 IntPtr texture,
2843 ref SDL_Rect srcrect,
2844 IntPtr dstrect,
2845 double angle,
2846 ref SDL_Point center,
2847 SDL_RendererFlip flip
2848 );
2849
2850 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
2851 * Internally, this function contains logic to use default values when
2852 * source, destination, and/or center are passed as NULL.
2853 * This overload allows for IntPtr.Zero (null) to be passed for center.
2854 */
2855 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2856 public static extern int SDL_RenderCopyEx(
2857 IntPtr renderer,
2858 IntPtr texture,
2859 ref SDL_Rect srcrect,
2860 ref SDL_Rect dstrect,
2861 double angle,
2862 IntPtr center,
2863 SDL_RendererFlip flip
2864 );
2865
2866 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
2867 * Internally, this function contains logic to use default values when
2868 * source, destination, and/or center are passed as NULL.
2869 * This overload allows for IntPtr.Zero (null) to be passed for both
2870 * srcrect and dstrect.
2871 */
2872 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2873 public static extern int SDL_RenderCopyEx(
2874 IntPtr renderer,
2875 IntPtr texture,
2876 IntPtr srcrect,
2877 IntPtr dstrect,
2878 double angle,
2879 ref SDL_Point center,
2880 SDL_RendererFlip flip
2881 );
2882
2883 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
2884 * Internally, this function contains logic to use default values when
2885 * source, destination, and/or center are passed as NULL.
2886 * This overload allows for IntPtr.Zero (null) to be passed for both
2887 * srcrect and center.
2888 */
2889 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2890 public static extern int SDL_RenderCopyEx(
2891 IntPtr renderer,
2892 IntPtr texture,
2893 IntPtr srcrect,
2894 ref SDL_Rect dstrect,
2895 double angle,
2896 IntPtr center,
2897 SDL_RendererFlip flip
2898 );
2899
2900 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
2901 * Internally, this function contains logic to use default values when
2902 * source, destination, and/or center are passed as NULL.
2903 * This overload allows for IntPtr.Zero (null) to be passed for both
2904 * dstrect and center.
2905 */
2906 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2907 public static extern int SDL_RenderCopyEx(
2908 IntPtr renderer,
2909 IntPtr texture,
2910 ref SDL_Rect srcrect,
2911 IntPtr dstrect,
2912 double angle,
2913 IntPtr center,
2914 SDL_RendererFlip flip
2915 );
2916
2917 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
2918 * Internally, this function contains logic to use default values when
2919 * source, destination, and/or center are passed as NULL.
2920 * This overload allows for IntPtr.Zero (null) to be passed for all
2921 * three parameters.
2922 */
2923 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2924 public static extern int SDL_RenderCopyEx(
2925 IntPtr renderer,
2926 IntPtr texture,
2927 IntPtr srcrect,
2928 IntPtr dstrect,
2929 double angle,
2930 IntPtr center,
2931 SDL_RendererFlip flip
2932 );
2933
2934 /* renderer refers to an SDL_Renderer* */
2935 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2936 public static extern int SDL_RenderDrawLine(
2937 IntPtr renderer,
2938 int x1,
2939 int y1,
2940 int x2,
2941 int y2
2942 );
2943
2944 /* renderer refers to an SDL_Renderer* */
2945 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2946 public static extern int SDL_RenderDrawLines(
2947 IntPtr renderer,
2948 [In] SDL_Point[] points,
2949 int count
2950 );
2951
2952 /* renderer refers to an SDL_Renderer* */
2953 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2954 public static extern int SDL_RenderDrawPoint(
2955 IntPtr renderer,
2956 int x,
2957 int y
2958 );
2959
2960 /* renderer refers to an SDL_Renderer* */
2961 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2962 public static extern int SDL_RenderDrawPoints(
2963 IntPtr renderer,
2964 [In] SDL_Point[] points,
2965 int count
2966 );
2967
2968 /* renderer refers to an SDL_Renderer* */
2969 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2970 public static extern int SDL_RenderDrawRect(
2971 IntPtr renderer,
2972 ref SDL_Rect rect
2973 );
2974
2975 /* renderer refers to an SDL_Renderer*, rect to an SDL_Rect*.
2976 * This overload allows for IntPtr.Zero (null) to be passed for rect.
2977 */
2978 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2979 public static extern int SDL_RenderDrawRect(
2980 IntPtr renderer,
2981 IntPtr rect
2982 );
2983
2984 /* renderer refers to an SDL_Renderer* */
2985 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2986 public static extern int SDL_RenderDrawRects(
2987 IntPtr renderer,
2988 [In] SDL_Rect[] rects,
2989 int count
2990 );
2991
2992 /* renderer refers to an SDL_Renderer* */
2993 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
2994 public static extern int SDL_RenderFillRect(
2995 IntPtr renderer,
2996 ref SDL_Rect rect
2997 );
2998
2999 /* renderer refers to an SDL_Renderer*, rect to an SDL_Rect*.
3000 * This overload allows for IntPtr.Zero (null) to be passed for rect.
3001 */
3002 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3003 public static extern int SDL_RenderFillRect(
3004 IntPtr renderer,
3005 IntPtr rect
3006 );
3007
3008 /* renderer refers to an SDL_Renderer* */
3009 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3010 public static extern int SDL_RenderFillRects(
3011 IntPtr renderer,
3012 [In] SDL_Rect[] rects,
3013 int count
3014 );
3015
3016 #region Floating Point Render Functions
3017
3018 /* This region only available in SDL 2.0.10 or higher. */
3019
3020 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */
3021 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3022 public static extern int SDL_RenderCopyF(
3023 IntPtr renderer,
3024 IntPtr texture,
3025 ref SDL_Rect srcrect,
3026 ref SDL_FRect dstrect
3027 );
3028
3029 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
3030 * Internally, this function contains logic to use default values when
3031 * source and destination rectangles are passed as NULL.
3032 * This overload allows for IntPtr.Zero (null) to be passed for srcrect.
3033 */
3034 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3035 public static extern int SDL_RenderCopyF(
3036 IntPtr renderer,
3037 IntPtr texture,
3038 IntPtr srcrect,
3039 ref SDL_FRect dstrect
3040 );
3041
3042 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
3043 * Internally, this function contains logic to use default values when
3044 * source and destination rectangles are passed as NULL.
3045 * This overload allows for IntPtr.Zero (null) to be passed for dstrect.
3046 */
3047 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3048 public static extern int SDL_RenderCopyF(
3049 IntPtr renderer,
3050 IntPtr texture,
3051 ref SDL_Rect srcrect,
3052 IntPtr dstrect
3053 );
3054
3055 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
3056 * Internally, this function contains logic to use default values when
3057 * source and destination rectangles are passed as NULL.
3058 * This overload allows for IntPtr.Zero (null) to be passed for both SDL_Rects.
3059 */
3060 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3061 public static extern int SDL_RenderCopyF(
3062 IntPtr renderer,
3063 IntPtr texture,
3064 IntPtr srcrect,
3065 IntPtr dstrect
3066 );
3067
3068 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */
3069 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3070 public static extern int SDL_RenderCopyEx(
3071 IntPtr renderer,
3072 IntPtr texture,
3073 ref SDL_Rect srcrect,
3074 ref SDL_FRect dstrect,
3075 double angle,
3076 ref SDL_FPoint center,
3077 SDL_RendererFlip flip
3078 );
3079
3080 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
3081 * Internally, this function contains logic to use default values when
3082 * source, destination, and/or center are passed as NULL.
3083 * This overload allows for IntPtr.Zero (null) to be passed for srcrect.
3084 */
3085 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3086 public static extern int SDL_RenderCopyEx(
3087 IntPtr renderer,
3088 IntPtr texture,
3089 IntPtr srcrect,
3090 ref SDL_FRect dstrect,
3091 double angle,
3092 ref SDL_FPoint center,
3093 SDL_RendererFlip flip
3094 );
3095
3096 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
3097 * Internally, this function contains logic to use default values when
3098 * source, destination, and/or center are passed as NULL.
3099 * This overload allows for IntPtr.Zero (null) to be passed for dstrect.
3100 */
3101 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3102 public static extern int SDL_RenderCopyExF(
3103 IntPtr renderer,
3104 IntPtr texture,
3105 ref SDL_Rect srcrect,
3106 IntPtr dstrect,
3107 double angle,
3108 ref SDL_FPoint center,
3109 SDL_RendererFlip flip
3110 );
3111
3112 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
3113 * Internally, this function contains logic to use default values when
3114 * source, destination, and/or center are passed as NULL.
3115 * This overload allows for IntPtr.Zero (null) to be passed for center.
3116 */
3117 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3118 public static extern int SDL_RenderCopyExF(
3119 IntPtr renderer,
3120 IntPtr texture,
3121 ref SDL_Rect srcrect,
3122 ref SDL_FRect dstrect,
3123 double angle,
3124 IntPtr center,
3125 SDL_RendererFlip flip
3126 );
3127
3128 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
3129 * Internally, this function contains logic to use default values when
3130 * source, destination, and/or center are passed as NULL.
3131 * This overload allows for IntPtr.Zero (null) to be passed for both
3132 * srcrect and dstrect.
3133 */
3134 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3135 public static extern int SDL_RenderCopyExF(
3136 IntPtr renderer,
3137 IntPtr texture,
3138 IntPtr srcrect,
3139 IntPtr dstrect,
3140 double angle,
3141 ref SDL_FPoint center,
3142 SDL_RendererFlip flip
3143 );
3144
3145 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
3146 * Internally, this function contains logic to use default values when
3147 * source, destination, and/or center are passed as NULL.
3148 * This overload allows for IntPtr.Zero (null) to be passed for both
3149 * srcrect and center.
3150 */
3151 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3152 public static extern int SDL_RenderCopyExF(
3153 IntPtr renderer,
3154 IntPtr texture,
3155 IntPtr srcrect,
3156 ref SDL_FRect dstrect,
3157 double angle,
3158 IntPtr center,
3159 SDL_RendererFlip flip
3160 );
3161
3162 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
3163 * Internally, this function contains logic to use default values when
3164 * source, destination, and/or center are passed as NULL.
3165 * This overload allows for IntPtr.Zero (null) to be passed for both
3166 * dstrect and center.
3167 */
3168 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3169 public static extern int SDL_RenderCopyExF(
3170 IntPtr renderer,
3171 IntPtr texture,
3172 ref SDL_Rect srcrect,
3173 IntPtr dstrect,
3174 double angle,
3175 IntPtr center,
3176 SDL_RendererFlip flip
3177 );
3178
3179 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture*.
3180 * Internally, this function contains logic to use default values when
3181 * source, destination, and/or center are passed as NULL.
3182 * This overload allows for IntPtr.Zero (null) to be passed for all
3183 * three parameters.
3184 */
3185 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3186 public static extern int SDL_RenderCopyExF(
3187 IntPtr renderer,
3188 IntPtr texture,
3189 IntPtr srcrect,
3190 IntPtr dstrect,
3191 double angle,
3192 IntPtr center,
3193 SDL_RendererFlip flip
3194 );
3195
3196 /* renderer refers to an SDL_Renderer*
3197 * texture refers to an SDL_Texture*
3198 * Only available in 2.0.18 or higher.
3199 */
3200 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3201 public static extern int SDL_RenderGeometry(
3202 IntPtr renderer,
3203 IntPtr texture,
3204 [In] SDL_Vertex[] vertices,
3205 int num_vertices,
3206 [In] int[] indices,
3207 int num_indices
3208 );
3209
3210 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3211 public static extern int SDL_RenderGeometry(
3212 IntPtr renderer,
3213 IntPtr texture,
3214 [In] SDL_Vertex[] vertices,
3215 int num_vertices,
3216 [In] IntPtr indices,
3217 int num_indices
3218 );
3219
3220 /* renderer refers to an SDL_Renderer*
3221 * texture refers to an SDL_Texture*
3222 * indices refers to a void*
3223 * Only available in 2.0.18 or higher.
3224 */
3225 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3226 public static extern int SDL_RenderGeometryRaw(
3227 IntPtr renderer,
3228 IntPtr texture,
3229 [In] float[] xy,
3230 int xy_stride,
3231 [In] int[] color,
3232 int color_stride,
3233 [In] float[] uv,
3234 int uv_stride,
3235 int num_vertices,
3236 IntPtr indices,
3237 int num_indices,
3238 int size_indices
3239 );
3240
3241 /* renderer refers to an SDL_Renderer* */
3242 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3243 public static extern int SDL_RenderDrawPointF(
3244 IntPtr renderer,
3245 float x,
3246 float y
3247 );
3248
3249 /* renderer refers to an SDL_Renderer* */
3250 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3251 public static extern int SDL_RenderDrawPointsF(
3252 IntPtr renderer,
3253 [In] SDL_FPoint[] points,
3254 int count
3255 );
3256
3257 /* renderer refers to an SDL_Renderer* */
3258 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3259 public static extern int SDL_RenderDrawLineF(
3260 IntPtr renderer,
3261 float x1,
3262 float y1,
3263 float x2,
3264 float y2
3265 );
3266
3267 /* renderer refers to an SDL_Renderer* */
3268 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3269 public static extern int SDL_RenderDrawLinesF(
3270 IntPtr renderer,
3271 [In] SDL_FPoint[] points,
3272 int count
3273 );
3274
3275 /* renderer refers to an SDL_Renderer* */
3276 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3277 public static extern int SDL_RenderDrawRectF(
3278 IntPtr renderer,
3279 ref SDL_FRect rect
3280 );
3281
3282 /* renderer refers to an SDL_Renderer*, rect to an SDL_Rect*.
3283 * This overload allows for IntPtr.Zero (null) to be passed for rect.
3284 */
3285 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3286 public static extern int SDL_RenderDrawRectF(
3287 IntPtr renderer,
3288 IntPtr rect
3289 );
3290
3291 /* renderer refers to an SDL_Renderer* */
3292 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3293 public static extern int SDL_RenderDrawRectsF(
3294 IntPtr renderer,
3295 [In] SDL_FRect[] rects,
3296 int count
3297 );
3298
3299 /* renderer refers to an SDL_Renderer* */
3300 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3301 public static extern int SDL_RenderFillRectF(
3302 IntPtr renderer,
3303 ref SDL_FRect rect
3304 );
3305
3306 /* renderer refers to an SDL_Renderer*, rect to an SDL_Rect*.
3307 * This overload allows for IntPtr.Zero (null) to be passed for rect.
3308 */
3309 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3310 public static extern int SDL_RenderFillRectF(
3311 IntPtr renderer,
3312 IntPtr rect
3313 );
3314
3315 /* renderer refers to an SDL_Renderer* */
3316 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3317 public static extern int SDL_RenderFillRectsF(
3318 IntPtr renderer,
3319 [In] SDL_FRect[] rects,
3320 int count
3321 );
3322
3323 #endregion
3324
3325 /* renderer refers to an SDL_Renderer* */
3326 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3327 public static extern void SDL_RenderGetClipRect(
3328 IntPtr renderer,
3329 out SDL_Rect rect
3330 );
3331
3332 /* renderer refers to an SDL_Renderer* */
3333 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3334 public static extern void SDL_RenderGetLogicalSize(
3335 IntPtr renderer,
3336 out int w,
3337 out int h
3338 );
3339
3340 /* renderer refers to an SDL_Renderer* */
3341 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3342 public static extern void SDL_RenderGetScale(
3343 IntPtr renderer,
3344 out float scaleX,
3345 out float scaleY
3346 );
3347
3348 /* renderer refers to an SDL_Renderer*
3349 * Only available in 2.0.18 or higher.
3350 */
3351 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3352 public static extern void SDL_RenderWindowToLogical(
3353 IntPtr renderer,
3354 int windowX,
3355 int windowY,
3356 out float logicalX,
3357 out float logicalY
3358 );
3359
3360 /* renderer refers to an SDL_Renderer*
3361 * Only available in 2.0.18 or higher.
3362 */
3363 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3364 public static extern void SDL_RenderLogicalToWindow(
3365 IntPtr renderer,
3366 float logicalX,
3367 float logicalY,
3368 out int windowX,
3369 out int windowY
3370 );
3371
3372 /* renderer refers to an SDL_Renderer* */
3373 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3374 public static extern int SDL_RenderGetViewport(
3375 IntPtr renderer,
3376 out SDL_Rect rect
3377 );
3378
3379 /* renderer refers to an SDL_Renderer* */
3380 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3381 public static extern void SDL_RenderPresent(IntPtr renderer);
3382
3383 /* renderer refers to an SDL_Renderer* */
3384 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3385 public static extern int SDL_RenderReadPixels(
3386 IntPtr renderer,
3387 ref SDL_Rect rect,
3388 uint format,
3389 IntPtr pixels,
3390 int pitch
3391 );
3392
3393 /* renderer refers to an SDL_Renderer* */
3394 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3395 public static extern int SDL_RenderSetClipRect(
3396 IntPtr renderer,
3397 ref SDL_Rect rect
3398 );
3399
3400 /* renderer refers to an SDL_Renderer*
3401 * This overload allows for IntPtr.Zero (null) to be passed for rect.
3402 */
3403 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3404 public static extern int SDL_RenderSetClipRect(
3405 IntPtr renderer,
3406 IntPtr rect
3407 );
3408
3409 /* renderer refers to an SDL_Renderer* */
3410 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3411 public static extern int SDL_RenderSetLogicalSize(
3412 IntPtr renderer,
3413 int w,
3414 int h
3415 );
3416
3417 /* renderer refers to an SDL_Renderer* */
3418 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3419 public static extern int SDL_RenderSetScale(
3420 IntPtr renderer,
3421 float scaleX,
3422 float scaleY
3423 );
3424
3425 /* renderer refers to an SDL_Renderer*
3426 * Only available in 2.0.5 or higher.
3427 */
3428 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3429 public static extern int SDL_RenderSetIntegerScale(
3430 IntPtr renderer,
3431 SDL_bool enable
3432 );
3433
3434 /* renderer refers to an SDL_Renderer* */
3435 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3436 public static extern int SDL_RenderSetViewport(
3437 IntPtr renderer,
3438 ref SDL_Rect rect
3439 );
3440
3441 /* renderer refers to an SDL_Renderer* */
3442 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3443 public static extern int SDL_SetRenderDrawBlendMode(
3444 IntPtr renderer,
3445 SDL_BlendMode blendMode
3446 );
3447
3448 /* renderer refers to an SDL_Renderer* */
3449 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3450 public static extern int SDL_SetRenderDrawColor(
3451 IntPtr renderer,
3452 byte r,
3453 byte g,
3454 byte b,
3455 byte a
3456 );
3457
3458 /* renderer refers to an SDL_Renderer*, texture to an SDL_Texture* */
3459 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3460 public static extern int SDL_SetRenderTarget(
3461 IntPtr renderer,
3462 IntPtr texture
3463 );
3464
3465 /* texture refers to an SDL_Texture* */
3466 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3467 public static extern int SDL_SetTextureAlphaMod(
3468 IntPtr texture,
3469 byte alpha
3470 );
3471
3472 /* texture refers to an SDL_Texture* */
3473 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3474 public static extern int SDL_SetTextureBlendMode(
3475 IntPtr texture,
3476 SDL_BlendMode blendMode
3477 );
3478
3479 /* texture refers to an SDL_Texture* */
3480 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3481 public static extern int SDL_SetTextureColorMod(
3482 IntPtr texture,
3483 byte r,
3484 byte g,
3485 byte b
3486 );
3487
3488 /* texture refers to an SDL_Texture* */
3489 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3490 public static extern void SDL_UnlockTexture(IntPtr texture);
3491
3492 /* texture refers to an SDL_Texture* */
3493 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3494 public static extern int SDL_UpdateTexture(
3495 IntPtr texture,
3496 ref SDL_Rect rect,
3497 IntPtr pixels,
3498 int pitch
3499 );
3500
3501 /* texture refers to an SDL_Texture* */
3502 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3503 public static extern int SDL_UpdateTexture(
3504 IntPtr texture,
3505 IntPtr rect,
3506 IntPtr pixels,
3507 int pitch
3508 );
3509
3510 /* texture refers to an SDL_Texture*
3511 * Only available in 2.0.1 or higher.
3512 */
3513 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3514 public static extern int SDL_UpdateYUVTexture(
3515 IntPtr texture,
3516 ref SDL_Rect rect,
3517 IntPtr yPlane,
3518 int yPitch,
3519 IntPtr uPlane,
3520 int uPitch,
3521 IntPtr vPlane,
3522 int vPitch
3523 );
3524
3525 /* texture refers to an SDL_Texture*.
3526 * yPlane and uvPlane refer to const Uint*.
3527 * Only available in 2.0.16 or higher.
3528 */
3529 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3530 public static extern int SDL_UpdateNVTexture(
3531 IntPtr texture,
3532 ref SDL_Rect rect,
3533 IntPtr yPlane,
3534 int yPitch,
3535 IntPtr uvPlane,
3536 int uvPitch
3537 );
3538
3539 /* renderer refers to an SDL_Renderer* */
3540 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3541 public static extern SDL_bool SDL_RenderTargetSupported(
3542 IntPtr renderer
3543 );
3544
3545 /* IntPtr refers to an SDL_Texture*, renderer to an SDL_Renderer* */
3546 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3547 public static extern IntPtr SDL_GetRenderTarget(IntPtr renderer);
3548
3549 /* renderer refers to an SDL_Renderer*
3550 * Only available in 2.0.8 or higher.
3551 */
3552 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3553 public static extern IntPtr SDL_RenderGetMetalLayer(
3554 IntPtr renderer
3555 );
3556
3557 /* renderer refers to an SDL_Renderer*
3558 * Only available in 2.0.8 or higher.
3559 */
3560 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3561 public static extern IntPtr SDL_RenderGetMetalCommandEncoder(
3562 IntPtr renderer
3563 );
3564
3565 /* renderer refers to an SDL_Renderer*
3566 * Only available in 2.0.18 or higher.
3567 */
3568 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3569 public static extern int SDL_RenderSetVSync(IntPtr renderer, int vsync);
3570
3571 /* renderer refers to an SDL_Renderer*
3572 * Only available in 2.0.4 or higher.
3573 */
3574 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3575 public static extern SDL_bool SDL_RenderIsClipEnabled(IntPtr renderer);
3576
3577 /* renderer refers to an SDL_Renderer*
3578 * Only available in 2.0.10 or higher.
3579 */
3580 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
3581 public static extern int SDL_RenderFlush(IntPtr renderer);
3582
3583 #endregion
3584
3585 #region SDL_pixels.h
3586
3587 public static uint SDL_DEFINE_PIXELFOURCC(byte A, byte B, byte C, byte D)
3588 {
3589 return SDL_FOURCC(A, B, C, D);
3590 }
3591
3592 public static uint SDL_DEFINE_PIXELFORMAT(
3593 SDL_PixelType type,
3594 uint order,
3595 SDL_PackedLayout layout,
3596 byte bits,
3597 byte bytes
3598 ) {
3599 return (uint) (
3600 (1 << 28) |
3601 (((byte) type) << 24) |
3602 (((byte) order) << 20) |
3603 (((byte) layout) << 16) |
3604 (bits << 8) |
3605 (bytes)
3606 );
3607 }
3608
3609 public static byte SDL_PIXELFLAG(uint X)
3610 {
3611 return (byte) ((X >> 28) & 0x0F);
3612 }
3613
3614 public static byte SDL_PIXELTYPE(uint X)
3615 {
3616 return (byte) ((X >> 24) & 0x0F);
3617 }
3618
3619 public static byte SDL_PIXELORDER(uint X)
3620 {
3621 return (byte) ((X >> 20) & 0x0F);
3622 }
3623
3624 public static byte SDL_PIXELLAYOUT(uint X)
3625 {
3626 return (byte) ((X >> 16) & 0x0F);
3627 }
3628
3629 public static byte SDL_BITSPERPIXEL(uint X)
3630 {
3631 return (byte) ((X >> 8) & 0xFF);
3632 }
3633
3634 public static byte SDL_BYTESPERPIXEL(uint X)
3635 {
3636 if (SDL_ISPIXELFORMAT_FOURCC(X))
3637 {
3638 if ( (X == SDL_PIXELFORMAT_YUY2) ||
3639 (X == SDL_PIXELFORMAT_UYVY) ||
3640 (X == SDL_PIXELFORMAT_YVYU) )
3641 {
3642 return 2;
3643 }
3644 return 1;
3645 }
3646 return (byte) (X & 0xFF);
3647 }
3648
3649 public static bool SDL_ISPIXELFORMAT_INDEXED(uint format)
3650 {
3651 if (SDL_ISPIXELFORMAT_FOURCC(format))
3652 {
3653 return false;
3654 }
3655 SDL_PixelType pType =
3656 (SDL_PixelType) SDL_PIXELTYPE(format);
3657 return (
3658 pType == SDL_PixelType.SDL_PIXELTYPE_INDEX1 ||
3659 pType == SDL_PixelType.SDL_PIXELTYPE_INDEX4 ||
3660 pType == SDL_PixelType.SDL_PIXELTYPE_INDEX8
3661 );
3662 }
3663
3664 public static bool SDL_ISPIXELFORMAT_PACKED(uint format)
3665 {
3666 if (SDL_ISPIXELFORMAT_FOURCC(format))
3667 {
3668 return false;
3669 }
3670 SDL_PixelType pType =
3671 (SDL_PixelType) SDL_PIXELTYPE(format);
3672 return (
3673 pType == SDL_PixelType.SDL_PIXELTYPE_PACKED8 ||
3674 pType == SDL_PixelType.SDL_PIXELTYPE_PACKED16 ||
3675 pType == SDL_PixelType.SDL_PIXELTYPE_PACKED32
3676 );
3677 }
3678
3679 public static bool SDL_ISPIXELFORMAT_ARRAY(uint format)
3680 {
3681 if (SDL_ISPIXELFORMAT_FOURCC(format))
3682 {
3683 return false;
3684 }
3685 SDL_PixelType pType =
3686 (SDL_PixelType) SDL_PIXELTYPE(format);
3687 return (
3688 pType == SDL_PixelType.SDL_PIXELTYPE_ARRAYU8 ||
3689 pType == SDL_PixelType.SDL_PIXELTYPE_ARRAYU16 ||
3690 pType == SDL_PixelType.SDL_PIXELTYPE_ARRAYU32 ||
3691 pType == SDL_PixelType.SDL_PIXELTYPE_ARRAYF16 ||
3692 pType == SDL_PixelType.SDL_PIXELTYPE_ARRAYF32
3693 );
3694 }
3695
3696 public static bool SDL_ISPIXELFORMAT_ALPHA(uint format)
3697 {
3698 if (SDL_ISPIXELFORMAT_PACKED(format))
3699 {
3700 SDL_PackedOrder pOrder =
3701 (SDL_PackedOrder) SDL_PIXELORDER(format);
3702 return (
3703 pOrder == SDL_PackedOrder.SDL_PACKEDORDER_ARGB ||
3704 pOrder == SDL_PackedOrder.SDL_PACKEDORDER_RGBA ||
3705 pOrder == SDL_PackedOrder.SDL_PACKEDORDER_ABGR ||
3706 pOrder == SDL_PackedOrder.SDL_PACKEDORDER_BGRA
3707 );
3708 }
3709 else if (SDL_ISPIXELFORMAT_ARRAY(format))
3710 {
3711 SDL_ArrayOrder aOrder =
3712 (SDL_ArrayOrder) SDL_PIXELORDER(format);
3713 return (
3714 aOrder == SDL_ArrayOrder.SDL_ARRAYORDER_ARGB ||
3715 aOrder == SDL_ArrayOrder.SDL_ARRAYORDER_RGBA ||
3716 aOrder == SDL_ArrayOrder.SDL_ARRAYORDER_ABGR ||
3717 aOrder == SDL_ArrayOrder.SDL_ARRAYORDER_BGRA
3718 );
3719 }
3720 return false;
3721 }
3722
3723 public static bool SDL_ISPIXELFORMAT_FOURCC(uint format)
3724 {
3725 return (format == 0) && (SDL_PIXELFLAG(format) != 1);
3726 }
3727
3728 public enum SDL_PixelType
3729 {
3730 SDL_PIXELTYPE_UNKNOWN,
3731 SDL_PIXELTYPE_INDEX1,
3732 SDL_PIXELTYPE_INDEX4,
3733 SDL_PIXELTYPE_INDEX8,
3734 SDL_PIXELTYPE_PACKED8,
3735 SDL_PIXELTYPE_PACKED16,
3736 SDL_PIXELTYPE_PACKED32,
3737 SDL_PIXELTYPE_ARRAYU8,
3738 SDL_PIXELTYPE_ARRAYU16,
3739 SDL_PIXELTYPE_ARRAYU32,
3740 SDL_PIXELTYPE_ARRAYF16,
3741 SDL_PIXELTYPE_ARRAYF32
3742 }
3743
3744 public enum SDL_BitmapOrder
3745 {
3746 SDL_BITMAPORDER_NONE,
3747 SDL_BITMAPORDER_4321,
3748 SDL_BITMAPORDER_1234
3749 }
3750
3751 public enum SDL_PackedOrder
3752 {
3753 SDL_PACKEDORDER_NONE,
3754 SDL_PACKEDORDER_XRGB,
3755 SDL_PACKEDORDER_RGBX,
3756 SDL_PACKEDORDER_ARGB,
3757 SDL_PACKEDORDER_RGBA,
3758 SDL_PACKEDORDER_XBGR,
3759 SDL_PACKEDORDER_BGRX,
3760 SDL_PACKEDORDER_ABGR,
3761 SDL_PACKEDORDER_BGRA
3762 }
3763
3764 public enum SDL_ArrayOrder
3765 {
3766 SDL_ARRAYORDER_NONE,
3767 SDL_ARRAYORDER_RGB,
3768 SDL_ARRAYORDER_RGBA,
3769 SDL_ARRAYORDER_ARGB,
3770 SDL_ARRAYORDER_BGR,
3771 SDL_ARRAYORDER_BGRA,
3772 SDL_ARRAYORDER_ABGR
3773 }
3774
3775 public enum SDL_PackedLayout
3776 {
3777 SDL_PACKEDLAYOUT_NONE,
3778 SDL_PACKEDLAYOUT_332,
3779 SDL_PACKEDLAYOUT_4444,
3780 SDL_PACKEDLAYOUT_1555,
3781 SDL_PACKEDLAYOUT_5551,
3782 SDL_PACKEDLAYOUT_565,
3783 SDL_PACKEDLAYOUT_8888,
3784 SDL_PACKEDLAYOUT_2101010,
3785 SDL_PACKEDLAYOUT_1010102
3786 }
3787
3788 public static readonly uint SDL_PIXELFORMAT_UNKNOWN = 0;
3789 public static readonly uint SDL_PIXELFORMAT_INDEX1LSB =
3790 SDL_DEFINE_PIXELFORMAT(
3791 SDL_PixelType.SDL_PIXELTYPE_INDEX1,
3792 (uint) SDL_BitmapOrder.SDL_BITMAPORDER_4321,
3793 0,
3794 1, 0
3795 );
3796 public static readonly uint SDL_PIXELFORMAT_INDEX1MSB =
3797 SDL_DEFINE_PIXELFORMAT(
3798 SDL_PixelType.SDL_PIXELTYPE_INDEX1,
3799 (uint) SDL_BitmapOrder.SDL_BITMAPORDER_1234,
3800 0,
3801 1, 0
3802 );
3803 public static readonly uint SDL_PIXELFORMAT_INDEX4LSB =
3804 SDL_DEFINE_PIXELFORMAT(
3805 SDL_PixelType.SDL_PIXELTYPE_INDEX4,
3806 (uint) SDL_BitmapOrder.SDL_BITMAPORDER_4321,
3807 0,
3808 4, 0
3809 );
3810 public static readonly uint SDL_PIXELFORMAT_INDEX4MSB =
3811 SDL_DEFINE_PIXELFORMAT(
3812 SDL_PixelType.SDL_PIXELTYPE_INDEX4,
3813 (uint) SDL_BitmapOrder.SDL_BITMAPORDER_1234,
3814 0,
3815 4, 0
3816 );
3817 public static readonly uint SDL_PIXELFORMAT_INDEX8 =
3818 SDL_DEFINE_PIXELFORMAT(
3819 SDL_PixelType.SDL_PIXELTYPE_INDEX8,
3820 0,
3821 0,
3822 8, 1
3823 );
3824 public static readonly uint SDL_PIXELFORMAT_RGB332 =
3825 SDL_DEFINE_PIXELFORMAT(
3826 SDL_PixelType.SDL_PIXELTYPE_PACKED8,
3827 (uint) SDL_PackedOrder.SDL_PACKEDORDER_XRGB,
3828 SDL_PackedLayout.SDL_PACKEDLAYOUT_332,
3829 8, 1
3830 );
3831 public static readonly uint SDL_PIXELFORMAT_XRGB444 =
3832 SDL_DEFINE_PIXELFORMAT(
3833 SDL_PixelType.SDL_PIXELTYPE_PACKED16,
3834 (uint) SDL_PackedOrder.SDL_PACKEDORDER_XRGB,
3835 SDL_PackedLayout.SDL_PACKEDLAYOUT_4444,
3836 12, 2
3837 );
3838 public static readonly uint SDL_PIXELFORMAT_RGB444 =
3839 SDL_PIXELFORMAT_XRGB444;
3840 public static readonly uint SDL_PIXELFORMAT_XBGR444 =
3841 SDL_DEFINE_PIXELFORMAT(
3842 SDL_PixelType.SDL_PIXELTYPE_PACKED16,
3843 (uint) SDL_PackedOrder.SDL_PACKEDORDER_XBGR,
3844 SDL_PackedLayout.SDL_PACKEDLAYOUT_4444,
3845 12, 2
3846 );
3847 public static readonly uint SDL_PIXELFORMAT_BGR444 =
3848 SDL_PIXELFORMAT_XBGR444;
3849 public static readonly uint SDL_PIXELFORMAT_XRGB1555 =
3850 SDL_DEFINE_PIXELFORMAT(
3851 SDL_PixelType.SDL_PIXELTYPE_PACKED16,
3852 (uint) SDL_PackedOrder.SDL_PACKEDORDER_XRGB,
3853 SDL_PackedLayout.SDL_PACKEDLAYOUT_1555,
3854 15, 2
3855 );
3856 public static readonly uint SDL_PIXELFORMAT_RGB555 =
3857 SDL_PIXELFORMAT_XRGB1555;
3858 public static readonly uint SDL_PIXELFORMAT_XBGR1555 =
3859 SDL_DEFINE_PIXELFORMAT(
3860 SDL_PixelType.SDL_PIXELTYPE_INDEX1,
3861 (uint) SDL_BitmapOrder.SDL_BITMAPORDER_4321,
3862 SDL_PackedLayout.SDL_PACKEDLAYOUT_1555,
3863 15, 2
3864 );
3865 public static readonly uint SDL_PIXELFORMAT_BGR555 =
3866 SDL_PIXELFORMAT_XBGR1555;
3867 public static readonly uint SDL_PIXELFORMAT_ARGB4444 =
3868 SDL_DEFINE_PIXELFORMAT(
3869 SDL_PixelType.SDL_PIXELTYPE_PACKED16,
3870 (uint) SDL_PackedOrder.SDL_PACKEDORDER_ARGB,
3871 SDL_PackedLayout.SDL_PACKEDLAYOUT_4444,
3872 16, 2
3873 );
3874 public static readonly uint SDL_PIXELFORMAT_RGBA4444 =
3875 SDL_DEFINE_PIXELFORMAT(
3876 SDL_PixelType.SDL_PIXELTYPE_PACKED16,
3877 (uint) SDL_PackedOrder.SDL_PACKEDORDER_RGBA,
3878 SDL_PackedLayout.SDL_PACKEDLAYOUT_4444,
3879 16, 2
3880 );
3881 public static readonly uint SDL_PIXELFORMAT_ABGR4444 =
3882 SDL_DEFINE_PIXELFORMAT(
3883 SDL_PixelType.SDL_PIXELTYPE_PACKED16,
3884 (uint) SDL_PackedOrder.SDL_PACKEDORDER_ABGR,
3885 SDL_PackedLayout.SDL_PACKEDLAYOUT_4444,
3886 16, 2
3887 );
3888 public static readonly uint SDL_PIXELFORMAT_BGRA4444 =
3889 SDL_DEFINE_PIXELFORMAT(
3890 SDL_PixelType.SDL_PIXELTYPE_PACKED16,
3891 (uint) SDL_PackedOrder.SDL_PACKEDORDER_BGRA,
3892 SDL_PackedLayout.SDL_PACKEDLAYOUT_4444,
3893 16, 2
3894 );
3895 public static readonly uint SDL_PIXELFORMAT_ARGB1555 =
3896 SDL_DEFINE_PIXELFORMAT(
3897 SDL_PixelType.SDL_PIXELTYPE_PACKED16,
3898 (uint) SDL_PackedOrder.SDL_PACKEDORDER_ARGB,
3899 SDL_PackedLayout.SDL_PACKEDLAYOUT_1555,
3900 16, 2
3901 );
3902 public static readonly uint SDL_PIXELFORMAT_RGBA5551 =
3903 SDL_DEFINE_PIXELFORMAT(
3904 SDL_PixelType.SDL_PIXELTYPE_PACKED16,
3905 (uint) SDL_PackedOrder.SDL_PACKEDORDER_RGBA,
3906 SDL_PackedLayout.SDL_PACKEDLAYOUT_5551,
3907 16, 2
3908 );
3909 public static readonly uint SDL_PIXELFORMAT_ABGR1555 =
3910 SDL_DEFINE_PIXELFORMAT(
3911 SDL_PixelType.SDL_PIXELTYPE_PACKED16,
3912 (uint) SDL_PackedOrder.SDL_PACKEDORDER_ABGR,
3913 SDL_PackedLayout.SDL_PACKEDLAYOUT_1555,
3914 16, 2
3915 );
3916 public static readonly uint SDL_PIXELFORMAT_BGRA5551 =
3917 SDL_DEFINE_PIXELFORMAT(
3918 SDL_PixelType.SDL_PIXELTYPE_PACKED16,
3919 (uint) SDL_PackedOrder.SDL_PACKEDORDER_BGRA,
3920 SDL_PackedLayout.SDL_PACKEDLAYOUT_5551,
3921 16, 2
3922 );
3923 public static readonly uint SDL_PIXELFORMAT_RGB565 =
3924 SDL_DEFINE_PIXELFORMAT(
3925 SDL_PixelType.SDL_PIXELTYPE_PACKED16,
3926 (uint) SDL_PackedOrder.SDL_PACKEDORDER_XRGB,
3927 SDL_PackedLayout.SDL_PACKEDLAYOUT_565,
3928 16, 2
3929 );
3930 public static readonly uint SDL_PIXELFORMAT_BGR565 =
3931 SDL_DEFINE_PIXELFORMAT(
3932 SDL_PixelType.SDL_PIXELTYPE_PACKED16,
3933 (uint) SDL_PackedOrder.SDL_PACKEDORDER_XBGR,
3934 SDL_PackedLayout.SDL_PACKEDLAYOUT_565,
3935 16, 2
3936 );
3937 public static readonly uint SDL_PIXELFORMAT_RGB24 =
3938 SDL_DEFINE_PIXELFORMAT(
3939 SDL_PixelType.SDL_PIXELTYPE_ARRAYU8,
3940 (uint) SDL_ArrayOrder.SDL_ARRAYORDER_RGB,
3941 0,
3942 24, 3
3943 );
3944 public static readonly uint SDL_PIXELFORMAT_BGR24 =
3945 SDL_DEFINE_PIXELFORMAT(
3946 SDL_PixelType.SDL_PIXELTYPE_ARRAYU8,
3947 (uint) SDL_ArrayOrder.SDL_ARRAYORDER_BGR,
3948 0,
3949 24, 3
3950 );
3951 public static readonly uint SDL_PIXELFORMAT_XRGB888 =
3952 SDL_DEFINE_PIXELFORMAT(
3953 SDL_PixelType.SDL_PIXELTYPE_PACKED32,
3954 (uint) SDL_PackedOrder.SDL_PACKEDORDER_XRGB,
3955 SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,
3956 24, 4
3957 );
3958 public static readonly uint SDL_PIXELFORMAT_RGB888 =
3959 SDL_PIXELFORMAT_XRGB888;
3960 public static readonly uint SDL_PIXELFORMAT_RGBX8888 =
3961 SDL_DEFINE_PIXELFORMAT(
3962 SDL_PixelType.SDL_PIXELTYPE_PACKED32,
3963 (uint) SDL_PackedOrder.SDL_PACKEDORDER_RGBX,
3964 SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,
3965 24, 4
3966 );
3967 public static readonly uint SDL_PIXELFORMAT_XBGR888 =
3968 SDL_DEFINE_PIXELFORMAT(
3969 SDL_PixelType.SDL_PIXELTYPE_PACKED32,
3970 (uint) SDL_PackedOrder.SDL_PACKEDORDER_XBGR,
3971 SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,
3972 24, 4
3973 );
3974 public static readonly uint SDL_PIXELFORMAT_BGR888 =
3975 SDL_PIXELFORMAT_XBGR888;
3976 public static readonly uint SDL_PIXELFORMAT_BGRX8888 =
3977 SDL_DEFINE_PIXELFORMAT(
3978 SDL_PixelType.SDL_PIXELTYPE_PACKED32,
3979 (uint) SDL_PackedOrder.SDL_PACKEDORDER_BGRX,
3980 SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,
3981 24, 4
3982 );
3983 public static readonly uint SDL_PIXELFORMAT_ARGB8888 =
3984 SDL_DEFINE_PIXELFORMAT(
3985 SDL_PixelType.SDL_PIXELTYPE_PACKED32,
3986 (uint) SDL_PackedOrder.SDL_PACKEDORDER_ARGB,
3987 SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,
3988 32, 4
3989 );
3990 public static readonly uint SDL_PIXELFORMAT_RGBA8888 =
3991 SDL_DEFINE_PIXELFORMAT(
3992 SDL_PixelType.SDL_PIXELTYPE_PACKED32,
3993 (uint) SDL_PackedOrder.SDL_PACKEDORDER_RGBA,
3994 SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,
3995 32, 4
3996 );
3997 public static readonly uint SDL_PIXELFORMAT_ABGR8888 =
3998 SDL_DEFINE_PIXELFORMAT(
3999 SDL_PixelType.SDL_PIXELTYPE_PACKED32,
4000 (uint) SDL_PackedOrder.SDL_PACKEDORDER_ABGR,
4001 SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,
4002 32, 4
4003 );
4004 public static readonly uint SDL_PIXELFORMAT_BGRA8888 =
4005 SDL_DEFINE_PIXELFORMAT(
4006 SDL_PixelType.SDL_PIXELTYPE_PACKED32,
4007 (uint) SDL_PackedOrder.SDL_PACKEDORDER_BGRA,
4008 SDL_PackedLayout.SDL_PACKEDLAYOUT_8888,
4009 32, 4
4010 );
4011 public static readonly uint SDL_PIXELFORMAT_ARGB2101010 =
4012 SDL_DEFINE_PIXELFORMAT(
4013 SDL_PixelType.SDL_PIXELTYPE_PACKED32,
4014 (uint) SDL_PackedOrder.SDL_PACKEDORDER_ARGB,
4015 SDL_PackedLayout.SDL_PACKEDLAYOUT_2101010,
4016 32, 4
4017 );
4018 public static readonly uint SDL_PIXELFORMAT_YV12 =
4019 SDL_DEFINE_PIXELFOURCC(
4020 (byte) 'Y', (byte) 'V', (byte) '1', (byte) '2'
4021 );
4022 public static readonly uint SDL_PIXELFORMAT_IYUV =
4023 SDL_DEFINE_PIXELFOURCC(
4024 (byte) 'I', (byte) 'Y', (byte) 'U', (byte) 'V'
4025 );
4026 public static readonly uint SDL_PIXELFORMAT_YUY2 =
4027 SDL_DEFINE_PIXELFOURCC(
4028 (byte) 'Y', (byte) 'U', (byte) 'Y', (byte) '2'
4029 );
4030 public static readonly uint SDL_PIXELFORMAT_UYVY =
4031 SDL_DEFINE_PIXELFOURCC(
4032 (byte) 'U', (byte) 'Y', (byte) 'V', (byte) 'Y'
4033 );
4034 public static readonly uint SDL_PIXELFORMAT_YVYU =
4035 SDL_DEFINE_PIXELFOURCC(
4036 (byte) 'Y', (byte) 'V', (byte) 'Y', (byte) 'U'
4037 );
4038
4039 [StructLayout(LayoutKind.Sequential)]
4040 public struct SDL_Color
4041 {
4042 public byte r;
4043 public byte g;
4044 public byte b;
4045 public byte a;
4046 }
4047
4048 [StructLayout(LayoutKind.Sequential)]
4049 public struct SDL_Palette
4050 {
4051 public int ncolors;
4052 public IntPtr colors;
4053 public int version;
4054 public int refcount;
4055 }
4056
4057 [StructLayout(LayoutKind.Sequential)]
4058 public struct SDL_PixelFormat
4059 {
4060 public uint format;
4061 public IntPtr palette; // SDL_Palette*
4062 public byte BitsPerPixel;
4063 public byte BytesPerPixel;
4064 public uint Rmask;
4065 public uint Gmask;
4066 public uint Bmask;
4067 public uint Amask;
4068 public byte Rloss;
4069 public byte Gloss;
4070 public byte Bloss;
4071 public byte Aloss;
4072 public byte Rshift;
4073 public byte Gshift;
4074 public byte Bshift;
4075 public byte Ashift;
4076 public int refcount;
4077 public IntPtr next; // SDL_PixelFormat*
4078 }
4079
4080 /* IntPtr refers to an SDL_PixelFormat* */
4081 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4082 public static extern IntPtr SDL_AllocFormat(uint pixel_format);
4083
4084 /* IntPtr refers to an SDL_Palette* */
4085 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4086 public static extern IntPtr SDL_AllocPalette(int ncolors);
4087
4088 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4089 public static extern void SDL_CalculateGammaRamp(
4090 float gamma,
4091 [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeConst = 256)]
4092 ushort[] ramp
4093 );
4094
4095 /* format refers to an SDL_PixelFormat* */
4096 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4097 public static extern void SDL_FreeFormat(IntPtr format);
4098
4099 /* palette refers to an SDL_Palette* */
4100 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4101 public static extern void SDL_FreePalette(IntPtr palette);
4102
4103 [DllImport(nativeLibName, EntryPoint = "SDL_GetPixelFormatName", CallingConvention = CallingConvention.Cdecl)]
4104 private static extern IntPtr INTERNAL_SDL_GetPixelFormatName(
4105 uint format
4106 );
4107 public static string SDL_GetPixelFormatName(uint format)
4108 {
4109 return UTF8_ToManaged(
4110 INTERNAL_SDL_GetPixelFormatName(format)
4111 );
4112 }
4113
4114 /* format refers to an SDL_PixelFormat* */
4115 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4116 public static extern void SDL_GetRGB(
4117 uint pixel,
4118 IntPtr format,
4119 out byte r,
4120 out byte g,
4121 out byte b
4122 );
4123
4124 /* format refers to an SDL_PixelFormat* */
4125 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4126 public static extern void SDL_GetRGBA(
4127 uint pixel,
4128 IntPtr format,
4129 out byte r,
4130 out byte g,
4131 out byte b,
4132 out byte a
4133 );
4134
4135 /* format refers to an SDL_PixelFormat* */
4136 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4137 public static extern uint SDL_MapRGB(
4138 IntPtr format,
4139 byte r,
4140 byte g,
4141 byte b
4142 );
4143
4144 /* format refers to an SDL_PixelFormat* */
4145 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4146 public static extern uint SDL_MapRGBA(
4147 IntPtr format,
4148 byte r,
4149 byte g,
4150 byte b,
4151 byte a
4152 );
4153
4154 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4155 public static extern uint SDL_MasksToPixelFormatEnum(
4156 int bpp,
4157 uint Rmask,
4158 uint Gmask,
4159 uint Bmask,
4160 uint Amask
4161 );
4162
4163 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4164 public static extern SDL_bool SDL_PixelFormatEnumToMasks(
4165 uint format,
4166 out int bpp,
4167 out uint Rmask,
4168 out uint Gmask,
4169 out uint Bmask,
4170 out uint Amask
4171 );
4172
4173 /* palette refers to an SDL_Palette* */
4174 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4175 public static extern int SDL_SetPaletteColors(
4176 IntPtr palette,
4177 [In] SDL_Color[] colors,
4178 int firstcolor,
4179 int ncolors
4180 );
4181
4182 /* format and palette refer to an SDL_PixelFormat* and SDL_Palette* */
4183 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4184 public static extern int SDL_SetPixelFormatPalette(
4185 IntPtr format,
4186 IntPtr palette
4187 );
4188
4189 #endregion
4190
4191 #region SDL_rect.h
4192
4193 [StructLayout(LayoutKind.Sequential)]
4194 public struct SDL_Point
4195 {
4196 public int x;
4197 public int y;
4198 }
4199
4200 [StructLayout(LayoutKind.Sequential)]
4201 public struct SDL_Rect
4202 {
4203 public int x;
4204 public int y;
4205 public int w;
4206 public int h;
4207 }
4208
4209 /* Only available in 2.0.10 or higher. */
4210 [StructLayout(LayoutKind.Sequential)]
4211 public struct SDL_FPoint
4212 {
4213 public float x;
4214 public float y;
4215 }
4216
4217 /* Only available in 2.0.10 or higher. */
4218 [StructLayout(LayoutKind.Sequential)]
4219 public struct SDL_FRect
4220 {
4221 public float x;
4222 public float y;
4223 public float w;
4224 public float h;
4225 }
4226
4227 /* Only available in 2.0.4 or higher. */
4228 public static SDL_bool SDL_PointInRect(ref SDL_Point p, ref SDL_Rect r)
4229 {
4230 return ( (p.x >= r.x) &&
4231 (p.x < (r.x + r.w)) &&
4232 (p.y >= r.y) &&
4233 (p.y < (r.y + r.h)) ) ?
4234 SDL_bool.SDL_TRUE :
4235 SDL_bool.SDL_FALSE;
4236 }
4237
4238 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4239 public static extern SDL_bool SDL_EnclosePoints(
4240 [In] SDL_Point[] points,
4241 int count,
4242 ref SDL_Rect clip,
4243 out SDL_Rect result
4244 );
4245
4246 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4247 public static extern SDL_bool SDL_HasIntersection(
4248 ref SDL_Rect A,
4249 ref SDL_Rect B
4250 );
4251
4252 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4253 public static extern SDL_bool SDL_IntersectRect(
4254 ref SDL_Rect A,
4255 ref SDL_Rect B,
4256 out SDL_Rect result
4257 );
4258
4259 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4260 public static extern SDL_bool SDL_IntersectRectAndLine(
4261 ref SDL_Rect rect,
4262 ref int X1,
4263 ref int Y1,
4264 ref int X2,
4265 ref int Y2
4266 );
4267
4268 public static SDL_bool SDL_RectEmpty(ref SDL_Rect r)
4269 {
4270 return ((r.w <= 0) || (r.h <= 0)) ?
4271 SDL_bool.SDL_TRUE :
4272 SDL_bool.SDL_FALSE;
4273 }
4274
4275 public static SDL_bool SDL_RectEquals(
4276 ref SDL_Rect a,
4277 ref SDL_Rect b
4278 ) {
4279 return ( (a.x == b.x) &&
4280 (a.y == b.y) &&
4281 (a.w == b.w) &&
4282 (a.h == b.h) ) ?
4283 SDL_bool.SDL_TRUE :
4284 SDL_bool.SDL_FALSE;
4285 }
4286
4287 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4288 public static extern void SDL_UnionRect(
4289 ref SDL_Rect A,
4290 ref SDL_Rect B,
4291 out SDL_Rect result
4292 );
4293
4294 #endregion
4295
4296 #region SDL_shape.h
4297
4298 public const int SDL_NONSHAPEABLE_WINDOW = -1;
4299 public const int SDL_INVALID_SHAPE_ARGUMENT = -2;
4300 public const int SDL_WINDOW_LACKS_SHAPE = -3;
4301
4302 [DllImport(nativeLibName, EntryPoint = "SDL_CreateShapedWindow", CallingConvention = CallingConvention.Cdecl)]
4303 private static unsafe extern IntPtr INTERNAL_SDL_CreateShapedWindow(
4304 byte* title,
4305 uint x,
4306 uint y,
4307 uint w,
4308 uint h,
4309 SDL_WindowFlags flags
4310 );
4311
4312 public static unsafe IntPtr SDL_CreateShapedWindow(string title, uint x, uint y, uint w, uint h, SDL_WindowFlags flags)
4313 {
4314 byte* utf8Title = Utf8EncodeHeap(title);
4315 IntPtr result = INTERNAL_SDL_CreateShapedWindow(utf8Title, x, y, w, h, flags);
4316 Marshal.FreeHGlobal((IntPtr)utf8Title);
4317 return result;
4318 }
4319
4320 [DllImport(nativeLibName, EntryPoint = "SDL_IsShapedWindow", CallingConvention = CallingConvention.Cdecl)]
4321 public static extern SDL_bool SDL_IsShapedWindow(IntPtr window);
4322
4323 public enum WindowShapeMode
4324 {
4325 ShapeModeDefault,
4326 ShapeModeBinarizeAlpha,
4327 ShapeModeReverseBinarizeAlpha,
4328 ShapeModeColorKey
4329 }
4330
4331 public static bool SDL_SHAPEMODEALPHA(WindowShapeMode mode)
4332 {
4333 switch (mode)
4334 {
4335 case WindowShapeMode.ShapeModeDefault:
4336 case WindowShapeMode.ShapeModeBinarizeAlpha:
4337 case WindowShapeMode.ShapeModeReverseBinarizeAlpha:
4338 return true;
4339 default:
4340 return false;
4341 }
4342 }
4343
4344 [StructLayout(LayoutKind.Explicit)]
4345 public struct SDL_WindowShapeParams
4346 {
4347 [FieldOffset(0)]
4348 public byte binarizationCutoff;
4349 [FieldOffset(0)]
4350 public SDL_Color colorKey;
4351 }
4352
4353 [StructLayout(LayoutKind.Sequential)]
4354 public struct SDL_WindowShapeMode
4355 {
4356 public WindowShapeMode mode;
4357 public SDL_WindowShapeParams parameters;
4358 }
4359
4360 [DllImport(nativeLibName, EntryPoint = "SDL_SetWindowShape", CallingConvention = CallingConvention.Cdecl)]
4361 public static extern int SDL_SetWindowShape(
4362 IntPtr window,
4363 IntPtr shape,
4364 ref SDL_WindowShapeMode shape_mode
4365 );
4366
4367 [DllImport(nativeLibName, EntryPoint = "SDL_GetShapedWindowMode", CallingConvention = CallingConvention.Cdecl)]
4368 public static extern int SDL_GetShapedWindowMode(
4369 IntPtr window,
4370 out SDL_WindowShapeMode shape_mode
4371 );
4372
4373 [DllImport(nativeLibName, EntryPoint = "SDL_GetShapedWindowMode", CallingConvention = CallingConvention.Cdecl)]
4374 public static extern int SDL_GetShapedWindowMode(
4375 IntPtr window,
4376 IntPtr shape_mode
4377 );
4378
4379 #endregion
4380
4381 #region SDL_surface.h
4382
4383 public const uint SDL_SWSURFACE = 0x00000000;
4384 public const uint SDL_PREALLOC = 0x00000001;
4385 public const uint SDL_RLEACCEL = 0x00000002;
4386 public const uint SDL_DONTFREE = 0x00000004;
4387
4388 [StructLayout(LayoutKind.Sequential)]
4389 public struct SDL_Surface
4390 {
4391 public uint flags;
4392 public IntPtr format; // SDL_PixelFormat*
4393 public int w;
4394 public int h;
4395 public int pitch;
4396 public IntPtr pixels; // void*
4397 public IntPtr userdata; // void*
4398 public int locked;
4399 public IntPtr list_blitmap; // void*
4400 public SDL_Rect clip_rect;
4401 public IntPtr map; // SDL_BlitMap*
4402 public int refcount;
4403 }
4404
4405 /* surface refers to an SDL_Surface* */
4406 public static bool SDL_MUSTLOCK(IntPtr surface)
4407 {
4408 SDL_Surface sur;
4409 sur = PtrToStructure<SDL_Surface>(
4410 surface
4411 );
4412 return (sur.flags & SDL_RLEACCEL) != 0;
4413 }
4414
4415 /* src and dst refer to an SDL_Surface* */
4416 [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlit", CallingConvention = CallingConvention.Cdecl)]
4417 public static extern int SDL_BlitSurface(
4418 IntPtr src,
4419 ref SDL_Rect srcrect,
4420 IntPtr dst,
4421 ref SDL_Rect dstrect
4422 );
4423
4424 /* src and dst refer to an SDL_Surface*
4425 * Internally, this function contains logic to use default values when
4426 * source and destination rectangles are passed as NULL.
4427 * This overload allows for IntPtr.Zero (null) to be passed for srcrect.
4428 */
4429 [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlit", CallingConvention = CallingConvention.Cdecl)]
4430 public static extern int SDL_BlitSurface(
4431 IntPtr src,
4432 IntPtr srcrect,
4433 IntPtr dst,
4434 ref SDL_Rect dstrect
4435 );
4436
4437 /* src and dst refer to an SDL_Surface*
4438 * Internally, this function contains logic to use default values when
4439 * source and destination rectangles are passed as NULL.
4440 * This overload allows for IntPtr.Zero (null) to be passed for dstrect.
4441 */
4442 [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlit", CallingConvention = CallingConvention.Cdecl)]
4443 public static extern int SDL_BlitSurface(
4444 IntPtr src,
4445 ref SDL_Rect srcrect,
4446 IntPtr dst,
4447 IntPtr dstrect
4448 );
4449
4450 /* src and dst refer to an SDL_Surface*
4451 * Internally, this function contains logic to use default values when
4452 * source and destination rectangles are passed as NULL.
4453 * This overload allows for IntPtr.Zero (null) to be passed for both SDL_Rects.
4454 */
4455 [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlit", CallingConvention = CallingConvention.Cdecl)]
4456 public static extern int SDL_BlitSurface(
4457 IntPtr src,
4458 IntPtr srcrect,
4459 IntPtr dst,
4460 IntPtr dstrect
4461 );
4462
4463 /* src and dst refer to an SDL_Surface* */
4464 [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlitScaled", CallingConvention = CallingConvention.Cdecl)]
4465 public static extern int SDL_BlitScaled(
4466 IntPtr src,
4467 ref SDL_Rect srcrect,
4468 IntPtr dst,
4469 ref SDL_Rect dstrect
4470 );
4471
4472 /* src and dst refer to an SDL_Surface*
4473 * Internally, this function contains logic to use default values when
4474 * source and destination rectangles are passed as NULL.
4475 * This overload allows for IntPtr.Zero (null) to be passed for srcrect.
4476 */
4477 [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlitScaled", CallingConvention = CallingConvention.Cdecl)]
4478 public static extern int SDL_BlitScaled(
4479 IntPtr src,
4480 IntPtr srcrect,
4481 IntPtr dst,
4482 ref SDL_Rect dstrect
4483 );
4484
4485 /* src and dst refer to an SDL_Surface*
4486 * Internally, this function contains logic to use default values when
4487 * source and destination rectangles are passed as NULL.
4488 * This overload allows for IntPtr.Zero (null) to be passed for dstrect.
4489 */
4490 [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlitScaled", CallingConvention = CallingConvention.Cdecl)]
4491 public static extern int SDL_BlitScaled(
4492 IntPtr src,
4493 ref SDL_Rect srcrect,
4494 IntPtr dst,
4495 IntPtr dstrect
4496 );
4497
4498 /* src and dst refer to an SDL_Surface*
4499 * Internally, this function contains logic to use default values when
4500 * source and destination rectangles are passed as NULL.
4501 * This overload allows for IntPtr.Zero (null) to be passed for both SDL_Rects.
4502 */
4503 [DllImport(nativeLibName, EntryPoint = "SDL_UpperBlitScaled", CallingConvention = CallingConvention.Cdecl)]
4504 public static extern int SDL_BlitScaled(
4505 IntPtr src,
4506 IntPtr srcrect,
4507 IntPtr dst,
4508 IntPtr dstrect
4509 );
4510
4511 /* src and dst are void* pointers */
4512 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4513 public static extern int SDL_ConvertPixels(
4514 int width,
4515 int height,
4516 uint src_format,
4517 IntPtr src,
4518 int src_pitch,
4519 uint dst_format,
4520 IntPtr dst,
4521 int dst_pitch
4522 );
4523
4524 /* src and dst are void* pointers
4525 * Only available in 2.0.18 or higher.
4526 */
4527 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4528 public static extern int SDL_PremultiplyAlpha(
4529 int width,
4530 int height,
4531 uint src_format,
4532 IntPtr src,
4533 int src_pitch,
4534 uint dst_format,
4535 IntPtr dst,
4536 int dst_pitch
4537 );
4538
4539 /* IntPtr refers to an SDL_Surface*
4540 * src refers to an SDL_Surface*
4541 * fmt refers to an SDL_PixelFormat*
4542 */
4543 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4544 public static extern IntPtr SDL_ConvertSurface(
4545 IntPtr src,
4546 IntPtr fmt,
4547 uint flags
4548 );
4549
4550 /* IntPtr refers to an SDL_Surface*, src to an SDL_Surface* */
4551 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4552 public static extern IntPtr SDL_ConvertSurfaceFormat(
4553 IntPtr src,
4554 uint pixel_format,
4555 uint flags
4556 );
4557
4558 /* IntPtr refers to an SDL_Surface* */
4559 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4560 public static extern IntPtr SDL_CreateRGBSurface(
4561 uint flags,
4562 int width,
4563 int height,
4564 int depth,
4565 uint Rmask,
4566 uint Gmask,
4567 uint Bmask,
4568 uint Amask
4569 );
4570
4571 /* IntPtr refers to an SDL_Surface*, pixels to a void* */
4572 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4573 public static extern IntPtr SDL_CreateRGBSurfaceFrom(
4574 IntPtr pixels,
4575 int width,
4576 int height,
4577 int depth,
4578 int pitch,
4579 uint Rmask,
4580 uint Gmask,
4581 uint Bmask,
4582 uint Amask
4583 );
4584
4585 /* IntPtr refers to an SDL_Surface*
4586 * Only available in 2.0.5 or higher.
4587 */
4588 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4589 public static extern IntPtr SDL_CreateRGBSurfaceWithFormat(
4590 uint flags,
4591 int width,
4592 int height,
4593 int depth,
4594 uint format
4595 );
4596
4597 /* IntPtr refers to an SDL_Surface*, pixels to a void*
4598 * Only available in 2.0.5 or higher.
4599 */
4600 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4601 public static extern IntPtr SDL_CreateRGBSurfaceWithFormatFrom(
4602 IntPtr pixels,
4603 int width,
4604 int height,
4605 int depth,
4606 int pitch,
4607 uint format
4608 );
4609
4610 /* dst refers to an SDL_Surface* */
4611 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4612 public static extern int SDL_FillRect(
4613 IntPtr dst,
4614 ref SDL_Rect rect,
4615 uint color
4616 );
4617
4618 /* dst refers to an SDL_Surface*.
4619 * This overload allows passing NULL to rect.
4620 */
4621 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4622 public static extern int SDL_FillRect(
4623 IntPtr dst,
4624 IntPtr rect,
4625 uint color
4626 );
4627
4628 /* dst refers to an SDL_Surface* */
4629 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4630 public static extern int SDL_FillRects(
4631 IntPtr dst,
4632 [In] SDL_Rect[] rects,
4633 int count,
4634 uint color
4635 );
4636
4637 /* surface refers to an SDL_Surface* */
4638 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4639 public static extern void SDL_FreeSurface(IntPtr surface);
4640
4641 /* surface refers to an SDL_Surface* */
4642 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4643 public static extern void SDL_GetClipRect(
4644 IntPtr surface,
4645 out SDL_Rect rect
4646 );
4647
4648 /* surface refers to an SDL_Surface*.
4649 * Only available in 2.0.9 or higher.
4650 */
4651 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4652 public static extern SDL_bool SDL_HasColorKey(IntPtr surface);
4653
4654 /* surface refers to an SDL_Surface* */
4655 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4656 public static extern int SDL_GetColorKey(
4657 IntPtr surface,
4658 out uint key
4659 );
4660
4661 /* surface refers to an SDL_Surface* */
4662 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4663 public static extern int SDL_GetSurfaceAlphaMod(
4664 IntPtr surface,
4665 out byte alpha
4666 );
4667
4668 /* surface refers to an SDL_Surface* */
4669 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4670 public static extern int SDL_GetSurfaceBlendMode(
4671 IntPtr surface,
4672 out SDL_BlendMode blendMode
4673 );
4674
4675 /* surface refers to an SDL_Surface* */
4676 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4677 public static extern int SDL_GetSurfaceColorMod(
4678 IntPtr surface,
4679 out byte r,
4680 out byte g,
4681 out byte b
4682 );
4683
4684 /* These are for SDL_LoadBMP, which is a macro in the SDL headers. */
4685 /* IntPtr refers to an SDL_Surface* */
4686 /* THIS IS AN RWops FUNCTION! */
4687 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4688 public static extern IntPtr SDL_LoadBMP_RW(
4689 IntPtr src,
4690 int freesrc
4691 );
4692 public static IntPtr SDL_LoadBMP(string file)
4693 {
4694 IntPtr rwops = SDL_RWFromFile(file, "rb");
4695 return SDL_LoadBMP_RW(rwops, 1);
4696 }
4697
4698 /* surface refers to an SDL_Surface* */
4699 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4700 public static extern int SDL_LockSurface(IntPtr surface);
4701
4702 /* src and dst refer to an SDL_Surface* */
4703 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4704 public static extern int SDL_LowerBlit(
4705 IntPtr src,
4706 ref SDL_Rect srcrect,
4707 IntPtr dst,
4708 ref SDL_Rect dstrect
4709 );
4710
4711 /* src and dst refer to an SDL_Surface* */
4712 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4713 public static extern int SDL_LowerBlitScaled(
4714 IntPtr src,
4715 ref SDL_Rect srcrect,
4716 IntPtr dst,
4717 ref SDL_Rect dstrect
4718 );
4719
4720 /* These are for SDL_SaveBMP, which is a macro in the SDL headers. */
4721 /* IntPtr refers to an SDL_Surface* */
4722 /* THIS IS AN RWops FUNCTION! */
4723 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4724 public static extern int SDL_SaveBMP_RW(
4725 IntPtr surface,
4726 IntPtr src,
4727 int freesrc
4728 );
4729 public static int SDL_SaveBMP(IntPtr surface, string file)
4730 {
4731 IntPtr rwops = SDL_RWFromFile(file, "wb");
4732 return SDL_SaveBMP_RW(surface, rwops, 1);
4733 }
4734
4735 /* surface refers to an SDL_Surface* */
4736 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4737 public static extern SDL_bool SDL_SetClipRect(
4738 IntPtr surface,
4739 ref SDL_Rect rect
4740 );
4741
4742 /* surface refers to an SDL_Surface* */
4743 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4744 public static extern int SDL_SetColorKey(
4745 IntPtr surface,
4746 int flag,
4747 uint key
4748 );
4749
4750 /* surface refers to an SDL_Surface* */
4751 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4752 public static extern int SDL_SetSurfaceAlphaMod(
4753 IntPtr surface,
4754 byte alpha
4755 );
4756
4757 /* surface refers to an SDL_Surface* */
4758 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4759 public static extern int SDL_SetSurfaceBlendMode(
4760 IntPtr surface,
4761 SDL_BlendMode blendMode
4762 );
4763
4764 /* surface refers to an SDL_Surface* */
4765 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4766 public static extern int SDL_SetSurfaceColorMod(
4767 IntPtr surface,
4768 byte r,
4769 byte g,
4770 byte b
4771 );
4772
4773 /* surface refers to an SDL_Surface*, palette to an SDL_Palette* */
4774 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4775 public static extern int SDL_SetSurfacePalette(
4776 IntPtr surface,
4777 IntPtr palette
4778 );
4779
4780 /* surface refers to an SDL_Surface* */
4781 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4782 public static extern int SDL_SetSurfaceRLE(
4783 IntPtr surface,
4784 int flag
4785 );
4786
4787 /* surface refers to an SDL_Surface*.
4788 * Only available in 2.0.14 or higher.
4789 */
4790 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4791 public static extern SDL_bool SDL_HasSurfaceRLE(
4792 IntPtr surface
4793 );
4794
4795 /* src and dst refer to an SDL_Surface* */
4796 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4797 public static extern int SDL_SoftStretch(
4798 IntPtr src,
4799 ref SDL_Rect srcrect,
4800 IntPtr dst,
4801 ref SDL_Rect dstrect
4802 );
4803
4804 /* src and dst refer to an SDL_Surface*
4805 * Only available in 2.0.16 or higher.
4806 */
4807 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4808 public static extern int SDL_SoftStretchLinear(
4809 IntPtr src,
4810 ref SDL_Rect srcrect,
4811 IntPtr dst,
4812 ref SDL_Rect dstrect
4813 );
4814
4815 /* surface refers to an SDL_Surface* */
4816 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4817 public static extern void SDL_UnlockSurface(IntPtr surface);
4818
4819 /* src and dst refer to an SDL_Surface* */
4820 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4821 public static extern int SDL_UpperBlit(
4822 IntPtr src,
4823 ref SDL_Rect srcrect,
4824 IntPtr dst,
4825 ref SDL_Rect dstrect
4826 );
4827
4828 /* src and dst refer to an SDL_Surface* */
4829 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4830 public static extern int SDL_UpperBlitScaled(
4831 IntPtr src,
4832 ref SDL_Rect srcrect,
4833 IntPtr dst,
4834 ref SDL_Rect dstrect
4835 );
4836
4837 /* surface and IntPtr refer to an SDL_Surface* */
4838 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4839 public static extern IntPtr SDL_DuplicateSurface(IntPtr surface);
4840
4841 #endregion
4842
4843 #region SDL_clipboard.h
4844
4845 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
4846 public static extern SDL_bool SDL_HasClipboardText();
4847
4848 [DllImport(nativeLibName, EntryPoint = "SDL_GetClipboardText", CallingConvention = CallingConvention.Cdecl)]
4849 private static extern IntPtr INTERNAL_SDL_GetClipboardText();
4850 public static string SDL_GetClipboardText()
4851 {
4852 return UTF8_ToManaged(INTERNAL_SDL_GetClipboardText(), true);
4853 }
4854
4855 [DllImport(nativeLibName, EntryPoint = "SDL_SetClipboardText", CallingConvention = CallingConvention.Cdecl)]
4856 private static extern unsafe int INTERNAL_SDL_SetClipboardText(
4857 byte* text
4858 );
4859 public static unsafe int SDL_SetClipboardText(
4860 string text
4861 ) {
4862 byte* utf8Text = Utf8EncodeHeap(text);
4863 int result = INTERNAL_SDL_SetClipboardText(
4864 utf8Text
4865 );
4866 Marshal.FreeHGlobal((IntPtr) utf8Text);
4867 return result;
4868 }
4869
4870 #endregion
4871
4872 #region SDL_events.h
4873
4874 /* General keyboard/mouse state definitions. */
4875 public const byte SDL_PRESSED = 1;
4876 public const byte SDL_RELEASED = 0;
4877
4878 /* Default size is according to SDL2 default. */
4879 public const int SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32;
4880 public const int SDL_TEXTINPUTEVENT_TEXT_SIZE = 32;
4881
4882 /* The types of events that can be delivered. */
4883 public enum SDL_EventType : uint
4884 {
4885 SDL_FIRSTEVENT = 0,
4886
4887 /* Application events */
4888 SDL_QUIT = 0x100,
4889
4890 /* iOS/Android/WinRT app events */
4891 SDL_APP_TERMINATING,
4892 SDL_APP_LOWMEMORY,
4893 SDL_APP_WILLENTERBACKGROUND,
4894 SDL_APP_DIDENTERBACKGROUND,
4895 SDL_APP_WILLENTERFOREGROUND,
4896 SDL_APP_DIDENTERFOREGROUND,
4897
4898 /* Only available in SDL 2.0.14 or higher. */
4899 SDL_LOCALECHANGED,
4900
4901 /* Display events */
4902 /* Only available in SDL 2.0.9 or higher. */
4903 SDL_DISPLAYEVENT = 0x150,
4904
4905 /* Window events */
4906 SDL_WINDOWEVENT = 0x200,
4907 SDL_SYSWMEVENT,
4908
4909 /* Keyboard events */
4910 SDL_KEYDOWN = 0x300,
4911 SDL_KEYUP,
4912 SDL_TEXTEDITING,
4913 SDL_TEXTINPUT,
4914 SDL_KEYMAPCHANGED,
4915 SDL_TEXTEDITING_EXT,
4916
4917 /* Mouse events */
4918 SDL_MOUSEMOTION = 0x400,
4919 SDL_MOUSEBUTTONDOWN,
4920 SDL_MOUSEBUTTONUP,
4921 SDL_MOUSEWHEEL,
4922
4923 /* Joystick events */
4924 SDL_JOYAXISMOTION = 0x600,
4925 SDL_JOYBALLMOTION,
4926 SDL_JOYHATMOTION,
4927 SDL_JOYBUTTONDOWN,
4928 SDL_JOYBUTTONUP,
4929 SDL_JOYDEVICEADDED,
4930 SDL_JOYDEVICEREMOVED,
4931
4932 /* Game controller events */
4933 SDL_CONTROLLERAXISMOTION = 0x650,
4934 SDL_CONTROLLERBUTTONDOWN,
4935 SDL_CONTROLLERBUTTONUP,
4936 SDL_CONTROLLERDEVICEADDED,
4937 SDL_CONTROLLERDEVICEREMOVED,
4938 SDL_CONTROLLERDEVICEREMAPPED,
4939 SDL_CONTROLLERTOUCHPADDOWN, /* Requires >= 2.0.14 */
4940 SDL_CONTROLLERTOUCHPADMOTION, /* Requires >= 2.0.14 */
4941 SDL_CONTROLLERTOUCHPADUP, /* Requires >= 2.0.14 */
4942 SDL_CONTROLLERSENSORUPDATE, /* Requires >= 2.0.14 */
4943
4944 /* Touch events */
4945 SDL_FINGERDOWN = 0x700,
4946 SDL_FINGERUP,
4947 SDL_FINGERMOTION,
4948
4949 /* Gesture events */
4950 SDL_DOLLARGESTURE = 0x800,
4951 SDL_DOLLARRECORD,
4952 SDL_MULTIGESTURE,
4953
4954 /* Clipboard events */
4955 SDL_CLIPBOARDUPDATE = 0x900,
4956
4957 /* Drag and drop events */
4958 SDL_DROPFILE = 0x1000,
4959 /* Only available in 2.0.4 or higher. */
4960 SDL_DROPTEXT,
4961 SDL_DROPBEGIN,
4962 SDL_DROPCOMPLETE,
4963
4964 /* Audio hotplug events */
4965 /* Only available in SDL 2.0.4 or higher. */
4966 SDL_AUDIODEVICEADDED = 0x1100,
4967 SDL_AUDIODEVICEREMOVED,
4968
4969 /* Sensor events */
4970 /* Only available in SDL 2.0.9 or higher. */
4971 SDL_SENSORUPDATE = 0x1200,
4972
4973 /* Render events */
4974 /* Only available in SDL 2.0.2 or higher. */
4975 SDL_RENDER_TARGETS_RESET = 0x2000,
4976 /* Only available in SDL 2.0.4 or higher. */
4977 SDL_RENDER_DEVICE_RESET,
4978
4979 /* Internal events */
4980 /* Only available in 2.0.18 or higher. */
4981 SDL_POLLSENTINEL = 0x7F00,
4982
4983 /* Events SDL_USEREVENT through SDL_LASTEVENT are for
4984 * your use, and should be allocated with
4985 * SDL_RegisterEvents()
4986 */
4987 SDL_USEREVENT = 0x8000,
4988
4989 /* The last event, used for bouding arrays. */
4990 SDL_LASTEVENT = 0xFFFF
4991 }
4992
4993 /* Only available in 2.0.4 or higher. */
4994 public enum SDL_MouseWheelDirection : uint
4995 {
4996 SDL_MOUSEWHEEL_NORMAL,
4997 SDL_MOUSEWHEEL_FLIPPED
4998 }
4999
5000 /* Fields shared by every event */
5001 [StructLayout(LayoutKind.Sequential)]
5002 public struct SDL_GenericEvent
5003 {
5004 public SDL_EventType type;
5005 public UInt32 timestamp;
5006 }
5007
5008// Ignore private members used for padding in this struct
5009#pragma warning disable 0169
5010 [StructLayout(LayoutKind.Sequential)]
5011 public struct SDL_DisplayEvent
5012 {
5013 public SDL_EventType type;
5014 public UInt32 timestamp;
5015 public UInt32 display;
5016 public SDL_DisplayEventID displayEvent; // event, lolC#
5017 private byte padding1;
5018 private byte padding2;
5019 private byte padding3;
5020 public Int32 data1;
5021 }
5022#pragma warning restore 0169
5023
5024// Ignore private members used for padding in this struct
5025#pragma warning disable 0169
5026 /* Window state change event data (event.window.*) */
5027 [StructLayout(LayoutKind.Sequential)]
5028 public struct SDL_WindowEvent
5029 {
5030 public SDL_EventType type;
5031 public UInt32 timestamp;
5032 public UInt32 windowID;
5033 public SDL_WindowEventID windowEvent; // event, lolC#
5034 private byte padding1;
5035 private byte padding2;
5036 private byte padding3;
5037 public Int32 data1;
5038 public Int32 data2;
5039 }
5040#pragma warning restore 0169
5041
5042// Ignore private members used for padding in this struct
5043#pragma warning disable 0169
5044 /* Keyboard button event structure (event.key.*) */
5045 [StructLayout(LayoutKind.Sequential)]
5046 public struct SDL_KeyboardEvent
5047 {
5048 public SDL_EventType type;
5049 public UInt32 timestamp;
5050 public UInt32 windowID;
5051 public byte state;
5052 public byte repeat; /* non-zero if this is a repeat */
5053 private byte padding2;
5054 private byte padding3;
5055 public SDL_Keysym keysym;
5056 }
5057#pragma warning restore 0169
5058
5059 [StructLayout(LayoutKind.Sequential)]
5060 public unsafe struct SDL_TextEditingEvent
5061 {
5062 public SDL_EventType type;
5063 public UInt32 timestamp;
5064 public UInt32 windowID;
5065 public fixed byte text[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
5066 public Int32 start;
5067 public Int32 length;
5068 }
5069
5070 [StructLayout(LayoutKind.Sequential)]
5071 public unsafe struct SDL_TextEditingExtEvent
5072 {
5073 public SDL_EventType type;
5074 public UInt32 timestamp;
5075 public UInt32 windowID;
5076 public IntPtr text; /* char*, free with SDL_free */
5077 public Int32 start;
5078 public Int32 length;
5079 }
5080
5081 [StructLayout(LayoutKind.Sequential)]
5082 public unsafe struct SDL_TextInputEvent
5083 {
5084 public SDL_EventType type;
5085 public UInt32 timestamp;
5086 public UInt32 windowID;
5087 public fixed byte text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
5088 }
5089
5090// Ignore private members used for padding in this struct
5091#pragma warning disable 0169
5092 /* Mouse motion event structure (event.motion.*) */
5093 [StructLayout(LayoutKind.Sequential)]
5094 public struct SDL_MouseMotionEvent
5095 {
5096 public SDL_EventType type;
5097 public UInt32 timestamp;
5098 public UInt32 windowID;
5099 public UInt32 which;
5100 public byte state; /* bitmask of buttons */
5101 private byte padding1;
5102 private byte padding2;
5103 private byte padding3;
5104 public Int32 x;
5105 public Int32 y;
5106 public Int32 xrel;
5107 public Int32 yrel;
5108 }
5109#pragma warning restore 0169
5110
5111// Ignore private members used for padding in this struct
5112#pragma warning disable 0169
5113 /* Mouse button event structure (event.button.*) */
5114 [StructLayout(LayoutKind.Sequential)]
5115 public struct SDL_MouseButtonEvent
5116 {
5117 public SDL_EventType type;
5118 public UInt32 timestamp;
5119 public UInt32 windowID;
5120 public UInt32 which;
5121 public byte button; /* button id */
5122 public byte state; /* SDL_PRESSED or SDL_RELEASED */
5123 public byte clicks; /* 1 for single-click, 2 for double-click, etc. */
5124 private byte padding1;
5125 public Int32 x;
5126 public Int32 y;
5127 }
5128#pragma warning restore 0169
5129
5130 /* Mouse wheel event structure (event.wheel.*) */
5131 [StructLayout(LayoutKind.Sequential)]
5132 public struct SDL_MouseWheelEvent
5133 {
5134 public SDL_EventType type;
5135 public UInt32 timestamp;
5136 public UInt32 windowID;
5137 public UInt32 which;
5138 public Int32 x; /* amount scrolled horizontally */
5139 public Int32 y; /* amount scrolled vertically */
5140 public UInt32 direction; /* Set to one of the SDL_MOUSEWHEEL_* defines */
5141 public float preciseX; /* Requires >= 2.0.18 */
5142 public float preciseY; /* Requires >= 2.0.18 */
5143 }
5144
5145// Ignore private members used for padding in this struct
5146#pragma warning disable 0169
5147 /* Joystick axis motion event structure (event.jaxis.*) */
5148 [StructLayout(LayoutKind.Sequential)]
5149 public struct SDL_JoyAxisEvent
5150 {
5151 public SDL_EventType type;
5152 public UInt32 timestamp;
5153 public Int32 which; /* SDL_JoystickID */
5154 public byte axis;
5155 private byte padding1;
5156 private byte padding2;
5157 private byte padding3;
5158 public Int16 axisValue; /* value, lolC# */
5159 public UInt16 padding4;
5160 }
5161#pragma warning restore 0169
5162
5163// Ignore private members used for padding in this struct
5164#pragma warning disable 0169
5165 /* Joystick trackball motion event structure (event.jball.*) */
5166 [StructLayout(LayoutKind.Sequential)]
5167 public struct SDL_JoyBallEvent
5168 {
5169 public SDL_EventType type;
5170 public UInt32 timestamp;
5171 public Int32 which; /* SDL_JoystickID */
5172 public byte ball;
5173 private byte padding1;
5174 private byte padding2;
5175 private byte padding3;
5176 public Int16 xrel;
5177 public Int16 yrel;
5178 }
5179#pragma warning restore 0169
5180
5181// Ignore private members used for padding in this struct
5182#pragma warning disable 0169
5183 /* Joystick hat position change event struct (event.jhat.*) */
5184 [StructLayout(LayoutKind.Sequential)]
5185 public struct SDL_JoyHatEvent
5186 {
5187 public SDL_EventType type;
5188 public UInt32 timestamp;
5189 public Int32 which; /* SDL_JoystickID */
5190 public byte hat; /* index of the hat */
5191 public byte hatValue; /* value, lolC# */
5192 private byte padding1;
5193 private byte padding2;
5194 }
5195#pragma warning restore 0169
5196
5197// Ignore private members used for padding in this struct
5198#pragma warning disable 0169
5199 /* Joystick button event structure (event.jbutton.*) */
5200 [StructLayout(LayoutKind.Sequential)]
5201 public struct SDL_JoyButtonEvent
5202 {
5203 public SDL_EventType type;
5204 public UInt32 timestamp;
5205 public Int32 which; /* SDL_JoystickID */
5206 public byte button;
5207 public byte state; /* SDL_PRESSED or SDL_RELEASED */
5208 private byte padding1;
5209 private byte padding2;
5210 }
5211#pragma warning restore 0169
5212
5213 /* Joystick device event structure (event.jdevice.*) */
5214 [StructLayout(LayoutKind.Sequential)]
5215 public struct SDL_JoyDeviceEvent
5216 {
5217 public SDL_EventType type;
5218 public UInt32 timestamp;
5219 public Int32 which; /* SDL_JoystickID */
5220 }
5221
5222// Ignore private members used for padding in this struct
5223#pragma warning disable 0169
5224 /* Game controller axis motion event (event.caxis.*) */
5225 [StructLayout(LayoutKind.Sequential)]
5226 public struct SDL_ControllerAxisEvent
5227 {
5228 public SDL_EventType type;
5229 public UInt32 timestamp;
5230 public Int32 which; /* SDL_JoystickID */
5231 public byte axis;
5232 private byte padding1;
5233 private byte padding2;
5234 private byte padding3;
5235 public Int16 axisValue; /* value, lolC# */
5236 private UInt16 padding4;
5237 }
5238#pragma warning restore 0169
5239
5240// Ignore private members used for padding in this struct
5241#pragma warning disable 0169
5242 /* Game controller button event (event.cbutton.*) */
5243 [StructLayout(LayoutKind.Sequential)]
5244 public struct SDL_ControllerButtonEvent
5245 {
5246 public SDL_EventType type;
5247 public UInt32 timestamp;
5248 public Int32 which; /* SDL_JoystickID */
5249 public byte button;
5250 public byte state;
5251 private byte padding1;
5252 private byte padding2;
5253 }
5254#pragma warning restore 0169
5255
5256 /* Game controller device event (event.cdevice.*) */
5257 [StructLayout(LayoutKind.Sequential)]
5258 public struct SDL_ControllerDeviceEvent
5259 {
5260 public SDL_EventType type;
5261 public UInt32 timestamp;
5262 public Int32 which; /* joystick id for ADDED,
5263 * else instance id
5264 */
5265 }
5266
5267 /* Game controller touchpad event structure (event.ctouchpad.*) */
5268 [StructLayout(LayoutKind.Sequential)]
5269 public struct SDL_ControllerTouchpadEvent
5270 {
5271 public SDL_EventType type;
5272 public UInt32 timestamp;
5273 public Int32 which; /* SDL_JoystickID */
5274 public Int32 touchpad;
5275 public Int32 finger;
5276 public float x;
5277 public float y;
5278 public float pressure;
5279 }
5280
5281 /* Game controller sensor event structure (event.csensor.*) */
5282 [StructLayout(LayoutKind.Sequential)]
5283 public struct SDL_ControllerSensorEvent
5284 {
5285 public SDL_EventType type;
5286 public UInt32 timestamp;
5287 public Int32 which; /* SDL_JoystickID */
5288 public Int32 sensor;
5289 public float data1;
5290 public float data2;
5291 public float data3;
5292 }
5293
5294// Ignore private members used for padding in this struct
5295#pragma warning disable 0169
5296 /* Audio device event (event.adevice.*) */
5297 [StructLayout(LayoutKind.Sequential)]
5298 public struct SDL_AudioDeviceEvent
5299 {
5300 public SDL_EventType type;
5301 public UInt32 timestamp;
5302 public UInt32 which;
5303 public byte iscapture;
5304 private byte padding1;
5305 private byte padding2;
5306 private byte padding3;
5307 }
5308#pragma warning restore 0169
5309
5310 [StructLayout(LayoutKind.Sequential)]
5311 public struct SDL_TouchFingerEvent
5312 {
5313 public SDL_EventType type;
5314 public UInt32 timestamp;
5315 public Int64 touchId; // SDL_TouchID
5316 public Int64 fingerId; // SDL_GestureID
5317 public float x;
5318 public float y;
5319 public float dx;
5320 public float dy;
5321 public float pressure;
5322 public uint windowID;
5323 }
5324
5325 [StructLayout(LayoutKind.Sequential)]
5326 public struct SDL_MultiGestureEvent
5327 {
5328 public SDL_EventType type;
5329 public UInt32 timestamp;
5330 public Int64 touchId; // SDL_TouchID
5331 public float dTheta;
5332 public float dDist;
5333 public float x;
5334 public float y;
5335 public UInt16 numFingers;
5336 public UInt16 padding;
5337 }
5338
5339 [StructLayout(LayoutKind.Sequential)]
5340 public struct SDL_DollarGestureEvent
5341 {
5342 public SDL_EventType type;
5343 public UInt32 timestamp;
5344 public Int64 touchId; // SDL_TouchID
5345 public Int64 gestureId; // SDL_GestureID
5346 public UInt32 numFingers;
5347 public float error;
5348 public float x;
5349 public float y;
5350 }
5351
5352 /* File open request by system (event.drop.*), enabled by
5353 * default
5354 */
5355 [StructLayout(LayoutKind.Sequential)]
5356 public struct SDL_DropEvent
5357 {
5358 public SDL_EventType type;
5359 public UInt32 timestamp;
5360
5361 /* char* filename, to be freed.
5362 * Access the variable EXACTLY ONCE like this:
5363 * string s = SDL.UTF8_ToManaged(evt.drop.file, true);
5364 */
5365 public IntPtr file;
5366 public UInt32 windowID;
5367 }
5368
5369 [StructLayout(LayoutKind.Sequential)]
5370 public unsafe struct SDL_SensorEvent
5371 {
5372 public SDL_EventType type;
5373 public UInt32 timestamp;
5374 public Int32 which;
5375 public fixed float data[6];
5376 }
5377
5378 /* The "quit requested" event */
5379 [StructLayout(LayoutKind.Sequential)]
5380 public struct SDL_QuitEvent
5381 {
5382 public SDL_EventType type;
5383 public UInt32 timestamp;
5384 }
5385
5386 /* A user defined event (event.user.*) */
5387 [StructLayout(LayoutKind.Sequential)]
5388 public struct SDL_UserEvent
5389 {
5390 public SDL_EventType type;
5391 public UInt32 timestamp;
5392 public UInt32 windowID;
5393 public Int32 code;
5394 public IntPtr data1; /* user-defined */
5395 public IntPtr data2; /* user-defined */
5396 }
5397
5398 /* A video driver dependent event (event.syswm.*), disabled */
5399 [StructLayout(LayoutKind.Sequential)]
5400 public struct SDL_SysWMEvent
5401 {
5402 public SDL_EventType type;
5403 public UInt32 timestamp;
5404 public IntPtr msg; /* SDL_SysWMmsg*, system-dependent*/
5405 }
5406
5407 /* General event structure */
5408 // C# doesn't do unions, so we do this ugly thing. */
5409 [StructLayout(LayoutKind.Explicit)]
5410 public unsafe struct SDL_Event
5411 {
5412 [FieldOffset(0)]
5413 public SDL_EventType type;
5414 [FieldOffset(0)]
5415 public SDL_EventType typeFSharp;
5416 [FieldOffset(0)]
5417 public SDL_DisplayEvent display;
5418 [FieldOffset(0)]
5419 public SDL_WindowEvent window;
5420 [FieldOffset(0)]
5421 public SDL_KeyboardEvent key;
5422 [FieldOffset(0)]
5423 public SDL_TextEditingEvent edit;
5424 [FieldOffset(0)]
5425 public SDL_TextEditingExtEvent editExt;
5426 [FieldOffset(0)]
5427 public SDL_TextInputEvent text;
5428 [FieldOffset(0)]
5429 public SDL_MouseMotionEvent motion;
5430 [FieldOffset(0)]
5431 public SDL_MouseButtonEvent button;
5432 [FieldOffset(0)]
5433 public SDL_MouseWheelEvent wheel;
5434 [FieldOffset(0)]
5435 public SDL_JoyAxisEvent jaxis;
5436 [FieldOffset(0)]
5437 public SDL_JoyBallEvent jball;
5438 [FieldOffset(0)]
5439 public SDL_JoyHatEvent jhat;
5440 [FieldOffset(0)]
5441 public SDL_JoyButtonEvent jbutton;
5442 [FieldOffset(0)]
5443 public SDL_JoyDeviceEvent jdevice;
5444 [FieldOffset(0)]
5445 public SDL_ControllerAxisEvent caxis;
5446 [FieldOffset(0)]
5447 public SDL_ControllerButtonEvent cbutton;
5448 [FieldOffset(0)]
5449 public SDL_ControllerDeviceEvent cdevice;
5450 [FieldOffset(0)]
5451 public SDL_ControllerTouchpadEvent ctouchpad;
5452 [FieldOffset(0)]
5453 public SDL_ControllerSensorEvent csensor;
5454 [FieldOffset(0)]
5455 public SDL_AudioDeviceEvent adevice;
5456 [FieldOffset(0)]
5457 public SDL_SensorEvent sensor;
5458 [FieldOffset(0)]
5459 public SDL_QuitEvent quit;
5460 [FieldOffset(0)]
5461 public SDL_UserEvent user;
5462 [FieldOffset(0)]
5463 public SDL_SysWMEvent syswm;
5464 [FieldOffset(0)]
5465 public SDL_TouchFingerEvent tfinger;
5466 [FieldOffset(0)]
5467 public SDL_MultiGestureEvent mgesture;
5468 [FieldOffset(0)]
5469 public SDL_DollarGestureEvent dgesture;
5470 [FieldOffset(0)]
5471 public SDL_DropEvent drop;
5472 [FieldOffset(0)]
5473 private fixed byte padding[56];
5474 }
5475
5476 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
5477 public delegate int SDL_EventFilter(
5478 IntPtr userdata, // void*
5479 IntPtr sdlevent // SDL_Event* event, lolC#
5480 );
5481
5482 /* Pump the event loop, getting events from the input devices*/
5483 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5484 public static extern void SDL_PumpEvents();
5485
5486 public enum SDL_eventaction
5487 {
5488 SDL_ADDEVENT,
5489 SDL_PEEKEVENT,
5490 SDL_GETEVENT
5491 }
5492
5493 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5494 public static extern int SDL_PeepEvents(
5495 [Out] SDL_Event[] events,
5496 int numevents,
5497 SDL_eventaction action,
5498 SDL_EventType minType,
5499 SDL_EventType maxType
5500 );
5501
5502 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5503 public static extern unsafe int SDL_PeepEvents(
5504 SDL_Event* events,
5505 int numevents,
5506 SDL_eventaction action,
5507 SDL_EventType minType,
5508 SDL_EventType maxType
5509 );
5510
5511 /* Checks to see if certain events are in the event queue */
5512 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5513 public static extern SDL_bool SDL_HasEvent(SDL_EventType type);
5514
5515 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5516 public static extern SDL_bool SDL_HasEvents(
5517 SDL_EventType minType,
5518 SDL_EventType maxType
5519 );
5520
5521 /* Clears events from the event queue */
5522 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5523 public static extern void SDL_FlushEvent(SDL_EventType type);
5524
5525 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5526 public static extern void SDL_FlushEvents(
5527 SDL_EventType min,
5528 SDL_EventType max
5529 );
5530
5531 /* Polls for currently pending events */
5532 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5533 public static extern int SDL_PollEvent(out SDL_Event _event);
5534
5535 /* Waits indefinitely for the next event */
5536 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5537 public static extern int SDL_WaitEvent(out SDL_Event _event);
5538
5539 /* Waits until the specified timeout (in ms) for the next event
5540 */
5541 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5542 public static extern int SDL_WaitEventTimeout(out SDL_Event _event, int timeout);
5543
5544 /* Add an event to the event queue */
5545 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5546 public static extern int SDL_PushEvent(ref SDL_Event _event);
5547
5548 /* userdata refers to a void* */
5549 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5550 public static extern void SDL_SetEventFilter(
5551 SDL_EventFilter filter,
5552 IntPtr userdata
5553 );
5554
5555 /* userdata refers to a void* */
5556 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5557 private static extern SDL_bool SDL_GetEventFilter(
5558 out IntPtr filter,
5559 out IntPtr userdata
5560 );
5561 public static SDL_bool SDL_GetEventFilter(
5562 out SDL_EventFilter filter,
5563 out IntPtr userdata
5564 ) {
5565 IntPtr result = IntPtr.Zero;
5566 SDL_bool retval = SDL_GetEventFilter(out result, out userdata);
5567 if (result != IntPtr.Zero)
5568 {
5569 filter = (SDL_EventFilter) GetDelegateForFunctionPointer<SDL_EventFilter>(
5570 result
5571 );
5572 }
5573 else
5574 {
5575 filter = null!;
5576 }
5577 return retval;
5578 }
5579
5580 /* userdata refers to a void* */
5581 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5582 public static extern void SDL_AddEventWatch(
5583 SDL_EventFilter filter,
5584 IntPtr userdata
5585 );
5586
5587 /* userdata refers to a void* */
5588 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5589 public static extern void SDL_DelEventWatch(
5590 SDL_EventFilter filter,
5591 IntPtr userdata
5592 );
5593
5594 /* userdata refers to a void* */
5595 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5596 public static extern void SDL_FilterEvents(
5597 SDL_EventFilter filter,
5598 IntPtr userdata
5599 );
5600
5601 /* These are for SDL_EventState() */
5602 public const int SDL_QUERY = -1;
5603 public const int SDL_IGNORE = 0;
5604 public const int SDL_DISABLE = 0;
5605 public const int SDL_ENABLE = 1;
5606
5607 /* This function allows you to enable/disable certain events */
5608 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5609 public static extern byte SDL_EventState(SDL_EventType type, int state);
5610
5611 /* Get the state of an event */
5612 public static byte SDL_GetEventState(SDL_EventType type)
5613 {
5614 return SDL_EventState(type, SDL_QUERY);
5615 }
5616
5617 /* Allocate a set of user-defined events */
5618 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
5619 public static extern UInt32 SDL_RegisterEvents(int numevents);
5620 #endregion
5621
5622 #region SDL_scancode.h
5623
5624 /* Scancodes based off USB keyboard page (0x07) */
5625 public enum SDL_Scancode
5626 {
5627 SDL_SCANCODE_UNKNOWN = 0,
5628
5629 SDL_SCANCODE_A = 4,
5630 SDL_SCANCODE_B = 5,
5631 SDL_SCANCODE_C = 6,
5632 SDL_SCANCODE_D = 7,
5633 SDL_SCANCODE_E = 8,
5634 SDL_SCANCODE_F = 9,
5635 SDL_SCANCODE_G = 10,
5636 SDL_SCANCODE_H = 11,
5637 SDL_SCANCODE_I = 12,
5638 SDL_SCANCODE_J = 13,
5639 SDL_SCANCODE_K = 14,
5640 SDL_SCANCODE_L = 15,
5641 SDL_SCANCODE_M = 16,
5642 SDL_SCANCODE_N = 17,
5643 SDL_SCANCODE_O = 18,
5644 SDL_SCANCODE_P = 19,
5645 SDL_SCANCODE_Q = 20,
5646 SDL_SCANCODE_R = 21,
5647 SDL_SCANCODE_S = 22,
5648 SDL_SCANCODE_T = 23,
5649 SDL_SCANCODE_U = 24,
5650 SDL_SCANCODE_V = 25,
5651 SDL_SCANCODE_W = 26,
5652 SDL_SCANCODE_X = 27,
5653 SDL_SCANCODE_Y = 28,
5654 SDL_SCANCODE_Z = 29,
5655
5656 SDL_SCANCODE_1 = 30,
5657 SDL_SCANCODE_2 = 31,
5658 SDL_SCANCODE_3 = 32,
5659 SDL_SCANCODE_4 = 33,
5660 SDL_SCANCODE_5 = 34,
5661 SDL_SCANCODE_6 = 35,
5662 SDL_SCANCODE_7 = 36,
5663 SDL_SCANCODE_8 = 37,
5664 SDL_SCANCODE_9 = 38,
5665 SDL_SCANCODE_0 = 39,
5666
5667 SDL_SCANCODE_RETURN = 40,
5668 SDL_SCANCODE_ESCAPE = 41,
5669 SDL_SCANCODE_BACKSPACE = 42,
5670 SDL_SCANCODE_TAB = 43,
5671 SDL_SCANCODE_SPACE = 44,
5672
5673 SDL_SCANCODE_MINUS = 45,
5674 SDL_SCANCODE_EQUALS = 46,
5675 SDL_SCANCODE_LEFTBRACKET = 47,
5676 SDL_SCANCODE_RIGHTBRACKET = 48,
5677 SDL_SCANCODE_BACKSLASH = 49,
5678 SDL_SCANCODE_NONUSHASH = 50,
5679 SDL_SCANCODE_SEMICOLON = 51,
5680 SDL_SCANCODE_APOSTROPHE = 52,
5681 SDL_SCANCODE_GRAVE = 53,
5682 SDL_SCANCODE_COMMA = 54,
5683 SDL_SCANCODE_PERIOD = 55,
5684 SDL_SCANCODE_SLASH = 56,
5685
5686 SDL_SCANCODE_CAPSLOCK = 57,
5687
5688 SDL_SCANCODE_F1 = 58,
5689 SDL_SCANCODE_F2 = 59,
5690 SDL_SCANCODE_F3 = 60,
5691 SDL_SCANCODE_F4 = 61,
5692 SDL_SCANCODE_F5 = 62,
5693 SDL_SCANCODE_F6 = 63,
5694 SDL_SCANCODE_F7 = 64,
5695 SDL_SCANCODE_F8 = 65,
5696 SDL_SCANCODE_F9 = 66,
5697 SDL_SCANCODE_F10 = 67,
5698 SDL_SCANCODE_F11 = 68,
5699 SDL_SCANCODE_F12 = 69,
5700
5701 SDL_SCANCODE_PRINTSCREEN = 70,
5702 SDL_SCANCODE_SCROLLLOCK = 71,
5703 SDL_SCANCODE_PAUSE = 72,
5704 SDL_SCANCODE_INSERT = 73,
5705 SDL_SCANCODE_HOME = 74,
5706 SDL_SCANCODE_PAGEUP = 75,
5707 SDL_SCANCODE_DELETE = 76,
5708 SDL_SCANCODE_END = 77,
5709 SDL_SCANCODE_PAGEDOWN = 78,
5710 SDL_SCANCODE_RIGHT = 79,
5711 SDL_SCANCODE_LEFT = 80,
5712 SDL_SCANCODE_DOWN = 81,
5713 SDL_SCANCODE_UP = 82,
5714
5715 SDL_SCANCODE_NUMLOCKCLEAR = 83,
5716 SDL_SCANCODE_KP_DIVIDE = 84,
5717 SDL_SCANCODE_KP_MULTIPLY = 85,
5718 SDL_SCANCODE_KP_MINUS = 86,
5719 SDL_SCANCODE_KP_PLUS = 87,
5720 SDL_SCANCODE_KP_ENTER = 88,
5721 SDL_SCANCODE_KP_1 = 89,
5722 SDL_SCANCODE_KP_2 = 90,
5723 SDL_SCANCODE_KP_3 = 91,
5724 SDL_SCANCODE_KP_4 = 92,
5725 SDL_SCANCODE_KP_5 = 93,
5726 SDL_SCANCODE_KP_6 = 94,
5727 SDL_SCANCODE_KP_7 = 95,
5728 SDL_SCANCODE_KP_8 = 96,
5729 SDL_SCANCODE_KP_9 = 97,
5730 SDL_SCANCODE_KP_0 = 98,
5731 SDL_SCANCODE_KP_PERIOD = 99,
5732
5733 SDL_SCANCODE_NONUSBACKSLASH = 100,
5734 SDL_SCANCODE_APPLICATION = 101,
5735 SDL_SCANCODE_POWER = 102,
5736 SDL_SCANCODE_KP_EQUALS = 103,
5737 SDL_SCANCODE_F13 = 104,
5738 SDL_SCANCODE_F14 = 105,
5739 SDL_SCANCODE_F15 = 106,
5740 SDL_SCANCODE_F16 = 107,
5741 SDL_SCANCODE_F17 = 108,
5742 SDL_SCANCODE_F18 = 109,
5743 SDL_SCANCODE_F19 = 110,
5744 SDL_SCANCODE_F20 = 111,
5745 SDL_SCANCODE_F21 = 112,
5746 SDL_SCANCODE_F22 = 113,
5747 SDL_SCANCODE_F23 = 114,
5748 SDL_SCANCODE_F24 = 115,
5749 SDL_SCANCODE_EXECUTE = 116,
5750 SDL_SCANCODE_HELP = 117,
5751 SDL_SCANCODE_MENU = 118,
5752 SDL_SCANCODE_SELECT = 119,
5753 SDL_SCANCODE_STOP = 120,
5754 SDL_SCANCODE_AGAIN = 121,
5755 SDL_SCANCODE_UNDO = 122,
5756 SDL_SCANCODE_CUT = 123,
5757 SDL_SCANCODE_COPY = 124,
5758 SDL_SCANCODE_PASTE = 125,
5759 SDL_SCANCODE_FIND = 126,
5760 SDL_SCANCODE_MUTE = 127,
5761 SDL_SCANCODE_VOLUMEUP = 128,
5762 SDL_SCANCODE_VOLUMEDOWN = 129,
5763 /* not sure whether there's a reason to enable these */
5764 /* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */
5765 /* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */
5766 /* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */
5767 SDL_SCANCODE_KP_COMMA = 133,
5768 SDL_SCANCODE_KP_EQUALSAS400 = 134,
5769
5770 SDL_SCANCODE_INTERNATIONAL1 = 135,
5771 SDL_SCANCODE_INTERNATIONAL2 = 136,
5772 SDL_SCANCODE_INTERNATIONAL3 = 137,
5773 SDL_SCANCODE_INTERNATIONAL4 = 138,
5774 SDL_SCANCODE_INTERNATIONAL5 = 139,
5775 SDL_SCANCODE_INTERNATIONAL6 = 140,
5776 SDL_SCANCODE_INTERNATIONAL7 = 141,
5777 SDL_SCANCODE_INTERNATIONAL8 = 142,
5778 SDL_SCANCODE_INTERNATIONAL9 = 143,
5779 SDL_SCANCODE_LANG1 = 144,
5780 SDL_SCANCODE_LANG2 = 145,
5781 SDL_SCANCODE_LANG3 = 146,
5782 SDL_SCANCODE_LANG4 = 147,
5783 SDL_SCANCODE_LANG5 = 148,
5784 SDL_SCANCODE_LANG6 = 149,
5785 SDL_SCANCODE_LANG7 = 150,
5786 SDL_SCANCODE_LANG8 = 151,
5787 SDL_SCANCODE_LANG9 = 152,
5788
5789 SDL_SCANCODE_ALTERASE = 153,
5790 SDL_SCANCODE_SYSREQ = 154,
5791 SDL_SCANCODE_CANCEL = 155,
5792 SDL_SCANCODE_CLEAR = 156,
5793 SDL_SCANCODE_PRIOR = 157,
5794 SDL_SCANCODE_RETURN2 = 158,
5795 SDL_SCANCODE_SEPARATOR = 159,
5796 SDL_SCANCODE_OUT = 160,
5797 SDL_SCANCODE_OPER = 161,
5798 SDL_SCANCODE_CLEARAGAIN = 162,
5799 SDL_SCANCODE_CRSEL = 163,
5800 SDL_SCANCODE_EXSEL = 164,
5801
5802 SDL_SCANCODE_KP_00 = 176,
5803 SDL_SCANCODE_KP_000 = 177,
5804 SDL_SCANCODE_THOUSANDSSEPARATOR = 178,
5805 SDL_SCANCODE_DECIMALSEPARATOR = 179,
5806 SDL_SCANCODE_CURRENCYUNIT = 180,
5807 SDL_SCANCODE_CURRENCYSUBUNIT = 181,
5808 SDL_SCANCODE_KP_LEFTPAREN = 182,
5809 SDL_SCANCODE_KP_RIGHTPAREN = 183,
5810 SDL_SCANCODE_KP_LEFTBRACE = 184,
5811 SDL_SCANCODE_KP_RIGHTBRACE = 185,
5812 SDL_SCANCODE_KP_TAB = 186,
5813 SDL_SCANCODE_KP_BACKSPACE = 187,
5814 SDL_SCANCODE_KP_A = 188,
5815 SDL_SCANCODE_KP_B = 189,
5816 SDL_SCANCODE_KP_C = 190,
5817 SDL_SCANCODE_KP_D = 191,
5818 SDL_SCANCODE_KP_E = 192,
5819 SDL_SCANCODE_KP_F = 193,
5820 SDL_SCANCODE_KP_XOR = 194,
5821 SDL_SCANCODE_KP_POWER = 195,
5822 SDL_SCANCODE_KP_PERCENT = 196,
5823 SDL_SCANCODE_KP_LESS = 197,
5824 SDL_SCANCODE_KP_GREATER = 198,
5825 SDL_SCANCODE_KP_AMPERSAND = 199,
5826 SDL_SCANCODE_KP_DBLAMPERSAND = 200,
5827 SDL_SCANCODE_KP_VERTICALBAR = 201,
5828 SDL_SCANCODE_KP_DBLVERTICALBAR = 202,
5829 SDL_SCANCODE_KP_COLON = 203,
5830 SDL_SCANCODE_KP_HASH = 204,
5831 SDL_SCANCODE_KP_SPACE = 205,
5832 SDL_SCANCODE_KP_AT = 206,
5833 SDL_SCANCODE_KP_EXCLAM = 207,
5834 SDL_SCANCODE_KP_MEMSTORE = 208,
5835 SDL_SCANCODE_KP_MEMRECALL = 209,
5836 SDL_SCANCODE_KP_MEMCLEAR = 210,
5837 SDL_SCANCODE_KP_MEMADD = 211,
5838 SDL_SCANCODE_KP_MEMSUBTRACT = 212,
5839 SDL_SCANCODE_KP_MEMMULTIPLY = 213,
5840 SDL_SCANCODE_KP_MEMDIVIDE = 214,
5841 SDL_SCANCODE_KP_PLUSMINUS = 215,
5842 SDL_SCANCODE_KP_CLEAR = 216,
5843 SDL_SCANCODE_KP_CLEARENTRY = 217,
5844 SDL_SCANCODE_KP_BINARY = 218,
5845 SDL_SCANCODE_KP_OCTAL = 219,
5846 SDL_SCANCODE_KP_DECIMAL = 220,
5847 SDL_SCANCODE_KP_HEXADECIMAL = 221,
5848
5849 SDL_SCANCODE_LCTRL = 224,
5850 SDL_SCANCODE_LSHIFT = 225,
5851 SDL_SCANCODE_LALT = 226,
5852 SDL_SCANCODE_LGUI = 227,
5853 SDL_SCANCODE_RCTRL = 228,
5854 SDL_SCANCODE_RSHIFT = 229,
5855 SDL_SCANCODE_RALT = 230,
5856 SDL_SCANCODE_RGUI = 231,
5857
5858 SDL_SCANCODE_MODE = 257,
5859
5860 /* These come from the USB consumer page (0x0C) */
5861 SDL_SCANCODE_AUDIONEXT = 258,
5862 SDL_SCANCODE_AUDIOPREV = 259,
5863 SDL_SCANCODE_AUDIOSTOP = 260,
5864 SDL_SCANCODE_AUDIOPLAY = 261,
5865 SDL_SCANCODE_AUDIOMUTE = 262,
5866 SDL_SCANCODE_MEDIASELECT = 263,
5867 SDL_SCANCODE_WWW = 264,
5868 SDL_SCANCODE_MAIL = 265,
5869 SDL_SCANCODE_CALCULATOR = 266,
5870 SDL_SCANCODE_COMPUTER = 267,
5871 SDL_SCANCODE_AC_SEARCH = 268,
5872 SDL_SCANCODE_AC_HOME = 269,
5873 SDL_SCANCODE_AC_BACK = 270,
5874 SDL_SCANCODE_AC_FORWARD = 271,
5875 SDL_SCANCODE_AC_STOP = 272,
5876 SDL_SCANCODE_AC_REFRESH = 273,
5877 SDL_SCANCODE_AC_BOOKMARKS = 274,
5878
5879 /* These come from other sources, and are mostly mac related */
5880 SDL_SCANCODE_BRIGHTNESSDOWN = 275,
5881 SDL_SCANCODE_BRIGHTNESSUP = 276,
5882 SDL_SCANCODE_DISPLAYSWITCH = 277,
5883 SDL_SCANCODE_KBDILLUMTOGGLE = 278,
5884 SDL_SCANCODE_KBDILLUMDOWN = 279,
5885 SDL_SCANCODE_KBDILLUMUP = 280,
5886 SDL_SCANCODE_EJECT = 281,
5887 SDL_SCANCODE_SLEEP = 282,
5888
5889 SDL_SCANCODE_APP1 = 283,
5890 SDL_SCANCODE_APP2 = 284,
5891
5892 /* These come from the USB consumer page (0x0C) */
5893 SDL_SCANCODE_AUDIOREWIND = 285,
5894 SDL_SCANCODE_AUDIOFASTFORWARD = 286,
5895
5896 /* This is not a key, simply marks the number of scancodes
5897 * so that you know how big to make your arrays. */
5898 SDL_NUM_SCANCODES = 512
5899 }
5900
5901 #endregion
5902
5903 #region SDL_keycode.h
5904
5905 public const int SDLK_SCANCODE_MASK = (1 << 30);
5906 public static SDL_Keycode SDL_SCANCODE_TO_KEYCODE(SDL_Scancode X)
5907 {
5908 return (SDL_Keycode)((int)X | SDLK_SCANCODE_MASK);
5909 }
5910
5911 public enum SDL_Keycode
5912 {
5913 SDLK_UNKNOWN = 0,
5914
5915 SDLK_RETURN = '\r',
5916 SDLK_ESCAPE = 27, // '\033'
5917 SDLK_BACKSPACE = '\b',
5918 SDLK_TAB = '\t',
5919 SDLK_SPACE = ' ',
5920 SDLK_EXCLAIM = '!',
5921 SDLK_QUOTEDBL = '"',
5922 SDLK_HASH = '#',
5923 SDLK_PERCENT = '%',
5924 SDLK_DOLLAR = '$',
5925 SDLK_AMPERSAND = '&',
5926 SDLK_QUOTE = '\'',
5927 SDLK_LEFTPAREN = '(',
5928 SDLK_RIGHTPAREN = ')',
5929 SDLK_ASTERISK = '*',
5930 SDLK_PLUS = '+',
5931 SDLK_COMMA = ',',
5932 SDLK_MINUS = '-',
5933 SDLK_PERIOD = '.',
5934 SDLK_SLASH = '/',
5935 SDLK_0 = '0',
5936 SDLK_1 = '1',
5937 SDLK_2 = '2',
5938 SDLK_3 = '3',
5939 SDLK_4 = '4',
5940 SDLK_5 = '5',
5941 SDLK_6 = '6',
5942 SDLK_7 = '7',
5943 SDLK_8 = '8',
5944 SDLK_9 = '9',
5945 SDLK_COLON = ':',
5946 SDLK_SEMICOLON = ';',
5947 SDLK_LESS = '<',
5948 SDLK_EQUALS = '=',
5949 SDLK_GREATER = '>',
5950 SDLK_QUESTION = '?',
5951 SDLK_AT = '@',
5952 /*
5953 Skip uppercase letters
5954 */
5955 SDLK_LEFTBRACKET = '[',
5956 SDLK_BACKSLASH = '\\',
5957 SDLK_RIGHTBRACKET = ']',
5958 SDLK_CARET = '^',
5959 SDLK_UNDERSCORE = '_',
5960 SDLK_BACKQUOTE = '`',
5961 SDLK_a = 'a',
5962 SDLK_b = 'b',
5963 SDLK_c = 'c',
5964 SDLK_d = 'd',
5965 SDLK_e = 'e',
5966 SDLK_f = 'f',
5967 SDLK_g = 'g',
5968 SDLK_h = 'h',
5969 SDLK_i = 'i',
5970 SDLK_j = 'j',
5971 SDLK_k = 'k',
5972 SDLK_l = 'l',
5973 SDLK_m = 'm',
5974 SDLK_n = 'n',
5975 SDLK_o = 'o',
5976 SDLK_p = 'p',
5977 SDLK_q = 'q',
5978 SDLK_r = 'r',
5979 SDLK_s = 's',
5980 SDLK_t = 't',
5981 SDLK_u = 'u',
5982 SDLK_v = 'v',
5983 SDLK_w = 'w',
5984 SDLK_x = 'x',
5985 SDLK_y = 'y',
5986 SDLK_z = 'z',
5987
5988 SDLK_CAPSLOCK = (int)SDL_Scancode.SDL_SCANCODE_CAPSLOCK | SDLK_SCANCODE_MASK,
5989
5990 SDLK_F1 = (int)SDL_Scancode.SDL_SCANCODE_F1 | SDLK_SCANCODE_MASK,
5991 SDLK_F2 = (int)SDL_Scancode.SDL_SCANCODE_F2 | SDLK_SCANCODE_MASK,
5992 SDLK_F3 = (int)SDL_Scancode.SDL_SCANCODE_F3 | SDLK_SCANCODE_MASK,
5993 SDLK_F4 = (int)SDL_Scancode.SDL_SCANCODE_F4 | SDLK_SCANCODE_MASK,
5994 SDLK_F5 = (int)SDL_Scancode.SDL_SCANCODE_F5 | SDLK_SCANCODE_MASK,
5995 SDLK_F6 = (int)SDL_Scancode.SDL_SCANCODE_F6 | SDLK_SCANCODE_MASK,
5996 SDLK_F7 = (int)SDL_Scancode.SDL_SCANCODE_F7 | SDLK_SCANCODE_MASK,
5997 SDLK_F8 = (int)SDL_Scancode.SDL_SCANCODE_F8 | SDLK_SCANCODE_MASK,
5998 SDLK_F9 = (int)SDL_Scancode.SDL_SCANCODE_F9 | SDLK_SCANCODE_MASK,
5999 SDLK_F10 = (int)SDL_Scancode.SDL_SCANCODE_F10 | SDLK_SCANCODE_MASK,
6000 SDLK_F11 = (int)SDL_Scancode.SDL_SCANCODE_F11 | SDLK_SCANCODE_MASK,
6001 SDLK_F12 = (int)SDL_Scancode.SDL_SCANCODE_F12 | SDLK_SCANCODE_MASK,
6002
6003 SDLK_PRINTSCREEN = (int)SDL_Scancode.SDL_SCANCODE_PRINTSCREEN | SDLK_SCANCODE_MASK,
6004 SDLK_SCROLLLOCK = (int)SDL_Scancode.SDL_SCANCODE_SCROLLLOCK | SDLK_SCANCODE_MASK,
6005 SDLK_PAUSE = (int)SDL_Scancode.SDL_SCANCODE_PAUSE | SDLK_SCANCODE_MASK,
6006 SDLK_INSERT = (int)SDL_Scancode.SDL_SCANCODE_INSERT | SDLK_SCANCODE_MASK,
6007 SDLK_HOME = (int)SDL_Scancode.SDL_SCANCODE_HOME | SDLK_SCANCODE_MASK,
6008 SDLK_PAGEUP = (int)SDL_Scancode.SDL_SCANCODE_PAGEUP | SDLK_SCANCODE_MASK,
6009 SDLK_DELETE = 127,
6010 SDLK_END = (int)SDL_Scancode.SDL_SCANCODE_END | SDLK_SCANCODE_MASK,
6011 SDLK_PAGEDOWN = (int)SDL_Scancode.SDL_SCANCODE_PAGEDOWN | SDLK_SCANCODE_MASK,
6012 SDLK_RIGHT = (int)SDL_Scancode.SDL_SCANCODE_RIGHT | SDLK_SCANCODE_MASK,
6013 SDLK_LEFT = (int)SDL_Scancode.SDL_SCANCODE_LEFT | SDLK_SCANCODE_MASK,
6014 SDLK_DOWN = (int)SDL_Scancode.SDL_SCANCODE_DOWN | SDLK_SCANCODE_MASK,
6015 SDLK_UP = (int)SDL_Scancode.SDL_SCANCODE_UP | SDLK_SCANCODE_MASK,
6016
6017 SDLK_NUMLOCKCLEAR = (int)SDL_Scancode.SDL_SCANCODE_NUMLOCKCLEAR | SDLK_SCANCODE_MASK,
6018 SDLK_KP_DIVIDE = (int)SDL_Scancode.SDL_SCANCODE_KP_DIVIDE | SDLK_SCANCODE_MASK,
6019 SDLK_KP_MULTIPLY = (int)SDL_Scancode.SDL_SCANCODE_KP_MULTIPLY | SDLK_SCANCODE_MASK,
6020 SDLK_KP_MINUS = (int)SDL_Scancode.SDL_SCANCODE_KP_MINUS | SDLK_SCANCODE_MASK,
6021 SDLK_KP_PLUS = (int)SDL_Scancode.SDL_SCANCODE_KP_PLUS | SDLK_SCANCODE_MASK,
6022 SDLK_KP_ENTER = (int)SDL_Scancode.SDL_SCANCODE_KP_ENTER | SDLK_SCANCODE_MASK,
6023 SDLK_KP_1 = (int)SDL_Scancode.SDL_SCANCODE_KP_1 | SDLK_SCANCODE_MASK,
6024 SDLK_KP_2 = (int)SDL_Scancode.SDL_SCANCODE_KP_2 | SDLK_SCANCODE_MASK,
6025 SDLK_KP_3 = (int)SDL_Scancode.SDL_SCANCODE_KP_3 | SDLK_SCANCODE_MASK,
6026 SDLK_KP_4 = (int)SDL_Scancode.SDL_SCANCODE_KP_4 | SDLK_SCANCODE_MASK,
6027 SDLK_KP_5 = (int)SDL_Scancode.SDL_SCANCODE_KP_5 | SDLK_SCANCODE_MASK,
6028 SDLK_KP_6 = (int)SDL_Scancode.SDL_SCANCODE_KP_6 | SDLK_SCANCODE_MASK,
6029 SDLK_KP_7 = (int)SDL_Scancode.SDL_SCANCODE_KP_7 | SDLK_SCANCODE_MASK,
6030 SDLK_KP_8 = (int)SDL_Scancode.SDL_SCANCODE_KP_8 | SDLK_SCANCODE_MASK,
6031 SDLK_KP_9 = (int)SDL_Scancode.SDL_SCANCODE_KP_9 | SDLK_SCANCODE_MASK,
6032 SDLK_KP_0 = (int)SDL_Scancode.SDL_SCANCODE_KP_0 | SDLK_SCANCODE_MASK,
6033 SDLK_KP_PERIOD = (int)SDL_Scancode.SDL_SCANCODE_KP_PERIOD | SDLK_SCANCODE_MASK,
6034
6035 SDLK_APPLICATION = (int)SDL_Scancode.SDL_SCANCODE_APPLICATION | SDLK_SCANCODE_MASK,
6036 SDLK_POWER = (int)SDL_Scancode.SDL_SCANCODE_POWER | SDLK_SCANCODE_MASK,
6037 SDLK_KP_EQUALS = (int)SDL_Scancode.SDL_SCANCODE_KP_EQUALS | SDLK_SCANCODE_MASK,
6038 SDLK_F13 = (int)SDL_Scancode.SDL_SCANCODE_F13 | SDLK_SCANCODE_MASK,
6039 SDLK_F14 = (int)SDL_Scancode.SDL_SCANCODE_F14 | SDLK_SCANCODE_MASK,
6040 SDLK_F15 = (int)SDL_Scancode.SDL_SCANCODE_F15 | SDLK_SCANCODE_MASK,
6041 SDLK_F16 = (int)SDL_Scancode.SDL_SCANCODE_F16 | SDLK_SCANCODE_MASK,
6042 SDLK_F17 = (int)SDL_Scancode.SDL_SCANCODE_F17 | SDLK_SCANCODE_MASK,
6043 SDLK_F18 = (int)SDL_Scancode.SDL_SCANCODE_F18 | SDLK_SCANCODE_MASK,
6044 SDLK_F19 = (int)SDL_Scancode.SDL_SCANCODE_F19 | SDLK_SCANCODE_MASK,
6045 SDLK_F20 = (int)SDL_Scancode.SDL_SCANCODE_F20 | SDLK_SCANCODE_MASK,
6046 SDLK_F21 = (int)SDL_Scancode.SDL_SCANCODE_F21 | SDLK_SCANCODE_MASK,
6047 SDLK_F22 = (int)SDL_Scancode.SDL_SCANCODE_F22 | SDLK_SCANCODE_MASK,
6048 SDLK_F23 = (int)SDL_Scancode.SDL_SCANCODE_F23 | SDLK_SCANCODE_MASK,
6049 SDLK_F24 = (int)SDL_Scancode.SDL_SCANCODE_F24 | SDLK_SCANCODE_MASK,
6050 SDLK_EXECUTE = (int)SDL_Scancode.SDL_SCANCODE_EXECUTE | SDLK_SCANCODE_MASK,
6051 SDLK_HELP = (int)SDL_Scancode.SDL_SCANCODE_HELP | SDLK_SCANCODE_MASK,
6052 SDLK_MENU = (int)SDL_Scancode.SDL_SCANCODE_MENU | SDLK_SCANCODE_MASK,
6053 SDLK_SELECT = (int)SDL_Scancode.SDL_SCANCODE_SELECT | SDLK_SCANCODE_MASK,
6054 SDLK_STOP = (int)SDL_Scancode.SDL_SCANCODE_STOP | SDLK_SCANCODE_MASK,
6055 SDLK_AGAIN = (int)SDL_Scancode.SDL_SCANCODE_AGAIN | SDLK_SCANCODE_MASK,
6056 SDLK_UNDO = (int)SDL_Scancode.SDL_SCANCODE_UNDO | SDLK_SCANCODE_MASK,
6057 SDLK_CUT = (int)SDL_Scancode.SDL_SCANCODE_CUT | SDLK_SCANCODE_MASK,
6058 SDLK_COPY = (int)SDL_Scancode.SDL_SCANCODE_COPY | SDLK_SCANCODE_MASK,
6059 SDLK_PASTE = (int)SDL_Scancode.SDL_SCANCODE_PASTE | SDLK_SCANCODE_MASK,
6060 SDLK_FIND = (int)SDL_Scancode.SDL_SCANCODE_FIND | SDLK_SCANCODE_MASK,
6061 SDLK_MUTE = (int)SDL_Scancode.SDL_SCANCODE_MUTE | SDLK_SCANCODE_MASK,
6062 SDLK_VOLUMEUP = (int)SDL_Scancode.SDL_SCANCODE_VOLUMEUP | SDLK_SCANCODE_MASK,
6063 SDLK_VOLUMEDOWN = (int)SDL_Scancode.SDL_SCANCODE_VOLUMEDOWN | SDLK_SCANCODE_MASK,
6064 SDLK_KP_COMMA = (int)SDL_Scancode.SDL_SCANCODE_KP_COMMA | SDLK_SCANCODE_MASK,
6065 SDLK_KP_EQUALSAS400 =
6066 (int)SDL_Scancode.SDL_SCANCODE_KP_EQUALSAS400 | SDLK_SCANCODE_MASK,
6067
6068 SDLK_ALTERASE = (int)SDL_Scancode.SDL_SCANCODE_ALTERASE | SDLK_SCANCODE_MASK,
6069 SDLK_SYSREQ = (int)SDL_Scancode.SDL_SCANCODE_SYSREQ | SDLK_SCANCODE_MASK,
6070 SDLK_CANCEL = (int)SDL_Scancode.SDL_SCANCODE_CANCEL | SDLK_SCANCODE_MASK,
6071 SDLK_CLEAR = (int)SDL_Scancode.SDL_SCANCODE_CLEAR | SDLK_SCANCODE_MASK,
6072 SDLK_PRIOR = (int)SDL_Scancode.SDL_SCANCODE_PRIOR | SDLK_SCANCODE_MASK,
6073 SDLK_RETURN2 = (int)SDL_Scancode.SDL_SCANCODE_RETURN2 | SDLK_SCANCODE_MASK,
6074 SDLK_SEPARATOR = (int)SDL_Scancode.SDL_SCANCODE_SEPARATOR | SDLK_SCANCODE_MASK,
6075 SDLK_OUT = (int)SDL_Scancode.SDL_SCANCODE_OUT | SDLK_SCANCODE_MASK,
6076 SDLK_OPER = (int)SDL_Scancode.SDL_SCANCODE_OPER | SDLK_SCANCODE_MASK,
6077 SDLK_CLEARAGAIN = (int)SDL_Scancode.SDL_SCANCODE_CLEARAGAIN | SDLK_SCANCODE_MASK,
6078 SDLK_CRSEL = (int)SDL_Scancode.SDL_SCANCODE_CRSEL | SDLK_SCANCODE_MASK,
6079 SDLK_EXSEL = (int)SDL_Scancode.SDL_SCANCODE_EXSEL | SDLK_SCANCODE_MASK,
6080
6081 SDLK_KP_00 = (int)SDL_Scancode.SDL_SCANCODE_KP_00 | SDLK_SCANCODE_MASK,
6082 SDLK_KP_000 = (int)SDL_Scancode.SDL_SCANCODE_KP_000 | SDLK_SCANCODE_MASK,
6083 SDLK_THOUSANDSSEPARATOR =
6084 (int)SDL_Scancode.SDL_SCANCODE_THOUSANDSSEPARATOR | SDLK_SCANCODE_MASK,
6085 SDLK_DECIMALSEPARATOR =
6086 (int)SDL_Scancode.SDL_SCANCODE_DECIMALSEPARATOR | SDLK_SCANCODE_MASK,
6087 SDLK_CURRENCYUNIT = (int)SDL_Scancode.SDL_SCANCODE_CURRENCYUNIT | SDLK_SCANCODE_MASK,
6088 SDLK_CURRENCYSUBUNIT =
6089 (int)SDL_Scancode.SDL_SCANCODE_CURRENCYSUBUNIT | SDLK_SCANCODE_MASK,
6090 SDLK_KP_LEFTPAREN = (int)SDL_Scancode.SDL_SCANCODE_KP_LEFTPAREN | SDLK_SCANCODE_MASK,
6091 SDLK_KP_RIGHTPAREN = (int)SDL_Scancode.SDL_SCANCODE_KP_RIGHTPAREN | SDLK_SCANCODE_MASK,
6092 SDLK_KP_LEFTBRACE = (int)SDL_Scancode.SDL_SCANCODE_KP_LEFTBRACE | SDLK_SCANCODE_MASK,
6093 SDLK_KP_RIGHTBRACE = (int)SDL_Scancode.SDL_SCANCODE_KP_RIGHTBRACE | SDLK_SCANCODE_MASK,
6094 SDLK_KP_TAB = (int)SDL_Scancode.SDL_SCANCODE_KP_TAB | SDLK_SCANCODE_MASK,
6095 SDLK_KP_BACKSPACE = (int)SDL_Scancode.SDL_SCANCODE_KP_BACKSPACE | SDLK_SCANCODE_MASK,
6096 SDLK_KP_A = (int)SDL_Scancode.SDL_SCANCODE_KP_A | SDLK_SCANCODE_MASK,
6097 SDLK_KP_B = (int)SDL_Scancode.SDL_SCANCODE_KP_B | SDLK_SCANCODE_MASK,
6098 SDLK_KP_C = (int)SDL_Scancode.SDL_SCANCODE_KP_C | SDLK_SCANCODE_MASK,
6099 SDLK_KP_D = (int)SDL_Scancode.SDL_SCANCODE_KP_D | SDLK_SCANCODE_MASK,
6100 SDLK_KP_E = (int)SDL_Scancode.SDL_SCANCODE_KP_E | SDLK_SCANCODE_MASK,
6101 SDLK_KP_F = (int)SDL_Scancode.SDL_SCANCODE_KP_F | SDLK_SCANCODE_MASK,
6102 SDLK_KP_XOR = (int)SDL_Scancode.SDL_SCANCODE_KP_XOR | SDLK_SCANCODE_MASK,
6103 SDLK_KP_POWER = (int)SDL_Scancode.SDL_SCANCODE_KP_POWER | SDLK_SCANCODE_MASK,
6104 SDLK_KP_PERCENT = (int)SDL_Scancode.SDL_SCANCODE_KP_PERCENT | SDLK_SCANCODE_MASK,
6105 SDLK_KP_LESS = (int)SDL_Scancode.SDL_SCANCODE_KP_LESS | SDLK_SCANCODE_MASK,
6106 SDLK_KP_GREATER = (int)SDL_Scancode.SDL_SCANCODE_KP_GREATER | SDLK_SCANCODE_MASK,
6107 SDLK_KP_AMPERSAND = (int)SDL_Scancode.SDL_SCANCODE_KP_AMPERSAND | SDLK_SCANCODE_MASK,
6108 SDLK_KP_DBLAMPERSAND =
6109 (int)SDL_Scancode.SDL_SCANCODE_KP_DBLAMPERSAND | SDLK_SCANCODE_MASK,
6110 SDLK_KP_VERTICALBAR =
6111 (int)SDL_Scancode.SDL_SCANCODE_KP_VERTICALBAR | SDLK_SCANCODE_MASK,
6112 SDLK_KP_DBLVERTICALBAR =
6113 (int)SDL_Scancode.SDL_SCANCODE_KP_DBLVERTICALBAR | SDLK_SCANCODE_MASK,
6114 SDLK_KP_COLON = (int)SDL_Scancode.SDL_SCANCODE_KP_COLON | SDLK_SCANCODE_MASK,
6115 SDLK_KP_HASH = (int)SDL_Scancode.SDL_SCANCODE_KP_HASH | SDLK_SCANCODE_MASK,
6116 SDLK_KP_SPACE = (int)SDL_Scancode.SDL_SCANCODE_KP_SPACE | SDLK_SCANCODE_MASK,
6117 SDLK_KP_AT = (int)SDL_Scancode.SDL_SCANCODE_KP_AT | SDLK_SCANCODE_MASK,
6118 SDLK_KP_EXCLAM = (int)SDL_Scancode.SDL_SCANCODE_KP_EXCLAM | SDLK_SCANCODE_MASK,
6119 SDLK_KP_MEMSTORE = (int)SDL_Scancode.SDL_SCANCODE_KP_MEMSTORE | SDLK_SCANCODE_MASK,
6120 SDLK_KP_MEMRECALL = (int)SDL_Scancode.SDL_SCANCODE_KP_MEMRECALL | SDLK_SCANCODE_MASK,
6121 SDLK_KP_MEMCLEAR = (int)SDL_Scancode.SDL_SCANCODE_KP_MEMCLEAR | SDLK_SCANCODE_MASK,
6122 SDLK_KP_MEMADD = (int)SDL_Scancode.SDL_SCANCODE_KP_MEMADD | SDLK_SCANCODE_MASK,
6123 SDLK_KP_MEMSUBTRACT =
6124 (int)SDL_Scancode.SDL_SCANCODE_KP_MEMSUBTRACT | SDLK_SCANCODE_MASK,
6125 SDLK_KP_MEMMULTIPLY =
6126 (int)SDL_Scancode.SDL_SCANCODE_KP_MEMMULTIPLY | SDLK_SCANCODE_MASK,
6127 SDLK_KP_MEMDIVIDE = (int)SDL_Scancode.SDL_SCANCODE_KP_MEMDIVIDE | SDLK_SCANCODE_MASK,
6128 SDLK_KP_PLUSMINUS = (int)SDL_Scancode.SDL_SCANCODE_KP_PLUSMINUS | SDLK_SCANCODE_MASK,
6129 SDLK_KP_CLEAR = (int)SDL_Scancode.SDL_SCANCODE_KP_CLEAR | SDLK_SCANCODE_MASK,
6130 SDLK_KP_CLEARENTRY = (int)SDL_Scancode.SDL_SCANCODE_KP_CLEARENTRY | SDLK_SCANCODE_MASK,
6131 SDLK_KP_BINARY = (int)SDL_Scancode.SDL_SCANCODE_KP_BINARY | SDLK_SCANCODE_MASK,
6132 SDLK_KP_OCTAL = (int)SDL_Scancode.SDL_SCANCODE_KP_OCTAL | SDLK_SCANCODE_MASK,
6133 SDLK_KP_DECIMAL = (int)SDL_Scancode.SDL_SCANCODE_KP_DECIMAL | SDLK_SCANCODE_MASK,
6134 SDLK_KP_HEXADECIMAL =
6135 (int)SDL_Scancode.SDL_SCANCODE_KP_HEXADECIMAL | SDLK_SCANCODE_MASK,
6136
6137 SDLK_LCTRL = (int)SDL_Scancode.SDL_SCANCODE_LCTRL | SDLK_SCANCODE_MASK,
6138 SDLK_LSHIFT = (int)SDL_Scancode.SDL_SCANCODE_LSHIFT | SDLK_SCANCODE_MASK,
6139 SDLK_LALT = (int)SDL_Scancode.SDL_SCANCODE_LALT | SDLK_SCANCODE_MASK,
6140 SDLK_LGUI = (int)SDL_Scancode.SDL_SCANCODE_LGUI | SDLK_SCANCODE_MASK,
6141 SDLK_RCTRL = (int)SDL_Scancode.SDL_SCANCODE_RCTRL | SDLK_SCANCODE_MASK,
6142 SDLK_RSHIFT = (int)SDL_Scancode.SDL_SCANCODE_RSHIFT | SDLK_SCANCODE_MASK,
6143 SDLK_RALT = (int)SDL_Scancode.SDL_SCANCODE_RALT | SDLK_SCANCODE_MASK,
6144 SDLK_RGUI = (int)SDL_Scancode.SDL_SCANCODE_RGUI | SDLK_SCANCODE_MASK,
6145
6146 SDLK_MODE = (int)SDL_Scancode.SDL_SCANCODE_MODE | SDLK_SCANCODE_MASK,
6147
6148 SDLK_AUDIONEXT = (int)SDL_Scancode.SDL_SCANCODE_AUDIONEXT | SDLK_SCANCODE_MASK,
6149 SDLK_AUDIOPREV = (int)SDL_Scancode.SDL_SCANCODE_AUDIOPREV | SDLK_SCANCODE_MASK,
6150 SDLK_AUDIOSTOP = (int)SDL_Scancode.SDL_SCANCODE_AUDIOSTOP | SDLK_SCANCODE_MASK,
6151 SDLK_AUDIOPLAY = (int)SDL_Scancode.SDL_SCANCODE_AUDIOPLAY | SDLK_SCANCODE_MASK,
6152 SDLK_AUDIOMUTE = (int)SDL_Scancode.SDL_SCANCODE_AUDIOMUTE | SDLK_SCANCODE_MASK,
6153 SDLK_MEDIASELECT = (int)SDL_Scancode.SDL_SCANCODE_MEDIASELECT | SDLK_SCANCODE_MASK,
6154 SDLK_WWW = (int)SDL_Scancode.SDL_SCANCODE_WWW | SDLK_SCANCODE_MASK,
6155 SDLK_MAIL = (int)SDL_Scancode.SDL_SCANCODE_MAIL | SDLK_SCANCODE_MASK,
6156 SDLK_CALCULATOR = (int)SDL_Scancode.SDL_SCANCODE_CALCULATOR | SDLK_SCANCODE_MASK,
6157 SDLK_COMPUTER = (int)SDL_Scancode.SDL_SCANCODE_COMPUTER | SDLK_SCANCODE_MASK,
6158 SDLK_AC_SEARCH = (int)SDL_Scancode.SDL_SCANCODE_AC_SEARCH | SDLK_SCANCODE_MASK,
6159 SDLK_AC_HOME = (int)SDL_Scancode.SDL_SCANCODE_AC_HOME | SDLK_SCANCODE_MASK,
6160 SDLK_AC_BACK = (int)SDL_Scancode.SDL_SCANCODE_AC_BACK | SDLK_SCANCODE_MASK,
6161 SDLK_AC_FORWARD = (int)SDL_Scancode.SDL_SCANCODE_AC_FORWARD | SDLK_SCANCODE_MASK,
6162 SDLK_AC_STOP = (int)SDL_Scancode.SDL_SCANCODE_AC_STOP | SDLK_SCANCODE_MASK,
6163 SDLK_AC_REFRESH = (int)SDL_Scancode.SDL_SCANCODE_AC_REFRESH | SDLK_SCANCODE_MASK,
6164 SDLK_AC_BOOKMARKS = (int)SDL_Scancode.SDL_SCANCODE_AC_BOOKMARKS | SDLK_SCANCODE_MASK,
6165
6166 SDLK_BRIGHTNESSDOWN =
6167 (int)SDL_Scancode.SDL_SCANCODE_BRIGHTNESSDOWN | SDLK_SCANCODE_MASK,
6168 SDLK_BRIGHTNESSUP = (int)SDL_Scancode.SDL_SCANCODE_BRIGHTNESSUP | SDLK_SCANCODE_MASK,
6169 SDLK_DISPLAYSWITCH = (int)SDL_Scancode.SDL_SCANCODE_DISPLAYSWITCH | SDLK_SCANCODE_MASK,
6170 SDLK_KBDILLUMTOGGLE =
6171 (int)SDL_Scancode.SDL_SCANCODE_KBDILLUMTOGGLE | SDLK_SCANCODE_MASK,
6172 SDLK_KBDILLUMDOWN = (int)SDL_Scancode.SDL_SCANCODE_KBDILLUMDOWN | SDLK_SCANCODE_MASK,
6173 SDLK_KBDILLUMUP = (int)SDL_Scancode.SDL_SCANCODE_KBDILLUMUP | SDLK_SCANCODE_MASK,
6174 SDLK_EJECT = (int)SDL_Scancode.SDL_SCANCODE_EJECT | SDLK_SCANCODE_MASK,
6175 SDLK_SLEEP = (int)SDL_Scancode.SDL_SCANCODE_SLEEP | SDLK_SCANCODE_MASK,
6176 SDLK_APP1 = (int)SDL_Scancode.SDL_SCANCODE_APP1 | SDLK_SCANCODE_MASK,
6177 SDLK_APP2 = (int)SDL_Scancode.SDL_SCANCODE_APP2 | SDLK_SCANCODE_MASK,
6178
6179 SDLK_AUDIOREWIND = (int)SDL_Scancode.SDL_SCANCODE_AUDIOREWIND | SDLK_SCANCODE_MASK,
6180 SDLK_AUDIOFASTFORWARD = (int)SDL_Scancode.SDL_SCANCODE_AUDIOFASTFORWARD | SDLK_SCANCODE_MASK
6181 }
6182
6183 /* Key modifiers (bitfield) */
6184 [Flags]
6185 public enum SDL_Keymod : ushort
6186 {
6187 KMOD_NONE = 0x0000,
6188 KMOD_LSHIFT = 0x0001,
6189 KMOD_RSHIFT = 0x0002,
6190 KMOD_LCTRL = 0x0040,
6191 KMOD_RCTRL = 0x0080,
6192 KMOD_LALT = 0x0100,
6193 KMOD_RALT = 0x0200,
6194 KMOD_LGUI = 0x0400,
6195 KMOD_RGUI = 0x0800,
6196 KMOD_NUM = 0x1000,
6197 KMOD_CAPS = 0x2000,
6198 KMOD_MODE = 0x4000,
6199 KMOD_SCROLL = 0x8000,
6200
6201 /* These are defines in the SDL headers */
6202 KMOD_CTRL = (KMOD_LCTRL | KMOD_RCTRL),
6203 KMOD_SHIFT = (KMOD_LSHIFT | KMOD_RSHIFT),
6204 KMOD_ALT = (KMOD_LALT | KMOD_RALT),
6205 KMOD_GUI = (KMOD_LGUI | KMOD_RGUI),
6206
6207 KMOD_RESERVED = KMOD_SCROLL
6208 }
6209
6210 #endregion
6211
6212 #region SDL_keyboard.h
6213
6214 [StructLayout(LayoutKind.Sequential)]
6215 public struct SDL_Keysym
6216 {
6217 public SDL_Scancode scancode;
6218 public SDL_Keycode sym;
6219 public SDL_Keymod mod; /* UInt16 */
6220 public UInt32 unicode; /* Deprecated */
6221 }
6222
6223 /* Get the window which has kbd focus */
6224 /* Return type is an SDL_Window pointer */
6225 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6226 public static extern IntPtr SDL_GetKeyboardFocus();
6227
6228 /* Get a snapshot of the keyboard state. */
6229 /* Return value is a pointer to a UInt8 array */
6230 /* Numkeys returns the size of the array if non-null */
6231 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6232 public static extern IntPtr SDL_GetKeyboardState(out int numkeys);
6233
6234 /* Get the current key modifier state for the keyboard. */
6235 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6236 public static extern SDL_Keymod SDL_GetModState();
6237
6238 /* Set the current key modifier state */
6239 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6240 public static extern void SDL_SetModState(SDL_Keymod modstate);
6241
6242 /* Get the key code corresponding to the given scancode
6243 * with the current keyboard layout.
6244 */
6245 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6246 public static extern SDL_Keycode SDL_GetKeyFromScancode(SDL_Scancode scancode);
6247
6248 /* Get the scancode for the given keycode */
6249 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6250 public static extern SDL_Scancode SDL_GetScancodeFromKey(SDL_Keycode key);
6251
6252 /* Wrapper for SDL_GetScancodeName */
6253 [DllImport(nativeLibName, EntryPoint = "SDL_GetScancodeName", CallingConvention = CallingConvention.Cdecl)]
6254 private static extern IntPtr INTERNAL_SDL_GetScancodeName(SDL_Scancode scancode);
6255 public static string SDL_GetScancodeName(SDL_Scancode scancode)
6256 {
6257 return UTF8_ToManaged(
6258 INTERNAL_SDL_GetScancodeName(scancode)
6259 );
6260 }
6261
6262 /* Get a scancode from a human-readable name */
6263 [DllImport(nativeLibName, EntryPoint = "SDL_GetScancodeFromName", CallingConvention = CallingConvention.Cdecl)]
6264 private static extern unsafe SDL_Scancode INTERNAL_SDL_GetScancodeFromName(
6265 byte* name
6266 );
6267 public static unsafe SDL_Scancode SDL_GetScancodeFromName(string name)
6268 {
6269 int utf8NameBufSize = Utf8Size(name);
6270 byte* utf8Name = stackalloc byte[utf8NameBufSize];
6271 return INTERNAL_SDL_GetScancodeFromName(
6272 Utf8Encode(name, utf8Name, utf8NameBufSize)
6273 );
6274 }
6275
6276 /* Wrapper for SDL_GetKeyName */
6277 [DllImport(nativeLibName, EntryPoint = "SDL_GetKeyName", CallingConvention = CallingConvention.Cdecl)]
6278 private static extern IntPtr INTERNAL_SDL_GetKeyName(SDL_Keycode key);
6279 public static string SDL_GetKeyName(SDL_Keycode key)
6280 {
6281 return UTF8_ToManaged(INTERNAL_SDL_GetKeyName(key));
6282 }
6283
6284 /* Get a key code from a human-readable name */
6285 [DllImport(nativeLibName, EntryPoint = "SDL_GetKeyFromName", CallingConvention = CallingConvention.Cdecl)]
6286 private static extern unsafe SDL_Keycode INTERNAL_SDL_GetKeyFromName(
6287 byte* name
6288 );
6289 public static unsafe SDL_Keycode SDL_GetKeyFromName(string name)
6290 {
6291 int utf8NameBufSize = Utf8Size(name);
6292 byte* utf8Name = stackalloc byte[utf8NameBufSize];
6293 return INTERNAL_SDL_GetKeyFromName(
6294 Utf8Encode(name, utf8Name, utf8NameBufSize)
6295 );
6296 }
6297
6298 /* Start accepting Unicode text input events, show keyboard */
6299 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6300 public static extern void SDL_StartTextInput();
6301
6302 /* Check if unicode input events are enabled */
6303 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6304 public static extern SDL_bool SDL_IsTextInputActive();
6305
6306 /* Stop receiving any text input events, hide onscreen kbd */
6307 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6308 public static extern void SDL_StopTextInput();
6309
6310 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6311 public static extern void SDL_ClearComposition();
6312
6313 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6314 public static extern SDL_bool SDL_IsTextInputShown();
6315
6316 /* Set the rectangle used for text input, hint for IME */
6317 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6318 public static extern void SDL_SetTextInputRect(ref SDL_Rect rect);
6319
6320 /* Does the platform support an on-screen keyboard? */
6321 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6322 public static extern SDL_bool SDL_HasScreenKeyboardSupport();
6323
6324 /* Is the on-screen keyboard shown for a given window? */
6325 /* window is an SDL_Window pointer */
6326 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6327 public static extern SDL_bool SDL_IsScreenKeyboardShown(IntPtr window);
6328
6329 #endregion
6330
6331 #region SDL_mouse.c
6332
6333 /* Note: SDL_Cursor is a typedef normally. We'll treat it as
6334 * an IntPtr, because C# doesn't do typedefs. Yay!
6335 */
6336
6337 /* System cursor types */
6338 public enum SDL_SystemCursor
6339 {
6340 SDL_SYSTEM_CURSOR_ARROW, // Arrow
6341 SDL_SYSTEM_CURSOR_IBEAM, // I-beam
6342 SDL_SYSTEM_CURSOR_WAIT, // Wait
6343 SDL_SYSTEM_CURSOR_CROSSHAIR, // Crosshair
6344 SDL_SYSTEM_CURSOR_WAITARROW, // Small wait cursor (or Wait if not available)
6345 SDL_SYSTEM_CURSOR_SIZENWSE, // Double arrow pointing northwest and southeast
6346 SDL_SYSTEM_CURSOR_SIZENESW, // Double arrow pointing northeast and southwest
6347 SDL_SYSTEM_CURSOR_SIZEWE, // Double arrow pointing west and east
6348 SDL_SYSTEM_CURSOR_SIZENS, // Double arrow pointing north and south
6349 SDL_SYSTEM_CURSOR_SIZEALL, // Four pointed arrow pointing north, south, east, and west
6350 SDL_SYSTEM_CURSOR_NO, // Slashed circle or crossbones
6351 SDL_SYSTEM_CURSOR_HAND, // Hand
6352 SDL_NUM_SYSTEM_CURSORS
6353 }
6354
6355 /* Get the window which currently has mouse focus */
6356 /* Return value is an SDL_Window pointer */
6357 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6358 public static extern IntPtr SDL_GetMouseFocus();
6359
6360 /* Get the current state of the mouse */
6361 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6362 public static extern UInt32 SDL_GetMouseState(out int x, out int y);
6363
6364 /* Get the current state of the mouse */
6365 /* This overload allows for passing NULL to x */
6366 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6367 public static extern UInt32 SDL_GetMouseState(IntPtr x, out int y);
6368
6369 /* Get the current state of the mouse */
6370 /* This overload allows for passing NULL to y */
6371 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6372 public static extern UInt32 SDL_GetMouseState(out int x, IntPtr y);
6373
6374 /* Get the current state of the mouse */
6375 /* This overload allows for passing NULL to both x and y */
6376 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6377 public static extern UInt32 SDL_GetMouseState(IntPtr x, IntPtr y);
6378
6379 /* Get the current state of the mouse, in relation to the desktop.
6380 * Only available in 2.0.4 or higher.
6381 */
6382 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6383 public static extern UInt32 SDL_GetGlobalMouseState(out int x, out int y);
6384
6385 /* Get the current state of the mouse, in relation to the desktop.
6386 * Only available in 2.0.4 or higher.
6387 * This overload allows for passing NULL to x.
6388 */
6389 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6390 public static extern UInt32 SDL_GetGlobalMouseState(IntPtr x, out int y);
6391
6392 /* Get the current state of the mouse, in relation to the desktop.
6393 * Only available in 2.0.4 or higher.
6394 * This overload allows for passing NULL to y.
6395 */
6396 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6397 public static extern UInt32 SDL_GetGlobalMouseState(out int x, IntPtr y);
6398
6399 /* Get the current state of the mouse, in relation to the desktop.
6400 * Only available in 2.0.4 or higher.
6401 * This overload allows for passing NULL to both x and y
6402 */
6403 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6404 public static extern UInt32 SDL_GetGlobalMouseState(IntPtr x, IntPtr y);
6405
6406 /* Get the mouse state with relative coords*/
6407 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6408 public static extern UInt32 SDL_GetRelativeMouseState(out int x, out int y);
6409
6410 /* Set the mouse cursor's position (within a window) */
6411 /* window is an SDL_Window pointer */
6412 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6413 public static extern void SDL_WarpMouseInWindow(IntPtr window, int x, int y);
6414
6415 /* Set the mouse cursor's position in global screen space.
6416 * Only available in 2.0.4 or higher.
6417 */
6418 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6419 public static extern int SDL_WarpMouseGlobal(int x, int y);
6420
6421 /* Enable/Disable relative mouse mode (grabs mouse, rel coords) */
6422 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6423 public static extern int SDL_SetRelativeMouseMode(SDL_bool enabled);
6424
6425 /* Capture the mouse, to track input outside an SDL window.
6426 * Only available in 2.0.4 or higher.
6427 */
6428 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6429 public static extern int SDL_CaptureMouse(SDL_bool enabled);
6430
6431 /* Query if the relative mouse mode is enabled */
6432 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6433 public static extern SDL_bool SDL_GetRelativeMouseMode();
6434
6435 /* Create a cursor from bitmap data (amd mask) in MSB format.
6436 * data and mask are byte arrays, and w must be a multiple of 8.
6437 * return value is an SDL_Cursor pointer.
6438 */
6439 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6440 public static extern IntPtr SDL_CreateCursor(
6441 IntPtr data,
6442 IntPtr mask,
6443 int w,
6444 int h,
6445 int hot_x,
6446 int hot_y
6447 );
6448
6449 /* Create a cursor from an SDL_Surface.
6450 * IntPtr refers to an SDL_Cursor*, surface to an SDL_Surface*
6451 */
6452 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6453 public static extern IntPtr SDL_CreateColorCursor(
6454 IntPtr surface,
6455 int hot_x,
6456 int hot_y
6457 );
6458
6459 /* Create a cursor from a system cursor id.
6460 * return value is an SDL_Cursor pointer
6461 */
6462 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6463 public static extern IntPtr SDL_CreateSystemCursor(SDL_SystemCursor id);
6464
6465 /* Set the active cursor.
6466 * cursor is an SDL_Cursor pointer
6467 */
6468 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6469 public static extern void SDL_SetCursor(IntPtr cursor);
6470
6471 /* Return the active cursor
6472 * return value is an SDL_Cursor pointer
6473 */
6474 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6475 public static extern IntPtr SDL_GetCursor();
6476
6477 /* Frees a cursor created with one of the CreateCursor functions.
6478 * cursor in an SDL_Cursor pointer
6479 */
6480 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6481 public static extern void SDL_FreeCursor(IntPtr cursor);
6482
6483 /* Toggle whether or not the cursor is shown */
6484 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6485 public static extern int SDL_ShowCursor(int toggle);
6486
6487 public static uint SDL_BUTTON(uint X)
6488 {
6489 // If only there were a better way of doing this in C#
6490 return (uint) (1 << ((int) X - 1));
6491 }
6492
6493 public const uint SDL_BUTTON_LEFT = 1;
6494 public const uint SDL_BUTTON_MIDDLE = 2;
6495 public const uint SDL_BUTTON_RIGHT = 3;
6496 public const uint SDL_BUTTON_X1 = 4;
6497 public const uint SDL_BUTTON_X2 = 5;
6498 public static readonly UInt32 SDL_BUTTON_LMASK = SDL_BUTTON(SDL_BUTTON_LEFT);
6499 public static readonly UInt32 SDL_BUTTON_MMASK = SDL_BUTTON(SDL_BUTTON_MIDDLE);
6500 public static readonly UInt32 SDL_BUTTON_RMASK = SDL_BUTTON(SDL_BUTTON_RIGHT);
6501 public static readonly UInt32 SDL_BUTTON_X1MASK = SDL_BUTTON(SDL_BUTTON_X1);
6502 public static readonly UInt32 SDL_BUTTON_X2MASK = SDL_BUTTON(SDL_BUTTON_X2);
6503
6504 #endregion
6505
6506 #region SDL_touch.h
6507
6508 public const uint SDL_TOUCH_MOUSEID = uint.MaxValue;
6509
6510 public struct SDL_Finger
6511 {
6512 public long id; // SDL_FingerID
6513 public float x;
6514 public float y;
6515 public float pressure;
6516 }
6517
6518 /* Only available in 2.0.10 or higher. */
6519 public enum SDL_TouchDeviceType
6520 {
6521 SDL_TOUCH_DEVICE_INVALID = -1,
6522 SDL_TOUCH_DEVICE_DIRECT, /* touch screen with window-relative coordinates */
6523 SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, /* trackpad with absolute device coordinates */
6524 SDL_TOUCH_DEVICE_INDIRECT_RELATIVE /* trackpad with screen cursor-relative coordinates */
6525 }
6526
6527 /**
6528 * \brief Get the number of registered touch devices.
6529 */
6530 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6531 public static extern int SDL_GetNumTouchDevices();
6532
6533 /**
6534 * \brief Get the touch ID with the given index, or 0 if the index is invalid.
6535 */
6536 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6537 public static extern long SDL_GetTouchDevice(int index);
6538
6539 /**
6540 * \brief Get the number of active fingers for a given touch device.
6541 */
6542 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6543 public static extern int SDL_GetNumTouchFingers(long touchID);
6544
6545 /**
6546 * \brief Get the finger object of the given touch, with the given index.
6547 * Returns pointer to SDL_Finger.
6548 */
6549 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6550 public static extern IntPtr SDL_GetTouchFinger(long touchID, int index);
6551
6552 /* Only available in 2.0.10 or higher. */
6553 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6554 public static extern SDL_TouchDeviceType SDL_GetTouchDeviceType(Int64 touchID);
6555
6556 /* Only available in 2.0.22 or higher. */
6557 [DllImport(nativeLibName, EntryPoint = "SDL_GetTouchName", CallingConvention = CallingConvention.Cdecl)]
6558 private static extern IntPtr INTERNAL_SDL_GetTouchName(int index);
6559
6560 /* Only available in 2.0.22 or higher. */
6561 public static string SDL_GetTouchName(int index)
6562 {
6563 return UTF8_ToManaged(INTERNAL_SDL_GetTouchName(index));
6564 }
6565
6566 #endregion
6567
6568 #region SDL_joystick.h
6569
6570 public const byte SDL_HAT_CENTERED = 0x00;
6571 public const byte SDL_HAT_UP = 0x01;
6572 public const byte SDL_HAT_RIGHT = 0x02;
6573 public const byte SDL_HAT_DOWN = 0x04;
6574 public const byte SDL_HAT_LEFT = 0x08;
6575 public const byte SDL_HAT_RIGHTUP = SDL_HAT_RIGHT | SDL_HAT_UP;
6576 public const byte SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT | SDL_HAT_DOWN;
6577 public const byte SDL_HAT_LEFTUP = SDL_HAT_LEFT | SDL_HAT_UP;
6578 public const byte SDL_HAT_LEFTDOWN = SDL_HAT_LEFT | SDL_HAT_DOWN;
6579
6580 public enum SDL_JoystickPowerLevel
6581 {
6582 SDL_JOYSTICK_POWER_UNKNOWN = -1,
6583 SDL_JOYSTICK_POWER_EMPTY,
6584 SDL_JOYSTICK_POWER_LOW,
6585 SDL_JOYSTICK_POWER_MEDIUM,
6586 SDL_JOYSTICK_POWER_FULL,
6587 SDL_JOYSTICK_POWER_WIRED,
6588 SDL_JOYSTICK_POWER_MAX
6589 }
6590
6591 public enum SDL_JoystickType
6592 {
6593 SDL_JOYSTICK_TYPE_UNKNOWN,
6594 SDL_JOYSTICK_TYPE_GAMECONTROLLER,
6595 SDL_JOYSTICK_TYPE_WHEEL,
6596 SDL_JOYSTICK_TYPE_ARCADE_STICK,
6597 SDL_JOYSTICK_TYPE_FLIGHT_STICK,
6598 SDL_JOYSTICK_TYPE_DANCE_PAD,
6599 SDL_JOYSTICK_TYPE_GUITAR,
6600 SDL_JOYSTICK_TYPE_DRUM_KIT,
6601 SDL_JOYSTICK_TYPE_ARCADE_PAD
6602 }
6603
6604 /* Only available in 2.0.14 or higher. */
6605 public const float SDL_IPHONE_MAX_GFORCE = 5.0f;
6606
6607 /* joystick refers to an SDL_Joystick*.
6608 * Only available in 2.0.9 or higher.
6609 */
6610 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6611 public static extern int SDL_JoystickRumble(
6612 IntPtr joystick,
6613 UInt16 low_frequency_rumble,
6614 UInt16 high_frequency_rumble,
6615 UInt32 duration_ms
6616 );
6617
6618 /* joystick refers to an SDL_Joystick*.
6619 * Only available in 2.0.14 or higher.
6620 */
6621 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6622 public static extern int SDL_JoystickRumbleTriggers(
6623 IntPtr joystick,
6624 UInt16 left_rumble,
6625 UInt16 right_rumble,
6626 UInt32 duration_ms
6627 );
6628
6629 /* joystick refers to an SDL_Joystick* */
6630 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6631 public static extern void SDL_JoystickClose(IntPtr joystick);
6632
6633 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6634 public static extern int SDL_JoystickEventState(int state);
6635
6636 /* joystick refers to an SDL_Joystick* */
6637 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6638 public static extern short SDL_JoystickGetAxis(
6639 IntPtr joystick,
6640 int axis
6641 );
6642
6643 /* joystick refers to an SDL_Joystick*.
6644 * Only available in 2.0.6 or higher.
6645 */
6646 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6647 public static extern SDL_bool SDL_JoystickGetAxisInitialState(
6648 IntPtr joystick,
6649 int axis,
6650 out short state
6651 );
6652
6653 /* joystick refers to an SDL_Joystick* */
6654 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6655 public static extern int SDL_JoystickGetBall(
6656 IntPtr joystick,
6657 int ball,
6658 out int dx,
6659 out int dy
6660 );
6661
6662 /* joystick refers to an SDL_Joystick* */
6663 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6664 public static extern byte SDL_JoystickGetButton(
6665 IntPtr joystick,
6666 int button
6667 );
6668
6669 /* joystick refers to an SDL_Joystick* */
6670 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6671 public static extern byte SDL_JoystickGetHat(
6672 IntPtr joystick,
6673 int hat
6674 );
6675
6676 /* joystick refers to an SDL_Joystick* */
6677 [DllImport(nativeLibName, EntryPoint = "SDL_JoystickName", CallingConvention = CallingConvention.Cdecl)]
6678 private static extern IntPtr INTERNAL_SDL_JoystickName(
6679 IntPtr joystick
6680 );
6681 public static string SDL_JoystickName(IntPtr joystick)
6682 {
6683 return UTF8_ToManaged(
6684 INTERNAL_SDL_JoystickName(joystick)
6685 );
6686 }
6687
6688 [DllImport(nativeLibName, EntryPoint = "SDL_JoystickNameForIndex", CallingConvention = CallingConvention.Cdecl)]
6689 private static extern IntPtr INTERNAL_SDL_JoystickNameForIndex(
6690 int device_index
6691 );
6692 public static string SDL_JoystickNameForIndex(int device_index)
6693 {
6694 return UTF8_ToManaged(
6695 INTERNAL_SDL_JoystickNameForIndex(device_index)
6696 );
6697 }
6698
6699 /* joystick refers to an SDL_Joystick* */
6700 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6701 public static extern int SDL_JoystickNumAxes(IntPtr joystick);
6702
6703 /* joystick refers to an SDL_Joystick* */
6704 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6705 public static extern int SDL_JoystickNumBalls(IntPtr joystick);
6706
6707 /* joystick refers to an SDL_Joystick* */
6708 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6709 public static extern int SDL_JoystickNumButtons(IntPtr joystick);
6710
6711 /* joystick refers to an SDL_Joystick* */
6712 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6713 public static extern int SDL_JoystickNumHats(IntPtr joystick);
6714
6715 /* IntPtr refers to an SDL_Joystick* */
6716 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6717 public static extern IntPtr SDL_JoystickOpen(int device_index);
6718
6719 /* joystick refers to an SDL_Joystick* */
6720 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6721 public static extern void SDL_JoystickUpdate();
6722
6723 /* joystick refers to an SDL_Joystick* */
6724 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6725 public static extern int SDL_NumJoysticks();
6726
6727 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6728 public static extern Guid SDL_JoystickGetDeviceGUID(
6729 int device_index
6730 );
6731
6732 /* joystick refers to an SDL_Joystick* */
6733 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6734 public static extern Guid SDL_JoystickGetGUID(
6735 IntPtr joystick
6736 );
6737
6738 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6739 public static extern void SDL_JoystickGetGUIDString(
6740 Guid guid,
6741 byte[] pszGUID,
6742 int cbGUID
6743 );
6744
6745 [DllImport(nativeLibName, EntryPoint = "SDL_JoystickGetGUIDFromString", CallingConvention = CallingConvention.Cdecl)]
6746 private static extern unsafe Guid INTERNAL_SDL_JoystickGetGUIDFromString(
6747 byte* pchGUID
6748 );
6749 public static unsafe Guid SDL_JoystickGetGUIDFromString(string pchGuid)
6750 {
6751 int utf8PchGuidBufSize = Utf8Size(pchGuid);
6752 byte* utf8PchGuid = stackalloc byte[utf8PchGuidBufSize];
6753 return INTERNAL_SDL_JoystickGetGUIDFromString(
6754 Utf8Encode(pchGuid, utf8PchGuid, utf8PchGuidBufSize)
6755 );
6756 }
6757
6758 /* Only available in 2.0.6 or higher. */
6759 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6760 public static extern ushort SDL_JoystickGetDeviceVendor(int device_index);
6761
6762 /* Only available in 2.0.6 or higher. */
6763 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6764 public static extern ushort SDL_JoystickGetDeviceProduct(int device_index);
6765
6766 /* Only available in 2.0.6 or higher. */
6767 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6768 public static extern ushort SDL_JoystickGetDeviceProductVersion(int device_index);
6769
6770 /* Only available in 2.0.6 or higher. */
6771 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6772 public static extern SDL_JoystickType SDL_JoystickGetDeviceType(int device_index);
6773
6774 /* int refers to an SDL_JoystickID.
6775 * Only available in 2.0.6 or higher.
6776 */
6777 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6778 public static extern int SDL_JoystickGetDeviceInstanceID(int device_index);
6779
6780 /* joystick refers to an SDL_Joystick*.
6781 * Only available in 2.0.6 or higher.
6782 */
6783 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6784 public static extern ushort SDL_JoystickGetVendor(IntPtr joystick);
6785
6786 /* joystick refers to an SDL_Joystick*.
6787 * Only available in 2.0.6 or higher.
6788 */
6789 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6790 public static extern ushort SDL_JoystickGetProduct(IntPtr joystick);
6791
6792 /* joystick refers to an SDL_Joystick*.
6793 * Only available in 2.0.6 or higher.
6794 */
6795 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6796 public static extern ushort SDL_JoystickGetProductVersion(IntPtr joystick);
6797
6798 /* joystick refers to an SDL_Joystick*.
6799 * Only available in 2.0.14 or higher.
6800 */
6801 [DllImport(nativeLibName, EntryPoint = "SDL_JoystickGetSerial", CallingConvention = CallingConvention.Cdecl)]
6802 private static extern IntPtr INTERNAL_SDL_JoystickGetSerial(
6803 IntPtr joystick
6804 );
6805 public static string SDL_JoystickGetSerial(
6806 IntPtr joystick
6807 ) {
6808 return UTF8_ToManaged(
6809 INTERNAL_SDL_JoystickGetSerial(joystick)
6810 );
6811 }
6812
6813 /* joystick refers to an SDL_Joystick*.
6814 * Only available in 2.0.6 or higher.
6815 */
6816 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6817 public static extern SDL_JoystickType SDL_JoystickGetType(IntPtr joystick);
6818
6819 /* joystick refers to an SDL_Joystick* */
6820 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6821 public static extern SDL_bool SDL_JoystickGetAttached(IntPtr joystick);
6822
6823 /* int refers to an SDL_JoystickID, joystick to an SDL_Joystick* */
6824 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6825 public static extern int SDL_JoystickInstanceID(IntPtr joystick);
6826
6827 /* joystick refers to an SDL_Joystick*.
6828 * Only available in 2.0.4 or higher.
6829 */
6830 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6831 public static extern SDL_JoystickPowerLevel SDL_JoystickCurrentPowerLevel(
6832 IntPtr joystick
6833 );
6834
6835 /* int refers to an SDL_JoystickID, IntPtr to an SDL_Joystick*.
6836 * Only available in 2.0.4 or higher.
6837 */
6838 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6839 public static extern IntPtr SDL_JoystickFromInstanceID(int instance_id);
6840
6841 /* Only available in 2.0.7 or higher. */
6842 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6843 public static extern void SDL_LockJoysticks();
6844
6845 /* Only available in 2.0.7 or higher. */
6846 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6847 public static extern void SDL_UnlockJoysticks();
6848
6849 /* IntPtr refers to an SDL_Joystick*.
6850 * Only available in 2.0.11 or higher.
6851 */
6852 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6853 public static extern IntPtr SDL_JoystickFromPlayerIndex(int player_index);
6854
6855 /* IntPtr refers to an SDL_Joystick*.
6856 * Only available in 2.0.11 or higher.
6857 */
6858 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6859 public static extern void SDL_JoystickSetPlayerIndex(
6860 IntPtr joystick,
6861 int player_index
6862 );
6863
6864 /* Int32 refers to an SDL_JoystickType.
6865 * Only available in 2.0.14 or higher.
6866 */
6867 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6868 public static extern int SDL_JoystickAttachVirtual(
6869 Int32 type,
6870 int naxes,
6871 int nbuttons,
6872 int nhats
6873 );
6874
6875 /* Only available in 2.0.14 or higher. */
6876 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6877 public static extern int SDL_JoystickDetachVirtual(int device_index);
6878
6879 /* Only available in 2.0.14 or higher. */
6880 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6881 public static extern SDL_bool SDL_JoystickIsVirtual(int device_index);
6882
6883 /* IntPtr refers to an SDL_Joystick*.
6884 * Only available in 2.0.14 or higher.
6885 */
6886 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6887 public static extern int SDL_JoystickSetVirtualAxis(
6888 IntPtr joystick,
6889 int axis,
6890 Int16 value
6891 );
6892
6893 /* IntPtr refers to an SDL_Joystick*.
6894 * Only available in 2.0.14 or higher.
6895 */
6896 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6897 public static extern int SDL_JoystickSetVirtualButton(
6898 IntPtr joystick,
6899 int button,
6900 byte value
6901 );
6902
6903 /* IntPtr refers to an SDL_Joystick*.
6904 * Only available in 2.0.14 or higher.
6905 */
6906 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6907 public static extern int SDL_JoystickSetVirtualHat(
6908 IntPtr joystick,
6909 int hat,
6910 byte value
6911 );
6912
6913 /* IntPtr refers to an SDL_Joystick*.
6914 * Only available in 2.0.14 or higher.
6915 */
6916 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6917 public static extern SDL_bool SDL_JoystickHasLED(IntPtr joystick);
6918
6919 /* IntPtr refers to an SDL_Joystick*.
6920 * Only available in 2.0.18 or higher.
6921 */
6922 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6923 public static extern SDL_bool SDL_JoystickHasRumble(IntPtr joystick);
6924
6925 /* IntPtr refers to an SDL_Joystick*.
6926 * Only available in 2.0.18 or higher.
6927 */
6928 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6929 public static extern SDL_bool SDL_JoystickHasRumbleTriggers(IntPtr joystick);
6930
6931 /* IntPtr refers to an SDL_Joystick*.
6932 * Only available in 2.0.14 or higher.
6933 */
6934 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6935 public static extern int SDL_JoystickSetLED(
6936 IntPtr joystick,
6937 byte red,
6938 byte green,
6939 byte blue
6940 );
6941
6942 /* joystick refers to an SDL_Joystick*.
6943 * data refers to a const void*.
6944 * Only available in 2.0.16 or higher.
6945 */
6946 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
6947 public static extern int SDL_JoystickSendEffect(
6948 IntPtr joystick,
6949 IntPtr data,
6950 int size
6951 );
6952
6953 #endregion
6954
6955 #region SDL_gamecontroller.h
6956
6957 public enum SDL_GameControllerBindType
6958 {
6959 SDL_CONTROLLER_BINDTYPE_NONE,
6960 SDL_CONTROLLER_BINDTYPE_BUTTON,
6961 SDL_CONTROLLER_BINDTYPE_AXIS,
6962 SDL_CONTROLLER_BINDTYPE_HAT
6963 }
6964
6965 public enum SDL_GameControllerAxis
6966 {
6967 SDL_CONTROLLER_AXIS_INVALID = -1,
6968 SDL_CONTROLLER_AXIS_LEFTX,
6969 SDL_CONTROLLER_AXIS_LEFTY,
6970 SDL_CONTROLLER_AXIS_RIGHTX,
6971 SDL_CONTROLLER_AXIS_RIGHTY,
6972 SDL_CONTROLLER_AXIS_TRIGGERLEFT,
6973 SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
6974 SDL_CONTROLLER_AXIS_MAX
6975 }
6976
6977 public enum SDL_GameControllerButton
6978 {
6979 SDL_CONTROLLER_BUTTON_INVALID = -1,
6980 SDL_CONTROLLER_BUTTON_A,
6981 SDL_CONTROLLER_BUTTON_B,
6982 SDL_CONTROLLER_BUTTON_X,
6983 SDL_CONTROLLER_BUTTON_Y,
6984 SDL_CONTROLLER_BUTTON_BACK,
6985 SDL_CONTROLLER_BUTTON_GUIDE,
6986 SDL_CONTROLLER_BUTTON_START,
6987 SDL_CONTROLLER_BUTTON_LEFTSTICK,
6988 SDL_CONTROLLER_BUTTON_RIGHTSTICK,
6989 SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
6990 SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
6991 SDL_CONTROLLER_BUTTON_DPAD_UP,
6992 SDL_CONTROLLER_BUTTON_DPAD_DOWN,
6993 SDL_CONTROLLER_BUTTON_DPAD_LEFT,
6994 SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
6995 SDL_CONTROLLER_BUTTON_MISC1,
6996 SDL_CONTROLLER_BUTTON_PADDLE1,
6997 SDL_CONTROLLER_BUTTON_PADDLE2,
6998 SDL_CONTROLLER_BUTTON_PADDLE3,
6999 SDL_CONTROLLER_BUTTON_PADDLE4,
7000 SDL_CONTROLLER_BUTTON_TOUCHPAD,
7001 SDL_CONTROLLER_BUTTON_MAX,
7002 }
7003
7004 public enum SDL_GameControllerType
7005 {
7006 SDL_CONTROLLER_TYPE_UNKNOWN = 0,
7007 SDL_CONTROLLER_TYPE_XBOX360,
7008 SDL_CONTROLLER_TYPE_XBOXONE,
7009 SDL_CONTROLLER_TYPE_PS3,
7010 SDL_CONTROLLER_TYPE_PS4,
7011 SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO,
7012 SDL_CONTROLLER_TYPE_VIRTUAL, /* Requires >= 2.0.14 */
7013 SDL_CONTROLLER_TYPE_PS5, /* Requires >= 2.0.14 */
7014 SDL_CONTROLLER_TYPE_AMAZON_LUNA, /* Requires >= 2.0.16 */
7015 SDL_CONTROLLER_TYPE_GOOGLE_STADIA /* Requires >= 2.0.16 */
7016 }
7017
7018 // FIXME: I'd rather this somehow be private...
7019 [StructLayout(LayoutKind.Sequential)]
7020 public struct INTERNAL_GameControllerButtonBind_hat
7021 {
7022 public int hat;
7023 public int hat_mask;
7024 }
7025
7026 // FIXME: I'd rather this somehow be private...
7027 [StructLayout(LayoutKind.Explicit)]
7028 public struct INTERNAL_GameControllerButtonBind_union
7029 {
7030 [FieldOffset(0)]
7031 public int button;
7032 [FieldOffset(0)]
7033 public int axis;
7034 [FieldOffset(0)]
7035 public INTERNAL_GameControllerButtonBind_hat hat;
7036 }
7037
7038 [StructLayout(LayoutKind.Sequential)]
7039 public struct SDL_GameControllerButtonBind
7040 {
7041 public SDL_GameControllerBindType bindType;
7042 public INTERNAL_GameControllerButtonBind_union value;
7043 }
7044
7045 /* This exists to deal with C# being stupid about blittable types. */
7046 [StructLayout(LayoutKind.Sequential)]
7047 private struct INTERNAL_SDL_GameControllerButtonBind
7048 {
7049 public int bindType;
7050 /* Largest data type in the union is two ints in size */
7051 public int unionVal0;
7052 public int unionVal1;
7053 }
7054
7055 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerAddMapping", CallingConvention = CallingConvention.Cdecl)]
7056 private static extern unsafe int INTERNAL_SDL_GameControllerAddMapping(
7057 byte* mappingString
7058 );
7059 public static unsafe int SDL_GameControllerAddMapping(
7060 string mappingString
7061 ) {
7062 byte* utf8MappingString = Utf8EncodeHeap(mappingString);
7063 int result = INTERNAL_SDL_GameControllerAddMapping(
7064 utf8MappingString
7065 );
7066 Marshal.FreeHGlobal((IntPtr) utf8MappingString);
7067 return result;
7068 }
7069
7070 /* Only available in 2.0.6 or higher. */
7071 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7072 public static extern int SDL_GameControllerNumMappings();
7073
7074 /* Only available in 2.0.6 or higher. */
7075 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerMappingForIndex", CallingConvention = CallingConvention.Cdecl)]
7076 private static extern IntPtr INTERNAL_SDL_GameControllerMappingForIndex(int mapping_index);
7077 public static string SDL_GameControllerMappingForIndex(int mapping_index)
7078 {
7079 return UTF8_ToManaged(
7080 INTERNAL_SDL_GameControllerMappingForIndex(
7081 mapping_index
7082 ),
7083 true
7084 );
7085 }
7086
7087 /* THIS IS AN RWops FUNCTION! */
7088 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerAddMappingsFromRW", CallingConvention = CallingConvention.Cdecl)]
7089 private static extern int INTERNAL_SDL_GameControllerAddMappingsFromRW(
7090 IntPtr rw,
7091 int freerw
7092 );
7093 public static int SDL_GameControllerAddMappingsFromFile(string file)
7094 {
7095 IntPtr rwops = SDL_RWFromFile(file, "rb");
7096 return INTERNAL_SDL_GameControllerAddMappingsFromRW(rwops, 1);
7097 }
7098
7099 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerMappingForGUID", CallingConvention = CallingConvention.Cdecl)]
7100 private static extern IntPtr INTERNAL_SDL_GameControllerMappingForGUID(
7101 Guid guid
7102 );
7103 public static string SDL_GameControllerMappingForGUID(Guid guid)
7104 {
7105 return UTF8_ToManaged(
7106 INTERNAL_SDL_GameControllerMappingForGUID(guid),
7107 true
7108 );
7109 }
7110
7111 /* gamecontroller refers to an SDL_GameController* */
7112 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerMapping", CallingConvention = CallingConvention.Cdecl)]
7113 private static extern IntPtr INTERNAL_SDL_GameControllerMapping(
7114 IntPtr gamecontroller
7115 );
7116 public static string SDL_GameControllerMapping(
7117 IntPtr gamecontroller
7118 ) {
7119 return UTF8_ToManaged(
7120 INTERNAL_SDL_GameControllerMapping(
7121 gamecontroller
7122 ),
7123 true
7124 );
7125 }
7126
7127 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7128 public static extern SDL_bool SDL_IsGameController(int joystick_index);
7129
7130 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerNameForIndex", CallingConvention = CallingConvention.Cdecl)]
7131 private static extern IntPtr INTERNAL_SDL_GameControllerNameForIndex(
7132 int joystick_index
7133 );
7134 public static string SDL_GameControllerNameForIndex(
7135 int joystick_index
7136 ) {
7137 return UTF8_ToManaged(
7138 INTERNAL_SDL_GameControllerNameForIndex(joystick_index)
7139 );
7140 }
7141
7142 /* Only available in 2.0.9 or higher. */
7143 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerMappingForDeviceIndex", CallingConvention = CallingConvention.Cdecl)]
7144 private static extern IntPtr INTERNAL_SDL_GameControllerMappingForDeviceIndex(
7145 int joystick_index
7146 );
7147 public static string SDL_GameControllerMappingForDeviceIndex(
7148 int joystick_index
7149 ) {
7150 return UTF8_ToManaged(
7151 INTERNAL_SDL_GameControllerMappingForDeviceIndex(joystick_index),
7152 true
7153 );
7154 }
7155
7156 /* IntPtr refers to an SDL_GameController* */
7157 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7158 public static extern IntPtr SDL_GameControllerOpen(int joystick_index);
7159
7160 /* gamecontroller refers to an SDL_GameController* */
7161 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerName", CallingConvention = CallingConvention.Cdecl)]
7162 private static extern IntPtr INTERNAL_SDL_GameControllerName(
7163 IntPtr gamecontroller
7164 );
7165 public static string SDL_GameControllerName(
7166 IntPtr gamecontroller
7167 ) {
7168 return UTF8_ToManaged(
7169 INTERNAL_SDL_GameControllerName(gamecontroller)
7170 );
7171 }
7172
7173 /* gamecontroller refers to an SDL_GameController*.
7174 * Only available in 2.0.6 or higher.
7175 */
7176 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7177 public static extern ushort SDL_GameControllerGetVendor(
7178 IntPtr gamecontroller
7179 );
7180
7181 /* gamecontroller refers to an SDL_GameController*.
7182 * Only available in 2.0.6 or higher.
7183 */
7184 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7185 public static extern ushort SDL_GameControllerGetProduct(
7186 IntPtr gamecontroller
7187 );
7188
7189 /* gamecontroller refers to an SDL_GameController*.
7190 * Only available in 2.0.6 or higher.
7191 */
7192 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7193 public static extern ushort SDL_GameControllerGetProductVersion(
7194 IntPtr gamecontroller
7195 );
7196
7197 /* gamecontroller refers to an SDL_GameController*.
7198 * Only available in 2.0.14 or higher.
7199 */
7200 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetSerial", CallingConvention = CallingConvention.Cdecl)]
7201 private static extern IntPtr INTERNAL_SDL_GameControllerGetSerial(
7202 IntPtr gamecontroller
7203 );
7204 public static string SDL_GameControllerGetSerial(
7205 IntPtr gamecontroller
7206 ) {
7207 return UTF8_ToManaged(
7208 INTERNAL_SDL_GameControllerGetSerial(gamecontroller)
7209 );
7210 }
7211
7212 /* gamecontroller refers to an SDL_GameController* */
7213 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7214 public static extern SDL_bool SDL_GameControllerGetAttached(
7215 IntPtr gamecontroller
7216 );
7217
7218 /* IntPtr refers to an SDL_Joystick*
7219 * gamecontroller refers to an SDL_GameController*
7220 */
7221 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7222 public static extern IntPtr SDL_GameControllerGetJoystick(
7223 IntPtr gamecontroller
7224 );
7225
7226 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7227 public static extern int SDL_GameControllerEventState(int state);
7228
7229 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7230 public static extern void SDL_GameControllerUpdate();
7231
7232 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetAxisFromString", CallingConvention = CallingConvention.Cdecl)]
7233 private static extern unsafe SDL_GameControllerAxis INTERNAL_SDL_GameControllerGetAxisFromString(
7234 byte* pchString
7235 );
7236 public static unsafe SDL_GameControllerAxis SDL_GameControllerGetAxisFromString(
7237 string pchString
7238 ) {
7239 int utf8PchStringBufSize = Utf8Size(pchString);
7240 byte* utf8PchString = stackalloc byte[utf8PchStringBufSize];
7241 return INTERNAL_SDL_GameControllerGetAxisFromString(
7242 Utf8Encode(pchString, utf8PchString, utf8PchStringBufSize)
7243 );
7244 }
7245
7246 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetStringForAxis", CallingConvention = CallingConvention.Cdecl)]
7247 private static extern IntPtr INTERNAL_SDL_GameControllerGetStringForAxis(
7248 SDL_GameControllerAxis axis
7249 );
7250 public static string SDL_GameControllerGetStringForAxis(
7251 SDL_GameControllerAxis axis
7252 ) {
7253 return UTF8_ToManaged(
7254 INTERNAL_SDL_GameControllerGetStringForAxis(
7255 axis
7256 )
7257 );
7258 }
7259
7260 /* gamecontroller refers to an SDL_GameController* */
7261 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetBindForAxis", CallingConvention = CallingConvention.Cdecl)]
7262 private static extern INTERNAL_SDL_GameControllerButtonBind INTERNAL_SDL_GameControllerGetBindForAxis(
7263 IntPtr gamecontroller,
7264 SDL_GameControllerAxis axis
7265 );
7266 public static SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis(
7267 IntPtr gamecontroller,
7268 SDL_GameControllerAxis axis
7269 ) {
7270 // This is guaranteed to never be null
7271 INTERNAL_SDL_GameControllerButtonBind dumb = INTERNAL_SDL_GameControllerGetBindForAxis(
7272 gamecontroller,
7273 axis
7274 );
7275 SDL_GameControllerButtonBind result = new SDL_GameControllerButtonBind();
7276 result.bindType = (SDL_GameControllerBindType) dumb.bindType;
7277 result.value.hat.hat = dumb.unionVal0;
7278 result.value.hat.hat_mask = dumb.unionVal1;
7279 return result;
7280 }
7281
7282 /* gamecontroller refers to an SDL_GameController* */
7283 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7284 public static extern short SDL_GameControllerGetAxis(
7285 IntPtr gamecontroller,
7286 SDL_GameControllerAxis axis
7287 );
7288
7289 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetButtonFromString", CallingConvention = CallingConvention.Cdecl)]
7290 private static extern unsafe SDL_GameControllerButton INTERNAL_SDL_GameControllerGetButtonFromString(
7291 byte* pchString
7292 );
7293 public static unsafe SDL_GameControllerButton SDL_GameControllerGetButtonFromString(
7294 string pchString
7295 ) {
7296 int utf8PchStringBufSize = Utf8Size(pchString);
7297 byte* utf8PchString = stackalloc byte[utf8PchStringBufSize];
7298 return INTERNAL_SDL_GameControllerGetButtonFromString(
7299 Utf8Encode(pchString, utf8PchString, utf8PchStringBufSize)
7300 );
7301 }
7302
7303 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetStringForButton", CallingConvention = CallingConvention.Cdecl)]
7304 private static extern IntPtr INTERNAL_SDL_GameControllerGetStringForButton(
7305 SDL_GameControllerButton button
7306 );
7307 public static string SDL_GameControllerGetStringForButton(
7308 SDL_GameControllerButton button
7309 ) {
7310 return UTF8_ToManaged(
7311 INTERNAL_SDL_GameControllerGetStringForButton(button)
7312 );
7313 }
7314
7315 /* gamecontroller refers to an SDL_GameController* */
7316 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetBindForButton", CallingConvention = CallingConvention.Cdecl)]
7317 private static extern INTERNAL_SDL_GameControllerButtonBind INTERNAL_SDL_GameControllerGetBindForButton(
7318 IntPtr gamecontroller,
7319 SDL_GameControllerButton button
7320 );
7321 public static SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(
7322 IntPtr gamecontroller,
7323 SDL_GameControllerButton button
7324 ) {
7325 // This is guaranteed to never be null
7326 INTERNAL_SDL_GameControllerButtonBind dumb = INTERNAL_SDL_GameControllerGetBindForButton(
7327 gamecontroller,
7328 button
7329 );
7330 SDL_GameControllerButtonBind result = new SDL_GameControllerButtonBind();
7331 result.bindType = (SDL_GameControllerBindType) dumb.bindType;
7332 result.value.hat.hat = dumb.unionVal0;
7333 result.value.hat.hat_mask = dumb.unionVal1;
7334 return result;
7335 }
7336
7337 /* gamecontroller refers to an SDL_GameController* */
7338 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7339 public static extern byte SDL_GameControllerGetButton(
7340 IntPtr gamecontroller,
7341 SDL_GameControllerButton button
7342 );
7343
7344 /* gamecontroller refers to an SDL_GameController*.
7345 * Only available in 2.0.9 or higher.
7346 */
7347 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7348 public static extern int SDL_GameControllerRumble(
7349 IntPtr gamecontroller,
7350 UInt16 low_frequency_rumble,
7351 UInt16 high_frequency_rumble,
7352 UInt32 duration_ms
7353 );
7354
7355 /* gamecontroller refers to an SDL_GameController*.
7356 * Only available in 2.0.14 or higher.
7357 */
7358 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7359 public static extern int SDL_GameControllerRumbleTriggers(
7360 IntPtr gamecontroller,
7361 UInt16 left_rumble,
7362 UInt16 right_rumble,
7363 UInt32 duration_ms
7364 );
7365
7366 /* gamecontroller refers to an SDL_GameController* */
7367 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7368 public static extern void SDL_GameControllerClose(
7369 IntPtr gamecontroller
7370 );
7371
7372 /* gamecontroller refers to an SDL_GameController*
7373 * Only available in 2.0.18 or higher.
7374 */
7375 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetAppleSFSymbolsNameForButton", CallingConvention = CallingConvention.Cdecl)]
7376 private static extern IntPtr INTERNAL_SDL_GameControllerGetAppleSFSymbolsNameForButton(
7377 IntPtr gamecontroller,
7378 SDL_GameControllerButton button
7379 );
7380 public static string SDL_GameControllerGetAppleSFSymbolsNameForButton(
7381 IntPtr gamecontroller,
7382 SDL_GameControllerButton button
7383 ) {
7384 return UTF8_ToManaged(
7385 INTERNAL_SDL_GameControllerGetAppleSFSymbolsNameForButton(gamecontroller, button)
7386 );
7387 }
7388
7389 /* gamecontroller refers to an SDL_GameController*
7390 * Only available in 2.0.18 or higher.
7391 */
7392 [DllImport(nativeLibName, EntryPoint = "SDL_GameControllerGetAppleSFSymbolsNameForAxis", CallingConvention = CallingConvention.Cdecl)]
7393 private static extern IntPtr INTERNAL_SDL_GameControllerGetAppleSFSymbolsNameForAxis(
7394 IntPtr gamecontroller,
7395 SDL_GameControllerAxis axis
7396 );
7397 public static string SDL_GameControllerGetAppleSFSymbolsNameForAxis(
7398 IntPtr gamecontroller,
7399 SDL_GameControllerAxis axis
7400 ) {
7401 return UTF8_ToManaged(
7402 INTERNAL_SDL_GameControllerGetAppleSFSymbolsNameForAxis(gamecontroller, axis)
7403 );
7404 }
7405
7406 /* int refers to an SDL_JoystickID, IntPtr to an SDL_GameController*.
7407 * Only available in 2.0.4 or higher.
7408 */
7409 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7410 public static extern IntPtr SDL_GameControllerFromInstanceID(int joyid);
7411
7412 /* Only available in 2.0.11 or higher. */
7413 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7414 public static extern SDL_GameControllerType SDL_GameControllerTypeForIndex(
7415 int joystick_index
7416 );
7417
7418 /* IntPtr refers to an SDL_GameController*.
7419 * Only available in 2.0.11 or higher.
7420 */
7421 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7422 public static extern SDL_GameControllerType SDL_GameControllerGetType(
7423 IntPtr gamecontroller
7424 );
7425
7426 /* IntPtr refers to an SDL_GameController*.
7427 * Only available in 2.0.11 or higher.
7428 */
7429 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7430 public static extern IntPtr SDL_GameControllerFromPlayerIndex(
7431 int player_index
7432 );
7433
7434 /* IntPtr refers to an SDL_GameController*.
7435 * Only available in 2.0.11 or higher.
7436 */
7437 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7438 public static extern void SDL_GameControllerSetPlayerIndex(
7439 IntPtr gamecontroller,
7440 int player_index
7441 );
7442
7443 /* gamecontroller refers to an SDL_GameController*.
7444 * Only available in 2.0.14 or higher.
7445 */
7446 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7447 public static extern SDL_bool SDL_GameControllerHasLED(
7448 IntPtr gamecontroller
7449 );
7450
7451 /* gamecontroller refers to an SDL_GameController*.
7452 * Only available in 2.0.18 or higher.
7453 */
7454 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7455 public static extern SDL_bool SDL_GameControllerHasRumble(
7456 IntPtr gamecontroller
7457 );
7458
7459 /* gamecontroller refers to an SDL_GameController*.
7460 * Only available in 2.0.18 or higher.
7461 */
7462 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7463 public static extern SDL_bool SDL_GameControllerHasRumbleTriggers(
7464 IntPtr gamecontroller
7465 );
7466
7467 /* gamecontroller refers to an SDL_GameController*.
7468 * Only available in 2.0.14 or higher.
7469 */
7470 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7471 public static extern int SDL_GameControllerSetLED(
7472 IntPtr gamecontroller,
7473 byte red,
7474 byte green,
7475 byte blue
7476 );
7477
7478 /* gamecontroller refers to an SDL_GameController*.
7479 * Only available in 2.0.14 or higher.
7480 */
7481 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7482 public static extern SDL_bool SDL_GameControllerHasAxis(
7483 IntPtr gamecontroller,
7484 SDL_GameControllerAxis axis
7485 );
7486
7487 /* gamecontroller refers to an SDL_GameController*.
7488 * Only available in 2.0.14 or higher.
7489 */
7490 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7491 public static extern SDL_bool SDL_GameControllerHasButton(
7492 IntPtr gamecontroller,
7493 SDL_GameControllerButton button
7494 );
7495
7496 /* gamecontroller refers to an SDL_GameController*.
7497 * Only available in 2.0.14 or higher.
7498 */
7499 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7500 public static extern int SDL_GameControllerGetNumTouchpads(
7501 IntPtr gamecontroller
7502 );
7503
7504 /* gamecontroller refers to an SDL_GameController*.
7505 * Only available in 2.0.14 or higher.
7506 */
7507 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7508 public static extern int SDL_GameControllerGetNumTouchpadFingers(
7509 IntPtr gamecontroller,
7510 int touchpad
7511 );
7512
7513 /* gamecontroller refers to an SDL_GameController*.
7514 * Only available in 2.0.14 or higher.
7515 */
7516 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7517 public static extern int SDL_GameControllerGetTouchpadFinger(
7518 IntPtr gamecontroller,
7519 int touchpad,
7520 int finger,
7521 out byte state,
7522 out float x,
7523 out float y,
7524 out float pressure
7525 );
7526
7527 /* gamecontroller refers to an SDL_GameController*.
7528 * Only available in 2.0.14 or higher.
7529 */
7530 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7531 public static extern SDL_bool SDL_GameControllerHasSensor(
7532 IntPtr gamecontroller,
7533 SDL_SensorType type
7534 );
7535
7536 /* gamecontroller refers to an SDL_GameController*.
7537 * Only available in 2.0.14 or higher.
7538 */
7539 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7540 public static extern int SDL_GameControllerSetSensorEnabled(
7541 IntPtr gamecontroller,
7542 SDL_SensorType type,
7543 SDL_bool enabled
7544 );
7545
7546 /* gamecontroller refers to an SDL_GameController*.
7547 * Only available in 2.0.14 or higher.
7548 */
7549 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7550 public static extern SDL_bool SDL_GameControllerIsSensorEnabled(
7551 IntPtr gamecontroller,
7552 SDL_SensorType type
7553 );
7554
7555 /* gamecontroller refers to an SDL_GameController*.
7556 * data refers to a float*.
7557 * Only available in 2.0.14 or higher.
7558 */
7559 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7560 public static extern int SDL_GameControllerGetSensorData(
7561 IntPtr gamecontroller,
7562 SDL_SensorType type,
7563 IntPtr data,
7564 int num_values
7565 );
7566
7567 /* gamecontroller refers to an SDL_GameController*.
7568 * Only available in 2.0.14 or higher.
7569 */
7570 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7571 public static extern int SDL_GameControllerGetSensorData(
7572 IntPtr gamecontroller,
7573 SDL_SensorType type,
7574 [In] float[] data,
7575 int num_values
7576 );
7577
7578 /* gamecontroller refers to an SDL_GameController*.
7579 * Only available in 2.0.16 or higher.
7580 */
7581 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7582 public static extern float SDL_GameControllerGetSensorDataRate(
7583 IntPtr gamecontroller,
7584 SDL_SensorType type
7585 );
7586
7587 /* gamecontroller refers to an SDL_GameController*.
7588 * data refers to a const void*.
7589 * Only available in 2.0.16 or higher.
7590 */
7591 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7592 public static extern int SDL_GameControllerSendEffect(
7593 IntPtr gamecontroller,
7594 IntPtr data,
7595 int size
7596 );
7597
7598 #endregion
7599
7600 #region SDL_haptic.h
7601
7602 /* SDL_HapticEffect type */
7603 public const ushort SDL_HAPTIC_CONSTANT = (1 << 0);
7604 public const ushort SDL_HAPTIC_SINE = (1 << 1);
7605 public const ushort SDL_HAPTIC_LEFTRIGHT = (1 << 2);
7606 public const ushort SDL_HAPTIC_TRIANGLE = (1 << 3);
7607 public const ushort SDL_HAPTIC_SAWTOOTHUP = (1 << 4);
7608 public const ushort SDL_HAPTIC_SAWTOOTHDOWN = (1 << 5);
7609 public const ushort SDL_HAPTIC_SPRING = (1 << 7);
7610 public const ushort SDL_HAPTIC_DAMPER = (1 << 8);
7611 public const ushort SDL_HAPTIC_INERTIA = (1 << 9);
7612 public const ushort SDL_HAPTIC_FRICTION = (1 << 10);
7613 public const ushort SDL_HAPTIC_CUSTOM = (1 << 11);
7614 public const ushort SDL_HAPTIC_GAIN = (1 << 12);
7615 public const ushort SDL_HAPTIC_AUTOCENTER = (1 << 13);
7616 public const ushort SDL_HAPTIC_STATUS = (1 << 14);
7617 public const ushort SDL_HAPTIC_PAUSE = (1 << 15);
7618
7619 /* SDL_HapticDirection type */
7620 public const byte SDL_HAPTIC_POLAR = 0;
7621 public const byte SDL_HAPTIC_CARTESIAN = 1;
7622 public const byte SDL_HAPTIC_SPHERICAL = 2;
7623 public const byte SDL_HAPTIC_STEERING_AXIS = 3; /* Requires >= 2.0.14 */
7624
7625 /* SDL_HapticRunEffect */
7626 public const uint SDL_HAPTIC_INFINITY = 4294967295U;
7627
7628 [StructLayout(LayoutKind.Sequential)]
7629 public unsafe struct SDL_HapticDirection
7630 {
7631 public byte type;
7632 public fixed int dir[3];
7633 }
7634
7635 [StructLayout(LayoutKind.Sequential)]
7636 public struct SDL_HapticConstant
7637 {
7638 // Header
7639 public ushort type;
7640 public SDL_HapticDirection direction;
7641 // Replay
7642 public uint length;
7643 public ushort delay;
7644 // Trigger
7645 public ushort button;
7646 public ushort interval;
7647 // Constant
7648 public short level;
7649 // Envelope
7650 public ushort attack_length;
7651 public ushort attack_level;
7652 public ushort fade_length;
7653 public ushort fade_level;
7654 }
7655
7656 [StructLayout(LayoutKind.Sequential)]
7657 public struct SDL_HapticPeriodic
7658 {
7659 // Header
7660 public ushort type;
7661 public SDL_HapticDirection direction;
7662 // Replay
7663 public uint length;
7664 public ushort delay;
7665 // Trigger
7666 public ushort button;
7667 public ushort interval;
7668 // Periodic
7669 public ushort period;
7670 public short magnitude;
7671 public short offset;
7672 public ushort phase;
7673 // Envelope
7674 public ushort attack_length;
7675 public ushort attack_level;
7676 public ushort fade_length;
7677 public ushort fade_level;
7678 }
7679
7680 [StructLayout(LayoutKind.Sequential)]
7681 public unsafe struct SDL_HapticCondition
7682 {
7683 // Header
7684 public ushort type;
7685 public SDL_HapticDirection direction;
7686 // Replay
7687 public uint length;
7688 public ushort delay;
7689 // Trigger
7690 public ushort button;
7691 public ushort interval;
7692 // Condition
7693 public fixed ushort right_sat[3];
7694 public fixed ushort left_sat[3];
7695 public fixed short right_coeff[3];
7696 public fixed short left_coeff[3];
7697 public fixed ushort deadband[3];
7698 public fixed short center[3];
7699 }
7700
7701 [StructLayout(LayoutKind.Sequential)]
7702 public struct SDL_HapticRamp
7703 {
7704 // Header
7705 public ushort type;
7706 public SDL_HapticDirection direction;
7707 // Replay
7708 public uint length;
7709 public ushort delay;
7710 // Trigger
7711 public ushort button;
7712 public ushort interval;
7713 // Ramp
7714 public short start;
7715 public short end;
7716 // Envelope
7717 public ushort attack_length;
7718 public ushort attack_level;
7719 public ushort fade_length;
7720 public ushort fade_level;
7721 }
7722
7723 [StructLayout(LayoutKind.Sequential)]
7724 public struct SDL_HapticLeftRight
7725 {
7726 // Header
7727 public ushort type;
7728 // Replay
7729 public uint length;
7730 // Rumble
7731 public ushort large_magnitude;
7732 public ushort small_magnitude;
7733 }
7734
7735 [StructLayout(LayoutKind.Sequential)]
7736 public struct SDL_HapticCustom
7737 {
7738 // Header
7739 public ushort type;
7740 public SDL_HapticDirection direction;
7741 // Replay
7742 public uint length;
7743 public ushort delay;
7744 // Trigger
7745 public ushort button;
7746 public ushort interval;
7747 // Custom
7748 public byte channels;
7749 public ushort period;
7750 public ushort samples;
7751 public IntPtr data; // Uint16*
7752 // Envelope
7753 public ushort attack_length;
7754 public ushort attack_level;
7755 public ushort fade_length;
7756 public ushort fade_level;
7757 }
7758
7759 [StructLayout(LayoutKind.Explicit)]
7760 public struct SDL_HapticEffect
7761 {
7762 [FieldOffset(0)]
7763 public ushort type;
7764 [FieldOffset(0)]
7765 public SDL_HapticConstant constant;
7766 [FieldOffset(0)]
7767 public SDL_HapticPeriodic periodic;
7768 [FieldOffset(0)]
7769 public SDL_HapticCondition condition;
7770 [FieldOffset(0)]
7771 public SDL_HapticRamp ramp;
7772 [FieldOffset(0)]
7773 public SDL_HapticLeftRight leftright;
7774 [FieldOffset(0)]
7775 public SDL_HapticCustom custom;
7776 }
7777
7778 /* haptic refers to an SDL_Haptic* */
7779 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7780 public static extern void SDL_HapticClose(IntPtr haptic);
7781
7782 /* haptic refers to an SDL_Haptic* */
7783 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7784 public static extern void SDL_HapticDestroyEffect(
7785 IntPtr haptic,
7786 int effect
7787 );
7788
7789 /* haptic refers to an SDL_Haptic* */
7790 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7791 public static extern int SDL_HapticEffectSupported(
7792 IntPtr haptic,
7793 ref SDL_HapticEffect effect
7794 );
7795
7796 /* haptic refers to an SDL_Haptic* */
7797 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7798 public static extern int SDL_HapticGetEffectStatus(
7799 IntPtr haptic,
7800 int effect
7801 );
7802
7803 /* haptic refers to an SDL_Haptic* */
7804 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7805 public static extern int SDL_HapticIndex(IntPtr haptic);
7806
7807 /* haptic refers to an SDL_Haptic* */
7808 [DllImport(nativeLibName, EntryPoint = "SDL_HapticName", CallingConvention = CallingConvention.Cdecl)]
7809 private static extern IntPtr INTERNAL_SDL_HapticName(int device_index);
7810 public static string SDL_HapticName(int device_index)
7811 {
7812 return UTF8_ToManaged(INTERNAL_SDL_HapticName(device_index));
7813 }
7814
7815 /* haptic refers to an SDL_Haptic* */
7816 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7817 public static extern int SDL_HapticNewEffect(
7818 IntPtr haptic,
7819 ref SDL_HapticEffect effect
7820 );
7821
7822 /* haptic refers to an SDL_Haptic* */
7823 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7824 public static extern int SDL_HapticNumAxes(IntPtr haptic);
7825
7826 /* haptic refers to an SDL_Haptic* */
7827 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7828 public static extern int SDL_HapticNumEffects(IntPtr haptic);
7829
7830 /* haptic refers to an SDL_Haptic* */
7831 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7832 public static extern int SDL_HapticNumEffectsPlaying(IntPtr haptic);
7833
7834 /* IntPtr refers to an SDL_Haptic* */
7835 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7836 public static extern IntPtr SDL_HapticOpen(int device_index);
7837
7838 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7839 public static extern int SDL_HapticOpened(int device_index);
7840
7841 /* IntPtr refers to an SDL_Haptic*, joystick to an SDL_Joystick* */
7842 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7843 public static extern IntPtr SDL_HapticOpenFromJoystick(
7844 IntPtr joystick
7845 );
7846
7847 /* IntPtr refers to an SDL_Haptic* */
7848 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7849 public static extern IntPtr SDL_HapticOpenFromMouse();
7850
7851 /* haptic refers to an SDL_Haptic* */
7852 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7853 public static extern int SDL_HapticPause(IntPtr haptic);
7854
7855 /* haptic refers to an SDL_Haptic* */
7856 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7857 public static extern uint SDL_HapticQuery(IntPtr haptic);
7858
7859 /* haptic refers to an SDL_Haptic* */
7860 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7861 public static extern int SDL_HapticRumbleInit(IntPtr haptic);
7862
7863 /* haptic refers to an SDL_Haptic* */
7864 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7865 public static extern int SDL_HapticRumblePlay(
7866 IntPtr haptic,
7867 float strength,
7868 uint length
7869 );
7870
7871 /* haptic refers to an SDL_Haptic* */
7872 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7873 public static extern int SDL_HapticRumbleStop(IntPtr haptic);
7874
7875 /* haptic refers to an SDL_Haptic* */
7876 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7877 public static extern int SDL_HapticRumbleSupported(IntPtr haptic);
7878
7879 /* haptic refers to an SDL_Haptic* */
7880 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7881 public static extern int SDL_HapticRunEffect(
7882 IntPtr haptic,
7883 int effect,
7884 uint iterations
7885 );
7886
7887 /* haptic refers to an SDL_Haptic* */
7888 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7889 public static extern int SDL_HapticSetAutocenter(
7890 IntPtr haptic,
7891 int autocenter
7892 );
7893
7894 /* haptic refers to an SDL_Haptic* */
7895 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7896 public static extern int SDL_HapticSetGain(
7897 IntPtr haptic,
7898 int gain
7899 );
7900
7901 /* haptic refers to an SDL_Haptic* */
7902 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7903 public static extern int SDL_HapticStopAll(IntPtr haptic);
7904
7905 /* haptic refers to an SDL_Haptic* */
7906 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7907 public static extern int SDL_HapticStopEffect(
7908 IntPtr haptic,
7909 int effect
7910 );
7911
7912 /* haptic refers to an SDL_Haptic* */
7913 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7914 public static extern int SDL_HapticUnpause(IntPtr haptic);
7915
7916 /* haptic refers to an SDL_Haptic* */
7917 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7918 public static extern int SDL_HapticUpdateEffect(
7919 IntPtr haptic,
7920 int effect,
7921 ref SDL_HapticEffect data
7922 );
7923
7924 /* joystick refers to an SDL_Joystick* */
7925 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7926 public static extern int SDL_JoystickIsHaptic(IntPtr joystick);
7927
7928 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7929 public static extern int SDL_MouseIsHaptic();
7930
7931 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7932 public static extern int SDL_NumHaptics();
7933
7934 #endregion
7935
7936 #region SDL_sensor.h
7937
7938 /* This region is only available in 2.0.9 or higher. */
7939
7940 public enum SDL_SensorType
7941 {
7942 SDL_SENSOR_INVALID = -1,
7943 SDL_SENSOR_UNKNOWN,
7944 SDL_SENSOR_ACCEL,
7945 SDL_SENSOR_GYRO
7946 }
7947
7948 public const float SDL_STANDARD_GRAVITY = 9.80665f;
7949
7950 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7951 public static extern int SDL_NumSensors();
7952
7953 [DllImport(nativeLibName, EntryPoint = "SDL_SensorGetDeviceName", CallingConvention = CallingConvention.Cdecl)]
7954 private static extern IntPtr INTERNAL_SDL_SensorGetDeviceName(int device_index);
7955 public static string SDL_SensorGetDeviceName(int device_index)
7956 {
7957 return UTF8_ToManaged(INTERNAL_SDL_SensorGetDeviceName(device_index));
7958 }
7959
7960 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7961 public static extern SDL_SensorType SDL_SensorGetDeviceType(int device_index);
7962
7963 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7964 public static extern int SDL_SensorGetDeviceNonPortableType(int device_index);
7965
7966 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7967 public static extern Int32 SDL_SensorGetDeviceInstanceID(int device_index);
7968
7969 /* IntPtr refers to an SDL_Sensor* */
7970 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7971 public static extern IntPtr SDL_SensorOpen(int device_index);
7972
7973 /* IntPtr refers to an SDL_Sensor* */
7974 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7975 public static extern IntPtr SDL_SensorFromInstanceID(
7976 Int32 instance_id
7977 );
7978
7979 /* sensor refers to an SDL_Sensor* */
7980 [DllImport(nativeLibName, EntryPoint = "SDL_SensorGetName", CallingConvention = CallingConvention.Cdecl)]
7981 private static extern IntPtr INTERNAL_SDL_SensorGetName(IntPtr sensor);
7982 public static string SDL_SensorGetName(IntPtr sensor)
7983 {
7984 return UTF8_ToManaged(INTERNAL_SDL_SensorGetName(sensor));
7985 }
7986
7987 /* sensor refers to an SDL_Sensor* */
7988 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7989 public static extern SDL_SensorType SDL_SensorGetType(IntPtr sensor);
7990
7991 /* sensor refers to an SDL_Sensor* */
7992 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7993 public static extern int SDL_SensorGetNonPortableType(IntPtr sensor);
7994
7995 /* sensor refers to an SDL_Sensor* */
7996 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
7997 public static extern Int32 SDL_SensorGetInstanceID(IntPtr sensor);
7998
7999 /* sensor refers to an SDL_Sensor* */
8000 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8001 public static extern int SDL_SensorGetData(
8002 IntPtr sensor,
8003 float[] data,
8004 int num_values
8005 );
8006
8007 /* sensor refers to an SDL_Sensor* */
8008 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8009 public static extern void SDL_SensorClose(IntPtr sensor);
8010
8011 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8012 public static extern void SDL_SensorUpdate();
8013
8014 /* Only available in 2.0.14 or higher. */
8015 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8016 public static extern void SDL_LockSensors();
8017
8018 /* Only available in 2.0.14 or higher. */
8019 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8020 public static extern void SDL_UnlockSensors();
8021
8022 #endregion
8023
8024 #region SDL_audio.h
8025
8026 public const ushort SDL_AUDIO_MASK_BITSIZE = 0xFF;
8027 public const ushort SDL_AUDIO_MASK_DATATYPE = (1 << 8);
8028 public const ushort SDL_AUDIO_MASK_ENDIAN = (1 << 12);
8029 public const ushort SDL_AUDIO_MASK_SIGNED = (1 << 15);
8030
8031 public static ushort SDL_AUDIO_BITSIZE(ushort x)
8032 {
8033 return (ushort) (x & SDL_AUDIO_MASK_BITSIZE);
8034 }
8035
8036 public static bool SDL_AUDIO_ISFLOAT(ushort x)
8037 {
8038 return (x & SDL_AUDIO_MASK_DATATYPE) != 0;
8039 }
8040
8041 public static bool SDL_AUDIO_ISBIGENDIAN(ushort x)
8042 {
8043 return (x & SDL_AUDIO_MASK_ENDIAN) != 0;
8044 }
8045
8046 public static bool SDL_AUDIO_ISSIGNED(ushort x)
8047 {
8048 return (x & SDL_AUDIO_MASK_SIGNED) != 0;
8049 }
8050
8051 public static bool SDL_AUDIO_ISINT(ushort x)
8052 {
8053 return (x & SDL_AUDIO_MASK_DATATYPE) == 0;
8054 }
8055
8056 public static bool SDL_AUDIO_ISLITTLEENDIAN(ushort x)
8057 {
8058 return (x & SDL_AUDIO_MASK_ENDIAN) == 0;
8059 }
8060
8061 public static bool SDL_AUDIO_ISUNSIGNED(ushort x)
8062 {
8063 return (x & SDL_AUDIO_MASK_SIGNED) == 0;
8064 }
8065
8066 public const ushort AUDIO_U8 = 0x0008;
8067 public const ushort AUDIO_S8 = 0x8008;
8068 public const ushort AUDIO_U16LSB = 0x0010;
8069 public const ushort AUDIO_S16LSB = 0x8010;
8070 public const ushort AUDIO_U16MSB = 0x1010;
8071 public const ushort AUDIO_S16MSB = 0x9010;
8072 public const ushort AUDIO_U16 = AUDIO_U16LSB;
8073 public const ushort AUDIO_S16 = AUDIO_S16LSB;
8074 public const ushort AUDIO_S32LSB = 0x8020;
8075 public const ushort AUDIO_S32MSB = 0x9020;
8076 public const ushort AUDIO_S32 = AUDIO_S32LSB;
8077 public const ushort AUDIO_F32LSB = 0x8120;
8078 public const ushort AUDIO_F32MSB = 0x9120;
8079 public const ushort AUDIO_F32 = AUDIO_F32LSB;
8080
8081 public static readonly ushort AUDIO_U16SYS =
8082 BitConverter.IsLittleEndian ? AUDIO_U16LSB : AUDIO_U16MSB;
8083 public static readonly ushort AUDIO_S16SYS =
8084 BitConverter.IsLittleEndian ? AUDIO_S16LSB : AUDIO_S16MSB;
8085 public static readonly ushort AUDIO_S32SYS =
8086 BitConverter.IsLittleEndian ? AUDIO_S32LSB : AUDIO_S32MSB;
8087 public static readonly ushort AUDIO_F32SYS =
8088 BitConverter.IsLittleEndian ? AUDIO_F32LSB : AUDIO_F32MSB;
8089
8090 public const uint SDL_AUDIO_ALLOW_FREQUENCY_CHANGE = 0x00000001;
8091 public const uint SDL_AUDIO_ALLOW_FORMAT_CHANGE = 0x00000002;
8092 public const uint SDL_AUDIO_ALLOW_CHANNELS_CHANGE = 0x00000004;
8093 public const uint SDL_AUDIO_ALLOW_SAMPLES_CHANGE = 0x00000008;
8094 public const uint SDL_AUDIO_ALLOW_ANY_CHANGE = (
8095 SDL_AUDIO_ALLOW_FREQUENCY_CHANGE |
8096 SDL_AUDIO_ALLOW_FORMAT_CHANGE |
8097 SDL_AUDIO_ALLOW_CHANNELS_CHANGE |
8098 SDL_AUDIO_ALLOW_SAMPLES_CHANGE
8099 );
8100
8101 public const int SDL_MIX_MAXVOLUME = 128;
8102
8103 public enum SDL_AudioStatus
8104 {
8105 SDL_AUDIO_STOPPED,
8106 SDL_AUDIO_PLAYING,
8107 SDL_AUDIO_PAUSED
8108 }
8109
8110 [StructLayout(LayoutKind.Sequential)]
8111 public struct SDL_AudioSpec
8112 {
8113 public int freq;
8114 public ushort format; // SDL_AudioFormat
8115 public byte channels;
8116 public byte silence;
8117 public ushort samples;
8118 public uint size;
8119 public SDL_AudioCallback callback;
8120 public IntPtr userdata; // void*
8121 }
8122
8123 /* userdata refers to a void*, stream to a Uint8 */
8124 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
8125 public delegate void SDL_AudioCallback(
8126 IntPtr userdata,
8127 IntPtr stream,
8128 int len
8129 );
8130
8131 [DllImport(nativeLibName, EntryPoint = "SDL_AudioInit", CallingConvention = CallingConvention.Cdecl)]
8132 private static extern unsafe int INTERNAL_SDL_AudioInit(
8133 byte* driver_name
8134 );
8135 public static unsafe int SDL_AudioInit(string driver_name)
8136 {
8137 int utf8DriverNameBufSize = Utf8Size(driver_name);
8138 byte* utf8DriverName = stackalloc byte[utf8DriverNameBufSize];
8139 return INTERNAL_SDL_AudioInit(
8140 Utf8Encode(driver_name, utf8DriverName, utf8DriverNameBufSize)
8141 );
8142 }
8143
8144 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8145 public static extern void SDL_AudioQuit();
8146
8147 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8148 public static extern void SDL_CloseAudio();
8149
8150 /* dev refers to an SDL_AudioDeviceID */
8151 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8152 public static extern void SDL_CloseAudioDevice(uint dev);
8153
8154 /* audio_buf refers to a malloc()'d buffer from SDL_LoadWAV */
8155 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8156 public static extern void SDL_FreeWAV(IntPtr audio_buf);
8157
8158 [DllImport(nativeLibName, EntryPoint = "SDL_GetAudioDeviceName", CallingConvention = CallingConvention.Cdecl)]
8159 private static extern IntPtr INTERNAL_SDL_GetAudioDeviceName(
8160 int index,
8161 int iscapture
8162 );
8163 public static string SDL_GetAudioDeviceName(
8164 int index,
8165 int iscapture
8166 ) {
8167 return UTF8_ToManaged(
8168 INTERNAL_SDL_GetAudioDeviceName(index, iscapture)
8169 );
8170 }
8171
8172 /* dev refers to an SDL_AudioDeviceID */
8173 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8174 public static extern SDL_AudioStatus SDL_GetAudioDeviceStatus(
8175 uint dev
8176 );
8177
8178 [DllImport(nativeLibName, EntryPoint = "SDL_GetAudioDriver", CallingConvention = CallingConvention.Cdecl)]
8179 private static extern IntPtr INTERNAL_SDL_GetAudioDriver(int index);
8180 public static string SDL_GetAudioDriver(int index)
8181 {
8182 return UTF8_ToManaged(
8183 INTERNAL_SDL_GetAudioDriver(index)
8184 );
8185 }
8186
8187 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8188 public static extern SDL_AudioStatus SDL_GetAudioStatus();
8189
8190 [DllImport(nativeLibName, EntryPoint = "SDL_GetCurrentAudioDriver", CallingConvention = CallingConvention.Cdecl)]
8191 private static extern IntPtr INTERNAL_SDL_GetCurrentAudioDriver();
8192 public static string SDL_GetCurrentAudioDriver()
8193 {
8194 return UTF8_ToManaged(INTERNAL_SDL_GetCurrentAudioDriver());
8195 }
8196
8197 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8198 public static extern int SDL_GetNumAudioDevices(int iscapture);
8199
8200 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8201 public static extern int SDL_GetNumAudioDrivers();
8202
8203 /* audio_buf refers to a malloc()'d buffer, IntPtr to an SDL_AudioSpec* */
8204 /* THIS IS AN RWops FUNCTION! */
8205 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8206 public static extern IntPtr SDL_LoadWAV_RW(
8207 IntPtr src,
8208 int freesrc,
8209 out SDL_AudioSpec spec,
8210 out IntPtr audio_buf,
8211 out uint audio_len
8212 );
8213 public static IntPtr SDL_LoadWAV(
8214 string file,
8215 out SDL_AudioSpec spec,
8216 out IntPtr audio_buf,
8217 out uint audio_len
8218 ) {
8219 IntPtr rwops = SDL_RWFromFile(file, "rb");
8220 return SDL_LoadWAV_RW(
8221 rwops,
8222 1,
8223 out spec,
8224 out audio_buf,
8225 out audio_len
8226 );
8227 }
8228
8229 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8230 public static extern void SDL_LockAudio();
8231
8232 /* dev refers to an SDL_AudioDeviceID */
8233 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8234 public static extern void SDL_LockAudioDevice(uint dev);
8235
8236 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8237 public static extern void SDL_MixAudio(
8238 [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 2)]
8239 byte[] dst,
8240 [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 2)]
8241 byte[] src,
8242 uint len,
8243 int volume
8244 );
8245
8246 /* format refers to an SDL_AudioFormat */
8247 /* This overload allows raw pointers to be passed for dst and src. */
8248 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8249 public static extern void SDL_MixAudioFormat(
8250 IntPtr dst,
8251 IntPtr src,
8252 ushort format,
8253 uint len,
8254 int volume
8255 );
8256
8257 /* format refers to an SDL_AudioFormat */
8258 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8259 public static extern void SDL_MixAudioFormat(
8260 [Out()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 3)]
8261 byte[] dst,
8262 [In()] [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 3)]
8263 byte[] src,
8264 ushort format,
8265 uint len,
8266 int volume
8267 );
8268
8269 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8270 public static extern int SDL_OpenAudio(
8271 ref SDL_AudioSpec desired,
8272 out SDL_AudioSpec obtained
8273 );
8274
8275 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8276 public static extern int SDL_OpenAudio(
8277 ref SDL_AudioSpec desired,
8278 IntPtr obtained
8279 );
8280
8281 /* uint refers to an SDL_AudioDeviceID */
8282 /* This overload allows for IntPtr.Zero (null) to be passed for device. */
8283 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8284 public static extern unsafe uint SDL_OpenAudioDevice(
8285 IntPtr device,
8286 int iscapture,
8287 ref SDL_AudioSpec desired,
8288 out SDL_AudioSpec obtained,
8289 int allowed_changes
8290 );
8291
8292 /* uint refers to an SDL_AudioDeviceID */
8293 [DllImport(nativeLibName, EntryPoint = "SDL_OpenAudioDevice", CallingConvention = CallingConvention.Cdecl)]
8294 private static extern unsafe uint INTERNAL_SDL_OpenAudioDevice(
8295 byte* device,
8296 int iscapture,
8297 ref SDL_AudioSpec desired,
8298 out SDL_AudioSpec obtained,
8299 int allowed_changes
8300 );
8301 public static unsafe uint SDL_OpenAudioDevice(
8302 string device,
8303 int iscapture,
8304 ref SDL_AudioSpec desired,
8305 out SDL_AudioSpec obtained,
8306 int allowed_changes
8307 ) {
8308 int utf8DeviceBufSize = Utf8Size(device);
8309 byte* utf8Device = stackalloc byte[utf8DeviceBufSize];
8310 return INTERNAL_SDL_OpenAudioDevice(
8311 Utf8Encode(device, utf8Device, utf8DeviceBufSize),
8312 iscapture,
8313 ref desired,
8314 out obtained,
8315 allowed_changes
8316 );
8317 }
8318
8319 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8320 public static extern void SDL_PauseAudio(int pause_on);
8321
8322 /* dev refers to an SDL_AudioDeviceID */
8323 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8324 public static extern void SDL_PauseAudioDevice(
8325 uint dev,
8326 int pause_on
8327 );
8328
8329 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8330 public static extern void SDL_UnlockAudio();
8331
8332 /* dev refers to an SDL_AudioDeviceID */
8333 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8334 public static extern void SDL_UnlockAudioDevice(uint dev);
8335
8336 /* dev refers to an SDL_AudioDeviceID, data to a void*
8337 * Only available in 2.0.4 or higher.
8338 */
8339 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8340 public static extern int SDL_QueueAudio(
8341 uint dev,
8342 IntPtr data,
8343 UInt32 len
8344 );
8345
8346 /* dev refers to an SDL_AudioDeviceID, data to a void*
8347 * Only available in 2.0.5 or higher.
8348 */
8349 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8350 public static extern uint SDL_DequeueAudio(
8351 uint dev,
8352 IntPtr data,
8353 uint len
8354 );
8355
8356 /* dev refers to an SDL_AudioDeviceID
8357 * Only available in 2.0.4 or higher.
8358 */
8359 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8360 public static extern UInt32 SDL_GetQueuedAudioSize(uint dev);
8361
8362 /* dev refers to an SDL_AudioDeviceID
8363 * Only available in 2.0.4 or higher.
8364 */
8365 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8366 public static extern void SDL_ClearQueuedAudio(uint dev);
8367
8368 /* src_format and dst_format refer to SDL_AudioFormats.
8369 * IntPtr refers to an SDL_AudioStream*.
8370 * Only available in 2.0.7 or higher.
8371 */
8372 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8373 public static extern IntPtr SDL_NewAudioStream(
8374 ushort src_format,
8375 byte src_channels,
8376 int src_rate,
8377 ushort dst_format,
8378 byte dst_channels,
8379 int dst_rate
8380 );
8381
8382 /* stream refers to an SDL_AudioStream*, buf to a void*.
8383 * Only available in 2.0.7 or higher.
8384 */
8385 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8386 public static extern int SDL_AudioStreamPut(
8387 IntPtr stream,
8388 IntPtr buf,
8389 int len
8390 );
8391
8392 /* stream refers to an SDL_AudioStream*, buf to a void*.
8393 * Only available in 2.0.7 or higher.
8394 */
8395 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8396 public static extern int SDL_AudioStreamGet(
8397 IntPtr stream,
8398 IntPtr buf,
8399 int len
8400 );
8401
8402 /* stream refers to an SDL_AudioStream*.
8403 * Only available in 2.0.7 or higher.
8404 */
8405 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8406 public static extern int SDL_AudioStreamAvailable(IntPtr stream);
8407
8408 /* stream refers to an SDL_AudioStream*.
8409 * Only available in 2.0.7 or higher.
8410 */
8411 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8412 public static extern void SDL_AudioStreamClear(IntPtr stream);
8413
8414 /* stream refers to an SDL_AudioStream*.
8415 * Only available in 2.0.7 or higher.
8416 */
8417 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8418 public static extern void SDL_FreeAudioStream(IntPtr stream);
8419
8420 /* Only available in 2.0.16 or higher. */
8421 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8422 public static extern int SDL_GetAudioDeviceSpec(
8423 int index,
8424 int iscapture,
8425 out SDL_AudioSpec spec
8426 );
8427
8428 #endregion
8429
8430 #region SDL_timer.h
8431
8432 /* System timers rely on different OS mechanisms depending on
8433 * which operating system SDL2 is compiled against.
8434 */
8435
8436 /* Compare tick values, return true if A has passed B. Introduced in SDL 2.0.1,
8437 * but does not require it (it was a macro).
8438 */
8439 public static bool SDL_TICKS_PASSED(UInt32 A, UInt32 B)
8440 {
8441 return ((Int32)(B - A) <= 0);
8442 }
8443
8444 /* Delays the thread's processing based on the milliseconds parameter */
8445 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8446 public static extern void SDL_Delay(UInt32 ms);
8447
8448 /* Returns the milliseconds that have passed since SDL was initialized */
8449 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8450 public static extern UInt32 SDL_GetTicks();
8451
8452 /* Returns the milliseconds that have passed since SDL was initialized
8453 * Only available in 2.0.18 or higher.
8454 */
8455 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8456 public static extern UInt64 SDL_GetTicks64();
8457
8458 /* Get the current value of the high resolution counter */
8459 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8460 public static extern UInt64 SDL_GetPerformanceCounter();
8461
8462 /* Get the count per second of the high resolution counter */
8463 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8464 public static extern UInt64 SDL_GetPerformanceFrequency();
8465
8466 /* param refers to a void* */
8467 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
8468 public delegate UInt32 SDL_TimerCallback(UInt32 interval, IntPtr param);
8469
8470 /* int refers to an SDL_TimerID, param to a void* */
8471 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8472 public static extern int SDL_AddTimer(
8473 UInt32 interval,
8474 SDL_TimerCallback callback,
8475 IntPtr param
8476 );
8477
8478 /* id refers to an SDL_TimerID */
8479 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8480 public static extern SDL_bool SDL_RemoveTimer(int id);
8481
8482 #endregion
8483
8484 #region SDL_system.h
8485
8486 /* Windows */
8487
8488 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
8489 public delegate IntPtr SDL_WindowsMessageHook(
8490 IntPtr userdata,
8491 IntPtr hWnd,
8492 uint message,
8493 ulong wParam,
8494 long lParam
8495 );
8496
8497 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8498 public static extern void SDL_SetWindowsMessageHook(
8499 SDL_WindowsMessageHook callback,
8500 IntPtr userdata
8501 );
8502
8503 /* renderer refers to an SDL_Renderer*
8504 * IntPtr refers to an IDirect3DDevice9*
8505 * Only available in 2.0.1 or higher.
8506 */
8507 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8508 public static extern IntPtr SDL_RenderGetD3D9Device(IntPtr renderer);
8509
8510 /* renderer refers to an SDL_Renderer*
8511 * IntPtr refers to an ID3D11Device*
8512 * Only available in 2.0.16 or higher.
8513 */
8514 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8515 public static extern IntPtr SDL_RenderGetD3D11Device(IntPtr renderer);
8516
8517 /* iOS */
8518
8519 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
8520 public delegate void SDL_iPhoneAnimationCallback(IntPtr p);
8521
8522 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8523 public static extern int SDL_iPhoneSetAnimationCallback(
8524 IntPtr window, /* SDL_Window* */
8525 int interval,
8526 SDL_iPhoneAnimationCallback callback,
8527 IntPtr callbackParam
8528 );
8529
8530 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8531 public static extern void SDL_iPhoneSetEventPump(SDL_bool enabled);
8532
8533 /* Android */
8534
8535 public const int SDL_ANDROID_EXTERNAL_STORAGE_READ = 0x01;
8536 public const int SDL_ANDROID_EXTERNAL_STORAGE_WRITE = 0x02;
8537
8538 /* IntPtr refers to a JNIEnv* */
8539 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8540 public static extern IntPtr SDL_AndroidGetJNIEnv();
8541
8542 /* IntPtr refers to a jobject */
8543 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8544 public static extern IntPtr SDL_AndroidGetActivity();
8545
8546 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8547 public static extern SDL_bool SDL_IsAndroidTV();
8548
8549 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8550 public static extern SDL_bool SDL_IsChromebook();
8551
8552 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8553 public static extern SDL_bool SDL_IsDeXMode();
8554
8555 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8556 public static extern void SDL_AndroidBackButton();
8557
8558 [DllImport(nativeLibName, EntryPoint = "SDL_AndroidGetInternalStoragePath", CallingConvention = CallingConvention.Cdecl)]
8559 private static extern IntPtr INTERNAL_SDL_AndroidGetInternalStoragePath();
8560
8561 public static string SDL_AndroidGetInternalStoragePath()
8562 {
8563 return UTF8_ToManaged(
8564 INTERNAL_SDL_AndroidGetInternalStoragePath()
8565 );
8566 }
8567
8568 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8569 public static extern int SDL_AndroidGetExternalStorageState();
8570
8571 [DllImport(nativeLibName, EntryPoint = "SDL_AndroidGetExternalStoragePath", CallingConvention = CallingConvention.Cdecl)]
8572 private static extern IntPtr INTERNAL_SDL_AndroidGetExternalStoragePath();
8573
8574 public static string SDL_AndroidGetExternalStoragePath()
8575 {
8576 return UTF8_ToManaged(
8577 INTERNAL_SDL_AndroidGetExternalStoragePath()
8578 );
8579 }
8580
8581 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8582 public static extern int SDL_GetAndroidSDKVersion();
8583
8584 /* Only available in 2.0.14 or higher. */
8585 [DllImport(nativeLibName, EntryPoint = "SDL_AndroidRequestPermission", CallingConvention = CallingConvention.Cdecl)]
8586 private static unsafe extern SDL_bool INTERNAL_SDL_AndroidRequestPermission(
8587 byte* permission
8588 );
8589 public static unsafe SDL_bool SDL_AndroidRequestPermission(
8590 string permission
8591 ) {
8592 byte* permissionPtr = Utf8EncodeHeap(permission);
8593 SDL_bool result = INTERNAL_SDL_AndroidRequestPermission(
8594 permissionPtr
8595 );
8596 Marshal.FreeHGlobal((IntPtr) permissionPtr);
8597 return result;
8598 }
8599
8600 /* Only available in 2.0.16 or higher. */
8601 [DllImport(nativeLibName, EntryPoint = "SDL_AndroidShowToast", CallingConvention = CallingConvention.Cdecl)]
8602 private static unsafe extern int INTERNAL_SDL_AndroidShowToast(
8603 byte* message,
8604 int duration,
8605 int gravity,
8606 int xOffset,
8607 int yOffset
8608 );
8609 public static unsafe int SDL_AndroidShowToast(
8610 string message,
8611 int duration,
8612 int gravity,
8613 int xOffset,
8614 int yOffset
8615 ) {
8616 byte* messagePtr = Utf8EncodeHeap(message);
8617 int result = INTERNAL_SDL_AndroidShowToast(
8618 messagePtr,
8619 duration,
8620 gravity,
8621 xOffset,
8622 yOffset
8623 );
8624 Marshal.FreeHGlobal((IntPtr) messagePtr);
8625 return result;
8626 }
8627
8628 /* WinRT */
8629
8630 public enum SDL_WinRT_DeviceFamily
8631 {
8632 SDL_WINRT_DEVICEFAMILY_UNKNOWN,
8633 SDL_WINRT_DEVICEFAMILY_DESKTOP,
8634 SDL_WINRT_DEVICEFAMILY_MOBILE,
8635 SDL_WINRT_DEVICEFAMILY_XBOX
8636 }
8637
8638 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8639 public static extern SDL_WinRT_DeviceFamily SDL_WinRTGetDeviceFamily();
8640
8641 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8642 public static extern SDL_bool SDL_IsTablet();
8643
8644 #endregion
8645
8646 #region SDL_syswm.h
8647
8648 public enum SDL_SYSWM_TYPE
8649 {
8650 SDL_SYSWM_UNKNOWN,
8651 SDL_SYSWM_WINDOWS,
8652 SDL_SYSWM_X11,
8653 SDL_SYSWM_DIRECTFB,
8654 SDL_SYSWM_COCOA,
8655 SDL_SYSWM_UIKIT,
8656 SDL_SYSWM_WAYLAND,
8657 SDL_SYSWM_MIR,
8658 SDL_SYSWM_WINRT,
8659 SDL_SYSWM_ANDROID,
8660 SDL_SYSWM_VIVANTE,
8661 SDL_SYSWM_OS2,
8662 SDL_SYSWM_HAIKU,
8663 SDL_SYSWM_KMSDRM /* requires >= 2.0.16 */
8664 }
8665
8666 // FIXME: I wish these weren't public...
8667 [StructLayout(LayoutKind.Sequential)]
8668 public struct INTERNAL_windows_wminfo
8669 {
8670 public IntPtr window; // Refers to an HWND
8671 public IntPtr hdc; // Refers to an HDC
8672 public IntPtr hinstance; // Refers to an HINSTANCE
8673 }
8674
8675 [StructLayout(LayoutKind.Sequential)]
8676 public struct INTERNAL_winrt_wminfo
8677 {
8678 public IntPtr window; // Refers to an IInspectable*
8679 }
8680
8681 [StructLayout(LayoutKind.Sequential)]
8682 public struct INTERNAL_x11_wminfo
8683 {
8684 public IntPtr display; // Refers to a Display*
8685 public IntPtr window; // Refers to a Window (XID, use ToInt64!)
8686 }
8687
8688 [StructLayout(LayoutKind.Sequential)]
8689 public struct INTERNAL_directfb_wminfo
8690 {
8691 public IntPtr dfb; // Refers to an IDirectFB*
8692 public IntPtr window; // Refers to an IDirectFBWindow*
8693 public IntPtr surface; // Refers to an IDirectFBSurface*
8694 }
8695
8696 [StructLayout(LayoutKind.Sequential)]
8697 public struct INTERNAL_cocoa_wminfo
8698 {
8699 public IntPtr window; // Refers to an NSWindow*
8700 }
8701
8702 [StructLayout(LayoutKind.Sequential)]
8703 public struct INTERNAL_uikit_wminfo
8704 {
8705 public IntPtr window; // Refers to a UIWindow*
8706 public uint framebuffer;
8707 public uint colorbuffer;
8708 public uint resolveFramebuffer;
8709 }
8710
8711 [StructLayout(LayoutKind.Sequential)]
8712 public struct INTERNAL_wayland_wminfo
8713 {
8714 public IntPtr display; // Refers to a wl_display*
8715 public IntPtr surface; // Refers to a wl_surface*
8716 public IntPtr shell_surface; // Refers to a wl_shell_surface*
8717 public IntPtr egl_window; // Refers to an egl_window*, requires >= 2.0.16
8718 public IntPtr xdg_surface; // Refers to an xdg_surface*, requires >= 2.0.16
8719 public IntPtr xdg_toplevel; // Referes to an xdg_toplevel*, requires >= 2.0.18
8720 public IntPtr xdg_popup;
8721 public IntPtr xdg_positioner;
8722 }
8723
8724 [StructLayout(LayoutKind.Sequential)]
8725 public struct INTERNAL_mir_wminfo
8726 {
8727 public IntPtr connection; // Refers to a MirConnection*
8728 public IntPtr surface; // Refers to a MirSurface*
8729 }
8730
8731 [StructLayout(LayoutKind.Sequential)]
8732 public struct INTERNAL_android_wminfo
8733 {
8734 public IntPtr window; // Refers to an ANativeWindow
8735 public IntPtr surface; // Refers to an EGLSurface
8736 }
8737
8738 [StructLayout(LayoutKind.Sequential)]
8739 public struct INTERNAL_vivante_wminfo
8740 {
8741 public IntPtr display; // Refers to an EGLNativeDisplayType
8742 public IntPtr window; // Refers to an EGLNativeWindowType
8743 }
8744
8745 /* Only available in 2.0.14 or higher. */
8746 [StructLayout(LayoutKind.Sequential)]
8747 public struct INTERNAL_os2_wminfo
8748 {
8749 public IntPtr hwnd; // Refers to an HWND
8750 public IntPtr hwndFrame; // Refers to an HWND
8751 }
8752
8753 /* Only available in 2.0.16 or higher. */
8754 [StructLayout(LayoutKind.Sequential)]
8755 public struct INTERNAL_kmsdrm_wminfo
8756 {
8757 int dev_index;
8758 int drm_fd;
8759 IntPtr gbm_dev; // Refers to a gbm_device*
8760 }
8761
8762 [StructLayout(LayoutKind.Explicit)]
8763 public struct INTERNAL_SysWMDriverUnion
8764 {
8765 [FieldOffset(0)]
8766 public INTERNAL_windows_wminfo win;
8767 [FieldOffset(0)]
8768 public INTERNAL_winrt_wminfo winrt;
8769 [FieldOffset(0)]
8770 public INTERNAL_x11_wminfo x11;
8771 [FieldOffset(0)]
8772 public INTERNAL_directfb_wminfo dfb;
8773 [FieldOffset(0)]
8774 public INTERNAL_cocoa_wminfo cocoa;
8775 [FieldOffset(0)]
8776 public INTERNAL_uikit_wminfo uikit;
8777 [FieldOffset(0)]
8778 public INTERNAL_wayland_wminfo wl;
8779 [FieldOffset(0)]
8780 public INTERNAL_mir_wminfo mir;
8781 [FieldOffset(0)]
8782 public INTERNAL_android_wminfo android;
8783 [FieldOffset(0)]
8784 public INTERNAL_os2_wminfo os2;
8785 [FieldOffset(0)]
8786 public INTERNAL_vivante_wminfo vivante;
8787 [FieldOffset(0)]
8788 public INTERNAL_kmsdrm_wminfo ksmdrm;
8789 // private int dummy;
8790 }
8791
8792 [StructLayout(LayoutKind.Sequential)]
8793 public struct SDL_SysWMinfo
8794 {
8795 public SDL_version version;
8796 public SDL_SYSWM_TYPE subsystem;
8797 public INTERNAL_SysWMDriverUnion info;
8798 }
8799
8800 /* window refers to an SDL_Window* */
8801 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8802 public static extern SDL_bool SDL_GetWindowWMInfo(
8803 IntPtr window,
8804 ref SDL_SysWMinfo info
8805 );
8806
8807 #endregion
8808
8809 #region SDL_filesystem.h
8810
8811 /* Only available in 2.0.1 or higher. */
8812 [DllImport(nativeLibName, EntryPoint = "SDL_GetBasePath", CallingConvention = CallingConvention.Cdecl)]
8813 private static extern IntPtr INTERNAL_SDL_GetBasePath();
8814 public static string SDL_GetBasePath()
8815 {
8816 return UTF8_ToManaged(INTERNAL_SDL_GetBasePath(), true);
8817 }
8818
8819 /* Only available in 2.0.1 or higher. */
8820 [DllImport(nativeLibName, EntryPoint = "SDL_GetPrefPath", CallingConvention = CallingConvention.Cdecl)]
8821 private static extern unsafe IntPtr INTERNAL_SDL_GetPrefPath(
8822 byte* org,
8823 byte* app
8824 );
8825 public static unsafe string SDL_GetPrefPath(string org, string app)
8826 {
8827 int utf8OrgBufSize = Utf8Size(org);
8828 byte* utf8Org = stackalloc byte[utf8OrgBufSize];
8829
8830 int utf8AppBufSize = Utf8Size(app);
8831 byte* utf8App = stackalloc byte[utf8AppBufSize];
8832
8833 return UTF8_ToManaged(
8834 INTERNAL_SDL_GetPrefPath(
8835 Utf8Encode(org, utf8Org, utf8OrgBufSize),
8836 Utf8Encode(app, utf8App, utf8AppBufSize)
8837 ),
8838 true
8839 );
8840 }
8841
8842 #endregion
8843
8844 #region SDL_power.h
8845
8846 public enum SDL_PowerState
8847 {
8848 SDL_POWERSTATE_UNKNOWN = 0,
8849 SDL_POWERSTATE_ON_BATTERY,
8850 SDL_POWERSTATE_NO_BATTERY,
8851 SDL_POWERSTATE_CHARGING,
8852 SDL_POWERSTATE_CHARGED
8853 }
8854
8855 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8856 public static extern SDL_PowerState SDL_GetPowerInfo(
8857 out int secs,
8858 out int pct
8859 );
8860
8861 #endregion
8862
8863 #region SDL_cpuinfo.h
8864
8865 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8866 public static extern int SDL_GetCPUCount();
8867
8868 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8869 public static extern int SDL_GetCPUCacheLineSize();
8870
8871 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8872 public static extern SDL_bool SDL_HasRDTSC();
8873
8874 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8875 public static extern SDL_bool SDL_HasAltiVec();
8876
8877 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8878 public static extern SDL_bool SDL_HasMMX();
8879
8880 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8881 public static extern SDL_bool SDL_Has3DNow();
8882
8883 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8884 public static extern SDL_bool SDL_HasSSE();
8885
8886 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8887 public static extern SDL_bool SDL_HasSSE2();
8888
8889 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8890 public static extern SDL_bool SDL_HasSSE3();
8891
8892 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8893 public static extern SDL_bool SDL_HasSSE41();
8894
8895 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8896 public static extern SDL_bool SDL_HasSSE42();
8897
8898 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8899 public static extern SDL_bool SDL_HasAVX();
8900
8901 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8902 public static extern SDL_bool SDL_HasAVX2();
8903
8904 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8905 public static extern SDL_bool SDL_HasAVX512F();
8906
8907 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8908 public static extern SDL_bool SDL_HasNEON();
8909
8910 /* Only available in 2.0.1 or higher. */
8911 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8912 public static extern int SDL_GetSystemRAM();
8913
8914 /* Only available in SDL 2.0.10 or higher. */
8915 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8916 public static extern uint SDL_SIMDGetAlignment();
8917
8918 /* Only available in SDL 2.0.10 or higher. */
8919 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8920 public static extern IntPtr SDL_SIMDAlloc(uint len);
8921
8922 /* Only available in SDL 2.0.14 or higher. */
8923 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8924 public static extern IntPtr SDL_SIMDRealloc(IntPtr ptr, uint len);
8925
8926 /* Only available in SDL 2.0.10 or higher. */
8927 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8928 public static extern void SDL_SIMDFree(IntPtr ptr);
8929
8930 /* Only available in SDL 2.0.11 or higher. */
8931 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8932 public static extern SDL_bool SDL_HasARMSIMD();
8933
8934 #endregion
8935
8936 #region SDL_locale.h
8937
8938 [StructLayout(LayoutKind.Sequential)]
8939 public struct SDL_Locale
8940 {
8941 IntPtr language;
8942 IntPtr country;
8943 }
8944
8945 /* IntPtr refers to an SDL_Locale*.
8946 * Only available in 2.0.14 or higher.
8947 */
8948 [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
8949 public static extern IntPtr SDL_GetPreferredLocales();
8950
8951 #endregion
8952
8953 #region SDL_misc.h
8954
8955 /* Only available in 2.0.14 or higher. */
8956 [DllImport(nativeLibName, EntryPoint = "SDL_OpenURL", CallingConvention = CallingConvention.Cdecl)]
8957 private static unsafe extern int INTERNAL_SDL_OpenURL(byte* url);
8958 public static unsafe int SDL_OpenURL(string url)
8959 {
8960 byte* urlPtr = Utf8EncodeHeap(url);
8961 int result = INTERNAL_SDL_OpenURL(urlPtr);
8962 Marshal.FreeHGlobal((IntPtr) urlPtr);
8963 return result;
8964 }
8965
8966 #endregion
8967 }
8968}