add code
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
build
|
||||||
|
recovery
|
||||||
|
BeefSpace_User.toml
|
||||||
|
CxxBuilderPath.toml
|
||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "SDL"]
|
||||||
|
path = SDL
|
||||||
|
url = https://github.com/libsdl-org/SDL.git
|
||||||
111
BeefProj.toml
Normal file
111
BeefProj.toml
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
FileVersion = 1
|
||||||
|
Dependencies = {corlib = "*", corlib = "*"}
|
||||||
|
|
||||||
|
[Project]
|
||||||
|
Name = "SDL3"
|
||||||
|
TargetType = "BeefLib"
|
||||||
|
StartupObject = "SDL3.Program"
|
||||||
|
|
||||||
|
[Configs.Debug.Win32]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.lib"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
PostBuildCmds = ["CopyToDependents(\"$(BuildDir)/SDL3.dll\")"]
|
||||||
|
|
||||||
|
[Configs.Debug.Win64]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.lib"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
PostBuildCmds = ["CopyToDependents(\"$(BuildDir)/SDL3.dll\")"]
|
||||||
|
|
||||||
|
[Configs.Debug.Linux32]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
|
||||||
|
[Configs.Debug.Linux64]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
|
||||||
|
[Configs.Debug.macOS]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
|
||||||
|
[Configs.Debug.wasm]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "c:\\Projects\\RandomStuff\\Cpp2Beef_dist\\CxxBuilder\\dist\\CxxBuilder.exe *.c */*.c */windows/*.c render/**.c -- \"cflags=-DSDL_PLATFORM_WINDOWS -I$(ProjectDir)/SDL/include -I$(ProjectDir)/SDL/include/build_config -I$(ProjectDir)/SDL/src\" output=SDL3 \"src=$(ProjectDir)/SDL/src\" \"builddir=$(BuildDir)\" target=$(TargetTriple)\""]
|
||||||
|
|
||||||
|
[Configs.Release.Win32]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.lib"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
PostBuildCmds = ["CopyToDependents(\"$(BuildDir)/SDL3.dll\")"]
|
||||||
|
|
||||||
|
[Configs.Release.Win64]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.lib"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
PostBuildCmds = ["CopyToDependents(\"$(BuildDir)/SDL3.dll\")"]
|
||||||
|
|
||||||
|
[Configs.Release.Linux32]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
|
||||||
|
[Configs.Release.Linux64]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
|
||||||
|
[Configs.Release.macOS]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
|
||||||
|
[Configs.Release.wasm]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "c:\\Projects\\RandomStuff\\Cpp2Beef_dist\\CxxBuilder\\dist\\CxxBuilder.exe *.c */*.c */windows/*.c render/**.c -- \"cflags=-DSDL_PLATFORM_WINDOWS -I$(ProjectDir)/SDL/include -I$(ProjectDir)/SDL/include/build_config -I$(ProjectDir)/SDL/src\" output=SDL3 \"src=$(ProjectDir)/SDL/src\" \"builddir=$(BuildDir)\" target=$(TargetTriple)\""]
|
||||||
|
|
||||||
|
[Configs.Paranoid.Win32]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.lib"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
PostBuildCmds = ["CopyToDependents(\"$(BuildDir)/SDL3.dll\")"]
|
||||||
|
|
||||||
|
[Configs.Paranoid.Win64]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.lib"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
PostBuildCmds = ["CopyToDependents(\"$(BuildDir)/SDL3.dll\")"]
|
||||||
|
|
||||||
|
[Configs.Paranoid.Linux32]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
|
||||||
|
[Configs.Paranoid.Linux64]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
|
||||||
|
[Configs.Paranoid.macOS]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
|
||||||
|
[Configs.Paranoid.wasm]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "c:\\Projects\\RandomStuff\\Cpp2Beef_dist\\CxxBuilder\\dist\\CxxBuilder.exe *.c */*.c */windows/*.c render/**.c -- \"cflags=-DSDL_PLATFORM_WINDOWS -I$(ProjectDir)/SDL/include -I$(ProjectDir)/SDL/include/build_config -I$(ProjectDir)/SDL/src\" output=SDL3 \"src=$(ProjectDir)/SDL/src\" \"builddir=$(BuildDir)\" target=$(TargetTriple)\""]
|
||||||
|
|
||||||
|
[Configs.Test.Win32]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.lib"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
PostBuildCmds = ["CopyToDependents(\"$(BuildDir)/SDL3.dll\")"]
|
||||||
|
|
||||||
|
[Configs.Test.Win64]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.lib"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
PostBuildCmds = ["CopyToDependents(\"$(BuildDir)/SDL3.dll\")"]
|
||||||
|
|
||||||
|
[Configs.Test.Linux32]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
|
||||||
|
[Configs.Test.Linux64]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
|
||||||
|
[Configs.Test.macOS]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "Execute(\"$(Var CxxBuilderPath) --cmake -- output=SDL3 \\\"src=$(ProjectDir)/SDL\\\" \\\"builddir=$(BuildDir)\\\" target=$(TargetTriple) config=$(Configuration)\")"]
|
||||||
|
|
||||||
|
[Configs.Test.wasm]
|
||||||
|
LibPaths = ["$(BuildDir)/SDL3.a"]
|
||||||
|
PreBuildCmds = ["ReadFile(\"$(ProjectDir)/CxxBuilderPath.txt\", \"CxxBuilderPath\")", "c:\\Projects\\RandomStuff\\Cpp2Beef_dist\\CxxBuilder\\dist\\CxxBuilder.exe *.c */*.c */windows/*.c render/**.c -- \"cflags=-DSDL_PLATFORM_WINDOWS -I$(ProjectDir)/SDL/include -I$(ProjectDir)/SDL/include/build_config -I$(ProjectDir)/SDL/src\" output=SDL3 \"src=$(ProjectDir)/SDL/src\" \"builddir=$(BuildDir)\" target=$(TargetTriple)\""]
|
||||||
6
BeefSpace.toml
Normal file
6
BeefSpace.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
FileVersion = 1
|
||||||
|
Projects = {SDL3 = {Path = "."}}
|
||||||
|
ExtraPlatforms = ["Linux32", "Linux64", "macOS", "wasm"]
|
||||||
|
|
||||||
|
[Workspace]
|
||||||
|
StartupProject = "SDL3"
|
||||||
1
CxxBuilderPath.txt
Normal file
1
CxxBuilderPath.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
C:\Users\EW\AppData\Local\BeefLang\BeefManaged\fa90624c843b959aed47a6441dc4c79b92059d61\CxxBuilder\dist\CxxBuilder.exe
|
||||||
3
Example/.gitignore
vendored
Normal file
3
Example/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
build
|
||||||
|
recovery
|
||||||
|
BeefSpace_User.toml
|
||||||
7
Example/BeefProj.toml
Normal file
7
Example/BeefProj.toml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
FileVersion = 1
|
||||||
|
Dependencies = {corlib = "*", SDL3 = "*"}
|
||||||
|
|
||||||
|
[Project]
|
||||||
|
Name = "SDL3.Example"
|
||||||
|
TargetType = "BeefGUIApplication"
|
||||||
|
StartupObject = "SDL3.Example.Program"
|
||||||
6
Example/BeefSpace.toml
Normal file
6
Example/BeefSpace.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
FileVersion = 1
|
||||||
|
Projects = {"SDL3.Example" = {Path = "."}, SDL3 = {Path = ".."}}
|
||||||
|
ExtraPlatforms = ["Linux32", "Linux64", "macOS"]
|
||||||
|
|
||||||
|
[Workspace]
|
||||||
|
StartupProject = "SDL3.Example"
|
||||||
81
Example/src/Program.bf
Normal file
81
Example/src/Program.bf
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
using SDL3;
|
||||||
|
|
||||||
|
namespace SDL3.Example;
|
||||||
|
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* This example code creates an SDL window and renderer, and then clears the
|
||||||
|
* window to a different color every frame, so you'll effectively get a window
|
||||||
|
* that's smoothly fading between colors.
|
||||||
|
*
|
||||||
|
* This code is public domain. Feel free to use it for any purpose!
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* We will use this renderer to draw into this window every frame. */
|
||||||
|
static SDL.Window *window = null;
|
||||||
|
static SDL.Renderer *renderer = null;
|
||||||
|
|
||||||
|
/* This function runs once at startup. */
|
||||||
|
static SDL.AppResult AppInit(void **appstate, int32 argc, char8 **argv)
|
||||||
|
{
|
||||||
|
SDL.SetAppMetadata("Example Renderer Clear", "1.0", "com.example.renderer-clear");
|
||||||
|
|
||||||
|
if (!SDL.Init(.Video)) {
|
||||||
|
SDL.Log("Couldn't initialize SDL: %s", SDL.GetError());
|
||||||
|
return .Failure;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SDL.CreateWindowAndRenderer("examples/renderer/clear", 640, 480, .Resizable, &window, &renderer)) {
|
||||||
|
SDL.Log("Couldn't create window/renderer: %s", SDL.GetError());
|
||||||
|
return .Failure;
|
||||||
|
}
|
||||||
|
SDL.SetRenderLogicalPresentation(renderer, 640, 480, .Letterbox);
|
||||||
|
|
||||||
|
return .Continue; /* carry on with the program! */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
|
||||||
|
static SDL.AppResult AppEvent(void *appstate, SDL.Event *event)
|
||||||
|
{
|
||||||
|
if (event.type == (.)SDL.EventType.Quit) {
|
||||||
|
return .Success; /* end the program, reporting success to the OS. */
|
||||||
|
}
|
||||||
|
return .Continue; /* carry on with the program! */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function runs once per frame, and is the heart of the program. */
|
||||||
|
static SDL.AppResult AppIterate(void *appstate)
|
||||||
|
{
|
||||||
|
double now = ((double)SDL.GetTicks()) / 1000.0; /* convert from milliseconds to seconds. */
|
||||||
|
/* choose the color for the frame we will draw. The sine wave trick makes it fade between colors smoothly. */
|
||||||
|
float red = (float) (0.5 + 0.5 * SDL.sin(now));
|
||||||
|
float green = (float) (0.5 + 0.5 * SDL.sin(now + SDL.PI_D * 2 / 3));
|
||||||
|
float blue = (float) (0.5 + 0.5 * SDL.sin(now + SDL.PI_D * 4 / 3));
|
||||||
|
SDL.SetRenderDrawColorFloat(renderer, red, green, blue, SDL.ALPHA_OPAQUE_FLOAT); /* new color, full alpha. */
|
||||||
|
|
||||||
|
/* clear the window to the draw color. */
|
||||||
|
SDL.RenderClear(renderer);
|
||||||
|
|
||||||
|
/* put the newly-cleared rendering on the screen. */
|
||||||
|
SDL.RenderPresent(renderer);
|
||||||
|
|
||||||
|
return .Continue; /* carry on with the program! */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function runs once at shutdown. */
|
||||||
|
static void AppQuit(void *appstate, SDL.AppResult result)
|
||||||
|
{
|
||||||
|
/* SDL will clean up the window/renderer for us. */
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int Main(String[] args)
|
||||||
|
{
|
||||||
|
char8*[] argv = scope .[args.Count];
|
||||||
|
for (var arg in ref argv)
|
||||||
|
arg = args[@arg].Ptr;
|
||||||
|
return SDL.EnterAppMainCallbacks((.)argv.Count, argv.Ptr, => AppInit, => AppIterate, => AppEvent, => AppQuit);
|
||||||
|
}
|
||||||
|
}
|
||||||
1
SDL
Submodule
1
SDL
Submodule
Submodule SDL added at c20a058ff4
5
Setup/.gitignore
vendored
Normal file
5
Setup/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
build
|
||||||
|
recovery
|
||||||
|
BeefSpace_User.toml
|
||||||
|
BeefSpace_Lock.toml
|
||||||
|
SDL3_all.h
|
||||||
66
Setup/BeefProj.toml
Normal file
66
Setup/BeefProj.toml
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
FileVersion = 1
|
||||||
|
Dependencies = {corlib = "*", "Cpp2Beef.git" = {Git = "https://git.unicon-gmbh.de/BeefBindings/Cpp2Beef.git"}}
|
||||||
|
|
||||||
|
[Project]
|
||||||
|
Name = "SDL3.Setup"
|
||||||
|
StartupObject = "SDL3.Setup.Program"
|
||||||
|
|
||||||
|
[Configs.Debug.Win32]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Debug.Win64]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/CxxBuilderPath.txt $(WorkspaceDir)/../CxxBuilderPath.txt"]
|
||||||
|
|
||||||
|
[Configs.Debug.Linux32]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Debug.Linux64]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Debug.macOS]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Release.Win32]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Release.Win64]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Release.Linux32]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Release.Linux64]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Release.macOS]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Paranoid.Win32]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Paranoid.Win64]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Paranoid.Linux32]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Paranoid.Linux64]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Paranoid.macOS]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Test.Win32]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Test.Win64]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Test.Linux32]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Test.Linux64]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
|
|
||||||
|
[Configs.Test.macOS]
|
||||||
|
PostBuildCmds = ["cp $(ProjectDir Cpp2Beef)/CxxBuilder/dist/SetCxxBuilderExe.beefscript $(WorkspaceDir)/../SetCxxBuilderExe.beefscript"]
|
||||||
6
Setup/BeefSpace.toml
Normal file
6
Setup/BeefSpace.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
FileVersion = 1
|
||||||
|
Projects = {"SDL3.Setup" = {Path = "."}, "Clang-C.git" = {Git = "https://git.unicon-gmbh.de/BeefBindings/Clang-C.git"}, "Cpp2Beef.git" = {Git = "https://git.unicon-gmbh.de/BeefBindings/Cpp2Beef.git"}}
|
||||||
|
ExtraPlatforms = ["Linux32", "Linux64", "macOS"]
|
||||||
|
|
||||||
|
[Workspace]
|
||||||
|
StartupProject = "SDL3.Setup"
|
||||||
353
Setup/src/Program.bf
Normal file
353
Setup/src/Program.bf
Normal file
@@ -0,0 +1,353 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
using Cpp2Beef;
|
||||||
|
using LibClang;
|
||||||
|
|
||||||
|
namespace SDL3.Setup;
|
||||||
|
|
||||||
|
class SDL3Generator : Cpp2BeefGenerator, this(Span<char8*> args)
|
||||||
|
{
|
||||||
|
protected override Span<char8*> Args => args;
|
||||||
|
protected override Flags Flags => .None;
|
||||||
|
|
||||||
|
private BumpAllocator alloc = new .() ~ delete _;
|
||||||
|
|
||||||
|
append Dictionary<String, StreamWriter> writers = .(16);
|
||||||
|
protected override StreamWriter GetWriterForHeader(StringView header)
|
||||||
|
{
|
||||||
|
String filename = Path.GetFileNameWithoutExtension(header, ..scope .(64));
|
||||||
|
if (!filename.StartsWith("SDL_") || filename == "SDL_begin_code") return null;
|
||||||
|
if (writers.TryAdd(filename, let keyPtr, let valuePtr))
|
||||||
|
{
|
||||||
|
*keyPtr = new:alloc .(filename);
|
||||||
|
*valuePtr = new:alloc .()..Create(scope $"../src/{filename}.bf")..Write("""
|
||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
|
||||||
|
""");
|
||||||
|
}
|
||||||
|
return *valuePtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Block GetCursorBlock(CXCursor cursor)
|
||||||
|
{
|
||||||
|
if (Path.GetFileName(GetFilePath!(fileInfo.file), ..scope .(128)).StartsWith("SDL_test"))
|
||||||
|
return .CustomBlock("SDLTest");
|
||||||
|
return .CustomBlock("SDL");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void HandleCursor(CXCursor cursor)
|
||||||
|
{
|
||||||
|
switch (cursor.kind)
|
||||||
|
{
|
||||||
|
case .MacroDefinition:
|
||||||
|
if (Clang.Cursor_IsMacroFunctionLike(cursor) != 0 && GetFilePath!(fileInfo.file).EndsWith("SDL_version.h"))
|
||||||
|
{
|
||||||
|
BeginCursor(cursor);
|
||||||
|
let tokens = ScopeTokenize!(cursor, unit);
|
||||||
|
WriteCustomAttributes(cursor);
|
||||||
|
str.Append("public static ");
|
||||||
|
if (GetCursorSpelling!(cursor) == "SDL_VERSION_ATLEAST")
|
||||||
|
str.Append("bool ");
|
||||||
|
else
|
||||||
|
str.Append("c_int ");
|
||||||
|
GetNameInBindings(cursor, str);
|
||||||
|
bool inArgs = true;
|
||||||
|
for (let token in tokens[1...])
|
||||||
|
{
|
||||||
|
if (inArgs)
|
||||||
|
{
|
||||||
|
let spelling = GetTokenSpelling!(token);
|
||||||
|
if (spelling == ")")
|
||||||
|
{
|
||||||
|
inArgs = false;
|
||||||
|
str.Append(") => ");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (Clang.GetTokenKind(token) == .Identifier)
|
||||||
|
str.Append("c_int ");
|
||||||
|
str.Append(spelling);
|
||||||
|
if (spelling == ",")
|
||||||
|
str.Append(' ');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
WriteToken(token);
|
||||||
|
}
|
||||||
|
str.Append(';');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let spelling = GetCursorSpelling!(cursor);
|
||||||
|
if (spelling.StartsWith("SDL_PRI") || spelling.StartsWith("VK_DEFINE_"))
|
||||||
|
return;
|
||||||
|
switch (spelling)
|
||||||
|
{
|
||||||
|
case "FONT_LINE_HEIGHT":
|
||||||
|
BeginCursor(cursor);
|
||||||
|
str.Append("public static c_int FONT_LINE_HEIGHT => (FONT_CHARACTER_SIZE + 2);");
|
||||||
|
return;
|
||||||
|
case "PFN_xrGetInstanceProcAddr":
|
||||||
|
BeginCursor(cursor);
|
||||||
|
str.Append("public typealias PFN_xrGetInstanceProcAddr = SDL.FunctionPointer;");
|
||||||
|
return;
|
||||||
|
case "main", "SDL_SIZE_MAX", "SDL_FUNCTION", "SDL_FILE", "SDL_ASSERT_FILE", "SDL_LINE", "SDL_SCOPED_CAPABILITY", "SDL_NO_THREAD_SAFETY_ANALYSIS":
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case .TypedefDecl:
|
||||||
|
String prefix = scope .(64);
|
||||||
|
var spelling = GetCursorSpelling!(cursor);
|
||||||
|
|
||||||
|
if (spelling == "SDL_Keycode")
|
||||||
|
prefix.Set("SDLK_");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!spelling.StartsWith("SDL_")) fallthrough;
|
||||||
|
spelling.RemoveFromStart(4);
|
||||||
|
|
||||||
|
/*if (GetTypeSpelling!(Clang.GetTypedefDeclUnderlyingType(cursor)) != "Uint32")
|
||||||
|
fallthrough;*/
|
||||||
|
|
||||||
|
if (spelling == "TrayEntryFlags")
|
||||||
|
spelling = "Trayentry";
|
||||||
|
else if (spelling == "MouseButtonFlags")
|
||||||
|
spelling = "Button";
|
||||||
|
else if (spelling.EndsWith("Flags"))
|
||||||
|
spelling.RemoveFromEnd(5);
|
||||||
|
else if (spelling.EndsWith("Flag"))
|
||||||
|
spelling.RemoveFromEnd(4);
|
||||||
|
/*else if (spelling.EndsWith("ID"))
|
||||||
|
spelling.RemoveFromEnd(2);*/
|
||||||
|
else if (spelling == "BlendMode")
|
||||||
|
spelling = "Blendmode";
|
||||||
|
else if (spelling == "GLContextResetNotification")
|
||||||
|
spelling = "GlContextReset";
|
||||||
|
else if (spelling == "GLProfile")
|
||||||
|
spelling = "GlContextProfile";
|
||||||
|
else if (spelling == "Keycode")
|
||||||
|
spelling = "K";
|
||||||
|
else if (spelling != "GPUShaderFormat")
|
||||||
|
fallthrough;
|
||||||
|
if (spelling.StartsWith("GL"))
|
||||||
|
{
|
||||||
|
spelling = scope:: String(spelling);
|
||||||
|
spelling[1] = 'l';
|
||||||
|
}
|
||||||
|
|
||||||
|
prefix.Append("SDL");
|
||||||
|
if (spelling.StartsWith("GPU"))
|
||||||
|
{
|
||||||
|
prefix.Append("_GPU_");
|
||||||
|
for (let c in spelling[3...])
|
||||||
|
prefix.Append(c.ToUpper);
|
||||||
|
prefix.Append('_');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (let c in spelling)
|
||||||
|
{
|
||||||
|
if (c.IsUpper) prefix.Append('_');
|
||||||
|
prefix.Append(c.ToUpper);
|
||||||
|
}
|
||||||
|
prefix.Append('_');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BeginCursor(cursor);
|
||||||
|
if (spelling == "Button") str.Append("[AllowDuplicates] ");
|
||||||
|
AccessSpecifier(cursor);
|
||||||
|
str.Append("enum ");
|
||||||
|
GetNameInBindings(cursor, str);
|
||||||
|
str.Append(" : ");
|
||||||
|
Type(Clang.GetTypedefDeclUnderlyingType(cursor));
|
||||||
|
void FixCurly()
|
||||||
|
{
|
||||||
|
if (fileInfo.queuedTokens.HasFlag(.LSquirly))
|
||||||
|
str.Append("\n{");
|
||||||
|
if (fileInfo.queuedTokens.HasFlag(.RSquirly))
|
||||||
|
str.Append("\n}");
|
||||||
|
else
|
||||||
|
str.Append("\n\t");
|
||||||
|
fileInfo.queuedTokens = .None;
|
||||||
|
}
|
||||||
|
bool isSDL_GLContextFlag = spelling == "GlContext";
|
||||||
|
{
|
||||||
|
BeginBody!(cursor);
|
||||||
|
for (let macro in this.[Friend]unitMacros)
|
||||||
|
{
|
||||||
|
let macroCursor = macro.value;
|
||||||
|
if (Clang.Cursor_IsMacroFunctionLike(macroCursor) != 0)
|
||||||
|
continue;
|
||||||
|
if (Clang.GetFileLocation(Clang.GetCursorLocation(macroCursor), ..?, ?, ?, ?) != fileInfo.file)
|
||||||
|
continue;
|
||||||
|
var macroSpelling = GetCursorSpelling!(macroCursor);
|
||||||
|
if (!macroSpelling.StartsWith(prefix))
|
||||||
|
continue;
|
||||||
|
if (isSDL_GLContextFlag)
|
||||||
|
{
|
||||||
|
if (!macroSpelling.EndsWith("_FLAG"))
|
||||||
|
continue;
|
||||||
|
macroSpelling.RemoveFromEnd(5);
|
||||||
|
}
|
||||||
|
macroSpelling.RemoveFromStart(prefix.Length);
|
||||||
|
BeginCursor(macroCursor);
|
||||||
|
FixCurly();
|
||||||
|
if (macroSpelling[0].IsDigit) str.Append('_');
|
||||||
|
UpperSnakeCase2PascalCase(macroSpelling, str);
|
||||||
|
let tokens = ScopeTokenize!(macroCursor, unit);
|
||||||
|
AllWhiteSpaceBetween(Clang.GetRangeEnd(Clang.GetTokenExtent(unit, tokens[0])), Clang.GetRangeStart(Clang.GetTokenExtent(unit, tokens[1])));
|
||||||
|
str.Append("= ");
|
||||||
|
WriteTokens(tokens[1...], Clang.GetNullLocation(), .Punctuation);
|
||||||
|
str.Append(',');
|
||||||
|
@macro.Remove();
|
||||||
|
WriteComments(Clang.GetCursorLocation(macroCursor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FixCurly();
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
base.HandleCursor(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void GetNameInBindings(CXCursor cursor, String outString)
|
||||||
|
{
|
||||||
|
bool RemovePrefix(ref StringView view)
|
||||||
|
{
|
||||||
|
if (view.StartsWith("SDLTest_")) view.RemoveFromStart(8);
|
||||||
|
else if (view.StartsWith("SDL_")) view.RemoveFromStart(4);
|
||||||
|
else return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var spelling = GetCursorSpelling!(cursor);
|
||||||
|
if (!RemovePrefix(ref spelling))
|
||||||
|
{
|
||||||
|
if (cursor.kind == .MacroDefinition)
|
||||||
|
switch (spelling)
|
||||||
|
{
|
||||||
|
case "NULL": outString.Append("null"); return;
|
||||||
|
case "TRUE": outString.Append("true"); return;
|
||||||
|
case "FALSE": outString.Append("false"); return;
|
||||||
|
}
|
||||||
|
base.GetNameInBindings(cursor, outString);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (cursor.kind)
|
||||||
|
{
|
||||||
|
case .EnumConstantDecl:
|
||||||
|
var parentSpelling = GetCursorSpelling!(Clang.GetCursorSemanticParent(cursor));
|
||||||
|
if (parentSpelling == "SDL_GPUTextureFormat")
|
||||||
|
{
|
||||||
|
spelling.RemoveFromStart("GPU_TEXTUREFORMAT_".Length);
|
||||||
|
outString.Append(spelling);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringView name = UpperSnakeCase2PascalCase(spelling, ..scope .(spelling.Length));
|
||||||
|
switch (parentSpelling)
|
||||||
|
{
|
||||||
|
case "SDL_AudioFormat": parentSpelling = "Audio";
|
||||||
|
case "SDL_AssertState": parentSpelling = "Assertion";
|
||||||
|
case "SDL_GamepadBindingType": parentSpelling = "GamepadBindtype";
|
||||||
|
case "SDL_RendererLogicalPresentation": parentSpelling = "LogicalPresentation";
|
||||||
|
default:
|
||||||
|
RemovePrefix(ref parentSpelling);
|
||||||
|
}
|
||||||
|
for (let c in parentSpelling)
|
||||||
|
{
|
||||||
|
if (name[0].ToLower == c.ToLower)
|
||||||
|
name.RemoveFromStart(1);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (name[0].IsDigit)
|
||||||
|
outString.Append('_');
|
||||||
|
outString.Append(name);
|
||||||
|
default:
|
||||||
|
outString.Append(spelling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void WriteToken(CXToken token)
|
||||||
|
{
|
||||||
|
var spelling = GetTokenSpelling!(token);
|
||||||
|
switch (spelling)
|
||||||
|
{
|
||||||
|
case "size_t": str.Append("c_size"); return;
|
||||||
|
case "SDL_BUTTON_LEFT": str.Append("Left"); return;
|
||||||
|
case "SDL_BUTTON_MIDDLE": str.Append("Middle"); return;
|
||||||
|
case "SDL_BUTTON_RIGHT": str.Append("Right"); return;
|
||||||
|
case "SDL_BUTTON_X1": str.Append("X1"); return;
|
||||||
|
case "SDL_BUTTON_X2": str.Append("X2"); return;
|
||||||
|
}
|
||||||
|
if (!spelling.StartsWith("SDL_") || !spelling.EndsWith("ID"))
|
||||||
|
{
|
||||||
|
base.WriteToken(token);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
spelling.RemoveFromStart(4);
|
||||||
|
str.Append("SDL.");
|
||||||
|
str.Append(spelling);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool IsOutParam(CXCursor arg, CXCursor method)
|
||||||
|
{
|
||||||
|
let comment = Clang.Cursor_GetParsedComment(method);
|
||||||
|
let spelling = GetCursorSpelling!(arg);
|
||||||
|
for (let i < Clang.Comment_GetNumChildren(comment))
|
||||||
|
{
|
||||||
|
let param = Clang.Comment_GetChild(comment, i);
|
||||||
|
if (Clang.Comment_GetKind(param) != .ParamCommand ||
|
||||||
|
ScopeCXString!(Clang.ParamCommandComment_GetParamName(param)) != spelling) continue;
|
||||||
|
let paragraph = Clang.BlockCommandComment_GetParagraph(param);
|
||||||
|
if (Clang.Comment_GetNumChildren(paragraph) == 0) continue;
|
||||||
|
let paragraphChild = Clang.Comment_GetChild(paragraph, 0);
|
||||||
|
if (Clang.Comment_GetKind(paragraphChild) != .Text) continue;
|
||||||
|
StringView paragraphText = ScopeCXString!(Clang.TextComment_GetText(paragraphChild))..TrimStart();
|
||||||
|
if (paragraphText.StartsWith("a pointer filled in") || paragraphText.StartsWith("a pointer to receive")) return true;
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
return base.IsOutParam(arg, method);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
[CLink] static extern int32 system(char8*);
|
||||||
|
|
||||||
|
public static int Main(String[] args)
|
||||||
|
{
|
||||||
|
//Runtime.Assert(system("git -C .. submodule update") == 0, "Failed to fetch SDL3, check your internet connection");
|
||||||
|
|
||||||
|
{
|
||||||
|
StreamWriter all = scope .()..Create("SDL3_all.h");
|
||||||
|
for (let file in Directory.EnumerateFiles("../SDL/include/SDL3"))
|
||||||
|
{
|
||||||
|
let filename = file.GetFileName(..scope .(64));
|
||||||
|
if (filename == "SDL_oldnames.h" || filename == "SDL_egl.h" || filename == "SDL_intrin.h" || filename == "SDL_endian.h" ||
|
||||||
|
filename == "SDL_platform_defines.h" || filename == "SDL_begin_code.h" || filename == "SDL_close_code.h" || filename.StartsWith("SDL_opengl"))
|
||||||
|
continue;
|
||||||
|
all.Write("#include <SDL3/");
|
||||||
|
all.Write(filename);
|
||||||
|
all.Write(">\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL3Generator generator = scope .(char8*[?]("--language=c", "-I../SDL/include",
|
||||||
|
"-DSDL_oldnames_h_", "-DSDL_platform_defines_h_", "-DSDL_endian_h_",
|
||||||
|
"-DCrcUint32=Uint32", "-DCrcUint8=Uint8",
|
||||||
|
"-DSDL_SLOW_MEMCPY", "-DSDL_SLOW_MEMMOVE", "-DSDL_SLOW_MEMSET", "-DSDL_DISABLE_ALLOCA", "-DSDL_DISABLE_ANALYZE_MACROS"));
|
||||||
|
generator.Generate("SDL3_all.h", null);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
19
src/Library.bf
Normal file
19
src/Library.bf
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
static class SDL
|
||||||
|
{
|
||||||
|
private static Sint64 SINT64_C(Sint64 n) => n;
|
||||||
|
private static Uint64 UINT64_C(Uint64 n) => n;
|
||||||
|
|
||||||
|
typealias CrcUint32 = Uint32;
|
||||||
|
typealias CrcUint8 = Uint8;
|
||||||
|
|
||||||
|
private static Uint32 BUTTON_MASK(MouseButtonFlags X) => (.)(1u << (((Uint32)X)-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
static class SDLTest
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
701
src/SDL_assert.bf
Normal file
701
src/SDL_assert.bf
Normal file
@@ -0,0 +1,701 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryAssert
|
||||||
|
*
|
||||||
|
* A helpful assertion macro!
|
||||||
|
*
|
||||||
|
* SDL assertions operate like your usual `assert` macro, but with some added
|
||||||
|
* features:
|
||||||
|
*
|
||||||
|
* - It uses a trick with the `sizeof` operator, so disabled assertions
|
||||||
|
* vaporize out of the compiled code, but variables only referenced in the
|
||||||
|
* assertion won't trigger compiler warnings about being unused.
|
||||||
|
* - It is safe to use with a dangling-else: `if (x) SDL_assert(y); else
|
||||||
|
* do_something();`
|
||||||
|
* - It works the same everywhere, instead of counting on various platforms'
|
||||||
|
* compiler and C runtime to behave.
|
||||||
|
* - It provides multiple levels of assertion (SDL_assert, SDL_assert_release,
|
||||||
|
* SDL_assert_paranoid) instead of a single all-or-nothing option.
|
||||||
|
* - It offers a variety of responses when an assertion fails (retry, trigger
|
||||||
|
* the debugger, abort the program, ignore the failure once, ignore it for
|
||||||
|
* the rest of the program's run).
|
||||||
|
* - It tries to show the user a dialog by default, if possible, but the app
|
||||||
|
* can provide a callback to handle assertion failures however they like.
|
||||||
|
* - It lets failed assertions be retried. Perhaps you had a network failure
|
||||||
|
* and just want to retry the test after plugging your network cable back
|
||||||
|
* in? You can.
|
||||||
|
* - It lets the user ignore an assertion failure, if there's a harmless
|
||||||
|
* problem that one can continue past.
|
||||||
|
* - It lets the user mark an assertion as ignored for the rest of the
|
||||||
|
* program's run; if there's a harmless problem that keeps popping up.
|
||||||
|
* - It provides statistics and data on all failed assertions to the app.
|
||||||
|
* - It allows the default assertion handler to be controlled with environment
|
||||||
|
* variables, in case an automated script needs to control it.
|
||||||
|
* - It can be used as an aid to Clang's static analysis; it will treat SDL
|
||||||
|
* assertions as universally true (under the assumption that you are serious
|
||||||
|
* about the asserted claims and that your debug builds will detect when
|
||||||
|
* these claims were wrong). This can help the analyzer avoid false
|
||||||
|
* positives.
|
||||||
|
*
|
||||||
|
* To use it: compile a debug build and just sprinkle around tests to check
|
||||||
|
* your code!
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The level of assertion aggressiveness.
|
||||||
|
*
|
||||||
|
* This value changes depending on compiler options and other preprocessor
|
||||||
|
* defines.
|
||||||
|
*
|
||||||
|
* It is currently one of the following values, but future SDL releases might
|
||||||
|
* add more:
|
||||||
|
*
|
||||||
|
* - 0: All SDL assertion macros are disabled.
|
||||||
|
* - 1: Release settings: SDL_assert disabled, SDL_assert_release enabled.
|
||||||
|
* - 2: Debug settings: SDL_assert and SDL_assert_release enabled.
|
||||||
|
* - 3: Paranoid settings: All SDL assertion macros enabled, including
|
||||||
|
* SDL_assert_paranoid.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public const let ASSERT_LEVEL = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to tell an attached debugger to pause.
|
||||||
|
*
|
||||||
|
* This allows an app to programmatically halt ("break") the debugger as if it
|
||||||
|
* had hit a breakpoint, allowing the developer to examine program state, etc.
|
||||||
|
*
|
||||||
|
* This is a macro--not a function--so that the debugger breaks on the source
|
||||||
|
* code line that used SDL_TriggerBreakpoint and not in some random guts of
|
||||||
|
* SDL. SDL_assert uses this macro for the same reason.
|
||||||
|
*
|
||||||
|
* If the program is not running under a debugger, SDL_TriggerBreakpoint will
|
||||||
|
* likely terminate the app, possibly without warning. If the current platform
|
||||||
|
* isn't supported, this macro is left undefined.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Don't include intrin.h here because it contains C++ code */
|
||||||
|
[CLink] public static extern void __debugbreak();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* this might work on other ARM targets, but this is a known quantity... */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* older gcc may not support SDL_HAS_BUILTIN(__builtin_trap) above */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_TriggerBreakpoint is intentionally left undefined on unknown platforms. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A macro that reports the current function being compiled.
|
||||||
|
*
|
||||||
|
* If SDL can't figure how the compiler reports this, it will use "???".
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* C99 supports __func__ as a standard. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A macro that reports the current file being compiled.
|
||||||
|
*
|
||||||
|
* This macro is only defined if it isn't already defined, so to override it
|
||||||
|
* (perhaps with something that doesn't provide path information at all, so
|
||||||
|
* build machine information doesn't leak into public binaries), apps can
|
||||||
|
* define this macro before including SDL.h or SDL_assert.h.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A macro that reports the current file being compiled, for use in
|
||||||
|
* assertions.
|
||||||
|
*
|
||||||
|
* This macro is only defined if it isn't already defined, so to override it
|
||||||
|
* (perhaps with something that doesn't provide path information at all, so
|
||||||
|
* build machine information doesn't leak into public binaries), apps can
|
||||||
|
* define this macro before including SDL_assert.h. For example, defining this
|
||||||
|
* to `""` will make sure no source path information is included in asserts.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.4.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A macro that reports the current line number of the file being compiled.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
sizeof (x) makes the compiler still parse the expression even without
|
||||||
|
assertions enabled, so the code is always checked at compile time, but
|
||||||
|
doesn't actually generate code for it, so there are no side effects or
|
||||||
|
expensive checks at run time, just the constant size of what x WOULD be,
|
||||||
|
which presumably gets optimized out as unused.
|
||||||
|
This also solves the problem of...
|
||||||
|
|
||||||
|
int somevalue = blah();
|
||||||
|
SDL_assert(somevalue == 1);
|
||||||
|
|
||||||
|
...which would cause compiles to complain that somevalue is unused if we
|
||||||
|
disable assertions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A macro for wrapping code in `do {} while (0);` without compiler warnings.
|
||||||
|
*
|
||||||
|
* Visual Studio with really aggressive warnings enabled needs this to avoid
|
||||||
|
* compiler complaints.
|
||||||
|
*
|
||||||
|
* the `do {} while (0);` trick is useful for wrapping code in a macro that
|
||||||
|
* may or may not be a single statement, to avoid various C language
|
||||||
|
* accidents.
|
||||||
|
*
|
||||||
|
* To use:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* do { SomethingOnce(); } while (SDL_NULL_WHILE_LOOP_CONDITION (0));
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Avoid /W4 warnings. */
|
||||||
|
/* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking
|
||||||
|
this condition isn't constant. And looks like an owl's face! */
|
||||||
|
public const let NULL_WHILE_LOOP_CONDITION = (0,0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The macro used when an assertion is disabled.
|
||||||
|
*
|
||||||
|
* This isn't for direct use by apps, but this is the code that is inserted
|
||||||
|
* when an SDL_assert is disabled (perhaps in a release build).
|
||||||
|
*
|
||||||
|
* The code does nothing, but wraps `condition` in a sizeof operator, which
|
||||||
|
* generates no code and has no side effects, but avoid compiler warnings
|
||||||
|
* about unused variables.
|
||||||
|
*
|
||||||
|
* \param condition the condition to assert (but not actually run here).
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Possible outcomes from a triggered assertion.
|
||||||
|
*
|
||||||
|
* When an enabled assertion triggers, it may call the assertion handler
|
||||||
|
* (possibly one provided by the app via SDL_SetAssertionHandler), which will
|
||||||
|
* return one of these values, possibly after asking the user.
|
||||||
|
*
|
||||||
|
* Then SDL will respond based on this outcome (loop around to retry the
|
||||||
|
* condition, try to break in a debugger, kill the program, or ignore the
|
||||||
|
* problem).
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum AssertState : c_int
|
||||||
|
{
|
||||||
|
Retry, /**< Retry the assert immediately. */
|
||||||
|
Break, /**< Make the debugger trigger a breakpoint. */
|
||||||
|
Abort, /**< Terminate the program. */
|
||||||
|
Ignore, /**< Ignore the assert. */
|
||||||
|
AlwaysIgnore, /**< Ignore the assert from now on. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information about an assertion failure.
|
||||||
|
*
|
||||||
|
* This structure is filled in with information about a triggered assertion,
|
||||||
|
* used by the assertion handler, then added to the assertion report. This is
|
||||||
|
* returned as a linked list from SDL_GetAssertionReport().
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct AssertData
|
||||||
|
{
|
||||||
|
public bool always_ignore; /**< true if app should always continue when assertion is triggered. */
|
||||||
|
public c_uint trigger_count; /**< Number of times this assertion has been triggered. */
|
||||||
|
public c_char* condition; /**< A string of this assert's test code. */
|
||||||
|
public c_char* filename; /**< The source file where this assert lives. */
|
||||||
|
public c_int linenum; /**< The line in `filename` where this assert lives. */
|
||||||
|
public c_char* @function; /**< The name of the function where this assert lives. */
|
||||||
|
public AssertData* next; /**< next item in the linked list. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Never call this directly.
|
||||||
|
*
|
||||||
|
* Use the SDL_assert macros instead.
|
||||||
|
*
|
||||||
|
* \param data assert data structure.
|
||||||
|
* \param func function name.
|
||||||
|
* \param file file name.
|
||||||
|
* \param line line number.
|
||||||
|
* \returns assert state.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ReportAssertion")] public static extern AssertState ReportAssertion(AssertData* data, c_char* func, c_char* file, c_int line);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The macro used when an assertion triggers a breakpoint.
|
||||||
|
*
|
||||||
|
* This isn't for direct use by apps; use SDL_assert or SDL_TriggerBreakpoint
|
||||||
|
* instead.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Define this as empty in case assert() is defined as SDL_assert */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* !SDL_AssertBreakpoint */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The macro used when an assertion is enabled.
|
||||||
|
*
|
||||||
|
* This isn't for direct use by apps, but this is the code that is inserted
|
||||||
|
* when an SDL_assert is enabled.
|
||||||
|
*
|
||||||
|
* The `do {} while(0)` avoids dangling else problems:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* if (x) SDL_assert(y); else blah();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* ... without the do/while, the "else" could attach to this macro's "if". We
|
||||||
|
* try to handle just the minimum we need here in a macro...the loop, the
|
||||||
|
* static vars, and break points. The heavy lifting is handled in
|
||||||
|
* SDL_ReportAssertion().
|
||||||
|
*
|
||||||
|
* \param condition the condition to assert.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* go again. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* not retrying. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An assertion test that is normally performed only in debug builds.
|
||||||
|
*
|
||||||
|
* This macro is enabled when the SDL_ASSERT_LEVEL is >= 2, otherwise it is
|
||||||
|
* disabled. This is meant to only do these tests in debug builds, so they can
|
||||||
|
* tend to be more expensive, and they are meant to bring everything to a halt
|
||||||
|
* when they fail, with the programmer there to assess the problem.
|
||||||
|
*
|
||||||
|
* In short: you can sprinkle these around liberally and assume they will
|
||||||
|
* evaporate out of the build when building for end-users.
|
||||||
|
*
|
||||||
|
* When assertions are disabled, this wraps `condition` in a `sizeof`
|
||||||
|
* operator, which means any function calls and side effects will not run, but
|
||||||
|
* the compiler will not complain about any otherwise-unused variables that
|
||||||
|
* are only referenced in the assertion.
|
||||||
|
*
|
||||||
|
* One can set the environment variable "SDL_ASSERT" to one of several strings
|
||||||
|
* ("abort", "break", "retry", "ignore", "always_ignore") to force a default
|
||||||
|
* behavior, which may be desirable for automation purposes. If your platform
|
||||||
|
* requires GUI interfaces to happen on the main thread but you're debugging
|
||||||
|
* an assertion in a background thread, it might be desirable to set this to
|
||||||
|
* "break" so that your debugger takes control as soon as assert is triggered,
|
||||||
|
* instead of risking a bad UI interaction (deadlock, etc) in the application.
|
||||||
|
*
|
||||||
|
* \param condition boolean value to test.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An assertion test that is performed even in release builds.
|
||||||
|
*
|
||||||
|
* This macro is enabled when the SDL_ASSERT_LEVEL is >= 1, otherwise it is
|
||||||
|
* disabled. This is meant to be for tests that are cheap to make and
|
||||||
|
* extremely unlikely to fail; generally it is frowned upon to have an
|
||||||
|
* assertion failure in a release build, so these assertions generally need to
|
||||||
|
* be of more than life-and-death importance if there's a chance they might
|
||||||
|
* trigger. You should almost always consider handling these cases more
|
||||||
|
* gracefully than an assert allows.
|
||||||
|
*
|
||||||
|
* When assertions are disabled, this wraps `condition` in a `sizeof`
|
||||||
|
* operator, which means any function calls and side effects will not run, but
|
||||||
|
* the compiler will not complain about any otherwise-unused variables that
|
||||||
|
* are only referenced in the assertion.
|
||||||
|
*
|
||||||
|
* One can set the environment variable "SDL_ASSERT" to one of several strings
|
||||||
|
* ("abort", "break", "retry", "ignore", "always_ignore") to force a default
|
||||||
|
* behavior, which may be desirable for automation purposes. If your platform
|
||||||
|
* requires GUI interfaces to happen on the main thread but you're debugging
|
||||||
|
* an assertion in a background thread, it might be desirable to set this to
|
||||||
|
* "break" so that your debugger takes control as soon as assert is triggered,
|
||||||
|
* instead of risking a bad UI interaction (deadlock, etc) in the application.
|
||||||
|
* *
|
||||||
|
*
|
||||||
|
* \param condition boolean value to test.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An assertion test that is performed only when built with paranoid settings.
|
||||||
|
*
|
||||||
|
* This macro is enabled when the SDL_ASSERT_LEVEL is >= 3, otherwise it is
|
||||||
|
* disabled. This is a higher level than both release and debug, so these
|
||||||
|
* tests are meant to be expensive and only run when specifically looking for
|
||||||
|
* extremely unexpected failure cases in a special build.
|
||||||
|
*
|
||||||
|
* When assertions are disabled, this wraps `condition` in a `sizeof`
|
||||||
|
* operator, which means any function calls and side effects will not run, but
|
||||||
|
* the compiler will not complain about any otherwise-unused variables that
|
||||||
|
* are only referenced in the assertion.
|
||||||
|
*
|
||||||
|
* One can set the environment variable "SDL_ASSERT" to one of several strings
|
||||||
|
* ("abort", "break", "retry", "ignore", "always_ignore") to force a default
|
||||||
|
* behavior, which may be desirable for automation purposes. If your platform
|
||||||
|
* requires GUI interfaces to happen on the main thread but you're debugging
|
||||||
|
* an assertion in a background thread, it might be desirable to set this to
|
||||||
|
* "break" so that your debugger takes control as soon as assert is triggered,
|
||||||
|
* instead of risking a bad UI interaction (deadlock, etc) in the application.
|
||||||
|
*
|
||||||
|
* \param condition boolean value to test.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Enable various levels of assertions. */
|
||||||
|
/* assertions disabled */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* release settings. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* debug settings. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* paranoid settings. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An assertion test that is always performed.
|
||||||
|
*
|
||||||
|
* This macro is always enabled no matter what SDL_ASSERT_LEVEL is set to. You
|
||||||
|
* almost never want to use this, as it could trigger on an end-user's system,
|
||||||
|
* crashing your program.
|
||||||
|
*
|
||||||
|
* One can set the environment variable "SDL_ASSERT" to one of several strings
|
||||||
|
* ("abort", "break", "retry", "ignore", "always_ignore") to force a default
|
||||||
|
* behavior, which may be desirable for automation purposes. If your platform
|
||||||
|
* requires GUI interfaces to happen on the main thread but you're debugging
|
||||||
|
* an assertion in a background thread, it might be desirable to set this to
|
||||||
|
* "break" so that your debugger takes control as soon as assert is triggered,
|
||||||
|
* instead of risking a bad UI interaction (deadlock, etc) in the application.
|
||||||
|
*
|
||||||
|
* \param condition boolean value to test.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A callback that fires when an SDL assertion fails.
|
||||||
|
*
|
||||||
|
* \param data a pointer to the SDL_AssertData structure corresponding to the
|
||||||
|
* current assertion.
|
||||||
|
* \param userdata what was passed as `userdata` to SDL_SetAssertionHandler().
|
||||||
|
* \returns an SDL_AssertState value indicating how to handle the failure.
|
||||||
|
*
|
||||||
|
* \threadsafety This callback may be called from any thread that triggers an
|
||||||
|
* assert at any time.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public function AssertState AssertionHandler(AssertData* data, void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an application-defined assertion handler.
|
||||||
|
*
|
||||||
|
* This function allows an application to show its own assertion UI and/or
|
||||||
|
* force the response to an assertion failure. If the application doesn't
|
||||||
|
* provide this, SDL will try to do the right thing, popping up a
|
||||||
|
* system-specific GUI dialog, and probably minimizing any fullscreen windows.
|
||||||
|
*
|
||||||
|
* This callback may fire from any thread, but it runs wrapped in a mutex, so
|
||||||
|
* it will only fire from one thread at a time.
|
||||||
|
*
|
||||||
|
* This callback is NOT reset to SDL's internal handler upon SDL_Quit()!
|
||||||
|
*
|
||||||
|
* \param handler the SDL_AssertionHandler function to call when an assertion
|
||||||
|
* fails or NULL for the default handler.
|
||||||
|
* \param userdata a pointer that is passed to `handler`.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetAssertionHandler
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetAssertionHandler")] public static extern void SetAssertionHandler(AssertionHandler handler, void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default assertion handler.
|
||||||
|
*
|
||||||
|
* This returns the function pointer that is called by default when an
|
||||||
|
* assertion is triggered. This is an internal function provided by SDL, that
|
||||||
|
* is used for assertions when SDL_SetAssertionHandler() hasn't been used to
|
||||||
|
* provide a different function.
|
||||||
|
*
|
||||||
|
* \returns the default SDL_AssertionHandler that is called when an assert
|
||||||
|
* triggers.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetAssertionHandler
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetDefaultAssertionHandler")] public static extern AssertionHandler GetDefaultAssertionHandler();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current assertion handler.
|
||||||
|
*
|
||||||
|
* This returns the function pointer that is called when an assertion is
|
||||||
|
* triggered. This is either the value last passed to
|
||||||
|
* SDL_SetAssertionHandler(), or if no application-specified function is set,
|
||||||
|
* is equivalent to calling SDL_GetDefaultAssertionHandler().
|
||||||
|
*
|
||||||
|
* The parameter `puserdata` is a pointer to a void*, which will store the
|
||||||
|
* "userdata" pointer that was passed to SDL_SetAssertionHandler(). This value
|
||||||
|
* will always be NULL for the default handler. If you don't care about this
|
||||||
|
* data, it is safe to pass a NULL pointer to this function to ignore it.
|
||||||
|
*
|
||||||
|
* \param puserdata pointer which is filled with the "userdata" pointer that
|
||||||
|
* was passed to SDL_SetAssertionHandler().
|
||||||
|
* \returns the SDL_AssertionHandler that is called when an assert triggers.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetAssertionHandler
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetAssertionHandler")] public static extern AssertionHandler GetAssertionHandler(void** puserdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of all assertion failures.
|
||||||
|
*
|
||||||
|
* This function gets all assertions triggered since the last call to
|
||||||
|
* SDL_ResetAssertionReport(), or the start of the program.
|
||||||
|
*
|
||||||
|
* The proper way to examine this data looks something like this:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* const SDL_AssertData *item = SDL_GetAssertionReport();
|
||||||
|
* while (item) {
|
||||||
|
* printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\\n",
|
||||||
|
* item->condition, item->function, item->filename,
|
||||||
|
* item->linenum, item->trigger_count,
|
||||||
|
* item->always_ignore ? "yes" : "no");
|
||||||
|
* item = item->next;
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* \returns a list of all failed assertions or NULL if the list is empty. This
|
||||||
|
* memory should not be modified or freed by the application. This
|
||||||
|
* pointer remains valid until the next call to SDL_Quit() or
|
||||||
|
* SDL_ResetAssertionReport().
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe. Other threads calling
|
||||||
|
* SDL_ResetAssertionReport() simultaneously, may render the
|
||||||
|
* returned pointer invalid.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ResetAssertionReport
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetAssertionReport")] public static extern AssertData* GetAssertionReport();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the list of all assertion failures.
|
||||||
|
*
|
||||||
|
* This function will clear the list of all assertions triggered up to that
|
||||||
|
* point. Immediately following this call, SDL_GetAssertionReport will return
|
||||||
|
* no items. In addition, any previously-triggered assertions will be reset to
|
||||||
|
* a trigger_count of zero, and their always_ignore state will be false.
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe. Other threads triggering an
|
||||||
|
* assertion, or simultaneously calling this function may cause
|
||||||
|
* memory leaks or crashes.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetAssertionReport
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ResetAssertionReport")] public static extern void ResetAssertionReport();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_assert_h_ */
|
||||||
557
src/SDL_asyncio.bf
Normal file
557
src/SDL_asyncio.bf
Normal file
@@ -0,0 +1,557 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* WIKI CATEGORY: AsyncIO */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryAsyncIO
|
||||||
|
*
|
||||||
|
* SDL offers a way to perform I/O asynchronously. This allows an app to read
|
||||||
|
* or write files without waiting for data to actually transfer; the functions
|
||||||
|
* that request I/O never block while the request is fulfilled.
|
||||||
|
*
|
||||||
|
* Instead, the data moves in the background and the app can check for results
|
||||||
|
* at their leisure.
|
||||||
|
*
|
||||||
|
* This is more complicated than just reading and writing files in a
|
||||||
|
* synchronous way, but it can allow for more efficiency, and never having
|
||||||
|
* framerate drops as the hard drive catches up, etc.
|
||||||
|
*
|
||||||
|
* The general usage pattern for async I/O is:
|
||||||
|
*
|
||||||
|
* - Create one or more SDL_AsyncIOQueue objects.
|
||||||
|
* - Open files with SDL_AsyncIOFromFile.
|
||||||
|
* - Start I/O tasks to the files with SDL_ReadAsyncIO or SDL_WriteAsyncIO,
|
||||||
|
* putting those tasks into one of the queues.
|
||||||
|
* - Later on, use SDL_GetAsyncIOResult on a queue to see if any task is
|
||||||
|
* finished without blocking. Tasks might finish in any order with success
|
||||||
|
* or failure.
|
||||||
|
* - When all your tasks are done, close the file with SDL_CloseAsyncIO. This
|
||||||
|
* also generates a task, since it might flush data to disk!
|
||||||
|
*
|
||||||
|
* This all works, without blocking, in a single thread, but one can also wait
|
||||||
|
* on a queue in a background thread, sleeping until new results have arrived:
|
||||||
|
*
|
||||||
|
* - Call SDL_WaitAsyncIOResult from one or more threads to efficiently block
|
||||||
|
* until new tasks complete.
|
||||||
|
* - When shutting down, call SDL_SignalAsyncIOQueue to unblock any sleeping
|
||||||
|
* threads despite there being no new tasks completed.
|
||||||
|
*
|
||||||
|
* And, of course, to match the synchronous SDL_LoadFile, we offer
|
||||||
|
* SDL_LoadFileAsync as a convenience function. This will handle allocating a
|
||||||
|
* buffer, slurping in the file data, and null-terminating it; you still check
|
||||||
|
* for results later.
|
||||||
|
*
|
||||||
|
* Behind the scenes, SDL will use newer, efficient APIs on platforms that
|
||||||
|
* support them: Linux's io_uring and Windows 11's IoRing, for example. If
|
||||||
|
* those technologies aren't available, SDL will offload the work to a thread
|
||||||
|
* pool that will manage otherwise-synchronous loads without blocking the app.
|
||||||
|
*
|
||||||
|
* ## Best Practices
|
||||||
|
*
|
||||||
|
* Simple non-blocking I/O--for an app that just wants to pick up data
|
||||||
|
* whenever it's ready without losing framerate waiting on disks to spin--can
|
||||||
|
* use whatever pattern works well for the program. In this case, simply call
|
||||||
|
* SDL_ReadAsyncIO, or maybe SDL_LoadFileAsync, as needed. Once a frame, call
|
||||||
|
* SDL_GetAsyncIOResult to check for any completed tasks and deal with the
|
||||||
|
* data as it arrives.
|
||||||
|
*
|
||||||
|
* If two separate pieces of the same program need their own I/O, it is legal
|
||||||
|
* for each to create their own queue. This will prevent either piece from
|
||||||
|
* accidentally consuming the other's completed tasks. Each queue does require
|
||||||
|
* some amount of resources, but it is not an overwhelming cost. Do not make a
|
||||||
|
* queue for each task, however. It is better to put many tasks into a single
|
||||||
|
* queue. They will be reported in order of completion, not in the order they
|
||||||
|
* were submitted, so it doesn't generally matter what order tasks are
|
||||||
|
* started.
|
||||||
|
*
|
||||||
|
* One async I/O queue can be shared by multiple threads, or one thread can
|
||||||
|
* have more than one queue, but the most efficient way--if ruthless
|
||||||
|
* efficiency is the goal--is to have one queue per thread, with multiple
|
||||||
|
* threads working in parallel, and attempt to keep each queue loaded with
|
||||||
|
* tasks that are both started by and consumed by the same thread. On modern
|
||||||
|
* platforms that can use newer interfaces, this can keep data flowing as
|
||||||
|
* efficiently as possible all the way from storage hardware to the app, with
|
||||||
|
* no contention between threads for access to the same queue.
|
||||||
|
*
|
||||||
|
* Written data is not guaranteed to make it to physical media by the time a
|
||||||
|
* closing task is completed, unless SDL_CloseAsyncIO is called with its
|
||||||
|
* `flush` parameter set to true, which is to say that a successful result
|
||||||
|
* here can still result in lost data during an unfortunately-timed power
|
||||||
|
* outage if not flushed. However, flushing will take longer and may be
|
||||||
|
* unnecessary, depending on the app's needs.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The asynchronous I/O operation structure.
|
||||||
|
*
|
||||||
|
* This operates as an opaque handle. One can then request read or write
|
||||||
|
* operations on it.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AsyncIOFromFile
|
||||||
|
*/
|
||||||
|
[CRepr] public struct AsyncIO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Types of asynchronous I/O tasks.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum AsyncIOTaskType : c_int
|
||||||
|
{
|
||||||
|
Read, /**< A read operation. */
|
||||||
|
Write, /**< A write operation. */
|
||||||
|
Close, /**< A close operation. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Possible outcomes of an asynchronous I/O task.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum AsyncIOResult : c_int
|
||||||
|
{
|
||||||
|
Complete, /**< request was completed without error */
|
||||||
|
Failure, /**< request failed for some reason; check SDL_GetError()! */
|
||||||
|
Canceled, /**< request was canceled before completing. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information about a completed asynchronous I/O request.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct AsyncIOOutcome
|
||||||
|
{
|
||||||
|
public AsyncIO* asyncio; /**< what generated this task. This pointer will be invalid if it was closed! */
|
||||||
|
public AsyncIOTaskType type; /**< What sort of task was this? Read, write, etc? */
|
||||||
|
public AsyncIOResult result; /**< the result of the work (success, failure, cancellation). */
|
||||||
|
public void* buffer; /**< buffer where data was read/written. */
|
||||||
|
public Uint64 offset; /**< offset in the SDL_AsyncIO where data was read/written. */
|
||||||
|
public Uint64 bytes_requested; /**< number of bytes the task was to read/write. */
|
||||||
|
public Uint64 bytes_transferred; /**< actual number of bytes that were read/written. */
|
||||||
|
public void* userdata; /**< pointer provided by the app when starting the task */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A queue of completed asynchronous I/O tasks.
|
||||||
|
*
|
||||||
|
* When starting an asynchronous operation, you specify a queue for the new
|
||||||
|
* task. A queue can be asked later if any tasks in it have completed,
|
||||||
|
* allowing an app to manage multiple pending tasks in one place, in whatever
|
||||||
|
* order they complete.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateAsyncIOQueue
|
||||||
|
* \sa SDL_ReadAsyncIO
|
||||||
|
* \sa SDL_WriteAsyncIO
|
||||||
|
* \sa SDL_GetAsyncIOResult
|
||||||
|
* \sa SDL_WaitAsyncIOResult
|
||||||
|
*/
|
||||||
|
[CRepr] public struct AsyncIOQueue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this function to create a new SDL_AsyncIO object for reading from
|
||||||
|
* and/or writing to a named file.
|
||||||
|
*
|
||||||
|
* The `mode` string understands the following values:
|
||||||
|
*
|
||||||
|
* - "r": Open a file for reading only. It must exist.
|
||||||
|
* - "w": Open a file for writing only. It will create missing files or
|
||||||
|
* truncate existing ones.
|
||||||
|
* - "r+": Open a file for update both reading and writing. The file must
|
||||||
|
* exist.
|
||||||
|
* - "w+": Create an empty file for both reading and writing. If a file with
|
||||||
|
* the same name already exists its content is erased and the file is
|
||||||
|
* treated as a new empty file.
|
||||||
|
*
|
||||||
|
* There is no "b" mode, as there is only "binary" style I/O, and no "a" mode
|
||||||
|
* for appending, since you specify the position when starting a task.
|
||||||
|
*
|
||||||
|
* This function supports Unicode filenames, but they must be encoded in UTF-8
|
||||||
|
* format, regardless of the underlying operating system.
|
||||||
|
*
|
||||||
|
* This call is _not_ asynchronous; it will open the file before returning,
|
||||||
|
* under the assumption that doing so is generally a fast operation. Future
|
||||||
|
* reads and writes to the opened file will be async, however.
|
||||||
|
*
|
||||||
|
* \param file a UTF-8 string representing the filename to open.
|
||||||
|
* \param mode an ASCII string representing the mode to be used for opening
|
||||||
|
* the file.
|
||||||
|
* \returns a pointer to the SDL_AsyncIO structure that is created or NULL on
|
||||||
|
* failure; call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CloseAsyncIO
|
||||||
|
* \sa SDL_ReadAsyncIO
|
||||||
|
* \sa SDL_WriteAsyncIO
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_AsyncIOFromFile")] public static extern AsyncIO* AsyncIOFromFile(c_char* file, c_char* mode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this function to get the size of the data stream in an SDL_AsyncIO.
|
||||||
|
*
|
||||||
|
* This call is _not_ asynchronous; it assumes that obtaining this info is a
|
||||||
|
* non-blocking operation in most reasonable cases.
|
||||||
|
*
|
||||||
|
* \param asyncio the SDL_AsyncIO to get the size of the data stream from.
|
||||||
|
* \returns the size of the data stream in the SDL_IOStream on success or a
|
||||||
|
* negative error code on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetAsyncIOSize")] public static extern Sint64 GetAsyncIOSize(AsyncIO* asyncio);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start an async read.
|
||||||
|
*
|
||||||
|
* This function reads up to `size` bytes from `offset` position in the data
|
||||||
|
* source to the area pointed at by `ptr`. This function may read less bytes
|
||||||
|
* than requested.
|
||||||
|
*
|
||||||
|
* This function returns as quickly as possible; it does not wait for the read
|
||||||
|
* to complete. On a successful return, this work will continue in the
|
||||||
|
* background. If the work begins, even failure is asynchronous: a failing
|
||||||
|
* return value from this function only means the work couldn't start at all.
|
||||||
|
*
|
||||||
|
* `ptr` must remain available until the work is done, and may be accessed by
|
||||||
|
* the system at any time until then. Do not allocate it on the stack, as this
|
||||||
|
* might take longer than the life of the calling function to complete!
|
||||||
|
*
|
||||||
|
* An SDL_AsyncIOQueue must be specified. The newly-created task will be added
|
||||||
|
* to it when it completes its work.
|
||||||
|
*
|
||||||
|
* \param asyncio a pointer to an SDL_AsyncIO structure.
|
||||||
|
* \param ptr a pointer to a buffer to read data into.
|
||||||
|
* \param offset the position to start reading in the data source.
|
||||||
|
* \param size the number of bytes to read from the data source.
|
||||||
|
* \param queue a queue to add the new SDL_AsyncIO to.
|
||||||
|
* \param userdata an app-defined pointer that will be provided with the task
|
||||||
|
* results.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_WriteAsyncIO
|
||||||
|
* \sa SDL_CreateAsyncIOQueue
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ReadAsyncIO")] public static extern bool ReadAsyncIO(AsyncIO* asyncio, void* ptr, Uint64 offset, Uint64 size, AsyncIOQueue* queue, void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start an async write.
|
||||||
|
*
|
||||||
|
* This function writes `size` bytes from `offset` position in the data source
|
||||||
|
* to the area pointed at by `ptr`.
|
||||||
|
*
|
||||||
|
* This function returns as quickly as possible; it does not wait for the
|
||||||
|
* write to complete. On a successful return, this work will continue in the
|
||||||
|
* background. If the work begins, even failure is asynchronous: a failing
|
||||||
|
* return value from this function only means the work couldn't start at all.
|
||||||
|
*
|
||||||
|
* `ptr` must remain available until the work is done, and may be accessed by
|
||||||
|
* the system at any time until then. Do not allocate it on the stack, as this
|
||||||
|
* might take longer than the life of the calling function to complete!
|
||||||
|
*
|
||||||
|
* An SDL_AsyncIOQueue must be specified. The newly-created task will be added
|
||||||
|
* to it when it completes its work.
|
||||||
|
*
|
||||||
|
* \param asyncio a pointer to an SDL_AsyncIO structure.
|
||||||
|
* \param ptr a pointer to a buffer to write data from.
|
||||||
|
* \param offset the position to start writing to the data source.
|
||||||
|
* \param size the number of bytes to write to the data source.
|
||||||
|
* \param queue a queue to add the new SDL_AsyncIO to.
|
||||||
|
* \param userdata an app-defined pointer that will be provided with the task
|
||||||
|
* results.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ReadAsyncIO
|
||||||
|
* \sa SDL_CreateAsyncIOQueue
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_WriteAsyncIO")] public static extern bool WriteAsyncIO(AsyncIO* asyncio, void* ptr, Uint64 offset, Uint64 size, AsyncIOQueue* queue, void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close and free any allocated resources for an async I/O object.
|
||||||
|
*
|
||||||
|
* Closing a file is _also_ an asynchronous task! If a write failure were to
|
||||||
|
* happen during the closing process, for example, the task results will
|
||||||
|
* report it as usual.
|
||||||
|
*
|
||||||
|
* Closing a file that has been written to does not guarantee the data has
|
||||||
|
* made it to physical media; it may remain in the operating system's file
|
||||||
|
* cache, for later writing to disk. This means that a successfully-closed
|
||||||
|
* file can be lost if the system crashes or loses power in this small window.
|
||||||
|
* To prevent this, call this function with the `flush` parameter set to true.
|
||||||
|
* This will make the operation take longer, and perhaps increase system load
|
||||||
|
* in general, but a successful result guarantees that the data has made it to
|
||||||
|
* physical storage. Don't use this for temporary files, caches, and
|
||||||
|
* unimportant data, and definitely use it for crucial irreplaceable files,
|
||||||
|
* like game saves.
|
||||||
|
*
|
||||||
|
* This function guarantees that the close will happen after any other pending
|
||||||
|
* tasks to `asyncio`, so it's safe to open a file, start several operations,
|
||||||
|
* close the file immediately, then check for all results later. This function
|
||||||
|
* will not block until the tasks have completed.
|
||||||
|
*
|
||||||
|
* Once this function returns true, `asyncio` is no longer valid, regardless
|
||||||
|
* of any future outcomes. Any completed tasks might still contain this
|
||||||
|
* pointer in their SDL_AsyncIOOutcome data, in case the app was using this
|
||||||
|
* value to track information, but it should not be used again.
|
||||||
|
*
|
||||||
|
* If this function returns false, the close wasn't started at all, and it's
|
||||||
|
* safe to attempt to close again later.
|
||||||
|
*
|
||||||
|
* An SDL_AsyncIOQueue must be specified. The newly-created task will be added
|
||||||
|
* to it when it completes its work.
|
||||||
|
*
|
||||||
|
* \param asyncio a pointer to an SDL_AsyncIO structure to close.
|
||||||
|
* \param flush true if data should sync to disk before the task completes.
|
||||||
|
* \param queue a queue to add the new SDL_AsyncIO to.
|
||||||
|
* \param userdata an app-defined pointer that will be provided with the task
|
||||||
|
* results.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread, but two
|
||||||
|
* threads should not attempt to close the same object.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CloseAsyncIO")] public static extern bool CloseAsyncIO(AsyncIO* asyncio, bool flush, AsyncIOQueue* queue, void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a task queue for tracking multiple I/O operations.
|
||||||
|
*
|
||||||
|
* Async I/O operations are assigned to a queue when started. The queue can be
|
||||||
|
* checked for completed tasks thereafter.
|
||||||
|
*
|
||||||
|
* \returns a new task queue object or NULL if there was an error; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_DestroyAsyncIOQueue
|
||||||
|
* \sa SDL_GetAsyncIOResult
|
||||||
|
* \sa SDL_WaitAsyncIOResult
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateAsyncIOQueue")] public static extern AsyncIOQueue* CreateAsyncIOQueue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy a previously-created async I/O task queue.
|
||||||
|
*
|
||||||
|
* If there are still tasks pending for this queue, this call will block until
|
||||||
|
* those tasks are finished. All those tasks will be deallocated. Their
|
||||||
|
* results will be lost to the app.
|
||||||
|
*
|
||||||
|
* Any pending reads from SDL_LoadFileAsync() that are still in this queue
|
||||||
|
* will have their buffers deallocated by this function, to prevent a memory
|
||||||
|
* leak.
|
||||||
|
*
|
||||||
|
* Once this function is called, the queue is no longer valid and should not
|
||||||
|
* be used, including by other threads that might access it while destruction
|
||||||
|
* is blocking on pending tasks.
|
||||||
|
*
|
||||||
|
* Do not destroy a queue that still has threads waiting on it through
|
||||||
|
* SDL_WaitAsyncIOResult(). You can call SDL_SignalAsyncIOQueue() first to
|
||||||
|
* unblock those threads, and take measures (such as SDL_WaitThread()) to make
|
||||||
|
* sure they have finished their wait and won't wait on the queue again.
|
||||||
|
*
|
||||||
|
* \param queue the task queue to destroy.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread, so long as
|
||||||
|
* no other thread is waiting on the queue with
|
||||||
|
* SDL_WaitAsyncIOResult.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_DestroyAsyncIOQueue")] public static extern void DestroyAsyncIOQueue(AsyncIOQueue* queue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query an async I/O task queue for completed tasks.
|
||||||
|
*
|
||||||
|
* If a task assigned to this queue has finished, this will return true and
|
||||||
|
* fill in `outcome` with the details of the task. If no task in the queue has
|
||||||
|
* finished, this function will return false. This function does not block.
|
||||||
|
*
|
||||||
|
* If a task has completed, this function will free its resources and the task
|
||||||
|
* pointer will no longer be valid. The task will be removed from the queue.
|
||||||
|
*
|
||||||
|
* It is safe for multiple threads to call this function on the same queue at
|
||||||
|
* once; a completed task will only go to one of the threads.
|
||||||
|
*
|
||||||
|
* \param queue the async I/O task queue to query.
|
||||||
|
* \param outcome details of a finished task will be written here. May not be
|
||||||
|
* NULL.
|
||||||
|
* \returns true if a task has completed, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_WaitAsyncIOResult
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetAsyncIOResult")] public static extern bool GetAsyncIOResult(AsyncIOQueue* queue, AsyncIOOutcome* outcome);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Block until an async I/O task queue has a completed task.
|
||||||
|
*
|
||||||
|
* This function puts the calling thread to sleep until there a task assigned
|
||||||
|
* to the queue that has finished.
|
||||||
|
*
|
||||||
|
* If a task assigned to the queue has finished, this will return true and
|
||||||
|
* fill in `outcome` with the details of the task. If no task in the queue has
|
||||||
|
* finished, this function will return false.
|
||||||
|
*
|
||||||
|
* If a task has completed, this function will free its resources and the task
|
||||||
|
* pointer will no longer be valid. The task will be removed from the queue.
|
||||||
|
*
|
||||||
|
* It is safe for multiple threads to call this function on the same queue at
|
||||||
|
* once; a completed task will only go to one of the threads.
|
||||||
|
*
|
||||||
|
* Note that by the nature of various platforms, more than one waiting thread
|
||||||
|
* may wake to handle a single task, but only one will obtain it, so
|
||||||
|
* `timeoutMS` is a _maximum_ wait time, and this function may return false
|
||||||
|
* sooner.
|
||||||
|
*
|
||||||
|
* This function may return false if there was a system error, the OS
|
||||||
|
* inadvertently awoke multiple threads, or if SDL_SignalAsyncIOQueue() was
|
||||||
|
* called to wake up all waiting threads without a finished task.
|
||||||
|
*
|
||||||
|
* A timeout can be used to specify a maximum wait time, but rather than
|
||||||
|
* polling, it is possible to have a timeout of -1 to wait forever, and use
|
||||||
|
* SDL_SignalAsyncIOQueue() to wake up the waiting threads later.
|
||||||
|
*
|
||||||
|
* \param queue the async I/O task queue to wait on.
|
||||||
|
* \param outcome details of a finished task will be written here. May not be
|
||||||
|
* NULL.
|
||||||
|
* \param timeoutMS the maximum time to wait, in milliseconds, or -1 to wait
|
||||||
|
* indefinitely.
|
||||||
|
* \returns true if task has completed, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SignalAsyncIOQueue
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_WaitAsyncIOResult")] public static extern bool WaitAsyncIOResult(AsyncIOQueue* queue, AsyncIOOutcome* outcome, Sint32 timeoutMS);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wake up any threads that are blocking in SDL_WaitAsyncIOResult().
|
||||||
|
*
|
||||||
|
* This will unblock any threads that are sleeping in a call to
|
||||||
|
* SDL_WaitAsyncIOResult for the specified queue, and cause them to return
|
||||||
|
* from that function.
|
||||||
|
*
|
||||||
|
* This can be useful when destroying a queue to make sure nothing is touching
|
||||||
|
* it indefinitely. In this case, once this call completes, the caller should
|
||||||
|
* take measures to make sure any previously-blocked threads have returned
|
||||||
|
* from their wait and will not touch the queue again (perhaps by setting a
|
||||||
|
* flag to tell the threads to terminate and then using SDL_WaitThread() to
|
||||||
|
* make sure they've done so).
|
||||||
|
*
|
||||||
|
* \param queue the async I/O task queue to signal.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_WaitAsyncIOResult
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SignalAsyncIOQueue")] public static extern void SignalAsyncIOQueue(AsyncIOQueue* queue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load all the data from a file path, asynchronously.
|
||||||
|
*
|
||||||
|
* This function returns as quickly as possible; it does not wait for the read
|
||||||
|
* to complete. On a successful return, this work will continue in the
|
||||||
|
* background. If the work begins, even failure is asynchronous: a failing
|
||||||
|
* return value from this function only means the work couldn't start at all.
|
||||||
|
*
|
||||||
|
* The data is allocated with a zero byte at the end (null terminated) for
|
||||||
|
* convenience. This extra byte is not included in SDL_AsyncIOOutcome's
|
||||||
|
* bytes_transferred value.
|
||||||
|
*
|
||||||
|
* This function will allocate the buffer to contain the file. It must be
|
||||||
|
* deallocated by calling SDL_free() on SDL_AsyncIOOutcome's buffer field
|
||||||
|
* after completion.
|
||||||
|
*
|
||||||
|
* An SDL_AsyncIOQueue must be specified. The newly-created task will be added
|
||||||
|
* to it when it completes its work.
|
||||||
|
*
|
||||||
|
* \param file the path to read all available data from.
|
||||||
|
* \param queue a queue to add the new SDL_AsyncIO to.
|
||||||
|
* \param userdata an app-defined pointer that will be provided with the task
|
||||||
|
* results.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_LoadFile_IO
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_LoadFileAsync")] public static extern bool LoadFileAsync(c_char* file, AsyncIOQueue* queue, void* userdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_asyncio_h_ */
|
||||||
693
src/SDL_atomic.bf
Normal file
693
src/SDL_atomic.bf
Normal file
@@ -0,0 +1,693 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryAtomic
|
||||||
|
*
|
||||||
|
* Atomic operations.
|
||||||
|
*
|
||||||
|
* IMPORTANT: If you are not an expert in concurrent lockless programming, you
|
||||||
|
* should not be using any functions in this file. You should be protecting
|
||||||
|
* your data structures with full mutexes instead.
|
||||||
|
*
|
||||||
|
* ***Seriously, here be dragons!***
|
||||||
|
*
|
||||||
|
* You can find out a little more about lockless programming and the subtle
|
||||||
|
* issues that can arise here:
|
||||||
|
* https://learn.microsoft.com/en-us/windows/win32/dxtecharts/lockless-programming
|
||||||
|
*
|
||||||
|
* There's also lots of good information here:
|
||||||
|
*
|
||||||
|
* - https://www.1024cores.net/home/lock-free-algorithms
|
||||||
|
* - https://preshing.com/
|
||||||
|
*
|
||||||
|
* These operations may or may not actually be implemented using processor
|
||||||
|
* specific atomic operations. When possible they are implemented as true
|
||||||
|
* processor specific atomic operations. When that is not possible the are
|
||||||
|
* implemented using locks that *do* use the available atomic operations.
|
||||||
|
*
|
||||||
|
* All of the atomic operations that modify memory are full memory barriers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An atomic spinlock.
|
||||||
|
*
|
||||||
|
* The atomic locks are efficient spinlocks using CPU instructions, but are
|
||||||
|
* vulnerable to starvation and can spin forever if a thread holding a lock
|
||||||
|
* has been terminated. For this reason you should minimize the code executed
|
||||||
|
* inside an atomic lock and never do expensive things like API or system
|
||||||
|
* calls while holding them.
|
||||||
|
*
|
||||||
|
* They are also vulnerable to starvation if the thread holding the lock is
|
||||||
|
* lower priority than other threads and doesn't get scheduled. In general you
|
||||||
|
* should use mutexes instead, since they have better performance and
|
||||||
|
* contention behavior.
|
||||||
|
*
|
||||||
|
* The atomic locks are not safe to lock recursively.
|
||||||
|
*
|
||||||
|
* Porting Note: The spin lock functions and type are required and can not be
|
||||||
|
* emulated because they are used in the atomic emulation code.
|
||||||
|
*/
|
||||||
|
public typealias SpinLock = c_int;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to lock a spin lock by setting it to a non-zero value.
|
||||||
|
*
|
||||||
|
* ***Please note that spinlocks are dangerous if you don't know what you're
|
||||||
|
* doing. Please be careful using any sort of spinlock!***
|
||||||
|
*
|
||||||
|
* \param lock a pointer to a lock variable.
|
||||||
|
* \returns true if the lock succeeded, false if the lock is already held.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_LockSpinlock
|
||||||
|
* \sa SDL_UnlockSpinlock
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_TryLockSpinlock")] public static extern bool TryLockSpinlock(SpinLock* lock);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lock a spin lock by setting it to a non-zero value.
|
||||||
|
*
|
||||||
|
* ***Please note that spinlocks are dangerous if you don't know what you're
|
||||||
|
* doing. Please be careful using any sort of spinlock!***
|
||||||
|
*
|
||||||
|
* \param lock a pointer to a lock variable.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_TryLockSpinlock
|
||||||
|
* \sa SDL_UnlockSpinlock
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_LockSpinlock")] public static extern void LockSpinlock(SpinLock* lock);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unlock a spin lock by setting it to 0.
|
||||||
|
*
|
||||||
|
* Always returns immediately.
|
||||||
|
*
|
||||||
|
* ***Please note that spinlocks are dangerous if you don't know what you're
|
||||||
|
* doing. Please be careful using any sort of spinlock!***
|
||||||
|
*
|
||||||
|
* \param lock a pointer to a lock variable.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_LockSpinlock
|
||||||
|
* \sa SDL_TryLockSpinlock
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_UnlockSpinlock")] public static extern void UnlockSpinlock(SpinLock* lock);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark a compiler barrier.
|
||||||
|
*
|
||||||
|
* A compiler barrier prevents the compiler from reordering reads and writes
|
||||||
|
* to globally visible variables across the call.
|
||||||
|
*
|
||||||
|
* This macro only prevents the compiler from reordering reads and writes, it
|
||||||
|
* does not prevent the CPU from reordering reads and writes. However, all of
|
||||||
|
* the atomic operations that modify memory are full memory barriers.
|
||||||
|
*
|
||||||
|
* \threadsafety Obviously this macro is safe to use from any thread at any
|
||||||
|
* time, but if you find yourself needing this, you are probably
|
||||||
|
* dealing with some very sensitive code; be careful!
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert a memory release barrier (function version).
|
||||||
|
*
|
||||||
|
* Please refer to SDL_MemoryBarrierRelease for details. This is a function
|
||||||
|
* version, which might be useful if you need to use this functionality from a
|
||||||
|
* scripting language, etc. Also, some of the macro versions call this
|
||||||
|
* function behind the scenes, where more heavy lifting can happen inside of
|
||||||
|
* SDL. Generally, though, an app written in C/C++/etc should use the macro
|
||||||
|
* version, as it will be more efficient.
|
||||||
|
*
|
||||||
|
* \threadsafety Obviously this function is safe to use from any thread at any
|
||||||
|
* time, but if you find yourself needing this, you are probably
|
||||||
|
* dealing with some very sensitive code; be careful!
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_MemoryBarrierRelease
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_MemoryBarrierReleaseFunction")] public static extern void MemoryBarrierReleaseFunction();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert a memory acquire barrier (function version).
|
||||||
|
*
|
||||||
|
* Please refer to SDL_MemoryBarrierRelease for details. This is a function
|
||||||
|
* version, which might be useful if you need to use this functionality from a
|
||||||
|
* scripting language, etc. Also, some of the macro versions call this
|
||||||
|
* function behind the scenes, where more heavy lifting can happen inside of
|
||||||
|
* SDL. Generally, though, an app written in C/C++/etc should use the macro
|
||||||
|
* version, as it will be more efficient.
|
||||||
|
*
|
||||||
|
* \threadsafety Obviously this function is safe to use from any thread at any
|
||||||
|
* time, but if you find yourself needing this, you are probably
|
||||||
|
* dealing with some very sensitive code; be careful!
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_MemoryBarrierAcquire
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_MemoryBarrierAcquireFunction")] public static extern void MemoryBarrierAcquireFunction();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert a memory release barrier (macro version).
|
||||||
|
*
|
||||||
|
* Memory barriers are designed to prevent reads and writes from being
|
||||||
|
* reordered by the compiler and being seen out of order on multi-core CPUs.
|
||||||
|
*
|
||||||
|
* A typical pattern would be for thread A to write some data and a flag, and
|
||||||
|
* for thread B to read the flag and get the data. In this case you would
|
||||||
|
* insert a release barrier between writing the data and the flag,
|
||||||
|
* guaranteeing that the data write completes no later than the flag is
|
||||||
|
* written, and you would insert an acquire barrier between reading the flag
|
||||||
|
* and reading the data, to ensure that all the reads associated with the flag
|
||||||
|
* have completed.
|
||||||
|
*
|
||||||
|
* In this pattern you should always see a release barrier paired with an
|
||||||
|
* acquire barrier and you should gate the data reads/writes with a single
|
||||||
|
* flag variable.
|
||||||
|
*
|
||||||
|
* For more information on these semantics, take a look at the blog post:
|
||||||
|
* http://preshing.com/20120913/acquire-and-release-semantics
|
||||||
|
*
|
||||||
|
* This is the macro version of this functionality; if possible, SDL will use
|
||||||
|
* compiler intrinsics or inline assembly, but some platforms might need to
|
||||||
|
* call the function version of this, SDL_MemoryBarrierReleaseFunction to do
|
||||||
|
* the heavy lifting. Apps that can use the macro should favor it over the
|
||||||
|
* function.
|
||||||
|
*
|
||||||
|
* \threadsafety Obviously this macro is safe to use from any thread at any
|
||||||
|
* time, but if you find yourself needing this, you are probably
|
||||||
|
* dealing with some very sensitive code; be careful!
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_MemoryBarrierAcquire
|
||||||
|
* \sa SDL_MemoryBarrierReleaseFunction
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert a memory acquire barrier (macro version).
|
||||||
|
*
|
||||||
|
* Please see SDL_MemoryBarrierRelease for the details on what memory barriers
|
||||||
|
* are and when to use them.
|
||||||
|
*
|
||||||
|
* This is the macro version of this functionality; if possible, SDL will use
|
||||||
|
* compiler intrinsics or inline assembly, but some platforms might need to
|
||||||
|
* call the function version of this, SDL_MemoryBarrierAcquireFunction, to do
|
||||||
|
* the heavy lifting. Apps that can use the macro should favor it over the
|
||||||
|
* function.
|
||||||
|
*
|
||||||
|
* \threadsafety Obviously this macro is safe to use from any thread at any
|
||||||
|
* time, but if you find yourself needing this, you are probably
|
||||||
|
* dealing with some very sensitive code; be careful!
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_MemoryBarrierRelease
|
||||||
|
* \sa SDL_MemoryBarrierAcquireFunction
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) */
|
||||||
|
/* Information from:
|
||||||
|
https://chromium.googlesource.com/chromium/chromium/+/trunk/base/atomicops_internals_arm_gcc.h#19
|
||||||
|
|
||||||
|
The Linux kernel provides a helper function which provides the right code for a memory barrier,
|
||||||
|
hard-coded at address 0xffff0fa0
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* The mcr instruction isn't available in thumb mode, use real functions */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* __thumb__ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_PLATFORM_LINUX || SDL_PLATFORM_ANDROID */
|
||||||
|
/* __GNUC__ && __arm__ */
|
||||||
|
|
||||||
|
|
||||||
|
/* This is correct for all CPUs on Solaris when using Solaris Studio 12.1+. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* This is correct for the x86 and x64 CPUs, and we'll expand this over time. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* "REP NOP" is PAUSE, coded for tools that don't know it by that name. */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A macro to insert a CPU-specific "pause" instruction into the program.
|
||||||
|
*
|
||||||
|
* This can be useful in busy-wait loops, as it serves as a hint to the CPU as
|
||||||
|
* to the program's intent; some CPUs can use this to do more efficient
|
||||||
|
* processing. On some platforms, this doesn't do anything, so using this
|
||||||
|
* macro might just be a harmless no-op.
|
||||||
|
*
|
||||||
|
* Note that if you are busy-waiting, there are often more-efficient
|
||||||
|
* approaches with other synchronization primitives: mutexes, semaphores,
|
||||||
|
* condition variables, etc.
|
||||||
|
*
|
||||||
|
* \threadsafety This macro is safe to use from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Some assemblers can't do REP NOP, so go with PAUSE. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* this is actually "rep nop" and not a SIMD instruction. No inline asm in MSVC x86-64! */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A type representing an atomic integer value.
|
||||||
|
*
|
||||||
|
* This can be used to manage a value that is synchronized across multiple
|
||||||
|
* CPUs without a race condition; when an app sets a value with
|
||||||
|
* SDL_SetAtomicInt all other threads, regardless of the CPU it is running on,
|
||||||
|
* will see that value when retrieved with SDL_GetAtomicInt, regardless of CPU
|
||||||
|
* caches, etc.
|
||||||
|
*
|
||||||
|
* This is also useful for atomic compare-and-swap operations: a thread can
|
||||||
|
* change the value as long as its current value matches expectations. When
|
||||||
|
* done in a loop, one can guarantee data consistency across threads without a
|
||||||
|
* lock (but the usual warnings apply: if you don't know what you're doing, or
|
||||||
|
* you don't do it carefully, you can confidently cause any number of
|
||||||
|
* disasters with this, so in most cases, you _should_ use a mutex instead of
|
||||||
|
* this!).
|
||||||
|
*
|
||||||
|
* This is a struct so people don't accidentally use numeric operations on it
|
||||||
|
* directly. You have to use SDL atomic functions.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CompareAndSwapAtomicInt
|
||||||
|
* \sa SDL_GetAtomicInt
|
||||||
|
* \sa SDL_SetAtomicInt
|
||||||
|
* \sa SDL_AddAtomicInt
|
||||||
|
*/
|
||||||
|
[CRepr] public struct AtomicInt { public c_int value; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an atomic variable to a new value if it is currently an old value.
|
||||||
|
*
|
||||||
|
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||||
|
* it!***
|
||||||
|
*
|
||||||
|
* \param a a pointer to an SDL_AtomicInt variable to be modified.
|
||||||
|
* \param oldval the old value.
|
||||||
|
* \param newval the new value.
|
||||||
|
* \returns true if the atomic variable was set, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetAtomicInt
|
||||||
|
* \sa SDL_SetAtomicInt
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CompareAndSwapAtomicInt")] public static extern bool CompareAndSwapAtomicInt(AtomicInt* a, c_int oldval, c_int newval);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an atomic variable to a value.
|
||||||
|
*
|
||||||
|
* This function also acts as a full memory barrier.
|
||||||
|
*
|
||||||
|
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||||
|
* it!***
|
||||||
|
*
|
||||||
|
* \param a a pointer to an SDL_AtomicInt variable to be modified.
|
||||||
|
* \param v the desired value.
|
||||||
|
* \returns the previous value of the atomic variable.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetAtomicInt
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetAtomicInt")] public static extern c_int SetAtomicInt(AtomicInt* a, c_int v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of an atomic variable.
|
||||||
|
*
|
||||||
|
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||||
|
* it!***
|
||||||
|
*
|
||||||
|
* \param a a pointer to an SDL_AtomicInt variable.
|
||||||
|
* \returns the current value of an atomic variable.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetAtomicInt
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetAtomicInt")] public static extern c_int GetAtomicInt(AtomicInt* a);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add to an atomic variable.
|
||||||
|
*
|
||||||
|
* This function also acts as a full memory barrier.
|
||||||
|
*
|
||||||
|
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||||
|
* it!***
|
||||||
|
*
|
||||||
|
* \param a a pointer to an SDL_AtomicInt variable to be modified.
|
||||||
|
* \param v the desired value to add.
|
||||||
|
* \returns the previous value of the atomic variable.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AtomicDecRef
|
||||||
|
* \sa SDL_AtomicIncRef
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_AddAtomicInt")] public static extern c_int AddAtomicInt(AtomicInt* a, c_int v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increment an atomic variable used as a reference count.
|
||||||
|
*
|
||||||
|
* ***Note: If you don't know what this macro is for, you shouldn't use it!***
|
||||||
|
*
|
||||||
|
* \param a a pointer to an SDL_AtomicInt to increment.
|
||||||
|
* \returns the previous value of the atomic variable.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AtomicDecRef
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrement an atomic variable used as a reference count.
|
||||||
|
*
|
||||||
|
* ***Note: If you don't know what this macro is for, you shouldn't use it!***
|
||||||
|
*
|
||||||
|
* \param a a pointer to an SDL_AtomicInt to decrement.
|
||||||
|
* \returns true if the variable reached zero after decrementing, false
|
||||||
|
* otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AtomicIncRef
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A type representing an atomic unsigned 32-bit value.
|
||||||
|
*
|
||||||
|
* This can be used to manage a value that is synchronized across multiple
|
||||||
|
* CPUs without a race condition; when an app sets a value with
|
||||||
|
* SDL_SetAtomicU32 all other threads, regardless of the CPU it is running on,
|
||||||
|
* will see that value when retrieved with SDL_GetAtomicU32, regardless of CPU
|
||||||
|
* caches, etc.
|
||||||
|
*
|
||||||
|
* This is also useful for atomic compare-and-swap operations: a thread can
|
||||||
|
* change the value as long as its current value matches expectations. When
|
||||||
|
* done in a loop, one can guarantee data consistency across threads without a
|
||||||
|
* lock (but the usual warnings apply: if you don't know what you're doing, or
|
||||||
|
* you don't do it carefully, you can confidently cause any number of
|
||||||
|
* disasters with this, so in most cases, you _should_ use a mutex instead of
|
||||||
|
* this!).
|
||||||
|
*
|
||||||
|
* This is a struct so people don't accidentally use numeric operations on it
|
||||||
|
* directly. You have to use SDL atomic functions.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CompareAndSwapAtomicU32
|
||||||
|
* \sa SDL_GetAtomicU32
|
||||||
|
* \sa SDL_SetAtomicU32
|
||||||
|
*/
|
||||||
|
[CRepr] public struct AtomicU32 { public Uint32 value; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an atomic variable to a new value if it is currently an old value.
|
||||||
|
*
|
||||||
|
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||||
|
* it!***
|
||||||
|
*
|
||||||
|
* \param a a pointer to an SDL_AtomicU32 variable to be modified.
|
||||||
|
* \param oldval the old value.
|
||||||
|
* \param newval the new value.
|
||||||
|
* \returns true if the atomic variable was set, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetAtomicU32
|
||||||
|
* \sa SDL_SetAtomicU32
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CompareAndSwapAtomicU32")] public static extern bool CompareAndSwapAtomicU32(AtomicU32* a, Uint32 oldval, Uint32 newval);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an atomic variable to a value.
|
||||||
|
*
|
||||||
|
* This function also acts as a full memory barrier.
|
||||||
|
*
|
||||||
|
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||||
|
* it!***
|
||||||
|
*
|
||||||
|
* \param a a pointer to an SDL_AtomicU32 variable to be modified.
|
||||||
|
* \param v the desired value.
|
||||||
|
* \returns the previous value of the atomic variable.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetAtomicU32
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetAtomicU32")] public static extern Uint32 SetAtomicU32(AtomicU32* a, Uint32 v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of an atomic variable.
|
||||||
|
*
|
||||||
|
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||||
|
* it!***
|
||||||
|
*
|
||||||
|
* \param a a pointer to an SDL_AtomicU32 variable.
|
||||||
|
* \returns the current value of an atomic variable.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetAtomicU32
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetAtomicU32")] public static extern Uint32 GetAtomicU32(AtomicU32* a);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add to an atomic variable.
|
||||||
|
*
|
||||||
|
* This function also acts as a full memory barrier.
|
||||||
|
*
|
||||||
|
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||||
|
* it!***
|
||||||
|
*
|
||||||
|
* \param a a pointer to an SDL_AtomicU32 variable to be modified.
|
||||||
|
* \param v the desired value to add or subtract.
|
||||||
|
* \returns the previous value of the atomic variable.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.4.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_AddAtomicU32")] public static extern Uint32 AddAtomicU32(AtomicU32* a, c_int v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a pointer to a new value if it is currently an old value.
|
||||||
|
*
|
||||||
|
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||||
|
* it!***
|
||||||
|
*
|
||||||
|
* \param a a pointer to a pointer.
|
||||||
|
* \param oldval the old pointer value.
|
||||||
|
* \param newval the new pointer value.
|
||||||
|
* \returns true if the pointer was set, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CompareAndSwapAtomicInt
|
||||||
|
* \sa SDL_GetAtomicPointer
|
||||||
|
* \sa SDL_SetAtomicPointer
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CompareAndSwapAtomicPointer")] public static extern bool CompareAndSwapAtomicPointer(void** a, void* oldval, void* newval);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a pointer to a value atomically.
|
||||||
|
*
|
||||||
|
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||||
|
* it!***
|
||||||
|
*
|
||||||
|
* \param a a pointer to a pointer.
|
||||||
|
* \param v the desired pointer value.
|
||||||
|
* \returns the previous value of the pointer.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CompareAndSwapAtomicPointer
|
||||||
|
* \sa SDL_GetAtomicPointer
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetAtomicPointer")] public static extern void* SetAtomicPointer(void** a, void* v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of a pointer atomically.
|
||||||
|
*
|
||||||
|
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||||
|
* it!***
|
||||||
|
*
|
||||||
|
* \param a a pointer to a pointer.
|
||||||
|
* \returns the current value of a pointer.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CompareAndSwapAtomicPointer
|
||||||
|
* \sa SDL_SetAtomicPointer
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetAtomicPointer")] public static extern void* GetAtomicPointer(void** a);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_atomic_h_ */
|
||||||
2367
src/SDL_audio.bf
Normal file
2367
src/SDL_audio.bf
Normal file
File diff suppressed because it is too large
Load Diff
152
src/SDL_bits.bf
Normal file
152
src/SDL_bits.bf
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryBits
|
||||||
|
*
|
||||||
|
* Functions for fiddling with bits and bitmasks.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the index of the most significant (set) bit in a 32-bit number.
|
||||||
|
*
|
||||||
|
* Result is undefined when called with 0. This operation can also be stated
|
||||||
|
* as "count leading zeroes" and "log base 2".
|
||||||
|
*
|
||||||
|
* Note that this is a forced-inline function in a header, and not a public
|
||||||
|
* API function available in the SDL library (which is to say, the code is
|
||||||
|
* embedded in the calling program and the linker and dynamic loader will not
|
||||||
|
* be able to find this function inside SDL itself).
|
||||||
|
*
|
||||||
|
* \param x the 32-bit value to examine.
|
||||||
|
* \returns the index of the most significant bit, or -1 if the value is 0.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_MostSignificantBitIndex32")] public static extern c_int MostSignificantBitIndex32(Uint32 x);
|
||||||
|
|
||||||
|
|
||||||
|
/* Count Leading Zeroes builtin in GCC.
|
||||||
|
* http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Based off of Bit Twiddling Hacks by Sean Eron Anderson
|
||||||
|
* <seander@cs.stanford.edu>, released in the public domain.
|
||||||
|
* http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if a unsigned 32-bit value has exactly one bit set.
|
||||||
|
*
|
||||||
|
* If there are no bits set (`x` is zero), or more than one bit set, this
|
||||||
|
* returns false. If any one bit is exclusively set, this returns true.
|
||||||
|
*
|
||||||
|
* Note that this is a forced-inline function in a header, and not a public
|
||||||
|
* API function available in the SDL library (which is to say, the code is
|
||||||
|
* embedded in the calling program and the linker and dynamic loader will not
|
||||||
|
* be able to find this function inside SDL itself).
|
||||||
|
*
|
||||||
|
* \param x the 32-bit value to examine.
|
||||||
|
* \returns true if exactly one bit is set in `x`, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasExactlyOneBitSet32")] public static extern bool HasExactlyOneBitSet32(Uint32 x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_bits_h_ */
|
||||||
216
src/SDL_blendmode.bf
Normal file
216
src/SDL_blendmode.bf
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryBlendmode
|
||||||
|
*
|
||||||
|
* Blend modes decide how two colors will mix together. There are both
|
||||||
|
* standard modes for basic needs and a means to create custom modes,
|
||||||
|
* dictating what sort of math to do on what color components.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A set of blend modes used in drawing operations.
|
||||||
|
*
|
||||||
|
* These predefined blend modes are supported everywhere.
|
||||||
|
*
|
||||||
|
* Additional values may be obtained from SDL_ComposeCustomBlendMode.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ComposeCustomBlendMode
|
||||||
|
*/
|
||||||
|
public enum BlendMode : Uint32
|
||||||
|
{
|
||||||
|
None = 0x00000000u, /**< no blending: dstRGBA = srcRGBA */
|
||||||
|
Blend = 0x00000001u, /**< alpha blending: dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)), dstA = srcA + (dstA * (1-srcA)) */
|
||||||
|
BlendPremultiplied = 0x00000010u, /**< pre-multiplied alpha blending: dstRGBA = srcRGBA + (dstRGBA * (1-srcA)) */
|
||||||
|
Add = 0x00000002u, /**< additive blending: dstRGB = (srcRGB * srcA) + dstRGB, dstA = dstA */
|
||||||
|
AddPremultiplied = 0x00000020u, /**< pre-multiplied additive blending: dstRGB = srcRGB + dstRGB, dstA = dstA */
|
||||||
|
Mod = 0x00000004u, /**< color modulate: dstRGB = srcRGB * dstRGB, dstA = dstA */
|
||||||
|
Mul = 0x00000008u, /**< color multiply: dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)), dstA = dstA */
|
||||||
|
Invalid = 0x7FFFFFFFu,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The blend operation used when combining source and destination pixel
|
||||||
|
* components.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The blend operation used when combining source and destination pixel
|
||||||
|
* components.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum BlendOperation : c_int
|
||||||
|
{
|
||||||
|
Add = 0x1, /**< dst + src: supported by all renderers */
|
||||||
|
Subtract = 0x2, /**< src - dst : supported by D3D, OpenGL, OpenGLES, and Vulkan */
|
||||||
|
RevSubtract = 0x3, /**< dst - src : supported by D3D, OpenGL, OpenGLES, and Vulkan */
|
||||||
|
Minimum = 0x4, /**< min(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan */
|
||||||
|
Maximum = 0x5, /**< max(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The normalized factor used to multiply pixel components.
|
||||||
|
*
|
||||||
|
* The blend factors are multiplied with the pixels from a drawing operation
|
||||||
|
* (src) and the pixels from the render target (dst) before the blend
|
||||||
|
* operation. The comma-separated factors listed above are always applied in
|
||||||
|
* the component order red, green, blue, and alpha.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum BlendFactor : c_int
|
||||||
|
{
|
||||||
|
Zero = 0x1, /**< 0, 0, 0, 0 */
|
||||||
|
One = 0x2, /**< 1, 1, 1, 1 */
|
||||||
|
SrcColor = 0x3, /**< srcR, srcG, srcB, srcA */
|
||||||
|
OneMinusSrcColor = 0x4, /**< 1-srcR, 1-srcG, 1-srcB, 1-srcA */
|
||||||
|
SrcAlpha = 0x5, /**< srcA, srcA, srcA, srcA */
|
||||||
|
OneMinusSrcAlpha = 0x6, /**< 1-srcA, 1-srcA, 1-srcA, 1-srcA */
|
||||||
|
DstColor = 0x7, /**< dstR, dstG, dstB, dstA */
|
||||||
|
OneMinusDstColor = 0x8, /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */
|
||||||
|
DstAlpha = 0x9, /**< dstA, dstA, dstA, dstA */
|
||||||
|
OneMinusDstAlpha = 0xA, /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compose a custom blend mode for renderers.
|
||||||
|
*
|
||||||
|
* The functions SDL_SetRenderDrawBlendMode and SDL_SetTextureBlendMode accept
|
||||||
|
* the SDL_BlendMode returned by this function if the renderer supports it.
|
||||||
|
*
|
||||||
|
* A blend mode controls how the pixels from a drawing operation (source) get
|
||||||
|
* combined with the pixels from the render target (destination). First, the
|
||||||
|
* components of the source and destination pixels get multiplied with their
|
||||||
|
* blend factors. Then, the blend operation takes the two products and
|
||||||
|
* calculates the result that will get stored in the render target.
|
||||||
|
*
|
||||||
|
* Expressed in pseudocode, it would look like this:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* dstRGB = colorOperation(srcRGB * srcColorFactor, dstRGB * dstColorFactor);
|
||||||
|
* dstA = alphaOperation(srcA * srcAlphaFactor, dstA * dstAlphaFactor);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Where the functions `colorOperation(src, dst)` and `alphaOperation(src,
|
||||||
|
* dst)` can return one of the following:
|
||||||
|
*
|
||||||
|
* - `src + dst`
|
||||||
|
* - `src - dst`
|
||||||
|
* - `dst - src`
|
||||||
|
* - `min(src, dst)`
|
||||||
|
* - `max(src, dst)`
|
||||||
|
*
|
||||||
|
* The red, green, and blue components are always multiplied with the first,
|
||||||
|
* second, and third components of the SDL_BlendFactor, respectively. The
|
||||||
|
* fourth component is not used.
|
||||||
|
*
|
||||||
|
* The alpha component is always multiplied with the fourth component of the
|
||||||
|
* SDL_BlendFactor. The other components are not used in the alpha
|
||||||
|
* calculation.
|
||||||
|
*
|
||||||
|
* Support for these blend modes varies for each renderer. To check if a
|
||||||
|
* specific SDL_BlendMode is supported, create a renderer and pass it to
|
||||||
|
* either SDL_SetRenderDrawBlendMode or SDL_SetTextureBlendMode. They will
|
||||||
|
* return with an error if the blend mode is not supported.
|
||||||
|
*
|
||||||
|
* This list describes the support of custom blend modes for each renderer.
|
||||||
|
* All renderers support the four blend modes listed in the SDL_BlendMode
|
||||||
|
* enumeration.
|
||||||
|
*
|
||||||
|
* - **direct3d**: Supports all operations with all factors. However, some
|
||||||
|
* factors produce unexpected results with `SDL_BLENDOPERATION_MINIMUM` and
|
||||||
|
* `SDL_BLENDOPERATION_MAXIMUM`.
|
||||||
|
* - **direct3d11**: Same as Direct3D 9.
|
||||||
|
* - **opengl**: Supports the `SDL_BLENDOPERATION_ADD` operation with all
|
||||||
|
* factors. OpenGL versions 1.1, 1.2, and 1.3 do not work correctly here.
|
||||||
|
* - **opengles2**: Supports the `SDL_BLENDOPERATION_ADD`,
|
||||||
|
* `SDL_BLENDOPERATION_SUBTRACT`, `SDL_BLENDOPERATION_REV_SUBTRACT`
|
||||||
|
* operations with all factors.
|
||||||
|
* - **psp**: No custom blend mode support.
|
||||||
|
* - **software**: No custom blend mode support.
|
||||||
|
*
|
||||||
|
* Some renderers do not provide an alpha component for the default render
|
||||||
|
* target. The `SDL_BLENDFACTOR_DST_ALPHA` and
|
||||||
|
* `SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA` factors do not have an effect in this
|
||||||
|
* case.
|
||||||
|
*
|
||||||
|
* \param srcColorFactor the SDL_BlendFactor applied to the red, green, and
|
||||||
|
* blue components of the source pixels.
|
||||||
|
* \param dstColorFactor the SDL_BlendFactor applied to the red, green, and
|
||||||
|
* blue components of the destination pixels.
|
||||||
|
* \param colorOperation the SDL_BlendOperation used to combine the red,
|
||||||
|
* green, and blue components of the source and
|
||||||
|
* destination pixels.
|
||||||
|
* \param srcAlphaFactor the SDL_BlendFactor applied to the alpha component of
|
||||||
|
* the source pixels.
|
||||||
|
* \param dstAlphaFactor the SDL_BlendFactor applied to the alpha component of
|
||||||
|
* the destination pixels.
|
||||||
|
* \param alphaOperation the SDL_BlendOperation used to combine the alpha
|
||||||
|
* component of the source and destination pixels.
|
||||||
|
* \returns an SDL_BlendMode that represents the chosen factors and
|
||||||
|
* operations.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetRenderDrawBlendMode
|
||||||
|
* \sa SDL_GetRenderDrawBlendMode
|
||||||
|
* \sa SDL_SetTextureBlendMode
|
||||||
|
* \sa SDL_GetTextureBlendMode
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ComposeCustomBlendMode")] public static extern BlendMode ComposeCustomBlendMode(BlendFactor srcColorFactor, BlendFactor dstColorFactor, BlendOperation colorOperation, BlendFactor srcAlphaFactor, BlendFactor dstAlphaFactor, BlendOperation alphaOperation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_blendmode_h_ */
|
||||||
546
src/SDL_camera.bf
Normal file
546
src/SDL_camera.bf
Normal file
@@ -0,0 +1,546 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryCamera
|
||||||
|
*
|
||||||
|
* Video capture for the SDL library.
|
||||||
|
*
|
||||||
|
* This API lets apps read input from video sources, like webcams. Camera
|
||||||
|
* devices can be enumerated, queried, and opened. Once opened, it will
|
||||||
|
* provide SDL_Surface objects as new frames of video come in. These surfaces
|
||||||
|
* can be uploaded to an SDL_Texture or processed as pixels in memory.
|
||||||
|
*
|
||||||
|
* Several platforms will alert the user if an app tries to access a camera,
|
||||||
|
* and some will present a UI asking the user if your application should be
|
||||||
|
* allowed to obtain images at all, which they can deny. A successfully opened
|
||||||
|
* camera will not provide images until permission is granted. Applications,
|
||||||
|
* after opening a camera device, can see if they were granted access by
|
||||||
|
* either polling with the SDL_GetCameraPermissionState() function, or waiting
|
||||||
|
* for an SDL_EVENT_CAMERA_DEVICE_APPROVED or SDL_EVENT_CAMERA_DEVICE_DENIED
|
||||||
|
* event. Platforms that don't have any user approval process will report
|
||||||
|
* approval immediately.
|
||||||
|
*
|
||||||
|
* Note that SDL cameras only provide video as individual frames; they will
|
||||||
|
* not provide full-motion video encoded in a movie file format, although an
|
||||||
|
* app is free to encode the acquired frames into any format it likes. It also
|
||||||
|
* does not provide audio from the camera hardware through this API; not only
|
||||||
|
* do many webcams not have microphones at all, many people--from streamers to
|
||||||
|
* people on Zoom calls--will want to use a separate microphone regardless of
|
||||||
|
* the camera. In any case, recorded audio will be available through SDL's
|
||||||
|
* audio API no matter what hardware provides the microphone.
|
||||||
|
*
|
||||||
|
* ## Camera gotchas
|
||||||
|
*
|
||||||
|
* Consumer-level camera hardware tends to take a little while to warm up,
|
||||||
|
* once the device has been opened. Generally most camera apps have some sort
|
||||||
|
* of UI to take a picture (a button to snap a pic while a preview is showing,
|
||||||
|
* some sort of multi-second countdown for the user to pose, like a photo
|
||||||
|
* booth), which puts control in the users' hands, or they are intended to
|
||||||
|
* stay on for long times (Pokemon Go, etc).
|
||||||
|
*
|
||||||
|
* It's not uncommon that a newly-opened camera will provide a couple of
|
||||||
|
* completely black frames, maybe followed by some under-exposed images. If
|
||||||
|
* taking a single frame automatically, or recording video from a camera's
|
||||||
|
* input without the user initiating it from a preview, it could be wise to
|
||||||
|
* drop the first several frames (if not the first several _seconds_ worth of
|
||||||
|
* frames!) before using images from a camera.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a unique ID for a camera device for the time it is connected to the
|
||||||
|
* system, and is never reused for the lifetime of the application.
|
||||||
|
*
|
||||||
|
* If the device is disconnected and reconnected, it will get a new ID.
|
||||||
|
*
|
||||||
|
* The value 0 is an invalid ID.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetCameras
|
||||||
|
*/
|
||||||
|
public typealias CameraID = Uint32;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The opaque structure used to identify an opened SDL camera.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct Camera;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of an output format for a camera device.
|
||||||
|
*
|
||||||
|
* Cameras often support multiple formats; each one will be encapsulated in
|
||||||
|
* this struct.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetCameraSupportedFormats
|
||||||
|
* \sa SDL_GetCameraFormat
|
||||||
|
*/
|
||||||
|
[CRepr] public struct CameraSpec
|
||||||
|
{
|
||||||
|
public PixelFormat format; /**< Frame format */
|
||||||
|
public Colorspace colorspace; /**< Frame colorspace */
|
||||||
|
public c_int width; /**< Frame width */
|
||||||
|
public c_int height; /**< Frame height */
|
||||||
|
public c_int framerate_numerator; /**< Frame rate numerator ((num / denom) == FPS, (denom / num) == duration in seconds) */
|
||||||
|
public c_int framerate_denominator; /**< Frame rate denominator ((num / denom) == FPS, (denom / num) == duration in seconds) */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The position of camera in relation to system device.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetCameraPosition
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum CameraPosition : c_int
|
||||||
|
{
|
||||||
|
Unknown,
|
||||||
|
FrontFacing,
|
||||||
|
BackFacing,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current state of a request for camera access.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.4.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetCameraPermissionState
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum CameraPermissionState : c_int
|
||||||
|
{
|
||||||
|
Denied = -1,
|
||||||
|
Pending,
|
||||||
|
Approved,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this function to get the number of built-in camera drivers.
|
||||||
|
*
|
||||||
|
* This function returns a hardcoded number. This never returns a negative
|
||||||
|
* value; if there are no drivers compiled into this build of SDL, this
|
||||||
|
* function returns zero. The presence of a driver in this list does not mean
|
||||||
|
* it will function, it just means SDL is capable of interacting with that
|
||||||
|
* interface. For example, a build of SDL might have v4l2 support, but if
|
||||||
|
* there's no kernel support available, SDL's v4l2 driver would fail if used.
|
||||||
|
*
|
||||||
|
* By default, SDL tries all drivers, in its preferred order, until one is
|
||||||
|
* found to be usable.
|
||||||
|
*
|
||||||
|
* \returns the number of built-in camera drivers.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetCameraDriver
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetNumCameraDrivers")] public static extern c_int GetNumCameraDrivers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this function to get the name of a built in camera driver.
|
||||||
|
*
|
||||||
|
* The list of camera drivers is given in the order that they are normally
|
||||||
|
* initialized by default; the drivers that seem more reasonable to choose
|
||||||
|
* first (as far as the SDL developers believe) are earlier in the list.
|
||||||
|
*
|
||||||
|
* The names of drivers are all simple, low-ASCII identifiers, like "v4l2",
|
||||||
|
* "coremedia" or "android". These never have Unicode characters, and are not
|
||||||
|
* meant to be proper names.
|
||||||
|
*
|
||||||
|
* \param index the index of the camera driver; the value ranges from 0 to
|
||||||
|
* SDL_GetNumCameraDrivers() - 1.
|
||||||
|
* \returns the name of the camera driver at the requested index, or NULL if
|
||||||
|
* an invalid index was specified.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetNumCameraDrivers
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetCameraDriver")] public static extern c_char* GetCameraDriver(c_int index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the current camera driver.
|
||||||
|
*
|
||||||
|
* The names of drivers are all simple, low-ASCII identifiers, like "v4l2",
|
||||||
|
* "coremedia" or "android". These never have Unicode characters, and are not
|
||||||
|
* meant to be proper names.
|
||||||
|
*
|
||||||
|
* \returns the name of the current camera driver or NULL if no driver has
|
||||||
|
* been initialized.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetCurrentCameraDriver")] public static extern c_char* GetCurrentCameraDriver();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of currently connected camera devices.
|
||||||
|
*
|
||||||
|
* \param count a pointer filled in with the number of cameras returned, may
|
||||||
|
* be NULL.
|
||||||
|
* \returns a 0 terminated array of camera instance IDs or NULL on failure;
|
||||||
|
* call SDL_GetError() for more information. This should be freed
|
||||||
|
* with SDL_free() when it is no longer needed.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_OpenCamera
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetCameras")] public static extern CameraID* GetCameras(out c_int count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list of native formats/sizes a camera supports.
|
||||||
|
*
|
||||||
|
* This returns a list of all formats and frame sizes that a specific camera
|
||||||
|
* can offer. This is useful if your app can accept a variety of image formats
|
||||||
|
* and sizes and so want to find the optimal spec that doesn't require
|
||||||
|
* conversion.
|
||||||
|
*
|
||||||
|
* This function isn't strictly required; if you call SDL_OpenCamera with a
|
||||||
|
* NULL spec, SDL will choose a native format for you, and if you instead
|
||||||
|
* specify a desired format, it will transparently convert to the requested
|
||||||
|
* format on your behalf.
|
||||||
|
*
|
||||||
|
* If `count` is not NULL, it will be filled with the number of elements in
|
||||||
|
* the returned array.
|
||||||
|
*
|
||||||
|
* Note that it's legal for a camera to supply an empty list. This is what
|
||||||
|
* will happen on Emscripten builds, since that platform won't tell _anything_
|
||||||
|
* about available cameras until you've opened one, and won't even tell if
|
||||||
|
* there _is_ a camera until the user has given you permission to check
|
||||||
|
* through a scary warning popup.
|
||||||
|
*
|
||||||
|
* \param instance_id the camera device instance ID.
|
||||||
|
* \param count a pointer filled in with the number of elements in the list,
|
||||||
|
* may be NULL.
|
||||||
|
* \returns a NULL terminated array of pointers to SDL_CameraSpec or NULL on
|
||||||
|
* failure; call SDL_GetError() for more information. This is a
|
||||||
|
* single allocation that should be freed with SDL_free() when it is
|
||||||
|
* no longer needed.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetCameras
|
||||||
|
* \sa SDL_OpenCamera
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetCameraSupportedFormats")] public static extern CameraSpec** GetCameraSupportedFormats(CameraID instance_id, out c_int count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the human-readable device name for a camera.
|
||||||
|
*
|
||||||
|
* \param instance_id the camera device instance ID.
|
||||||
|
* \returns a human-readable device name or NULL on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetCameras
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetCameraName")] public static extern c_char* GetCameraName(CameraID instance_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the position of the camera in relation to the system.
|
||||||
|
*
|
||||||
|
* Most platforms will report UNKNOWN, but mobile devices, like phones, can
|
||||||
|
* often make a distinction between cameras on the front of the device (that
|
||||||
|
* points towards the user, for taking "selfies") and cameras on the back (for
|
||||||
|
* filming in the direction the user is facing).
|
||||||
|
*
|
||||||
|
* \param instance_id the camera device instance ID.
|
||||||
|
* \returns the position of the camera on the system hardware.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetCameras
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetCameraPosition")] public static extern CameraPosition GetCameraPosition(CameraID instance_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a video recording device (a "camera").
|
||||||
|
*
|
||||||
|
* You can open the device with any reasonable spec, and if the hardware can't
|
||||||
|
* directly support it, it will convert data seamlessly to the requested
|
||||||
|
* format. This might incur overhead, including scaling of image data.
|
||||||
|
*
|
||||||
|
* If you would rather accept whatever format the device offers, you can pass
|
||||||
|
* a NULL spec here and it will choose one for you (and you can use
|
||||||
|
* SDL_Surface's conversion/scaling functions directly if necessary).
|
||||||
|
*
|
||||||
|
* You can call SDL_GetCameraFormat() to get the actual data format if passing
|
||||||
|
* a NULL spec here. You can see the exact specs a device can support without
|
||||||
|
* conversion with SDL_GetCameraSupportedFormats().
|
||||||
|
*
|
||||||
|
* SDL will not attempt to emulate framerate; it will try to set the hardware
|
||||||
|
* to the rate closest to the requested speed, but it won't attempt to limit
|
||||||
|
* or duplicate frames artificially; call SDL_GetCameraFormat() to see the
|
||||||
|
* actual framerate of the opened the device, and check your timestamps if
|
||||||
|
* this is crucial to your app!
|
||||||
|
*
|
||||||
|
* Note that the camera is not usable until the user approves its use! On some
|
||||||
|
* platforms, the operating system will prompt the user to permit access to
|
||||||
|
* the camera, and they can choose Yes or No at that point. Until they do, the
|
||||||
|
* camera will not be usable. The app should either wait for an
|
||||||
|
* SDL_EVENT_CAMERA_DEVICE_APPROVED (or SDL_EVENT_CAMERA_DEVICE_DENIED) event,
|
||||||
|
* or poll SDL_GetCameraPermissionState() occasionally until it returns
|
||||||
|
* non-zero. On platforms that don't require explicit user approval (and
|
||||||
|
* perhaps in places where the user previously permitted access), the approval
|
||||||
|
* event might come immediately, but it might come seconds, minutes, or hours
|
||||||
|
* later!
|
||||||
|
*
|
||||||
|
* \param instance_id the camera device instance ID.
|
||||||
|
* \param spec the desired format for data the device will provide. Can be
|
||||||
|
* NULL.
|
||||||
|
* \returns an SDL_Camera object or NULL on failure; call SDL_GetError() for
|
||||||
|
* more information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetCameras
|
||||||
|
* \sa SDL_GetCameraFormat
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OpenCamera")] public static extern Camera* OpenCamera(CameraID instance_id, CameraSpec* spec);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query if camera access has been approved by the user.
|
||||||
|
*
|
||||||
|
* Cameras will not function between when the device is opened by the app and
|
||||||
|
* when the user permits access to the hardware. On some platforms, this
|
||||||
|
* presents as a popup dialog where the user has to explicitly approve access;
|
||||||
|
* on others the approval might be implicit and not alert the user at all.
|
||||||
|
*
|
||||||
|
* This function can be used to check the status of that approval. It will
|
||||||
|
* return SDL_CAMERA_PERMISSION_STATE_PENDING if waiting for user response,
|
||||||
|
* SDL_CAMERA_PERMISSION_STATE_APPROVED if the camera is approved for use, and
|
||||||
|
* SDL_CAMERA_PERMISSION_STATE_DENIED if the user denied access.
|
||||||
|
*
|
||||||
|
* Instead of polling with this function, you can wait for a
|
||||||
|
* SDL_EVENT_CAMERA_DEVICE_APPROVED (or SDL_EVENT_CAMERA_DEVICE_DENIED) event
|
||||||
|
* in the standard SDL event loop, which is guaranteed to be sent once when
|
||||||
|
* permission to use the camera is decided.
|
||||||
|
*
|
||||||
|
* If a camera is declined, there's nothing to be done but call
|
||||||
|
* SDL_CloseCamera() to dispose of it.
|
||||||
|
*
|
||||||
|
* \param camera the opened camera device to query.
|
||||||
|
* \returns an SDL_CameraPermissionState value indicating if access is
|
||||||
|
* granted, or `SDL_CAMERA_PERMISSION_STATE_PENDING` if the decision
|
||||||
|
* is still pending.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_OpenCamera
|
||||||
|
* \sa SDL_CloseCamera
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetCameraPermissionState")] public static extern CameraPermissionState GetCameraPermissionState(Camera* camera);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the instance ID of an opened camera.
|
||||||
|
*
|
||||||
|
* \param camera an SDL_Camera to query.
|
||||||
|
* \returns the instance ID of the specified camera on success or 0 on
|
||||||
|
* failure; call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_OpenCamera
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetCameraID")] public static extern CameraID GetCameraID(Camera* camera);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the properties associated with an opened camera.
|
||||||
|
*
|
||||||
|
* \param camera the SDL_Camera obtained from SDL_OpenCamera().
|
||||||
|
* \returns a valid property ID on success or 0 on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetCameraProperties")] public static extern PropertiesID GetCameraProperties(Camera* camera);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the spec that a camera is using when generating images.
|
||||||
|
*
|
||||||
|
* Note that this might not be the native format of the hardware, as SDL might
|
||||||
|
* be converting to this format behind the scenes.
|
||||||
|
*
|
||||||
|
* If the system is waiting for the user to approve access to the camera, as
|
||||||
|
* some platforms require, this will return false, but this isn't necessarily
|
||||||
|
* a fatal error; you should either wait for an
|
||||||
|
* SDL_EVENT_CAMERA_DEVICE_APPROVED (or SDL_EVENT_CAMERA_DEVICE_DENIED) event,
|
||||||
|
* or poll SDL_GetCameraPermissionState() occasionally until it returns
|
||||||
|
* non-zero.
|
||||||
|
*
|
||||||
|
* \param camera opened camera device.
|
||||||
|
* \param spec the SDL_CameraSpec to be initialized by this function.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_OpenCamera
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetCameraFormat")] public static extern bool GetCameraFormat(Camera* camera, CameraSpec* spec);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acquire a frame.
|
||||||
|
*
|
||||||
|
* The frame is a memory pointer to the image data, whose size and format are
|
||||||
|
* given by the spec requested when opening the device.
|
||||||
|
*
|
||||||
|
* This is a non blocking API. If there is a frame available, a non-NULL
|
||||||
|
* surface is returned, and timestampNS will be filled with a non-zero value.
|
||||||
|
*
|
||||||
|
* Note that an error case can also return NULL, but a NULL by itself is
|
||||||
|
* normal and just signifies that a new frame is not yet available. Note that
|
||||||
|
* even if a camera device fails outright (a USB camera is unplugged while in
|
||||||
|
* use, etc), SDL will send an event separately to notify the app, but
|
||||||
|
* continue to provide blank frames at ongoing intervals until
|
||||||
|
* SDL_CloseCamera() is called, so real failure here is almost always an out
|
||||||
|
* of memory condition.
|
||||||
|
*
|
||||||
|
* After use, the frame should be released with SDL_ReleaseCameraFrame(). If
|
||||||
|
* you don't do this, the system may stop providing more video!
|
||||||
|
*
|
||||||
|
* Do not call SDL_DestroySurface() on the returned surface! It must be given
|
||||||
|
* back to the camera subsystem with SDL_ReleaseCameraFrame!
|
||||||
|
*
|
||||||
|
* If the system is waiting for the user to approve access to the camera, as
|
||||||
|
* some platforms require, this will return NULL (no frames available); you
|
||||||
|
* should either wait for an SDL_EVENT_CAMERA_DEVICE_APPROVED (or
|
||||||
|
* SDL_EVENT_CAMERA_DEVICE_DENIED) event, or poll
|
||||||
|
* SDL_GetCameraPermissionState() occasionally until it returns non-zero.
|
||||||
|
*
|
||||||
|
* \param camera opened camera device.
|
||||||
|
* \param timestampNS a pointer filled in with the frame's timestamp, or 0 on
|
||||||
|
* error. Can be NULL.
|
||||||
|
* \returns a new frame of video on success, NULL if none is currently
|
||||||
|
* available.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ReleaseCameraFrame
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_AcquireCameraFrame")] public static extern Surface* AcquireCameraFrame(Camera* camera, out Uint64 timestampNS);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Release a frame of video acquired from a camera.
|
||||||
|
*
|
||||||
|
* Let the back-end re-use the internal buffer for camera.
|
||||||
|
*
|
||||||
|
* This function _must_ be called only on surface objects returned by
|
||||||
|
* SDL_AcquireCameraFrame(). This function should be called as quickly as
|
||||||
|
* possible after acquisition, as SDL keeps a small FIFO queue of surfaces for
|
||||||
|
* video frames; if surfaces aren't released in a timely manner, SDL may drop
|
||||||
|
* upcoming video frames from the camera.
|
||||||
|
*
|
||||||
|
* If the app needs to keep the surface for a significant time, they should
|
||||||
|
* make a copy of it and release the original.
|
||||||
|
*
|
||||||
|
* The app should not use the surface again after calling this function;
|
||||||
|
* assume the surface is freed and the pointer is invalid.
|
||||||
|
*
|
||||||
|
* \param camera opened camera device.
|
||||||
|
* \param frame the video frame surface to release.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AcquireCameraFrame
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ReleaseCameraFrame")] public static extern void ReleaseCameraFrame(Camera* camera, Surface* frame);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this function to shut down camera processing and close the camera
|
||||||
|
* device.
|
||||||
|
*
|
||||||
|
* \param camera opened camera device.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread, but no
|
||||||
|
* thread may reference `device` once this function is called.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_OpenCamera
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CloseCamera")] public static extern void CloseCamera(Camera* camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_camera_h_ */
|
||||||
342
src/SDL_clipboard.bf
Normal file
342
src/SDL_clipboard.bf
Normal file
@@ -0,0 +1,342 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryClipboard
|
||||||
|
*
|
||||||
|
* SDL provides access to the system clipboard, both for reading information
|
||||||
|
* from other processes and publishing information of its own.
|
||||||
|
*
|
||||||
|
* This is not just text! SDL apps can access and publish data by mimetype.
|
||||||
|
*
|
||||||
|
* ## Basic use (text)
|
||||||
|
*
|
||||||
|
* Obtaining and publishing simple text to the system clipboard is as easy as
|
||||||
|
* calling SDL_GetClipboardText() and SDL_SetClipboardText(), respectively.
|
||||||
|
* These deal with C strings in UTF-8 encoding. Data transmission and encoding
|
||||||
|
* conversion is completely managed by SDL.
|
||||||
|
*
|
||||||
|
* ## Clipboard callbacks (data other than text)
|
||||||
|
*
|
||||||
|
* Things get more complicated when the clipboard contains something other
|
||||||
|
* than text. Not only can the system clipboard contain data of any type, in
|
||||||
|
* some cases it can contain the same data in different formats! For example,
|
||||||
|
* an image painting app might let the user copy a graphic to the clipboard,
|
||||||
|
* and offers it in .BMP, .JPG, or .PNG format for other apps to consume.
|
||||||
|
*
|
||||||
|
* Obtaining clipboard data ("pasting") like this is a matter of calling
|
||||||
|
* SDL_GetClipboardData() and telling it the mimetype of the data you want.
|
||||||
|
* But how does one know if that format is available? SDL_HasClipboardData()
|
||||||
|
* can report if a specific mimetype is offered, and
|
||||||
|
* SDL_GetClipboardMimeTypes() can provide the entire list of mimetypes
|
||||||
|
* available, so the app can decide what to do with the data and what formats
|
||||||
|
* it can support.
|
||||||
|
*
|
||||||
|
* Setting the clipboard ("copying") to arbitrary data is done with
|
||||||
|
* SDL_SetClipboardData. The app does not provide the data in this call, but
|
||||||
|
* rather the mimetypes it is willing to provide and a callback function.
|
||||||
|
* During the callback, the app will generate the data. This allows massive
|
||||||
|
* data sets to be provided to the clipboard, without any data being copied
|
||||||
|
* before it is explicitly requested. More specifically, it allows an app to
|
||||||
|
* offer data in multiple formats without providing a copy of all of them
|
||||||
|
* upfront. If the app has an image that it could provide in PNG or JPG
|
||||||
|
* format, it doesn't have to encode it to either of those unless and until
|
||||||
|
* something tries to paste it.
|
||||||
|
*
|
||||||
|
* ## Primary Selection
|
||||||
|
*
|
||||||
|
* The X11 and Wayland video targets have a concept of the "primary selection"
|
||||||
|
* in addition to the usual clipboard. This is generally highlighted (but not
|
||||||
|
* explicitly copied) text from various apps. SDL offers APIs for this through
|
||||||
|
* SDL_GetPrimarySelectionText() and SDL_SetPrimarySelectionText(). SDL offers
|
||||||
|
* these APIs on platforms without this concept, too, but only so far that it
|
||||||
|
* will keep a copy of a string that the app sets for later retrieval; the
|
||||||
|
* operating system will not ever attempt to change the string externally if
|
||||||
|
* it doesn't support a primary selection.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Function prototypes */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put UTF-8 text into the clipboard.
|
||||||
|
*
|
||||||
|
* \param text the text to store in the clipboard.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetClipboardText
|
||||||
|
* \sa SDL_HasClipboardText
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetClipboardText")] public static extern bool SetClipboardText(c_char* text);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get UTF-8 text from the clipboard.
|
||||||
|
*
|
||||||
|
* This function returns an empty string if there is not enough memory left
|
||||||
|
* for a copy of the clipboard's content.
|
||||||
|
*
|
||||||
|
* \returns the clipboard text on success or an empty string on failure; call
|
||||||
|
* SDL_GetError() for more information. This should be freed with
|
||||||
|
* SDL_free() when it is no longer needed.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasClipboardText
|
||||||
|
* \sa SDL_SetClipboardText
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetClipboardText")] public static extern c_char* GetClipboardText();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query whether the clipboard exists and contains a non-empty text string.
|
||||||
|
*
|
||||||
|
* \returns true if the clipboard has text, or false if it does not.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetClipboardText
|
||||||
|
* \sa SDL_SetClipboardText
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasClipboardText")] public static extern bool HasClipboardText();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put UTF-8 text into the primary selection.
|
||||||
|
*
|
||||||
|
* \param text the text to store in the primary selection.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetPrimarySelectionText
|
||||||
|
* \sa SDL_HasPrimarySelectionText
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetPrimarySelectionText")] public static extern bool SetPrimarySelectionText(c_char* text);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get UTF-8 text from the primary selection.
|
||||||
|
*
|
||||||
|
* This function returns an empty string if there is not enough memory left
|
||||||
|
* for a copy of the primary selection's content.
|
||||||
|
*
|
||||||
|
* \returns the primary selection text on success or an empty string on
|
||||||
|
* failure; call SDL_GetError() for more information. This should be
|
||||||
|
* freed with SDL_free() when it is no longer needed.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasPrimarySelectionText
|
||||||
|
* \sa SDL_SetPrimarySelectionText
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetPrimarySelectionText")] public static extern c_char* GetPrimarySelectionText();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query whether the primary selection exists and contains a non-empty text
|
||||||
|
* string.
|
||||||
|
*
|
||||||
|
* \returns true if the primary selection has text, or false if it does not.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetPrimarySelectionText
|
||||||
|
* \sa SDL_SetPrimarySelectionText
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasPrimarySelectionText")] public static extern bool HasPrimarySelectionText();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback function that will be called when data for the specified mime-type
|
||||||
|
* is requested by the OS.
|
||||||
|
*
|
||||||
|
* The callback function is called with NULL as the mime_type when the
|
||||||
|
* clipboard is cleared or new data is set. The clipboard is automatically
|
||||||
|
* cleared in SDL_Quit().
|
||||||
|
*
|
||||||
|
* \param userdata a pointer to the provided user data.
|
||||||
|
* \param mime_type the requested mime-type.
|
||||||
|
* \param size a pointer filled in with the length of the returned data.
|
||||||
|
* \returns a pointer to the data for the provided mime-type. Returning NULL
|
||||||
|
* or setting the length to 0 will cause zero length data to be sent
|
||||||
|
* to the "receiver", which should be able to handle this. The
|
||||||
|
* returned data will not be freed, so it needs to be retained and
|
||||||
|
* dealt with internally.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetClipboardData
|
||||||
|
*/
|
||||||
|
public function void* ClipboardDataCallback(void* userdata, c_char* mime_type, c_size* size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback function that will be called when the clipboard is cleared, or
|
||||||
|
* when new data is set.
|
||||||
|
*
|
||||||
|
* \param userdata a pointer to the provided user data.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetClipboardData
|
||||||
|
*/
|
||||||
|
public function void ClipboardCleanupCallback(void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offer clipboard data to the OS.
|
||||||
|
*
|
||||||
|
* Tell the operating system that the application is offering clipboard data
|
||||||
|
* for each of the provided mime-types. Once another application requests the
|
||||||
|
* data the callback function will be called, allowing it to generate and
|
||||||
|
* respond with the data for the requested mime-type.
|
||||||
|
*
|
||||||
|
* The size of text data does not include any terminator, and the text does
|
||||||
|
* not need to be null-terminated (e.g., you can directly copy a portion of a
|
||||||
|
* document).
|
||||||
|
*
|
||||||
|
* \param callback a function pointer to the function that provides the
|
||||||
|
* clipboard data.
|
||||||
|
* \param cleanup a function pointer to the function that cleans up the
|
||||||
|
* clipboard data.
|
||||||
|
* \param userdata an opaque pointer that will be forwarded to the callbacks.
|
||||||
|
* \param mime_types a list of mime-types that are being offered. SDL copies
|
||||||
|
* the given list.
|
||||||
|
* \param num_mime_types the number of mime-types in the mime_types list.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ClearClipboardData
|
||||||
|
* \sa SDL_GetClipboardData
|
||||||
|
* \sa SDL_HasClipboardData
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetClipboardData")] public static extern bool SetClipboardData(ClipboardDataCallback callback, ClipboardCleanupCallback cleanup, void* userdata, c_char** mime_types, c_size num_mime_types);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the clipboard data.
|
||||||
|
*
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetClipboardData
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ClearClipboardData")] public static extern bool ClearClipboardData();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the data from the clipboard for a given mime type.
|
||||||
|
*
|
||||||
|
* The size of text data does not include the terminator, but the text is
|
||||||
|
* guaranteed to be null-terminated.
|
||||||
|
*
|
||||||
|
* \param mime_type the mime type to read from the clipboard.
|
||||||
|
* \param size a pointer filled in with the length of the returned data.
|
||||||
|
* \returns the retrieved data buffer or NULL on failure; call SDL_GetError()
|
||||||
|
* for more information. This should be freed with SDL_free() when it
|
||||||
|
* is no longer needed.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasClipboardData
|
||||||
|
* \sa SDL_SetClipboardData
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetClipboardData")] public static extern void* GetClipboardData(c_char* mime_type, out c_size size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query whether there is data in the clipboard for the provided mime type.
|
||||||
|
*
|
||||||
|
* \param mime_type the mime type to check for data.
|
||||||
|
* \returns true if data exists in the clipboard for the provided mime type,
|
||||||
|
* false if it does not.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetClipboardData
|
||||||
|
* \sa SDL_GetClipboardData
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasClipboardData")] public static extern bool HasClipboardData(c_char* mime_type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the list of mime types available in the clipboard.
|
||||||
|
*
|
||||||
|
* \param num_mime_types a pointer filled with the number of mime types, may
|
||||||
|
* be NULL.
|
||||||
|
* \returns a null-terminated array of strings with mime types, or NULL on
|
||||||
|
* failure; call SDL_GetError() for more information. This should be
|
||||||
|
* freed with SDL_free() when it is no longer needed.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetClipboardData
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetClipboardMimeTypes")] public static extern c_char** GetClipboardMimeTypes(c_size* num_mime_types);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_clipboard_h_ */
|
||||||
49
src/SDL_close_code.bf
Normal file
49
src/SDL_close_code.bf
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file reverses the effects of SDL_begin_code.h and should be included
|
||||||
|
* after you finish any function and structure declarations in your headers.
|
||||||
|
*
|
||||||
|
* SDL's headers use this; applications generally should not include this
|
||||||
|
* header directly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Reset structure packing at previous byte alignment */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Compiler needs structure packing set */
|
||||||
385
src/SDL_cpuinfo.bf
Normal file
385
src/SDL_cpuinfo.bf
Normal file
@@ -0,0 +1,385 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* WIKI CATEGORY: CPUInfo */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryCPUInfo
|
||||||
|
*
|
||||||
|
* CPU feature detection for SDL.
|
||||||
|
*
|
||||||
|
* These functions are largely concerned with reporting if the system has
|
||||||
|
* access to various SIMD instruction sets, but also has other important info
|
||||||
|
* to share, such as system RAM size and number of logical CPU cores.
|
||||||
|
*
|
||||||
|
* CPU instruction set checks, like SDL_HasSSE() and SDL_HasNEON(), are
|
||||||
|
* available on all platforms, even if they don't make sense (an ARM processor
|
||||||
|
* will never have SSE and an x86 processor will never have NEON, for example,
|
||||||
|
* but these functions still exist and will simply return false in these
|
||||||
|
* cases).
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A guess for the cacheline size used for padding.
|
||||||
|
*
|
||||||
|
* Most x86 processors have a 64 byte cache line. The 64-bit PowerPC
|
||||||
|
* processors have a 128 byte cache line. We use the larger value to be
|
||||||
|
* generally safe.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public const let CACHELINE_SIZE = 128;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of logical CPU cores available.
|
||||||
|
*
|
||||||
|
* \returns the total number of logical CPU cores. On CPUs that include
|
||||||
|
* technologies such as hyperthreading, the number of logical cores
|
||||||
|
* may be more than the number of physical cores.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetNumLogicalCPUCores")] public static extern c_int GetNumLogicalCPUCores();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine the L1 cache line size of the CPU.
|
||||||
|
*
|
||||||
|
* This is useful for determining multi-threaded structure padding or SIMD
|
||||||
|
* prefetch sizes.
|
||||||
|
*
|
||||||
|
* \returns the L1 cache line size of the CPU, in bytes.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetCPUCacheLineSize")] public static extern c_int GetCPUCacheLineSize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the CPU has AltiVec features.
|
||||||
|
*
|
||||||
|
* This always returns false on CPUs that aren't using PowerPC instruction
|
||||||
|
* sets.
|
||||||
|
*
|
||||||
|
* \returns true if the CPU has AltiVec features or false if not.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasAltiVec")] public static extern bool HasAltiVec();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the CPU has MMX features.
|
||||||
|
*
|
||||||
|
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||||
|
*
|
||||||
|
* \returns true if the CPU has MMX features or false if not.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasMMX")] public static extern bool HasMMX();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the CPU has SSE features.
|
||||||
|
*
|
||||||
|
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||||
|
*
|
||||||
|
* \returns true if the CPU has SSE features or false if not.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasSSE2
|
||||||
|
* \sa SDL_HasSSE3
|
||||||
|
* \sa SDL_HasSSE41
|
||||||
|
* \sa SDL_HasSSE42
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasSSE")] public static extern bool HasSSE();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the CPU has SSE2 features.
|
||||||
|
*
|
||||||
|
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||||
|
*
|
||||||
|
* \returns true if the CPU has SSE2 features or false if not.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasSSE
|
||||||
|
* \sa SDL_HasSSE3
|
||||||
|
* \sa SDL_HasSSE41
|
||||||
|
* \sa SDL_HasSSE42
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasSSE2")] public static extern bool HasSSE2();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the CPU has SSE3 features.
|
||||||
|
*
|
||||||
|
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||||
|
*
|
||||||
|
* \returns true if the CPU has SSE3 features or false if not.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasSSE
|
||||||
|
* \sa SDL_HasSSE2
|
||||||
|
* \sa SDL_HasSSE41
|
||||||
|
* \sa SDL_HasSSE42
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasSSE3")] public static extern bool HasSSE3();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the CPU has SSE4.1 features.
|
||||||
|
*
|
||||||
|
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||||
|
*
|
||||||
|
* \returns true if the CPU has SSE4.1 features or false if not.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasSSE
|
||||||
|
* \sa SDL_HasSSE2
|
||||||
|
* \sa SDL_HasSSE3
|
||||||
|
* \sa SDL_HasSSE42
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasSSE41")] public static extern bool HasSSE41();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the CPU has SSE4.2 features.
|
||||||
|
*
|
||||||
|
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||||
|
*
|
||||||
|
* \returns true if the CPU has SSE4.2 features or false if not.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasSSE
|
||||||
|
* \sa SDL_HasSSE2
|
||||||
|
* \sa SDL_HasSSE3
|
||||||
|
* \sa SDL_HasSSE41
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasSSE42")] public static extern bool HasSSE42();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the CPU has AVX features.
|
||||||
|
*
|
||||||
|
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||||
|
*
|
||||||
|
* \returns true if the CPU has AVX features or false if not.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasAVX2
|
||||||
|
* \sa SDL_HasAVX512F
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasAVX")] public static extern bool HasAVX();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the CPU has AVX2 features.
|
||||||
|
*
|
||||||
|
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||||
|
*
|
||||||
|
* \returns true if the CPU has AVX2 features or false if not.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasAVX
|
||||||
|
* \sa SDL_HasAVX512F
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasAVX2")] public static extern bool HasAVX2();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the CPU has AVX-512F (foundation) features.
|
||||||
|
*
|
||||||
|
* This always returns false on CPUs that aren't using Intel instruction sets.
|
||||||
|
*
|
||||||
|
* \returns true if the CPU has AVX-512F features or false if not.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasAVX
|
||||||
|
* \sa SDL_HasAVX2
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasAVX512F")] public static extern bool HasAVX512F();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the CPU has ARM SIMD (ARMv6) features.
|
||||||
|
*
|
||||||
|
* This is different from ARM NEON, which is a different instruction set.
|
||||||
|
*
|
||||||
|
* This always returns false on CPUs that aren't using ARM instruction sets.
|
||||||
|
*
|
||||||
|
* \returns true if the CPU has ARM SIMD features or false if not.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasNEON
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasARMSIMD")] public static extern bool HasARMSIMD();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the CPU has NEON (ARM SIMD) features.
|
||||||
|
*
|
||||||
|
* This always returns false on CPUs that aren't using ARM instruction sets.
|
||||||
|
*
|
||||||
|
* \returns true if the CPU has ARM NEON features or false if not.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasNEON")] public static extern bool HasNEON();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the CPU has LSX (LOONGARCH SIMD) features.
|
||||||
|
*
|
||||||
|
* This always returns false on CPUs that aren't using LOONGARCH instruction
|
||||||
|
* sets.
|
||||||
|
*
|
||||||
|
* \returns true if the CPU has LOONGARCH LSX features or false if not.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasLSX")] public static extern bool HasLSX();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the CPU has LASX (LOONGARCH SIMD) features.
|
||||||
|
*
|
||||||
|
* This always returns false on CPUs that aren't using LOONGARCH instruction
|
||||||
|
* sets.
|
||||||
|
*
|
||||||
|
* \returns true if the CPU has LOONGARCH LASX features or false if not.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasLASX")] public static extern bool HasLASX();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the amount of RAM configured in the system.
|
||||||
|
*
|
||||||
|
* \returns the amount of RAM configured in the system in MiB.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetSystemRAM")] public static extern c_int GetSystemRAM();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report the alignment this system needs for SIMD allocations.
|
||||||
|
*
|
||||||
|
* This will return the minimum number of bytes to which a pointer must be
|
||||||
|
* aligned to be compatible with SIMD instructions on the current machine. For
|
||||||
|
* example, if the machine supports SSE only, it will return 16, but if it
|
||||||
|
* supports AVX-512F, it'll return 64 (etc). This only reports values for
|
||||||
|
* instruction sets SDL knows about, so if your SDL build doesn't have
|
||||||
|
* SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and
|
||||||
|
* not 64 for the AVX-512 instructions that exist but SDL doesn't know about.
|
||||||
|
* Plan accordingly.
|
||||||
|
*
|
||||||
|
* \returns the alignment in bytes needed for available, known SIMD
|
||||||
|
* instructions.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_aligned_alloc
|
||||||
|
* \sa SDL_aligned_free
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetSIMDAlignment")] public static extern c_size GetSIMDAlignment();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report the size of a page of memory.
|
||||||
|
*
|
||||||
|
* Different platforms might have different memory page sizes. In current
|
||||||
|
* times, 4 kilobytes is not unusual, but newer systems are moving to larger
|
||||||
|
* page sizes, and esoteric platforms might have any unexpected size.
|
||||||
|
*
|
||||||
|
* Note that this function can return 0, which means SDL can't determine the
|
||||||
|
* page size on this platform. It will _not_ set an error string to be
|
||||||
|
* retrieved with SDL_GetError() in this case! In this case, defaulting to
|
||||||
|
* 4096 is often a reasonable option.
|
||||||
|
*
|
||||||
|
* \returns the size of a single page of memory, in bytes, or 0 if SDL can't
|
||||||
|
* determine this information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.4.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetSystemPageSize")] public static extern c_int GetSystemPageSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_cpuinfo_h_ */
|
||||||
356
src/SDL_dialog.bf
Normal file
356
src/SDL_dialog.bf
Normal file
@@ -0,0 +1,356 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryDialog
|
||||||
|
*
|
||||||
|
* File dialog support.
|
||||||
|
*
|
||||||
|
* SDL offers file dialogs, to let users select files with native GUI
|
||||||
|
* interfaces. There are "open" dialogs, "save" dialogs, and folder selection
|
||||||
|
* dialogs. The app can control some details, such as filtering to specific
|
||||||
|
* files, or whether multiple files can be selected by the user.
|
||||||
|
*
|
||||||
|
* Note that launching a file dialog is a non-blocking operation; control
|
||||||
|
* returns to the app immediately, and a callback is called later (possibly in
|
||||||
|
* another thread) when the user makes a choice.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An entry for filters for file dialogs.
|
||||||
|
*
|
||||||
|
* `name` is a user-readable label for the filter (for example, "Office
|
||||||
|
* document").
|
||||||
|
*
|
||||||
|
* `pattern` is a semicolon-separated list of file extensions (for example,
|
||||||
|
* "doc;docx"). File extensions may only contain alphanumeric characters,
|
||||||
|
* hyphens, underscores and periods. Alternatively, the whole string can be a
|
||||||
|
* single asterisk ("*"), which serves as an "All files" filter.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_DialogFileCallback
|
||||||
|
* \sa SDL_ShowOpenFileDialog
|
||||||
|
* \sa SDL_ShowSaveFileDialog
|
||||||
|
* \sa SDL_ShowOpenFolderDialog
|
||||||
|
* \sa SDL_ShowFileDialogWithProperties
|
||||||
|
*/
|
||||||
|
[CRepr] public struct DialogFileFilter
|
||||||
|
{
|
||||||
|
public c_char* name;
|
||||||
|
public c_char* pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback used by file dialog functions.
|
||||||
|
*
|
||||||
|
* The specific usage is described in each function.
|
||||||
|
*
|
||||||
|
* If `filelist` is:
|
||||||
|
*
|
||||||
|
* - NULL, an error occurred. Details can be obtained with SDL_GetError().
|
||||||
|
* - A pointer to NULL, the user either didn't choose any file or canceled the
|
||||||
|
* dialog.
|
||||||
|
* - A pointer to non-`NULL`, the user chose one or more files. The argument
|
||||||
|
* is a null-terminated array of pointers to UTF-8 encoded strings, each
|
||||||
|
* containing a path.
|
||||||
|
*
|
||||||
|
* The filelist argument should not be freed; it will automatically be freed
|
||||||
|
* when the callback returns.
|
||||||
|
*
|
||||||
|
* The filter argument is the index of the filter that was selected, or -1 if
|
||||||
|
* no filter was selected or if the platform or method doesn't support
|
||||||
|
* fetching the selected filter.
|
||||||
|
*
|
||||||
|
* In Android, the `filelist` are `content://` URIs. They should be opened
|
||||||
|
* using SDL_IOFromFile() with appropriate modes. This applies both to open
|
||||||
|
* and save file dialog.
|
||||||
|
*
|
||||||
|
* \param userdata an app-provided pointer, for the callback's use.
|
||||||
|
* \param filelist the file(s) chosen by the user.
|
||||||
|
* \param filter index of the selected filter.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_DialogFileFilter
|
||||||
|
* \sa SDL_ShowOpenFileDialog
|
||||||
|
* \sa SDL_ShowSaveFileDialog
|
||||||
|
* \sa SDL_ShowOpenFolderDialog
|
||||||
|
* \sa SDL_ShowFileDialogWithProperties
|
||||||
|
*/
|
||||||
|
public function void DialogFileCallback(void* userdata, c_char** filelist, c_int filter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a dialog that lets the user select a file on their filesystem.
|
||||||
|
*
|
||||||
|
* This is an asynchronous function; it will return immediately, and the
|
||||||
|
* result will be passed to the callback.
|
||||||
|
*
|
||||||
|
* The callback will be invoked with a null-terminated list of files the user
|
||||||
|
* chose. The list will be empty if the user canceled the dialog, and it will
|
||||||
|
* be NULL if an error occurred.
|
||||||
|
*
|
||||||
|
* Note that the callback may be called from a different thread than the one
|
||||||
|
* the function was invoked on.
|
||||||
|
*
|
||||||
|
* Depending on the platform, the user may be allowed to input paths that
|
||||||
|
* don't yet exist.
|
||||||
|
*
|
||||||
|
* On Linux, dialogs may require XDG Portals, which requires DBus, which
|
||||||
|
* requires an event-handling loop. Apps that do not use SDL to handle events
|
||||||
|
* should add a call to SDL_PumpEvents in their main loop.
|
||||||
|
*
|
||||||
|
* \param callback a function pointer to be invoked when the user selects a
|
||||||
|
* file and accepts, or cancels the dialog, or an error
|
||||||
|
* occurs.
|
||||||
|
* \param userdata an optional pointer to pass extra data to the callback when
|
||||||
|
* it will be invoked.
|
||||||
|
* \param window the window that the dialog should be modal for, may be NULL.
|
||||||
|
* Not all platforms support this option.
|
||||||
|
* \param filters a list of filters, may be NULL. See the
|
||||||
|
* [`SDL_DialogFileFilter`](SDL_DialogFileFilter#code-examples)
|
||||||
|
* documentation for examples]. Not all platforms support this
|
||||||
|
* option, and platforms that do support it may allow the user
|
||||||
|
* to ignore the filters. If non-NULL, it must remain valid at
|
||||||
|
* least until the callback is invoked.
|
||||||
|
* \param nfilters the number of filters. Ignored if filters is NULL.
|
||||||
|
* \param default_location the default folder or file to start the dialog at,
|
||||||
|
* may be NULL. Not all platforms support this option.
|
||||||
|
* \param allow_many if non-zero, the user will be allowed to select multiple
|
||||||
|
* entries. Not all platforms support this option.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called only from the main thread. The
|
||||||
|
* callback may be invoked from the same thread or from a
|
||||||
|
* different one, depending on the OS's constraints.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_DialogFileCallback
|
||||||
|
* \sa SDL_DialogFileFilter
|
||||||
|
* \sa SDL_ShowSaveFileDialog
|
||||||
|
* \sa SDL_ShowOpenFolderDialog
|
||||||
|
* \sa SDL_ShowFileDialogWithProperties
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ShowOpenFileDialog")] public static extern void ShowOpenFileDialog(DialogFileCallback callback, void* userdata, Window* window, DialogFileFilter* filters, c_int nfilters, c_char* default_location, bool allow_many);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a dialog that lets the user choose a new or existing file on their
|
||||||
|
* filesystem.
|
||||||
|
*
|
||||||
|
* This is an asynchronous function; it will return immediately, and the
|
||||||
|
* result will be passed to the callback.
|
||||||
|
*
|
||||||
|
* The callback will be invoked with a null-terminated list of files the user
|
||||||
|
* chose. The list will be empty if the user canceled the dialog, and it will
|
||||||
|
* be NULL if an error occurred.
|
||||||
|
*
|
||||||
|
* Note that the callback may be called from a different thread than the one
|
||||||
|
* the function was invoked on.
|
||||||
|
*
|
||||||
|
* The chosen file may or may not already exist.
|
||||||
|
*
|
||||||
|
* On Linux, dialogs may require XDG Portals, which requires DBus, which
|
||||||
|
* requires an event-handling loop. Apps that do not use SDL to handle events
|
||||||
|
* should add a call to SDL_PumpEvents in their main loop.
|
||||||
|
*
|
||||||
|
* \param callback a function pointer to be invoked when the user selects a
|
||||||
|
* file and accepts, or cancels the dialog, or an error
|
||||||
|
* occurs.
|
||||||
|
* \param userdata an optional pointer to pass extra data to the callback when
|
||||||
|
* it will be invoked.
|
||||||
|
* \param window the window that the dialog should be modal for, may be NULL.
|
||||||
|
* Not all platforms support this option.
|
||||||
|
* \param filters a list of filters, may be NULL. Not all platforms support
|
||||||
|
* this option, and platforms that do support it may allow the
|
||||||
|
* user to ignore the filters. If non-NULL, it must remain
|
||||||
|
* valid at least until the callback is invoked.
|
||||||
|
* \param nfilters the number of filters. Ignored if filters is NULL.
|
||||||
|
* \param default_location the default folder or file to start the dialog at,
|
||||||
|
* may be NULL. Not all platforms support this option.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called only from the main thread. The
|
||||||
|
* callback may be invoked from the same thread or from a
|
||||||
|
* different one, depending on the OS's constraints.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_DialogFileCallback
|
||||||
|
* \sa SDL_DialogFileFilter
|
||||||
|
* \sa SDL_ShowOpenFileDialog
|
||||||
|
* \sa SDL_ShowOpenFolderDialog
|
||||||
|
* \sa SDL_ShowFileDialogWithProperties
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ShowSaveFileDialog")] public static extern void ShowSaveFileDialog(DialogFileCallback callback, void* userdata, Window* window, DialogFileFilter* filters, c_int nfilters, c_char* default_location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a dialog that lets the user select a folder on their filesystem.
|
||||||
|
*
|
||||||
|
* This is an asynchronous function; it will return immediately, and the
|
||||||
|
* result will be passed to the callback.
|
||||||
|
*
|
||||||
|
* The callback will be invoked with a null-terminated list of files the user
|
||||||
|
* chose. The list will be empty if the user canceled the dialog, and it will
|
||||||
|
* be NULL if an error occurred.
|
||||||
|
*
|
||||||
|
* Note that the callback may be called from a different thread than the one
|
||||||
|
* the function was invoked on.
|
||||||
|
*
|
||||||
|
* Depending on the platform, the user may be allowed to input paths that
|
||||||
|
* don't yet exist.
|
||||||
|
*
|
||||||
|
* On Linux, dialogs may require XDG Portals, which requires DBus, which
|
||||||
|
* requires an event-handling loop. Apps that do not use SDL to handle events
|
||||||
|
* should add a call to SDL_PumpEvents in their main loop.
|
||||||
|
*
|
||||||
|
* \param callback a function pointer to be invoked when the user selects a
|
||||||
|
* file and accepts, or cancels the dialog, or an error
|
||||||
|
* occurs.
|
||||||
|
* \param userdata an optional pointer to pass extra data to the callback when
|
||||||
|
* it will be invoked.
|
||||||
|
* \param window the window that the dialog should be modal for, may be NULL.
|
||||||
|
* Not all platforms support this option.
|
||||||
|
* \param default_location the default folder or file to start the dialog at,
|
||||||
|
* may be NULL. Not all platforms support this option.
|
||||||
|
* \param allow_many if non-zero, the user will be allowed to select multiple
|
||||||
|
* entries. Not all platforms support this option.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called only from the main thread. The
|
||||||
|
* callback may be invoked from the same thread or from a
|
||||||
|
* different one, depending on the OS's constraints.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_DialogFileCallback
|
||||||
|
* \sa SDL_ShowOpenFileDialog
|
||||||
|
* \sa SDL_ShowSaveFileDialog
|
||||||
|
* \sa SDL_ShowFileDialogWithProperties
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ShowOpenFolderDialog")] public static extern void ShowOpenFolderDialog(DialogFileCallback callback, void* userdata, Window* window, c_char* default_location, bool allow_many);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Various types of file dialogs.
|
||||||
|
*
|
||||||
|
* This is used by SDL_ShowFileDialogWithProperties() to decide what kind of
|
||||||
|
* dialog to present to the user.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ShowFileDialogWithProperties
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum FileDialogType : c_int
|
||||||
|
{
|
||||||
|
Openfile,
|
||||||
|
Savefile,
|
||||||
|
Openfolder,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create and launch a file dialog with the specified properties.
|
||||||
|
*
|
||||||
|
* These are the supported properties:
|
||||||
|
*
|
||||||
|
* - `SDL_PROP_FILE_DIALOG_FILTERS_POINTER`: a pointer to a list of
|
||||||
|
* SDL_DialogFileFilter structs, which will be used as filters for
|
||||||
|
* file-based selections. Ignored if the dialog is an "Open Folder" dialog.
|
||||||
|
* If non-NULL, the array of filters must remain valid at least until the
|
||||||
|
* callback is invoked.
|
||||||
|
* - `SDL_PROP_FILE_DIALOG_NFILTERS_NUMBER`: the number of filters in the
|
||||||
|
* array of filters, if it exists.
|
||||||
|
* - `SDL_PROP_FILE_DIALOG_WINDOW_POINTER`: the window that the dialog should
|
||||||
|
* be modal for.
|
||||||
|
* - `SDL_PROP_FILE_DIALOG_LOCATION_STRING`: the default folder or file to
|
||||||
|
* start the dialog at.
|
||||||
|
* - `SDL_PROP_FILE_DIALOG_MANY_BOOLEAN`: true to allow the user to select
|
||||||
|
* more than one entry.
|
||||||
|
* - `SDL_PROP_FILE_DIALOG_TITLE_STRING`: the title for the dialog.
|
||||||
|
* - `SDL_PROP_FILE_DIALOG_ACCEPT_STRING`: the label that the accept button
|
||||||
|
* should have.
|
||||||
|
* - `SDL_PROP_FILE_DIALOG_CANCEL_STRING`: the label that the cancel button
|
||||||
|
* should have.
|
||||||
|
*
|
||||||
|
* Note that each platform may or may not support any of the properties.
|
||||||
|
*
|
||||||
|
* \param type the type of file dialog.
|
||||||
|
* \param callback a function pointer to be invoked when the user selects a
|
||||||
|
* file and accepts, or cancels the dialog, or an error
|
||||||
|
* occurs.
|
||||||
|
* \param userdata an optional pointer to pass extra data to the callback when
|
||||||
|
* it will be invoked.
|
||||||
|
* \param props the properties to use.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called only from the main thread. The
|
||||||
|
* callback may be invoked from the same thread or from a
|
||||||
|
* different one, depending on the OS's constraints.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_FileDialogType
|
||||||
|
* \sa SDL_DialogFileCallback
|
||||||
|
* \sa SDL_DialogFileFilter
|
||||||
|
* \sa SDL_ShowOpenFileDialog
|
||||||
|
* \sa SDL_ShowSaveFileDialog
|
||||||
|
* \sa SDL_ShowOpenFolderDialog
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ShowFileDialogWithProperties")] public static extern void ShowFileDialogWithProperties(FileDialogType type, DialogFileCallback callback, void* userdata, PropertiesID props);
|
||||||
|
|
||||||
|
public const let PROP_FILE_DIALOG_FILTERS_POINTER = "SDL.filedialog.filters";
|
||||||
|
public const let PROP_FILE_DIALOG_NFILTERS_NUMBER = "SDL.filedialog.nfilters";
|
||||||
|
public const let PROP_FILE_DIALOG_WINDOW_POINTER = "SDL.filedialog.window";
|
||||||
|
public const let PROP_FILE_DIALOG_LOCATION_STRING = "SDL.filedialog.location";
|
||||||
|
public const let PROP_FILE_DIALOG_MANY_BOOLEAN = "SDL.filedialog.many";
|
||||||
|
public const let PROP_FILE_DIALOG_TITLE_STRING = "SDL.filedialog.title";
|
||||||
|
public const let PROP_FILE_DIALOG_ACCEPT_STRING = "SDL.filedialog.accept";
|
||||||
|
public const let PROP_FILE_DIALOG_CANCEL_STRING = "SDL.filedialog.cancel";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_dialog_h_ */
|
||||||
247
src/SDL_dlopennote.bf
Normal file
247
src/SDL_dlopennote.bf
Normal file
@@ -0,0 +1,247 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* WIKI CATEGORY: DlopenNotes */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryDlopenNotes
|
||||||
|
*
|
||||||
|
* This header allows you to annotate your code so external tools know about
|
||||||
|
* dynamic shared library dependencies.
|
||||||
|
*
|
||||||
|
* If you determine that your toolchain doesn't support dlopen notes, you can
|
||||||
|
* disable this feature by defining `SDL_DISABLE_DLOPEN_NOTES`. You can use
|
||||||
|
* this CMake snippet to check for support:
|
||||||
|
*
|
||||||
|
* ```cmake
|
||||||
|
* include(CheckCSourceCompiles)
|
||||||
|
* find_package(SDL3 REQUIRED CONFIG COMPONENTS Headers)
|
||||||
|
* list(APPEND CMAKE_REQUIRED_LIBRARIES SDL3::Headers)
|
||||||
|
* check_c_source_compiles([==[
|
||||||
|
* #include <SDL3/SDL_dlopennote.h>
|
||||||
|
* SDL_ELF_NOTE_DLOPEN("sdl-video",
|
||||||
|
* "Support for video through SDL",
|
||||||
|
* SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
|
||||||
|
* "libSDL-1.2.so.0", "libSDL-2.0.so.0", "libSDL3.so.0"
|
||||||
|
* )
|
||||||
|
* int main(int argc, char *argv[]) {
|
||||||
|
* return argc + argv[0][1];
|
||||||
|
* }
|
||||||
|
* ]==] COMPILER_SUPPORTS_SDL_ELF_NOTE_DLOPEN)
|
||||||
|
* if(NOT COMPILER_SUPPORTS_SDL_ELF_NOTE_DLOPEN)
|
||||||
|
* add_compile_definitions(-DSDL_DISABLE_DLOPEN_NOTE)
|
||||||
|
* endif()
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this macro with SDL_ELF_NOTE_DLOPEN() to note that a dynamic shared
|
||||||
|
* library dependency is optional.
|
||||||
|
*
|
||||||
|
* Optional functionality uses the dependency, the binary will work and the
|
||||||
|
* dependency is only needed for full-featured installations.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.4.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ELF_NOTE_DLOPEN
|
||||||
|
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED
|
||||||
|
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED
|
||||||
|
*/
|
||||||
|
public const let ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED = "suggested";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this macro with SDL_ELF_NOTE_DLOPEN() to note that a dynamic shared
|
||||||
|
* library dependency is recommended.
|
||||||
|
*
|
||||||
|
* Important functionality needs the dependency, the binary will work but in
|
||||||
|
* most cases the dependency should be provided.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.4.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ELF_NOTE_DLOPEN
|
||||||
|
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED
|
||||||
|
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED
|
||||||
|
*/
|
||||||
|
public const let ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED = "recommended";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this macro with SDL_ELF_NOTE_DLOPEN() to note that a dynamic shared
|
||||||
|
* library dependency is required.
|
||||||
|
*
|
||||||
|
* Core functionality needs the dependency, the binary will not work if it
|
||||||
|
* cannot be found.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.4.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ELF_NOTE_DLOPEN
|
||||||
|
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED
|
||||||
|
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED
|
||||||
|
*/
|
||||||
|
public const let ELF_NOTE_DLOPEN_PRIORITY_REQUIRED = "required";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* The dlopen note functionality isn't used on this platform */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* gcc < 3.1 too old */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_PLATFORM_UNIX || SDL_PLATFORM_ANDROID */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Create "unique" variable name using __LINE__,
|
||||||
|
* so creating multiple elf notes on the same line is not supported
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a note that your application has dynamic shared library dependencies.
|
||||||
|
*
|
||||||
|
* You can do this by adding the following to the global scope:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* SDL_ELF_NOTE_DLOPEN(
|
||||||
|
* "png",
|
||||||
|
* "Support for loading PNG images using libpng (required for APNG)",
|
||||||
|
* SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED,
|
||||||
|
* "libpng12.so.0"
|
||||||
|
* )
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* A trailing semicolon is not needed.
|
||||||
|
*
|
||||||
|
* Or if you support multiple versions of a library, you can list them:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* // Our app supports SDL1, SDL2, and SDL3 by dynamically loading them
|
||||||
|
* SDL_ELF_NOTE_DLOPEN(
|
||||||
|
* "SDL",
|
||||||
|
* "Create windows through SDL video backend",
|
||||||
|
* SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED
|
||||||
|
* "libSDL-1.2.so.0", "libSDL2-2.0.so.0", "libSDL3.so.0"
|
||||||
|
* )
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* This macro is not available for compilers that do not support variadic
|
||||||
|
* macro's.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.4.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED
|
||||||
|
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED
|
||||||
|
* \sa SDL_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Variadic macros are not supported */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_dlopennote_h */
|
||||||
653
src/SDL_endian.bf
Normal file
653
src/SDL_endian.bf
Normal file
@@ -0,0 +1,653 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryEndian
|
||||||
|
*
|
||||||
|
* Functions converting endian-specific values to different byte orders.
|
||||||
|
*
|
||||||
|
* These functions either unconditionally swap byte order (SDL_Swap16,
|
||||||
|
* SDL_Swap32, SDL_Swap64, SDL_SwapFloat), or they swap to/from the system's
|
||||||
|
* native byte order (SDL_Swap16LE, SDL_Swap16BE, SDL_Swap32LE, SDL_Swap32BE,
|
||||||
|
* SDL_Swap32LE, SDL_Swap32BE, SDL_SwapFloatLE, SDL_SwapFloatBE). In the
|
||||||
|
* latter case, the functionality is provided by macros that become no-ops if
|
||||||
|
* a swap isn't necessary: on an x86 (littleendian) processor, SDL_Swap32LE
|
||||||
|
* does nothing, but SDL_Swap32BE reverses the bytes of the data. On a PowerPC
|
||||||
|
* processor (bigendian), the macros behavior is reversed.
|
||||||
|
*
|
||||||
|
* The swap routines are inline functions, and attempt to use compiler
|
||||||
|
* intrinsics, inline assembly, and other magic to make byteswapping
|
||||||
|
* efficient.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version,
|
||||||
|
so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* _MM_HINT_T0 */
|
||||||
|
|
||||||
|
/* __PRFCHWINTRIN_H */
|
||||||
|
/* __clang__ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \name The two types of endianness
|
||||||
|
*/
|
||||||
|
/* @{ */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A value to represent littleendian byteorder.
|
||||||
|
*
|
||||||
|
* This is used with the preprocessor macro SDL_BYTEORDER, to determine a
|
||||||
|
* platform's byte ordering:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* #if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||||
|
* SDL_Log("This system is littleendian.");
|
||||||
|
* #endif
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_BYTEORDER
|
||||||
|
* \sa SDL_BIG_ENDIAN
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A value to represent bigendian byteorder.
|
||||||
|
*
|
||||||
|
* This is used with the preprocessor macro SDL_BYTEORDER, to determine a
|
||||||
|
* platform's byte ordering:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* #if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||||
|
* SDL_Log("This system is bigendian.");
|
||||||
|
* #endif
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_BYTEORDER
|
||||||
|
* \sa SDL_LIL_ENDIAN
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* @} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A macro that reports the target system's byte order.
|
||||||
|
*
|
||||||
|
* This is set to either SDL_LIL_ENDIAN or SDL_BIG_ENDIAN (and maybe other
|
||||||
|
* values in the future, if something else becomes popular). This can be
|
||||||
|
* tested with the preprocessor, so decisions can be made at compile time.
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* #if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||||
|
* SDL_Log("This system is bigendian.");
|
||||||
|
* #endif
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_LIL_ENDIAN
|
||||||
|
* \sa SDL_BIG_ENDIAN
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* predefs from newer gcc and clang versions: */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_PLATFORM_LINUX */
|
||||||
|
/* !SDL_BYTEORDER */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A macro that reports the target system's floating point word order.
|
||||||
|
*
|
||||||
|
* This is set to either SDL_LIL_ENDIAN or SDL_BIG_ENDIAN (and maybe other
|
||||||
|
* values in the future, if something else becomes popular). This can be
|
||||||
|
* tested with the preprocessor, so decisions can be made at compile time.
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* #if SDL_FLOATWORDORDER == SDL_BIG_ENDIAN
|
||||||
|
* SDL_Log("This system's floats are bigendian.");
|
||||||
|
* #endif
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_LIL_ENDIAN
|
||||||
|
* \sa SDL_BIG_ENDIAN
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* predefs from newer gcc versions: */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**/
|
||||||
|
|
||||||
|
/* For Maverick, float words are always little-endian. */
|
||||||
|
|
||||||
|
|
||||||
|
/* For FPA, float words are always big-endian. */
|
||||||
|
|
||||||
|
|
||||||
|
/* By default, assume that floats words follow the memory system mode. */
|
||||||
|
|
||||||
|
/* __FLOAT_WORD_ORDER__ */
|
||||||
|
/* !SDL_FLOATWORDORDER */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* various modern compilers may have builtin swap */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* this one is broken */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Byte swap 16-bit integer. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Byte swap 32-bit integer. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Byte swap 64-bit integer. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Separate into high and low 32-bit values and swap them */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Byte-swap a floating point number.
|
||||||
|
*
|
||||||
|
* This will always byte-swap the value, whether it's currently in the native
|
||||||
|
* byteorder of the system or not. You should use SDL_SwapFloatLE or
|
||||||
|
* SDL_SwapFloatBE instead, in most cases.
|
||||||
|
*
|
||||||
|
* Note that this is a forced-inline function in a header, and not a public
|
||||||
|
* API function available in the SDL library (which is to say, the code is
|
||||||
|
* embedded in the calling program and the linker and dynamic loader will not
|
||||||
|
* be able to find this function inside SDL itself).
|
||||||
|
*
|
||||||
|
* \param x the value to byte-swap.
|
||||||
|
* \returns x, with its bytes in the opposite endian order.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* remove extra macros */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Byte-swap an unsigned 16-bit number.
|
||||||
|
*
|
||||||
|
* This will always byte-swap the value, whether it's currently in the native
|
||||||
|
* byteorder of the system or not. You should use SDL_Swap16LE or SDL_Swap16BE
|
||||||
|
* instead, in most cases.
|
||||||
|
*
|
||||||
|
* Note that this is a forced-inline function in a header, and not a public
|
||||||
|
* API function available in the SDL library (which is to say, the code is
|
||||||
|
* embedded in the calling program and the linker and dynamic loader will not
|
||||||
|
* be able to find this function inside SDL itself).
|
||||||
|
*
|
||||||
|
* \param x the value to byte-swap.
|
||||||
|
* \returns `x`, with its bytes in the opposite endian order.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Byte-swap an unsigned 32-bit number.
|
||||||
|
*
|
||||||
|
* This will always byte-swap the value, whether it's currently in the native
|
||||||
|
* byteorder of the system or not. You should use SDL_Swap32LE or SDL_Swap32BE
|
||||||
|
* instead, in most cases.
|
||||||
|
*
|
||||||
|
* Note that this is a forced-inline function in a header, and not a public
|
||||||
|
* API function available in the SDL library (which is to say, the code is
|
||||||
|
* embedded in the calling program and the linker and dynamic loader will not
|
||||||
|
* be able to find this function inside SDL itself).
|
||||||
|
*
|
||||||
|
* \param x the value to byte-swap.
|
||||||
|
* \returns `x`, with its bytes in the opposite endian order.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Byte-swap an unsigned 64-bit number.
|
||||||
|
*
|
||||||
|
* This will always byte-swap the value, whether it's currently in the native
|
||||||
|
* byteorder of the system or not. You should use SDL_Swap64LE or SDL_Swap64BE
|
||||||
|
* instead, in most cases.
|
||||||
|
*
|
||||||
|
* Note that this is a forced-inline function in a header, and not a public
|
||||||
|
* API function available in the SDL library (which is to say, the code is
|
||||||
|
* embedded in the calling program and the linker and dynamic loader will not
|
||||||
|
* be able to find this function inside SDL itself).
|
||||||
|
*
|
||||||
|
* \param x the value to byte-swap.
|
||||||
|
* \returns `x`, with its bytes in the opposite endian order.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swap a 16-bit value from littleendian to native byte order.
|
||||||
|
*
|
||||||
|
* If this is running on a littleendian system, `x` is returned unchanged.
|
||||||
|
*
|
||||||
|
* This macro never references `x` more than once, avoiding side effects.
|
||||||
|
*
|
||||||
|
* \param x the value to swap, in littleendian byte order.
|
||||||
|
* \returns `x` in native byte order.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swap a 32-bit value from littleendian to native byte order.
|
||||||
|
*
|
||||||
|
* If this is running on a littleendian system, `x` is returned unchanged.
|
||||||
|
*
|
||||||
|
* This macro never references `x` more than once, avoiding side effects.
|
||||||
|
*
|
||||||
|
* \param x the value to swap, in littleendian byte order.
|
||||||
|
* \returns `x` in native byte order.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swap a 64-bit value from littleendian to native byte order.
|
||||||
|
*
|
||||||
|
* If this is running on a littleendian system, `x` is returned unchanged.
|
||||||
|
*
|
||||||
|
* This macro never references `x` more than once, avoiding side effects.
|
||||||
|
*
|
||||||
|
* \param x the value to swap, in littleendian byte order.
|
||||||
|
* \returns `x` in native byte order.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swap a floating point value from littleendian to native byte order.
|
||||||
|
*
|
||||||
|
* If this is running on a littleendian system, `x` is returned unchanged.
|
||||||
|
*
|
||||||
|
* This macro never references `x` more than once, avoiding side effects.
|
||||||
|
*
|
||||||
|
* \param x the value to swap, in littleendian byte order.
|
||||||
|
* \returns `x` in native byte order.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swap a 16-bit value from bigendian to native byte order.
|
||||||
|
*
|
||||||
|
* If this is running on a bigendian system, `x` is returned unchanged.
|
||||||
|
*
|
||||||
|
* This macro never references `x` more than once, avoiding side effects.
|
||||||
|
*
|
||||||
|
* \param x the value to swap, in bigendian byte order.
|
||||||
|
* \returns `x` in native byte order.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swap a 32-bit value from bigendian to native byte order.
|
||||||
|
*
|
||||||
|
* If this is running on a bigendian system, `x` is returned unchanged.
|
||||||
|
*
|
||||||
|
* This macro never references `x` more than once, avoiding side effects.
|
||||||
|
*
|
||||||
|
* \param x the value to swap, in bigendian byte order.
|
||||||
|
* \returns `x` in native byte order.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swap a 64-bit value from bigendian to native byte order.
|
||||||
|
*
|
||||||
|
* If this is running on a bigendian system, `x` is returned unchanged.
|
||||||
|
*
|
||||||
|
* This macro never references `x` more than once, avoiding side effects.
|
||||||
|
*
|
||||||
|
* \param x the value to swap, in bigendian byte order.
|
||||||
|
* \returns `x` in native byte order.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swap a floating point value from bigendian to native byte order.
|
||||||
|
*
|
||||||
|
* If this is running on a bigendian system, `x` is returned unchanged.
|
||||||
|
*
|
||||||
|
* This macro never references `x` more than once, avoiding side effects.
|
||||||
|
*
|
||||||
|
* \param x the value to swap, in bigendian byte order.
|
||||||
|
* \returns `x` in native byte order.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_endian_h_ */
|
||||||
239
src/SDL_error.bf
Normal file
239
src/SDL_error.bf
Normal file
@@ -0,0 +1,239 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryError
|
||||||
|
*
|
||||||
|
* Simple error message routines for SDL.
|
||||||
|
*
|
||||||
|
* Most apps will interface with these APIs in exactly one function: when
|
||||||
|
* almost any SDL function call reports failure, you can get a human-readable
|
||||||
|
* string of the problem from SDL_GetError().
|
||||||
|
*
|
||||||
|
* These strings are maintained per-thread, and apps are welcome to set their
|
||||||
|
* own errors, which is popular when building libraries on top of SDL for
|
||||||
|
* other apps to consume. These strings are set by calling SDL_SetError().
|
||||||
|
*
|
||||||
|
* A common usage pattern is to have a function that returns true for success
|
||||||
|
* and false for failure, and do this when something fails:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* if (something_went_wrong) {
|
||||||
|
* return SDL_SetError("The thing broke in this specific way: %d", errcode);
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* It's also common to just return `false` in this case if the failing thing
|
||||||
|
* is known to call SDL_SetError(), so errors simply propagate through.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Public functions */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the SDL error message for the current thread.
|
||||||
|
*
|
||||||
|
* Calling this function will replace any previous error message that was set.
|
||||||
|
*
|
||||||
|
* This function always returns false, since SDL frequently uses false to
|
||||||
|
* signify a failing result, leading to this idiom:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* if (error_code) {
|
||||||
|
* return SDL_SetError("This operation has failed: %d", error_code);
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* \param fmt a printf()-style message format string.
|
||||||
|
* \param ... additional parameters matching % tokens in the `fmt` string, if
|
||||||
|
* any.
|
||||||
|
* \returns false.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ClearError
|
||||||
|
* \sa SDL_GetError
|
||||||
|
* \sa SDL_SetErrorV
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetError")] public static extern bool SetError(c_char* fmt, ...);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the SDL error message for the current thread.
|
||||||
|
*
|
||||||
|
* Calling this function will replace any previous error message that was set.
|
||||||
|
*
|
||||||
|
* \param fmt a printf()-style message format string.
|
||||||
|
* \param ap a variable argument list.
|
||||||
|
* \returns false.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ClearError
|
||||||
|
* \sa SDL_GetError
|
||||||
|
* \sa SDL_SetError
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetErrorV")] public static extern bool SetErrorV(c_char* fmt, VarArgs ap);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an error indicating that memory allocation failed.
|
||||||
|
*
|
||||||
|
* This function does not do any memory allocation.
|
||||||
|
*
|
||||||
|
* \returns false.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OutOfMemory")] public static extern bool OutOfMemory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a message about the last error that occurred on the current
|
||||||
|
* thread.
|
||||||
|
*
|
||||||
|
* It is possible for multiple errors to occur before calling SDL_GetError().
|
||||||
|
* Only the last error is returned.
|
||||||
|
*
|
||||||
|
* The message is only applicable when an SDL function has signaled an error.
|
||||||
|
* You must check the return values of SDL function calls to determine when to
|
||||||
|
* appropriately call SDL_GetError(). You should *not* use the results of
|
||||||
|
* SDL_GetError() to decide if an error has occurred! Sometimes SDL will set
|
||||||
|
* an error string even when reporting success.
|
||||||
|
*
|
||||||
|
* SDL will *not* clear the error string for successful API calls. You *must*
|
||||||
|
* check return values for failure cases before you can assume the error
|
||||||
|
* string applies.
|
||||||
|
*
|
||||||
|
* Error strings are set per-thread, so an error set in a different thread
|
||||||
|
* will not interfere with the current thread's operation.
|
||||||
|
*
|
||||||
|
* The returned value is a thread-local string which will remain valid until
|
||||||
|
* the current thread's error string is changed. The caller should make a copy
|
||||||
|
* if the value is needed after the next SDL API call.
|
||||||
|
*
|
||||||
|
* \returns a message with information about the specific error that occurred,
|
||||||
|
* or an empty string if there hasn't been an error message set since
|
||||||
|
* the last call to SDL_ClearError().
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ClearError
|
||||||
|
* \sa SDL_SetError
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetError")] public static extern c_char* GetError();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear any previous error message for this thread.
|
||||||
|
*
|
||||||
|
* \returns true.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetError
|
||||||
|
* \sa SDL_SetError
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ClearError")] public static extern bool ClearError();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \name Internal error functions
|
||||||
|
*
|
||||||
|
* \internal
|
||||||
|
* Private error reporting function - used internally.
|
||||||
|
*/
|
||||||
|
/* @{ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A macro to standardize error reporting on unsupported operations.
|
||||||
|
*
|
||||||
|
* This simply calls SDL_SetError() with a standardized error string, for
|
||||||
|
* convenience, consistency, and clarity.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A macro to standardize error reporting on unsupported operations.
|
||||||
|
*
|
||||||
|
* This simply calls SDL_SetError() with a standardized error string, for
|
||||||
|
* convenience, consistency, and clarity.
|
||||||
|
*
|
||||||
|
* A common usage pattern inside SDL is this:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* bool MyFunction(const char *str) {
|
||||||
|
* if (!str) {
|
||||||
|
* return SDL_InvalidParamError("str"); // returns false.
|
||||||
|
* }
|
||||||
|
* DoSomething(str);
|
||||||
|
* return true;
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* @} */ /* Internal error functions */
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_error_h_ */
|
||||||
1656
src/SDL_events.bf
Normal file
1656
src/SDL_events.bf
Normal file
File diff suppressed because it is too large
Load Diff
563
src/SDL_filesystem.bf
Normal file
563
src/SDL_filesystem.bf
Normal file
@@ -0,0 +1,563 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryFilesystem
|
||||||
|
*
|
||||||
|
* SDL offers an API for examining and manipulating the system's filesystem.
|
||||||
|
* This covers most things one would need to do with directories, except for
|
||||||
|
* actual file I/O (which is covered by [CategoryIOStream](CategoryIOStream)
|
||||||
|
* and [CategoryAsyncIO](CategoryAsyncIO) instead).
|
||||||
|
*
|
||||||
|
* There are functions to answer necessary path questions:
|
||||||
|
*
|
||||||
|
* - Where is my app's data? SDL_GetBasePath().
|
||||||
|
* - Where can I safely write files? SDL_GetPrefPath().
|
||||||
|
* - Where are paths like Downloads, Desktop, Music? SDL_GetUserFolder().
|
||||||
|
* - What is this thing at this location? SDL_GetPathInfo().
|
||||||
|
* - What items live in this folder? SDL_EnumerateDirectory().
|
||||||
|
* - What items live in this folder by wildcard? SDL_GlobDirectory().
|
||||||
|
* - What is my current working directory? SDL_GetCurrentDirectory().
|
||||||
|
*
|
||||||
|
* SDL also offers functions to manipulate the directory tree: renaming,
|
||||||
|
* removing, copying files.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the directory where the application was run from.
|
||||||
|
*
|
||||||
|
* SDL caches the result of this call internally, but the first call to this
|
||||||
|
* function is not necessarily fast, so plan accordingly.
|
||||||
|
*
|
||||||
|
* **macOS and iOS Specific Functionality**: If the application is in a ".app"
|
||||||
|
* bundle, this function returns the Resource directory (e.g.
|
||||||
|
* MyApp.app/Contents/Resources/). This behaviour can be overridden by adding
|
||||||
|
* a property to the Info.plist file. Adding a string key with the name
|
||||||
|
* SDL_FILESYSTEM_BASE_DIR_TYPE with a supported value will change the
|
||||||
|
* behaviour.
|
||||||
|
*
|
||||||
|
* Supported values for the SDL_FILESYSTEM_BASE_DIR_TYPE property (Given an
|
||||||
|
* application in /Applications/SDLApp/MyApp.app):
|
||||||
|
*
|
||||||
|
* - `resource`: bundle resource directory (the default). For example:
|
||||||
|
* `/Applications/SDLApp/MyApp.app/Contents/Resources`
|
||||||
|
* - `bundle`: the Bundle directory. For example:
|
||||||
|
* `/Applications/SDLApp/MyApp.app/`
|
||||||
|
* - `parent`: the containing directory of the bundle. For example:
|
||||||
|
* `/Applications/SDLApp/`
|
||||||
|
*
|
||||||
|
* **Android Specific Functionality**: This function returns "./", which
|
||||||
|
* allows filesystem operations to use internal storage and the asset system.
|
||||||
|
*
|
||||||
|
* **Nintendo 3DS Specific Functionality**: This function returns "romfs"
|
||||||
|
* directory of the application as it is uncommon to store resources outside
|
||||||
|
* the executable. As such it is not a writable directory.
|
||||||
|
*
|
||||||
|
* The returned path is guaranteed to end with a path separator ('\\' on
|
||||||
|
* Windows, '/' on most other platforms).
|
||||||
|
*
|
||||||
|
* \returns an absolute path in UTF-8 encoding to the application data
|
||||||
|
* directory. NULL will be returned on error or when the platform
|
||||||
|
* doesn't implement this functionality, call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetPrefPath
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetBasePath")] public static extern c_char* GetBasePath();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the user-and-app-specific path where files can be written.
|
||||||
|
*
|
||||||
|
* Get the "pref dir". This is meant to be where users can write personal
|
||||||
|
* files (preferences and save games, etc) that are specific to your
|
||||||
|
* application. This directory is unique per user, per application.
|
||||||
|
*
|
||||||
|
* This function will decide the appropriate location in the native
|
||||||
|
* filesystem, create the directory if necessary, and return a string of the
|
||||||
|
* absolute path to the directory in UTF-8 encoding.
|
||||||
|
*
|
||||||
|
* On Windows, the string might look like:
|
||||||
|
*
|
||||||
|
* `C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\`
|
||||||
|
*
|
||||||
|
* On Linux, the string might look like:
|
||||||
|
*
|
||||||
|
* `/home/bob/.local/share/My Program Name/`
|
||||||
|
*
|
||||||
|
* On macOS, the string might look like:
|
||||||
|
*
|
||||||
|
* `/Users/bob/Library/Application Support/My Program Name/`
|
||||||
|
*
|
||||||
|
* You should assume the path returned by this function is the only safe place
|
||||||
|
* to write files (and that SDL_GetBasePath(), while it might be writable, or
|
||||||
|
* even the parent of the returned path, isn't where you should be writing
|
||||||
|
* things).
|
||||||
|
*
|
||||||
|
* Both the org and app strings may become part of a directory name, so please
|
||||||
|
* follow these rules:
|
||||||
|
*
|
||||||
|
* - Try to use the same org string (_including case-sensitivity_) for all
|
||||||
|
* your applications that use this function.
|
||||||
|
* - Always use a unique app string for each one, and make sure it never
|
||||||
|
* changes for an app once you've decided on it.
|
||||||
|
* - Unicode characters are legal, as long as they are UTF-8 encoded, but...
|
||||||
|
* - ...only use letters, numbers, and spaces. Avoid punctuation like "Game
|
||||||
|
* Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
|
||||||
|
*
|
||||||
|
* Due to historical mistakes, `org` is allowed to be NULL or "". In such
|
||||||
|
* cases, SDL will omit the org subdirectory, including on platforms where it
|
||||||
|
* shouldn't, and including on platforms where this would make your app fail
|
||||||
|
* certification for an app store. New apps should definitely specify a real
|
||||||
|
* string for `org`.
|
||||||
|
*
|
||||||
|
* The returned path is guaranteed to end with a path separator ('\\' on
|
||||||
|
* Windows, '/' on most other platforms).
|
||||||
|
*
|
||||||
|
* \param org the name of your organization.
|
||||||
|
* \param app the name of your application.
|
||||||
|
* \returns a UTF-8 string of the user directory in platform-dependent
|
||||||
|
* notation. NULL if there's a problem (creating directory failed,
|
||||||
|
* etc.). This should be freed with SDL_free() when it is no longer
|
||||||
|
* needed.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetBasePath
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetPrefPath")] public static extern c_char* GetPrefPath(c_char* org, c_char* app);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of the OS-provided default folder for a specific purpose.
|
||||||
|
*
|
||||||
|
* Note that the Trash folder isn't included here, because trashing files
|
||||||
|
* usually involves extra OS-specific functionality to remember the file's
|
||||||
|
* original location.
|
||||||
|
*
|
||||||
|
* The folders supported per platform are:
|
||||||
|
*
|
||||||
|
* | | Windows | macOS/iOS | tvOS | Unix (XDG) | Haiku | Emscripten |
|
||||||
|
* | ----------- | ------- | --------- | ---- | ---------- | ----- | ---------- |
|
||||||
|
* | HOME | X | X | | X | X | X |
|
||||||
|
* | DESKTOP | X | X | | X | X | |
|
||||||
|
* | DOCUMENTS | X | X | | X | | |
|
||||||
|
* | DOWNLOADS | Vista+ | X | | X | | |
|
||||||
|
* | MUSIC | X | X | | X | | |
|
||||||
|
* | PICTURES | X | X | | X | | |
|
||||||
|
* | PUBLICSHARE | | X | | X | | |
|
||||||
|
* | SAVEDGAMES | Vista+ | | | | | |
|
||||||
|
* | SCREENSHOTS | Vista+ | | | | | |
|
||||||
|
* | TEMPLATES | X | X | | X | | |
|
||||||
|
* | VIDEOS | X | X* | | X | | |
|
||||||
|
*
|
||||||
|
* Note that on macOS/iOS, the Videos folder is called "Movies".
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetUserFolder
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum Folder : c_int
|
||||||
|
{
|
||||||
|
Home, /**< The folder which contains all of the current user's data, preferences, and documents. It usually contains most of the other folders. If a requested folder does not exist, the home folder can be considered a safe fallback to store a user's documents. */
|
||||||
|
Desktop, /**< The folder of files that are displayed on the desktop. Note that the existence of a desktop folder does not guarantee that the system does show icons on its desktop; certain GNU/Linux distros with a graphical environment may not have desktop icons. */
|
||||||
|
Documents, /**< User document files, possibly application-specific. This is a good place to save a user's projects. */
|
||||||
|
Downloads, /**< Standard folder for user files downloaded from the internet. */
|
||||||
|
Music, /**< Music files that can be played using a standard music player (mp3, ogg...). */
|
||||||
|
Pictures, /**< Image files that can be displayed using a standard viewer (png, jpg...). */
|
||||||
|
Publicshare, /**< Files that are meant to be shared with other users on the same computer. */
|
||||||
|
Savedgames, /**< Save files for games. */
|
||||||
|
Screenshots, /**< Application screenshots. */
|
||||||
|
Templates, /**< Template files to be used when the user requests the desktop environment to create a new file in a certain folder, such as "New Text File.txt". Any file in the Templates folder can be used as a starting point for a new file. */
|
||||||
|
Videos, /**< Video files that can be played using a standard video player (mp4, webm...). */
|
||||||
|
Count, /**< Total number of types in this enum, not a folder type by itself. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the most suitable user folder for a specific purpose.
|
||||||
|
*
|
||||||
|
* Many OSes provide certain standard folders for certain purposes, such as
|
||||||
|
* storing pictures, music or videos for a certain user. This function gives
|
||||||
|
* the path for many of those special locations.
|
||||||
|
*
|
||||||
|
* This function is specifically for _user_ folders, which are meant for the
|
||||||
|
* user to access and manage. For application-specific folders, meant to hold
|
||||||
|
* data for the application to manage, see SDL_GetBasePath() and
|
||||||
|
* SDL_GetPrefPath().
|
||||||
|
*
|
||||||
|
* The returned path is guaranteed to end with a path separator ('\\' on
|
||||||
|
* Windows, '/' on most other platforms).
|
||||||
|
*
|
||||||
|
* If NULL is returned, the error may be obtained with SDL_GetError().
|
||||||
|
*
|
||||||
|
* \param folder the type of folder to find.
|
||||||
|
* \returns either a null-terminated C string containing the full path to the
|
||||||
|
* folder, or NULL if an error happened.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetUserFolder")] public static extern c_char* GetUserFolder(Folder folder);
|
||||||
|
|
||||||
|
|
||||||
|
/* Abstract filesystem interface */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Types of filesystem entries.
|
||||||
|
*
|
||||||
|
* Note that there may be other sorts of items on a filesystem: devices,
|
||||||
|
* symlinks, named pipes, etc. They are currently reported as
|
||||||
|
* SDL_PATHTYPE_OTHER.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_PathInfo
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum PathType : c_int
|
||||||
|
{
|
||||||
|
None, /**< path does not exist */
|
||||||
|
File, /**< a normal file */
|
||||||
|
Directory, /**< a directory */
|
||||||
|
Other, /**< something completely different like a device node (not a symlink, those are always followed) */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information about a path on the filesystem.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetPathInfo
|
||||||
|
* \sa SDL_GetStoragePathInfo
|
||||||
|
*/
|
||||||
|
[CRepr] public struct PathInfo
|
||||||
|
{
|
||||||
|
public PathType type; /**< the path type */
|
||||||
|
public Uint64 size; /**< the file size in bytes */
|
||||||
|
public Time create_time; /**< the time when the path was created */
|
||||||
|
public Time modify_time; /**< the last time the path was modified */
|
||||||
|
public Time access_time; /**< the last time the path was read */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flags for path matching.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GlobDirectory
|
||||||
|
* \sa SDL_GlobStorageDirectory
|
||||||
|
*/
|
||||||
|
public enum GlobFlags : Uint32
|
||||||
|
{
|
||||||
|
Caseinsensitive = (1u << 0),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a directory, and any missing parent directories.
|
||||||
|
*
|
||||||
|
* This reports success if `path` already exists as a directory.
|
||||||
|
*
|
||||||
|
* If parent directories are missing, it will also create them. Note that if
|
||||||
|
* this fails, it will not remove any parent directories it already made.
|
||||||
|
*
|
||||||
|
* \param path the path of the directory to create.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a directory, and any missing parent directories.
|
||||||
|
*
|
||||||
|
* This reports success if `path` already exists as a directory.
|
||||||
|
*
|
||||||
|
* If parent directories are missing, it will also create them. Note that if
|
||||||
|
* this fails, it will not remove any parent directories it already made.
|
||||||
|
*
|
||||||
|
* \param path the path of the directory to create.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateDirectory")] public static extern bool CreateDirectory(c_char* path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Possible results from an enumeration callback.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_EnumerateDirectoryCallback
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum EnumerationResult : c_int
|
||||||
|
{
|
||||||
|
Continue, /**< Value that requests that enumeration continue. */
|
||||||
|
Success, /**< Value that requests that enumeration stop, successfully. */
|
||||||
|
Failure, /**< Value that requests that enumeration stop, as a failure. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback for directory enumeration.
|
||||||
|
*
|
||||||
|
* Enumeration of directory entries will continue until either all entries
|
||||||
|
* have been provided to the callback, or the callback has requested a stop
|
||||||
|
* through its return value.
|
||||||
|
*
|
||||||
|
* Returning SDL_ENUM_CONTINUE will let enumeration proceed, calling the
|
||||||
|
* callback with further entries. SDL_ENUM_SUCCESS and SDL_ENUM_FAILURE will
|
||||||
|
* terminate the enumeration early, and dictate the return value of the
|
||||||
|
* enumeration function itself.
|
||||||
|
*
|
||||||
|
* `dirname` is guaranteed to end with a path separator ('\\' on Windows, '/'
|
||||||
|
* on most other platforms).
|
||||||
|
*
|
||||||
|
* \param userdata an app-controlled pointer that is passed to the callback.
|
||||||
|
* \param dirname the directory that is being enumerated.
|
||||||
|
* \param fname the next entry in the enumeration.
|
||||||
|
* \returns how the enumeration should proceed.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_EnumerateDirectory
|
||||||
|
*/
|
||||||
|
public function EnumerationResult EnumerateDirectoryCallback(void* userdata, c_char* dirname, c_char* fname);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumerate a directory through a callback function.
|
||||||
|
*
|
||||||
|
* This function provides every directory entry through an app-provided
|
||||||
|
* callback, called once for each directory entry, until all results have been
|
||||||
|
* provided or the callback returns either SDL_ENUM_SUCCESS or
|
||||||
|
* SDL_ENUM_FAILURE.
|
||||||
|
*
|
||||||
|
* This will return false if there was a system problem in general, or if a
|
||||||
|
* callback returns SDL_ENUM_FAILURE. A successful return means a callback
|
||||||
|
* returned SDL_ENUM_SUCCESS to halt enumeration, or all directory entries
|
||||||
|
* were enumerated.
|
||||||
|
*
|
||||||
|
* \param path the path of the directory to enumerate.
|
||||||
|
* \param callback a function that is called for each entry in the directory.
|
||||||
|
* \param userdata a pointer that is passed to `callback`.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_EnumerateDirectory")] public static extern bool EnumerateDirectory(c_char* path, EnumerateDirectoryCallback callback, void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a file or an empty directory.
|
||||||
|
*
|
||||||
|
* Directories that are not empty will fail; this function will not recursely
|
||||||
|
* delete directory trees.
|
||||||
|
*
|
||||||
|
* \param path the path to remove from the filesystem.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_RemovePath")] public static extern bool RemovePath(c_char* path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rename a file or directory.
|
||||||
|
*
|
||||||
|
* If the file at `newpath` already exists, it will be replaced.
|
||||||
|
*
|
||||||
|
* Note that this will not copy files across filesystems/drives/volumes, as
|
||||||
|
* that is a much more complicated (and possibly time-consuming) operation.
|
||||||
|
*
|
||||||
|
* Which is to say, if this function fails, SDL_CopyFile() to a temporary file
|
||||||
|
* in the same directory as `newpath`, then SDL_RenamePath() from the
|
||||||
|
* temporary file to `newpath` and SDL_RemovePath() on `oldpath` might work
|
||||||
|
* for files. Renaming a non-empty directory across filesystems is
|
||||||
|
* dramatically more complex, however.
|
||||||
|
*
|
||||||
|
* \param oldpath the old path.
|
||||||
|
* \param newpath the new path.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_RenamePath")] public static extern bool RenamePath(c_char* oldpath, c_char* newpath);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy a file.
|
||||||
|
*
|
||||||
|
* If the file at `newpath` already exists, it will be overwritten with the
|
||||||
|
* contents of the file at `oldpath`.
|
||||||
|
*
|
||||||
|
* This function will block until the copy is complete, which might be a
|
||||||
|
* significant time for large files on slow disks. On some platforms, the copy
|
||||||
|
* can be handed off to the OS itself, but on others SDL might just open both
|
||||||
|
* paths, and read from one and write to the other.
|
||||||
|
*
|
||||||
|
* Note that this is not an atomic operation! If something tries to read from
|
||||||
|
* `newpath` while the copy is in progress, it will see an incomplete copy of
|
||||||
|
* the data, and if the calling thread terminates (or the power goes out)
|
||||||
|
* during the copy, `newpath`'s previous contents will be gone, replaced with
|
||||||
|
* an incomplete copy of the data. To avoid this risk, it is recommended that
|
||||||
|
* the app copy to a temporary file in the same directory as `newpath`, and if
|
||||||
|
* the copy is successful, use SDL_RenamePath() to replace `newpath` with the
|
||||||
|
* temporary file. This will ensure that reads of `newpath` will either see a
|
||||||
|
* complete copy of the data, or it will see the pre-copy state of `newpath`.
|
||||||
|
*
|
||||||
|
* This function attempts to synchronize the newly-copied data to disk before
|
||||||
|
* returning, if the platform allows it, so that the renaming trick will not
|
||||||
|
* have a problem in a system crash or power failure, where the file could be
|
||||||
|
* renamed but the contents never made it from the system file cache to the
|
||||||
|
* physical disk.
|
||||||
|
*
|
||||||
|
* If the copy fails for any reason, the state of `newpath` is undefined. It
|
||||||
|
* might be half a copy, it might be the untouched data of what was already
|
||||||
|
* there, or it might be a zero-byte file, etc.
|
||||||
|
*
|
||||||
|
* \param oldpath the old path.
|
||||||
|
* \param newpath the new path.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread, but this
|
||||||
|
* operation is not atomic, so the app might need to protect
|
||||||
|
* access to specific paths from other threads if appropriate.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CopyFile")] public static extern bool CopyFile(c_char* oldpath, c_char* newpath);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about a filesystem path.
|
||||||
|
*
|
||||||
|
* \param path the path to query.
|
||||||
|
* \param info a pointer filled in with information about the path, or NULL to
|
||||||
|
* check for the existence of a file.
|
||||||
|
* \returns true on success or false if the file doesn't exist, or another
|
||||||
|
* failure; call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetPathInfo")] public static extern bool GetPathInfo(c_char* path, out PathInfo info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumerate a directory tree, filtered by pattern, and return a list.
|
||||||
|
*
|
||||||
|
* Files are filtered out if they don't match the string in `pattern`, which
|
||||||
|
* may contain wildcard characters `*` (match everything) and `?` (match one
|
||||||
|
* character). If pattern is NULL, no filtering is done and all results are
|
||||||
|
* returned. Subdirectories are permitted, and are specified with a path
|
||||||
|
* separator of `/`. Wildcard characters `*` and `?` never match a path
|
||||||
|
* separator.
|
||||||
|
*
|
||||||
|
* `flags` may be set to SDL_GLOB_CASEINSENSITIVE to make the pattern matching
|
||||||
|
* case-insensitive.
|
||||||
|
*
|
||||||
|
* The returned array is always NULL-terminated, for your iterating
|
||||||
|
* convenience, but if `count` is non-NULL, on return it will contain the
|
||||||
|
* number of items in the array, not counting the NULL terminator.
|
||||||
|
*
|
||||||
|
* \param path the path of the directory to enumerate.
|
||||||
|
* \param pattern the pattern that files in the directory must match. Can be
|
||||||
|
* NULL.
|
||||||
|
* \param flags `SDL_GLOB_*` bitflags that affect this search.
|
||||||
|
* \param count on return, will be set to the number of items in the returned
|
||||||
|
* array. Can be NULL.
|
||||||
|
* \returns an array of strings on success or NULL on failure; call
|
||||||
|
* SDL_GetError() for more information. This is a single allocation
|
||||||
|
* that should be freed with SDL_free() when it is no longer needed.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GlobDirectory")] public static extern c_char** GlobDirectory(c_char* path, c_char* pattern, GlobFlags flags, c_int* count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get what the system believes is the "current working directory."
|
||||||
|
*
|
||||||
|
* For systems without a concept of a current working directory, this will
|
||||||
|
* still attempt to provide something reasonable.
|
||||||
|
*
|
||||||
|
* SDL does not provide a means to _change_ the current working directory; for
|
||||||
|
* platforms without this concept, this would cause surprises with file access
|
||||||
|
* outside of SDL.
|
||||||
|
*
|
||||||
|
* The returned path is guaranteed to end with a path separator ('\\' on
|
||||||
|
* Windows, '/' on most other platforms).
|
||||||
|
*
|
||||||
|
* \returns a UTF-8 string of the current working directory in
|
||||||
|
* platform-dependent notation. NULL if there's a problem. This
|
||||||
|
* should be freed with SDL_free() when it is no longer needed.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetCurrentDirectory")] public static extern c_char* GetCurrentDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_filesystem_h_ */
|
||||||
1713
src/SDL_gamepad.bf
Normal file
1713
src/SDL_gamepad.bf
Normal file
File diff suppressed because it is too large
Load Diff
4374
src/SDL_gpu.bf
Normal file
4374
src/SDL_gpu.bf
Normal file
File diff suppressed because it is too large
Load Diff
117
src/SDL_guid.bf
Normal file
117
src/SDL_guid.bf
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* WIKI CATEGORY: GUID */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryGUID
|
||||||
|
*
|
||||||
|
* A GUID is a 128-bit value that represents something that is uniquely
|
||||||
|
* identifiable by this value: "globally unique."
|
||||||
|
*
|
||||||
|
* SDL provides functions to convert a GUID to/from a string.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An SDL_GUID is a 128-bit identifier for an input device that identifies
|
||||||
|
* that device across runs of SDL programs on the same platform.
|
||||||
|
*
|
||||||
|
* If the device is detached and then re-attached to a different port, or if
|
||||||
|
* the base system is rebooted, the device should still report the same GUID.
|
||||||
|
*
|
||||||
|
* GUIDs are as precise as possible but are not guaranteed to distinguish
|
||||||
|
* physically distinct but equivalent devices. For example, two game
|
||||||
|
* controllers from the same vendor with the same product ID and revision may
|
||||||
|
* have the same GUID.
|
||||||
|
*
|
||||||
|
* GUIDs may be platform-dependent (i.e., the same device may report different
|
||||||
|
* GUIDs on different operating systems).
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct GUID {
|
||||||
|
public Uint8[16] data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Function prototypes */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an ASCII string representation for a given SDL_GUID.
|
||||||
|
*
|
||||||
|
* \param guid the SDL_GUID you wish to convert to string.
|
||||||
|
* \param pszGUID buffer in which to write the ASCII string.
|
||||||
|
* \param cbGUID the size of pszGUID, should be at least 33 bytes.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_StringToGUID
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GUIDToString")] public static extern void GUIDToString(GUID guid, c_char* pszGUID, c_int cbGUID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a GUID string into a SDL_GUID structure.
|
||||||
|
*
|
||||||
|
* Performs no error checking. If this function is given a string containing
|
||||||
|
* an invalid GUID, the function will silently succeed, but the GUID generated
|
||||||
|
* will not be useful.
|
||||||
|
*
|
||||||
|
* \param pchGUID string containing an ASCII representation of a GUID.
|
||||||
|
* \returns a SDL_GUID structure.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GUIDToString
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_StringToGUID")] public static extern GUID StringToGUID(c_char* pchGUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_guid_h_ */
|
||||||
1472
src/SDL_haptic.bf
Normal file
1472
src/SDL_haptic.bf
Normal file
File diff suppressed because it is too large
Load Diff
582
src/SDL_hidapi.bf
Normal file
582
src/SDL_hidapi.bf
Normal file
@@ -0,0 +1,582 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* WIKI CATEGORY: HIDAPI */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryHIDAPI
|
||||||
|
*
|
||||||
|
* Header file for SDL HIDAPI functions.
|
||||||
|
*
|
||||||
|
* This is an adaptation of the original HIDAPI interface by Alan Ott, and
|
||||||
|
* includes source code licensed under the following license:
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* HIDAPI - Multi-Platform library for
|
||||||
|
* communication with HID devices.
|
||||||
|
*
|
||||||
|
* Copyright 2009, Alan Ott, Signal 11 Software.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This software may be used by anyone for any reason so
|
||||||
|
* long as the copyright notice in the source files
|
||||||
|
* remains intact.
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* (Note that this license is the same as item three of SDL's zlib license, so
|
||||||
|
* it adds no new requirements on the user.)
|
||||||
|
*
|
||||||
|
* If you would like a version of SDL without this code, you can build SDL
|
||||||
|
* with SDL_HIDAPI_DISABLED defined to 1. You might want to do this for
|
||||||
|
* example on iOS or tvOS to avoid a dependency on the CoreBluetooth
|
||||||
|
* framework.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An opaque handle representing an open HID device.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct hid_device;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HID underlying bus types.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum hid_bus_type : c_int {
|
||||||
|
/** Unknown bus type */
|
||||||
|
ApiBusUnknown = 0x00,
|
||||||
|
|
||||||
|
/** USB bus
|
||||||
|
Specifications:
|
||||||
|
https://usb.org/hid */
|
||||||
|
ApiBusUsb = 0x01,
|
||||||
|
|
||||||
|
/** Bluetooth or Bluetooth LE bus
|
||||||
|
Specifications:
|
||||||
|
https://www.bluetooth.com/specifications/specs/human-interface-device-profile-1-1-1/
|
||||||
|
https://www.bluetooth.com/specifications/specs/hid-service-1-0/
|
||||||
|
https://www.bluetooth.com/specifications/specs/hid-over-gatt-profile-1-0/ */
|
||||||
|
ApiBusBluetooth = 0x02,
|
||||||
|
|
||||||
|
/** I2C bus
|
||||||
|
Specifications:
|
||||||
|
https://docs.microsoft.com/previous-versions/windows/hardware/design/dn642101(v=vs.85) */
|
||||||
|
ApiBusI2c = 0x03,
|
||||||
|
|
||||||
|
/** SPI bus
|
||||||
|
Specifications:
|
||||||
|
https://www.microsoft.com/download/details.aspx?id=103325 */
|
||||||
|
ApiBusSpi = 0x04,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** hidapi info structure */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information about a connected HID device
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct hid_device_info
|
||||||
|
{
|
||||||
|
/** Platform-specific device path */
|
||||||
|
public c_char* path;
|
||||||
|
/** Device Vendor ID */
|
||||||
|
public c_ushort vendor_id;
|
||||||
|
/** Device Product ID */
|
||||||
|
public c_ushort product_id;
|
||||||
|
/** Serial Number */
|
||||||
|
public c_wchar* serial_number;
|
||||||
|
/** Device Release Number in binary-coded decimal,
|
||||||
|
also known as Device Version Number */
|
||||||
|
public c_ushort release_number;
|
||||||
|
/** Manufacturer String */
|
||||||
|
public c_wchar* manufacturer_string;
|
||||||
|
/** Product string */
|
||||||
|
public c_wchar* product_string;
|
||||||
|
/** Usage Page for this Device/Interface
|
||||||
|
(Windows/Mac/hidraw only) */
|
||||||
|
public c_ushort usage_page;
|
||||||
|
/** Usage for this Device/Interface
|
||||||
|
(Windows/Mac/hidraw only) */
|
||||||
|
public c_ushort usage;
|
||||||
|
/** The USB interface which this logical device
|
||||||
|
represents.
|
||||||
|
|
||||||
|
Valid only if the device is a USB HID device.
|
||||||
|
Set to -1 in all other cases.
|
||||||
|
*/
|
||||||
|
public c_int interface_number;
|
||||||
|
|
||||||
|
/** Additional information about the USB interface.
|
||||||
|
Valid on libusb and Android implementations. */
|
||||||
|
public c_int interface_class;
|
||||||
|
public c_int interface_subclass;
|
||||||
|
public c_int interface_protocol;
|
||||||
|
|
||||||
|
/** Underlying bus type */
|
||||||
|
public hid_bus_type bus_type;
|
||||||
|
|
||||||
|
/** Pointer to the next device */
|
||||||
|
public hid_device_info* next;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the HIDAPI library.
|
||||||
|
*
|
||||||
|
* This function initializes the HIDAPI library. Calling it is not strictly
|
||||||
|
* necessary, as it will be called automatically by SDL_hid_enumerate(),
|
||||||
|
* SDL_hid_open(), and SDL_hid_open_path() if needed. This function should be
|
||||||
|
* called at the beginning of execution however, if there is a chance of
|
||||||
|
* HIDAPI handles being opened by different threads simultaneously.
|
||||||
|
*
|
||||||
|
* Each call to this function should have a matching call to SDL_hid_exit()
|
||||||
|
*
|
||||||
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_hid_exit
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_init")] public static extern c_int hid_init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finalize the HIDAPI library.
|
||||||
|
*
|
||||||
|
* This function frees all of the static data associated with HIDAPI. It
|
||||||
|
* should be called at the end of execution to avoid memory leaks.
|
||||||
|
*
|
||||||
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_hid_init
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_exit")] public static extern c_int hid_exit();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if devices may have been added or removed.
|
||||||
|
*
|
||||||
|
* Enumerating the HID devices is an expensive operation, so you can call this
|
||||||
|
* to see if there have been any system device changes since the last call to
|
||||||
|
* this function. A change in the counter returned doesn't necessarily mean
|
||||||
|
* that anything has changed, but you can call SDL_hid_enumerate() to get an
|
||||||
|
* updated device list.
|
||||||
|
*
|
||||||
|
* Calling this function for the first time may cause a thread or other system
|
||||||
|
* resource to be allocated to track device change notifications.
|
||||||
|
*
|
||||||
|
* \returns a change counter that is incremented with each potential device
|
||||||
|
* change, or 0 if device change detection isn't available.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_hid_enumerate
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_device_change_count")] public static extern Uint32 hid_device_change_count();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumerate the HID Devices.
|
||||||
|
*
|
||||||
|
* This function returns a linked list of all the HID devices attached to the
|
||||||
|
* system which match vendor_id and product_id. If `vendor_id` is set to 0
|
||||||
|
* then any vendor matches. If `product_id` is set to 0 then any product
|
||||||
|
* matches. If `vendor_id` and `product_id` are both set to 0, then all HID
|
||||||
|
* devices will be returned.
|
||||||
|
*
|
||||||
|
* By default SDL will only enumerate controllers, to reduce risk of hanging
|
||||||
|
* or crashing on bad drivers, but SDL_HINT_HIDAPI_ENUMERATE_ONLY_CONTROLLERS
|
||||||
|
* can be set to "0" to enumerate all HID devices.
|
||||||
|
*
|
||||||
|
* \param vendor_id the Vendor ID (VID) of the types of device to open, or 0
|
||||||
|
* to match any vendor.
|
||||||
|
* \param product_id the Product ID (PID) of the types of device to open, or 0
|
||||||
|
* to match any product.
|
||||||
|
* \returns a pointer to a linked list of type SDL_hid_device_info, containing
|
||||||
|
* information about the HID devices attached to the system, or NULL
|
||||||
|
* in the case of failure. Free this linked list by calling
|
||||||
|
* SDL_hid_free_enumeration().
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_hid_device_change_count
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_enumerate")] public static extern hid_device_info* hid_enumerate(c_ushort vendor_id, c_ushort product_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free an enumeration linked list.
|
||||||
|
*
|
||||||
|
* This function frees a linked list created by SDL_hid_enumerate().
|
||||||
|
*
|
||||||
|
* \param devs pointer to a list of struct_device returned from
|
||||||
|
* SDL_hid_enumerate().
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_free_enumeration")] public static extern void hid_free_enumeration(hid_device_info* devs);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally
|
||||||
|
* a serial number.
|
||||||
|
*
|
||||||
|
* If `serial_number` is NULL, the first device with the specified VID and PID
|
||||||
|
* is opened.
|
||||||
|
*
|
||||||
|
* \param vendor_id the Vendor ID (VID) of the device to open.
|
||||||
|
* \param product_id the Product ID (PID) of the device to open.
|
||||||
|
* \param serial_number the Serial Number of the device to open (Optionally
|
||||||
|
* NULL).
|
||||||
|
* \returns a pointer to a SDL_hid_device object on success or NULL on
|
||||||
|
* failure; call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_open")] public static extern hid_device* hid_open(c_ushort vendor_id, c_ushort product_id, c_wchar* serial_number);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a HID device by its path name.
|
||||||
|
*
|
||||||
|
* The path name be determined by calling SDL_hid_enumerate(), or a
|
||||||
|
* platform-specific path name can be used (eg: /dev/hidraw0 on Linux).
|
||||||
|
*
|
||||||
|
* \param path the path name of the device to open.
|
||||||
|
* \returns a pointer to a SDL_hid_device object on success or NULL on
|
||||||
|
* failure; call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_open_path")] public static extern hid_device* hid_open_path(c_char* path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the properties associated with an SDL_hid_device.
|
||||||
|
*
|
||||||
|
* The following read-only properties are provided by SDL:
|
||||||
|
*
|
||||||
|
* - `SDL_PROP_HIDAPI_LIBUSB_DEVICE_HANDLE_POINTER`: the libusb_device_handle
|
||||||
|
* associated with the device, if it was opened using libusb.
|
||||||
|
*
|
||||||
|
* \param dev a device handle returned from SDL_hid_open().
|
||||||
|
* \returns a valid property ID on success or 0 on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.4.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_get_properties")] public static extern PropertiesID hid_get_properties(hid_device* dev);
|
||||||
|
|
||||||
|
public const let PROP_HIDAPI_LIBUSB_DEVICE_HANDLE_POINTER = "SDL.hidapi.libusb.device.handle";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write an Output report to a HID device.
|
||||||
|
*
|
||||||
|
* The first byte of `data` must contain the Report ID. For devices which only
|
||||||
|
* support a single report, this must be set to 0x0. The remaining bytes
|
||||||
|
* contain the report data. Since the Report ID is mandatory, calls to
|
||||||
|
* SDL_hid_write() will always contain one more byte than the report contains.
|
||||||
|
* For example, if a hid report is 16 bytes long, 17 bytes must be passed to
|
||||||
|
* SDL_hid_write(), the Report ID (or 0x0, for devices with a single report),
|
||||||
|
* followed by the report data (16 bytes). In this example, the length passed
|
||||||
|
* in would be 17.
|
||||||
|
*
|
||||||
|
* SDL_hid_write() will send the data on the first OUT endpoint, if one
|
||||||
|
* exists. If it does not, it will send the data through the Control Endpoint
|
||||||
|
* (Endpoint 0).
|
||||||
|
*
|
||||||
|
* \param dev a device handle returned from SDL_hid_open().
|
||||||
|
* \param data the data to send, including the report number as the first
|
||||||
|
* byte.
|
||||||
|
* \param length the length in bytes of the data to send.
|
||||||
|
* \returns the actual number of bytes written and -1 on on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_write")] public static extern c_int hid_write(hid_device* dev, c_uchar* data, c_size length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read an Input report from a HID device with timeout.
|
||||||
|
*
|
||||||
|
* Input reports are returned to the host through the INTERRUPT IN endpoint.
|
||||||
|
* The first byte will contain the Report number if the device uses numbered
|
||||||
|
* reports.
|
||||||
|
*
|
||||||
|
* \param dev a device handle returned from SDL_hid_open().
|
||||||
|
* \param data a buffer to put the read data into.
|
||||||
|
* \param length the number of bytes to read. For devices with multiple
|
||||||
|
* reports, make sure to read an extra byte for the report
|
||||||
|
* number.
|
||||||
|
* \param milliseconds timeout in milliseconds or -1 for blocking wait.
|
||||||
|
* \returns the actual number of bytes read and -1 on on failure; call
|
||||||
|
* SDL_GetError() for more information. If no packet was available to
|
||||||
|
* be read within the timeout period, this function returns 0.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_read_timeout")] public static extern c_int hid_read_timeout(hid_device* dev, c_uchar* data, c_size length, c_int milliseconds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read an Input report from a HID device.
|
||||||
|
*
|
||||||
|
* Input reports are returned to the host through the INTERRUPT IN endpoint.
|
||||||
|
* The first byte will contain the Report number if the device uses numbered
|
||||||
|
* reports.
|
||||||
|
*
|
||||||
|
* \param dev a device handle returned from SDL_hid_open().
|
||||||
|
* \param data a buffer to put the read data into.
|
||||||
|
* \param length the number of bytes to read. For devices with multiple
|
||||||
|
* reports, make sure to read an extra byte for the report
|
||||||
|
* number.
|
||||||
|
* \returns the actual number of bytes read and -1 on failure; call
|
||||||
|
* SDL_GetError() for more information. If no packet was available to
|
||||||
|
* be read and the handle is in non-blocking mode, this function
|
||||||
|
* returns 0.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_read")] public static extern c_int hid_read(hid_device* dev, c_uchar* data, c_size length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the device handle to be non-blocking.
|
||||||
|
*
|
||||||
|
* In non-blocking mode calls to SDL_hid_read() will return immediately with a
|
||||||
|
* value of 0 if there is no data to be read. In blocking mode, SDL_hid_read()
|
||||||
|
* will wait (block) until there is data to read before returning.
|
||||||
|
*
|
||||||
|
* Nonblocking can be turned on and off at any time.
|
||||||
|
*
|
||||||
|
* \param dev a device handle returned from SDL_hid_open().
|
||||||
|
* \param nonblock enable or not the nonblocking reads - 1 to enable
|
||||||
|
* nonblocking - 0 to disable nonblocking.
|
||||||
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_set_nonblocking")] public static extern c_int hid_set_nonblocking(hid_device* dev, c_int nonblock);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a Feature report to the device.
|
||||||
|
*
|
||||||
|
* Feature reports are sent over the Control endpoint as a Set_Report
|
||||||
|
* transfer. The first byte of `data` must contain the Report ID. For devices
|
||||||
|
* which only support a single report, this must be set to 0x0. The remaining
|
||||||
|
* bytes contain the report data. Since the Report ID is mandatory, calls to
|
||||||
|
* SDL_hid_send_feature_report() will always contain one more byte than the
|
||||||
|
* report contains. For example, if a hid report is 16 bytes long, 17 bytes
|
||||||
|
* must be passed to SDL_hid_send_feature_report(): the Report ID (or 0x0, for
|
||||||
|
* devices which do not use numbered reports), followed by the report data (16
|
||||||
|
* bytes). In this example, the length passed in would be 17.
|
||||||
|
*
|
||||||
|
* \param dev a device handle returned from SDL_hid_open().
|
||||||
|
* \param data the data to send, including the report number as the first
|
||||||
|
* byte.
|
||||||
|
* \param length the length in bytes of the data to send, including the report
|
||||||
|
* number.
|
||||||
|
* \returns the actual number of bytes written and -1 on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_send_feature_report")] public static extern c_int hid_send_feature_report(hid_device* dev, c_uchar* data, c_size length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a feature report from a HID device.
|
||||||
|
*
|
||||||
|
* Set the first byte of `data` to the Report ID of the report to be read.
|
||||||
|
* Make sure to allow space for this extra byte in `data`. Upon return, the
|
||||||
|
* first byte will still contain the Report ID, and the report data will start
|
||||||
|
* in data[1].
|
||||||
|
*
|
||||||
|
* \param dev a device handle returned from SDL_hid_open().
|
||||||
|
* \param data a buffer to put the read data into, including the Report ID.
|
||||||
|
* Set the first byte of `data` to the Report ID of the report to
|
||||||
|
* be read, or set it to zero if your device does not use numbered
|
||||||
|
* reports.
|
||||||
|
* \param length the number of bytes to read, including an extra byte for the
|
||||||
|
* report ID. The buffer can be longer than the actual report.
|
||||||
|
* \returns the number of bytes read plus one for the report ID (which is
|
||||||
|
* still in the first byte), or -1 on on failure; call SDL_GetError()
|
||||||
|
* for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_get_feature_report")] public static extern c_int hid_get_feature_report(hid_device* dev, c_uchar* data, c_size length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an input report from a HID device.
|
||||||
|
*
|
||||||
|
* Set the first byte of `data` to the Report ID of the report to be read.
|
||||||
|
* Make sure to allow space for this extra byte in `data`. Upon return, the
|
||||||
|
* first byte will still contain the Report ID, and the report data will start
|
||||||
|
* in data[1].
|
||||||
|
*
|
||||||
|
* \param dev a device handle returned from SDL_hid_open().
|
||||||
|
* \param data a buffer to put the read data into, including the Report ID.
|
||||||
|
* Set the first byte of `data` to the Report ID of the report to
|
||||||
|
* be read, or set it to zero if your device does not use numbered
|
||||||
|
* reports.
|
||||||
|
* \param length the number of bytes to read, including an extra byte for the
|
||||||
|
* report ID. The buffer can be longer than the actual report.
|
||||||
|
* \returns the number of bytes read plus one for the report ID (which is
|
||||||
|
* still in the first byte), or -1 on on failure; call SDL_GetError()
|
||||||
|
* for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_get_input_report")] public static extern c_int hid_get_input_report(hid_device* dev, c_uchar* data, c_size length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close a HID device.
|
||||||
|
*
|
||||||
|
* \param dev a device handle returned from SDL_hid_open().
|
||||||
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_close")] public static extern c_int hid_close(hid_device* dev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get The Manufacturer String from a HID device.
|
||||||
|
*
|
||||||
|
* \param dev a device handle returned from SDL_hid_open().
|
||||||
|
* \param string a wide string buffer to put the data into.
|
||||||
|
* \param maxlen the length of the buffer in multiples of wchar_t.
|
||||||
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_get_manufacturer_string")] public static extern c_int hid_get_manufacturer_string(hid_device* dev, c_wchar* string, c_size maxlen);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get The Product String from a HID device.
|
||||||
|
*
|
||||||
|
* \param dev a device handle returned from SDL_hid_open().
|
||||||
|
* \param string a wide string buffer to put the data into.
|
||||||
|
* \param maxlen the length of the buffer in multiples of wchar_t.
|
||||||
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_get_product_string")] public static extern c_int hid_get_product_string(hid_device* dev, c_wchar* string, c_size maxlen);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get The Serial Number String from a HID device.
|
||||||
|
*
|
||||||
|
* \param dev a device handle returned from SDL_hid_open().
|
||||||
|
* \param string a wide string buffer to put the data into.
|
||||||
|
* \param maxlen the length of the buffer in multiples of wchar_t.
|
||||||
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_get_serial_number_string")] public static extern c_int hid_get_serial_number_string(hid_device* dev, c_wchar* string, c_size maxlen);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a string from a HID device, based on its string index.
|
||||||
|
*
|
||||||
|
* \param dev a device handle returned from SDL_hid_open().
|
||||||
|
* \param string_index the index of the string to get.
|
||||||
|
* \param string a wide string buffer to put the data into.
|
||||||
|
* \param maxlen the length of the buffer in multiples of wchar_t.
|
||||||
|
* \returns 0 on success or a negative error code on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_get_indexed_string")] public static extern c_int hid_get_indexed_string(hid_device* dev, c_int string_index, c_wchar* string, c_size maxlen);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the device info from a HID device.
|
||||||
|
*
|
||||||
|
* \param dev a device handle returned from SDL_hid_open().
|
||||||
|
* \returns a pointer to the SDL_hid_device_info for this hid_device or NULL
|
||||||
|
* on failure; call SDL_GetError() for more information. This struct
|
||||||
|
* is valid until the device is closed with SDL_hid_close().
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_get_device_info")] public static extern hid_device_info* hid_get_device_info(hid_device* dev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a report descriptor from a HID device.
|
||||||
|
*
|
||||||
|
* User has to provide a preallocated buffer where descriptor will be copied
|
||||||
|
* to. The recommended size for a preallocated buffer is 4096 bytes.
|
||||||
|
*
|
||||||
|
* \param dev a device handle returned from SDL_hid_open().
|
||||||
|
* \param buf the buffer to copy descriptor into.
|
||||||
|
* \param buf_size the size of the buffer in bytes.
|
||||||
|
* \returns the number of bytes actually copied or -1 on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_get_report_descriptor")] public static extern c_int hid_get_report_descriptor(hid_device* dev, c_uchar* buf, c_size buf_size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start or stop a BLE scan on iOS and tvOS to pair Steam Controllers.
|
||||||
|
*
|
||||||
|
* \param active true to start the scan, false to stop the scan.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_hid_ble_scan")] public static extern void hid_ble_scan(bool active);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_hidapi_h_ */
|
||||||
4898
src/SDL_hints.bf
Normal file
4898
src/SDL_hints.bf
Normal file
File diff suppressed because it is too large
Load Diff
509
src/SDL_init.bf
Normal file
509
src/SDL_init.bf
Normal file
@@ -0,0 +1,509 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryInit
|
||||||
|
*
|
||||||
|
* All SDL programs need to initialize the library before starting to work
|
||||||
|
* with it.
|
||||||
|
*
|
||||||
|
* Almost everything can simply call SDL_Init() near startup, with a handful
|
||||||
|
* of flags to specify subsystems to touch. These are here to make sure SDL
|
||||||
|
* does not even attempt to touch low-level pieces of the operating system
|
||||||
|
* that you don't intend to use. For example, you might be using SDL for video
|
||||||
|
* and input but chose an external library for audio, and in this case you
|
||||||
|
* would just need to leave off the `SDL_INIT_AUDIO` flag to make sure that
|
||||||
|
* external library has complete control.
|
||||||
|
*
|
||||||
|
* Most apps, when terminating, should call SDL_Quit(). This will clean up
|
||||||
|
* (nearly) everything that SDL might have allocated, and crucially, it'll
|
||||||
|
* make sure that the display's resolution is back to what the user expects if
|
||||||
|
* you had previously changed it for your game.
|
||||||
|
*
|
||||||
|
* SDL3 apps are strongly encouraged to call SDL_SetAppMetadata() at startup
|
||||||
|
* to fill in details about the program. This is completely optional, but it
|
||||||
|
* helps in small ways (we can provide an About dialog box for the macOS menu,
|
||||||
|
* we can name the app in the system's audio mixer, etc). Those that want to
|
||||||
|
* provide a _lot_ of information should look at the more-detailed
|
||||||
|
* SDL_SetAppMetadataProperty().
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* As of version 0.5, SDL is loaded dynamically into the application */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialization flags for SDL_Init and/or SDL_InitSubSystem
|
||||||
|
*
|
||||||
|
* These are the flags which may be passed to SDL_Init(). You should specify
|
||||||
|
* the subsystems which you will be using in your application.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Init
|
||||||
|
* \sa SDL_Quit
|
||||||
|
* \sa SDL_InitSubSystem
|
||||||
|
* \sa SDL_QuitSubSystem
|
||||||
|
* \sa SDL_WasInit
|
||||||
|
*/
|
||||||
|
public enum InitFlags : Uint32
|
||||||
|
{
|
||||||
|
Audio = 0x00000010u, /**< `SDL_INIT_AUDIO` implies `SDL_INIT_EVENTS` */
|
||||||
|
Video = 0x00000020u, /**< `SDL_INIT_VIDEO` implies `SDL_INIT_EVENTS`, should be initialized on the main thread */
|
||||||
|
Joystick = 0x00000200u, /**< `SDL_INIT_JOYSTICK` implies `SDL_INIT_EVENTS` */
|
||||||
|
Haptic = 0x00001000u,
|
||||||
|
Gamepad = 0x00002000u, /**< `SDL_INIT_GAMEPAD` implies `SDL_INIT_JOYSTICK` */
|
||||||
|
Events = 0x00004000u,
|
||||||
|
Sensor = 0x00008000u, /**< `SDL_INIT_SENSOR` implies `SDL_INIT_EVENTS` */
|
||||||
|
Camera = 0x00010000u, /**< `SDL_INIT_CAMERA` implies `SDL_INIT_EVENTS` */
|
||||||
|
} /**< `SDL_INIT_CAMERA` implies `SDL_INIT_EVENTS` */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return values for optional main callbacks.
|
||||||
|
*
|
||||||
|
* Returning SDL_APP_SUCCESS or SDL_APP_FAILURE from SDL_AppInit,
|
||||||
|
* SDL_AppEvent, or SDL_AppIterate will terminate the program and report
|
||||||
|
* success/failure to the operating system. What that means is
|
||||||
|
* platform-dependent. On Unix, for example, on success, the process error
|
||||||
|
* code will be zero, and on failure it will be 1. This interface doesn't
|
||||||
|
* allow you to return specific exit codes, just whether there was an error
|
||||||
|
* generally or not.
|
||||||
|
*
|
||||||
|
* Returning SDL_APP_CONTINUE from these functions will let the app continue
|
||||||
|
* to run.
|
||||||
|
*
|
||||||
|
* See
|
||||||
|
* [Main callbacks in SDL3](https://wiki.libsdl.org/SDL3/README-main-functions#main-callbacks-in-sdl3)
|
||||||
|
* for complete details.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum AppResult : c_int
|
||||||
|
{
|
||||||
|
Continue, /**< Value that requests that the app continue from the main callbacks. */
|
||||||
|
Success, /**< Value that requests termination with success from the main callbacks. */
|
||||||
|
Failure, /**< Value that requests termination with error from the main callbacks. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function pointer typedef for SDL_AppInit.
|
||||||
|
*
|
||||||
|
* These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind
|
||||||
|
* the scenes for apps using the optional main callbacks. Apps that want to
|
||||||
|
* use this should just implement SDL_AppInit directly.
|
||||||
|
*
|
||||||
|
* \param appstate a place where the app can optionally store a pointer for
|
||||||
|
* future use.
|
||||||
|
* \param argc the standard ANSI C main's argc; number of elements in `argv`.
|
||||||
|
* \param argv the standard ANSI C main's argv; array of command line
|
||||||
|
* arguments.
|
||||||
|
* \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
|
||||||
|
* terminate with success, SDL_APP_CONTINUE to continue.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public function AppResult AppInit_func(void** appstate, c_int argc, c_char**);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function pointer typedef for SDL_AppIterate.
|
||||||
|
*
|
||||||
|
* These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind
|
||||||
|
* the scenes for apps using the optional main callbacks. Apps that want to
|
||||||
|
* use this should just implement SDL_AppIterate directly.
|
||||||
|
*
|
||||||
|
* \param appstate an optional pointer, provided by the app in SDL_AppInit.
|
||||||
|
* \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
|
||||||
|
* terminate with success, SDL_APP_CONTINUE to continue.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public function AppResult AppIterate_func(void* appstate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function pointer typedef for SDL_AppEvent.
|
||||||
|
*
|
||||||
|
* These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind
|
||||||
|
* the scenes for apps using the optional main callbacks. Apps that want to
|
||||||
|
* use this should just implement SDL_AppEvent directly.
|
||||||
|
*
|
||||||
|
* \param appstate an optional pointer, provided by the app in SDL_AppInit.
|
||||||
|
* \param event the new event for the app to examine.
|
||||||
|
* \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
|
||||||
|
* terminate with success, SDL_APP_CONTINUE to continue.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public function AppResult AppEvent_func(void* appstate, Event* event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function pointer typedef for SDL_AppQuit.
|
||||||
|
*
|
||||||
|
* These are used by SDL_EnterAppMainCallbacks. This mechanism operates behind
|
||||||
|
* the scenes for apps using the optional main callbacks. Apps that want to
|
||||||
|
* use this should just implement SDL_AppEvent directly.
|
||||||
|
*
|
||||||
|
* \param appstate an optional pointer, provided by the app in SDL_AppInit.
|
||||||
|
* \param result the result code that terminated the app (success or failure).
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public function void AppQuit_func(void* appstate, AppResult result);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the SDL library.
|
||||||
|
*
|
||||||
|
* SDL_Init() simply forwards to calling SDL_InitSubSystem(). Therefore, the
|
||||||
|
* two may be used interchangeably. Though for readability of your code
|
||||||
|
* SDL_InitSubSystem() might be preferred.
|
||||||
|
*
|
||||||
|
* The file I/O (for example: SDL_IOFromFile) and threading (SDL_CreateThread)
|
||||||
|
* subsystems are initialized by default. Message boxes
|
||||||
|
* (SDL_ShowSimpleMessageBox) also attempt to work without initializing the
|
||||||
|
* video subsystem, in hopes of being useful in showing an error dialog when
|
||||||
|
* SDL_Init fails. You must specifically initialize other subsystems if you
|
||||||
|
* use them in your application.
|
||||||
|
*
|
||||||
|
* Logging (such as SDL_Log) works without initialization, too.
|
||||||
|
*
|
||||||
|
* `flags` may be any of the following OR'd together:
|
||||||
|
*
|
||||||
|
* - `SDL_INIT_AUDIO`: audio subsystem; automatically initializes the events
|
||||||
|
* subsystem
|
||||||
|
* - `SDL_INIT_VIDEO`: video subsystem; automatically initializes the events
|
||||||
|
* subsystem, should be initialized on the main thread.
|
||||||
|
* - `SDL_INIT_JOYSTICK`: joystick subsystem; automatically initializes the
|
||||||
|
* events subsystem
|
||||||
|
* - `SDL_INIT_HAPTIC`: haptic (force feedback) subsystem
|
||||||
|
* - `SDL_INIT_GAMEPAD`: gamepad subsystem; automatically initializes the
|
||||||
|
* joystick subsystem
|
||||||
|
* - `SDL_INIT_EVENTS`: events subsystem
|
||||||
|
* - `SDL_INIT_SENSOR`: sensor subsystem; automatically initializes the events
|
||||||
|
* subsystem
|
||||||
|
* - `SDL_INIT_CAMERA`: camera subsystem; automatically initializes the events
|
||||||
|
* subsystem
|
||||||
|
*
|
||||||
|
* Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem()
|
||||||
|
* for each SDL_InitSubSystem() to correctly shutdown a subsystem manually (or
|
||||||
|
* call SDL_Quit() to force shutdown). If a subsystem is already loaded then
|
||||||
|
* this call will increase the ref-count and return.
|
||||||
|
*
|
||||||
|
* Consider reporting some basic metadata about your application before
|
||||||
|
* calling SDL_Init, using either SDL_SetAppMetadata() or
|
||||||
|
* SDL_SetAppMetadataProperty().
|
||||||
|
*
|
||||||
|
* \param flags subsystem initialization flags.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetAppMetadata
|
||||||
|
* \sa SDL_SetAppMetadataProperty
|
||||||
|
* \sa SDL_InitSubSystem
|
||||||
|
* \sa SDL_Quit
|
||||||
|
* \sa SDL_SetMainReady
|
||||||
|
* \sa SDL_WasInit
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_Init")] public static extern bool Init(InitFlags flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compatibility function to initialize the SDL library.
|
||||||
|
*
|
||||||
|
* This function and SDL_Init() are interchangeable.
|
||||||
|
*
|
||||||
|
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Init
|
||||||
|
* \sa SDL_Quit
|
||||||
|
* \sa SDL_QuitSubSystem
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_InitSubSystem")] public static extern bool InitSubSystem(InitFlags flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shut down specific SDL subsystems.
|
||||||
|
*
|
||||||
|
* You still need to call SDL_Quit() even if you close all open subsystems
|
||||||
|
* with SDL_QuitSubSystem().
|
||||||
|
*
|
||||||
|
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_InitSubSystem
|
||||||
|
* \sa SDL_Quit
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_QuitSubSystem")] public static extern void QuitSubSystem(InitFlags flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a mask of the specified subsystems which are currently initialized.
|
||||||
|
*
|
||||||
|
* \param flags any of the flags used by SDL_Init(); see SDL_Init for details.
|
||||||
|
* \returns a mask of all initialized subsystems if `flags` is 0, otherwise it
|
||||||
|
* returns the initialization status of the specified subsystems.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Init
|
||||||
|
* \sa SDL_InitSubSystem
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_WasInit")] public static extern InitFlags WasInit(InitFlags flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up all initialized subsystems.
|
||||||
|
*
|
||||||
|
* You should call this function even if you have already shutdown each
|
||||||
|
* initialized subsystem with SDL_QuitSubSystem(). It is safe to call this
|
||||||
|
* function even in the case of errors in initialization.
|
||||||
|
*
|
||||||
|
* You can use this function with atexit() to ensure that it is run when your
|
||||||
|
* application is shutdown, but it is not wise to do this from a library or
|
||||||
|
* other dynamically loaded code.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Init
|
||||||
|
* \sa SDL_QuitSubSystem
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_Quit")] public static extern void Quit();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether this is the main thread.
|
||||||
|
*
|
||||||
|
* On Apple platforms, the main thread is the thread that runs your program's
|
||||||
|
* main() entry point. On other platforms, the main thread is the one that
|
||||||
|
* calls SDL_Init(SDL_INIT_VIDEO), which should usually be the one that runs
|
||||||
|
* your program's main() entry point. If you are using the main callbacks,
|
||||||
|
* SDL_AppInit(), SDL_AppIterate(), and SDL_AppQuit() are all called on the
|
||||||
|
* main thread.
|
||||||
|
*
|
||||||
|
* \returns true if this thread is the main thread, or false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_RunOnMainThread
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_IsMainThread")] public static extern bool IsMainThread();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback run on the main thread.
|
||||||
|
*
|
||||||
|
* \param userdata an app-controlled pointer that is passed to the callback.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_RunOnMainThread
|
||||||
|
*/
|
||||||
|
public function void MainThreadCallback(void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call a function on the main thread during event processing.
|
||||||
|
*
|
||||||
|
* If this is called on the main thread, the callback is executed immediately.
|
||||||
|
* If this is called on another thread, this callback is queued for execution
|
||||||
|
* on the main thread during event processing.
|
||||||
|
*
|
||||||
|
* Be careful of deadlocks when using this functionality. You should not have
|
||||||
|
* the main thread wait for the current thread while this function is being
|
||||||
|
* called with `wait_complete` true.
|
||||||
|
*
|
||||||
|
* \param callback the callback to call on the main thread.
|
||||||
|
* \param userdata a pointer that is passed to `callback`.
|
||||||
|
* \param wait_complete true to wait for the callback to complete, false to
|
||||||
|
* return immediately.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_IsMainThread
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_RunOnMainThread")] public static extern bool RunOnMainThread(MainThreadCallback callback, void* userdata, bool wait_complete);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify basic metadata about your app.
|
||||||
|
*
|
||||||
|
* You can optionally provide metadata about your app to SDL. This is not
|
||||||
|
* required, but strongly encouraged.
|
||||||
|
*
|
||||||
|
* There are several locations where SDL can make use of metadata (an "About"
|
||||||
|
* box in the macOS menu bar, the name of the app can be shown on some audio
|
||||||
|
* mixers, etc). Any piece of metadata can be left as NULL, if a specific
|
||||||
|
* detail doesn't make sense for the app.
|
||||||
|
*
|
||||||
|
* This function should be called as early as possible, before SDL_Init.
|
||||||
|
* Multiple calls to this function are allowed, but various state might not
|
||||||
|
* change once it has been set up with a previous call to this function.
|
||||||
|
*
|
||||||
|
* Passing a NULL removes any previous metadata.
|
||||||
|
*
|
||||||
|
* This is a simplified interface for the most important information. You can
|
||||||
|
* supply significantly more detailed metadata with
|
||||||
|
* SDL_SetAppMetadataProperty().
|
||||||
|
*
|
||||||
|
* \param appname The name of the application ("My Game 2: Bad Guy's
|
||||||
|
* Revenge!").
|
||||||
|
* \param appversion The version of the application ("1.0.0beta5" or a git
|
||||||
|
* hash, or whatever makes sense).
|
||||||
|
* \param appidentifier A unique string in reverse-domain format that
|
||||||
|
* identifies this app ("com.example.mygame2").
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetAppMetadataProperty
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetAppMetadata")] public static extern bool SetAppMetadata(c_char* appname, c_char* appversion, c_char* appidentifier);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify metadata about your app through a set of properties.
|
||||||
|
*
|
||||||
|
* You can optionally provide metadata about your app to SDL. This is not
|
||||||
|
* required, but strongly encouraged.
|
||||||
|
*
|
||||||
|
* There are several locations where SDL can make use of metadata (an "About"
|
||||||
|
* box in the macOS menu bar, the name of the app can be shown on some audio
|
||||||
|
* mixers, etc). Any piece of metadata can be left out, if a specific detail
|
||||||
|
* doesn't make sense for the app.
|
||||||
|
*
|
||||||
|
* This function should be called as early as possible, before SDL_Init.
|
||||||
|
* Multiple calls to this function are allowed, but various state might not
|
||||||
|
* change once it has been set up with a previous call to this function.
|
||||||
|
*
|
||||||
|
* Once set, this metadata can be read using SDL_GetAppMetadataProperty().
|
||||||
|
*
|
||||||
|
* These are the supported properties:
|
||||||
|
*
|
||||||
|
* - `SDL_PROP_APP_METADATA_NAME_STRING`: The human-readable name of the
|
||||||
|
* application, like "My Game 2: Bad Guy's Revenge!". This will show up
|
||||||
|
* anywhere the OS shows the name of the application separately from window
|
||||||
|
* titles, such as volume control applets, etc. This defaults to "SDL
|
||||||
|
* Application".
|
||||||
|
* - `SDL_PROP_APP_METADATA_VERSION_STRING`: The version of the app that is
|
||||||
|
* running; there are no rules on format, so "1.0.3beta2" and "April 22nd,
|
||||||
|
* 2024" and a git hash are all valid options. This has no default.
|
||||||
|
* - `SDL_PROP_APP_METADATA_IDENTIFIER_STRING`: A unique string that
|
||||||
|
* identifies this app. This must be in reverse-domain format, like
|
||||||
|
* "com.example.mygame2". This string is used by desktop compositors to
|
||||||
|
* identify and group windows together, as well as match applications with
|
||||||
|
* associated desktop settings and icons. If you plan to package your
|
||||||
|
* application in a container such as Flatpak, the app ID should match the
|
||||||
|
* name of your Flatpak container as well. This has no default.
|
||||||
|
* - `SDL_PROP_APP_METADATA_CREATOR_STRING`: The human-readable name of the
|
||||||
|
* creator/developer/maker of this app, like "MojoWorkshop, LLC"
|
||||||
|
* - `SDL_PROP_APP_METADATA_COPYRIGHT_STRING`: The human-readable copyright
|
||||||
|
* notice, like "Copyright (c) 2024 MojoWorkshop, LLC" or whatnot. Keep this
|
||||||
|
* to one line, don't paste a copy of a whole software license in here. This
|
||||||
|
* has no default.
|
||||||
|
* - `SDL_PROP_APP_METADATA_URL_STRING`: A URL to the app on the web. Maybe a
|
||||||
|
* product page, or a storefront, or even a GitHub repository, for user's
|
||||||
|
* further information This has no default.
|
||||||
|
* - `SDL_PROP_APP_METADATA_TYPE_STRING`: The type of application this is.
|
||||||
|
* Currently this string can be "game" for a video game, "mediaplayer" for a
|
||||||
|
* media player, or generically "application" if nothing else applies.
|
||||||
|
* Future versions of SDL might add new types. This defaults to
|
||||||
|
* "application".
|
||||||
|
*
|
||||||
|
* \param name the name of the metadata property to set.
|
||||||
|
* \param value the value of the property, or NULL to remove that property.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetAppMetadataProperty
|
||||||
|
* \sa SDL_SetAppMetadata
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetAppMetadataProperty")] public static extern bool SetAppMetadataProperty(c_char* name, c_char* value);
|
||||||
|
|
||||||
|
public const let PROP_APP_METADATA_NAME_STRING = "SDL.app.metadata.name";
|
||||||
|
public const let PROP_APP_METADATA_VERSION_STRING = "SDL.app.metadata.version";
|
||||||
|
public const let PROP_APP_METADATA_IDENTIFIER_STRING = "SDL.app.metadata.identifier";
|
||||||
|
public const let PROP_APP_METADATA_CREATOR_STRING = "SDL.app.metadata.creator";
|
||||||
|
public const let PROP_APP_METADATA_COPYRIGHT_STRING = "SDL.app.metadata.copyright";
|
||||||
|
public const let PROP_APP_METADATA_URL_STRING = "SDL.app.metadata.url";
|
||||||
|
public const let PROP_APP_METADATA_TYPE_STRING = "SDL.app.metadata.type";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get metadata about your app.
|
||||||
|
*
|
||||||
|
* This returns metadata previously set using SDL_SetAppMetadata() or
|
||||||
|
* SDL_SetAppMetadataProperty(). See SDL_SetAppMetadataProperty() for the list
|
||||||
|
* of available properties and their meanings.
|
||||||
|
*
|
||||||
|
* \param name the name of the metadata property to get.
|
||||||
|
* \returns the current value of the metadata property, or the default if it
|
||||||
|
* is not set, NULL for properties with no default.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread, although
|
||||||
|
* the string returned is not protected and could potentially be
|
||||||
|
* freed if you call SDL_SetAppMetadataProperty() to set that
|
||||||
|
* property from another thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetAppMetadata
|
||||||
|
* \sa SDL_SetAppMetadataProperty
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetAppMetadataProperty")] public static extern c_char* GetAppMetadataProperty(c_char* name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_init_h_ */
|
||||||
1390
src/SDL_iostream.bf
Normal file
1390
src/SDL_iostream.bf
Normal file
File diff suppressed because it is too large
Load Diff
1411
src/SDL_joystick.bf
Normal file
1411
src/SDL_joystick.bf
Normal file
File diff suppressed because it is too large
Load Diff
619
src/SDL_keyboard.bf
Normal file
619
src/SDL_keyboard.bf
Normal file
@@ -0,0 +1,619 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryKeyboard
|
||||||
|
*
|
||||||
|
* SDL keyboard management.
|
||||||
|
*
|
||||||
|
* Please refer to the Best Keyboard Practices document for details on how
|
||||||
|
* best to accept keyboard input in various types of programs:
|
||||||
|
*
|
||||||
|
* https://wiki.libsdl.org/SDL3/BestKeyboardPractices
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a unique ID for a keyboard for the time it is connected to the
|
||||||
|
* system, and is never reused for the lifetime of the application.
|
||||||
|
*
|
||||||
|
* If the keyboard is disconnected and reconnected, it will get a new ID.
|
||||||
|
*
|
||||||
|
* The value 0 is an invalid ID.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public typealias KeyboardID = Uint32;
|
||||||
|
|
||||||
|
/* Function prototypes */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether a keyboard is currently connected.
|
||||||
|
*
|
||||||
|
* \returns true if a keyboard is connected, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetKeyboards
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasKeyboard")] public static extern bool HasKeyboard();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of currently connected keyboards.
|
||||||
|
*
|
||||||
|
* Note that this will include any device or virtual driver that includes
|
||||||
|
* keyboard functionality, including some mice, KVM switches, motherboard
|
||||||
|
* power buttons, etc. You should wait for input from a device before you
|
||||||
|
* consider it actively in use.
|
||||||
|
*
|
||||||
|
* \param count a pointer filled in with the number of keyboards returned, may
|
||||||
|
* be NULL.
|
||||||
|
* \returns a 0 terminated array of keyboards instance IDs or NULL on failure;
|
||||||
|
* call SDL_GetError() for more information. This should be freed
|
||||||
|
* with SDL_free() when it is no longer needed.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetKeyboardNameForID
|
||||||
|
* \sa SDL_HasKeyboard
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetKeyboards")] public static extern KeyboardID* GetKeyboards(out c_int count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of a keyboard.
|
||||||
|
*
|
||||||
|
* This function returns "" if the keyboard doesn't have a name.
|
||||||
|
*
|
||||||
|
* \param instance_id the keyboard instance ID.
|
||||||
|
* \returns the name of the selected keyboard or NULL on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetKeyboards
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetKeyboardNameForID")] public static extern c_char* GetKeyboardNameForID(KeyboardID instance_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the window which currently has keyboard focus.
|
||||||
|
*
|
||||||
|
* \returns the window with keyboard focus.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetKeyboardFocus")] public static extern Window* GetKeyboardFocus();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a snapshot of the current state of the keyboard.
|
||||||
|
*
|
||||||
|
* The pointer returned is a pointer to an internal SDL array. It will be
|
||||||
|
* valid for the whole lifetime of the application and should not be freed by
|
||||||
|
* the caller.
|
||||||
|
*
|
||||||
|
* A array element with a value of true means that the key is pressed and a
|
||||||
|
* value of false means that it is not. Indexes into this array are obtained
|
||||||
|
* by using SDL_Scancode values.
|
||||||
|
*
|
||||||
|
* Use SDL_PumpEvents() to update the state array.
|
||||||
|
*
|
||||||
|
* This function gives you the current state after all events have been
|
||||||
|
* processed, so if a key or button has been pressed and released before you
|
||||||
|
* process events, then the pressed state will never show up in the
|
||||||
|
* SDL_GetKeyboardState() calls.
|
||||||
|
*
|
||||||
|
* Note: This function doesn't take into account whether shift has been
|
||||||
|
* pressed or not.
|
||||||
|
*
|
||||||
|
* \param numkeys if non-NULL, receives the length of the returned array.
|
||||||
|
* \returns a pointer to an array of key states.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_PumpEvents
|
||||||
|
* \sa SDL_ResetKeyboard
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetKeyboardState")] public static extern bool* GetKeyboardState(c_int* numkeys);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the state of the keyboard.
|
||||||
|
*
|
||||||
|
* This function will generate key up events for all pressed keys.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetKeyboardState
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ResetKeyboard")] public static extern void ResetKeyboard();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current key modifier state for the keyboard.
|
||||||
|
*
|
||||||
|
* \returns an OR'd combination of the modifier keys for the keyboard.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetKeyboardState
|
||||||
|
* \sa SDL_SetModState
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetModState")] public static extern Keymod GetModState();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current key modifier state for the keyboard.
|
||||||
|
*
|
||||||
|
* The inverse of SDL_GetModState(), SDL_SetModState() allows you to impose
|
||||||
|
* modifier key states on your application. Simply pass your desired modifier
|
||||||
|
* states into `modstate`. This value may be a bitwise, OR'd combination of
|
||||||
|
* SDL_Keymod values.
|
||||||
|
*
|
||||||
|
* This does not change the keyboard state, only the key modifier flags that
|
||||||
|
* SDL reports.
|
||||||
|
*
|
||||||
|
* \param modstate the desired SDL_Keymod for the keyboard.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetModState
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetModState")] public static extern void SetModState(Keymod modstate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the key code corresponding to the given scancode according to the
|
||||||
|
* current keyboard layout.
|
||||||
|
*
|
||||||
|
* If you want to get the keycode as it would be delivered in key events,
|
||||||
|
* including options specified in SDL_HINT_KEYCODE_OPTIONS, then you should
|
||||||
|
* pass `key_event` as true. Otherwise this function simply translates the
|
||||||
|
* scancode based on the given modifier state.
|
||||||
|
*
|
||||||
|
* \param scancode the desired SDL_Scancode to query.
|
||||||
|
* \param modstate the modifier state to use when translating the scancode to
|
||||||
|
* a keycode.
|
||||||
|
* \param key_event true if the keycode will be used in key events.
|
||||||
|
* \returns the SDL_Keycode that corresponds to the given SDL_Scancode.
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetKeyName
|
||||||
|
* \sa SDL_GetScancodeFromKey
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetKeyFromScancode")] public static extern Keycode GetKeyFromScancode(Scancode scancode, Keymod modstate, bool key_event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the scancode corresponding to the given key code according to the
|
||||||
|
* current keyboard layout.
|
||||||
|
*
|
||||||
|
* Note that there may be multiple scancode+modifier states that can generate
|
||||||
|
* this keycode, this will just return the first one found.
|
||||||
|
*
|
||||||
|
* \param key the desired SDL_Keycode to query.
|
||||||
|
* \param modstate a pointer to the modifier state that would be used when the
|
||||||
|
* scancode generates this key, may be NULL.
|
||||||
|
* \returns the SDL_Scancode that corresponds to the given SDL_Keycode.
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetKeyFromScancode
|
||||||
|
* \sa SDL_GetScancodeName
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetScancodeFromKey")] public static extern Scancode GetScancodeFromKey(Keycode key, Keymod* modstate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a human-readable name for a scancode.
|
||||||
|
*
|
||||||
|
* \param scancode the desired SDL_Scancode.
|
||||||
|
* \param name the name to use for the scancode, encoded as UTF-8. The string
|
||||||
|
* is not copied, so the pointer given to this function must stay
|
||||||
|
* valid while SDL is being used.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetScancodeName
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetScancodeName")] public static extern bool SetScancodeName(Scancode scancode, c_char* name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a human-readable name for a scancode.
|
||||||
|
*
|
||||||
|
* **Warning**: The returned name is by design not stable across platforms,
|
||||||
|
* e.g. the name for `SDL_SCANCODE_LGUI` is "Left GUI" under Linux but "Left
|
||||||
|
* Windows" under Microsoft Windows, and some scancodes like
|
||||||
|
* `SDL_SCANCODE_NONUSBACKSLASH` don't have any name at all. There are even
|
||||||
|
* scancodes that share names, e.g. `SDL_SCANCODE_RETURN` and
|
||||||
|
* `SDL_SCANCODE_RETURN2` (both called "Return"). This function is therefore
|
||||||
|
* unsuitable for creating a stable cross-platform two-way mapping between
|
||||||
|
* strings and scancodes.
|
||||||
|
*
|
||||||
|
* \param scancode the desired SDL_Scancode to query.
|
||||||
|
* \returns a pointer to the name for the scancode. If the scancode doesn't
|
||||||
|
* have a name this function returns an empty string ("").
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetScancodeFromKey
|
||||||
|
* \sa SDL_GetScancodeFromName
|
||||||
|
* \sa SDL_SetScancodeName
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetScancodeName")] public static extern c_char* GetScancodeName(Scancode scancode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a scancode from a human-readable name.
|
||||||
|
*
|
||||||
|
* \param name the human-readable scancode name.
|
||||||
|
* \returns the SDL_Scancode, or `SDL_SCANCODE_UNKNOWN` if the name wasn't
|
||||||
|
* recognized; call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetKeyFromName
|
||||||
|
* \sa SDL_GetScancodeFromKey
|
||||||
|
* \sa SDL_GetScancodeName
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetScancodeFromName")] public static extern Scancode GetScancodeFromName(c_char* name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a human-readable name for a key.
|
||||||
|
*
|
||||||
|
* If the key doesn't have a name, this function returns an empty string ("").
|
||||||
|
*
|
||||||
|
* Letters will be presented in their uppercase form, if applicable.
|
||||||
|
*
|
||||||
|
* \param key the desired SDL_Keycode to query.
|
||||||
|
* \returns a UTF-8 encoded string of the key name.
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetKeyFromName
|
||||||
|
* \sa SDL_GetKeyFromScancode
|
||||||
|
* \sa SDL_GetScancodeFromKey
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetKeyName")] public static extern c_char* GetKeyName(Keycode key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a key code from a human-readable name.
|
||||||
|
*
|
||||||
|
* \param name the human-readable key name.
|
||||||
|
* \returns key code, or `SDLK_UNKNOWN` if the name wasn't recognized; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetKeyFromScancode
|
||||||
|
* \sa SDL_GetKeyName
|
||||||
|
* \sa SDL_GetScancodeFromName
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetKeyFromName")] public static extern Keycode GetKeyFromName(c_char* name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start accepting Unicode text input events in a window.
|
||||||
|
*
|
||||||
|
* This function will enable text input (SDL_EVENT_TEXT_INPUT and
|
||||||
|
* SDL_EVENT_TEXT_EDITING events) in the specified window. Please use this
|
||||||
|
* function paired with SDL_StopTextInput().
|
||||||
|
*
|
||||||
|
* Text input events are not received by default.
|
||||||
|
*
|
||||||
|
* On some platforms using this function shows the screen keyboard and/or
|
||||||
|
* activates an IME, which can prevent some key press events from being passed
|
||||||
|
* through.
|
||||||
|
*
|
||||||
|
* \param window the window to enable text input.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetTextInputArea
|
||||||
|
* \sa SDL_StartTextInputWithProperties
|
||||||
|
* \sa SDL_StopTextInput
|
||||||
|
* \sa SDL_TextInputActive
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_StartTextInput")] public static extern bool StartTextInput(Window* window);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Text input type.
|
||||||
|
*
|
||||||
|
* These are the valid values for SDL_PROP_TEXTINPUT_TYPE_NUMBER. Not every
|
||||||
|
* value is valid on every platform, but where a value isn't supported, a
|
||||||
|
* reasonable fallback will be used.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_StartTextInputWithProperties
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum TextInputType : c_int
|
||||||
|
{
|
||||||
|
Text, /**< The input is text */
|
||||||
|
TextName, /**< The input is a person's name */
|
||||||
|
TextEmail, /**< The input is an e-mail address */
|
||||||
|
TextUsername, /**< The input is a username */
|
||||||
|
TextPasswordHidden, /**< The input is a secure password that is hidden */
|
||||||
|
TextPasswordVisible, /**< The input is a secure password that is visible */
|
||||||
|
Number, /**< The input is a number */
|
||||||
|
NumberPasswordHidden, /**< The input is a secure PIN that is hidden */
|
||||||
|
NumberPasswordVisible, /**< The input is a secure PIN that is visible */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto capitalization type.
|
||||||
|
*
|
||||||
|
* These are the valid values for SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER.
|
||||||
|
* Not every value is valid on every platform, but where a value isn't
|
||||||
|
* supported, a reasonable fallback will be used.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_StartTextInputWithProperties
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum Capitalization : c_int
|
||||||
|
{
|
||||||
|
eNone, /**< No auto-capitalization will be done */
|
||||||
|
eSentences, /**< The first letter of sentences will be capitalized */
|
||||||
|
eWords, /**< The first letter of words will be capitalized */
|
||||||
|
eLetters, /**< All letters will be capitalized */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start accepting Unicode text input events in a window, with properties
|
||||||
|
* describing the input.
|
||||||
|
*
|
||||||
|
* This function will enable text input (SDL_EVENT_TEXT_INPUT and
|
||||||
|
* SDL_EVENT_TEXT_EDITING events) in the specified window. Please use this
|
||||||
|
* function paired with SDL_StopTextInput().
|
||||||
|
*
|
||||||
|
* Text input events are not received by default.
|
||||||
|
*
|
||||||
|
* On some platforms using this function shows the screen keyboard and/or
|
||||||
|
* activates an IME, which can prevent some key press events from being passed
|
||||||
|
* through.
|
||||||
|
*
|
||||||
|
* These are the supported properties:
|
||||||
|
*
|
||||||
|
* - `SDL_PROP_TEXTINPUT_TYPE_NUMBER` - an SDL_TextInputType value that
|
||||||
|
* describes text being input, defaults to SDL_TEXTINPUT_TYPE_TEXT.
|
||||||
|
* - `SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER` - an SDL_Capitalization value
|
||||||
|
* that describes how text should be capitalized, defaults to
|
||||||
|
* SDL_CAPITALIZE_SENTENCES for normal text entry, SDL_CAPITALIZE_WORDS for
|
||||||
|
* SDL_TEXTINPUT_TYPE_TEXT_NAME, and SDL_CAPITALIZE_NONE for e-mail
|
||||||
|
* addresses, usernames, and passwords.
|
||||||
|
* - `SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN` - true to enable auto completion
|
||||||
|
* and auto correction, defaults to true.
|
||||||
|
* - `SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN` - true if multiple lines of text
|
||||||
|
* are allowed. This defaults to true if SDL_HINT_RETURN_KEY_HIDES_IME is
|
||||||
|
* "0" or is not set, and defaults to false if SDL_HINT_RETURN_KEY_HIDES_IME
|
||||||
|
* is "1".
|
||||||
|
*
|
||||||
|
* On Android you can directly specify the input type:
|
||||||
|
*
|
||||||
|
* - `SDL_PROP_TEXTINPUT_ANDROID_INPUTTYPE_NUMBER` - the text input type to
|
||||||
|
* use, overriding other properties. This is documented at
|
||||||
|
* https://developer.android.com/reference/android/text/InputType
|
||||||
|
*
|
||||||
|
* \param window the window to enable text input.
|
||||||
|
* \param props the properties to use.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetTextInputArea
|
||||||
|
* \sa SDL_StartTextInput
|
||||||
|
* \sa SDL_StopTextInput
|
||||||
|
* \sa SDL_TextInputActive
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_StartTextInputWithProperties")] public static extern bool StartTextInputWithProperties(Window* window, PropertiesID props);
|
||||||
|
|
||||||
|
public const let PROP_TEXTINPUT_TYPE_NUMBER = "SDL.textinput.type";
|
||||||
|
public const let PROP_TEXTINPUT_CAPITALIZATION_NUMBER = "SDL.textinput.capitalization";
|
||||||
|
public const let PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN = "SDL.textinput.autocorrect";
|
||||||
|
public const let PROP_TEXTINPUT_MULTILINE_BOOLEAN = "SDL.textinput.multiline";
|
||||||
|
public const let PROP_TEXTINPUT_ANDROID_INPUTTYPE_NUMBER = "SDL.textinput.android.inputtype";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether or not Unicode text input events are enabled for a window.
|
||||||
|
*
|
||||||
|
* \param window the window to check.
|
||||||
|
* \returns true if text input events are enabled else false.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_StartTextInput
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_TextInputActive")] public static extern bool TextInputActive(Window* window);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop receiving any text input events in a window.
|
||||||
|
*
|
||||||
|
* If SDL_StartTextInput() showed the screen keyboard, this function will hide
|
||||||
|
* it.
|
||||||
|
*
|
||||||
|
* \param window the window to disable text input.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_StartTextInput
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_StopTextInput")] public static extern bool StopTextInput(Window* window);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dismiss the composition window/IME without disabling the subsystem.
|
||||||
|
*
|
||||||
|
* \param window the window to affect.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_StartTextInput
|
||||||
|
* \sa SDL_StopTextInput
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ClearComposition")] public static extern bool ClearComposition(Window* window);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the area used to type Unicode text input.
|
||||||
|
*
|
||||||
|
* Native input methods may place a window with word suggestions near the
|
||||||
|
* cursor, without covering the text being entered.
|
||||||
|
*
|
||||||
|
* \param window the window for which to set the text input area.
|
||||||
|
* \param rect the SDL_Rect representing the text input area, in window
|
||||||
|
* coordinates, or NULL to clear it.
|
||||||
|
* \param cursor the offset of the current cursor location relative to
|
||||||
|
* `rect->x`, in window coordinates.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetTextInputArea
|
||||||
|
* \sa SDL_StartTextInput
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetTextInputArea")] public static extern bool SetTextInputArea(Window* window, Rect* rect, c_int cursor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the area used to type Unicode text input.
|
||||||
|
*
|
||||||
|
* This returns the values previously set by SDL_SetTextInputArea().
|
||||||
|
*
|
||||||
|
* \param window the window for which to query the text input area.
|
||||||
|
* \param rect a pointer to an SDL_Rect filled in with the text input area,
|
||||||
|
* may be NULL.
|
||||||
|
* \param cursor a pointer to the offset of the current cursor location
|
||||||
|
* relative to `rect->x`, may be NULL.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetTextInputArea
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTextInputArea")] public static extern bool GetTextInputArea(Window* window, Rect* rect, c_int* cursor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the platform has screen keyboard support.
|
||||||
|
*
|
||||||
|
* \returns true if the platform has some screen keyboard support or false if
|
||||||
|
* not.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_StartTextInput
|
||||||
|
* \sa SDL_ScreenKeyboardShown
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasScreenKeyboardSupport")] public static extern bool HasScreenKeyboardSupport();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the screen keyboard is shown for given window.
|
||||||
|
*
|
||||||
|
* \param window the window for which screen keyboard should be queried.
|
||||||
|
* \returns true if screen keyboard is shown or false if not.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasScreenKeyboardSupport
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ScreenKeyboardShown")] public static extern bool ScreenKeyboardShown(Window* window);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_keyboard_h_ */
|
||||||
360
src/SDL_keycode.bf
Normal file
360
src/SDL_keycode.bf
Normal file
@@ -0,0 +1,360 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryKeycode
|
||||||
|
*
|
||||||
|
* Defines constants which identify keyboard keys and modifiers.
|
||||||
|
*
|
||||||
|
* Please refer to the Best Keyboard Practices document for details on what
|
||||||
|
* this information means and how best to use it.
|
||||||
|
*
|
||||||
|
* https://wiki.libsdl.org/SDL3/BestKeyboardPractices
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SDL virtual key representation.
|
||||||
|
*
|
||||||
|
* Values of this type are used to represent keyboard keys using the current
|
||||||
|
* layout of the keyboard. These values include Unicode values representing
|
||||||
|
* the unmodified character that would be generated by pressing the key, or an
|
||||||
|
* `SDLK_*` constant for those keys that do not generate characters.
|
||||||
|
*
|
||||||
|
* A special exception is the number keys at the top of the keyboard which map
|
||||||
|
* by default to SDLK_0...SDLK_9 on AZERTY layouts.
|
||||||
|
*
|
||||||
|
* Keys with the `SDLK_EXTENDED_MASK` bit set do not map to a scancode or
|
||||||
|
* Unicode code point.
|
||||||
|
*
|
||||||
|
* Many common keycodes are listed below, but this list is not exhaustive.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HINT_KEYCODE_OPTIONS
|
||||||
|
*/
|
||||||
|
public enum Keycode : Uint32
|
||||||
|
{
|
||||||
|
ExtendedMask = (1u << 29),
|
||||||
|
ScancodeMask = (1u << 30),
|
||||||
|
Unknown = 0x00000000u, /**< 0 */
|
||||||
|
Return = 0x0000000du, /**< '\r' */
|
||||||
|
Escape = 0x0000001bu, /**< '\x1B' */
|
||||||
|
Backspace = 0x00000008u, /**< '\b' */
|
||||||
|
Tab = 0x00000009u, /**< '\t' */
|
||||||
|
Space = 0x00000020u, /**< ' ' */
|
||||||
|
Exclaim = 0x00000021u, /**< '!' */
|
||||||
|
Dblapostrophe = 0x00000022u, /**< '"' */
|
||||||
|
Hash = 0x00000023u, /**< '#' */
|
||||||
|
Dollar = 0x00000024u, /**< '$' */
|
||||||
|
Percent = 0x00000025u, /**< '%' */
|
||||||
|
Ampersand = 0x00000026u, /**< '&' */
|
||||||
|
Apostrophe = 0x00000027u, /**< '\'' */
|
||||||
|
Leftparen = 0x00000028u, /**< '(' */
|
||||||
|
Rightparen = 0x00000029u, /**< ')' */
|
||||||
|
Asterisk = 0x0000002au, /**< '*' */
|
||||||
|
Plus = 0x0000002bu, /**< '+' */
|
||||||
|
Comma = 0x0000002cu, /**< ',' */
|
||||||
|
Minus = 0x0000002du, /**< '-' */
|
||||||
|
Period = 0x0000002eu, /**< '.' */
|
||||||
|
Slash = 0x0000002fu, /**< '/' */
|
||||||
|
_0 = 0x00000030u, /**< '0' */
|
||||||
|
_1 = 0x00000031u, /**< '1' */
|
||||||
|
_2 = 0x00000032u, /**< '2' */
|
||||||
|
_3 = 0x00000033u, /**< '3' */
|
||||||
|
_4 = 0x00000034u, /**< '4' */
|
||||||
|
_5 = 0x00000035u, /**< '5' */
|
||||||
|
_6 = 0x00000036u, /**< '6' */
|
||||||
|
_7 = 0x00000037u, /**< '7' */
|
||||||
|
_8 = 0x00000038u, /**< '8' */
|
||||||
|
_9 = 0x00000039u, /**< '9' */
|
||||||
|
Colon = 0x0000003au, /**< ':' */
|
||||||
|
Semicolon = 0x0000003bu, /**< ';' */
|
||||||
|
Less = 0x0000003cu, /**< '<' */
|
||||||
|
Equals = 0x0000003du, /**< '=' */
|
||||||
|
Greater = 0x0000003eu, /**< '>' */
|
||||||
|
Question = 0x0000003fu, /**< '?' */
|
||||||
|
At = 0x00000040u, /**< '@' */
|
||||||
|
Leftbracket = 0x0000005bu, /**< '[' */
|
||||||
|
Backslash = 0x0000005cu, /**< '\\' */
|
||||||
|
Rightbracket = 0x0000005du, /**< ']' */
|
||||||
|
Caret = 0x0000005eu, /**< '^' */
|
||||||
|
Underscore = 0x0000005fu, /**< '_' */
|
||||||
|
Grave = 0x00000060u, /**< '`' */
|
||||||
|
A = 0x00000061u, /**< 'a' */
|
||||||
|
B = 0x00000062u, /**< 'b' */
|
||||||
|
C = 0x00000063u, /**< 'c' */
|
||||||
|
D = 0x00000064u, /**< 'd' */
|
||||||
|
E = 0x00000065u, /**< 'e' */
|
||||||
|
F = 0x00000066u, /**< 'f' */
|
||||||
|
G = 0x00000067u, /**< 'g' */
|
||||||
|
H = 0x00000068u, /**< 'h' */
|
||||||
|
I = 0x00000069u, /**< 'i' */
|
||||||
|
J = 0x0000006au, /**< 'j' */
|
||||||
|
K = 0x0000006bu, /**< 'k' */
|
||||||
|
L = 0x0000006cu, /**< 'l' */
|
||||||
|
M = 0x0000006du, /**< 'm' */
|
||||||
|
N = 0x0000006eu, /**< 'n' */
|
||||||
|
O = 0x0000006fu, /**< 'o' */
|
||||||
|
P = 0x00000070u, /**< 'p' */
|
||||||
|
Q = 0x00000071u, /**< 'q' */
|
||||||
|
R = 0x00000072u, /**< 'r' */
|
||||||
|
S = 0x00000073u, /**< 's' */
|
||||||
|
T = 0x00000074u, /**< 't' */
|
||||||
|
U = 0x00000075u, /**< 'u' */
|
||||||
|
V = 0x00000076u, /**< 'v' */
|
||||||
|
W = 0x00000077u, /**< 'w' */
|
||||||
|
X = 0x00000078u, /**< 'x' */
|
||||||
|
Y = 0x00000079u, /**< 'y' */
|
||||||
|
Z = 0x0000007au, /**< 'z' */
|
||||||
|
Leftbrace = 0x0000007bu, /**< '{' */
|
||||||
|
Pipe = 0x0000007cu, /**< '|' */
|
||||||
|
Rightbrace = 0x0000007du, /**< '}' */
|
||||||
|
Tilde = 0x0000007eu, /**< '~' */
|
||||||
|
Delete = 0x0000007fu, /**< '\x7F' */
|
||||||
|
Plusminus = 0x000000b1u, /**< '\xB1' */
|
||||||
|
Capslock = 0x40000039u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CAPSLOCK) */
|
||||||
|
F1 = 0x4000003au, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F1) */
|
||||||
|
F2 = 0x4000003bu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F2) */
|
||||||
|
F3 = 0x4000003cu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F3) */
|
||||||
|
F4 = 0x4000003du, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F4) */
|
||||||
|
F5 = 0x4000003eu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F5) */
|
||||||
|
F6 = 0x4000003fu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F6) */
|
||||||
|
F7 = 0x40000040u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F7) */
|
||||||
|
F8 = 0x40000041u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F8) */
|
||||||
|
F9 = 0x40000042u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F9) */
|
||||||
|
F10 = 0x40000043u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F10) */
|
||||||
|
F11 = 0x40000044u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F11) */
|
||||||
|
F12 = 0x40000045u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F12) */
|
||||||
|
Printscreen = 0x40000046u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRINTSCREEN) */
|
||||||
|
Scrolllock = 0x40000047u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SCROLLLOCK) */
|
||||||
|
Pause = 0x40000048u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAUSE) */
|
||||||
|
Insert = 0x40000049u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INSERT) */
|
||||||
|
Home = 0x4000004au, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HOME) */
|
||||||
|
Pageup = 0x4000004bu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEUP) */
|
||||||
|
End = 0x4000004du, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_END) */
|
||||||
|
Pagedown = 0x4000004eu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEDOWN) */
|
||||||
|
Right = 0x4000004fu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RIGHT) */
|
||||||
|
Left = 0x40000050u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LEFT) */
|
||||||
|
Down = 0x40000051u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DOWN) */
|
||||||
|
Up = 0x40000052u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UP) */
|
||||||
|
Numlockclear = 0x40000053u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_NUMLOCKCLEAR) */
|
||||||
|
KpDivide = 0x40000054u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DIVIDE) */
|
||||||
|
KpMultiply = 0x40000055u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MULTIPLY) */
|
||||||
|
KpMinus = 0x40000056u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MINUS) */
|
||||||
|
KpPlus = 0x40000057u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUS) */
|
||||||
|
KpEnter = 0x40000058u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_ENTER) */
|
||||||
|
Kp1 = 0x40000059u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_1) */
|
||||||
|
Kp2 = 0x4000005au, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_2) */
|
||||||
|
Kp3 = 0x4000005bu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_3) */
|
||||||
|
Kp4 = 0x4000005cu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_4) */
|
||||||
|
Kp5 = 0x4000005du, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_5) */
|
||||||
|
Kp6 = 0x4000005eu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_6) */
|
||||||
|
Kp7 = 0x4000005fu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_7) */
|
||||||
|
Kp8 = 0x40000060u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_8) */
|
||||||
|
Kp9 = 0x40000061u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_9) */
|
||||||
|
Kp0 = 0x40000062u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_0) */
|
||||||
|
KpPeriod = 0x40000063u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERIOD) */
|
||||||
|
Application = 0x40000065u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APPLICATION) */
|
||||||
|
Power = 0x40000066u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_POWER) */
|
||||||
|
KpEquals = 0x40000067u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALS) */
|
||||||
|
F13 = 0x40000068u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F13) */
|
||||||
|
F14 = 0x40000069u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F14) */
|
||||||
|
F15 = 0x4000006au, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F15) */
|
||||||
|
F16 = 0x4000006bu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F16) */
|
||||||
|
F17 = 0x4000006cu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F17) */
|
||||||
|
F18 = 0x4000006du, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F18) */
|
||||||
|
F19 = 0x4000006eu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F19) */
|
||||||
|
F20 = 0x4000006fu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F20) */
|
||||||
|
F21 = 0x40000070u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F21) */
|
||||||
|
F22 = 0x40000071u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F22) */
|
||||||
|
F23 = 0x40000072u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F23) */
|
||||||
|
F24 = 0x40000073u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F24) */
|
||||||
|
Execute = 0x40000074u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXECUTE) */
|
||||||
|
Help = 0x40000075u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HELP) */
|
||||||
|
Menu = 0x40000076u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MENU) */
|
||||||
|
Select = 0x40000077u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SELECT) */
|
||||||
|
Stop = 0x40000078u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_STOP) */
|
||||||
|
Again = 0x40000079u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AGAIN) */
|
||||||
|
Undo = 0x4000007au, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UNDO) */
|
||||||
|
Cut = 0x4000007bu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CUT) */
|
||||||
|
Copy = 0x4000007cu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COPY) */
|
||||||
|
Paste = 0x4000007du, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PASTE) */
|
||||||
|
Find = 0x4000007eu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_FIND) */
|
||||||
|
Mute = 0x4000007fu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MUTE) */
|
||||||
|
Volumeup = 0x40000080u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEUP) */
|
||||||
|
Volumedown = 0x40000081u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEDOWN) */
|
||||||
|
KpComma = 0x40000085u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COMMA) */
|
||||||
|
KpEqualsas400 = 0x40000086u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALSAS400) */
|
||||||
|
Alterase = 0x40000099u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ALTERASE) */
|
||||||
|
Sysreq = 0x4000009au, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SYSREQ) */
|
||||||
|
Cancel = 0x4000009bu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CANCEL) */
|
||||||
|
Clear = 0x4000009cu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEAR) */
|
||||||
|
Prior = 0x4000009du, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRIOR) */
|
||||||
|
Return2 = 0x4000009eu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RETURN2) */
|
||||||
|
Separator = 0x4000009fu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SEPARATOR) */
|
||||||
|
Out = 0x400000a0u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OUT) */
|
||||||
|
Oper = 0x400000a1u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OPER) */
|
||||||
|
Clearagain = 0x400000a2u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEARAGAIN) */
|
||||||
|
Crsel = 0x400000a3u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CRSEL) */
|
||||||
|
Exsel = 0x400000a4u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXSEL) */
|
||||||
|
Kp00 = 0x400000b0u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_00) */
|
||||||
|
Kp000 = 0x400000b1u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_000) */
|
||||||
|
Thousandsseparator = 0x400000b2u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_THOUSANDSSEPARATOR) */
|
||||||
|
Decimalseparator = 0x400000b3u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DECIMALSEPARATOR) */
|
||||||
|
Currencyunit = 0x400000b4u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYUNIT) */
|
||||||
|
Currencysubunit = 0x400000b5u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYSUBUNIT) */
|
||||||
|
KpLeftparen = 0x400000b6u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTPAREN) */
|
||||||
|
KpRightparen = 0x400000b7u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTPAREN) */
|
||||||
|
KpLeftbrace = 0x400000b8u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTBRACE) */
|
||||||
|
KpRightbrace = 0x400000b9u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTBRACE) */
|
||||||
|
KpTab = 0x400000bau, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_TAB) */
|
||||||
|
KpBackspace = 0x400000bbu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BACKSPACE) */
|
||||||
|
KpA = 0x400000bcu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_A) */
|
||||||
|
KpB = 0x400000bdu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_B) */
|
||||||
|
KpC = 0x400000beu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_C) */
|
||||||
|
KpD = 0x400000bfu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_D) */
|
||||||
|
KpE = 0x400000c0u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_E) */
|
||||||
|
KpF = 0x400000c1u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_F) */
|
||||||
|
KpXor = 0x400000c2u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_XOR) */
|
||||||
|
KpPower = 0x400000c3u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_POWER) */
|
||||||
|
KpPercent = 0x400000c4u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERCENT) */
|
||||||
|
KpLess = 0x400000c5u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LESS) */
|
||||||
|
KpGreater = 0x400000c6u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_GREATER) */
|
||||||
|
KpAmpersand = 0x400000c7u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AMPERSAND) */
|
||||||
|
KpDblampersand = 0x400000c8u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLAMPERSAND) */
|
||||||
|
KpVerticalbar = 0x400000c9u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_VERTICALBAR) */
|
||||||
|
KpDblverticalbar = 0x400000cau, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLVERTICALBAR) */
|
||||||
|
KpColon = 0x400000cbu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COLON) */
|
||||||
|
KpHash = 0x400000ccu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HASH) */
|
||||||
|
KpSpace = 0x400000cdu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_SPACE) */
|
||||||
|
KpAt = 0x400000ceu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AT) */
|
||||||
|
KpExclam = 0x400000cfu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EXCLAM) */
|
||||||
|
KpMemstore = 0x400000d0u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSTORE) */
|
||||||
|
KpMemrecall = 0x400000d1u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMRECALL) */
|
||||||
|
KpMemclear = 0x400000d2u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMCLEAR) */
|
||||||
|
KpMemadd = 0x400000d3u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMADD) */
|
||||||
|
KpMemsubtract = 0x400000d4u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSUBTRACT) */
|
||||||
|
KpMemmultiply = 0x400000d5u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMMULTIPLY) */
|
||||||
|
KpMemdivide = 0x400000d6u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMDIVIDE) */
|
||||||
|
KpPlusminus = 0x400000d7u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUSMINUS) */
|
||||||
|
KpClear = 0x400000d8u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEAR) */
|
||||||
|
KpClearentry = 0x400000d9u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEARENTRY) */
|
||||||
|
KpBinary = 0x400000dau, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BINARY) */
|
||||||
|
KpOctal = 0x400000dbu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_OCTAL) */
|
||||||
|
KpDecimal = 0x400000dcu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DECIMAL) */
|
||||||
|
KpHexadecimal = 0x400000ddu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HEXADECIMAL) */
|
||||||
|
Lctrl = 0x400000e0u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LCTRL) */
|
||||||
|
Lshift = 0x400000e1u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LSHIFT) */
|
||||||
|
Lalt = 0x400000e2u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LALT) */
|
||||||
|
Lgui = 0x400000e3u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LGUI) */
|
||||||
|
Rctrl = 0x400000e4u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RCTRL) */
|
||||||
|
Rshift = 0x400000e5u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RSHIFT) */
|
||||||
|
Ralt = 0x400000e6u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RALT) */
|
||||||
|
Rgui = 0x400000e7u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RGUI) */
|
||||||
|
Mode = 0x40000101u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MODE) */
|
||||||
|
Sleep = 0x40000102u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP) */
|
||||||
|
Wake = 0x40000103u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_WAKE) */
|
||||||
|
ChannelIncrement = 0x40000104u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CHANNEL_INCREMENT) */
|
||||||
|
ChannelDecrement = 0x40000105u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CHANNEL_DECREMENT) */
|
||||||
|
MediaPlay = 0x40000106u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_PLAY) */
|
||||||
|
MediaPause = 0x40000107u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_PAUSE) */
|
||||||
|
MediaRecord = 0x40000108u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_RECORD) */
|
||||||
|
MediaFastForward = 0x40000109u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_FAST_FORWARD) */
|
||||||
|
MediaRewind = 0x4000010au, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_REWIND) */
|
||||||
|
MediaNextTrack = 0x4000010bu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_NEXT_TRACK) */
|
||||||
|
MediaPreviousTrack = 0x4000010cu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_PREVIOUS_TRACK) */
|
||||||
|
MediaStop = 0x4000010du, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_STOP) */
|
||||||
|
MediaEject = 0x4000010eu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_EJECT) */
|
||||||
|
MediaPlayPause = 0x4000010fu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_PLAY_PAUSE) */
|
||||||
|
MediaSelect = 0x40000110u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIA_SELECT) */
|
||||||
|
AcNew = 0x40000111u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_NEW) */
|
||||||
|
AcOpen = 0x40000112u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_OPEN) */
|
||||||
|
AcClose = 0x40000113u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_CLOSE) */
|
||||||
|
AcExit = 0x40000114u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_EXIT) */
|
||||||
|
AcSave = 0x40000115u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_SAVE) */
|
||||||
|
AcPrint = 0x40000116u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_PRINT) */
|
||||||
|
AcProperties = 0x40000117u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_PROPERTIES) */
|
||||||
|
AcSearch = 0x40000118u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_SEARCH) */
|
||||||
|
AcHome = 0x40000119u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_HOME) */
|
||||||
|
AcBack = 0x4000011au, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BACK) */
|
||||||
|
AcForward = 0x4000011bu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_FORWARD) */
|
||||||
|
AcStop = 0x4000011cu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_STOP) */
|
||||||
|
AcRefresh = 0x4000011du, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_REFRESH) */
|
||||||
|
AcBookmarks = 0x4000011eu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BOOKMARKS) */
|
||||||
|
Softleft = 0x4000011fu, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SOFTLEFT) */
|
||||||
|
Softright = 0x40000120u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SOFTRIGHT) */
|
||||||
|
Call = 0x40000121u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CALL) */
|
||||||
|
Endcall = 0x40000122u, /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ENDCALL) */
|
||||||
|
LeftTab = 0x20000001u, /**< Extended key Left Tab */
|
||||||
|
Level5Shift = 0x20000002u, /**< Extended key Level 5 Shift */
|
||||||
|
MultiKeyCompose = 0x20000003u, /**< Extended key Multi-key Compose */
|
||||||
|
Lmeta = 0x20000004u, /**< Extended key Left Meta */
|
||||||
|
Rmeta = 0x20000005u, /**< Extended key Right Meta */
|
||||||
|
Lhyper = 0x20000006u, /**< Extended key Left Hyper */
|
||||||
|
Rhyper = 0x20000007u, /**< Extended key Right Hyper */
|
||||||
|
} /**< Extended key Right Hyper */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valid key modifiers (possibly OR'd together).
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public typealias Keymod = Uint16;
|
||||||
|
|
||||||
|
public const let KMOD_NONE = 0x0000u;/**< no modifier is applicable. */
|
||||||
|
public const let KMOD_LSHIFT = 0x0001u;/**< the left Shift key is down. */
|
||||||
|
public const let KMOD_RSHIFT = 0x0002u;/**< the right Shift key is down. */
|
||||||
|
public const let KMOD_LEVEL5 = 0x0004u;/**< the Level 5 Shift key is down. */
|
||||||
|
public const let KMOD_LCTRL = 0x0040u;/**< the left Ctrl (Control) key is down. */
|
||||||
|
public const let KMOD_RCTRL = 0x0080u;/**< the right Ctrl (Control) key is down. */
|
||||||
|
public const let KMOD_LALT = 0x0100u;/**< the left Alt key is down. */
|
||||||
|
public const let KMOD_RALT = 0x0200u;/**< the right Alt key is down. */
|
||||||
|
public const let KMOD_LGUI = 0x0400u;/**< the left GUI key (often the Windows key) is down. */
|
||||||
|
public const let KMOD_RGUI = 0x0800u;/**< the right GUI key (often the Windows key) is down. */
|
||||||
|
public const let KMOD_NUM = 0x1000u;/**< the Num Lock key (may be located on an extended keypad) is down. */
|
||||||
|
public const let KMOD_CAPS = 0x2000u;/**< the Caps Lock key is down. */
|
||||||
|
public const let KMOD_MODE = 0x4000u;/**< the !AltGr key is down. */
|
||||||
|
public const let KMOD_SCROLL = 0x8000u;/**< the Scroll Lock key is down. */
|
||||||
|
public const let KMOD_CTRL = (KMOD_LCTRL | KMOD_RCTRL);/**< Any Ctrl key is down. */
|
||||||
|
public const let KMOD_SHIFT = (KMOD_LSHIFT | KMOD_RSHIFT);/**< Any Shift key is down. */
|
||||||
|
public const let KMOD_ALT = (KMOD_LALT | KMOD_RALT);/**< Any Alt key is down. */
|
||||||
|
public const let KMOD_GUI = (KMOD_LGUI | KMOD_RGUI);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**< Any GUI key is down. */
|
||||||
|
|
||||||
|
/* SDL_keycode_h_ */
|
||||||
156
src/SDL_loadso.bf
Normal file
156
src/SDL_loadso.bf
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* WIKI CATEGORY: SharedObject */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategorySharedObject
|
||||||
|
*
|
||||||
|
* System-dependent library loading routines.
|
||||||
|
*
|
||||||
|
* Shared objects are code that is programmatically loadable at runtime.
|
||||||
|
* Windows calls these "DLLs", Linux calls them "shared libraries", etc.
|
||||||
|
*
|
||||||
|
* To use them, build such a library, then call SDL_LoadObject() on it. Once
|
||||||
|
* loaded, you can use SDL_LoadFunction() on that object to find the address
|
||||||
|
* of its exported symbols. When done with the object, call SDL_UnloadObject()
|
||||||
|
* to dispose of it.
|
||||||
|
*
|
||||||
|
* Some things to keep in mind:
|
||||||
|
*
|
||||||
|
* - These functions only work on C function names. Other languages may have
|
||||||
|
* name mangling and intrinsic language support that varies from compiler to
|
||||||
|
* compiler.
|
||||||
|
* - Make sure you declare your function pointers with the same calling
|
||||||
|
* convention as the actual library function. Your code will crash
|
||||||
|
* mysteriously if you do not do this.
|
||||||
|
* - Avoid namespace collisions. If you load a symbol from the library, it is
|
||||||
|
* not defined whether or not it goes into the global symbol namespace for
|
||||||
|
* the application. If it does and it conflicts with symbols in your code or
|
||||||
|
* other shared libraries, you will not get the results you expect. :)
|
||||||
|
* - Once a library is unloaded, all pointers into it obtained through
|
||||||
|
* SDL_LoadFunction() become invalid, even if the library is later reloaded.
|
||||||
|
* Don't unload a library if you plan to use these pointers in the future.
|
||||||
|
* Notably: beware of giving one of these pointers to atexit(), since it may
|
||||||
|
* call that pointer after the library unloads.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An opaque datatype that represents a loaded shared object.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_LoadObject
|
||||||
|
* \sa SDL_LoadFunction
|
||||||
|
* \sa SDL_UnloadObject
|
||||||
|
*/
|
||||||
|
[CRepr] public struct SharedObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamically load a shared object.
|
||||||
|
*
|
||||||
|
* \param sofile a system-dependent name of the object file.
|
||||||
|
* \returns an opaque pointer to the object handle or NULL on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_LoadFunction
|
||||||
|
* \sa SDL_UnloadObject
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_LoadObject")] public static extern SharedObject* LoadObject(c_char* sofile);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look up the address of the named function in a shared object.
|
||||||
|
*
|
||||||
|
* This function pointer is no longer valid after calling SDL_UnloadObject().
|
||||||
|
*
|
||||||
|
* This function can only look up C function names. Other languages may have
|
||||||
|
* name mangling and intrinsic language support that varies from compiler to
|
||||||
|
* compiler.
|
||||||
|
*
|
||||||
|
* Make sure you declare your function pointers with the same calling
|
||||||
|
* convention as the actual library function. Your code will crash
|
||||||
|
* mysteriously if you do not do this.
|
||||||
|
*
|
||||||
|
* If the requested function doesn't exist, NULL is returned.
|
||||||
|
*
|
||||||
|
* \param handle a valid shared object handle returned by SDL_LoadObject().
|
||||||
|
* \param name the name of the function to look up.
|
||||||
|
* \returns a pointer to the function or NULL on failure; call SDL_GetError()
|
||||||
|
* for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_LoadObject
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_LoadFunction")] public static extern FunctionPointer LoadFunction(SharedObject* handle, c_char* name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unload a shared object from memory.
|
||||||
|
*
|
||||||
|
* Note that any pointers from this object looked up through
|
||||||
|
* SDL_LoadFunction() will no longer be valid.
|
||||||
|
*
|
||||||
|
* \param handle a valid shared object handle returned by SDL_LoadObject().
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_LoadObject
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_UnloadObject")] public static extern void UnloadObject(SharedObject* handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_loadso_h_ */
|
||||||
128
src/SDL_locale.bf
Normal file
128
src/SDL_locale.bf
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryLocale
|
||||||
|
*
|
||||||
|
* SDL locale services.
|
||||||
|
*
|
||||||
|
* This provides a way to get a list of preferred locales (language plus
|
||||||
|
* country) for the user. There is exactly one function:
|
||||||
|
* SDL_GetPreferredLocales(), which handles all the heavy lifting, and offers
|
||||||
|
* documentation on all the strange ways humans might have configured their
|
||||||
|
* language settings.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
/* *INDENT-OFF* */
|
||||||
|
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A struct to provide locale data.
|
||||||
|
*
|
||||||
|
* Locale data is split into a spoken language, like English, and an optional
|
||||||
|
* country, like Canada. The language will be in ISO-639 format (so English
|
||||||
|
* would be "en"), and the country, if not NULL, will be an ISO-3166 country
|
||||||
|
* code (so Canada would be "CA").
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetPreferredLocales
|
||||||
|
*/
|
||||||
|
[CRepr] public struct Locale
|
||||||
|
{
|
||||||
|
public c_char* language; /**< A language name, like "en" for English. */
|
||||||
|
public c_char* country; /**< A country, like "US" for America. Can be NULL. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report the user's preferred locale.
|
||||||
|
*
|
||||||
|
* Returned language strings are in the format xx, where 'xx' is an ISO-639
|
||||||
|
* language specifier (such as "en" for English, "de" for German, etc).
|
||||||
|
* Country strings are in the format YY, where "YY" is an ISO-3166 country
|
||||||
|
* code (such as "US" for the United States, "CA" for Canada, etc). Country
|
||||||
|
* might be NULL if there's no specific guidance on them (so you might get {
|
||||||
|
* "en", "US" } for American English, but { "en", NULL } means "English
|
||||||
|
* language, generically"). Language strings are never NULL, except to
|
||||||
|
* terminate the array.
|
||||||
|
*
|
||||||
|
* Please note that not all of these strings are 2 characters; some are three
|
||||||
|
* or more.
|
||||||
|
*
|
||||||
|
* The returned list of locales are in the order of the user's preference. For
|
||||||
|
* example, a German citizen that is fluent in US English and knows enough
|
||||||
|
* Japanese to navigate around Tokyo might have a list like: { "de", "en_US",
|
||||||
|
* "jp", NULL }. Someone from England might prefer British English (where
|
||||||
|
* "color" is spelled "colour", etc), but will settle for anything like it: {
|
||||||
|
* "en_GB", "en", NULL }.
|
||||||
|
*
|
||||||
|
* This function returns NULL on error, including when the platform does not
|
||||||
|
* supply this information at all.
|
||||||
|
*
|
||||||
|
* This might be a "slow" call that has to query the operating system. It's
|
||||||
|
* best to ask for this once and save the results. However, this list can
|
||||||
|
* change, usually because the user has changed a system preference outside of
|
||||||
|
* your program; SDL will send an SDL_EVENT_LOCALE_CHANGED event in this case,
|
||||||
|
* if possible, and you can call this function again to get an updated copy of
|
||||||
|
* preferred locales.
|
||||||
|
*
|
||||||
|
* \param count a pointer filled in with the number of locales returned, may
|
||||||
|
* be NULL.
|
||||||
|
* \returns a NULL terminated array of locale pointers, or NULL on failure;
|
||||||
|
* call SDL_GetError() for more information. This is a single
|
||||||
|
* allocation that should be freed with SDL_free() when it is no
|
||||||
|
* longer needed.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetPreferredLocales")] public static extern Locale** GetPreferredLocales(out c_int count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
/* *INDENT-OFF* */
|
||||||
|
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_locale_h */
|
||||||
546
src/SDL_log.bf
Normal file
546
src/SDL_log.bf
Normal file
@@ -0,0 +1,546 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryLog
|
||||||
|
*
|
||||||
|
* Simple log messages with priorities and categories. A message's
|
||||||
|
* SDL_LogPriority signifies how important the message is. A message's
|
||||||
|
* SDL_LogCategory signifies from what domain it belongs to. Every category
|
||||||
|
* has a minimum priority specified: when a message belongs to that category,
|
||||||
|
* it will only be sent out if it has that minimum priority or higher.
|
||||||
|
*
|
||||||
|
* SDL's own logs are sent below the default priority threshold, so they are
|
||||||
|
* quiet by default.
|
||||||
|
*
|
||||||
|
* You can change the log verbosity programmatically using
|
||||||
|
* SDL_SetLogPriority() or with SDL_SetHint(SDL_HINT_LOGGING, ...), or with
|
||||||
|
* the "SDL_LOGGING" environment variable. This variable is a comma separated
|
||||||
|
* set of category=level tokens that define the default logging levels for SDL
|
||||||
|
* applications.
|
||||||
|
*
|
||||||
|
* The category can be a numeric category, one of "app", "error", "assert",
|
||||||
|
* "system", "audio", "video", "render", "input", "test", or `*` for any
|
||||||
|
* unspecified category.
|
||||||
|
*
|
||||||
|
* The level can be a numeric level, one of "trace", "verbose", "debug",
|
||||||
|
* "info", "warn", "error", "critical", or "quiet" to disable that category.
|
||||||
|
*
|
||||||
|
* You can omit the category if you want to set the logging level for all
|
||||||
|
* categories.
|
||||||
|
*
|
||||||
|
* If this hint isn't set, the default log levels are equivalent to:
|
||||||
|
*
|
||||||
|
* `app=info,assert=warn,test=verbose,*=error`
|
||||||
|
*
|
||||||
|
* Here's where the messages go on different platforms:
|
||||||
|
*
|
||||||
|
* - Windows: debug output stream
|
||||||
|
* - Android: log output
|
||||||
|
* - Others: standard error output (stderr)
|
||||||
|
*
|
||||||
|
* You don't need to have a newline (`\n`) on the end of messages, the
|
||||||
|
* functions will do that for you. For consistent behavior cross-platform, you
|
||||||
|
* shouldn't have any newlines in messages, such as to log multiple lines in
|
||||||
|
* one call; unusual platform-specific behavior can be observed in such usage.
|
||||||
|
* Do one log call per line instead, with no newlines in messages.
|
||||||
|
*
|
||||||
|
* Each log call is atomic, so you won't see log messages cut off one another
|
||||||
|
* when logging from multiple threads.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The predefined log categories
|
||||||
|
*
|
||||||
|
* By default the application and gpu categories are enabled at the INFO
|
||||||
|
* level, the assert category is enabled at the WARN level, test is enabled at
|
||||||
|
* the VERBOSE level and all other categories are enabled at the ERROR level.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum LogCategory : c_int
|
||||||
|
{
|
||||||
|
Application,
|
||||||
|
Error,
|
||||||
|
Assert,
|
||||||
|
System,
|
||||||
|
Audio,
|
||||||
|
Video,
|
||||||
|
Render,
|
||||||
|
Input,
|
||||||
|
Test,
|
||||||
|
Gpu,
|
||||||
|
|
||||||
|
/* Reserved for future SDL library use */
|
||||||
|
Reserved2,
|
||||||
|
Reserved3,
|
||||||
|
Reserved4,
|
||||||
|
Reserved5,
|
||||||
|
Reserved6,
|
||||||
|
Reserved7,
|
||||||
|
Reserved8,
|
||||||
|
Reserved9,
|
||||||
|
Reserved10,
|
||||||
|
|
||||||
|
/* Beyond this point is reserved for application use, e.g.
|
||||||
|
enum {
|
||||||
|
MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM,
|
||||||
|
MYAPP_CATEGORY_AWESOME2,
|
||||||
|
MYAPP_CATEGORY_AWESOME3,
|
||||||
|
...
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
Custom,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The predefined log priorities
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum LogPriority : c_int
|
||||||
|
{
|
||||||
|
Invalid,
|
||||||
|
Trace,
|
||||||
|
Verbose,
|
||||||
|
Debug,
|
||||||
|
Info,
|
||||||
|
Warn,
|
||||||
|
Error,
|
||||||
|
Critical,
|
||||||
|
Count,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the priority of all log categories.
|
||||||
|
*
|
||||||
|
* \param priority the SDL_LogPriority to assign.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ResetLogPriorities
|
||||||
|
* \sa SDL_SetLogPriority
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetLogPriorities")] public static extern void SetLogPriorities(LogPriority priority);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the priority of a particular log category.
|
||||||
|
*
|
||||||
|
* \param category the category to assign a priority to.
|
||||||
|
* \param priority the SDL_LogPriority to assign.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetLogPriority
|
||||||
|
* \sa SDL_ResetLogPriorities
|
||||||
|
* \sa SDL_SetLogPriorities
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetLogPriority")] public static extern void SetLogPriority(c_int category, LogPriority priority);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the priority of a particular log category.
|
||||||
|
*
|
||||||
|
* \param category the category to query.
|
||||||
|
* \returns the SDL_LogPriority for the requested category.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetLogPriority
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetLogPriority")] public static extern LogPriority GetLogPriority(c_int category);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset all priorities to default.
|
||||||
|
*
|
||||||
|
* This is called by SDL_Quit().
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetLogPriorities
|
||||||
|
* \sa SDL_SetLogPriority
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ResetLogPriorities")] public static extern void ResetLogPriorities();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the text prepended to log messages of a given priority.
|
||||||
|
*
|
||||||
|
* By default SDL_LOG_PRIORITY_INFO and below have no prefix, and
|
||||||
|
* SDL_LOG_PRIORITY_WARN and higher have a prefix showing their priority, e.g.
|
||||||
|
* "WARNING: ".
|
||||||
|
*
|
||||||
|
* This function makes a copy of its string argument, **prefix**, so it is not
|
||||||
|
* necessary to keep the value of **prefix** alive after the call returns.
|
||||||
|
*
|
||||||
|
* \param priority the SDL_LogPriority to modify.
|
||||||
|
* \param prefix the prefix to use for that log priority, or NULL to use no
|
||||||
|
* prefix.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetLogPriorities
|
||||||
|
* \sa SDL_SetLogPriority
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetLogPriorityPrefix")] public static extern bool SetLogPriorityPrefix(LogPriority priority, c_char* prefix);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.
|
||||||
|
*
|
||||||
|
* \param fmt a printf() style message format string.
|
||||||
|
* \param ... additional parameters matching % tokens in the `fmt` string, if
|
||||||
|
* any.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_LogCritical
|
||||||
|
* \sa SDL_LogDebug
|
||||||
|
* \sa SDL_LogError
|
||||||
|
* \sa SDL_LogInfo
|
||||||
|
* \sa SDL_LogMessage
|
||||||
|
* \sa SDL_LogMessageV
|
||||||
|
* \sa SDL_LogTrace
|
||||||
|
* \sa SDL_LogVerbose
|
||||||
|
* \sa SDL_LogWarn
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_Log")] public static extern void Log(c_char* fmt, ...);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with SDL_LOG_PRIORITY_TRACE.
|
||||||
|
*
|
||||||
|
* \param category the category of the message.
|
||||||
|
* \param fmt a printf() style message format string.
|
||||||
|
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||||
|
* if any.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Log
|
||||||
|
* \sa SDL_LogCritical
|
||||||
|
* \sa SDL_LogDebug
|
||||||
|
* \sa SDL_LogError
|
||||||
|
* \sa SDL_LogInfo
|
||||||
|
* \sa SDL_LogMessage
|
||||||
|
* \sa SDL_LogMessageV
|
||||||
|
* \sa SDL_LogVerbose
|
||||||
|
* \sa SDL_LogWarn
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_LogTrace")] public static extern void LogTrace(c_int category, c_char* fmt, ...);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with SDL_LOG_PRIORITY_VERBOSE.
|
||||||
|
*
|
||||||
|
* \param category the category of the message.
|
||||||
|
* \param fmt a printf() style message format string.
|
||||||
|
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||||
|
* if any.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Log
|
||||||
|
* \sa SDL_LogCritical
|
||||||
|
* \sa SDL_LogDebug
|
||||||
|
* \sa SDL_LogError
|
||||||
|
* \sa SDL_LogInfo
|
||||||
|
* \sa SDL_LogMessage
|
||||||
|
* \sa SDL_LogMessageV
|
||||||
|
* \sa SDL_LogWarn
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_LogVerbose")] public static extern void LogVerbose(c_int category, c_char* fmt, ...);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with SDL_LOG_PRIORITY_DEBUG.
|
||||||
|
*
|
||||||
|
* \param category the category of the message.
|
||||||
|
* \param fmt a printf() style message format string.
|
||||||
|
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||||
|
* if any.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Log
|
||||||
|
* \sa SDL_LogCritical
|
||||||
|
* \sa SDL_LogError
|
||||||
|
* \sa SDL_LogInfo
|
||||||
|
* \sa SDL_LogMessage
|
||||||
|
* \sa SDL_LogMessageV
|
||||||
|
* \sa SDL_LogTrace
|
||||||
|
* \sa SDL_LogVerbose
|
||||||
|
* \sa SDL_LogWarn
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_LogDebug")] public static extern void LogDebug(c_int category, c_char* fmt, ...);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with SDL_LOG_PRIORITY_INFO.
|
||||||
|
*
|
||||||
|
* \param category the category of the message.
|
||||||
|
* \param fmt a printf() style message format string.
|
||||||
|
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||||
|
* if any.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Log
|
||||||
|
* \sa SDL_LogCritical
|
||||||
|
* \sa SDL_LogDebug
|
||||||
|
* \sa SDL_LogError
|
||||||
|
* \sa SDL_LogMessage
|
||||||
|
* \sa SDL_LogMessageV
|
||||||
|
* \sa SDL_LogTrace
|
||||||
|
* \sa SDL_LogVerbose
|
||||||
|
* \sa SDL_LogWarn
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_LogInfo")] public static extern void LogInfo(c_int category, c_char* fmt, ...);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with SDL_LOG_PRIORITY_WARN.
|
||||||
|
*
|
||||||
|
* \param category the category of the message.
|
||||||
|
* \param fmt a printf() style message format string.
|
||||||
|
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||||
|
* if any.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Log
|
||||||
|
* \sa SDL_LogCritical
|
||||||
|
* \sa SDL_LogDebug
|
||||||
|
* \sa SDL_LogError
|
||||||
|
* \sa SDL_LogInfo
|
||||||
|
* \sa SDL_LogMessage
|
||||||
|
* \sa SDL_LogMessageV
|
||||||
|
* \sa SDL_LogTrace
|
||||||
|
* \sa SDL_LogVerbose
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_LogWarn")] public static extern void LogWarn(c_int category, c_char* fmt, ...);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with SDL_LOG_PRIORITY_ERROR.
|
||||||
|
*
|
||||||
|
* \param category the category of the message.
|
||||||
|
* \param fmt a printf() style message format string.
|
||||||
|
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||||
|
* if any.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Log
|
||||||
|
* \sa SDL_LogCritical
|
||||||
|
* \sa SDL_LogDebug
|
||||||
|
* \sa SDL_LogInfo
|
||||||
|
* \sa SDL_LogMessage
|
||||||
|
* \sa SDL_LogMessageV
|
||||||
|
* \sa SDL_LogTrace
|
||||||
|
* \sa SDL_LogVerbose
|
||||||
|
* \sa SDL_LogWarn
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_LogError")] public static extern void LogError(c_int category, c_char* fmt, ...);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with SDL_LOG_PRIORITY_CRITICAL.
|
||||||
|
*
|
||||||
|
* \param category the category of the message.
|
||||||
|
* \param fmt a printf() style message format string.
|
||||||
|
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||||
|
* if any.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Log
|
||||||
|
* \sa SDL_LogDebug
|
||||||
|
* \sa SDL_LogError
|
||||||
|
* \sa SDL_LogInfo
|
||||||
|
* \sa SDL_LogMessage
|
||||||
|
* \sa SDL_LogMessageV
|
||||||
|
* \sa SDL_LogTrace
|
||||||
|
* \sa SDL_LogVerbose
|
||||||
|
* \sa SDL_LogWarn
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_LogCritical")] public static extern void LogCritical(c_int category, c_char* fmt, ...);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with the specified category and priority.
|
||||||
|
*
|
||||||
|
* \param category the category of the message.
|
||||||
|
* \param priority the priority of the message.
|
||||||
|
* \param fmt a printf() style message format string.
|
||||||
|
* \param ... additional parameters matching % tokens in the **fmt** string,
|
||||||
|
* if any.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Log
|
||||||
|
* \sa SDL_LogCritical
|
||||||
|
* \sa SDL_LogDebug
|
||||||
|
* \sa SDL_LogError
|
||||||
|
* \sa SDL_LogInfo
|
||||||
|
* \sa SDL_LogMessageV
|
||||||
|
* \sa SDL_LogTrace
|
||||||
|
* \sa SDL_LogVerbose
|
||||||
|
* \sa SDL_LogWarn
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_LogMessage")] public static extern void LogMessage(c_int category, LogPriority priority, c_char* fmt, ...);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with the specified category and priority.
|
||||||
|
*
|
||||||
|
* \param category the category of the message.
|
||||||
|
* \param priority the priority of the message.
|
||||||
|
* \param fmt a printf() style message format string.
|
||||||
|
* \param ap a variable argument list.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Log
|
||||||
|
* \sa SDL_LogCritical
|
||||||
|
* \sa SDL_LogDebug
|
||||||
|
* \sa SDL_LogError
|
||||||
|
* \sa SDL_LogInfo
|
||||||
|
* \sa SDL_LogMessage
|
||||||
|
* \sa SDL_LogTrace
|
||||||
|
* \sa SDL_LogVerbose
|
||||||
|
* \sa SDL_LogWarn
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_LogMessageV")] public static extern void LogMessageV(c_int category, LogPriority priority, c_char* fmt, VarArgs ap);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The prototype for the log output callback function.
|
||||||
|
*
|
||||||
|
* This function is called by SDL when there is new text to be logged. A mutex
|
||||||
|
* is held so that this function is never called by more than one thread at
|
||||||
|
* once.
|
||||||
|
*
|
||||||
|
* \param userdata what was passed as `userdata` to
|
||||||
|
* SDL_SetLogOutputFunction().
|
||||||
|
* \param category the category of the message.
|
||||||
|
* \param priority the priority of the message.
|
||||||
|
* \param message the message being output.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public function void LogOutputFunction(void* userdata, c_int category, LogPriority priority, c_char* message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default log output function.
|
||||||
|
*
|
||||||
|
* \returns the default log output callback.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetLogOutputFunction
|
||||||
|
* \sa SDL_GetLogOutputFunction
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetDefaultLogOutputFunction")] public static extern LogOutputFunction GetDefaultLogOutputFunction();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current log output function.
|
||||||
|
*
|
||||||
|
* \param callback an SDL_LogOutputFunction filled in with the current log
|
||||||
|
* callback.
|
||||||
|
* \param userdata a pointer filled in with the pointer that is passed to
|
||||||
|
* `callback`.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetDefaultLogOutputFunction
|
||||||
|
* \sa SDL_SetLogOutputFunction
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetLogOutputFunction")] public static extern void GetLogOutputFunction(LogOutputFunction* callback, out void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace the default log output function with one of your own.
|
||||||
|
*
|
||||||
|
* \param callback an SDL_LogOutputFunction to call instead of the default.
|
||||||
|
* \param userdata a pointer that is passed to `callback`.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetDefaultLogOutputFunction
|
||||||
|
* \sa SDL_GetLogOutputFunction
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetLogOutputFunction")] public static extern void SetLogOutputFunction(LogOutputFunction callback, void* userdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_log_h_ */
|
||||||
683
src/SDL_main.bf
Normal file
683
src/SDL_main.bf
Normal file
@@ -0,0 +1,683 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryMain
|
||||||
|
*
|
||||||
|
* Redefine main() if necessary so that it is called by SDL.
|
||||||
|
*
|
||||||
|
* In order to make this consistent on all platforms, the application's main()
|
||||||
|
* should look like this:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* #include <SDL3/SDL.h>
|
||||||
|
* #include <SDL3/SDL_main.h>
|
||||||
|
*
|
||||||
|
* int main(int argc, char *argv[])
|
||||||
|
* {
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* SDL will take care of platform specific details on how it gets called.
|
||||||
|
*
|
||||||
|
* This is also where an app can be configured to use the main callbacks, via
|
||||||
|
* the SDL_MAIN_USE_CALLBACKS macro.
|
||||||
|
*
|
||||||
|
* SDL_main.h is a "single-header library," which is to say that including
|
||||||
|
* this header inserts code into your program, and you should only include it
|
||||||
|
* once in most cases. SDL.h does not include this header automatically.
|
||||||
|
*
|
||||||
|
* For more information, see:
|
||||||
|
*
|
||||||
|
* https://wiki.libsdl.org/SDL3/README-main-functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inform SDL that the app is providing an entry point instead of SDL.
|
||||||
|
*
|
||||||
|
* SDL does not define this macro, but will check if it is defined when
|
||||||
|
* including `SDL_main.h`. If defined, SDL will expect the app to provide the
|
||||||
|
* proper entry point for the platform, and all the other magic details
|
||||||
|
* needed, like manually calling SDL_SetMainReady.
|
||||||
|
*
|
||||||
|
* Please see [README-main-functions](README-main-functions), (or
|
||||||
|
* docs/README-main-functions.md in the source tree) for a more detailed
|
||||||
|
* explanation.
|
||||||
|
*
|
||||||
|
* \since This macro is used by the headers since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inform SDL to use the main callbacks instead of main.
|
||||||
|
*
|
||||||
|
* SDL does not define this macro, but will check if it is defined when
|
||||||
|
* including `SDL_main.h`. If defined, SDL will expect the app to provide
|
||||||
|
* several functions: SDL_AppInit, SDL_AppEvent, SDL_AppIterate, and
|
||||||
|
* SDL_AppQuit. The app should not provide a `main` function in this case, and
|
||||||
|
* doing so will likely cause the build to fail.
|
||||||
|
*
|
||||||
|
* Please see [README-main-functions](README-main-functions), (or
|
||||||
|
* docs/README-main-functions.md in the source tree) for a more detailed
|
||||||
|
* explanation.
|
||||||
|
*
|
||||||
|
* \since This macro is used by the headers since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AppInit
|
||||||
|
* \sa SDL_AppEvent
|
||||||
|
* \sa SDL_AppIterate
|
||||||
|
* \sa SDL_AppQuit
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defined if the target platform offers a special mainline through SDL.
|
||||||
|
*
|
||||||
|
* This won't be defined otherwise. If defined, SDL's headers will redefine
|
||||||
|
* `main` to `SDL_main`.
|
||||||
|
*
|
||||||
|
* This macro is defined by `SDL_main.h`, which is not automatically included
|
||||||
|
* by `SDL.h`.
|
||||||
|
*
|
||||||
|
* Even if available, an app can define SDL_MAIN_HANDLED and provide their
|
||||||
|
* own, if they know what they're doing.
|
||||||
|
*
|
||||||
|
* This macro is used internally by SDL, and apps probably shouldn't rely on
|
||||||
|
* it.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defined if the target platform _requires_ a special mainline through SDL.
|
||||||
|
*
|
||||||
|
* This won't be defined otherwise. If defined, SDL's headers will redefine
|
||||||
|
* `main` to `SDL_main`.
|
||||||
|
*
|
||||||
|
* This macro is defined by `SDL_main.h`, which is not automatically included
|
||||||
|
* by `SDL.h`.
|
||||||
|
*
|
||||||
|
* Even if required, an app can define SDL_MAIN_HANDLED and provide their own,
|
||||||
|
* if they know what they're doing.
|
||||||
|
*
|
||||||
|
* This macro is used internally by SDL, and apps probably shouldn't rely on
|
||||||
|
* it.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Private platforms may have their own ideas about entry points. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* On Windows SDL provides WinMain(), which parses the command line and passes
|
||||||
|
the arguments to your main function.
|
||||||
|
|
||||||
|
If you provide your own WinMain(), you may define SDL_MAIN_HANDLED
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* On GDK, SDL provides a main function that initializes the game runtime.
|
||||||
|
|
||||||
|
If you prefer to write your own WinMain-function instead of having SDL
|
||||||
|
provide one that calls your main() function,
|
||||||
|
#define SDL_MAIN_HANDLED before #include'ing SDL_main.h
|
||||||
|
and call the SDL_RunApp function from your entry point.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* On iOS and tvOS SDL provides a main function that creates an application delegate and starts the application run loop.
|
||||||
|
|
||||||
|
To use it, just #include <SDL3/SDL_main.h> in the source file that contains your main() function.
|
||||||
|
|
||||||
|
See src/video/uikit/SDL_uikitappdelegate.m for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* On Android SDL provides a Java class in SDLActivity.java that is the
|
||||||
|
main activity entry point.
|
||||||
|
|
||||||
|
See docs/README-android.md for more details on extending that class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* As this is launched from Java, the real entry point (main() function)
|
||||||
|
is outside of the the binary built from this code.
|
||||||
|
This define makes sure that, unlike on other platforms, SDL_main.h
|
||||||
|
and SDL_main_impl.h export an `SDL_main()` function (to be called
|
||||||
|
from Java), but don't implement a native `int main(int argc, char* argv[])`
|
||||||
|
or similar.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* On Emscripten, SDL provides a main function that converts URL
|
||||||
|
parameters that start with "SDL_" to environment variables, so
|
||||||
|
they can be used as SDL hints, etc.
|
||||||
|
|
||||||
|
This is 100% optional, so if you don't want this to happen, you may
|
||||||
|
define SDL_MAIN_HANDLED
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* On PSP SDL provides a main function that sets the module info,
|
||||||
|
activates the GPU and starts the thread required to be able to exit
|
||||||
|
the software.
|
||||||
|
|
||||||
|
If you provide this yourself, you may define SDL_MAIN_HANDLED
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
On N3DS, SDL provides a main function that sets up the screens
|
||||||
|
and storage.
|
||||||
|
|
||||||
|
If you provide this yourself, you may define SDL_MAIN_HANDLED
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_MAIN_HANDLED */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A macro to tag a main entry point function as exported.
|
||||||
|
*
|
||||||
|
* Most platforms don't need this, and the macro will be defined to nothing.
|
||||||
|
* Some, like Android, keep the entry points in a shared library and need to
|
||||||
|
* explicitly export the symbols.
|
||||||
|
*
|
||||||
|
* External code rarely needs this, and if it needs something, it's almost
|
||||||
|
* always SDL_DECLSPEC instead.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_DECLSPEC
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* We need to export SDL_main so it can be launched from external code,
|
||||||
|
like SDLActivity.java on Android */
|
||||||
|
|
||||||
|
|
||||||
|
/* usually this is empty */
|
||||||
|
|
||||||
|
/* SDL_MAIN_EXPORTED */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* You can (optionally!) define SDL_MAIN_USE_CALLBACKS before including
|
||||||
|
* SDL_main.h, and then your application will _not_ have a standard
|
||||||
|
* "main" entry point. Instead, it will operate as a collection of
|
||||||
|
* functions that are called as necessary by the system. On some
|
||||||
|
* platforms, this is just a layer where SDL drives your program
|
||||||
|
* instead of your program driving SDL, on other platforms this might
|
||||||
|
* hook into the OS to manage the lifecycle. Programs on most platforms
|
||||||
|
* can use whichever approach they prefer, but the decision boils down
|
||||||
|
* to:
|
||||||
|
*
|
||||||
|
* - Using a standard "main" function: this works like it always has for
|
||||||
|
* the past 50+ years in C programming, and your app is in control.
|
||||||
|
* - Using the callback functions: this might clean up some code,
|
||||||
|
* avoid some #ifdef blocks in your program for some platforms, be more
|
||||||
|
* resource-friendly to the system, and possibly be the primary way to
|
||||||
|
* access some future platforms (but none require this at the moment).
|
||||||
|
*
|
||||||
|
* This is up to the app; both approaches are considered valid and supported
|
||||||
|
* ways to write SDL apps.
|
||||||
|
*
|
||||||
|
* If using the callbacks, don't define a "main" function. Instead, implement
|
||||||
|
* the functions listed below in your program.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* App-implemented initial entry point for SDL_MAIN_USE_CALLBACKS apps.
|
||||||
|
*
|
||||||
|
* Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
|
||||||
|
* standard "main" function, you should not supply this.
|
||||||
|
*
|
||||||
|
* This function is called by SDL once, at startup. The function should
|
||||||
|
* initialize whatever is necessary, possibly create windows and open audio
|
||||||
|
* devices, etc. The `argc` and `argv` parameters work like they would with a
|
||||||
|
* standard "main" function.
|
||||||
|
*
|
||||||
|
* This function should not go into an infinite mainloop; it should do any
|
||||||
|
* one-time setup it requires and then return.
|
||||||
|
*
|
||||||
|
* The app may optionally assign a pointer to `*appstate`. This pointer will
|
||||||
|
* be provided on every future call to the other entry points, to allow
|
||||||
|
* application state to be preserved between functions without the app needing
|
||||||
|
* to use a global variable. If this isn't set, the pointer will be NULL in
|
||||||
|
* future entry points.
|
||||||
|
*
|
||||||
|
* If this function returns SDL_APP_CONTINUE, the app will proceed to normal
|
||||||
|
* operation, and will begin receiving repeated calls to SDL_AppIterate and
|
||||||
|
* SDL_AppEvent for the life of the program. If this function returns
|
||||||
|
* SDL_APP_FAILURE, SDL will call SDL_AppQuit and terminate the process with
|
||||||
|
* an exit code that reports an error to the platform. If it returns
|
||||||
|
* SDL_APP_SUCCESS, SDL calls SDL_AppQuit and terminates with an exit code
|
||||||
|
* that reports success to the platform.
|
||||||
|
*
|
||||||
|
* This function is called by SDL on the main thread.
|
||||||
|
*
|
||||||
|
* \param appstate a place where the app can optionally store a pointer for
|
||||||
|
* future use.
|
||||||
|
* \param argc the standard ANSI C main's argc; number of elements in `argv`.
|
||||||
|
* \param argv the standard ANSI C main's argv; array of command line
|
||||||
|
* arguments.
|
||||||
|
* \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
|
||||||
|
* terminate with success, SDL_APP_CONTINUE to continue.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AppIterate
|
||||||
|
* \sa SDL_AppEvent
|
||||||
|
* \sa SDL_AppQuit
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* App-implemented iteration entry point for SDL_MAIN_USE_CALLBACKS apps.
|
||||||
|
*
|
||||||
|
* Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
|
||||||
|
* standard "main" function, you should not supply this.
|
||||||
|
*
|
||||||
|
* This function is called repeatedly by SDL after SDL_AppInit returns
|
||||||
|
* SDL_APP_CONTINUE. The function should operate as a single iteration the
|
||||||
|
* program's primary loop; it should update whatever state it needs and draw a
|
||||||
|
* new frame of video, usually.
|
||||||
|
*
|
||||||
|
* On some platforms, this function will be called at the refresh rate of the
|
||||||
|
* display (which might change during the life of your app!). There are no
|
||||||
|
* promises made about what frequency this function might run at. You should
|
||||||
|
* use SDL's timer functions if you need to see how much time has passed since
|
||||||
|
* the last iteration.
|
||||||
|
*
|
||||||
|
* There is no need to process the SDL event queue during this function; SDL
|
||||||
|
* will send events as they arrive in SDL_AppEvent, and in most cases the
|
||||||
|
* event queue will be empty when this function runs anyhow.
|
||||||
|
*
|
||||||
|
* This function should not go into an infinite mainloop; it should do one
|
||||||
|
* iteration of whatever the program does and return.
|
||||||
|
*
|
||||||
|
* The `appstate` parameter is an optional pointer provided by the app during
|
||||||
|
* SDL_AppInit(). If the app never provided a pointer, this will be NULL.
|
||||||
|
*
|
||||||
|
* If this function returns SDL_APP_CONTINUE, the app will continue normal
|
||||||
|
* operation, receiving repeated calls to SDL_AppIterate and SDL_AppEvent for
|
||||||
|
* the life of the program. If this function returns SDL_APP_FAILURE, SDL will
|
||||||
|
* call SDL_AppQuit and terminate the process with an exit code that reports
|
||||||
|
* an error to the platform. If it returns SDL_APP_SUCCESS, SDL calls
|
||||||
|
* SDL_AppQuit and terminates with an exit code that reports success to the
|
||||||
|
* platform.
|
||||||
|
*
|
||||||
|
* This function is called by SDL on the main thread.
|
||||||
|
*
|
||||||
|
* \param appstate an optional pointer, provided by the app in SDL_AppInit.
|
||||||
|
* \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
|
||||||
|
* terminate with success, SDL_APP_CONTINUE to continue.
|
||||||
|
*
|
||||||
|
* \threadsafety This function may get called concurrently with SDL_AppEvent()
|
||||||
|
* for events not pushed on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AppInit
|
||||||
|
* \sa SDL_AppEvent
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* App-implemented event entry point for SDL_MAIN_USE_CALLBACKS apps.
|
||||||
|
*
|
||||||
|
* Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
|
||||||
|
* standard "main" function, you should not supply this.
|
||||||
|
*
|
||||||
|
* This function is called as needed by SDL after SDL_AppInit returns
|
||||||
|
* SDL_APP_CONTINUE. It is called once for each new event.
|
||||||
|
*
|
||||||
|
* There is (currently) no guarantee about what thread this will be called
|
||||||
|
* from; whatever thread pushes an event onto SDL's queue will trigger this
|
||||||
|
* function. SDL is responsible for pumping the event queue between each call
|
||||||
|
* to SDL_AppIterate, so in normal operation one should only get events in a
|
||||||
|
* serial fashion, but be careful if you have a thread that explicitly calls
|
||||||
|
* SDL_PushEvent. SDL itself will push events to the queue on the main thread.
|
||||||
|
*
|
||||||
|
* Events sent to this function are not owned by the app; if you need to save
|
||||||
|
* the data, you should copy it.
|
||||||
|
*
|
||||||
|
* This function should not go into an infinite mainloop; it should handle the
|
||||||
|
* provided event appropriately and return.
|
||||||
|
*
|
||||||
|
* The `appstate` parameter is an optional pointer provided by the app during
|
||||||
|
* SDL_AppInit(). If the app never provided a pointer, this will be NULL.
|
||||||
|
*
|
||||||
|
* If this function returns SDL_APP_CONTINUE, the app will continue normal
|
||||||
|
* operation, receiving repeated calls to SDL_AppIterate and SDL_AppEvent for
|
||||||
|
* the life of the program. If this function returns SDL_APP_FAILURE, SDL will
|
||||||
|
* call SDL_AppQuit and terminate the process with an exit code that reports
|
||||||
|
* an error to the platform. If it returns SDL_APP_SUCCESS, SDL calls
|
||||||
|
* SDL_AppQuit and terminates with an exit code that reports success to the
|
||||||
|
* platform.
|
||||||
|
*
|
||||||
|
* \param appstate an optional pointer, provided by the app in SDL_AppInit.
|
||||||
|
* \param event the new event for the app to examine.
|
||||||
|
* \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
|
||||||
|
* terminate with success, SDL_APP_CONTINUE to continue.
|
||||||
|
*
|
||||||
|
* \threadsafety This function may get called concurrently with
|
||||||
|
* SDL_AppIterate() or SDL_AppQuit() for events not pushed from
|
||||||
|
* the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AppInit
|
||||||
|
* \sa SDL_AppIterate
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* App-implemented deinit entry point for SDL_MAIN_USE_CALLBACKS apps.
|
||||||
|
*
|
||||||
|
* Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
|
||||||
|
* standard "main" function, you should not supply this.
|
||||||
|
*
|
||||||
|
* This function is called once by SDL before terminating the program.
|
||||||
|
*
|
||||||
|
* This function will be called in all cases, even if SDL_AppInit requests
|
||||||
|
* termination at startup.
|
||||||
|
*
|
||||||
|
* This function should not go into an infinite mainloop; it should
|
||||||
|
* deinitialize any resources necessary, perform whatever shutdown activities,
|
||||||
|
* and return.
|
||||||
|
*
|
||||||
|
* You do not need to call SDL_Quit() in this function, as SDL will call it
|
||||||
|
* after this function returns and before the process terminates, but it is
|
||||||
|
* safe to do so.
|
||||||
|
*
|
||||||
|
* The `appstate` parameter is an optional pointer provided by the app during
|
||||||
|
* SDL_AppInit(). If the app never provided a pointer, this will be NULL. This
|
||||||
|
* function call is the last time this pointer will be provided, so any
|
||||||
|
* resources to it should be cleaned up here.
|
||||||
|
*
|
||||||
|
* This function is called by SDL on the main thread.
|
||||||
|
*
|
||||||
|
* \param appstate an optional pointer, provided by the app in SDL_AppInit.
|
||||||
|
* \param result the result code that terminated the app (success or failure).
|
||||||
|
*
|
||||||
|
* \threadsafety SDL_AppEvent() may get called concurrently with this function
|
||||||
|
* if other threads that push events are still active.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AppInit
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_MAIN_USE_CALLBACKS */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The prototype for the application's main() function
|
||||||
|
*
|
||||||
|
* \param argc an ANSI-C style main function's argc.
|
||||||
|
* \param argv an ANSI-C style main function's argv.
|
||||||
|
* \returns an ANSI-C main return code; generally 0 is considered successful
|
||||||
|
* program completion, and small non-zero values are considered
|
||||||
|
* errors.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public function c_int main_func(c_int argc, c_char**);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An app-supplied function for program entry.
|
||||||
|
*
|
||||||
|
* Apps do not directly create this function; they should create a standard
|
||||||
|
* ANSI-C `main` function instead. If SDL needs to insert some startup code
|
||||||
|
* before `main` runs, or the platform doesn't actually _use_ a function
|
||||||
|
* called "main", SDL will do some macro magic to redefine `main` to
|
||||||
|
* `SDL_main` and provide its own `main`.
|
||||||
|
*
|
||||||
|
* Apps should include `SDL_main.h` in the same file as their `main` function,
|
||||||
|
* and they should not use that symbol for anything else in that file, as it
|
||||||
|
* might get redefined.
|
||||||
|
*
|
||||||
|
* This function is only provided by the app if it isn't using
|
||||||
|
* SDL_MAIN_USE_CALLBACKS.
|
||||||
|
*
|
||||||
|
* Program startup is a surprisingly complex topic. Please see
|
||||||
|
* [README-main-functions](README-main-functions), (or
|
||||||
|
* docs/README-main-functions.md in the source tree) for a more detailed
|
||||||
|
* explanation.
|
||||||
|
*
|
||||||
|
* \param argc an ANSI-C style main function's argc.
|
||||||
|
* \param argv an ANSI-C style main function's argv.
|
||||||
|
* \returns an ANSI-C main return code; generally 0 is considered successful
|
||||||
|
* program completion, and small non-zero values are considered
|
||||||
|
* errors.
|
||||||
|
*
|
||||||
|
* \threadsafety This is the program entry point.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_main")] public static extern c_int main(c_int argc, c_char** argv);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Circumvent failure of SDL_Init() when not using SDL_main() as an entry
|
||||||
|
* point.
|
||||||
|
*
|
||||||
|
* This function is defined in SDL_main.h, along with the preprocessor rule to
|
||||||
|
* redefine main() as SDL_main(). Thus to ensure that your main() function
|
||||||
|
* will not be changed it is necessary to define SDL_MAIN_HANDLED before
|
||||||
|
* including SDL.h.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Init
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetMainReady")] public static extern void SetMainReady();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes and launches an SDL application, by doing platform-specific
|
||||||
|
* initialization before calling your mainFunction and cleanups after it
|
||||||
|
* returns, if that is needed for a specific platform, otherwise it just calls
|
||||||
|
* mainFunction.
|
||||||
|
*
|
||||||
|
* You can use this if you want to use your own main() implementation without
|
||||||
|
* using SDL_main (like when using SDL_MAIN_HANDLED). When using this, you do
|
||||||
|
* *not* need SDL_SetMainReady().
|
||||||
|
*
|
||||||
|
* If `argv` is NULL, SDL will provide command line arguments, either by
|
||||||
|
* querying the OS for them if possible, or supplying a filler array if not.
|
||||||
|
*
|
||||||
|
* \param argc the argc parameter from the application's main() function, or 0
|
||||||
|
* if the platform's main-equivalent has no argc.
|
||||||
|
* \param argv the argv parameter from the application's main() function, or
|
||||||
|
* NULL if the platform's main-equivalent has no argv.
|
||||||
|
* \param mainFunction your SDL app's C-style main(). NOT the function you're
|
||||||
|
* calling this from! Its name doesn't matter; it doesn't
|
||||||
|
* literally have to be `main`.
|
||||||
|
* \param reserved should be NULL (reserved for future use, will probably be
|
||||||
|
* platform-specific then).
|
||||||
|
* \returns the return value from mainFunction: 0 on success, otherwise
|
||||||
|
* failure; SDL_GetError() might have more information on the
|
||||||
|
* failure.
|
||||||
|
*
|
||||||
|
* \threadsafety Generally this is called once, near startup, from the
|
||||||
|
* process's initial thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_RunApp")] public static extern c_int RunApp(c_int argc, c_char** argv, main_func mainFunction, void* reserved);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An entry point for SDL's use in SDL_MAIN_USE_CALLBACKS.
|
||||||
|
*
|
||||||
|
* Generally, you should not call this function directly. This only exists to
|
||||||
|
* hand off work into SDL as soon as possible, where it has a lot more control
|
||||||
|
* and functionality available, and make the inline code in SDL_main.h as
|
||||||
|
* small as possible.
|
||||||
|
*
|
||||||
|
* Not all platforms use this, it's actual use is hidden in a magic
|
||||||
|
* header-only library, and you should not call this directly unless you
|
||||||
|
* _really_ know what you're doing.
|
||||||
|
*
|
||||||
|
* \param argc standard Unix main argc.
|
||||||
|
* \param argv standard Unix main argv.
|
||||||
|
* \param appinit the application's SDL_AppInit function.
|
||||||
|
* \param appiter the application's SDL_AppIterate function.
|
||||||
|
* \param appevent the application's SDL_AppEvent function.
|
||||||
|
* \param appquit the application's SDL_AppQuit function.
|
||||||
|
* \returns standard Unix main return value.
|
||||||
|
*
|
||||||
|
* \threadsafety It is not safe to call this anywhere except as the only
|
||||||
|
* function call in SDL_main.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_EnterAppMainCallbacks")] public static extern c_int EnterAppMainCallbacks(c_int argc, c_char** argv, AppInit_func appinit, AppIterate_func appiter, AppEvent_func appevent, AppQuit_func appquit);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a win32 window class for SDL's use.
|
||||||
|
*
|
||||||
|
* This can be called to set the application window class at startup. It is
|
||||||
|
* safe to call this multiple times, as long as every call is eventually
|
||||||
|
* paired with a call to SDL_UnregisterApp, but a second registration attempt
|
||||||
|
* while a previous registration is still active will be ignored, other than
|
||||||
|
* to increment a counter.
|
||||||
|
*
|
||||||
|
* Most applications do not need to, and should not, call this directly; SDL
|
||||||
|
* will call it when initializing the video subsystem.
|
||||||
|
*
|
||||||
|
* If `name` is NULL, SDL currently uses `(CS_BYTEALIGNCLIENT | CS_OWNDC)` for
|
||||||
|
* the style, regardless of what is specified here.
|
||||||
|
*
|
||||||
|
* \param name the window class name, in UTF-8 encoding. If NULL, SDL
|
||||||
|
* currently uses "SDL_app" but this isn't guaranteed.
|
||||||
|
* \param style the value to use in WNDCLASSEX::style.
|
||||||
|
* \param hInst the HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL
|
||||||
|
* will use `GetModuleHandle(NULL)` instead.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deregister the win32 window class from an SDL_RegisterApp call.
|
||||||
|
*
|
||||||
|
* This can be called to undo the effects of SDL_RegisterApp.
|
||||||
|
*
|
||||||
|
* Most applications do not need to, and should not, call this directly; SDL
|
||||||
|
* will call it when deinitializing the video subsystem.
|
||||||
|
*
|
||||||
|
* It is safe to call this multiple times, as long as every call is eventually
|
||||||
|
* paired with a prior call to SDL_RegisterApp. The window class will only be
|
||||||
|
* deregistered when the registration counter in SDL_RegisterApp decrements to
|
||||||
|
* zero through calls to this function.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* defined(SDL_PLATFORM_WINDOWS) */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback from the application to let the suspend continue.
|
||||||
|
*
|
||||||
|
* This function is only needed for Xbox GDK support; all other platforms will
|
||||||
|
* do nothing and set an "unsupported" error message.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GDKSuspendComplete")] public static extern void GDKSuspendComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* include header-only SDL_main implementations */
|
||||||
|
|
||||||
|
/* platforms which main (-equivalent) can be implemented in plain C */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_main_h_ */
|
||||||
164
src/SDL_main_impl.bf
Normal file
164
src/SDL_main_impl.bf
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* WIKI CATEGORY: Main */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* if someone wants to include SDL_main.h but doesn't want the main handing magic,
|
||||||
|
(maybe to call SDL_RegisterApp()) they can #define SDL_MAIN_HANDLED first.
|
||||||
|
SDL_MAIN_NOIMPL is for SDL-internal usage (only affects implementation,
|
||||||
|
not definition of SDL_MAIN_AVAILABLE etc in SDL_main.h) and if the user wants
|
||||||
|
to have the SDL_main implementation (from this header) in another source file
|
||||||
|
than their main() function, for example if SDL_main requires C++
|
||||||
|
and main() is implemented in plain C */
|
||||||
|
|
||||||
|
|
||||||
|
/* the implementations below must be able to use the implement real main(), nothing renamed
|
||||||
|
(the user's main() will be renamed to SDL_main so it can be called from here) */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* currently there are no platforms that _need_ a magic entry point here
|
||||||
|
for callbacks, but if one shows up, implement it here. */
|
||||||
|
|
||||||
|
/* use a standard SDL_main, which the app SHOULD NOT ALSO SUPPLY. */
|
||||||
|
|
||||||
|
/* this define makes the normal SDL_main entry point stuff work...we just provide SDL_main() instead of the app. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* platform-specific tests */
|
||||||
|
|
||||||
|
/* SDL_MAIN_USE_CALLBACKS */
|
||||||
|
|
||||||
|
|
||||||
|
/* set up the usual SDL_main stuff if we're not using callbacks or if we are but need the normal entry point,
|
||||||
|
unless the real entry point needs to be somewhere else entirely, like Android where it's in Java code */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Private platforms may have their own ideas about entry points. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* these defines/typedefs are needed for the WinMain() definition */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* The VC++ compiler needs main/wmain defined, but not for GDK */
|
||||||
|
|
||||||
|
|
||||||
|
/* This is where execution begins [console apps] */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ANSI */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* UNICODE */
|
||||||
|
|
||||||
|
/* _MSC_VER && ! SDL_PLATFORM_GDK */
|
||||||
|
|
||||||
|
/* This is where execution begins [windowed apps and GDK] */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ANSI */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* extern "C" */
|
||||||
|
|
||||||
|
|
||||||
|
/* end of SDL_PLATFORM_WINDOWS impls */
|
||||||
|
|
||||||
|
/* platforms that use a standard main() and just call SDL_RunApp(), like iOS and 3DS */
|
||||||
|
[CLink] public static extern c_int main(c_int argc, c_char** argv);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* end of impls for standard-conforming platforms */
|
||||||
|
|
||||||
|
/* SDL_PLATFORM_WIN32 etc */
|
||||||
|
|
||||||
|
/* !defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD) */
|
||||||
|
|
||||||
|
/* rename users main() function to SDL_main() so it can be called from the wrappers above */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_MAIN_HANDLED */
|
||||||
|
|
||||||
|
/* SDL_main_impl_h_ */
|
||||||
238
src/SDL_messagebox.bf
Normal file
238
src/SDL_messagebox.bf
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryMessagebox
|
||||||
|
*
|
||||||
|
* SDL offers a simple message box API, which is useful for simple alerts,
|
||||||
|
* such as informing the user when something fatal happens at startup without
|
||||||
|
* the need to build a UI for it (or informing the user _before_ your UI is
|
||||||
|
* ready).
|
||||||
|
*
|
||||||
|
* These message boxes are native system dialogs where possible.
|
||||||
|
*
|
||||||
|
* There is both a customizable function (SDL_ShowMessageBox()) that offers
|
||||||
|
* lots of options for what to display and reports on what choice the user
|
||||||
|
* made, and also a much-simplified version (SDL_ShowSimpleMessageBox()),
|
||||||
|
* merely takes a text message and title, and waits until the user presses a
|
||||||
|
* single "OK" UI button. Often, this is all that is necessary.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* For SDL_Window */
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message box flags.
|
||||||
|
*
|
||||||
|
* If supported will display warning icon, etc.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public enum MessageBoxFlags : Uint32 {}
|
||||||
|
|
||||||
|
|
||||||
|
public const let MESSAGEBOX_ERROR = 0x00000010u;/**< error dialog */
|
||||||
|
public const let MESSAGEBOX_WARNING = 0x00000020u;/**< warning dialog */
|
||||||
|
public const let MESSAGEBOX_INFORMATION = 0x00000040u;/**< informational dialog */
|
||||||
|
public const let MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT = 0x00000080u;/**< buttons placed left to right */
|
||||||
|
public const let MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT = 0x00000100u;/**< buttons placed right to left */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SDL_MessageBoxButtonData flags.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public enum MessageBoxButtonFlags : Uint32 {}
|
||||||
|
|
||||||
|
|
||||||
|
public const let MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001u;/**< Marks the default button when return is hit */
|
||||||
|
public const let MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002u;/**< Marks the default button when escape is hit */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Individual button data.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct MessageBoxButtonData
|
||||||
|
{
|
||||||
|
public MessageBoxButtonFlags flags;
|
||||||
|
public c_int buttonID; /**< User defined button id (value returned via SDL_ShowMessageBox) */
|
||||||
|
public c_char* text; /**< The UTF-8 button text */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RGB value used in a message box color scheme
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct MessageBoxColor
|
||||||
|
{
|
||||||
|
public Uint8 r; public Uint8 g; public Uint8 b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An enumeration of indices inside the colors array of
|
||||||
|
* SDL_MessageBoxColorScheme.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum MessageBoxColorType : c_int
|
||||||
|
{
|
||||||
|
Background,
|
||||||
|
ext,
|
||||||
|
ButtonBorder,
|
||||||
|
ButtonBackground,
|
||||||
|
ButtonSelected,
|
||||||
|
Count, /**< Size of the colors array of SDL_MessageBoxColorScheme. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A set of colors to use for message box dialogs
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct MessageBoxColorScheme
|
||||||
|
{
|
||||||
|
public MessageBoxColor[5] colors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MessageBox structure containing title, text, window, etc.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct MessageBoxData
|
||||||
|
{
|
||||||
|
public MessageBoxFlags flags;
|
||||||
|
public Window* window; /**< Parent window, can be NULL */
|
||||||
|
public c_char* title; /**< UTF-8 title */
|
||||||
|
public c_char* message; /**< UTF-8 message text */
|
||||||
|
|
||||||
|
public c_int numbuttons;
|
||||||
|
public MessageBoxButtonData* buttons;
|
||||||
|
|
||||||
|
public MessageBoxColorScheme* colorScheme; /**< SDL_MessageBoxColorScheme, can be NULL to use system settings */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a modal message box.
|
||||||
|
*
|
||||||
|
* If your needs aren't complex, it might be easier to use
|
||||||
|
* SDL_ShowSimpleMessageBox.
|
||||||
|
*
|
||||||
|
* This function should be called on the thread that created the parent
|
||||||
|
* window, or on the main thread if the messagebox has no parent. It will
|
||||||
|
* block execution of that thread until the user clicks a button or closes the
|
||||||
|
* messagebox.
|
||||||
|
*
|
||||||
|
* This function may be called at any time, even before SDL_Init(). This makes
|
||||||
|
* it useful for reporting errors like a failure to create a renderer or
|
||||||
|
* OpenGL context.
|
||||||
|
*
|
||||||
|
* On X11, SDL rolls its own dialog box with X11 primitives instead of a
|
||||||
|
* formal toolkit like GTK+ or Qt.
|
||||||
|
*
|
||||||
|
* Note that if SDL_Init() would fail because there isn't any available video
|
||||||
|
* target, this function is likely to fail for the same reasons. If this is a
|
||||||
|
* concern, check the return value from this function and fall back to writing
|
||||||
|
* to stderr if you can.
|
||||||
|
*
|
||||||
|
* \param messageboxdata the SDL_MessageBoxData structure with title, text and
|
||||||
|
* other options.
|
||||||
|
* \param buttonid the pointer to which user id of hit button should be
|
||||||
|
* copied.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ShowSimpleMessageBox
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ShowMessageBox")] public static extern bool ShowMessageBox(MessageBoxData* messageboxdata, c_int* buttonid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a simple modal message box.
|
||||||
|
*
|
||||||
|
* If your needs aren't complex, this function is preferred over
|
||||||
|
* SDL_ShowMessageBox.
|
||||||
|
*
|
||||||
|
* `flags` may be any of the following:
|
||||||
|
*
|
||||||
|
* - `SDL_MESSAGEBOX_ERROR`: error dialog
|
||||||
|
* - `SDL_MESSAGEBOX_WARNING`: warning dialog
|
||||||
|
* - `SDL_MESSAGEBOX_INFORMATION`: informational dialog
|
||||||
|
*
|
||||||
|
* This function should be called on the thread that created the parent
|
||||||
|
* window, or on the main thread if the messagebox has no parent. It will
|
||||||
|
* block execution of that thread until the user clicks a button or closes the
|
||||||
|
* messagebox.
|
||||||
|
*
|
||||||
|
* This function may be called at any time, even before SDL_Init(). This makes
|
||||||
|
* it useful for reporting errors like a failure to create a renderer or
|
||||||
|
* OpenGL context.
|
||||||
|
*
|
||||||
|
* On X11, SDL rolls its own dialog box with X11 primitives instead of a
|
||||||
|
* formal toolkit like GTK+ or Qt.
|
||||||
|
*
|
||||||
|
* Note that if SDL_Init() would fail because there isn't any available video
|
||||||
|
* target, this function is likely to fail for the same reasons. If this is a
|
||||||
|
* concern, check the return value from this function and fall back to writing
|
||||||
|
* to stderr if you can.
|
||||||
|
*
|
||||||
|
* \param flags an SDL_MessageBoxFlags value.
|
||||||
|
* \param title UTF-8 title text.
|
||||||
|
* \param message UTF-8 message text.
|
||||||
|
* \param window the parent window, or NULL for no parent.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ShowMessageBox
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ShowSimpleMessageBox")] public static extern bool ShowSimpleMessageBox(MessageBoxFlags flags, c_char* title, c_char* message, Window* window);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_messagebox_h_ */
|
||||||
118
src/SDL_metal.bf
Normal file
118
src/SDL_metal.bf
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryMetal
|
||||||
|
*
|
||||||
|
* Functions to creating Metal layers and views on SDL windows.
|
||||||
|
*
|
||||||
|
* This provides some platform-specific glue for Apple platforms. Most macOS
|
||||||
|
* and iOS apps can use SDL without these functions, but this API they can be
|
||||||
|
* useful for specific OS-level integration tasks.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS).
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public typealias MetalView = void*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \name Metal support functions
|
||||||
|
*/
|
||||||
|
/* @{ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a CAMetalLayer-backed NSView/UIView and attach it to the specified
|
||||||
|
* window.
|
||||||
|
*
|
||||||
|
* On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on
|
||||||
|
* its own. It is up to user code to do that.
|
||||||
|
*
|
||||||
|
* The returned handle can be casted directly to a NSView or UIView. To access
|
||||||
|
* the backing CAMetalLayer, call SDL_Metal_GetLayer().
|
||||||
|
*
|
||||||
|
* \param window the window.
|
||||||
|
* \returns handle NSView or UIView.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Metal_DestroyView
|
||||||
|
* \sa SDL_Metal_GetLayer
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_Metal_CreateView")] public static extern MetalView Metal_CreateView(Window* window);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy an existing SDL_MetalView object.
|
||||||
|
*
|
||||||
|
* This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was
|
||||||
|
* called after SDL_CreateWindow.
|
||||||
|
*
|
||||||
|
* \param view the SDL_MetalView object.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Metal_CreateView
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_Metal_DestroyView")] public static extern void Metal_DestroyView(MetalView view);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a pointer to the backing CAMetalLayer for the given view.
|
||||||
|
*
|
||||||
|
* \param view the SDL_MetalView object.
|
||||||
|
* \returns a pointer.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_Metal_GetLayer")] public static extern void* Metal_GetLayer(MetalView view);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @} */ /* Metal support functions */
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_metal_h_ */
|
||||||
89
src/SDL_misc.bf
Normal file
89
src/SDL_misc.bf
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryMisc
|
||||||
|
*
|
||||||
|
* SDL API functions that don't fit elsewhere.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a URL/URI in the browser or other appropriate external application.
|
||||||
|
*
|
||||||
|
* Open a URL in a separate, system-provided application. How this works will
|
||||||
|
* vary wildly depending on the platform. This will likely launch what makes
|
||||||
|
* sense to handle a specific URL's protocol (a web browser for `http://`,
|
||||||
|
* etc), but it might also be able to launch file managers for directories and
|
||||||
|
* other things.
|
||||||
|
*
|
||||||
|
* What happens when you open a URL varies wildly as well: your game window
|
||||||
|
* may lose focus (and may or may not lose focus if your game was fullscreen
|
||||||
|
* or grabbing input at the time). On mobile devices, your app will likely
|
||||||
|
* move to the background or your process might be paused. Any given platform
|
||||||
|
* may or may not handle a given URL.
|
||||||
|
*
|
||||||
|
* If this is unimplemented (or simply unavailable) for a platform, this will
|
||||||
|
* fail with an error. A successful result does not mean the URL loaded, just
|
||||||
|
* that we launched _something_ to handle it (or at least believe we did).
|
||||||
|
*
|
||||||
|
* All this to say: this function can be useful, but you should definitely
|
||||||
|
* test it on every platform you target.
|
||||||
|
*
|
||||||
|
* \param url a valid URL/URI to open. Use `file:///full/path/to/file` for
|
||||||
|
* local files, if supported.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OpenURL")] public static extern bool OpenURL(c_char* url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_misc_h_ */
|
||||||
840
src/SDL_mouse.bf
Normal file
840
src/SDL_mouse.bf
Normal file
@@ -0,0 +1,840 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryMouse
|
||||||
|
*
|
||||||
|
* Any GUI application has to deal with the mouse, and SDL provides functions
|
||||||
|
* to manage mouse input and the displayed cursor.
|
||||||
|
*
|
||||||
|
* Most interactions with the mouse will come through the event subsystem.
|
||||||
|
* Moving a mouse generates an SDL_EVENT_MOUSE_MOTION event, pushing a button
|
||||||
|
* generates SDL_EVENT_MOUSE_BUTTON_DOWN, etc, but one can also query the
|
||||||
|
* current state of the mouse at any time with SDL_GetMouseState().
|
||||||
|
*
|
||||||
|
* For certain games, it's useful to disassociate the mouse cursor from mouse
|
||||||
|
* input. An FPS, for example, would not want the player's motion to stop as
|
||||||
|
* the mouse hits the edge of the window. For these scenarios, use
|
||||||
|
* SDL_SetWindowRelativeMouseMode(), which hides the cursor, grabs mouse input
|
||||||
|
* to the window, and reads mouse input no matter how far it moves.
|
||||||
|
*
|
||||||
|
* Games that want the system to track the mouse but want to draw their own
|
||||||
|
* cursor can use SDL_HideCursor() and SDL_ShowCursor(). It might be more
|
||||||
|
* efficient to let the system manage the cursor, if possible, using
|
||||||
|
* SDL_SetCursor() with a custom image made through SDL_CreateColorCursor(),
|
||||||
|
* or perhaps just a specific system cursor from SDL_CreateSystemCursor().
|
||||||
|
*
|
||||||
|
* SDL can, on many platforms, differentiate between multiple connected mice,
|
||||||
|
* allowing for interesting input scenarios and multiplayer games. They can be
|
||||||
|
* enumerated with SDL_GetMice(), and SDL will send SDL_EVENT_MOUSE_ADDED and
|
||||||
|
* SDL_EVENT_MOUSE_REMOVED events as they are connected and unplugged.
|
||||||
|
*
|
||||||
|
* Since many apps only care about basic mouse input, SDL offers a virtual
|
||||||
|
* mouse device for touch and pen input, which often can make a desktop
|
||||||
|
* application work on a touchscreen phone without any code changes. Apps that
|
||||||
|
* care about touch/pen separately from mouse input should filter out events
|
||||||
|
* with a `which` field of SDL_TOUCH_MOUSEID/SDL_PEN_MOUSEID.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a unique ID for a mouse for the time it is connected to the system,
|
||||||
|
* and is never reused for the lifetime of the application.
|
||||||
|
*
|
||||||
|
* If the mouse is disconnected and reconnected, it will get a new ID.
|
||||||
|
*
|
||||||
|
* The value 0 is an invalid ID.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public typealias MouseID = Uint32;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The structure used to identify an SDL cursor.
|
||||||
|
*
|
||||||
|
* This is opaque data.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct Cursor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cursor types for SDL_CreateSystemCursor().
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum SystemCursor : c_int
|
||||||
|
{
|
||||||
|
Default, /**< Default cursor. Usually an arrow. */
|
||||||
|
Text, /**< Text selection. Usually an I-beam. */
|
||||||
|
Wait, /**< Wait. Usually an hourglass or watch or spinning ball. */
|
||||||
|
Crosshair, /**< Crosshair. */
|
||||||
|
Progress, /**< Program is busy but still interactive. Usually it's WAIT with an arrow. */
|
||||||
|
NwseResize, /**< Double arrow pointing northwest and southeast. */
|
||||||
|
NeswResize, /**< Double arrow pointing northeast and southwest. */
|
||||||
|
EwResize, /**< Double arrow pointing west and east. */
|
||||||
|
NsResize, /**< Double arrow pointing north and south. */
|
||||||
|
Move, /**< Four pointed arrow pointing north, south, east, and west. */
|
||||||
|
NotAllowed, /**< Not permitted. Usually a slashed circle or crossbones. */
|
||||||
|
Pointer, /**< Pointer that indicates a link. Usually a pointing hand. */
|
||||||
|
NwResize, /**< Window resize top-left. This may be a single arrow or a double arrow like NWSE_RESIZE. */
|
||||||
|
NResize, /**< Window resize top. May be NS_RESIZE. */
|
||||||
|
NeResize, /**< Window resize top-right. May be NESW_RESIZE. */
|
||||||
|
EResize, /**< Window resize right. May be EW_RESIZE. */
|
||||||
|
SeResize, /**< Window resize bottom-right. May be NWSE_RESIZE. */
|
||||||
|
SResize, /**< Window resize bottom. May be NS_RESIZE. */
|
||||||
|
SwResize, /**< Window resize bottom-left. May be NESW_RESIZE. */
|
||||||
|
WResize, /**< Window resize left. May be EW_RESIZE. */
|
||||||
|
Count,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scroll direction types for the Scroll event
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum MouseWheelDirection : c_int
|
||||||
|
{
|
||||||
|
Normal, /**< The scroll direction is normal */
|
||||||
|
Flipped, /**< The scroll direction is flipped / natural */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Animated cursor frame info.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.4.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct CursorFrameInfo
|
||||||
|
{
|
||||||
|
public Surface* surface; /**< The surface data for this frame */
|
||||||
|
public Uint32 duration; /**< The frame duration in milliseconds (a duration of 0 is infinite) */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A bitmask of pressed mouse buttons, as reported by SDL_GetMouseState, etc.
|
||||||
|
*
|
||||||
|
* - Button 1: Left mouse button
|
||||||
|
* - Button 2: Middle mouse button
|
||||||
|
* - Button 3: Right mouse button
|
||||||
|
* - Button 4: Side mouse button 1
|
||||||
|
* - Button 5: Side mouse button 2
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetMouseState
|
||||||
|
* \sa SDL_GetGlobalMouseState
|
||||||
|
* \sa SDL_GetRelativeMouseState
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum MouseButtonFlags : Uint32
|
||||||
|
{
|
||||||
|
Left = 1,
|
||||||
|
Middle = 2,
|
||||||
|
Right = 3,
|
||||||
|
X1 = 4,
|
||||||
|
X2 = 5,
|
||||||
|
Lmask = BUTTON_MASK(Left),
|
||||||
|
Mmask = BUTTON_MASK(Middle),
|
||||||
|
Rmask = BUTTON_MASK(Right),
|
||||||
|
X1mask = BUTTON_MASK(X1),
|
||||||
|
X2mask = BUTTON_MASK(X2),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A callback used to transform mouse motion delta from raw values.
|
||||||
|
*
|
||||||
|
* This is called during SDL's handling of platform mouse events to scale the
|
||||||
|
* values of the resulting motion delta.
|
||||||
|
*
|
||||||
|
* \param userdata what was passed as `userdata` to
|
||||||
|
* SDL_SetRelativeMouseTransform().
|
||||||
|
* \param timestamp the associated time at which this mouse motion event was
|
||||||
|
* received.
|
||||||
|
* \param window the associated window to which this mouse motion event was
|
||||||
|
* addressed.
|
||||||
|
* \param mouseID the associated mouse from which this mouse motion event was
|
||||||
|
* emitted.
|
||||||
|
* \param x pointer to a variable that will be treated as the resulting x-axis
|
||||||
|
* motion.
|
||||||
|
* \param y pointer to a variable that will be treated as the resulting y-axis
|
||||||
|
* motion.
|
||||||
|
*
|
||||||
|
* \threadsafety This callback is called by SDL's internal mouse input
|
||||||
|
* processing procedure, which may be a thread separate from the
|
||||||
|
* main event loop that is run at realtime priority. Stalling
|
||||||
|
* this thread with too much work in the callback can therefore
|
||||||
|
* potentially freeze the entire system. Care should be taken
|
||||||
|
* with proper synchronization practices when adding other side
|
||||||
|
* effects beyond mutation of the x and y values.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.4.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetRelativeMouseTransform
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A callback used to transform mouse motion delta from raw values.
|
||||||
|
*
|
||||||
|
* This is called during SDL's handling of platform mouse events to scale the
|
||||||
|
* values of the resulting motion delta.
|
||||||
|
*
|
||||||
|
* \param userdata what was passed as `userdata` to
|
||||||
|
* SDL_SetRelativeMouseTransform().
|
||||||
|
* \param timestamp the associated time at which this mouse motion event was
|
||||||
|
* received.
|
||||||
|
* \param window the associated window to which this mouse motion event was
|
||||||
|
* addressed.
|
||||||
|
* \param mouseID the associated mouse from which this mouse motion event was
|
||||||
|
* emitted.
|
||||||
|
* \param x pointer to a variable that will be treated as the resulting x-axis
|
||||||
|
* motion.
|
||||||
|
* \param y pointer to a variable that will be treated as the resulting y-axis
|
||||||
|
* motion.
|
||||||
|
*
|
||||||
|
* \threadsafety This callback is called by SDL's internal mouse input
|
||||||
|
* processing procedure, which may be a thread separate from the
|
||||||
|
* main event loop that is run at realtime priority. Stalling
|
||||||
|
* this thread with too much work in the callback can therefore
|
||||||
|
* potentially freeze the entire system. Care should be taken
|
||||||
|
* with proper synchronization practices when adding other side
|
||||||
|
* effects beyond mutation of the x and y values.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.4.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetRelativeMouseTransform
|
||||||
|
*/
|
||||||
|
public function void MouseMotionTransformCallback(void* userdata, Uint64 timestamp, Window* window, MouseID mouseID, float* x, float* y);
|
||||||
|
|
||||||
|
/* Function prototypes */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether a mouse is currently connected.
|
||||||
|
*
|
||||||
|
* \returns true if a mouse is connected, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetMice
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasMouse")] public static extern bool HasMouse();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of currently connected mice.
|
||||||
|
*
|
||||||
|
* Note that this will include any device or virtual driver that includes
|
||||||
|
* mouse functionality, including some game controllers, KVM switches, etc.
|
||||||
|
* You should wait for input from a device before you consider it actively in
|
||||||
|
* use.
|
||||||
|
*
|
||||||
|
* \param count a pointer filled in with the number of mice returned, may be
|
||||||
|
* NULL.
|
||||||
|
* \returns a 0 terminated array of mouse instance IDs or NULL on failure;
|
||||||
|
* call SDL_GetError() for more information. This should be freed
|
||||||
|
* with SDL_free() when it is no longer needed.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetMouseNameForID
|
||||||
|
* \sa SDL_HasMouse
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetMice")] public static extern MouseID* GetMice(out c_int count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of a mouse.
|
||||||
|
*
|
||||||
|
* This function returns "" if the mouse doesn't have a name.
|
||||||
|
*
|
||||||
|
* \param instance_id the mouse instance ID.
|
||||||
|
* \returns the name of the selected mouse, or NULL on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetMice
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetMouseNameForID")] public static extern c_char* GetMouseNameForID(MouseID instance_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the window which currently has mouse focus.
|
||||||
|
*
|
||||||
|
* \returns the window with mouse focus.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetMouseFocus")] public static extern Window* GetMouseFocus();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query SDL's cache for the synchronous mouse button state and the
|
||||||
|
* window-relative SDL-cursor position.
|
||||||
|
*
|
||||||
|
* This function returns the cached synchronous state as SDL understands it
|
||||||
|
* from the last pump of the event queue.
|
||||||
|
*
|
||||||
|
* To query the platform for immediate asynchronous state, use
|
||||||
|
* SDL_GetGlobalMouseState.
|
||||||
|
*
|
||||||
|
* Passing non-NULL pointers to `x` or `y` will write the destination with
|
||||||
|
* respective x or y coordinates relative to the focused window.
|
||||||
|
*
|
||||||
|
* In Relative Mode, the SDL-cursor's position usually contradicts the
|
||||||
|
* platform-cursor's position as manually calculated from
|
||||||
|
* SDL_GetGlobalMouseState() and SDL_GetWindowPosition.
|
||||||
|
*
|
||||||
|
* \param x a pointer to receive the SDL-cursor's x-position from the focused
|
||||||
|
* window's top left corner, can be NULL if unused.
|
||||||
|
* \param y a pointer to receive the SDL-cursor's y-position from the focused
|
||||||
|
* window's top left corner, can be NULL if unused.
|
||||||
|
* \returns a 32-bit bitmask of the button state that can be bitwise-compared
|
||||||
|
* against the SDL_BUTTON_MASK(X) macro.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetGlobalMouseState
|
||||||
|
* \sa SDL_GetRelativeMouseState
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetMouseState")] public static extern MouseButtonFlags GetMouseState(out float x, out float y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the platform for the asynchronous mouse button state and the
|
||||||
|
* desktop-relative platform-cursor position.
|
||||||
|
*
|
||||||
|
* This function immediately queries the platform for the most recent
|
||||||
|
* asynchronous state, more costly than retrieving SDL's cached state in
|
||||||
|
* SDL_GetMouseState().
|
||||||
|
*
|
||||||
|
* Passing non-NULL pointers to `x` or `y` will write the destination with
|
||||||
|
* respective x or y coordinates relative to the desktop.
|
||||||
|
*
|
||||||
|
* In Relative Mode, the platform-cursor's position usually contradicts the
|
||||||
|
* SDL-cursor's position as manually calculated from SDL_GetMouseState() and
|
||||||
|
* SDL_GetWindowPosition.
|
||||||
|
*
|
||||||
|
* This function can be useful if you need to track the mouse outside of a
|
||||||
|
* specific window and SDL_CaptureMouse() doesn't fit your needs. For example,
|
||||||
|
* it could be useful if you need to track the mouse while dragging a window,
|
||||||
|
* where coordinates relative to a window might not be in sync at all times.
|
||||||
|
*
|
||||||
|
* \param x a pointer to receive the platform-cursor's x-position from the
|
||||||
|
* desktop's top left corner, can be NULL if unused.
|
||||||
|
* \param y a pointer to receive the platform-cursor's y-position from the
|
||||||
|
* desktop's top left corner, can be NULL if unused.
|
||||||
|
* \returns a 32-bit bitmask of the button state that can be bitwise-compared
|
||||||
|
* against the SDL_BUTTON_MASK(X) macro.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CaptureMouse
|
||||||
|
* \sa SDL_GetMouseState
|
||||||
|
* \sa SDL_GetGlobalMouseState
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetGlobalMouseState")] public static extern MouseButtonFlags GetGlobalMouseState(out float x, out float y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query SDL's cache for the synchronous mouse button state and accumulated
|
||||||
|
* mouse delta since last call.
|
||||||
|
*
|
||||||
|
* This function returns the cached synchronous state as SDL understands it
|
||||||
|
* from the last pump of the event queue.
|
||||||
|
*
|
||||||
|
* To query the platform for immediate asynchronous state, use
|
||||||
|
* SDL_GetGlobalMouseState.
|
||||||
|
*
|
||||||
|
* Passing non-NULL pointers to `x` or `y` will write the destination with
|
||||||
|
* respective x or y deltas accumulated since the last call to this function
|
||||||
|
* (or since event initialization).
|
||||||
|
*
|
||||||
|
* This function is useful for reducing overhead by processing relative mouse
|
||||||
|
* inputs in one go per-frame instead of individually per-event, at the
|
||||||
|
* expense of losing the order between events within the frame (e.g. quickly
|
||||||
|
* pressing and releasing a button within the same frame).
|
||||||
|
*
|
||||||
|
* \param x a pointer to receive the x mouse delta accumulated since last
|
||||||
|
* call, can be NULL if unused.
|
||||||
|
* \param y a pointer to receive the y mouse delta accumulated since last
|
||||||
|
* call, can be NULL if unused.
|
||||||
|
* \returns a 32-bit bitmask of the button state that can be bitwise-compared
|
||||||
|
* against the SDL_BUTTON_MASK(X) macro.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetMouseState
|
||||||
|
* \sa SDL_GetGlobalMouseState
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetRelativeMouseState")] public static extern MouseButtonFlags GetRelativeMouseState(out float x, out float y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move the mouse cursor to the given position within the window.
|
||||||
|
*
|
||||||
|
* This function generates a mouse motion event if relative mode is not
|
||||||
|
* enabled. If relative mode is enabled, you can force mouse events for the
|
||||||
|
* warp by setting the SDL_HINT_MOUSE_RELATIVE_WARP_MOTION hint.
|
||||||
|
*
|
||||||
|
* Note that this function will appear to succeed, but not actually move the
|
||||||
|
* mouse when used over Microsoft Remote Desktop.
|
||||||
|
*
|
||||||
|
* \param window the window to move the mouse into, or NULL for the current
|
||||||
|
* mouse focus.
|
||||||
|
* \param x the x coordinate within the window.
|
||||||
|
* \param y the y coordinate within the window.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_WarpMouseGlobal
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_WarpMouseInWindow")] public static extern void WarpMouseInWindow(Window* window, float x, float y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move the mouse to the given position in global screen space.
|
||||||
|
*
|
||||||
|
* This function generates a mouse motion event.
|
||||||
|
*
|
||||||
|
* A failure of this function usually means that it is unsupported by a
|
||||||
|
* platform.
|
||||||
|
*
|
||||||
|
* Note that this function will appear to succeed, but not actually move the
|
||||||
|
* mouse when used over Microsoft Remote Desktop.
|
||||||
|
*
|
||||||
|
* \param x the x coordinate.
|
||||||
|
* \param y the y coordinate.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_WarpMouseInWindow
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_WarpMouseGlobal")] public static extern bool WarpMouseGlobal(float x, float y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a user-defined function by which to transform relative mouse inputs.
|
||||||
|
*
|
||||||
|
* This overrides the relative system scale and relative speed scale hints.
|
||||||
|
* Should be called prior to enabling relative mouse mode, fails otherwise.
|
||||||
|
*
|
||||||
|
* \param callback a callback used to transform relative mouse motion, or NULL
|
||||||
|
* for default behavior.
|
||||||
|
* \param userdata a pointer that will be passed to `callback`.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.4.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetRelativeMouseTransform")] public static extern bool SetRelativeMouseTransform(MouseMotionTransformCallback callback, void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set relative mouse mode for a window.
|
||||||
|
*
|
||||||
|
* While the window has focus and relative mouse mode is enabled, the cursor
|
||||||
|
* is hidden, the mouse position is constrained to the window, and SDL will
|
||||||
|
* report continuous relative mouse motion even if the mouse is at the edge of
|
||||||
|
* the window.
|
||||||
|
*
|
||||||
|
* If you'd like to keep the mouse position fixed while in relative mode you
|
||||||
|
* can use SDL_SetWindowMouseRect(). If you'd like the cursor to be at a
|
||||||
|
* specific location when relative mode ends, you should use
|
||||||
|
* SDL_WarpMouseInWindow() before disabling relative mode.
|
||||||
|
*
|
||||||
|
* This function will flush any pending mouse motion for this window.
|
||||||
|
*
|
||||||
|
* \param window the window to change.
|
||||||
|
* \param enabled true to enable relative mode, false to disable.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetWindowRelativeMouseMode
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetWindowRelativeMouseMode")] public static extern bool SetWindowRelativeMouseMode(Window* window, bool enabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query whether relative mouse mode is enabled for a window.
|
||||||
|
*
|
||||||
|
* \param window the window to query.
|
||||||
|
* \returns true if relative mode is enabled for a window or false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetWindowRelativeMouseMode
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetWindowRelativeMouseMode")] public static extern bool GetWindowRelativeMouseMode(Window* window);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capture the mouse and to track input outside an SDL window.
|
||||||
|
*
|
||||||
|
* Capturing enables your app to obtain mouse events globally, instead of just
|
||||||
|
* within your window. Not all video targets support this function. When
|
||||||
|
* capturing is enabled, the current window will get all mouse events, but
|
||||||
|
* unlike relative mode, no change is made to the cursor and it is not
|
||||||
|
* restrained to your window.
|
||||||
|
*
|
||||||
|
* This function may also deny mouse input to other windows--both those in
|
||||||
|
* your application and others on the system--so you should use this function
|
||||||
|
* sparingly, and in small bursts. For example, you might want to track the
|
||||||
|
* mouse while the user is dragging something, until the user releases a mouse
|
||||||
|
* button. It is not recommended that you capture the mouse for long periods
|
||||||
|
* of time, such as the entire time your app is running. For that, you should
|
||||||
|
* probably use SDL_SetWindowRelativeMouseMode() or SDL_SetWindowMouseGrab(),
|
||||||
|
* depending on your goals.
|
||||||
|
*
|
||||||
|
* While captured, mouse events still report coordinates relative to the
|
||||||
|
* current (foreground) window, but those coordinates may be outside the
|
||||||
|
* bounds of the window (including negative values). Capturing is only allowed
|
||||||
|
* for the foreground window. If the window loses focus while capturing, the
|
||||||
|
* capture will be disabled automatically.
|
||||||
|
*
|
||||||
|
* While capturing is enabled, the current window will have the
|
||||||
|
* `SDL_WINDOW_MOUSE_CAPTURE` flag set.
|
||||||
|
*
|
||||||
|
* Please note that SDL will attempt to "auto capture" the mouse while the
|
||||||
|
* user is pressing a button; this is to try and make mouse behavior more
|
||||||
|
* consistent between platforms, and deal with the common case of a user
|
||||||
|
* dragging the mouse outside of the window. This means that if you are
|
||||||
|
* calling SDL_CaptureMouse() only to deal with this situation, you do not
|
||||||
|
* have to (although it is safe to do so). If this causes problems for your
|
||||||
|
* app, you can disable auto capture by setting the
|
||||||
|
* `SDL_HINT_MOUSE_AUTO_CAPTURE` hint to zero.
|
||||||
|
*
|
||||||
|
* \param enabled true to enable capturing, false to disable.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetGlobalMouseState
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CaptureMouse")] public static extern bool CaptureMouse(bool enabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a cursor using the specified bitmap data and mask (in MSB format).
|
||||||
|
*
|
||||||
|
* `mask` has to be in MSB (Most Significant Bit) format.
|
||||||
|
*
|
||||||
|
* The cursor width (`w`) must be a multiple of 8 bits.
|
||||||
|
*
|
||||||
|
* The cursor is created in black and white according to the following:
|
||||||
|
*
|
||||||
|
* - data=0, mask=1: white
|
||||||
|
* - data=1, mask=1: black
|
||||||
|
* - data=0, mask=0: transparent
|
||||||
|
* - data=1, mask=0: inverted color if possible, black if not.
|
||||||
|
*
|
||||||
|
* Cursors created with this function must be freed with SDL_DestroyCursor().
|
||||||
|
*
|
||||||
|
* If you want to have a color cursor, or create your cursor from an
|
||||||
|
* SDL_Surface, you should use SDL_CreateColorCursor(). Alternately, you can
|
||||||
|
* hide the cursor and draw your own as part of your game's rendering, but it
|
||||||
|
* will be bound to the framerate.
|
||||||
|
*
|
||||||
|
* Also, SDL_CreateSystemCursor() is available, which provides several
|
||||||
|
* readily-available system cursors to pick from.
|
||||||
|
*
|
||||||
|
* \param data the color value for each pixel of the cursor.
|
||||||
|
* \param mask the mask value for each pixel of the cursor.
|
||||||
|
* \param w the width of the cursor.
|
||||||
|
* \param h the height of the cursor.
|
||||||
|
* \param hot_x the x-axis offset from the left of the cursor image to the
|
||||||
|
* mouse x position, in the range of 0 to `w` - 1.
|
||||||
|
* \param hot_y the y-axis offset from the top of the cursor image to the
|
||||||
|
* mouse y position, in the range of 0 to `h` - 1.
|
||||||
|
* \returns a new cursor with the specified parameters on success or NULL on
|
||||||
|
* failure; call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateAnimatedCursor
|
||||||
|
* \sa SDL_CreateColorCursor
|
||||||
|
* \sa SDL_CreateSystemCursor
|
||||||
|
* \sa SDL_DestroyCursor
|
||||||
|
* \sa SDL_SetCursor
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateCursor")] public static extern Cursor* CreateCursor(Uint8* data, Uint8* mask, c_int w, c_int h, c_int hot_x, c_int hot_y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a color cursor.
|
||||||
|
*
|
||||||
|
* If this function is passed a surface with alternate representations added
|
||||||
|
* with SDL_AddSurfaceAlternateImage(), the surface will be interpreted as the
|
||||||
|
* content to be used for 100% display scale, and the alternate
|
||||||
|
* representations will be used for high DPI situations if
|
||||||
|
* SDL_HINT_MOUSE_DPI_SCALE_CURSORS is enabled. For example, if the original
|
||||||
|
* surface is 32x32, then on a 2x macOS display or 200% display scale on
|
||||||
|
* Windows, a 64x64 version of the image will be used, if available. If a
|
||||||
|
* matching version of the image isn't available, the closest larger size
|
||||||
|
* image will be downscaled to the appropriate size and be used instead, if
|
||||||
|
* available. Otherwise, the closest smaller image will be upscaled and be
|
||||||
|
* used instead.
|
||||||
|
*
|
||||||
|
* \param surface an SDL_Surface structure representing the cursor image.
|
||||||
|
* \param hot_x the x position of the cursor hot spot.
|
||||||
|
* \param hot_y the y position of the cursor hot spot.
|
||||||
|
* \returns the new cursor on success or NULL on failure; call SDL_GetError()
|
||||||
|
* for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AddSurfaceAlternateImage
|
||||||
|
* \sa SDL_CreateAnimatedCursor
|
||||||
|
* \sa SDL_CreateCursor
|
||||||
|
* \sa SDL_CreateSystemCursor
|
||||||
|
* \sa SDL_DestroyCursor
|
||||||
|
* \sa SDL_SetCursor
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateColorCursor")] public static extern Cursor* CreateColorCursor(Surface* surface, c_int hot_x, c_int hot_y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an animated color cursor.
|
||||||
|
*
|
||||||
|
* Animated cursors are composed of a sequential array of frames, specified as
|
||||||
|
* surfaces and durations in an array of SDL_CursorFrameInfo structs. The hot
|
||||||
|
* spot coordinates are universal to all frames, and all frames must have the
|
||||||
|
* same dimensions.
|
||||||
|
*
|
||||||
|
* Frame durations are specified in milliseconds. A duration of 0 implies an
|
||||||
|
* infinite frame time, and the animation will stop on that frame. To create a
|
||||||
|
* one-shot animation, set the duration of the last frame in the sequence to
|
||||||
|
* 0.
|
||||||
|
*
|
||||||
|
* If this function is passed surfaces with alternate representations added
|
||||||
|
* with SDL_AddSurfaceAlternateImage(), the surfaces will be interpreted as
|
||||||
|
* the content to be used for 100% display scale, and the alternate
|
||||||
|
* representations will be used for high DPI situations. For example, if the
|
||||||
|
* original surfaces are 32x32, then on a 2x macOS display or 200% display
|
||||||
|
* scale on Windows, a 64x64 version of the image will be used, if available.
|
||||||
|
* If a matching version of the image isn't available, the closest larger size
|
||||||
|
* image will be downscaled to the appropriate size and be used instead, if
|
||||||
|
* available. Otherwise, the closest smaller image will be upscaled and be
|
||||||
|
* used instead.
|
||||||
|
*
|
||||||
|
* If the underlying platform does not support animated cursors, this function
|
||||||
|
* will fall back to creating a static color cursor using the first frame in
|
||||||
|
* the sequence.
|
||||||
|
*
|
||||||
|
* \param frames an array of cursor images composing the animation.
|
||||||
|
* \param frame_count the number of frames in the sequence.
|
||||||
|
* \param hot_x the x position of the cursor hot spot.
|
||||||
|
* \param hot_y the y position of the cursor hot spot.
|
||||||
|
* \returns the new cursor on success or NULL on failure; call SDL_GetError()
|
||||||
|
* for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.4.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AddSurfaceAlternateImage
|
||||||
|
* \sa SDL_CreateCursor
|
||||||
|
* \sa SDL_CreateColorCursor
|
||||||
|
* \sa SDL_CreateSystemCursor
|
||||||
|
* \sa SDL_DestroyCursor
|
||||||
|
* \sa SDL_SetCursor
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateAnimatedCursor")] public static extern Cursor* CreateAnimatedCursor(CursorFrameInfo* frames, c_int frame_count, c_int hot_x, c_int hot_y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a system cursor.
|
||||||
|
*
|
||||||
|
* \param id an SDL_SystemCursor enum value.
|
||||||
|
* \returns a cursor on success or NULL on failure; call SDL_GetError() for
|
||||||
|
* more information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_DestroyCursor
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateSystemCursor")] public static extern Cursor* CreateSystemCursor(SystemCursor id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the active cursor.
|
||||||
|
*
|
||||||
|
* This function sets the currently active cursor to the specified one. If the
|
||||||
|
* cursor is currently visible, the change will be immediately represented on
|
||||||
|
* the display. SDL_SetCursor(NULL) can be used to force cursor redraw, if
|
||||||
|
* this is desired for any reason.
|
||||||
|
*
|
||||||
|
* \param cursor a cursor to make active.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetCursor
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetCursor")] public static extern bool SetCursor(Cursor* cursor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the active cursor.
|
||||||
|
*
|
||||||
|
* This function returns a pointer to the current cursor which is owned by the
|
||||||
|
* library. It is not necessary to free the cursor with SDL_DestroyCursor().
|
||||||
|
*
|
||||||
|
* \returns the active cursor or NULL if there is no mouse.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetCursor
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetCursor")] public static extern Cursor* GetCursor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default cursor.
|
||||||
|
*
|
||||||
|
* You do not have to call SDL_DestroyCursor() on the return value, but it is
|
||||||
|
* safe to do so.
|
||||||
|
*
|
||||||
|
* \returns the default cursor on success or NULL on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetDefaultCursor")] public static extern Cursor* GetDefaultCursor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free a previously-created cursor.
|
||||||
|
*
|
||||||
|
* Use this function to free cursor resources created with SDL_CreateCursor(),
|
||||||
|
* SDL_CreateColorCursor() or SDL_CreateSystemCursor().
|
||||||
|
*
|
||||||
|
* \param cursor the cursor to free.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateAnimatedCursor
|
||||||
|
* \sa SDL_CreateColorCursor
|
||||||
|
* \sa SDL_CreateCursor
|
||||||
|
* \sa SDL_CreateSystemCursor
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_DestroyCursor")] public static extern void DestroyCursor(Cursor* cursor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the cursor.
|
||||||
|
*
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CursorVisible
|
||||||
|
* \sa SDL_HideCursor
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ShowCursor")] public static extern bool ShowCursor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide the cursor.
|
||||||
|
*
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CursorVisible
|
||||||
|
* \sa SDL_ShowCursor
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HideCursor")] public static extern bool HideCursor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether the cursor is currently being shown.
|
||||||
|
*
|
||||||
|
* \returns `true` if the cursor is being shown, or `false` if the cursor is
|
||||||
|
* hidden.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HideCursor
|
||||||
|
* \sa SDL_ShowCursor
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CursorVisible")] public static extern bool CursorVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_mouse_h_ */
|
||||||
1083
src/SDL_mutex.bf
Normal file
1083
src/SDL_mutex.bf
Normal file
File diff suppressed because it is too large
Load Diff
1335
src/SDL_oldnames.bf
Normal file
1335
src/SDL_oldnames.bf
Normal file
File diff suppressed because it is too large
Load Diff
242
src/SDL_openxr.bf
Normal file
242
src/SDL_openxr.bf
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryOpenXR
|
||||||
|
*
|
||||||
|
* Functions for creating OpenXR handles for SDL_gpu contexts.
|
||||||
|
*
|
||||||
|
* For the most part, OpenXR operates independent of SDL, but
|
||||||
|
* the graphics initialization depends on direct support from SDL_gpu.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* OPENXR_H_ */
|
||||||
|
|
||||||
|
|
||||||
|
public const let XR_NULL_HANDLE = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* XR_DEFINE_HANDLE */
|
||||||
|
|
||||||
|
[AllowDuplicates] public enum XrStructureType : c_int {
|
||||||
|
XR_TYPE_SESSION_CREATE_INFO = 8,
|
||||||
|
XR_TYPE_SWAPCHAIN_CREATE_INFO = 9,
|
||||||
|
}
|
||||||
|
|
||||||
|
public typealias XrInstance = Uint64;
|
||||||
|
public typealias XrSystemId = Uint64;
|
||||||
|
public typealias XrSession = Uint64;
|
||||||
|
public typealias XrSwapchain = Uint64;
|
||||||
|
|
||||||
|
[CRepr] public struct XrSessionCreateInfo {
|
||||||
|
public XrStructureType type;
|
||||||
|
public void* next;
|
||||||
|
}
|
||||||
|
[CRepr] public struct XrSwapchainCreateInfo {
|
||||||
|
public XrStructureType type;
|
||||||
|
public void* next;
|
||||||
|
}
|
||||||
|
|
||||||
|
[AllowDuplicates] public enum XrResult : c_int {
|
||||||
|
XR_ERROR_FUNCTION_UNSUPPORTED = -7,
|
||||||
|
XR_ERROR_HANDLE_INVALID = -12,
|
||||||
|
}
|
||||||
|
|
||||||
|
public typealias PFN_xrGetInstanceProcAddr = SDL.FunctionPointer;
|
||||||
|
/* NO_SDL_OPENXR_TYPEDEFS */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an OpenXR session.
|
||||||
|
*
|
||||||
|
* The OpenXR system ID is pulled from the passed GPU context.
|
||||||
|
*
|
||||||
|
* \param device a GPU context.
|
||||||
|
* \param createinfo the create info for the OpenXR session, sans the system
|
||||||
|
* ID.
|
||||||
|
* \param session a pointer filled in with an OpenXR session created for the
|
||||||
|
* given device.
|
||||||
|
* \returns the result of the call.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.6.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateGPUDeviceWithProperties
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateGPUXRSession")] public static extern XrResult CreateGPUXRSession(GPUDevice* device, XrSessionCreateInfo* createinfo, out XrSession session);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queries the GPU device for supported XR swapchain image formats.
|
||||||
|
*
|
||||||
|
* The returned pointer should be allocated with SDL_malloc() and will be
|
||||||
|
* passed to SDL_free().
|
||||||
|
*
|
||||||
|
* \param device a GPU context.
|
||||||
|
* \param session an OpenXR session created for the given device.
|
||||||
|
* \param num_formats a pointer filled with the number of supported XR
|
||||||
|
* swapchain formats.
|
||||||
|
* \returns a 0 terminated array of supported formats or NULL on failure; call
|
||||||
|
* SDL_GetError() for more information. This should be freed with
|
||||||
|
* SDL_free() when it is no longer needed.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.6.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateGPUXRSwapchain
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetGPUXRSwapchainFormats")] public static extern GPUTextureFormat* GetGPUXRSwapchainFormats(GPUDevice* device, XrSession session, c_int* num_formats);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an OpenXR swapchain.
|
||||||
|
*
|
||||||
|
* The array returned via `textures` is sized according to
|
||||||
|
* `xrEnumerateSwapchainImages`, and thus should only be accessed via index
|
||||||
|
* values returned from `xrAcquireSwapchainImage`.
|
||||||
|
*
|
||||||
|
* Applications are still allowed to call `xrEnumerateSwapchainImages` on the
|
||||||
|
* returned XrSwapchain if they need to get the exact size of the array.
|
||||||
|
*
|
||||||
|
* \param device a GPU context.
|
||||||
|
* \param session an OpenXR session created for the given device.
|
||||||
|
* \param createinfo the create info for the OpenXR swapchain, sans the
|
||||||
|
* format.
|
||||||
|
* \param format a supported format for the OpenXR swapchain.
|
||||||
|
* \param swapchain a pointer filled in with the created OpenXR swapchain.
|
||||||
|
* \param textures a pointer filled in with the array of created swapchain
|
||||||
|
* images.
|
||||||
|
* \returns the result of the call.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.6.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateGPUDeviceWithProperties
|
||||||
|
* \sa SDL_CreateGPUXRSession
|
||||||
|
* \sa SDL_GetGPUXRSwapchainFormats
|
||||||
|
* \sa SDL_DestroyGPUXRSwapchain
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateGPUXRSwapchain")] public static extern XrResult CreateGPUXRSwapchain(GPUDevice* device, XrSession session, XrSwapchainCreateInfo* createinfo, GPUTextureFormat format, out XrSwapchain swapchain, out GPUTexture** textures);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys and OpenXR swapchain previously returned by
|
||||||
|
* SDL_CreateGPUXRSwapchain.
|
||||||
|
*
|
||||||
|
* \param device a GPU context.
|
||||||
|
* \param swapchain a swapchain previously returned by
|
||||||
|
* SDL_CreateGPUXRSwapchain.
|
||||||
|
* \param swapchainImages an array of swapchain images returned by the same
|
||||||
|
* call to SDL_CreateGPUXRSwapchain.
|
||||||
|
* \returns the result of the call.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.6.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateGPUDeviceWithProperties
|
||||||
|
* \sa SDL_CreateGPUXRSession
|
||||||
|
* \sa SDL_CreateGPUXRSwapchain
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_DestroyGPUXRSwapchain")] public static extern XrResult DestroyGPUXRSwapchain(GPUDevice* device, XrSwapchain swapchain, GPUTexture** swapchainImages);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamically load the OpenXR loader.
|
||||||
|
*
|
||||||
|
* This can be called at any time.
|
||||||
|
*
|
||||||
|
* SDL keeps a reference count of the OpenXR loader, calling this function
|
||||||
|
* multiple times will increment that count, rather than loading the library
|
||||||
|
* multiple times.
|
||||||
|
*
|
||||||
|
* If not called, this will be implicitly called when creating a GPU device
|
||||||
|
* with OpenXR.
|
||||||
|
*
|
||||||
|
* This function will use the platform default OpenXR loader name, unless the
|
||||||
|
* `SDL_HINT_OPENXR_LIBRARY` hint is set.
|
||||||
|
*
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.6.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HINT_OPENXR_LIBRARY
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OpenXR_LoadLibrary")] public static extern bool OpenXR_LoadLibrary();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unload the OpenXR loader previously loaded by SDL_OpenXR_LoadLibrary.
|
||||||
|
*
|
||||||
|
* SDL keeps a reference count of the OpenXR loader, calling this function
|
||||||
|
* will decrement that count. Once the reference count reaches zero, the
|
||||||
|
* library is unloaded.
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.6.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OpenXR_UnloadLibrary")] public static extern void OpenXR_UnloadLibrary();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the address of the `xrGetInstanceProcAddr` function.
|
||||||
|
*
|
||||||
|
* This should be called after either calling SDL_OpenXR_LoadLibrary() or
|
||||||
|
* creating an OpenXR SDL_GPUDevice.
|
||||||
|
*
|
||||||
|
* The actual type of the returned function pointer is
|
||||||
|
* PFN_xrGetInstanceProcAddr, but that isn't always available. You should
|
||||||
|
* include the OpenXR headers before this header, or cast the return value of
|
||||||
|
* this function to the correct type.
|
||||||
|
*
|
||||||
|
* \returns the function pointer for `xrGetInstanceProcAddr` or NULL on
|
||||||
|
* failure; call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.6.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OpenXR_GetXrGetInstanceProcAddr")] public static extern FunctionPointer OpenXR_GetXrGetInstanceProcAddr();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_openxr_h_ */
|
||||||
209
src/SDL_pen.bf
Normal file
209
src/SDL_pen.bf
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryPen
|
||||||
|
*
|
||||||
|
* SDL pen event handling.
|
||||||
|
*
|
||||||
|
* SDL provides an API for pressure-sensitive pen (stylus and/or eraser)
|
||||||
|
* handling, e.g., for input and drawing tablets or suitably equipped mobile /
|
||||||
|
* tablet devices.
|
||||||
|
*
|
||||||
|
* To get started with pens, simply handle pen events:
|
||||||
|
*
|
||||||
|
* - SDL_EVENT_PEN_PROXIMITY_IN, SDL_EVENT_PEN_PROXIMITY_OUT
|
||||||
|
* (SDL_PenProximityEvent)
|
||||||
|
* - SDL_EVENT_PEN_DOWN, SDL_EVENT_PEN_UP (SDL_PenTouchEvent)
|
||||||
|
* - SDL_EVENT_PEN_MOTION (SDL_PenMotionEvent)
|
||||||
|
* - SDL_EVENT_PEN_BUTTON_DOWN, SDL_EVENT_PEN_BUTTON_UP (SDL_PenButtonEvent)
|
||||||
|
* - SDL_EVENT_PEN_AXIS (SDL_PenAxisEvent)
|
||||||
|
*
|
||||||
|
* Pens may provide more than simple touch input; they might have other axes,
|
||||||
|
* such as pressure, tilt, rotation, etc.
|
||||||
|
*
|
||||||
|
* When a pen starts providing input, SDL will assign it a unique SDL_PenID,
|
||||||
|
* which will remain for the life of the process, as long as the pen stays
|
||||||
|
* connected. A pen leaving proximity (being taken far enough away from the
|
||||||
|
* digitizer tablet that it no longer reponds) and then coming back should
|
||||||
|
* fire proximity events, but the SDL_PenID should remain consistent.
|
||||||
|
* Unplugging the digitizer and reconnecting may cause future input to have a
|
||||||
|
* new SDL_PenID, as SDL may not know that this is the same hardware.
|
||||||
|
*
|
||||||
|
* Please note that various platforms vary wildly in how (and how well) they
|
||||||
|
* support pen input. If your pen supports some piece of functionality but SDL
|
||||||
|
* doesn't seem to, it might actually be the operating system's fault. For
|
||||||
|
* example, some platforms can manage multiple devices at the same time, but
|
||||||
|
* others will make any connected pens look like a single logical device, much
|
||||||
|
* how all USB mice connected to a computer will move the same system cursor.
|
||||||
|
* Other platforms might not support pen buttons, or the distance axis, etc.
|
||||||
|
* Very few platforms can even report _what_ functionality the pen supports in
|
||||||
|
* the first place, so best practices is to either build UI to let the user
|
||||||
|
* configure their pens, or be prepared to handle new functionality for a pen
|
||||||
|
* the first time an event is reported.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SDL pen instance IDs.
|
||||||
|
*
|
||||||
|
* Zero is used to signify an invalid/null device.
|
||||||
|
*
|
||||||
|
* These show up in pen events when SDL sees input from them. They remain
|
||||||
|
* consistent as long as SDL can recognize a tool to be the same pen; but if a
|
||||||
|
* pen's digitizer table is physically detached from the computer, it might
|
||||||
|
* get a new ID when reconnected, as SDL won't know it's the same device.
|
||||||
|
*
|
||||||
|
* These IDs are only stable within a single run of a program; the next time a
|
||||||
|
* program is run, the pen's ID will likely be different, even if the hardware
|
||||||
|
* hasn't been disconnected, etc.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public typealias PenID = Uint32;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SDL_MouseID for mouse events simulated with pen input.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public const let PEN_MOUSEID = ((SDL.MouseID)-2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SDL_TouchID for touch events simulated with pen input.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public const let PEN_TOUCHID = ((SDL.TouchID)-2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pen input flags, as reported by various pen events' `pen_state` field.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public enum PenInputFlags : Uint32
|
||||||
|
{
|
||||||
|
Down = (1u << 0), /**< pen is pressed down */
|
||||||
|
Button1 = (1u << 1), /**< button 1 is pressed */
|
||||||
|
Button2 = (1u << 2), /**< button 2 is pressed */
|
||||||
|
Button3 = (1u << 3), /**< button 3 is pressed */
|
||||||
|
Button4 = (1u << 4), /**< button 4 is pressed */
|
||||||
|
Button5 = (1u << 5), /**< button 5 is pressed */
|
||||||
|
EraserTip = (1u << 30), /**< eraser tip is used */
|
||||||
|
InProximity = (1u << 31), /**< pen is in proximity (since SDL 3.4.0) */
|
||||||
|
} /**< pen is in proximity (since SDL 3.4.0) */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pen axis indices.
|
||||||
|
*
|
||||||
|
* These are the valid values for the `axis` field in SDL_PenAxisEvent. All
|
||||||
|
* axes are either normalised to 0..1 or report a (positive or negative) angle
|
||||||
|
* in degrees, with 0.0 representing the centre. Not all pens/backends support
|
||||||
|
* all axes: unsupported axes are always zero.
|
||||||
|
*
|
||||||
|
* To convert angles for tilt and rotation into vector representation, use
|
||||||
|
* SDL_sinf on the XTILT, YTILT, or ROTATION component, for example:
|
||||||
|
*
|
||||||
|
* `SDL_sinf(xtilt * SDL_PI_F / 180.0)`.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum PenAxis : c_int
|
||||||
|
{
|
||||||
|
Pressure, /**< Pen pressure. Unidirectional: 0 to 1.0 */
|
||||||
|
Xtilt, /**< Pen horizontal tilt angle. Bidirectional: -90.0 to 90.0 (left-to-right). */
|
||||||
|
Ytilt, /**< Pen vertical tilt angle. Bidirectional: -90.0 to 90.0 (top-to-down). */
|
||||||
|
Distance, /**< Pen distance to drawing surface. Unidirectional: 0.0 to 1.0 */
|
||||||
|
Rotation, /**< Pen barrel rotation. Bidirectional: -180 to 179.9 (clockwise, 0 is facing up, -180.0 is facing down). */
|
||||||
|
Slider, /**< Pen finger wheel or slider (e.g., Airbrush Pen). Unidirectional: 0 to 1.0 */
|
||||||
|
TangentialPressure, /**< Pressure from squeezing the pen ("barrel pressure"). */
|
||||||
|
Count, /**< Total known pen axis types in this version of SDL. This number may grow in future releases! */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An enum that describes the type of a pen device.
|
||||||
|
*
|
||||||
|
* A "direct" device is a pen that touches a graphic display (like an Apple
|
||||||
|
* Pencil on an iPad's screen). "Indirect" devices touch an external tablet
|
||||||
|
* surface that is connected to the machine but is not a display (like a
|
||||||
|
* lower-end Wacom tablet connected over USB).
|
||||||
|
*
|
||||||
|
* Apps may use this information to decide if they should draw a cursor; if
|
||||||
|
* the pen is touching the screen directly, a cursor doesn't make sense and
|
||||||
|
* can be in the way, but becomes necessary for indirect devices to know where
|
||||||
|
* on the display they are interacting.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.4.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum PenDeviceType : c_int
|
||||||
|
{
|
||||||
|
Invalid = -1, /**< Not a valid pen device. */
|
||||||
|
Unknown, /**< Don't know specifics of this pen. */
|
||||||
|
Direct, /**< Pen touches display. */
|
||||||
|
Indirect, /**< Pen touches something that isn't the display. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the device type of the given pen.
|
||||||
|
*
|
||||||
|
* Many platforms do not supply this information, so an app must always be
|
||||||
|
* prepared to get an SDL_PEN_DEVICE_TYPE_UNKNOWN result.
|
||||||
|
*
|
||||||
|
* \param instance_id the pen instance ID.
|
||||||
|
* \returns the device type of the given pen, or SDL_PEN_DEVICE_TYPE_INVALID
|
||||||
|
* on failure; call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.4.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetPenDeviceType")] public static extern PenDeviceType GetPenDeviceType(PenID instance_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_pen_h_ */
|
||||||
1451
src/SDL_pixels.bf
Normal file
1451
src/SDL_pixels.bf
Normal file
File diff suppressed because it is too large
Load Diff
75
src/SDL_platform.bf
Normal file
75
src/SDL_platform.bf
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryPlatform
|
||||||
|
*
|
||||||
|
* SDL provides a means to identify the app's platform, both at compile time
|
||||||
|
* and runtime.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the platform.
|
||||||
|
*
|
||||||
|
* Here are the names returned for some (but not all) supported platforms:
|
||||||
|
*
|
||||||
|
* - "Windows"
|
||||||
|
* - "macOS"
|
||||||
|
* - "Linux"
|
||||||
|
* - "iOS"
|
||||||
|
* - "Android"
|
||||||
|
*
|
||||||
|
* \returns the name of the platform. If the correct platform name is not
|
||||||
|
* available, returns a string beginning with the text "Unknown".
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetPlatform")] public static extern c_char* GetPlatform();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_platform_h_ */
|
||||||
505
src/SDL_platform_defines.bf
Normal file
505
src/SDL_platform_defines.bf
Normal file
@@ -0,0 +1,505 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* WIKI CATEGORY: Platform */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SDL_platform_defines.h tries to get a standard set of platform defines.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for AIX.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Haiku OS.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for BSDi
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for FreeBSD.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for HP-UX.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for IRIX.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Linux.
|
||||||
|
*
|
||||||
|
* Note that Android, although ostensibly a Linux-based system, will not
|
||||||
|
* define this. It defines SDL_PLATFORM_ANDROID instead.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Android.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for a Unix-like
|
||||||
|
* system.
|
||||||
|
*
|
||||||
|
* Other platforms, like Linux, might define this in addition to their primary
|
||||||
|
* define.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Apple platforms.
|
||||||
|
*
|
||||||
|
* iOS, macOS, etc will additionally define a more specific platform macro.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_PLATFORM_MACOS
|
||||||
|
* \sa SDL_PLATFORM_IOS
|
||||||
|
* \sa SDL_PLATFORM_TVOS
|
||||||
|
* \sa SDL_PLATFORM_VISIONOS
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* lets us know what version of macOS we're compiling on */
|
||||||
|
|
||||||
|
/* Older compilers don't support this */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Fix building with older SDKs that don't define these
|
||||||
|
See this for more information:
|
||||||
|
https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for tvOS.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_PLATFORM_APPLE
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for visionOS.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_PLATFORM_APPLE
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for iOS or visionOS.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_PLATFORM_APPLE
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for macOS.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_PLATFORM_APPLE
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* MAC_OS_X_VERSION_MIN_REQUIRED < 1070 */
|
||||||
|
/* TARGET_OS_IPHONE */
|
||||||
|
/* defined(__APPLE__) */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Emscripten.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for NetBSD.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for OpenBSD.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for OS/2.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Tru64 (OSF/1).
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for QNX Neutrino.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for RISC OS.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for SunOS/Solaris.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Cygwin.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Windows.
|
||||||
|
*
|
||||||
|
* This also covers several other platforms, like Microsoft GDK, Xbox, WinRT,
|
||||||
|
* etc. Each will have their own more-specific platform macros, too.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_PLATFORM_WIN32
|
||||||
|
* \sa SDL_PLATFORM_XBOXONE
|
||||||
|
* \sa SDL_PLATFORM_XBOXSERIES
|
||||||
|
* \sa SDL_PLATFORM_WINGDK
|
||||||
|
* \sa SDL_PLATFORM_GDK
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Try to find out if we're compiling for WinRT, GDK or non-WinRT/GDK */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */
|
||||||
|
/* _MSC_VER == 1700 for Visual Studio 2012 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* HAVE_WINAPIFAMILY_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that defined to 1 if compiling for Windows Phone.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* GDK project configuration always defines _GAMING_XXX */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Microsoft GDK
|
||||||
|
* for Windows.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Xbox One.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Xbox Series.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for desktop Windows.
|
||||||
|
*
|
||||||
|
* Despite the "32", this also covers 64-bit Windows; as an informal
|
||||||
|
* convention, its system layer tends to still be referred to as "the Win32
|
||||||
|
* API."
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) */
|
||||||
|
|
||||||
|
|
||||||
|
/* This is to support generic "any GDK" separate from a platform-specific GDK */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Microsoft GDK on
|
||||||
|
* any platform.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Sony PSP.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Sony PlayStation
|
||||||
|
* 2.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Sony Vita.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for Nintendo 3DS.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for the Nokia
|
||||||
|
* N-Gage.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.4.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A preprocessor macro that is only defined if compiling for GNU/Hurd.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.4.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_platform_defines_h_ */
|
||||||
117
src/SDL_power.bf
Normal file
117
src/SDL_power.bf
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryPower
|
||||||
|
*
|
||||||
|
* SDL power management routines.
|
||||||
|
*
|
||||||
|
* There is a single function in this category: SDL_GetPowerInfo().
|
||||||
|
*
|
||||||
|
* This function is useful for games on the go. This allows an app to know if
|
||||||
|
* it's running on a draining battery, which can be useful if the app wants to
|
||||||
|
* reduce processing, or perhaps framerate, to extend the duration of the
|
||||||
|
* battery's charge. Perhaps the app just wants to show a battery meter when
|
||||||
|
* fullscreen, or alert the user when the power is getting extremely low, so
|
||||||
|
* they can save their game.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The basic state for the system's power supply.
|
||||||
|
*
|
||||||
|
* These are results returned by SDL_GetPowerInfo().
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum PowerState : c_int
|
||||||
|
{
|
||||||
|
Error = -1, /**< error determining power status */
|
||||||
|
Unknown, /**< cannot determine power status */
|
||||||
|
OnBattery, /**< Not plugged in, running on the battery */
|
||||||
|
NoBattery, /**< Plugged in, no battery available */
|
||||||
|
Charging, /**< Plugged in, charging battery */
|
||||||
|
Charged, /**< Plugged in, battery charged */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current power supply details.
|
||||||
|
*
|
||||||
|
* You should never take a battery status as absolute truth. Batteries
|
||||||
|
* (especially failing batteries) are delicate hardware, and the values
|
||||||
|
* reported here are best estimates based on what that hardware reports. It's
|
||||||
|
* not uncommon for older batteries to lose stored power much faster than it
|
||||||
|
* reports, or completely drain when reporting it has 20 percent left, etc.
|
||||||
|
*
|
||||||
|
* Battery status can change at any time; if you are concerned with power
|
||||||
|
* state, you should call this function frequently, and perhaps ignore changes
|
||||||
|
* until they seem to be stable for a few seconds.
|
||||||
|
*
|
||||||
|
* It's possible a platform can only report battery percentage or time left
|
||||||
|
* but not both.
|
||||||
|
*
|
||||||
|
* On some platforms, retrieving power supply details might be expensive. If
|
||||||
|
* you want to display continuous status you could call this function every
|
||||||
|
* minute or so.
|
||||||
|
*
|
||||||
|
* \param seconds a pointer filled in with the seconds of battery life left,
|
||||||
|
* or NULL to ignore. This will be filled in with -1 if we
|
||||||
|
* can't determine a value or there is no battery.
|
||||||
|
* \param percent a pointer filled in with the percentage of battery life
|
||||||
|
* left, between 0 and 100, or NULL to ignore. This will be
|
||||||
|
* filled in with -1 when we can't determine a value or there
|
||||||
|
* is no battery.
|
||||||
|
* \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure;
|
||||||
|
* call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetPowerInfo")] public static extern PowerState GetPowerInfo(out c_int seconds, out c_int percent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_power_h_ */
|
||||||
452
src/SDL_process.bf
Normal file
452
src/SDL_process.bf
Normal file
@@ -0,0 +1,452 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryProcess
|
||||||
|
*
|
||||||
|
* Process control support.
|
||||||
|
*
|
||||||
|
* These functions provide a cross-platform way to spawn and manage OS-level
|
||||||
|
* processes.
|
||||||
|
*
|
||||||
|
* You can create a new subprocess with SDL_CreateProcess() and optionally
|
||||||
|
* read and write to it using SDL_ReadProcess() or SDL_GetProcessInput() and
|
||||||
|
* SDL_GetProcessOutput(). If more advanced functionality like chaining input
|
||||||
|
* between processes is necessary, you can use
|
||||||
|
* SDL_CreateProcessWithProperties().
|
||||||
|
*
|
||||||
|
* You can get the status of a created process with SDL_WaitProcess(), or
|
||||||
|
* terminate the process with SDL_KillProcess().
|
||||||
|
*
|
||||||
|
* Don't forget to call SDL_DestroyProcess() to clean up, whether the process
|
||||||
|
* process was killed, terminated on its own, or is still running!
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An opaque handle representing a system process.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateProcess
|
||||||
|
*/
|
||||||
|
[CRepr] public struct Process;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new process.
|
||||||
|
*
|
||||||
|
* The path to the executable is supplied in args[0]. args[1..N] are
|
||||||
|
* additional arguments passed on the command line of the new process, and the
|
||||||
|
* argument list should be terminated with a NULL, e.g.:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* const char *args[] = { "myprogram", "argument", NULL };
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Setting pipe_stdio to true is equivalent to setting
|
||||||
|
* `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER` and
|
||||||
|
* `SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER` to `SDL_PROCESS_STDIO_APP`, and
|
||||||
|
* will allow the use of SDL_ReadProcess() or SDL_GetProcessInput() and
|
||||||
|
* SDL_GetProcessOutput().
|
||||||
|
*
|
||||||
|
* See SDL_CreateProcessWithProperties() for more details.
|
||||||
|
*
|
||||||
|
* \param args the path and arguments for the new process.
|
||||||
|
* \param pipe_stdio true to create pipes to the process's standard input and
|
||||||
|
* from the process's standard output, false for the process
|
||||||
|
* to have no input and inherit the application's standard
|
||||||
|
* output.
|
||||||
|
* \returns the newly created and running process, or NULL if the process
|
||||||
|
* couldn't be created.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateProcessWithProperties
|
||||||
|
* \sa SDL_GetProcessProperties
|
||||||
|
* \sa SDL_ReadProcess
|
||||||
|
* \sa SDL_GetProcessInput
|
||||||
|
* \sa SDL_GetProcessOutput
|
||||||
|
* \sa SDL_KillProcess
|
||||||
|
* \sa SDL_WaitProcess
|
||||||
|
* \sa SDL_DestroyProcess
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateProcess")] public static extern Process* CreateProcess(c_char** args, bool pipe_stdio);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description of where standard I/O should be directed when creating a
|
||||||
|
* process.
|
||||||
|
*
|
||||||
|
* If a standard I/O stream is set to SDL_PROCESS_STDIO_INHERITED, it will go
|
||||||
|
* to the same place as the application's I/O stream. This is the default for
|
||||||
|
* standard output and standard error.
|
||||||
|
*
|
||||||
|
* If a standard I/O stream is set to SDL_PROCESS_STDIO_NULL, it is connected
|
||||||
|
* to `NUL:` on Windows and `/dev/null` on POSIX systems. This is the default
|
||||||
|
* for standard input.
|
||||||
|
*
|
||||||
|
* If a standard I/O stream is set to SDL_PROCESS_STDIO_APP, it is connected
|
||||||
|
* to a new SDL_IOStream that is available to the application. Standard input
|
||||||
|
* will be available as `SDL_PROP_PROCESS_STDIN_POINTER` and allows
|
||||||
|
* SDL_GetProcessInput(), standard output will be available as
|
||||||
|
* `SDL_PROP_PROCESS_STDOUT_POINTER` and allows SDL_ReadProcess() and
|
||||||
|
* SDL_GetProcessOutput(), and standard error will be available as
|
||||||
|
* `SDL_PROP_PROCESS_STDERR_POINTER` in the properties for the created
|
||||||
|
* process.
|
||||||
|
*
|
||||||
|
* If a standard I/O stream is set to SDL_PROCESS_STDIO_REDIRECT, it is
|
||||||
|
* connected to an existing SDL_IOStream provided by the application. Standard
|
||||||
|
* input is provided using `SDL_PROP_PROCESS_CREATE_STDIN_POINTER`, standard
|
||||||
|
* output is provided using `SDL_PROP_PROCESS_CREATE_STDOUT_POINTER`, and
|
||||||
|
* standard error is provided using `SDL_PROP_PROCESS_CREATE_STDERR_POINTER`
|
||||||
|
* in the creation properties. These existing streams should be closed by the
|
||||||
|
* application once the new process is created.
|
||||||
|
*
|
||||||
|
* In order to use an SDL_IOStream with SDL_PROCESS_STDIO_REDIRECT, it must
|
||||||
|
* have `SDL_PROP_IOSTREAM_WINDOWS_HANDLE_POINTER` or
|
||||||
|
* `SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER` set. This is true for streams
|
||||||
|
* representing files and process I/O.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateProcessWithProperties
|
||||||
|
* \sa SDL_GetProcessProperties
|
||||||
|
* \sa SDL_ReadProcess
|
||||||
|
* \sa SDL_GetProcessInput
|
||||||
|
* \sa SDL_GetProcessOutput
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum ProcessIO : c_int
|
||||||
|
{
|
||||||
|
StdioInherited, /**< The I/O stream is inherited from the application. */
|
||||||
|
StdioNull, /**< The I/O stream is ignored. */
|
||||||
|
StdioApp, /**< The I/O stream is connected to a new SDL_IOStream that the application can read or write */
|
||||||
|
StdioRedirect, /**< The I/O stream is redirected to an existing SDL_IOStream. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new process with the specified properties.
|
||||||
|
*
|
||||||
|
* These are the supported properties:
|
||||||
|
*
|
||||||
|
* - `SDL_PROP_PROCESS_CREATE_ARGS_POINTER`: an array of strings containing
|
||||||
|
* the program to run, any arguments, and a NULL pointer, e.g. const char
|
||||||
|
* *args[] = { "myprogram", "argument", NULL }. This is a required property.
|
||||||
|
* - `SDL_PROP_PROCESS_CREATE_ENVIRONMENT_POINTER`: an SDL_Environment
|
||||||
|
* pointer. If this property is set, it will be the entire environment for
|
||||||
|
* the process, otherwise the current environment is used.
|
||||||
|
* - `SDL_PROP_PROCESS_CREATE_WORKING_DIRECTORY_STRING`: a UTF-8 encoded
|
||||||
|
* string representing the working directory for the process, defaults to
|
||||||
|
* the current working directory.
|
||||||
|
* - `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER`: an SDL_ProcessIO value describing
|
||||||
|
* where standard input for the process comes from, defaults to
|
||||||
|
* `SDL_PROCESS_STDIO_NULL`.
|
||||||
|
* - `SDL_PROP_PROCESS_CREATE_STDIN_POINTER`: an SDL_IOStream pointer used for
|
||||||
|
* standard input when `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER` is set to
|
||||||
|
* `SDL_PROCESS_STDIO_REDIRECT`.
|
||||||
|
* - `SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER`: an SDL_ProcessIO value
|
||||||
|
* describing where standard output for the process goes to, defaults to
|
||||||
|
* `SDL_PROCESS_STDIO_INHERITED`.
|
||||||
|
* - `SDL_PROP_PROCESS_CREATE_STDOUT_POINTER`: an SDL_IOStream pointer used
|
||||||
|
* for standard output when `SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER` is set
|
||||||
|
* to `SDL_PROCESS_STDIO_REDIRECT`.
|
||||||
|
* - `SDL_PROP_PROCESS_CREATE_STDERR_NUMBER`: an SDL_ProcessIO value
|
||||||
|
* describing where standard error for the process goes to, defaults to
|
||||||
|
* `SDL_PROCESS_STDIO_INHERITED`.
|
||||||
|
* - `SDL_PROP_PROCESS_CREATE_STDERR_POINTER`: an SDL_IOStream pointer used
|
||||||
|
* for standard error when `SDL_PROP_PROCESS_CREATE_STDERR_NUMBER` is set to
|
||||||
|
* `SDL_PROCESS_STDIO_REDIRECT`.
|
||||||
|
* - `SDL_PROP_PROCESS_CREATE_STDERR_TO_STDOUT_BOOLEAN`: true if the error
|
||||||
|
* output of the process should be redirected into the standard output of
|
||||||
|
* the process. This property has no effect if
|
||||||
|
* `SDL_PROP_PROCESS_CREATE_STDERR_NUMBER` is set.
|
||||||
|
* - `SDL_PROP_PROCESS_CREATE_BACKGROUND_BOOLEAN`: true if the process should
|
||||||
|
* run in the background. In this case the default input and output is
|
||||||
|
* `SDL_PROCESS_STDIO_NULL` and the exitcode of the process is not
|
||||||
|
* available, and will always be 0.
|
||||||
|
* - `SDL_PROP_PROCESS_CREATE_CMDLINE_STRING`: a string containing the program
|
||||||
|
* to run and any parameters. This string is passed directly to
|
||||||
|
* `CreateProcess` on Windows, and does nothing on other platforms. This
|
||||||
|
* property is only important if you want to start programs that does
|
||||||
|
* non-standard command-line processing, and in most cases using
|
||||||
|
* `SDL_PROP_PROCESS_CREATE_ARGS_POINTER` is sufficient.
|
||||||
|
*
|
||||||
|
* On POSIX platforms, wait() and waitpid(-1, ...) should not be called, and
|
||||||
|
* SIGCHLD should not be ignored or handled because those would prevent SDL
|
||||||
|
* from properly tracking the lifetime of the underlying process. You should
|
||||||
|
* use SDL_WaitProcess() instead.
|
||||||
|
*
|
||||||
|
* \param props the properties to use.
|
||||||
|
* \returns the newly created and running process, or NULL if the process
|
||||||
|
* couldn't be created.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateProcess
|
||||||
|
* \sa SDL_GetProcessProperties
|
||||||
|
* \sa SDL_ReadProcess
|
||||||
|
* \sa SDL_GetProcessInput
|
||||||
|
* \sa SDL_GetProcessOutput
|
||||||
|
* \sa SDL_KillProcess
|
||||||
|
* \sa SDL_WaitProcess
|
||||||
|
* \sa SDL_DestroyProcess
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateProcessWithProperties")] public static extern Process* CreateProcessWithProperties(PropertiesID props);
|
||||||
|
|
||||||
|
public const let PROP_PROCESS_CREATE_ARGS_POINTER = "SDL.process.create.args";
|
||||||
|
public const let PROP_PROCESS_CREATE_ENVIRONMENT_POINTER = "SDL.process.create.environment";
|
||||||
|
public const let PROP_PROCESS_CREATE_WORKING_DIRECTORY_STRING = "SDL.process.create.working_directory";
|
||||||
|
public const let PROP_PROCESS_CREATE_STDIN_NUMBER = "SDL.process.create.stdin_option";
|
||||||
|
public const let PROP_PROCESS_CREATE_STDIN_POINTER = "SDL.process.create.stdin_source";
|
||||||
|
public const let PROP_PROCESS_CREATE_STDOUT_NUMBER = "SDL.process.create.stdout_option";
|
||||||
|
public const let PROP_PROCESS_CREATE_STDOUT_POINTER = "SDL.process.create.stdout_source";
|
||||||
|
public const let PROP_PROCESS_CREATE_STDERR_NUMBER = "SDL.process.create.stderr_option";
|
||||||
|
public const let PROP_PROCESS_CREATE_STDERR_POINTER = "SDL.process.create.stderr_source";
|
||||||
|
public const let PROP_PROCESS_CREATE_STDERR_TO_STDOUT_BOOLEAN = "SDL.process.create.stderr_to_stdout";
|
||||||
|
public const let PROP_PROCESS_CREATE_BACKGROUND_BOOLEAN = "SDL.process.create.background";
|
||||||
|
public const let PROP_PROCESS_CREATE_CMDLINE_STRING = "SDL.process.create.cmdline";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the properties associated with a process.
|
||||||
|
*
|
||||||
|
* The following read-only properties are provided by SDL:
|
||||||
|
*
|
||||||
|
* - `SDL_PROP_PROCESS_PID_NUMBER`: the process ID of the process.
|
||||||
|
* - `SDL_PROP_PROCESS_STDIN_POINTER`: an SDL_IOStream that can be used to
|
||||||
|
* write input to the process, if it was created with
|
||||||
|
* `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER` set to `SDL_PROCESS_STDIO_APP`.
|
||||||
|
* - `SDL_PROP_PROCESS_STDOUT_POINTER`: a non-blocking SDL_IOStream that can
|
||||||
|
* be used to read output from the process, if it was created with
|
||||||
|
* `SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER` set to `SDL_PROCESS_STDIO_APP`.
|
||||||
|
* - `SDL_PROP_PROCESS_STDERR_POINTER`: a non-blocking SDL_IOStream that can
|
||||||
|
* be used to read error output from the process, if it was created with
|
||||||
|
* `SDL_PROP_PROCESS_CREATE_STDERR_NUMBER` set to `SDL_PROCESS_STDIO_APP`.
|
||||||
|
* - `SDL_PROP_PROCESS_BACKGROUND_BOOLEAN`: true if the process is running in
|
||||||
|
* the background.
|
||||||
|
*
|
||||||
|
* \param process the process to query.
|
||||||
|
* \returns a valid property ID on success or 0 on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateProcess
|
||||||
|
* \sa SDL_CreateProcessWithProperties
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetProcessProperties")] public static extern PropertiesID GetProcessProperties(Process* process);
|
||||||
|
|
||||||
|
public const let PROP_PROCESS_PID_NUMBER = "SDL.process.pid";
|
||||||
|
public const let PROP_PROCESS_STDIN_POINTER = "SDL.process.stdin";
|
||||||
|
public const let PROP_PROCESS_STDOUT_POINTER = "SDL.process.stdout";
|
||||||
|
public const let PROP_PROCESS_STDERR_POINTER = "SDL.process.stderr";
|
||||||
|
public const let PROP_PROCESS_BACKGROUND_BOOLEAN = "SDL.process.background";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read all the output from a process.
|
||||||
|
*
|
||||||
|
* If a process was created with I/O enabled, you can use this function to
|
||||||
|
* read the output. This function blocks until the process is complete,
|
||||||
|
* capturing all output, and providing the process exit code.
|
||||||
|
*
|
||||||
|
* The data is allocated with a zero byte at the end (null terminated) for
|
||||||
|
* convenience. This extra byte is not included in the value reported via
|
||||||
|
* `datasize`.
|
||||||
|
*
|
||||||
|
* The data should be freed with SDL_free().
|
||||||
|
*
|
||||||
|
* \param process The process to read.
|
||||||
|
* \param datasize a pointer filled in with the number of bytes read, may be
|
||||||
|
* NULL.
|
||||||
|
* \param exitcode a pointer filled in with the process exit code if the
|
||||||
|
* process has exited, may be NULL.
|
||||||
|
* \returns the data or NULL on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateProcess
|
||||||
|
* \sa SDL_CreateProcessWithProperties
|
||||||
|
* \sa SDL_DestroyProcess
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ReadProcess")] public static extern void* ReadProcess(Process* process, out c_size datasize, out c_int exitcode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the SDL_IOStream associated with process standard input.
|
||||||
|
*
|
||||||
|
* The process must have been created with SDL_CreateProcess() and pipe_stdio
|
||||||
|
* set to true, or with SDL_CreateProcessWithProperties() and
|
||||||
|
* `SDL_PROP_PROCESS_CREATE_STDIN_NUMBER` set to `SDL_PROCESS_STDIO_APP`.
|
||||||
|
*
|
||||||
|
* Writing to this stream can return less data than expected if the process
|
||||||
|
* hasn't read its input. It may be blocked waiting for its output to be read,
|
||||||
|
* if so you may need to call SDL_GetProcessOutput() and read the output in
|
||||||
|
* parallel with writing input.
|
||||||
|
*
|
||||||
|
* \param process The process to get the input stream for.
|
||||||
|
* \returns the input stream or NULL on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateProcess
|
||||||
|
* \sa SDL_CreateProcessWithProperties
|
||||||
|
* \sa SDL_GetProcessOutput
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetProcessInput")] public static extern IOStream* GetProcessInput(Process* process);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the SDL_IOStream associated with process standard output.
|
||||||
|
*
|
||||||
|
* The process must have been created with SDL_CreateProcess() and pipe_stdio
|
||||||
|
* set to true, or with SDL_CreateProcessWithProperties() and
|
||||||
|
* `SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER` set to `SDL_PROCESS_STDIO_APP`.
|
||||||
|
*
|
||||||
|
* Reading from this stream can return 0 with SDL_GetIOStatus() returning
|
||||||
|
* SDL_IO_STATUS_NOT_READY if no output is available yet.
|
||||||
|
*
|
||||||
|
* \param process The process to get the output stream for.
|
||||||
|
* \returns the output stream or NULL on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateProcess
|
||||||
|
* \sa SDL_CreateProcessWithProperties
|
||||||
|
* \sa SDL_GetProcessInput
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetProcessOutput")] public static extern IOStream* GetProcessOutput(Process* process);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop a process.
|
||||||
|
*
|
||||||
|
* \param process The process to stop.
|
||||||
|
* \param force true to terminate the process immediately, false to try to
|
||||||
|
* stop the process gracefully. In general you should try to stop
|
||||||
|
* the process gracefully first as terminating a process may
|
||||||
|
* leave it with half-written data or in some other unstable
|
||||||
|
* state.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateProcess
|
||||||
|
* \sa SDL_CreateProcessWithProperties
|
||||||
|
* \sa SDL_WaitProcess
|
||||||
|
* \sa SDL_DestroyProcess
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_KillProcess")] public static extern bool KillProcess(Process* process, bool force);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait for a process to finish.
|
||||||
|
*
|
||||||
|
* This can be called multiple times to get the status of a process.
|
||||||
|
*
|
||||||
|
* The exit code will be the exit code of the process if it terminates
|
||||||
|
* normally, a negative signal if it terminated due to a signal, or -255
|
||||||
|
* otherwise. It will not be changed if the process is still running.
|
||||||
|
*
|
||||||
|
* If you create a process with standard output piped to the application
|
||||||
|
* (`pipe_stdio` being true) then you should read all of the process output
|
||||||
|
* before calling SDL_WaitProcess(). If you don't do this the process might be
|
||||||
|
* blocked indefinitely waiting for output to be read and SDL_WaitProcess()
|
||||||
|
* will never return true;
|
||||||
|
*
|
||||||
|
* \param process The process to wait for.
|
||||||
|
* \param block If true, block until the process finishes; otherwise, report
|
||||||
|
* on the process' status.
|
||||||
|
* \param exitcode a pointer filled in with the process exit code if the
|
||||||
|
* process has exited, may be NULL.
|
||||||
|
* \returns true if the process exited, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateProcess
|
||||||
|
* \sa SDL_CreateProcessWithProperties
|
||||||
|
* \sa SDL_KillProcess
|
||||||
|
* \sa SDL_DestroyProcess
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_WaitProcess")] public static extern bool WaitProcess(Process* process, bool block, out c_int exitcode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy a previously created process object.
|
||||||
|
*
|
||||||
|
* Note that this does not stop the process, just destroys the SDL object used
|
||||||
|
* to track it. If you want to stop the process you should use
|
||||||
|
* SDL_KillProcess().
|
||||||
|
*
|
||||||
|
* \param process The process object to destroy.
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateProcess
|
||||||
|
* \sa SDL_CreateProcessWithProperties
|
||||||
|
* \sa SDL_KillProcess
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_DestroyProcess")] public static extern void DestroyProcess(Process* process);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_process_h_ */
|
||||||
581
src/SDL_properties.bf
Normal file
581
src/SDL_properties.bf
Normal file
@@ -0,0 +1,581 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryProperties
|
||||||
|
*
|
||||||
|
* A property is a variable that can be created and retrieved by name at
|
||||||
|
* runtime.
|
||||||
|
*
|
||||||
|
* All properties are part of a property group (SDL_PropertiesID). A property
|
||||||
|
* group can be created with the SDL_CreateProperties function and destroyed
|
||||||
|
* with the SDL_DestroyProperties function.
|
||||||
|
*
|
||||||
|
* Properties can be added to and retrieved from a property group through the
|
||||||
|
* following functions:
|
||||||
|
*
|
||||||
|
* - SDL_SetPointerProperty and SDL_GetPointerProperty operate on `void*`
|
||||||
|
* pointer types.
|
||||||
|
* - SDL_SetStringProperty and SDL_GetStringProperty operate on string types.
|
||||||
|
* - SDL_SetNumberProperty and SDL_GetNumberProperty operate on signed 64-bit
|
||||||
|
* integer types.
|
||||||
|
* - SDL_SetFloatProperty and SDL_GetFloatProperty operate on floating point
|
||||||
|
* types.
|
||||||
|
* - SDL_SetBooleanProperty and SDL_GetBooleanProperty operate on boolean
|
||||||
|
* types.
|
||||||
|
*
|
||||||
|
* Properties can be removed from a group by using SDL_ClearProperty.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An ID that represents a properties set.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public typealias PropertiesID = Uint32;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SDL property type
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum PropertyType : c_int
|
||||||
|
{
|
||||||
|
Invalid,
|
||||||
|
Pointer,
|
||||||
|
String,
|
||||||
|
Number,
|
||||||
|
Float,
|
||||||
|
Boolean,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A generic property for naming things.
|
||||||
|
*
|
||||||
|
* This property is intended to be added to any SDL_PropertiesID that needs a
|
||||||
|
* generic name associated with the property set. It is not guaranteed that
|
||||||
|
* any property set will include this key, but it is convenient to have a
|
||||||
|
* standard key that any piece of code could reasonably agree to use.
|
||||||
|
*
|
||||||
|
* For example, the properties associated with an SDL_Texture might have a
|
||||||
|
* name string of "player sprites", or an SDL_AudioStream might have
|
||||||
|
* "background music", etc. This might also be useful for an SDL_IOStream to
|
||||||
|
* list the path to its asset.
|
||||||
|
*
|
||||||
|
* There is no format for the value set with this key; it is expected to be
|
||||||
|
* human-readable and informational in nature, possibly for logging or
|
||||||
|
* debugging purposes.
|
||||||
|
*
|
||||||
|
* SDL does not currently set this property on any objects it creates, but
|
||||||
|
* this may change in later versions; it is currently expected that apps and
|
||||||
|
* external libraries will take advantage of it, when appropriate.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.4.0.
|
||||||
|
*/
|
||||||
|
public const let PROP_NAME_STRING = "SDL.name";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the global SDL properties.
|
||||||
|
*
|
||||||
|
* \returns a valid property ID on success or 0 on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetGlobalProperties")] public static extern PropertiesID GetGlobalProperties();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a group of properties.
|
||||||
|
*
|
||||||
|
* All properties are automatically destroyed when SDL_Quit() is called.
|
||||||
|
*
|
||||||
|
* \returns an ID for a new group of properties, or 0 on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_DestroyProperties
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateProperties")] public static extern PropertiesID CreateProperties();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy a group of properties.
|
||||||
|
*
|
||||||
|
* Copy all the properties from one group of properties to another, with the
|
||||||
|
* exception of properties requiring cleanup (set using
|
||||||
|
* SDL_SetPointerPropertyWithCleanup()), which will not be copied. Any
|
||||||
|
* property that already exists on `dst` will be overwritten.
|
||||||
|
*
|
||||||
|
* \param src the properties to copy.
|
||||||
|
* \param dst the destination properties.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread. This
|
||||||
|
* function acquires simultaneous mutex locks on both the source
|
||||||
|
* and destination property sets.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CopyProperties")] public static extern bool CopyProperties(PropertiesID src, PropertiesID dst);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lock a group of properties.
|
||||||
|
*
|
||||||
|
* Obtain a multi-threaded lock for these properties. Other threads will wait
|
||||||
|
* while trying to lock these properties until they are unlocked. Properties
|
||||||
|
* must be unlocked before they are destroyed.
|
||||||
|
*
|
||||||
|
* The lock is automatically taken when setting individual properties, this
|
||||||
|
* function is only needed when you want to set several properties atomically
|
||||||
|
* or want to guarantee that properties being queried aren't freed in another
|
||||||
|
* thread.
|
||||||
|
*
|
||||||
|
* \param props the properties to lock.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_UnlockProperties
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_LockProperties")] public static extern bool LockProperties(PropertiesID props);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unlock a group of properties.
|
||||||
|
*
|
||||||
|
* \param props the properties to unlock.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_LockProperties
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_UnlockProperties")] public static extern void UnlockProperties(PropertiesID props);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A callback used to free resources when a property is deleted.
|
||||||
|
*
|
||||||
|
* This should release any resources associated with `value` that are no
|
||||||
|
* longer needed.
|
||||||
|
*
|
||||||
|
* This callback is set per-property. Different properties in the same group
|
||||||
|
* can have different cleanup callbacks.
|
||||||
|
*
|
||||||
|
* This callback will be called _during_ SDL_SetPointerPropertyWithCleanup if
|
||||||
|
* the function fails for any reason.
|
||||||
|
*
|
||||||
|
* \param userdata an app-defined pointer passed to the callback.
|
||||||
|
* \param value the pointer assigned to the property to clean up.
|
||||||
|
*
|
||||||
|
* \threadsafety This callback may fire without any locks held; if this is a
|
||||||
|
* concern, the app should provide its own locking.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetPointerPropertyWithCleanup
|
||||||
|
*/
|
||||||
|
public function void CleanupPropertyCallback(void* userdata, void* value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a pointer property in a group of properties with a cleanup function
|
||||||
|
* that is called when the property is deleted.
|
||||||
|
*
|
||||||
|
* The cleanup function is also called if setting the property fails for any
|
||||||
|
* reason.
|
||||||
|
*
|
||||||
|
* For simply setting basic data types, like numbers, bools, or strings, use
|
||||||
|
* SDL_SetNumberProperty, SDL_SetBooleanProperty, or SDL_SetStringProperty
|
||||||
|
* instead, as those functions will handle cleanup on your behalf. This
|
||||||
|
* function is only for more complex, custom data.
|
||||||
|
*
|
||||||
|
* \param props the properties to modify.
|
||||||
|
* \param name the name of the property to modify.
|
||||||
|
* \param value the new value of the property, or NULL to delete the property.
|
||||||
|
* \param cleanup the function to call when this property is deleted, or NULL
|
||||||
|
* if no cleanup is necessary.
|
||||||
|
* \param userdata a pointer that is passed to the cleanup function.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetPointerProperty
|
||||||
|
* \sa SDL_SetPointerProperty
|
||||||
|
* \sa SDL_CleanupPropertyCallback
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetPointerPropertyWithCleanup")] public static extern bool SetPointerPropertyWithCleanup(PropertiesID props, c_char* name, void* value, CleanupPropertyCallback cleanup, void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a pointer property in a group of properties.
|
||||||
|
*
|
||||||
|
* \param props the properties to modify.
|
||||||
|
* \param name the name of the property to modify.
|
||||||
|
* \param value the new value of the property, or NULL to delete the property.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetPointerProperty
|
||||||
|
* \sa SDL_HasProperty
|
||||||
|
* \sa SDL_SetBooleanProperty
|
||||||
|
* \sa SDL_SetFloatProperty
|
||||||
|
* \sa SDL_SetNumberProperty
|
||||||
|
* \sa SDL_SetPointerPropertyWithCleanup
|
||||||
|
* \sa SDL_SetStringProperty
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetPointerProperty")] public static extern bool SetPointerProperty(PropertiesID props, c_char* name, void* value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a string property in a group of properties.
|
||||||
|
*
|
||||||
|
* This function makes a copy of the string; the caller does not have to
|
||||||
|
* preserve the data after this call completes.
|
||||||
|
*
|
||||||
|
* \param props the properties to modify.
|
||||||
|
* \param name the name of the property to modify.
|
||||||
|
* \param value the new value of the property, or NULL to delete the property.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetStringProperty
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetStringProperty")] public static extern bool SetStringProperty(PropertiesID props, c_char* name, c_char* value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an integer property in a group of properties.
|
||||||
|
*
|
||||||
|
* \param props the properties to modify.
|
||||||
|
* \param name the name of the property to modify.
|
||||||
|
* \param value the new value of the property.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetNumberProperty
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetNumberProperty")] public static extern bool SetNumberProperty(PropertiesID props, c_char* name, Sint64 value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a floating point property in a group of properties.
|
||||||
|
*
|
||||||
|
* \param props the properties to modify.
|
||||||
|
* \param name the name of the property to modify.
|
||||||
|
* \param value the new value of the property.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetFloatProperty
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetFloatProperty")] public static extern bool SetFloatProperty(PropertiesID props, c_char* name, float value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a boolean property in a group of properties.
|
||||||
|
*
|
||||||
|
* \param props the properties to modify.
|
||||||
|
* \param name the name of the property to modify.
|
||||||
|
* \param value the new value of the property.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetBooleanProperty
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetBooleanProperty")] public static extern bool SetBooleanProperty(PropertiesID props, c_char* name, bool value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether a property exists in a group of properties.
|
||||||
|
*
|
||||||
|
* \param props the properties to query.
|
||||||
|
* \param name the name of the property to query.
|
||||||
|
* \returns true if the property exists, or false if it doesn't.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetPropertyType
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasProperty")] public static extern bool HasProperty(PropertiesID props, c_char* name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type of a property in a group of properties.
|
||||||
|
*
|
||||||
|
* \param props the properties to query.
|
||||||
|
* \param name the name of the property to query.
|
||||||
|
* \returns the type of the property, or SDL_PROPERTY_TYPE_INVALID if it is
|
||||||
|
* not set.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasProperty
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetPropertyType")] public static extern PropertyType GetPropertyType(PropertiesID props, c_char* name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a pointer property from a group of properties.
|
||||||
|
*
|
||||||
|
* By convention, the names of properties that SDL exposes on objects will
|
||||||
|
* start with "SDL.", and properties that SDL uses internally will start with
|
||||||
|
* "SDL.internal.". These should be considered read-only and should not be
|
||||||
|
* modified by applications.
|
||||||
|
*
|
||||||
|
* \param props the properties to query.
|
||||||
|
* \param name the name of the property to query.
|
||||||
|
* \param default_value the default value of the property.
|
||||||
|
* \returns the value of the property, or `default_value` if it is not set or
|
||||||
|
* not a pointer property.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread, although
|
||||||
|
* the data returned is not protected and could potentially be
|
||||||
|
* freed if you call SDL_SetPointerProperty() or
|
||||||
|
* SDL_ClearProperty() on these properties from another thread.
|
||||||
|
* If you need to avoid this, use SDL_LockProperties() and
|
||||||
|
* SDL_UnlockProperties().
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetBooleanProperty
|
||||||
|
* \sa SDL_GetFloatProperty
|
||||||
|
* \sa SDL_GetNumberProperty
|
||||||
|
* \sa SDL_GetPropertyType
|
||||||
|
* \sa SDL_GetStringProperty
|
||||||
|
* \sa SDL_HasProperty
|
||||||
|
* \sa SDL_SetPointerProperty
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetPointerProperty")] public static extern void* GetPointerProperty(PropertiesID props, c_char* name, void* default_value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a string property from a group of properties.
|
||||||
|
*
|
||||||
|
* \param props the properties to query.
|
||||||
|
* \param name the name of the property to query.
|
||||||
|
* \param default_value the default value of the property.
|
||||||
|
* \returns the value of the property, or `default_value` if it is not set or
|
||||||
|
* not a string property.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread, although
|
||||||
|
* the data returned is not protected and could potentially be
|
||||||
|
* freed if you call SDL_SetStringProperty() or
|
||||||
|
* SDL_ClearProperty() on these properties from another thread.
|
||||||
|
* If you need to avoid this, use SDL_LockProperties() and
|
||||||
|
* SDL_UnlockProperties().
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetPropertyType
|
||||||
|
* \sa SDL_HasProperty
|
||||||
|
* \sa SDL_SetStringProperty
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetStringProperty")] public static extern c_char* GetStringProperty(PropertiesID props, c_char* name, c_char* default_value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a number property from a group of properties.
|
||||||
|
*
|
||||||
|
* You can use SDL_GetPropertyType() to query whether the property exists and
|
||||||
|
* is a number property.
|
||||||
|
*
|
||||||
|
* \param props the properties to query.
|
||||||
|
* \param name the name of the property to query.
|
||||||
|
* \param default_value the default value of the property.
|
||||||
|
* \returns the value of the property, or `default_value` if it is not set or
|
||||||
|
* not a number property.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetPropertyType
|
||||||
|
* \sa SDL_HasProperty
|
||||||
|
* \sa SDL_SetNumberProperty
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetNumberProperty")] public static extern Sint64 GetNumberProperty(PropertiesID props, c_char* name, Sint64 default_value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a floating point property from a group of properties.
|
||||||
|
*
|
||||||
|
* You can use SDL_GetPropertyType() to query whether the property exists and
|
||||||
|
* is a floating point property.
|
||||||
|
*
|
||||||
|
* \param props the properties to query.
|
||||||
|
* \param name the name of the property to query.
|
||||||
|
* \param default_value the default value of the property.
|
||||||
|
* \returns the value of the property, or `default_value` if it is not set or
|
||||||
|
* not a float property.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetPropertyType
|
||||||
|
* \sa SDL_HasProperty
|
||||||
|
* \sa SDL_SetFloatProperty
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetFloatProperty")] public static extern float GetFloatProperty(PropertiesID props, c_char* name, float default_value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a boolean property from a group of properties.
|
||||||
|
*
|
||||||
|
* You can use SDL_GetPropertyType() to query whether the property exists and
|
||||||
|
* is a boolean property.
|
||||||
|
*
|
||||||
|
* \param props the properties to query.
|
||||||
|
* \param name the name of the property to query.
|
||||||
|
* \param default_value the default value of the property.
|
||||||
|
* \returns the value of the property, or `default_value` if it is not set or
|
||||||
|
* not a boolean property.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetPropertyType
|
||||||
|
* \sa SDL_HasProperty
|
||||||
|
* \sa SDL_SetBooleanProperty
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetBooleanProperty")] public static extern bool GetBooleanProperty(PropertiesID props, c_char* name, bool default_value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear a property from a group of properties.
|
||||||
|
*
|
||||||
|
* \param props the properties to modify.
|
||||||
|
* \param name the name of the property to clear.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ClearProperty")] public static extern bool ClearProperty(PropertiesID props, c_char* name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A callback used to enumerate all the properties in a group of properties.
|
||||||
|
*
|
||||||
|
* This callback is called from SDL_EnumerateProperties(), and is called once
|
||||||
|
* per property in the set.
|
||||||
|
*
|
||||||
|
* \param userdata an app-defined pointer passed to the callback.
|
||||||
|
* \param props the SDL_PropertiesID that is being enumerated.
|
||||||
|
* \param name the next property name in the enumeration.
|
||||||
|
*
|
||||||
|
* \threadsafety SDL_EnumerateProperties holds a lock on `props` during this
|
||||||
|
* callback.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_EnumerateProperties
|
||||||
|
*/
|
||||||
|
public function void EnumeratePropertiesCallback(void* userdata, PropertiesID props, c_char* name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumerate the properties contained in a group of properties.
|
||||||
|
*
|
||||||
|
* The callback function is called for each property in the group of
|
||||||
|
* properties. The properties are locked during enumeration.
|
||||||
|
*
|
||||||
|
* \param props the properties to query.
|
||||||
|
* \param callback the function to call for each property.
|
||||||
|
* \param userdata a pointer that is passed to `callback`.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_EnumerateProperties")] public static extern bool EnumerateProperties(PropertiesID props, EnumeratePropertiesCallback callback, void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy a group of properties.
|
||||||
|
*
|
||||||
|
* All properties are deleted and their cleanup functions will be called, if
|
||||||
|
* any.
|
||||||
|
*
|
||||||
|
* \param props the properties to destroy.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should not be called while these properties are
|
||||||
|
* locked or other threads might be setting or getting values
|
||||||
|
* from these properties.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateProperties
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_DestroyProperties")] public static extern void DestroyProperties(PropertiesID props);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_properties_h_ */
|
||||||
521
src/SDL_rect.bf
Normal file
521
src/SDL_rect.bf
Normal file
@@ -0,0 +1,521 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryRect
|
||||||
|
*
|
||||||
|
* Some helper functions for managing rectangles and 2D points, in both
|
||||||
|
* integer and floating point versions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The structure that defines a point (using integers).
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetRectEnclosingPoints
|
||||||
|
* \sa SDL_PointInRect
|
||||||
|
*/
|
||||||
|
[CRepr] public struct Point
|
||||||
|
{
|
||||||
|
public c_int x;
|
||||||
|
public c_int y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The structure that defines a point (using floating point values).
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetRectEnclosingPointsFloat
|
||||||
|
* \sa SDL_PointInRectFloat
|
||||||
|
*/
|
||||||
|
[CRepr] public struct FPoint
|
||||||
|
{
|
||||||
|
public float x;
|
||||||
|
public float y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A rectangle, with the origin at the upper left (using integers).
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_RectEmpty
|
||||||
|
* \sa SDL_RectsEqual
|
||||||
|
* \sa SDL_HasRectIntersection
|
||||||
|
* \sa SDL_GetRectIntersection
|
||||||
|
* \sa SDL_GetRectAndLineIntersection
|
||||||
|
* \sa SDL_GetRectUnion
|
||||||
|
* \sa SDL_GetRectEnclosingPoints
|
||||||
|
*/
|
||||||
|
[CRepr] public struct Rect
|
||||||
|
{
|
||||||
|
public c_int x; public c_int y;
|
||||||
|
public c_int w; public c_int h;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A rectangle stored using floating point values.
|
||||||
|
*
|
||||||
|
* The origin of the coordinate space is in the top-left, with increasing
|
||||||
|
* values moving down and right. The properties `x` and `y` represent the
|
||||||
|
* coordinates of the top-left corner of the rectangle.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_RectEmptyFloat
|
||||||
|
* \sa SDL_RectsEqualFloat
|
||||||
|
* \sa SDL_RectsEqualEpsilon
|
||||||
|
* \sa SDL_HasRectIntersectionFloat
|
||||||
|
* \sa SDL_GetRectIntersectionFloat
|
||||||
|
* \sa SDL_GetRectAndLineIntersectionFloat
|
||||||
|
* \sa SDL_GetRectUnionFloat
|
||||||
|
* \sa SDL_GetRectEnclosingPointsFloat
|
||||||
|
* \sa SDL_PointInRectFloat
|
||||||
|
*/
|
||||||
|
[CRepr] public struct FRect
|
||||||
|
{
|
||||||
|
public float x;
|
||||||
|
public float y;
|
||||||
|
public float w;
|
||||||
|
public float h;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an SDL_Rect to SDL_FRect
|
||||||
|
*
|
||||||
|
* \param rect a pointer to an SDL_Rect.
|
||||||
|
* \param frect a pointer filled in with the floating point representation of
|
||||||
|
* `rect`.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_RectToFRect")] public static extern void RectToFRect(Rect* rect, out FRect frect);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether a point resides inside a rectangle.
|
||||||
|
*
|
||||||
|
* A point is considered part of a rectangle if both `p` and `r` are not NULL,
|
||||||
|
* and `p`'s x and y coordinates are >= to the rectangle's top left corner,
|
||||||
|
* and < the rectangle's x+w and y+h. So a 1x1 rectangle considers point (0,0)
|
||||||
|
* as "inside" and (0,1) as not.
|
||||||
|
*
|
||||||
|
* Note that this is a forced-inline function in a header, and not a public
|
||||||
|
* API function available in the SDL library (which is to say, the code is
|
||||||
|
* embedded in the calling program and the linker and dynamic loader will not
|
||||||
|
* be able to find this function inside SDL itself).
|
||||||
|
*
|
||||||
|
* \param p the point to test.
|
||||||
|
* \param r the rectangle to test.
|
||||||
|
* \returns true if `p` is contained by `r`, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_PointInRect")] public static extern bool PointInRect(Point* p, Rect* r);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether a rectangle has no area.
|
||||||
|
*
|
||||||
|
* A rectangle is considered "empty" for this function if `r` is NULL, or if
|
||||||
|
* `r`'s width and/or height are <= 0.
|
||||||
|
*
|
||||||
|
* Note that this is a forced-inline function in a header, and not a public
|
||||||
|
* API function available in the SDL library (which is to say, the code is
|
||||||
|
* embedded in the calling program and the linker and dynamic loader will not
|
||||||
|
* be able to find this function inside SDL itself).
|
||||||
|
*
|
||||||
|
* \param r the rectangle to test.
|
||||||
|
* \returns true if the rectangle is "empty", false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_RectEmpty")] public static extern bool RectEmpty(Rect* r);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether two rectangles are equal.
|
||||||
|
*
|
||||||
|
* Rectangles are considered equal if both are not NULL and each of their x,
|
||||||
|
* y, width and height match.
|
||||||
|
*
|
||||||
|
* Note that this is a forced-inline function in a header, and not a public
|
||||||
|
* API function available in the SDL library (which is to say, the code is
|
||||||
|
* embedded in the calling program and the linker and dynamic loader will not
|
||||||
|
* be able to find this function inside SDL itself).
|
||||||
|
*
|
||||||
|
* \param a the first rectangle to test.
|
||||||
|
* \param b the second rectangle to test.
|
||||||
|
* \returns true if the rectangles are equal, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_RectsEqual")] public static extern bool RectsEqual(Rect* a, Rect* b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether two rectangles intersect.
|
||||||
|
*
|
||||||
|
* If either pointer is NULL the function will return false.
|
||||||
|
*
|
||||||
|
* \param A an SDL_Rect structure representing the first rectangle.
|
||||||
|
* \param B an SDL_Rect structure representing the second rectangle.
|
||||||
|
* \returns true if there is an intersection, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetRectIntersection
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasRectIntersection")] public static extern bool HasRectIntersection(Rect* A, Rect* B);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the intersection of two rectangles.
|
||||||
|
*
|
||||||
|
* If `result` is NULL then this function will return false.
|
||||||
|
*
|
||||||
|
* \param A an SDL_Rect structure representing the first rectangle.
|
||||||
|
* \param B an SDL_Rect structure representing the second rectangle.
|
||||||
|
* \param result an SDL_Rect structure filled in with the intersection of
|
||||||
|
* rectangles `A` and `B`.
|
||||||
|
* \returns true if there is an intersection, false otherwise.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasRectIntersection
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetRectIntersection")] public static extern bool GetRectIntersection(Rect* A, Rect* B, Rect* result);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the union of two rectangles.
|
||||||
|
*
|
||||||
|
* \param A an SDL_Rect structure representing the first rectangle.
|
||||||
|
* \param B an SDL_Rect structure representing the second rectangle.
|
||||||
|
* \param result an SDL_Rect structure filled in with the union of rectangles
|
||||||
|
* `A` and `B`.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetRectUnion")] public static extern bool GetRectUnion(Rect* A, Rect* B, Rect* result);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate a minimal rectangle enclosing a set of points.
|
||||||
|
*
|
||||||
|
* If `clip` is not NULL then only points inside of the clipping rectangle are
|
||||||
|
* considered.
|
||||||
|
*
|
||||||
|
* \param points an array of SDL_Point structures representing points to be
|
||||||
|
* enclosed.
|
||||||
|
* \param count the number of structures in the `points` array.
|
||||||
|
* \param clip an SDL_Rect used for clipping or NULL to enclose all points.
|
||||||
|
* \param result an SDL_Rect structure filled in with the minimal enclosing
|
||||||
|
* rectangle.
|
||||||
|
* \returns true if any points were enclosed or false if all the points were
|
||||||
|
* outside of the clipping rectangle.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetRectEnclosingPoints")] public static extern bool GetRectEnclosingPoints(Point* points, c_int count, Rect* clip, Rect* result);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the intersection of a rectangle and line segment.
|
||||||
|
*
|
||||||
|
* This function is used to clip a line segment to a rectangle. A line segment
|
||||||
|
* contained entirely within the rectangle or that does not intersect will
|
||||||
|
* remain unchanged. A line segment that crosses the rectangle at either or
|
||||||
|
* both ends will be clipped to the boundary of the rectangle and the new
|
||||||
|
* coordinates saved in `X1`, `Y1`, `X2`, and/or `Y2` as necessary.
|
||||||
|
*
|
||||||
|
* \param rect an SDL_Rect structure representing the rectangle to intersect.
|
||||||
|
* \param X1 a pointer to the starting X-coordinate of the line.
|
||||||
|
* \param Y1 a pointer to the starting Y-coordinate of the line.
|
||||||
|
* \param X2 a pointer to the ending X-coordinate of the line.
|
||||||
|
* \param Y2 a pointer to the ending Y-coordinate of the line.
|
||||||
|
* \returns true if there is an intersection, false otherwise.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetRectAndLineIntersection")] public static extern bool GetRectAndLineIntersection(Rect* rect, c_int* X1, c_int* Y1, c_int* X2, c_int* Y2);
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_FRect versions... */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether a point resides inside a floating point rectangle.
|
||||||
|
*
|
||||||
|
* A point is considered part of a rectangle if both `p` and `r` are not NULL,
|
||||||
|
* and `p`'s x and y coordinates are >= to the rectangle's top left corner,
|
||||||
|
* and <= the rectangle's x+w and y+h. So a 1x1 rectangle considers point
|
||||||
|
* (0,0) and (0,1) as "inside" and (0,2) as not.
|
||||||
|
*
|
||||||
|
* Note that this is a forced-inline function in a header, and not a public
|
||||||
|
* API function available in the SDL library (which is to say, the code is
|
||||||
|
* embedded in the calling program and the linker and dynamic loader will not
|
||||||
|
* be able to find this function inside SDL itself).
|
||||||
|
*
|
||||||
|
* \param p the point to test.
|
||||||
|
* \param r the rectangle to test.
|
||||||
|
* \returns true if `p` is contained by `r`, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_PointInRectFloat")] public static extern bool PointInRectFloat(FPoint* p, FRect* r);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether a floating point rectangle takes no space.
|
||||||
|
*
|
||||||
|
* A rectangle is considered "empty" for this function if `r` is NULL, or if
|
||||||
|
* `r`'s width and/or height are < 0.0f.
|
||||||
|
*
|
||||||
|
* Note that this is a forced-inline function in a header, and not a public
|
||||||
|
* API function available in the SDL library (which is to say, the code is
|
||||||
|
* embedded in the calling program and the linker and dynamic loader will not
|
||||||
|
* be able to find this function inside SDL itself).
|
||||||
|
*
|
||||||
|
* \param r the rectangle to test.
|
||||||
|
* \returns true if the rectangle is "empty", false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_RectEmptyFloat")] public static extern bool RectEmptyFloat(FRect* r);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether two floating point rectangles are equal, within some
|
||||||
|
* given epsilon.
|
||||||
|
*
|
||||||
|
* Rectangles are considered equal if both are not NULL and each of their x,
|
||||||
|
* y, width and height are within `epsilon` of each other. If you don't know
|
||||||
|
* what value to use for `epsilon`, you should call the SDL_RectsEqualFloat
|
||||||
|
* function instead.
|
||||||
|
*
|
||||||
|
* Note that this is a forced-inline function in a header, and not a public
|
||||||
|
* API function available in the SDL library (which is to say, the code is
|
||||||
|
* embedded in the calling program and the linker and dynamic loader will not
|
||||||
|
* be able to find this function inside SDL itself).
|
||||||
|
*
|
||||||
|
* \param a the first rectangle to test.
|
||||||
|
* \param b the second rectangle to test.
|
||||||
|
* \param epsilon the epsilon value for comparison.
|
||||||
|
* \returns true if the rectangles are equal, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_RectsEqualFloat
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_RectsEqualEpsilon")] public static extern bool RectsEqualEpsilon(FRect* a, FRect* b, float epsilon);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether two floating point rectangles are equal, within a default
|
||||||
|
* epsilon.
|
||||||
|
*
|
||||||
|
* Rectangles are considered equal if both are not NULL and each of their x,
|
||||||
|
* y, width and height are within SDL_FLT_EPSILON of each other. This is often
|
||||||
|
* a reasonable way to compare two floating point rectangles and deal with the
|
||||||
|
* slight precision variations in floating point calculations that tend to pop
|
||||||
|
* up.
|
||||||
|
*
|
||||||
|
* Note that this is a forced-inline function in a header, and not a public
|
||||||
|
* API function available in the SDL library (which is to say, the code is
|
||||||
|
* embedded in the calling program and the linker and dynamic loader will not
|
||||||
|
* be able to find this function inside SDL itself).
|
||||||
|
*
|
||||||
|
* \param a the first rectangle to test.
|
||||||
|
* \param b the second rectangle to test.
|
||||||
|
* \returns true if the rectangles are equal, false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_RectsEqualEpsilon
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_RectsEqualFloat")] public static extern bool RectsEqualFloat(FRect* a, FRect* b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether two rectangles intersect with float precision.
|
||||||
|
*
|
||||||
|
* If either pointer is NULL the function will return false.
|
||||||
|
*
|
||||||
|
* \param A an SDL_FRect structure representing the first rectangle.
|
||||||
|
* \param B an SDL_FRect structure representing the second rectangle.
|
||||||
|
* \returns true if there is an intersection, false otherwise.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetRectIntersectionFloat
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_HasRectIntersectionFloat")] public static extern bool HasRectIntersectionFloat(FRect* A, FRect* B);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the intersection of two rectangles with float precision.
|
||||||
|
*
|
||||||
|
* If `result` is NULL then this function will return false.
|
||||||
|
*
|
||||||
|
* \param A an SDL_FRect structure representing the first rectangle.
|
||||||
|
* \param B an SDL_FRect structure representing the second rectangle.
|
||||||
|
* \param result an SDL_FRect structure filled in with the intersection of
|
||||||
|
* rectangles `A` and `B`.
|
||||||
|
* \returns true if there is an intersection, false otherwise.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_HasRectIntersectionFloat
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetRectIntersectionFloat")] public static extern bool GetRectIntersectionFloat(FRect* A, FRect* B, FRect* result);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the union of two rectangles with float precision.
|
||||||
|
*
|
||||||
|
* \param A an SDL_FRect structure representing the first rectangle.
|
||||||
|
* \param B an SDL_FRect structure representing the second rectangle.
|
||||||
|
* \param result an SDL_FRect structure filled in with the union of rectangles
|
||||||
|
* `A` and `B`.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetRectUnionFloat")] public static extern bool GetRectUnionFloat(FRect* A, FRect* B, FRect* result);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate a minimal rectangle enclosing a set of points with float
|
||||||
|
* precision.
|
||||||
|
*
|
||||||
|
* If `clip` is not NULL then only points inside of the clipping rectangle are
|
||||||
|
* considered.
|
||||||
|
*
|
||||||
|
* \param points an array of SDL_FPoint structures representing points to be
|
||||||
|
* enclosed.
|
||||||
|
* \param count the number of structures in the `points` array.
|
||||||
|
* \param clip an SDL_FRect used for clipping or NULL to enclose all points.
|
||||||
|
* \param result an SDL_FRect structure filled in with the minimal enclosing
|
||||||
|
* rectangle.
|
||||||
|
* \returns true if any points were enclosed or false if all the points were
|
||||||
|
* outside of the clipping rectangle.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetRectEnclosingPointsFloat")] public static extern bool GetRectEnclosingPointsFloat(FPoint* points, c_int count, FRect* clip, FRect* result);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the intersection of a rectangle and line segment with float
|
||||||
|
* precision.
|
||||||
|
*
|
||||||
|
* This function is used to clip a line segment to a rectangle. A line segment
|
||||||
|
* contained entirely within the rectangle or that does not intersect will
|
||||||
|
* remain unchanged. A line segment that crosses the rectangle at either or
|
||||||
|
* both ends will be clipped to the boundary of the rectangle and the new
|
||||||
|
* coordinates saved in `X1`, `Y1`, `X2`, and/or `Y2` as necessary.
|
||||||
|
*
|
||||||
|
* \param rect an SDL_FRect structure representing the rectangle to intersect.
|
||||||
|
* \param X1 a pointer to the starting X-coordinate of the line.
|
||||||
|
* \param Y1 a pointer to the starting Y-coordinate of the line.
|
||||||
|
* \param X2 a pointer to the ending X-coordinate of the line.
|
||||||
|
* \param Y2 a pointer to the ending Y-coordinate of the line.
|
||||||
|
* \returns true if there is an intersection, false otherwise.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetRectAndLineIntersectionFloat")] public static extern bool GetRectAndLineIntersectionFloat(FRect* rect, float* X1, float* Y1, float* X2, float* Y2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_rect_h_ */
|
||||||
3014
src/SDL_render.bf
Normal file
3014
src/SDL_render.bf
Normal file
File diff suppressed because it is too large
Load Diff
8
src/SDL_revision.bf
Normal file
8
src/SDL_revision.bf
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
442
src/SDL_scancode.bf
Normal file
442
src/SDL_scancode.bf
Normal file
@@ -0,0 +1,442 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryScancode
|
||||||
|
*
|
||||||
|
* Defines keyboard scancodes.
|
||||||
|
*
|
||||||
|
* Please refer to the Best Keyboard Practices document for details on what
|
||||||
|
* this information means and how best to use it.
|
||||||
|
*
|
||||||
|
* https://wiki.libsdl.org/SDL3/BestKeyboardPractices
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SDL keyboard scancode representation.
|
||||||
|
*
|
||||||
|
* An SDL scancode is the physical representation of a key on the keyboard,
|
||||||
|
* independent of language and keyboard mapping.
|
||||||
|
*
|
||||||
|
* Values of this type are used to represent keyboard keys, among other places
|
||||||
|
* in the `scancode` field of the SDL_KeyboardEvent structure.
|
||||||
|
*
|
||||||
|
* The values in this enumeration are based on the USB usage page standard:
|
||||||
|
* https://usb.org/sites/default/files/hut1_5.pdf
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum Scancode : c_int
|
||||||
|
{
|
||||||
|
Unknown = 0,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \name Usage page 0x07
|
||||||
|
*
|
||||||
|
* These values are from usage page 0x07 (USB keyboard page).
|
||||||
|
*/
|
||||||
|
/* @{ */
|
||||||
|
|
||||||
|
A = 4,
|
||||||
|
B = 5,
|
||||||
|
C = 6,
|
||||||
|
D = 7,
|
||||||
|
E = 8,
|
||||||
|
F = 9,
|
||||||
|
G = 10,
|
||||||
|
H = 11,
|
||||||
|
I = 12,
|
||||||
|
J = 13,
|
||||||
|
K = 14,
|
||||||
|
L = 15,
|
||||||
|
M = 16,
|
||||||
|
N = 17,
|
||||||
|
O = 18,
|
||||||
|
P = 19,
|
||||||
|
Q = 20,
|
||||||
|
R = 21,
|
||||||
|
S = 22,
|
||||||
|
T = 23,
|
||||||
|
U = 24,
|
||||||
|
V = 25,
|
||||||
|
W = 26,
|
||||||
|
X = 27,
|
||||||
|
Y = 28,
|
||||||
|
Z = 29,
|
||||||
|
|
||||||
|
_1 = 30,
|
||||||
|
_2 = 31,
|
||||||
|
_3 = 32,
|
||||||
|
_4 = 33,
|
||||||
|
_5 = 34,
|
||||||
|
_6 = 35,
|
||||||
|
_7 = 36,
|
||||||
|
_8 = 37,
|
||||||
|
_9 = 38,
|
||||||
|
_0 = 39,
|
||||||
|
|
||||||
|
Return = 40,
|
||||||
|
Escape = 41,
|
||||||
|
Backspace = 42,
|
||||||
|
Tab = 43,
|
||||||
|
Space = 44,
|
||||||
|
|
||||||
|
Minus = 45,
|
||||||
|
Equals = 46,
|
||||||
|
Leftbracket = 47,
|
||||||
|
Rightbracket = 48,
|
||||||
|
Backslash = 49, /**< Located at the lower left of the return
|
||||||
|
* key on ISO keyboards and at the right end
|
||||||
|
* of the QWERTY row on ANSI keyboards.
|
||||||
|
* Produces REVERSE SOLIDUS (backslash) and
|
||||||
|
* VERTICAL LINE in a US layout, REVERSE
|
||||||
|
* SOLIDUS and VERTICAL LINE in a UK Mac
|
||||||
|
* layout, NUMBER SIGN and TILDE in a UK
|
||||||
|
* Windows layout, DOLLAR SIGN and POUND SIGN
|
||||||
|
* in a Swiss German layout, NUMBER SIGN and
|
||||||
|
* APOSTROPHE in a German layout, GRAVE
|
||||||
|
* ACCENT and POUND SIGN in a French Mac
|
||||||
|
* layout, and ASTERISK and MICRO SIGN in a
|
||||||
|
* French Windows layout.
|
||||||
|
*/
|
||||||
|
Nonushash = 50, /**< ISO USB keyboards actually use this code
|
||||||
|
* instead of 49 for the same key, but all
|
||||||
|
* OSes I've seen treat the two codes
|
||||||
|
* identically. So, as an implementor, unless
|
||||||
|
* your keyboard generates both of those
|
||||||
|
* codes and your OS treats them differently,
|
||||||
|
* you should generate SDL_SCANCODE_BACKSLASH
|
||||||
|
* instead of this code. As a user, you
|
||||||
|
* should not rely on this code because SDL
|
||||||
|
* will never generate it with most (all?)
|
||||||
|
* keyboards.
|
||||||
|
*/
|
||||||
|
Semicolon = 51,
|
||||||
|
Apostrophe = 52,
|
||||||
|
Grave = 53, /**< Located in the top left corner (on both ANSI
|
||||||
|
* and ISO keyboards). Produces GRAVE ACCENT and
|
||||||
|
* TILDE in a US Windows layout and in US and UK
|
||||||
|
* Mac layouts on ANSI keyboards, GRAVE ACCENT
|
||||||
|
* and NOT SIGN in a UK Windows layout, SECTION
|
||||||
|
* SIGN and PLUS-MINUS SIGN in US and UK Mac
|
||||||
|
* layouts on ISO keyboards, SECTION SIGN and
|
||||||
|
* DEGREE SIGN in a Swiss German layout (Mac:
|
||||||
|
* only on ISO keyboards), CIRCUMFLEX ACCENT and
|
||||||
|
* DEGREE SIGN in a German layout (Mac: only on
|
||||||
|
* ISO keyboards), SUPERSCRIPT TWO and TILDE in a
|
||||||
|
* French Windows layout, COMMERCIAL AT and
|
||||||
|
* NUMBER SIGN in a French Mac layout on ISO
|
||||||
|
* keyboards, and LESS-THAN SIGN and GREATER-THAN
|
||||||
|
* SIGN in a Swiss German, German, or French Mac
|
||||||
|
* layout on ANSI keyboards.
|
||||||
|
*/
|
||||||
|
Comma = 54,
|
||||||
|
Period = 55,
|
||||||
|
Slash = 56,
|
||||||
|
|
||||||
|
Capslock = 57,
|
||||||
|
|
||||||
|
F1 = 58,
|
||||||
|
F2 = 59,
|
||||||
|
F3 = 60,
|
||||||
|
F4 = 61,
|
||||||
|
F5 = 62,
|
||||||
|
F6 = 63,
|
||||||
|
F7 = 64,
|
||||||
|
F8 = 65,
|
||||||
|
F9 = 66,
|
||||||
|
F10 = 67,
|
||||||
|
F11 = 68,
|
||||||
|
F12 = 69,
|
||||||
|
|
||||||
|
Printscreen = 70,
|
||||||
|
Scrolllock = 71,
|
||||||
|
Pause = 72,
|
||||||
|
Insert = 73, /**< insert on PC, help on some Mac keyboards (but
|
||||||
|
does send code 73, not 117) */
|
||||||
|
Home = 74,
|
||||||
|
Pageup = 75,
|
||||||
|
Delete = 76,
|
||||||
|
End = 77,
|
||||||
|
Pagedown = 78,
|
||||||
|
Right = 79,
|
||||||
|
Left = 80,
|
||||||
|
Down = 81,
|
||||||
|
Up = 82,
|
||||||
|
|
||||||
|
Numlockclear = 83, /**< num lock on PC, clear on Mac keyboards
|
||||||
|
*/
|
||||||
|
KpDivide = 84,
|
||||||
|
KpMultiply = 85,
|
||||||
|
KpMinus = 86,
|
||||||
|
KpPlus = 87,
|
||||||
|
KpEnter = 88,
|
||||||
|
Kp1 = 89,
|
||||||
|
Kp2 = 90,
|
||||||
|
Kp3 = 91,
|
||||||
|
Kp4 = 92,
|
||||||
|
Kp5 = 93,
|
||||||
|
Kp6 = 94,
|
||||||
|
Kp7 = 95,
|
||||||
|
Kp8 = 96,
|
||||||
|
Kp9 = 97,
|
||||||
|
Kp0 = 98,
|
||||||
|
KpPeriod = 99,
|
||||||
|
|
||||||
|
Nonusbackslash = 100, /**< This is the additional key that ISO
|
||||||
|
* keyboards have over ANSI ones,
|
||||||
|
* located between left shift and Z.
|
||||||
|
* Produces GRAVE ACCENT and TILDE in a
|
||||||
|
* US or UK Mac layout, REVERSE SOLIDUS
|
||||||
|
* (backslash) and VERTICAL LINE in a
|
||||||
|
* US or UK Windows layout, and
|
||||||
|
* LESS-THAN SIGN and GREATER-THAN SIGN
|
||||||
|
* in a Swiss German, German, or French
|
||||||
|
* layout. */
|
||||||
|
Application = 101, /**< windows contextual menu, compose */
|
||||||
|
Power = 102, /**< The USB document says this is a status flag,
|
||||||
|
* not a physical key - but some Mac keyboards
|
||||||
|
* do have a power key. */
|
||||||
|
KpEquals = 103,
|
||||||
|
F13 = 104,
|
||||||
|
F14 = 105,
|
||||||
|
F15 = 106,
|
||||||
|
F16 = 107,
|
||||||
|
F17 = 108,
|
||||||
|
F18 = 109,
|
||||||
|
F19 = 110,
|
||||||
|
F20 = 111,
|
||||||
|
F21 = 112,
|
||||||
|
F22 = 113,
|
||||||
|
F23 = 114,
|
||||||
|
F24 = 115,
|
||||||
|
Execute = 116,
|
||||||
|
Help = 117, /**< AL Integrated Help Center */
|
||||||
|
Menu = 118, /**< Menu (show menu) */
|
||||||
|
Select = 119,
|
||||||
|
Stop = 120, /**< AC Stop */
|
||||||
|
Again = 121, /**< AC Redo/Repeat */
|
||||||
|
Undo = 122, /**< AC Undo */
|
||||||
|
Cut = 123, /**< AC Cut */
|
||||||
|
Copy = 124, /**< AC Copy */
|
||||||
|
Paste = 125, /**< AC Paste */
|
||||||
|
Find = 126, /**< AC Find */
|
||||||
|
Mute = 127,
|
||||||
|
Volumeup = 128,
|
||||||
|
Volumedown = 129,
|
||||||
|
/* not sure whether there's a reason to enable these */
|
||||||
|
/* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */
|
||||||
|
/* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */
|
||||||
|
/* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */
|
||||||
|
KpComma = 133,
|
||||||
|
KpEqualsas400 = 134,
|
||||||
|
|
||||||
|
International1 = 135, /**< used on Asian keyboards, see
|
||||||
|
footnotes in USB doc */
|
||||||
|
International2 = 136,
|
||||||
|
International3 = 137, /**< Yen */
|
||||||
|
International4 = 138,
|
||||||
|
International5 = 139,
|
||||||
|
International6 = 140,
|
||||||
|
International7 = 141,
|
||||||
|
International8 = 142,
|
||||||
|
International9 = 143,
|
||||||
|
Lang1 = 144, /**< Hangul/English toggle */
|
||||||
|
Lang2 = 145, /**< Hanja conversion */
|
||||||
|
Lang3 = 146, /**< Katakana */
|
||||||
|
Lang4 = 147, /**< Hiragana */
|
||||||
|
Lang5 = 148, /**< Zenkaku/Hankaku */
|
||||||
|
Lang6 = 149, /**< reserved */
|
||||||
|
Lang7 = 150, /**< reserved */
|
||||||
|
Lang8 = 151, /**< reserved */
|
||||||
|
Lang9 = 152, /**< reserved */
|
||||||
|
|
||||||
|
Alterase = 153, /**< Erase-Eaze */
|
||||||
|
Sysreq = 154,
|
||||||
|
Cancel = 155, /**< AC Cancel */
|
||||||
|
Clear = 156,
|
||||||
|
Prior = 157,
|
||||||
|
Return2 = 158,
|
||||||
|
Separator = 159,
|
||||||
|
Out = 160,
|
||||||
|
Oper = 161,
|
||||||
|
Clearagain = 162,
|
||||||
|
Crsel = 163,
|
||||||
|
Exsel = 164,
|
||||||
|
|
||||||
|
Kp00 = 176,
|
||||||
|
Kp000 = 177,
|
||||||
|
Thousandsseparator = 178,
|
||||||
|
Decimalseparator = 179,
|
||||||
|
Currencyunit = 180,
|
||||||
|
Currencysubunit = 181,
|
||||||
|
KpLeftparen = 182,
|
||||||
|
KpRightparen = 183,
|
||||||
|
KpLeftbrace = 184,
|
||||||
|
KpRightbrace = 185,
|
||||||
|
KpTab = 186,
|
||||||
|
KpBackspace = 187,
|
||||||
|
KpA = 188,
|
||||||
|
KpB = 189,
|
||||||
|
KpC = 190,
|
||||||
|
KpD = 191,
|
||||||
|
KpE = 192,
|
||||||
|
KpF = 193,
|
||||||
|
KpXor = 194,
|
||||||
|
KpPower = 195,
|
||||||
|
KpPercent = 196,
|
||||||
|
KpLess = 197,
|
||||||
|
KpGreater = 198,
|
||||||
|
KpAmpersand = 199,
|
||||||
|
KpDblampersand = 200,
|
||||||
|
KpVerticalbar = 201,
|
||||||
|
KpDblverticalbar = 202,
|
||||||
|
KpColon = 203,
|
||||||
|
KpHash = 204,
|
||||||
|
KpSpace = 205,
|
||||||
|
KpAt = 206,
|
||||||
|
KpExclam = 207,
|
||||||
|
KpMemstore = 208,
|
||||||
|
KpMemrecall = 209,
|
||||||
|
KpMemclear = 210,
|
||||||
|
KpMemadd = 211,
|
||||||
|
KpMemsubtract = 212,
|
||||||
|
KpMemmultiply = 213,
|
||||||
|
KpMemdivide = 214,
|
||||||
|
KpPlusminus = 215,
|
||||||
|
KpClear = 216,
|
||||||
|
KpClearentry = 217,
|
||||||
|
KpBinary = 218,
|
||||||
|
KpOctal = 219,
|
||||||
|
KpDecimal = 220,
|
||||||
|
KpHexadecimal = 221,
|
||||||
|
|
||||||
|
Lctrl = 224,
|
||||||
|
Lshift = 225,
|
||||||
|
Lalt = 226, /**< alt, option */
|
||||||
|
Lgui = 227, /**< windows, command (apple), meta */
|
||||||
|
Rctrl = 228,
|
||||||
|
Rshift = 229,
|
||||||
|
Ralt = 230, /**< alt gr, option */
|
||||||
|
Rgui = 231, /**< windows, command (apple), meta */
|
||||||
|
|
||||||
|
Mode = 257, /**< I'm not sure if this is really not covered
|
||||||
|
* by any of the above, but since there's a
|
||||||
|
* special SDL_KMOD_MODE for it I'm adding it here
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* @} */ /* Usage page 0x07 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \name Usage page 0x0C
|
||||||
|
*
|
||||||
|
* These values are mapped from usage page 0x0C (USB consumer page).
|
||||||
|
*
|
||||||
|
* There are way more keys in the spec than we can represent in the
|
||||||
|
* current scancode range, so pick the ones that commonly come up in
|
||||||
|
* real world usage.
|
||||||
|
*/
|
||||||
|
/* @{ */
|
||||||
|
|
||||||
|
Sleep = 258, /**< Sleep */
|
||||||
|
Wake = 259, /**< Wake */
|
||||||
|
|
||||||
|
ChannelIncrement = 260, /**< Channel Increment */
|
||||||
|
ChannelDecrement = 261, /**< Channel Decrement */
|
||||||
|
|
||||||
|
MediaPlay = 262, /**< Play */
|
||||||
|
MediaPause = 263, /**< Pause */
|
||||||
|
MediaRecord = 264, /**< Record */
|
||||||
|
MediaFastForward = 265, /**< Fast Forward */
|
||||||
|
MediaRewind = 266, /**< Rewind */
|
||||||
|
MediaNextTrack = 267, /**< Next Track */
|
||||||
|
MediaPreviousTrack = 268, /**< Previous Track */
|
||||||
|
MediaStop = 269, /**< Stop */
|
||||||
|
MediaEject = 270, /**< Eject */
|
||||||
|
MediaPlayPause = 271, /**< Play / Pause */
|
||||||
|
MediaSelect = 272, /* Media Select */
|
||||||
|
|
||||||
|
AcNew = 273, /**< AC New */
|
||||||
|
AcOpen = 274, /**< AC Open */
|
||||||
|
AcClose = 275, /**< AC Close */
|
||||||
|
AcExit = 276, /**< AC Exit */
|
||||||
|
AcSave = 277, /**< AC Save */
|
||||||
|
AcPrint = 278, /**< AC Print */
|
||||||
|
AcProperties = 279, /**< AC Properties */
|
||||||
|
|
||||||
|
AcSearch = 280, /**< AC Search */
|
||||||
|
AcHome = 281, /**< AC Home */
|
||||||
|
AcBack = 282, /**< AC Back */
|
||||||
|
AcForward = 283, /**< AC Forward */
|
||||||
|
AcStop = 284, /**< AC Stop */
|
||||||
|
AcRefresh = 285, /**< AC Refresh */
|
||||||
|
AcBookmarks = 286, /**< AC Bookmarks */
|
||||||
|
|
||||||
|
/* @} */ /* Usage page 0x0C */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \name Mobile keys
|
||||||
|
*
|
||||||
|
* These are values that are often used on mobile phones.
|
||||||
|
*/
|
||||||
|
/* @{ */
|
||||||
|
|
||||||
|
Softleft = 287, /**< Usually situated below the display on phones and
|
||||||
|
used as a multi-function feature key for selecting
|
||||||
|
a software defined function shown on the bottom left
|
||||||
|
of the display. */
|
||||||
|
Softright = 288, /**< Usually situated below the display on phones and
|
||||||
|
used as a multi-function feature key for selecting
|
||||||
|
a software defined function shown on the bottom right
|
||||||
|
of the display. */
|
||||||
|
Call = 289, /**< Used for accepting phone calls. */
|
||||||
|
Endcall = 290, /**< Used for rejecting phone calls. */
|
||||||
|
|
||||||
|
/* @} */ /* Mobile keys */
|
||||||
|
|
||||||
|
/* Add any other keys here. */
|
||||||
|
|
||||||
|
Reserved = 400, /**< 400-500 reserved for dynamic keycodes */
|
||||||
|
|
||||||
|
Count = 512,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**< not a key, just marks the number of scancodes for array bounds */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* SDL_scancode_h_ */
|
||||||
331
src/SDL_sensor.bf
Normal file
331
src/SDL_sensor.bf
Normal file
@@ -0,0 +1,331 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategorySensor
|
||||||
|
*
|
||||||
|
* SDL sensor management.
|
||||||
|
*
|
||||||
|
* These APIs grant access to gyros and accelerometers on various platforms.
|
||||||
|
*
|
||||||
|
* In order to use these functions, SDL_Init() must have been called with the
|
||||||
|
* SDL_INIT_SENSOR flag. This causes SDL to scan the system for sensors, and
|
||||||
|
* load appropriate drivers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
/* *INDENT-OFF* */
|
||||||
|
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The opaque structure used to identify an opened SDL sensor.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct Sensor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a unique ID for a sensor for the time it is connected to the
|
||||||
|
* system, and is never reused for the lifetime of the application.
|
||||||
|
*
|
||||||
|
* The value 0 is an invalid ID.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public typealias SensorID = Uint32;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A constant to represent standard gravity for accelerometer sensors.
|
||||||
|
*
|
||||||
|
* The accelerometer returns the current acceleration in SI meters per second
|
||||||
|
* squared. This measurement includes the force of gravity, so a device at
|
||||||
|
* rest will have an value of SDL_STANDARD_GRAVITY away from the center of the
|
||||||
|
* earth, which is a positive Y value.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public const let STANDARD_GRAVITY = 9.80665f;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The different sensors defined by SDL.
|
||||||
|
*
|
||||||
|
* Additional sensors may be available, using platform dependent semantics.
|
||||||
|
*
|
||||||
|
* Here are the additional Android sensors:
|
||||||
|
*
|
||||||
|
* https://developer.android.com/reference/android/hardware/SensorEvent.html#values
|
||||||
|
*
|
||||||
|
* Accelerometer sensor notes:
|
||||||
|
*
|
||||||
|
* The accelerometer returns the current acceleration in SI meters per second
|
||||||
|
* squared. This measurement includes the force of gravity, so a device at
|
||||||
|
* rest will have an value of SDL_STANDARD_GRAVITY away from the center of the
|
||||||
|
* earth, which is a positive Y value.
|
||||||
|
*
|
||||||
|
* - `values[0]`: Acceleration on the x axis
|
||||||
|
* - `values[1]`: Acceleration on the y axis
|
||||||
|
* - `values[2]`: Acceleration on the z axis
|
||||||
|
*
|
||||||
|
* For phones and tablets held in natural orientation and game controllers
|
||||||
|
* held in front of you, the axes are defined as follows:
|
||||||
|
*
|
||||||
|
* - -X ... +X : left ... right
|
||||||
|
* - -Y ... +Y : bottom ... top
|
||||||
|
* - -Z ... +Z : farther ... closer
|
||||||
|
*
|
||||||
|
* The accelerometer axis data is not changed when the device is rotated.
|
||||||
|
*
|
||||||
|
* Gyroscope sensor notes:
|
||||||
|
*
|
||||||
|
* The gyroscope returns the current rate of rotation in radians per second.
|
||||||
|
* The rotation is positive in the counter-clockwise direction. That is, an
|
||||||
|
* observer looking from a positive location on one of the axes would see
|
||||||
|
* positive rotation on that axis when it appeared to be rotating
|
||||||
|
* counter-clockwise.
|
||||||
|
*
|
||||||
|
* - `values[0]`: Angular speed around the x axis (pitch)
|
||||||
|
* - `values[1]`: Angular speed around the y axis (yaw)
|
||||||
|
* - `values[2]`: Angular speed around the z axis (roll)
|
||||||
|
*
|
||||||
|
* For phones and tablets held in natural orientation and game controllers
|
||||||
|
* held in front of you, the axes are defined as follows:
|
||||||
|
*
|
||||||
|
* - -X ... +X : left ... right
|
||||||
|
* - -Y ... +Y : bottom ... top
|
||||||
|
* - -Z ... +Z : farther ... closer
|
||||||
|
*
|
||||||
|
* The gyroscope axis data is not changed when the device is rotated.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetCurrentDisplayOrientation
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum SensorType : c_int
|
||||||
|
{
|
||||||
|
Invalid = -1, /**< Returned for an invalid sensor */
|
||||||
|
Unknown, /**< Unknown sensor type */
|
||||||
|
Accel, /**< Accelerometer */
|
||||||
|
Gyro, /**< Gyroscope */
|
||||||
|
AccelL, /**< Accelerometer for left Joy-Con controller and Wii nunchuk */
|
||||||
|
GyroL, /**< Gyroscope for left Joy-Con controller */
|
||||||
|
AccelR, /**< Accelerometer for right Joy-Con controller */
|
||||||
|
GyroR, /**< Gyroscope for right Joy-Con controller */
|
||||||
|
Count,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Function prototypes */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of currently connected sensors.
|
||||||
|
*
|
||||||
|
* \param count a pointer filled in with the number of sensors returned, may
|
||||||
|
* be NULL.
|
||||||
|
* \returns a 0 terminated array of sensor instance IDs or NULL on failure;
|
||||||
|
* call SDL_GetError() for more information. This should be freed
|
||||||
|
* with SDL_free() when it is no longer needed.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetSensors")] public static extern SensorID* GetSensors(out c_int count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the implementation dependent name of a sensor.
|
||||||
|
*
|
||||||
|
* This can be called before any sensors are opened.
|
||||||
|
*
|
||||||
|
* \param instance_id the sensor instance ID.
|
||||||
|
* \returns the sensor name, or NULL if `instance_id` is not valid.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetSensorNameForID")] public static extern c_char* GetSensorNameForID(SensorID instance_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type of a sensor.
|
||||||
|
*
|
||||||
|
* This can be called before any sensors are opened.
|
||||||
|
*
|
||||||
|
* \param instance_id the sensor instance ID.
|
||||||
|
* \returns the SDL_SensorType, or `SDL_SENSOR_INVALID` if `instance_id` is
|
||||||
|
* not valid.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetSensorTypeForID")] public static extern SensorType GetSensorTypeForID(SensorID instance_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the platform dependent type of a sensor.
|
||||||
|
*
|
||||||
|
* This can be called before any sensors are opened.
|
||||||
|
*
|
||||||
|
* \param instance_id the sensor instance ID.
|
||||||
|
* \returns the sensor platform dependent type, or -1 if `instance_id` is not
|
||||||
|
* valid.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetSensorNonPortableTypeForID")] public static extern c_int GetSensorNonPortableTypeForID(SensorID instance_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a sensor for use.
|
||||||
|
*
|
||||||
|
* \param instance_id the sensor instance ID.
|
||||||
|
* \returns an SDL_Sensor object or NULL on failure; call SDL_GetError() for
|
||||||
|
* more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OpenSensor")] public static extern Sensor* OpenSensor(SensorID instance_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the SDL_Sensor associated with an instance ID.
|
||||||
|
*
|
||||||
|
* \param instance_id the sensor instance ID.
|
||||||
|
* \returns an SDL_Sensor object or NULL on failure; call SDL_GetError() for
|
||||||
|
* more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetSensorFromID")] public static extern Sensor* GetSensorFromID(SensorID instance_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the properties associated with a sensor.
|
||||||
|
*
|
||||||
|
* \param sensor the SDL_Sensor object.
|
||||||
|
* \returns a valid property ID on success or 0 on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetSensorProperties")] public static extern PropertiesID GetSensorProperties(Sensor* sensor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the implementation dependent name of a sensor.
|
||||||
|
*
|
||||||
|
* \param sensor the SDL_Sensor object.
|
||||||
|
* \returns the sensor name or NULL on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetSensorName")] public static extern c_char* GetSensorName(Sensor* sensor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type of a sensor.
|
||||||
|
*
|
||||||
|
* \param sensor the SDL_Sensor object to inspect.
|
||||||
|
* \returns the SDL_SensorType type, or `SDL_SENSOR_INVALID` if `sensor` is
|
||||||
|
* NULL.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetSensorType")] public static extern SensorType GetSensorType(Sensor* sensor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the platform dependent type of a sensor.
|
||||||
|
*
|
||||||
|
* \param sensor the SDL_Sensor object to inspect.
|
||||||
|
* \returns the sensor platform dependent type, or -1 if `sensor` is NULL.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetSensorNonPortableType")] public static extern c_int GetSensorNonPortableType(Sensor* sensor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the instance ID of a sensor.
|
||||||
|
*
|
||||||
|
* \param sensor the SDL_Sensor object to inspect.
|
||||||
|
* \returns the sensor instance ID, or 0 on failure; call SDL_GetError() for
|
||||||
|
* more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetSensorID")] public static extern SensorID GetSensorID(Sensor* sensor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current state of an opened sensor.
|
||||||
|
*
|
||||||
|
* The number of values and interpretation of the data is sensor dependent.
|
||||||
|
*
|
||||||
|
* \param sensor the SDL_Sensor object to query.
|
||||||
|
* \param data a pointer filled with the current sensor state.
|
||||||
|
* \param num_values the number of values to write to data.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetSensorData")] public static extern bool GetSensorData(Sensor* sensor, float* data, c_int num_values);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close a sensor previously opened with SDL_OpenSensor().
|
||||||
|
*
|
||||||
|
* \param sensor the SDL_Sensor object to close.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CloseSensor")] public static extern void CloseSensor(Sensor* sensor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the current state of the open sensors.
|
||||||
|
*
|
||||||
|
* This is called automatically by the event loop if sensor events are
|
||||||
|
* enabled.
|
||||||
|
*
|
||||||
|
* This needs to be called from the thread that initialized the sensor
|
||||||
|
* subsystem.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_UpdateSensors")] public static extern void UpdateSensors();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
/* *INDENT-OFF* */
|
||||||
|
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_sensor_h_ */
|
||||||
6163
src/SDL_stdinc.bf
Normal file
6163
src/SDL_stdinc.bf
Normal file
File diff suppressed because it is too large
Load Diff
697
src/SDL_storage.bf
Normal file
697
src/SDL_storage.bf
Normal file
@@ -0,0 +1,697 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryStorage
|
||||||
|
*
|
||||||
|
* The storage API is a high-level API designed to abstract away the
|
||||||
|
* portability issues that come up when using something lower-level (in SDL's
|
||||||
|
* case, this sits on top of the [Filesystem](CategoryFilesystem) and
|
||||||
|
* [IOStream](CategoryIOStream) subsystems). It is significantly more
|
||||||
|
* restrictive than a typical filesystem API, for a number of reasons:
|
||||||
|
*
|
||||||
|
* 1. **What to Access:** A common pitfall with existing filesystem APIs is
|
||||||
|
* the assumption that all storage is monolithic. However, many other
|
||||||
|
* platforms (game consoles in particular) are more strict about what _type_
|
||||||
|
* of filesystem is being accessed; for example, game content and user data
|
||||||
|
* are usually two separate storage devices with entirely different
|
||||||
|
* characteristics (and possibly different low-level APIs altogether!).
|
||||||
|
*
|
||||||
|
* 2. **How to Access:** Another common mistake is applications assuming that
|
||||||
|
* all storage is universally writeable - again, many platforms treat game
|
||||||
|
* content and user data as two separate storage devices, and only user data
|
||||||
|
* is writeable while game content is read-only.
|
||||||
|
*
|
||||||
|
* 3. **When to Access:** The most common portability issue with filesystem
|
||||||
|
* access is _timing_ - you cannot always assume that the storage device is
|
||||||
|
* always accessible all of the time, nor can you assume that there are no
|
||||||
|
* limits to how long you have access to a particular device.
|
||||||
|
*
|
||||||
|
* Consider the following example:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* void ReadGameData(void)
|
||||||
|
* {
|
||||||
|
* extern char** fileNames;
|
||||||
|
* extern size_t numFiles;
|
||||||
|
* for (size_t i = 0; i < numFiles; i += 1) {
|
||||||
|
* FILE *data = fopen(fileNames[i], "rwb");
|
||||||
|
* if (data == NULL) {
|
||||||
|
* // Something bad happened!
|
||||||
|
* } else {
|
||||||
|
* // A bunch of stuff happens here
|
||||||
|
* fclose(data);
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* void ReadSave(void)
|
||||||
|
* {
|
||||||
|
* FILE *save = fopen("saves/save0.sav", "rb");
|
||||||
|
* if (save == NULL) {
|
||||||
|
* // Something bad happened!
|
||||||
|
* } else {
|
||||||
|
* // A bunch of stuff happens here
|
||||||
|
* fclose(save);
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* void WriteSave(void)
|
||||||
|
* {
|
||||||
|
* FILE *save = fopen("saves/save0.sav", "wb");
|
||||||
|
* if (save == NULL) {
|
||||||
|
* // Something bad happened!
|
||||||
|
* } else {
|
||||||
|
* // A bunch of stuff happens here
|
||||||
|
* fclose(save);
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Going over the bullet points again:
|
||||||
|
*
|
||||||
|
* 1. **What to Access:** This code accesses a global filesystem; game data
|
||||||
|
* and saves are all presumed to be in the current working directory (which
|
||||||
|
* may or may not be the game's installation folder!).
|
||||||
|
*
|
||||||
|
* 2. **How to Access:** This code assumes that content paths are writeable,
|
||||||
|
* and that save data is also writeable despite being in the same location as
|
||||||
|
* the game data.
|
||||||
|
*
|
||||||
|
* 3. **When to Access:** This code assumes that they can be called at any
|
||||||
|
* time, since the filesystem is always accessible and has no limits on how
|
||||||
|
* long the filesystem is being accessed.
|
||||||
|
*
|
||||||
|
* Due to these assumptions, the filesystem code is not portable and will fail
|
||||||
|
* under these common scenarios:
|
||||||
|
*
|
||||||
|
* - The game is installed on a device that is read-only, both content loading
|
||||||
|
* and game saves will fail or crash outright
|
||||||
|
* - Game/User storage is not implicitly mounted, so no files will be found
|
||||||
|
* for either scenario when a platform requires explicitly mounting
|
||||||
|
* filesystems
|
||||||
|
* - Save data may not be safe since the I/O is not being flushed or
|
||||||
|
* validated, so an error occurring elsewhere in the program may result in
|
||||||
|
* missing/corrupted save data
|
||||||
|
*
|
||||||
|
* When using SDL_Storage, these types of problems are virtually impossible to
|
||||||
|
* trip over:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* void ReadGameData(void)
|
||||||
|
* {
|
||||||
|
* extern char** fileNames;
|
||||||
|
* extern size_t numFiles;
|
||||||
|
*
|
||||||
|
* SDL_Storage *title = SDL_OpenTitleStorage(NULL, 0);
|
||||||
|
* if (title == NULL) {
|
||||||
|
* // Something bad happened!
|
||||||
|
* }
|
||||||
|
* while (!SDL_StorageReady(title)) {
|
||||||
|
* SDL_Delay(1);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* for (size_t i = 0; i < numFiles; i += 1) {
|
||||||
|
* void* dst;
|
||||||
|
* Uint64 dstLen = 0;
|
||||||
|
*
|
||||||
|
* if (SDL_GetStorageFileSize(title, fileNames[i], &dstLen) && dstLen > 0) {
|
||||||
|
* dst = SDL_malloc(dstLen);
|
||||||
|
* if (SDL_ReadStorageFile(title, fileNames[i], dst, dstLen)) {
|
||||||
|
* // A bunch of stuff happens here
|
||||||
|
* } else {
|
||||||
|
* // Something bad happened!
|
||||||
|
* }
|
||||||
|
* SDL_free(dst);
|
||||||
|
* } else {
|
||||||
|
* // Something bad happened!
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* SDL_CloseStorage(title);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* void ReadSave(void)
|
||||||
|
* {
|
||||||
|
* SDL_Storage *user = SDL_OpenUserStorage("libsdl", "Storage Example", 0);
|
||||||
|
* if (user == NULL) {
|
||||||
|
* // Something bad happened!
|
||||||
|
* }
|
||||||
|
* while (!SDL_StorageReady(user)) {
|
||||||
|
* SDL_Delay(1);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* Uint64 saveLen = 0;
|
||||||
|
* if (SDL_GetStorageFileSize(user, "save0.sav", &saveLen) && saveLen > 0) {
|
||||||
|
* void* dst = SDL_malloc(saveLen);
|
||||||
|
* if (SDL_ReadStorageFile(user, "save0.sav", dst, saveLen)) {
|
||||||
|
* // A bunch of stuff happens here
|
||||||
|
* } else {
|
||||||
|
* // Something bad happened!
|
||||||
|
* }
|
||||||
|
* SDL_free(dst);
|
||||||
|
* } else {
|
||||||
|
* // Something bad happened!
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* SDL_CloseStorage(user);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* void WriteSave(void)
|
||||||
|
* {
|
||||||
|
* SDL_Storage *user = SDL_OpenUserStorage("libsdl", "Storage Example", 0);
|
||||||
|
* if (user == NULL) {
|
||||||
|
* // Something bad happened!
|
||||||
|
* }
|
||||||
|
* while (!SDL_StorageReady(user)) {
|
||||||
|
* SDL_Delay(1);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* extern void *saveData; // A bunch of stuff happened here...
|
||||||
|
* extern Uint64 saveLen;
|
||||||
|
* if (!SDL_WriteStorageFile(user, "save0.sav", saveData, saveLen)) {
|
||||||
|
* // Something bad happened!
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* SDL_CloseStorage(user);
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Note the improvements that SDL_Storage makes:
|
||||||
|
*
|
||||||
|
* 1. **What to Access:** This code explicitly reads from a title or user
|
||||||
|
* storage device based on the context of the function.
|
||||||
|
*
|
||||||
|
* 2. **How to Access:** This code explicitly uses either a read or write
|
||||||
|
* function based on the context of the function.
|
||||||
|
*
|
||||||
|
* 3. **When to Access:** This code explicitly opens the device when it needs
|
||||||
|
* to, and closes it when it is finished working with the filesystem.
|
||||||
|
*
|
||||||
|
* The result is an application that is significantly more robust against the
|
||||||
|
* increasing demands of platforms and their filesystems!
|
||||||
|
*
|
||||||
|
* A publicly available example of an SDL_Storage backend is the
|
||||||
|
* [Steam Cloud](https://partner.steamgames.com/doc/features/cloud)
|
||||||
|
* backend - you can initialize Steamworks when starting the program, and then
|
||||||
|
* SDL will recognize that Steamworks is initialized and automatically use
|
||||||
|
* ISteamRemoteStorage when the application opens user storage. More
|
||||||
|
* importantly, when you _open_ storage it knows to begin a "batch" of
|
||||||
|
* filesystem operations, and when you _close_ storage it knows to end and
|
||||||
|
* flush the batch. This is used by Steam to support
|
||||||
|
* [Dynamic Cloud Sync](https://steamcommunity.com/groups/steamworks/announcements/detail/3142949576401813670)
|
||||||
|
* ; users can save data on one PC, put the device to sleep, and then continue
|
||||||
|
* playing on another PC (and vice versa) with the save data fully
|
||||||
|
* synchronized across all devices, allowing for a seamless experience without
|
||||||
|
* having to do full restarts of the program.
|
||||||
|
*
|
||||||
|
* ## Notes on valid paths
|
||||||
|
*
|
||||||
|
* All paths in the Storage API use Unix-style path separators ('/'). Using a
|
||||||
|
* different path separator will not work, even if the underlying platform
|
||||||
|
* would otherwise accept it. This is to keep code using the Storage API
|
||||||
|
* portable between platforms and Storage implementations and simplify app
|
||||||
|
* code.
|
||||||
|
*
|
||||||
|
* Paths with relative directories ("." and "..") are forbidden by the Storage
|
||||||
|
* API.
|
||||||
|
*
|
||||||
|
* All valid UTF-8 strings (discounting the NULL terminator character and the
|
||||||
|
* '/' path separator) are usable for filenames, however, an underlying
|
||||||
|
* Storage implementation may not support particularly strange sequences and
|
||||||
|
* refuse to create files with those names, etc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function interface for SDL_Storage.
|
||||||
|
*
|
||||||
|
* Apps that want to supply a custom implementation of SDL_Storage will fill
|
||||||
|
* in all the functions in this struct, and then pass it to SDL_OpenStorage to
|
||||||
|
* create a custom SDL_Storage object.
|
||||||
|
*
|
||||||
|
* It is not usually necessary to do this; SDL provides standard
|
||||||
|
* implementations for many things you might expect to do with an SDL_Storage.
|
||||||
|
*
|
||||||
|
* This structure should be initialized using SDL_INIT_INTERFACE()
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_INIT_INTERFACE
|
||||||
|
*/
|
||||||
|
[CRepr] public struct StorageInterface
|
||||||
|
{
|
||||||
|
/* The version of this interface */
|
||||||
|
public Uint32 version;
|
||||||
|
|
||||||
|
/* Called when the storage is closed */
|
||||||
|
public function bool(void*) close;
|
||||||
|
|
||||||
|
/* Optional, returns whether the storage is currently ready for access */
|
||||||
|
public function bool(void*) ready;
|
||||||
|
|
||||||
|
/* Enumerate a directory, optional for write-only storage */
|
||||||
|
public function bool(void*, c_char*, EnumerateDirectoryCallback, void*) enumerate;
|
||||||
|
|
||||||
|
/* Get path information, optional for write-only storage */
|
||||||
|
public function bool(void*, c_char*, PathInfo*) info;
|
||||||
|
|
||||||
|
/* Read a file from storage, optional for write-only storage */
|
||||||
|
public function bool(void*, c_char*, void*, Uint64) read_file;
|
||||||
|
|
||||||
|
/* Write a file to storage, optional for read-only storage */
|
||||||
|
public function bool(void*, c_char*, void*, Uint64) write_file;
|
||||||
|
|
||||||
|
/* Create a directory, optional for read-only storage */
|
||||||
|
public function bool(void*, c_char*) mkdir;
|
||||||
|
|
||||||
|
/* Remove a file or empty directory, optional for read-only storage */
|
||||||
|
public function bool(void*, c_char*) remove;
|
||||||
|
|
||||||
|
/* Rename a path, optional for read-only storage */
|
||||||
|
public function bool(void*, c_char*, c_char*) rename;
|
||||||
|
|
||||||
|
/* Copy a file, optional for read-only storage */
|
||||||
|
public function bool(void*, c_char*, c_char*) copy;
|
||||||
|
|
||||||
|
/* Get the space remaining, optional for read-only storage */
|
||||||
|
public function Uint64(void* userdata) space_remaining;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check the size of SDL_StorageInterface
|
||||||
|
*
|
||||||
|
* If this assert fails, either the compiler is padding to an unexpected size,
|
||||||
|
* or the interface has been updated and this should be updated to match and
|
||||||
|
* the code using this interface should be updated to handle the old version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abstract interface for filesystem access.
|
||||||
|
*
|
||||||
|
* This is an opaque datatype. One can create this object using standard SDL
|
||||||
|
* functions like SDL_OpenTitleStorage or SDL_OpenUserStorage, etc, or create
|
||||||
|
* an object with a custom implementation using SDL_OpenStorage.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens up a read-only container for the application's filesystem.
|
||||||
|
*
|
||||||
|
* By default, SDL_OpenTitleStorage uses the generic storage implementation.
|
||||||
|
* When the path override is not provided, the generic implementation will use
|
||||||
|
* the output of SDL_GetBasePath as the base path.
|
||||||
|
*
|
||||||
|
* \param override a path to override the backend's default title root.
|
||||||
|
* \param props a property list that may contain backend-specific information.
|
||||||
|
* \returns a title storage container on success or NULL on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CloseStorage
|
||||||
|
* \sa SDL_GetStorageFileSize
|
||||||
|
* \sa SDL_OpenUserStorage
|
||||||
|
* \sa SDL_ReadStorageFile
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OpenTitleStorage")] public static extern Storage* OpenTitleStorage(c_char* @override, PropertiesID props);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens up a container for a user's unique read/write filesystem.
|
||||||
|
*
|
||||||
|
* While title storage can generally be kept open throughout runtime, user
|
||||||
|
* storage should only be opened when the client is ready to read/write files.
|
||||||
|
* This allows the backend to properly batch file operations and flush them
|
||||||
|
* when the container has been closed; ensuring safe and optimal save I/O.
|
||||||
|
*
|
||||||
|
* \param org the name of your organization.
|
||||||
|
* \param app the name of your application.
|
||||||
|
* \param props a property list that may contain backend-specific information.
|
||||||
|
* \returns a user storage container on success or NULL on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CloseStorage
|
||||||
|
* \sa SDL_GetStorageFileSize
|
||||||
|
* \sa SDL_GetStorageSpaceRemaining
|
||||||
|
* \sa SDL_OpenTitleStorage
|
||||||
|
* \sa SDL_ReadStorageFile
|
||||||
|
* \sa SDL_StorageReady
|
||||||
|
* \sa SDL_WriteStorageFile
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OpenUserStorage")] public static extern Storage* OpenUserStorage(c_char* org, c_char* app, PropertiesID props);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens up a container for local filesystem storage.
|
||||||
|
*
|
||||||
|
* This is provided for development and tools. Portable applications should
|
||||||
|
* use SDL_OpenTitleStorage() for access to game data and
|
||||||
|
* SDL_OpenUserStorage() for access to user data.
|
||||||
|
*
|
||||||
|
* \param path the base path prepended to all storage paths, or NULL for no
|
||||||
|
* base path.
|
||||||
|
* \returns a filesystem storage container on success or NULL on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CloseStorage
|
||||||
|
* \sa SDL_GetStorageFileSize
|
||||||
|
* \sa SDL_GetStorageSpaceRemaining
|
||||||
|
* \sa SDL_OpenTitleStorage
|
||||||
|
* \sa SDL_OpenUserStorage
|
||||||
|
* \sa SDL_ReadStorageFile
|
||||||
|
* \sa SDL_WriteStorageFile
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OpenFileStorage")] public static extern Storage* OpenFileStorage(c_char* path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens up a container using a client-provided storage interface.
|
||||||
|
*
|
||||||
|
* Applications do not need to use this function unless they are providing
|
||||||
|
* their own SDL_Storage implementation. If you just need an SDL_Storage, you
|
||||||
|
* should use the built-in implementations in SDL, like SDL_OpenTitleStorage()
|
||||||
|
* or SDL_OpenUserStorage().
|
||||||
|
*
|
||||||
|
* This function makes a copy of `iface` and the caller does not need to keep
|
||||||
|
* it around after this call.
|
||||||
|
*
|
||||||
|
* \param iface the interface that implements this storage, initialized using
|
||||||
|
* SDL_INIT_INTERFACE().
|
||||||
|
* \param userdata the pointer that will be passed to the interface functions.
|
||||||
|
* \returns a storage container on success or NULL on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CloseStorage
|
||||||
|
* \sa SDL_GetStorageFileSize
|
||||||
|
* \sa SDL_GetStorageSpaceRemaining
|
||||||
|
* \sa SDL_INIT_INTERFACE
|
||||||
|
* \sa SDL_ReadStorageFile
|
||||||
|
* \sa SDL_StorageReady
|
||||||
|
* \sa SDL_WriteStorageFile
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OpenStorage")] public static extern Storage* OpenStorage(StorageInterface* iface, void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes and frees a storage container.
|
||||||
|
*
|
||||||
|
* \param storage a storage container to close.
|
||||||
|
* \returns true if the container was freed with no errors, false otherwise;
|
||||||
|
* call SDL_GetError() for more information. Even if the function
|
||||||
|
* returns an error, the container data will be freed; the error is
|
||||||
|
* only for informational purposes.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_OpenFileStorage
|
||||||
|
* \sa SDL_OpenStorage
|
||||||
|
* \sa SDL_OpenTitleStorage
|
||||||
|
* \sa SDL_OpenUserStorage
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CloseStorage")] public static extern bool CloseStorage(Storage* storage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the storage container is ready to use.
|
||||||
|
*
|
||||||
|
* This function should be called in regular intervals until it returns true -
|
||||||
|
* however, it is not recommended to spinwait on this call, as the backend may
|
||||||
|
* depend on a synchronous message loop. You might instead poll this in your
|
||||||
|
* game's main loop while processing events and drawing a loading screen.
|
||||||
|
*
|
||||||
|
* \param storage a storage container to query.
|
||||||
|
* \returns true if the container is ready, false otherwise.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_StorageReady")] public static extern bool StorageReady(Storage* storage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query the size of a file within a storage container.
|
||||||
|
*
|
||||||
|
* \param storage a storage container to query.
|
||||||
|
* \param path the relative path of the file to query.
|
||||||
|
* \param length a pointer to be filled with the file's length.
|
||||||
|
* \returns true if the file could be queried or false on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ReadStorageFile
|
||||||
|
* \sa SDL_StorageReady
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetStorageFileSize")] public static extern bool GetStorageFileSize(Storage* storage, c_char* path, Uint64* length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Synchronously read a file from a storage container into a client-provided
|
||||||
|
* buffer.
|
||||||
|
*
|
||||||
|
* The value of `length` must match the length of the file exactly; call
|
||||||
|
* SDL_GetStorageFileSize() to get this value. This behavior may be relaxed in
|
||||||
|
* a future release.
|
||||||
|
*
|
||||||
|
* \param storage a storage container to read from.
|
||||||
|
* \param path the relative path of the file to read.
|
||||||
|
* \param destination a client-provided buffer to read the file into.
|
||||||
|
* \param length the length of the destination buffer.
|
||||||
|
* \returns true if the file was read or false on failure; call SDL_GetError()
|
||||||
|
* for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetStorageFileSize
|
||||||
|
* \sa SDL_StorageReady
|
||||||
|
* \sa SDL_WriteStorageFile
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ReadStorageFile")] public static extern bool ReadStorageFile(Storage* storage, c_char* path, void* destination, Uint64 length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Synchronously write a file from client memory into a storage container.
|
||||||
|
*
|
||||||
|
* \param storage a storage container to write to.
|
||||||
|
* \param path the relative path of the file to write.
|
||||||
|
* \param source a client-provided buffer to write from.
|
||||||
|
* \param length the length of the source buffer.
|
||||||
|
* \returns true if the file was written or false on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetStorageSpaceRemaining
|
||||||
|
* \sa SDL_ReadStorageFile
|
||||||
|
* \sa SDL_StorageReady
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_WriteStorageFile")] public static extern bool WriteStorageFile(Storage* storage, c_char* path, void* source, Uint64 length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a directory in a writable storage container.
|
||||||
|
*
|
||||||
|
* \param storage a storage container.
|
||||||
|
* \param path the path of the directory to create.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_StorageReady
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateStorageDirectory")] public static extern bool CreateStorageDirectory(Storage* storage, c_char* path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumerate a directory in a storage container through a callback function.
|
||||||
|
*
|
||||||
|
* This function provides every directory entry through an app-provided
|
||||||
|
* callback, called once for each directory entry, until all results have been
|
||||||
|
* provided or the callback returns either SDL_ENUM_SUCCESS or
|
||||||
|
* SDL_ENUM_FAILURE.
|
||||||
|
*
|
||||||
|
* This will return false if there was a system problem in general, or if a
|
||||||
|
* callback returns SDL_ENUM_FAILURE. A successful return means a callback
|
||||||
|
* returned SDL_ENUM_SUCCESS to halt enumeration, or all directory entries
|
||||||
|
* were enumerated.
|
||||||
|
*
|
||||||
|
* If `path` is NULL, this is treated as a request to enumerate the root of
|
||||||
|
* the storage container's tree. An empty string also works for this.
|
||||||
|
*
|
||||||
|
* \param storage a storage container.
|
||||||
|
* \param path the path of the directory to enumerate, or NULL for the root.
|
||||||
|
* \param callback a function that is called for each entry in the directory.
|
||||||
|
* \param userdata a pointer that is passed to `callback`.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_StorageReady
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_EnumerateStorageDirectory")] public static extern bool EnumerateStorageDirectory(Storage* storage, c_char* path, EnumerateDirectoryCallback callback, void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a file or an empty directory in a writable storage container.
|
||||||
|
*
|
||||||
|
* \param storage a storage container.
|
||||||
|
* \param path the path to remove from the filesystem.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_StorageReady
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_RemoveStoragePath")] public static extern bool RemoveStoragePath(Storage* storage, c_char* path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rename a file or directory in a writable storage container.
|
||||||
|
*
|
||||||
|
* \param storage a storage container.
|
||||||
|
* \param oldpath the old path.
|
||||||
|
* \param newpath the new path.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_StorageReady
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_RenameStoragePath")] public static extern bool RenameStoragePath(Storage* storage, c_char* oldpath, c_char* newpath);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy a file in a writable storage container.
|
||||||
|
*
|
||||||
|
* \param storage a storage container.
|
||||||
|
* \param oldpath the old path.
|
||||||
|
* \param newpath the new path.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_StorageReady
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CopyStorageFile")] public static extern bool CopyStorageFile(Storage* storage, c_char* oldpath, c_char* newpath);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about a filesystem path in a storage container.
|
||||||
|
*
|
||||||
|
* \param storage a storage container.
|
||||||
|
* \param path the path to query.
|
||||||
|
* \param info a pointer filled in with information about the path, or NULL to
|
||||||
|
* check for the existence of a file.
|
||||||
|
* \returns true on success or false if the file doesn't exist, or another
|
||||||
|
* failure; call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_StorageReady
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetStoragePathInfo")] public static extern bool GetStoragePathInfo(Storage* storage, c_char* path, out PathInfo info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queries the remaining space in a storage container.
|
||||||
|
*
|
||||||
|
* \param storage a storage container to query.
|
||||||
|
* \returns the amount of remaining space, in bytes.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_StorageReady
|
||||||
|
* \sa SDL_WriteStorageFile
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetStorageSpaceRemaining")] public static extern Uint64 GetStorageSpaceRemaining(Storage* storage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumerate a directory tree, filtered by pattern, and return a list.
|
||||||
|
*
|
||||||
|
* Files are filtered out if they don't match the string in `pattern`, which
|
||||||
|
* may contain wildcard characters `*` (match everything) and `?` (match one
|
||||||
|
* character). If pattern is NULL, no filtering is done and all results are
|
||||||
|
* returned. Subdirectories are permitted, and are specified with a path
|
||||||
|
* separator of '/'. Wildcard characters `*` and `?` never match a path
|
||||||
|
* separator.
|
||||||
|
*
|
||||||
|
* `flags` may be set to SDL_GLOB_CASEINSENSITIVE to make the pattern matching
|
||||||
|
* case-insensitive.
|
||||||
|
*
|
||||||
|
* The returned array is always NULL-terminated, for your iterating
|
||||||
|
* convenience, but if `count` is non-NULL, on return it will contain the
|
||||||
|
* number of items in the array, not counting the NULL terminator.
|
||||||
|
*
|
||||||
|
* If `path` is NULL, this is treated as a request to enumerate the root of
|
||||||
|
* the storage container's tree. An empty string also works for this.
|
||||||
|
*
|
||||||
|
* \param storage a storage container.
|
||||||
|
* \param path the path of the directory to enumerate, or NULL for the root.
|
||||||
|
* \param pattern the pattern that files in the directory must match. Can be
|
||||||
|
* NULL.
|
||||||
|
* \param flags `SDL_GLOB_*` bitflags that affect this search.
|
||||||
|
* \param count on return, will be set to the number of items in the returned
|
||||||
|
* array. Can be NULL.
|
||||||
|
* \returns an array of strings on success or NULL on failure; call
|
||||||
|
* SDL_GetError() for more information. The caller should pass the
|
||||||
|
* returned pointer to SDL_free when done with it. This is a single
|
||||||
|
* allocation that should be freed with SDL_free() when it is no
|
||||||
|
* longer needed.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread, assuming
|
||||||
|
* the `storage` object is thread-safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GlobStorageDirectory")] public static extern c_char** GlobStorageDirectory(Storage* storage, c_char* path, c_char* pattern, GlobFlags flags, c_int* count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_storage_h_ */
|
||||||
1781
src/SDL_surface.bf
Normal file
1781
src/SDL_surface.bf
Normal file
File diff suppressed because it is too large
Load Diff
827
src/SDL_system.bf
Normal file
827
src/SDL_system.bf
Normal file
@@ -0,0 +1,827 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategorySystem
|
||||||
|
*
|
||||||
|
* Platform-specific SDL API functions. These are functions that deal with
|
||||||
|
* needs of specific operating systems, that didn't make sense to offer as
|
||||||
|
* platform-independent, generic APIs.
|
||||||
|
*
|
||||||
|
* Most apps can make do without these functions, but they can be useful for
|
||||||
|
* integrating with other parts of a specific system, adding platform-specific
|
||||||
|
* polish to an app, or solving problems that only affect one target.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Platform specific functions for Windows
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A callback to be used with SDL_SetWindowsMessageHook.
|
||||||
|
*
|
||||||
|
* This callback may modify the message, and should return true if the message
|
||||||
|
* should continue to be processed, or false to prevent further processing.
|
||||||
|
*
|
||||||
|
* As this is processing a message directly from the Windows event loop, this
|
||||||
|
* callback should do the minimum required work and return quickly.
|
||||||
|
*
|
||||||
|
* \param userdata the app-defined pointer provided to
|
||||||
|
* SDL_SetWindowsMessageHook.
|
||||||
|
* \param msg a pointer to a Win32 event structure to process.
|
||||||
|
* \returns true to let event continue on, false to drop it.
|
||||||
|
*
|
||||||
|
* \threadsafety This may only be called (by SDL) from the thread handling the
|
||||||
|
* Windows event loop.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetWindowsMessageHook
|
||||||
|
* \sa SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a callback for every Windows message, run before TranslateMessage().
|
||||||
|
*
|
||||||
|
* The callback may modify the message, and should return true if the message
|
||||||
|
* should continue to be processed, or false to prevent further processing.
|
||||||
|
*
|
||||||
|
* \param callback the SDL_WindowsMessageHook function to call.
|
||||||
|
* \param userdata a pointer to pass to every iteration of `callback`.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_WindowsMessageHook
|
||||||
|
* \sa SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* defined(SDL_PLATFORM_WINDOWS) */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the D3D9 adapter index that matches the specified display.
|
||||||
|
*
|
||||||
|
* The returned adapter index can be passed to `IDirect3D9::CreateDevice` and
|
||||||
|
* controls on which monitor a full screen application will appear.
|
||||||
|
*
|
||||||
|
* \param displayID the instance of the display to query.
|
||||||
|
* \returns the D3D9 adapter index on success or -1 on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the DXGI Adapter and Output indices for the specified display.
|
||||||
|
*
|
||||||
|
* The DXGI Adapter and Output indices can be passed to `EnumAdapters` and
|
||||||
|
* `EnumOutputs` respectively to get the objects required to create a DX10 or
|
||||||
|
* DX11 device and swap chain.
|
||||||
|
*
|
||||||
|
* \param displayID the instance of the display to query.
|
||||||
|
* \param adapterIndex a pointer to be filled in with the adapter index.
|
||||||
|
* \param outputIndex a pointer to be filled in with the output index.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Platform specific functions for UNIX
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* this is defined in Xlib's headers, just need a simple declaration here. */
|
||||||
|
[CRepr, Union] public struct _XEvent; public typealias XEvent = _XEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A callback to be used with SDL_SetX11EventHook.
|
||||||
|
*
|
||||||
|
* This callback may modify the event, and should return true if the event
|
||||||
|
* should continue to be processed, or false to prevent further processing.
|
||||||
|
*
|
||||||
|
* As this is processing an event directly from the X11 event loop, this
|
||||||
|
* callback should do the minimum required work and return quickly.
|
||||||
|
*
|
||||||
|
* \param userdata the app-defined pointer provided to SDL_SetX11EventHook.
|
||||||
|
* \param xevent a pointer to an Xlib XEvent union to process.
|
||||||
|
* \returns true to let event continue on, false to drop it.
|
||||||
|
*
|
||||||
|
* \threadsafety This may only be called (by SDL) from the thread handling the
|
||||||
|
* X11 event loop.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetX11EventHook
|
||||||
|
*/
|
||||||
|
public function bool X11EventHook(void* userdata, XEvent* xevent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a callback for every X11 event.
|
||||||
|
*
|
||||||
|
* The callback may modify the event, and should return true if the event
|
||||||
|
* should continue to be processed, or false to prevent further processing.
|
||||||
|
*
|
||||||
|
* \param callback the SDL_X11EventHook function to call.
|
||||||
|
* \param userdata a pointer to pass to every iteration of `callback`.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetX11EventHook")] public static extern void SetX11EventHook(X11EventHook callback, void* userdata);
|
||||||
|
|
||||||
|
/* Platform specific functions for Linux*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the UNIX nice value for a thread.
|
||||||
|
*
|
||||||
|
* This uses setpriority() if possible, and RealtimeKit if available.
|
||||||
|
*
|
||||||
|
* \param threadID the Unix thread ID to change priority of.
|
||||||
|
* \param priority the new, Unix-specific, priority value.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the priority (not nice level) and scheduling policy for a thread.
|
||||||
|
*
|
||||||
|
* This uses setpriority() if possible, and RealtimeKit if available.
|
||||||
|
*
|
||||||
|
* \param threadID the Unix thread ID to change priority of.
|
||||||
|
* \param sdlPriority the new SDL_ThreadPriority value.
|
||||||
|
* \param schedPolicy the new scheduling policy (SCHED_FIFO, SCHED_RR,
|
||||||
|
* SCHED_OTHER, etc...).
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_PLATFORM_LINUX */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Platform specific functions for iOS
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The prototype for an Apple iOS animation callback.
|
||||||
|
*
|
||||||
|
* This datatype is only useful on Apple iOS.
|
||||||
|
*
|
||||||
|
* After passing a function pointer of this type to
|
||||||
|
* SDL_SetiOSAnimationCallback, the system will call that function pointer at
|
||||||
|
* a regular interval.
|
||||||
|
*
|
||||||
|
* \param userdata what was passed as `callbackParam` to
|
||||||
|
* SDL_SetiOSAnimationCallback as `callbackParam`.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetiOSAnimationCallback
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this function to set the animation callback on Apple iOS.
|
||||||
|
*
|
||||||
|
* The function prototype for `callback` is:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* void callback(void *callbackParam);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Where its parameter, `callbackParam`, is what was passed as `callbackParam`
|
||||||
|
* to SDL_SetiOSAnimationCallback().
|
||||||
|
*
|
||||||
|
* This function is only available on Apple iOS.
|
||||||
|
*
|
||||||
|
* For more information see:
|
||||||
|
*
|
||||||
|
* https://wiki.libsdl.org/SDL3/README-ios
|
||||||
|
*
|
||||||
|
* Note that if you use the "main callbacks" instead of a standard C `main`
|
||||||
|
* function, you don't have to use this API, as SDL will manage this for you.
|
||||||
|
*
|
||||||
|
* Details on main callbacks are here:
|
||||||
|
*
|
||||||
|
* https://wiki.libsdl.org/SDL3/README-main-functions
|
||||||
|
*
|
||||||
|
* \param window the window for which the animation callback should be set.
|
||||||
|
* \param interval the number of frames after which **callback** will be
|
||||||
|
* called.
|
||||||
|
* \param callback the function to call for every frame.
|
||||||
|
* \param callbackParam a pointer that is passed to `callback`.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetiOSEventPump
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this function to enable or disable the SDL event pump on Apple iOS.
|
||||||
|
*
|
||||||
|
* This function is only available on Apple iOS.
|
||||||
|
*
|
||||||
|
* \param enabled true to enable the event pump, false to disable it.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetiOSAnimationCallback
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_PLATFORM_IOS */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Platform specific functions for Android
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Android Java Native Interface Environment of the current thread.
|
||||||
|
*
|
||||||
|
* This is the JNIEnv one needs to access the Java virtual machine from native
|
||||||
|
* code, and is needed for many Android APIs to be usable from C.
|
||||||
|
*
|
||||||
|
* The prototype of the function in SDL's code actually declare a void* return
|
||||||
|
* type, even if the implementation returns a pointer to a JNIEnv. The
|
||||||
|
* rationale being that the SDL headers can avoid including jni.h.
|
||||||
|
*
|
||||||
|
* \returns a pointer to Java native interface object (JNIEnv) to which the
|
||||||
|
* current thread is attached, or NULL on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetAndroidActivity
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the Java instance of the Android activity class.
|
||||||
|
*
|
||||||
|
* The prototype of the function in SDL's code actually declares a void*
|
||||||
|
* return type, even if the implementation returns a jobject. The rationale
|
||||||
|
* being that the SDL headers can avoid including jni.h.
|
||||||
|
*
|
||||||
|
* The jobject returned by the function is a local reference and must be
|
||||||
|
* released by the caller. See the PushLocalFrame() and PopLocalFrame() or
|
||||||
|
* DeleteLocalRef() functions of the Java native interface:
|
||||||
|
*
|
||||||
|
* https://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html
|
||||||
|
*
|
||||||
|
* \returns the jobject representing the instance of the Activity class of the
|
||||||
|
* Android application, or NULL on failure; call SDL_GetError() for
|
||||||
|
* more information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetAndroidJNIEnv
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query Android API level of the current device.
|
||||||
|
*
|
||||||
|
* - API level 35: Android 15 (VANILLA_ICE_CREAM)
|
||||||
|
* - API level 34: Android 14 (UPSIDE_DOWN_CAKE)
|
||||||
|
* - API level 33: Android 13 (TIRAMISU)
|
||||||
|
* - API level 32: Android 12L (S_V2)
|
||||||
|
* - API level 31: Android 12 (S)
|
||||||
|
* - API level 30: Android 11 (R)
|
||||||
|
* - API level 29: Android 10 (Q)
|
||||||
|
* - API level 28: Android 9 (P)
|
||||||
|
* - API level 27: Android 8.1 (O_MR1)
|
||||||
|
* - API level 26: Android 8.0 (O)
|
||||||
|
* - API level 25: Android 7.1 (N_MR1)
|
||||||
|
* - API level 24: Android 7.0 (N)
|
||||||
|
* - API level 23: Android 6.0 (M)
|
||||||
|
* - API level 22: Android 5.1 (LOLLIPOP_MR1)
|
||||||
|
* - API level 21: Android 5.0 (LOLLIPOP, L)
|
||||||
|
* - API level 20: Android 4.4W (KITKAT_WATCH)
|
||||||
|
* - API level 19: Android 4.4 (KITKAT)
|
||||||
|
* - API level 18: Android 4.3 (JELLY_BEAN_MR2)
|
||||||
|
* - API level 17: Android 4.2 (JELLY_BEAN_MR1)
|
||||||
|
* - API level 16: Android 4.1 (JELLY_BEAN)
|
||||||
|
* - API level 15: Android 4.0.3 (ICE_CREAM_SANDWICH_MR1)
|
||||||
|
* - API level 14: Android 4.0 (ICE_CREAM_SANDWICH)
|
||||||
|
* - API level 13: Android 3.2 (HONEYCOMB_MR2)
|
||||||
|
* - API level 12: Android 3.1 (HONEYCOMB_MR1)
|
||||||
|
* - API level 11: Android 3.0 (HONEYCOMB)
|
||||||
|
* - API level 10: Android 2.3.3 (GINGERBREAD_MR1)
|
||||||
|
*
|
||||||
|
* \returns the Android API level.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query if the application is running on a Chromebook.
|
||||||
|
*
|
||||||
|
* \returns true if this is a Chromebook, false otherwise.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query if the application is running on a Samsung DeX docking station.
|
||||||
|
*
|
||||||
|
* \returns true if this is a DeX docking station, false otherwise.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trigger the Android system back button behavior.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See the official Android developer guide for more information:
|
||||||
|
* http://developer.android.com/guide/topics/data/data-storage.html
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See the official Android developer guide for more information:
|
||||||
|
* http://developer.android.com/guide/topics/data/data-storage.html
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the path used for internal storage for this Android application.
|
||||||
|
*
|
||||||
|
* This path is unique to your application and cannot be written to by other
|
||||||
|
* applications.
|
||||||
|
*
|
||||||
|
* Your internal storage path is typically:
|
||||||
|
* `/data/data/your.app.package/files`.
|
||||||
|
*
|
||||||
|
* This is a C wrapper over `android.content.Context.getFilesDir()`:
|
||||||
|
*
|
||||||
|
* https://developer.android.com/reference/android/content/Context#getFilesDir()
|
||||||
|
*
|
||||||
|
* \returns the path used for internal storage or NULL on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetAndroidExternalStoragePath
|
||||||
|
* \sa SDL_GetAndroidCachePath
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current state of external storage for this Android application.
|
||||||
|
*
|
||||||
|
* The current state of external storage, a bitmask of these values:
|
||||||
|
* `SDL_ANDROID_EXTERNAL_STORAGE_READ`, `SDL_ANDROID_EXTERNAL_STORAGE_WRITE`.
|
||||||
|
*
|
||||||
|
* If external storage is currently unavailable, this will return 0.
|
||||||
|
*
|
||||||
|
* \returns the current state of external storage, or 0 if external storage is
|
||||||
|
* currently unavailable.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetAndroidExternalStoragePath
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the path used for external storage for this Android application.
|
||||||
|
*
|
||||||
|
* This path is unique to your application, but is public and can be written
|
||||||
|
* to by other applications.
|
||||||
|
*
|
||||||
|
* Your external storage path is typically:
|
||||||
|
* `/storage/sdcard0/Android/data/your.app.package/files`.
|
||||||
|
*
|
||||||
|
* This is a C wrapper over `android.content.Context.getExternalFilesDir()`:
|
||||||
|
*
|
||||||
|
* https://developer.android.com/reference/android/content/Context#getExternalFilesDir()
|
||||||
|
*
|
||||||
|
* \returns the path used for external storage for this application on success
|
||||||
|
* or NULL on failure; call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetAndroidExternalStorageState
|
||||||
|
* \sa SDL_GetAndroidInternalStoragePath
|
||||||
|
* \sa SDL_GetAndroidCachePath
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the path used for caching data for this Android application.
|
||||||
|
*
|
||||||
|
* This path is unique to your application, but is public and can be written
|
||||||
|
* to by other applications.
|
||||||
|
*
|
||||||
|
* Your cache path is typically: `/data/data/your.app.package/cache/`.
|
||||||
|
*
|
||||||
|
* This is a C wrapper over `android.content.Context.getCacheDir()`:
|
||||||
|
*
|
||||||
|
* https://developer.android.com/reference/android/content/Context#getCacheDir()
|
||||||
|
*
|
||||||
|
* \returns the path used for caches for this application on success or NULL
|
||||||
|
* on failure; call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetAndroidInternalStoragePath
|
||||||
|
* \sa SDL_GetAndroidExternalStoragePath
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback that presents a response from a SDL_RequestAndroidPermission call.
|
||||||
|
*
|
||||||
|
* \param userdata an app-controlled pointer that is passed to the callback.
|
||||||
|
* \param permission the Android-specific permission name that was requested.
|
||||||
|
* \param granted true if permission is granted, false if denied.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_RequestAndroidPermission
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request permissions at runtime, asynchronously.
|
||||||
|
*
|
||||||
|
* You do not need to call this for built-in functionality of SDL; recording
|
||||||
|
* from a microphone or reading images from a camera, using standard SDL APIs,
|
||||||
|
* will manage permission requests for you.
|
||||||
|
*
|
||||||
|
* This function never blocks. Instead, the app-supplied callback will be
|
||||||
|
* called when a decision has been made. This callback may happen on a
|
||||||
|
* different thread, and possibly much later, as it might wait on a user to
|
||||||
|
* respond to a system dialog. If permission has already been granted for a
|
||||||
|
* specific entitlement, the callback will still fire, probably on the current
|
||||||
|
* thread and before this function returns.
|
||||||
|
*
|
||||||
|
* If the request submission fails, this function returns -1 and the callback
|
||||||
|
* will NOT be called, but this should only happen in catastrophic conditions,
|
||||||
|
* like memory running out. Normally there will be a yes or no to the request
|
||||||
|
* through the callback.
|
||||||
|
*
|
||||||
|
* For the `permission` parameter, choose a value from here:
|
||||||
|
*
|
||||||
|
* https://developer.android.com/reference/android/Manifest.permission
|
||||||
|
*
|
||||||
|
* \param permission the permission to request.
|
||||||
|
* \param cb the callback to trigger when the request has a response.
|
||||||
|
* \param userdata an app-controlled pointer that is passed to the callback.
|
||||||
|
* \returns true if the request was submitted, false if there was an error
|
||||||
|
* submitting. The result of the request is only ever reported
|
||||||
|
* through the callback, not this return value.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows an Android toast notification.
|
||||||
|
*
|
||||||
|
* Toasts are a sort of lightweight notification that are unique to Android.
|
||||||
|
*
|
||||||
|
* https://developer.android.com/guide/topics/ui/notifiers/toasts
|
||||||
|
*
|
||||||
|
* Shows toast in UI thread.
|
||||||
|
*
|
||||||
|
* For the `gravity` parameter, choose a value from here, or -1 if you don't
|
||||||
|
* have a preference:
|
||||||
|
*
|
||||||
|
* https://developer.android.com/reference/android/view/Gravity
|
||||||
|
*
|
||||||
|
* \param message text message to be shown.
|
||||||
|
* \param duration 0=short, 1=long.
|
||||||
|
* \param gravity where the notification should appear on the screen.
|
||||||
|
* \param xoffset set this parameter only when gravity >=0.
|
||||||
|
* \param yoffset set this parameter only when gravity >=0.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a user command to SDLActivity.
|
||||||
|
*
|
||||||
|
* Override "boolean onUnhandledMessage(Message msg)" to handle the message.
|
||||||
|
*
|
||||||
|
* \param command user command that must be greater or equal to 0x8000.
|
||||||
|
* \param param user parameter.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_PLATFORM_ANDROID */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query if the current device is a tablet.
|
||||||
|
*
|
||||||
|
* If SDL can't determine this, it will return false.
|
||||||
|
*
|
||||||
|
* \returns true if the device is a tablet, false otherwise.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_IsTablet")] public static extern bool IsTablet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query if the current device is a TV.
|
||||||
|
*
|
||||||
|
* If SDL can't determine this, it will return false.
|
||||||
|
*
|
||||||
|
* \returns true if the device is a TV, false otherwise.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_IsTV")] public static extern bool IsTV();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Application sandbox environment.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum Sandbox : c_int
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
UnknownContainer,
|
||||||
|
Flatpak,
|
||||||
|
Snap,
|
||||||
|
Macos,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the application sandbox environment, if any.
|
||||||
|
*
|
||||||
|
* \returns the application sandbox environment or SDL_SANDBOX_NONE if the
|
||||||
|
* application is not running in a sandbox environment.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetSandbox")] public static extern Sandbox GetSandbox();
|
||||||
|
|
||||||
|
|
||||||
|
/* Functions used by iOS app delegates to notify SDL about state changes. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Let iOS apps with external event handling report
|
||||||
|
* onApplicationWillTerminate.
|
||||||
|
*
|
||||||
|
* This functions allows iOS apps that have their own event handling to hook
|
||||||
|
* into SDL to generate SDL events. This maps directly to an iOS-specific
|
||||||
|
* event, but since it doesn't do anything iOS-specific internally, it is
|
||||||
|
* available on all platforms, in case it might be useful for some specific
|
||||||
|
* paradigm. Most apps do not need to use this directly; SDL's internal event
|
||||||
|
* code will handle all this for windows created by SDL_CreateWindow!
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OnApplicationWillTerminate")] public static extern void OnApplicationWillTerminate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Let iOS apps with external event handling report
|
||||||
|
* onApplicationDidReceiveMemoryWarning.
|
||||||
|
*
|
||||||
|
* This functions allows iOS apps that have their own event handling to hook
|
||||||
|
* into SDL to generate SDL events. This maps directly to an iOS-specific
|
||||||
|
* event, but since it doesn't do anything iOS-specific internally, it is
|
||||||
|
* available on all platforms, in case it might be useful for some specific
|
||||||
|
* paradigm. Most apps do not need to use this directly; SDL's internal event
|
||||||
|
* code will handle all this for windows created by SDL_CreateWindow!
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OnApplicationDidReceiveMemoryWarning")] public static extern void OnApplicationDidReceiveMemoryWarning();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Let iOS apps with external event handling report
|
||||||
|
* onApplicationWillResignActive.
|
||||||
|
*
|
||||||
|
* This functions allows iOS apps that have their own event handling to hook
|
||||||
|
* into SDL to generate SDL events. This maps directly to an iOS-specific
|
||||||
|
* event, but since it doesn't do anything iOS-specific internally, it is
|
||||||
|
* available on all platforms, in case it might be useful for some specific
|
||||||
|
* paradigm. Most apps do not need to use this directly; SDL's internal event
|
||||||
|
* code will handle all this for windows created by SDL_CreateWindow!
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OnApplicationWillEnterBackground")] public static extern void OnApplicationWillEnterBackground();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Let iOS apps with external event handling report
|
||||||
|
* onApplicationDidEnterBackground.
|
||||||
|
*
|
||||||
|
* This functions allows iOS apps that have their own event handling to hook
|
||||||
|
* into SDL to generate SDL events. This maps directly to an iOS-specific
|
||||||
|
* event, but since it doesn't do anything iOS-specific internally, it is
|
||||||
|
* available on all platforms, in case it might be useful for some specific
|
||||||
|
* paradigm. Most apps do not need to use this directly; SDL's internal event
|
||||||
|
* code will handle all this for windows created by SDL_CreateWindow!
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OnApplicationDidEnterBackground")] public static extern void OnApplicationDidEnterBackground();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Let iOS apps with external event handling report
|
||||||
|
* onApplicationWillEnterForeground.
|
||||||
|
*
|
||||||
|
* This functions allows iOS apps that have their own event handling to hook
|
||||||
|
* into SDL to generate SDL events. This maps directly to an iOS-specific
|
||||||
|
* event, but since it doesn't do anything iOS-specific internally, it is
|
||||||
|
* available on all platforms, in case it might be useful for some specific
|
||||||
|
* paradigm. Most apps do not need to use this directly; SDL's internal event
|
||||||
|
* code will handle all this for windows created by SDL_CreateWindow!
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OnApplicationWillEnterForeground")] public static extern void OnApplicationWillEnterForeground();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Let iOS apps with external event handling report
|
||||||
|
* onApplicationDidBecomeActive.
|
||||||
|
*
|
||||||
|
* This functions allows iOS apps that have their own event handling to hook
|
||||||
|
* into SDL to generate SDL events. This maps directly to an iOS-specific
|
||||||
|
* event, but since it doesn't do anything iOS-specific internally, it is
|
||||||
|
* available on all platforms, in case it might be useful for some specific
|
||||||
|
* paradigm. Most apps do not need to use this directly; SDL's internal event
|
||||||
|
* code will handle all this for windows created by SDL_CreateWindow!
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_OnApplicationDidEnterForeground")] public static extern void OnApplicationDidEnterForeground();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Let iOS apps with external event handling report
|
||||||
|
* onApplicationDidChangeStatusBarOrientation.
|
||||||
|
*
|
||||||
|
* This functions allows iOS apps that have their own event handling to hook
|
||||||
|
* into SDL to generate SDL events. This maps directly to an iOS-specific
|
||||||
|
* event, but since it doesn't do anything iOS-specific internally, it is
|
||||||
|
* available on all platforms, in case it might be useful for some specific
|
||||||
|
* paradigm. Most apps do not need to use this directly; SDL's internal event
|
||||||
|
* code will handle all this for windows created by SDL_CreateWindow!
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Functions used only by GDK
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a reference to the global async task queue handle for GDK,
|
||||||
|
* initializing if needed.
|
||||||
|
*
|
||||||
|
* Once you are done with the task queue, you should call
|
||||||
|
* XTaskQueueCloseHandle to reduce the reference count to avoid a resource
|
||||||
|
* leak.
|
||||||
|
*
|
||||||
|
* \param outTaskQueue a pointer to be filled in with task queue handle.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a reference to the default user handle for GDK.
|
||||||
|
*
|
||||||
|
* This is effectively a synchronous version of XUserAddAsync, which always
|
||||||
|
* prefers the default user and allows a sign-in UI.
|
||||||
|
*
|
||||||
|
* \param outUserHandle a pointer to be filled in with the default user
|
||||||
|
* handle.
|
||||||
|
* \returns true if success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_system_h_ */
|
||||||
76
src/SDL_test.bf
Normal file
76
src/SDL_test.bf
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDLTest
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include file for SDL test framework.
|
||||||
|
*
|
||||||
|
* This code is a part of the SDL test library, not the main SDL library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Global definitions */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Note: Maximum size of SDLTest log message is less than SDL's limit
|
||||||
|
* to ensure we can fit additional information such as the timestamp.
|
||||||
|
*/
|
||||||
|
public const let SDLTEST_MAX_LOGMESSAGE_LENGTH = 3584;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_test_h_ */
|
||||||
104
src/SDL_test_assert.bf
Normal file
104
src/SDL_test_assert.bf
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDLTest
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assertion functions of SDL test framework.
|
||||||
|
*
|
||||||
|
* This code is a part of the SDL test library, not the main SDL library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Assert API for test code and test cases
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Fails the assert. */
|
||||||
|
public const let ASSERT_FAIL = 0;
|
||||||
|
|
||||||
|
/* Passes the assert. */
|
||||||
|
public const let ASSERT_PASS = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Assert that logs and break execution flow on failures.
|
||||||
|
*
|
||||||
|
* \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
|
||||||
|
* \param assertDescription Message to log with the assert describing it.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_Assert")] public static extern void Assert(c_int assertCondition, c_char* assertDescription, ...);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters.
|
||||||
|
*
|
||||||
|
* \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
|
||||||
|
* \param assertDescription Message to log with the assert describing it.
|
||||||
|
*
|
||||||
|
* \returns the assertCondition so it can be used to externally to break execution flow if desired.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_AssertCheck")] public static extern c_int AssertCheck(c_int assertCondition, c_char* assertDescription, ...);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Explicitly pass without checking an assertion condition. Updates assertion counter.
|
||||||
|
*
|
||||||
|
* \param assertDescription Message to log with the assert describing it.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_AssertPass")] public static extern void AssertPass(c_char* assertDescription, ...);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Resets the assert summary counters to zero.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_ResetAssertSummary")] public static extern void ResetAssertSummary();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_LogAssertSummary")] public static extern void LogAssertSummary();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Converts the current assert summary state to a test result.
|
||||||
|
*
|
||||||
|
* \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_AssertSummaryToTestResult")] public static extern c_int AssertSummaryToTestResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* SDL_test_assert_h_ */
|
||||||
304
src/SDL_test_common.bf
Normal file
304
src/SDL_test_common.bf
Normal file
@@ -0,0 +1,304 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDLTest
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common functions of SDL test framework.
|
||||||
|
*
|
||||||
|
* This code is a part of the SDL test library, not the main SDL library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Ported from original test/common.h file. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public const let DEFAULT_WINDOW_WIDTH = 640;
|
||||||
|
public const let DEFAULT_WINDOW_HEIGHT = 480;
|
||||||
|
|
||||||
|
|
||||||
|
public typealias VerboseFlags = Uint32;
|
||||||
|
public const let VERBOSE_VIDEO = 0x00000001;
|
||||||
|
public const let VERBOSE_MODES = 0x00000002;
|
||||||
|
public const let VERBOSE_RENDER = 0x00000004;
|
||||||
|
public const let VERBOSE_EVENT = 0x00000008;
|
||||||
|
public const let VERBOSE_AUDIO = 0x00000010;
|
||||||
|
public const let VERBOSE_MOTION = 0x00000020;
|
||||||
|
|
||||||
|
/* !< Function pointer parsing one argument at argv[index], returning the number of parsed arguments,
|
||||||
|
* or a negative value when the argument is invalid */
|
||||||
|
public function c_int ParseArgumentsFp(void* data, c_char** argv, c_int index);
|
||||||
|
|
||||||
|
/* !< Finalize the argument parser. */
|
||||||
|
public function void FinalizeArgumentParserFp(void* arg);
|
||||||
|
|
||||||
|
[CRepr] public struct ArgumentParser
|
||||||
|
{
|
||||||
|
/* !< Parse an argument. */
|
||||||
|
public ParseArgumentsFp parse_arguments;
|
||||||
|
/* !< Finalize this argument parser. Called once before parsing the first argument. */
|
||||||
|
public FinalizeArgumentParserFp finalize;
|
||||||
|
/* !< Null-terminated array of arguments. Printed when running with --help. */
|
||||||
|
public c_char** usage;
|
||||||
|
/* !< User data, passed to all callbacks. */
|
||||||
|
public void* data;
|
||||||
|
/* !< Next argument parser. */
|
||||||
|
public ArgumentParser* next;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CRepr] public struct CommonState
|
||||||
|
{
|
||||||
|
/* SDL init flags */
|
||||||
|
public c_char** argv;
|
||||||
|
public InitFlags flags;
|
||||||
|
public VerboseFlags verbose;
|
||||||
|
|
||||||
|
/* Video info */
|
||||||
|
public c_char* videodriver;
|
||||||
|
public c_int display_index;
|
||||||
|
public DisplayID displayID;
|
||||||
|
public c_char* window_title;
|
||||||
|
public c_char* window_icon;
|
||||||
|
public WindowFlags window_flags;
|
||||||
|
public bool flash_on_focus_loss;
|
||||||
|
public c_int window_x;
|
||||||
|
public c_int window_y;
|
||||||
|
public c_int window_w;
|
||||||
|
public c_int window_h;
|
||||||
|
public c_int window_minW;
|
||||||
|
public c_int window_minH;
|
||||||
|
public c_int window_maxW;
|
||||||
|
public c_int window_maxH;
|
||||||
|
public float window_min_aspect;
|
||||||
|
public float window_max_aspect;
|
||||||
|
public c_int logical_w;
|
||||||
|
public c_int logical_h;
|
||||||
|
public bool auto_scale_content;
|
||||||
|
public RendererLogicalPresentation logical_presentation;
|
||||||
|
public float scale;
|
||||||
|
public c_int depth;
|
||||||
|
public float refresh_rate;
|
||||||
|
public bool fill_usable_bounds;
|
||||||
|
public bool fullscreen_exclusive;
|
||||||
|
public DisplayMode fullscreen_mode;
|
||||||
|
public c_int num_windows;
|
||||||
|
public Window** windows;
|
||||||
|
public c_char* gpudriver;
|
||||||
|
|
||||||
|
/* Renderer info */
|
||||||
|
public c_char* renderdriver;
|
||||||
|
public c_int render_vsync;
|
||||||
|
public bool skip_renderer;
|
||||||
|
public Renderer** renderers;
|
||||||
|
public Texture** targets;
|
||||||
|
|
||||||
|
/* Audio info */
|
||||||
|
public c_char* audiodriver;
|
||||||
|
public AudioFormat audio_format;
|
||||||
|
public c_int audio_channels;
|
||||||
|
public c_int audio_freq;
|
||||||
|
public AudioDeviceID audio_id;
|
||||||
|
|
||||||
|
/* GL settings */
|
||||||
|
public c_int gl_red_size;
|
||||||
|
public c_int gl_green_size;
|
||||||
|
public c_int gl_blue_size;
|
||||||
|
public c_int gl_alpha_size;
|
||||||
|
public c_int gl_buffer_size;
|
||||||
|
public c_int gl_depth_size;
|
||||||
|
public c_int gl_stencil_size;
|
||||||
|
public c_int gl_double_buffer;
|
||||||
|
public c_int gl_accum_red_size;
|
||||||
|
public c_int gl_accum_green_size;
|
||||||
|
public c_int gl_accum_blue_size;
|
||||||
|
public c_int gl_accum_alpha_size;
|
||||||
|
public c_int gl_stereo;
|
||||||
|
public c_int gl_release_behavior;
|
||||||
|
public c_int gl_multisamplebuffers;
|
||||||
|
public c_int gl_multisamplesamples;
|
||||||
|
public c_int gl_retained_backing;
|
||||||
|
public c_int gl_accelerated;
|
||||||
|
public c_int gl_major_version;
|
||||||
|
public c_int gl_minor_version;
|
||||||
|
public c_int gl_debug;
|
||||||
|
public c_int gl_profile_mask;
|
||||||
|
|
||||||
|
/* Mouse info */
|
||||||
|
public Rect confine;
|
||||||
|
public bool hide_cursor;
|
||||||
|
|
||||||
|
/* Misc. */
|
||||||
|
public c_int quit_after_ms_interval;
|
||||||
|
public TimerID quit_after_ms_timer;
|
||||||
|
|
||||||
|
/* Options info */
|
||||||
|
public ArgumentParser common_argparser;
|
||||||
|
public ArgumentParser video_argparser;
|
||||||
|
public ArgumentParser audio_argparser;
|
||||||
|
|
||||||
|
public ArgumentParser* argparser;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Function prototypes */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse command line parameters and create common state.
|
||||||
|
*
|
||||||
|
* \param argv Array of command line parameters
|
||||||
|
* \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO)
|
||||||
|
*
|
||||||
|
* \returns a newly allocated common state object.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_CommonCreateState")] public static extern CommonState* CommonCreateState(c_char** argv, InitFlags flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free the common state object.
|
||||||
|
*
|
||||||
|
* You should call SDL_Quit() before calling this function.
|
||||||
|
*
|
||||||
|
* \param state The common state object to destroy
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_CommonDestroyState")] public static extern void CommonDestroyState(CommonState* state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process one common argument.
|
||||||
|
*
|
||||||
|
* \param state The common state describing the test window to create.
|
||||||
|
* \param index The index of the argument to process in argv[].
|
||||||
|
*
|
||||||
|
* \returns the number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_CommonArg")] public static extern c_int CommonArg(CommonState* state, c_int index);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs command line usage info.
|
||||||
|
*
|
||||||
|
* This logs the appropriate command line options for the subsystems in use
|
||||||
|
* plus other common options, and then any application-specific options.
|
||||||
|
* This uses the SDL_Log() function and splits up output to be friendly to
|
||||||
|
* 80-character-wide terminals.
|
||||||
|
*
|
||||||
|
* \param state The common state describing the test window for the app.
|
||||||
|
* \param argv0 argv[0], as passed to main/SDL_main.
|
||||||
|
* \param options an array of strings for application specific options. The last element of the array should be NULL.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_CommonLogUsage")] public static extern void CommonLogUsage(CommonState* state, c_char* argv0, c_char** options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open test window.
|
||||||
|
*
|
||||||
|
* \param state The common state describing the test window to create.
|
||||||
|
*
|
||||||
|
* \returns true if initialization succeeded, false otherwise
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_CommonInit")] public static extern bool CommonInit(CommonState* state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Easy argument handling when test app doesn't need any custom args.
|
||||||
|
*
|
||||||
|
* \param state The common state describing the test window to create.
|
||||||
|
* \param argc argc, as supplied to SDL_main
|
||||||
|
* \param argv argv, as supplied to SDL_main
|
||||||
|
*
|
||||||
|
* \returns false if app should quit, true otherwise.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_CommonDefaultArgs")] public static extern bool CommonDefaultArgs(CommonState* state, c_int argc, c_char** argv);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print the details of an event.
|
||||||
|
*
|
||||||
|
* This is automatically called by SDLTest_CommonEvent() as needed.
|
||||||
|
*
|
||||||
|
* \param event The event to print.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_PrintEvent")] public static extern void PrintEvent(Event* event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common event handler for test windows if you use a standard SDL_main.
|
||||||
|
*
|
||||||
|
* \param state The common state used to create test window.
|
||||||
|
* \param event The event to handle.
|
||||||
|
* \param done Flag indicating we are done.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_CommonEvent")] public static extern void CommonEvent(CommonState* state, Event* event, c_int* done);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common event handler for test windows if you use SDL_AppEvent.
|
||||||
|
*
|
||||||
|
* This does _not_ free anything in `event`.
|
||||||
|
*
|
||||||
|
* \param state The common state used to create test window.
|
||||||
|
* \param event The event to handle.
|
||||||
|
* \returns Value suitable for returning from SDL_AppEvent().
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_CommonEventMainCallbacks")] public static extern AppResult CommonEventMainCallbacks(CommonState* state, Event* event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close test window.
|
||||||
|
*
|
||||||
|
* \param state The common state used to create test window.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_CommonQuit")] public static extern void CommonQuit(CommonState* state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws various window information (position, size, etc.) to the renderer.
|
||||||
|
*
|
||||||
|
* \param renderer The renderer to draw to.
|
||||||
|
* \param window The window whose information should be displayed.
|
||||||
|
* \param usedHeight Returns the height used, so the caller can draw more below.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_CommonDrawWindowInfo")] public static extern void CommonDrawWindowInfo(Renderer* renderer, Window* window, float* usedHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_test_common_h_ */
|
||||||
88
src/SDL_test_compare.bf
Normal file
88
src/SDL_test_compare.bf
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDLTest
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comparison function of SDL test framework.
|
||||||
|
*
|
||||||
|
* This code is a part of the SDL test library, not the main SDL library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Defines comparison functions (i.e. for surfaces).
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares a surface and with reference image data for equality
|
||||||
|
*
|
||||||
|
* \param surface Surface used in comparison
|
||||||
|
* \param referenceSurface Test Surface used in comparison
|
||||||
|
* \param allowable_error Allowable difference (=sum of squared difference for each RGB component) in blending accuracy.
|
||||||
|
*
|
||||||
|
* \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_CompareSurfaces")] public static extern c_int CompareSurfaces(Surface* surface, Surface* referenceSurface, c_int allowable_error);
|
||||||
|
[LinkName("SDLTest_CompareSurfacesIgnoreTransparentPixels")] public static extern c_int CompareSurfacesIgnoreTransparentPixels(Surface* surface, Surface* referenceSurface, c_int allowable_error);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares 2 memory blocks for equality
|
||||||
|
*
|
||||||
|
* \param actual Memory used in comparison, displayed on the left
|
||||||
|
* \param size_actual Size of actual in bytes
|
||||||
|
* \param reference Reference memory, displayed on the right
|
||||||
|
* \param size_reference Size of reference in bytes
|
||||||
|
*
|
||||||
|
* \returns 0 if the left and right memory block are equal, non-zero if they are non-equal.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_CompareMemory")] public static extern c_int CompareMemory(void* actual, c_size size_actual, void* reference, c_size size_reference);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_test_compare_h_ */
|
||||||
132
src/SDL_test_crc32.bf
Normal file
132
src/SDL_test_crc32.bf
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDLTest
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CRC32 functions of SDL test framework.
|
||||||
|
*
|
||||||
|
* This code is a part of the SDL test library, not the main SDL library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Implements CRC32 calculations (default output is Perl String::CRC32 compatible).
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------ Definitions --------- */
|
||||||
|
|
||||||
|
/* Definition shared by all CRC routines */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* AUTODIN II, Ethernet, & FDDI */
|
||||||
|
|
||||||
|
public const let CRC32_POLY = 0xEDB88320; /* Perl String::CRC32 compatible */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data structure for CRC32 (checksum) computation
|
||||||
|
*/
|
||||||
|
[CRepr] public struct Crc32Context {
|
||||||
|
public Uint32[256] crc32_table; /* CRC table */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- Function Prototypes ------------- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize the CRC context
|
||||||
|
*
|
||||||
|
* Note: The function initializes the crc table required for all crc calculations.
|
||||||
|
*
|
||||||
|
* \param crcContext pointer to context variable
|
||||||
|
*
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError()
|
||||||
|
* for more information.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_Crc32Init")] public static extern bool Crc32Init(Crc32Context* crcContext);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* calculate a crc32 from a data block
|
||||||
|
*
|
||||||
|
* \param crcContext pointer to context variable
|
||||||
|
* \param inBuf input buffer to checksum
|
||||||
|
* \param inLen length of input buffer
|
||||||
|
* \param crc32 pointer to Uint32 to store the final CRC into
|
||||||
|
*
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError()
|
||||||
|
* for more information.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_Crc32Calc")] public static extern bool Crc32Calc(Crc32Context* crcContext, Uint8* inBuf, Uint32 inLen, Uint32* crc32);
|
||||||
|
|
||||||
|
/* Same routine broken down into three steps */
|
||||||
|
[LinkName("SDLTest_Crc32CalcStart")] public static extern bool Crc32CalcStart(Crc32Context* crcContext, Uint32* crc32);
|
||||||
|
[LinkName("SDLTest_Crc32CalcEnd")] public static extern bool Crc32CalcEnd(Crc32Context* crcContext, Uint32* crc32);
|
||||||
|
[LinkName("SDLTest_Crc32CalcBuffer")] public static extern bool Crc32CalcBuffer(Crc32Context* crcContext, Uint8* inBuf, Uint32 inLen, Uint32* crc32);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* clean up CRC context
|
||||||
|
*
|
||||||
|
* \param crcContext pointer to context variable
|
||||||
|
*
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError()
|
||||||
|
* for more information.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
[LinkName("SDLTest_Crc32Done")] public static extern bool Crc32Done(Crc32Context* crcContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_test_crc32_h_ */
|
||||||
180
src/SDL_test_font.bf
Normal file
180
src/SDL_test_font.bf
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDLTest
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Font related functions of SDL test framework.
|
||||||
|
*
|
||||||
|
* This code is a part of the SDL test library, not the main SDL library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Function prototypes */
|
||||||
|
|
||||||
|
[CLink] public static extern c_int FONT_CHARACTER_SIZE;
|
||||||
|
|
||||||
|
public static c_int FONT_LINE_HEIGHT => (FONT_CHARACTER_SIZE + 2);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Draw a string in the currently set font.
|
||||||
|
*
|
||||||
|
* \param renderer The renderer to draw on.
|
||||||
|
* \param x The X coordinate of the upper left corner of the character.
|
||||||
|
* \param y The Y coordinate of the upper left corner of the character.
|
||||||
|
* \param c The character to draw.
|
||||||
|
*
|
||||||
|
* \returns true on success, false on failure.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_DrawCharacter")] public static extern bool DrawCharacter(Renderer* renderer, float x, float y, Uint32 c);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Draw a UTF-8 string in the currently set font.
|
||||||
|
*
|
||||||
|
* The font currently only supports characters in the Basic Latin and Latin-1 Supplement sets.
|
||||||
|
*
|
||||||
|
* \param renderer The renderer to draw on.
|
||||||
|
* \param x The X coordinate of the upper left corner of the string.
|
||||||
|
* \param y The Y coordinate of the upper left corner of the string.
|
||||||
|
* \param s The string to draw.
|
||||||
|
*
|
||||||
|
* \returns true on success, false on failure.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_DrawString")] public static extern bool DrawString(Renderer* renderer, float x, float y, c_char* s);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data used for multi-line text output
|
||||||
|
*/
|
||||||
|
[CRepr] public struct TextWindow
|
||||||
|
{
|
||||||
|
public FRect rect;
|
||||||
|
public c_int current;
|
||||||
|
public c_int numlines;
|
||||||
|
public c_char** lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a multi-line text output window
|
||||||
|
*
|
||||||
|
* \param x The X coordinate of the upper left corner of the window.
|
||||||
|
* \param y The Y coordinate of the upper left corner of the window.
|
||||||
|
* \param w The width of the window (currently ignored)
|
||||||
|
* \param h The height of the window (currently ignored)
|
||||||
|
*
|
||||||
|
* \returns the new window, or NULL on failure.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_TextWindowCreate")] public static extern TextWindow* TextWindowCreate(float x, float y, float w, float h);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display a multi-line text output window
|
||||||
|
*
|
||||||
|
* This function should be called every frame to display the text
|
||||||
|
*
|
||||||
|
* \param textwin The text output window
|
||||||
|
* \param renderer The renderer to use for display
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_TextWindowDisplay")] public static extern void TextWindowDisplay(TextWindow* textwin, Renderer* renderer);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add text to a multi-line text output window
|
||||||
|
*
|
||||||
|
* Adds UTF-8 text to the end of the current text. The newline character starts a
|
||||||
|
* new line of text. The backspace character deletes the last character or, if the
|
||||||
|
* line is empty, deletes the line and goes to the end of the previous line.
|
||||||
|
*
|
||||||
|
* \param textwin The text output window
|
||||||
|
* \param fmt A printf() style format string
|
||||||
|
* \param ... additional parameters matching % tokens in the `fmt` string, if any
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_TextWindowAddText")] public static extern void TextWindowAddText(TextWindow* textwin, c_char* fmt, ...);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add text to a multi-line text output window
|
||||||
|
*
|
||||||
|
* Adds UTF-8 text to the end of the current text. The newline character starts a
|
||||||
|
* new line of text. The backspace character deletes the last character or, if the
|
||||||
|
* line is empty, deletes the line and goes to the end of the previous line.
|
||||||
|
*
|
||||||
|
* \param textwin The text output window
|
||||||
|
* \param text The text to add to the window
|
||||||
|
* \param len The length, in bytes, of the text to add to the window
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_TextWindowAddTextWithLength")] public static extern void TextWindowAddTextWithLength(TextWindow* textwin, c_char* text, c_size len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Clear the text in a multi-line text output window
|
||||||
|
*
|
||||||
|
* \param textwin The text output window
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_TextWindowClear")] public static extern void TextWindowClear(TextWindow* textwin);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free the storage associated with a multi-line text output window
|
||||||
|
*
|
||||||
|
* \param textwin The text output window
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_TextWindowDestroy")] public static extern void TextWindowDestroy(TextWindow* textwin);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Cleanup textures used by font drawing functions.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_CleanupTextDrawing")] public static extern void CleanupTextDrawing();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_test_font_h_ */
|
||||||
382
src/SDL_test_fuzzer.bf
Normal file
382
src/SDL_test_fuzzer.bf
Normal file
@@ -0,0 +1,382 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDLTest
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fuzzer functions of SDL test framework.
|
||||||
|
*
|
||||||
|
* This code is a part of the SDL test library, not the main SDL library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Data generators for fuzzing test data in a reproducible way.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Based on GSOC code by Markus Kauppila <markus.kauppila@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note: The fuzzer implementation uses a static instance of random context
|
||||||
|
* internally which makes it thread-UNsafe.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the fuzzer for a test
|
||||||
|
*
|
||||||
|
* \param execKey Execution "Key" that initializes the random number generator uniquely for the test.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_FuzzerInit")] public static extern void FuzzerInit(Uint64 execKey);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a random Uint8
|
||||||
|
*
|
||||||
|
* \returns a generated integer
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomUint8")] public static extern Uint8 RandomUint8();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a random Sint8
|
||||||
|
*
|
||||||
|
* \returns a generated signed integer
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomSint8")] public static extern Sint8 RandomSint8();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a random Uint16
|
||||||
|
*
|
||||||
|
* \returns a generated integer
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomUint16")] public static extern Uint16 RandomUint16();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a random Sint16
|
||||||
|
*
|
||||||
|
* \returns a generated signed integer
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomSint16")] public static extern Sint16 RandomSint16();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a random integer
|
||||||
|
*
|
||||||
|
* \returns a generated integer
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomSint32")] public static extern Sint32 RandomSint32();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a random positive integer
|
||||||
|
*
|
||||||
|
* \returns a generated integer
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomUint32")] public static extern Uint32 RandomUint32();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns random Uint64.
|
||||||
|
*
|
||||||
|
* \returns a generated integer
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomUint64")] public static extern Uint64 RandomUint64();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns random Sint64.
|
||||||
|
*
|
||||||
|
* \returns a generated signed integer
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomSint64")] public static extern Sint64 RandomSint64();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \returns a random float in range [0.0 - 1.0]
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomUnitFloat")] public static extern float RandomUnitFloat();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \returns a random double in range [0.0 - 1.0]
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomUnitDouble")] public static extern double RandomUnitDouble();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \returns a random float.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomFloat")] public static extern float RandomFloat();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \returns a random double.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomDouble")] public static extern double RandomDouble();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a random boundary value for Uint8 within the given boundaries.
|
||||||
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
|
* boundaries are also possible.
|
||||||
|
* If boundary1 > boundary2, the values are swapped
|
||||||
|
*
|
||||||
|
* Usage examples:
|
||||||
|
* RandomUint8BoundaryValue(10, 20, true) returns 10, 11, 19 or 20
|
||||||
|
* RandomUint8BoundaryValue(1, 20, false) returns 0 or 21
|
||||||
|
* RandomUint8BoundaryValue(0, 99, false) returns 100
|
||||||
|
* RandomUint8BoundaryValue(0, 255, false) returns 0 (error set)
|
||||||
|
*
|
||||||
|
* \param boundary1 Lower boundary limit
|
||||||
|
* \param boundary2 Upper boundary limit
|
||||||
|
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||||
|
*
|
||||||
|
* \returns a random boundary value for the given range and domain or 0 with error set
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomUint8BoundaryValue")] public static extern Uint8 RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, bool validDomain);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a random boundary value for Uint16 within the given boundaries.
|
||||||
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
|
* boundaries are also possible.
|
||||||
|
* If boundary1 > boundary2, the values are swapped
|
||||||
|
*
|
||||||
|
* Usage examples:
|
||||||
|
* RandomUint16BoundaryValue(10, 20, true) returns 10, 11, 19 or 20
|
||||||
|
* RandomUint16BoundaryValue(1, 20, false) returns 0 or 21
|
||||||
|
* RandomUint16BoundaryValue(0, 99, false) returns 100
|
||||||
|
* RandomUint16BoundaryValue(0, 0xFFFF, false) returns 0 (error set)
|
||||||
|
*
|
||||||
|
* \param boundary1 Lower boundary limit
|
||||||
|
* \param boundary2 Upper boundary limit
|
||||||
|
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||||
|
*
|
||||||
|
* \returns a random boundary value for the given range and domain or 0 with error set
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomUint16BoundaryValue")] public static extern Uint16 RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, bool validDomain);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a random boundary value for Uint32 within the given boundaries.
|
||||||
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
|
* boundaries are also possible.
|
||||||
|
* If boundary1 > boundary2, the values are swapped
|
||||||
|
*
|
||||||
|
* Usage examples:
|
||||||
|
* RandomUint32BoundaryValue(10, 20, true) returns 10, 11, 19 or 20
|
||||||
|
* RandomUint32BoundaryValue(1, 20, false) returns 0 or 21
|
||||||
|
* RandomUint32BoundaryValue(0, 99, false) returns 100
|
||||||
|
* RandomUint32BoundaryValue(0, 0xFFFFFFFF, false) returns 0 (with error set)
|
||||||
|
*
|
||||||
|
* \param boundary1 Lower boundary limit
|
||||||
|
* \param boundary2 Upper boundary limit
|
||||||
|
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||||
|
*
|
||||||
|
* \returns a random boundary value for the given range and domain or 0 with error set
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomUint32BoundaryValue")] public static extern Uint32 RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, bool validDomain);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a random boundary value for Uint64 within the given boundaries.
|
||||||
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
|
* boundaries are also possible.
|
||||||
|
* If boundary1 > boundary2, the values are swapped
|
||||||
|
*
|
||||||
|
* Usage examples:
|
||||||
|
* RandomUint64BoundaryValue(10, 20, true) returns 10, 11, 19 or 20
|
||||||
|
* RandomUint64BoundaryValue(1, 20, false) returns 0 or 21
|
||||||
|
* RandomUint64BoundaryValue(0, 99, false) returns 100
|
||||||
|
* RandomUint64BoundaryValue(0, 0xFFFFFFFFFFFFFFFF, false) returns 0 (with error set)
|
||||||
|
*
|
||||||
|
* \param boundary1 Lower boundary limit
|
||||||
|
* \param boundary2 Upper boundary limit
|
||||||
|
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||||
|
*
|
||||||
|
* \returns a random boundary value for the given range and domain or 0 with error set
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomUint64BoundaryValue")] public static extern Uint64 RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, bool validDomain);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a random boundary value for Sint8 within the given boundaries.
|
||||||
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
|
* boundaries are also possible.
|
||||||
|
* If boundary1 > boundary2, the values are swapped
|
||||||
|
*
|
||||||
|
* Usage examples:
|
||||||
|
* RandomSint8BoundaryValue(-10, 20, true) returns -11, -10, 19 or 20
|
||||||
|
* RandomSint8BoundaryValue(-100, -10, false) returns -101 or -9
|
||||||
|
* RandomSint8BoundaryValue(SINT8_MIN, 99, false) returns 100
|
||||||
|
* RandomSint8BoundaryValue(SINT8_MIN, SINT8_MAX, false) returns SINT8_MIN (== error value) with error set
|
||||||
|
*
|
||||||
|
* \param boundary1 Lower boundary limit
|
||||||
|
* \param boundary2 Upper boundary limit
|
||||||
|
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||||
|
*
|
||||||
|
* \returns a random boundary value for the given range and domain or SINT8_MIN with error set
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomSint8BoundaryValue")] public static extern Sint8 RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, bool validDomain);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a random boundary value for Sint16 within the given boundaries.
|
||||||
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
|
* boundaries are also possible.
|
||||||
|
* If boundary1 > boundary2, the values are swapped
|
||||||
|
*
|
||||||
|
* Usage examples:
|
||||||
|
* RandomSint16BoundaryValue(-10, 20, true) returns -11, -10, 19 or 20
|
||||||
|
* RandomSint16BoundaryValue(-100, -10, false) returns -101 or -9
|
||||||
|
* RandomSint16BoundaryValue(SINT16_MIN, 99, false) returns 100
|
||||||
|
* RandomSint16BoundaryValue(SINT16_MIN, SINT16_MAX, false) returns SINT16_MIN (== error value) with error set
|
||||||
|
*
|
||||||
|
* \param boundary1 Lower boundary limit
|
||||||
|
* \param boundary2 Upper boundary limit
|
||||||
|
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||||
|
*
|
||||||
|
* \returns a random boundary value for the given range and domain or SINT16_MIN with error set
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomSint16BoundaryValue")] public static extern Sint16 RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, bool validDomain);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a random boundary value for Sint32 within the given boundaries.
|
||||||
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
|
* boundaries are also possible.
|
||||||
|
* If boundary1 > boundary2, the values are swapped
|
||||||
|
*
|
||||||
|
* Usage examples:
|
||||||
|
* RandomSint32BoundaryValue(-10, 20, true) returns -11, -10, 19 or 20
|
||||||
|
* RandomSint32BoundaryValue(-100, -10, false) returns -101 or -9
|
||||||
|
* RandomSint32BoundaryValue(SINT32_MIN, 99, false) returns 100
|
||||||
|
* RandomSint32BoundaryValue(SINT32_MIN, SINT32_MAX, false) returns SINT32_MIN (== error value)
|
||||||
|
*
|
||||||
|
* \param boundary1 Lower boundary limit
|
||||||
|
* \param boundary2 Upper boundary limit
|
||||||
|
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||||
|
*
|
||||||
|
* \returns a random boundary value for the given range and domain or SINT32_MIN with error set
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomSint32BoundaryValue")] public static extern Sint32 RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, bool validDomain);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a random boundary value for Sint64 within the given boundaries.
|
||||||
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
|
* boundaries are also possible.
|
||||||
|
* If boundary1 > boundary2, the values are swapped
|
||||||
|
*
|
||||||
|
* Usage examples:
|
||||||
|
* RandomSint64BoundaryValue(-10, 20, true) returns -11, -10, 19 or 20
|
||||||
|
* RandomSint64BoundaryValue(-100, -10, false) returns -101 or -9
|
||||||
|
* RandomSint64BoundaryValue(SINT64_MIN, 99, false) returns 100
|
||||||
|
* RandomSint64BoundaryValue(SINT64_MIN, SINT64_MAX, false) returns SINT64_MIN (== error value) and error set
|
||||||
|
*
|
||||||
|
* \param boundary1 Lower boundary limit
|
||||||
|
* \param boundary2 Upper boundary limit
|
||||||
|
* \param validDomain Should the generated boundary be valid (=within the bounds) or not?
|
||||||
|
*
|
||||||
|
* \returns a random boundary value for the given range and domain or SINT64_MIN with error set
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomSint64BoundaryValue")] public static extern Sint64 RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, bool validDomain);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns integer in range [min, max] (inclusive).
|
||||||
|
* Min and max values can be negative values.
|
||||||
|
* If Max in smaller than min, then the values are swapped.
|
||||||
|
* Min and max are the same value, that value will be returned.
|
||||||
|
*
|
||||||
|
* \param min Minimum inclusive value of returned random number
|
||||||
|
* \param max Maximum inclusive value of returned random number
|
||||||
|
*
|
||||||
|
* \returns a generated random integer in range
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomIntegerInRange")] public static extern Sint32 RandomIntegerInRange(Sint32 min, Sint32 max);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates random null-terminated string. The minimum length for
|
||||||
|
* the string is 1 character, maximum length for the string is 255
|
||||||
|
* characters and it can contain ASCII characters from 32 to 126.
|
||||||
|
*
|
||||||
|
* Note: Returned string needs to be deallocated.
|
||||||
|
*
|
||||||
|
* \returns a newly allocated random string; or NULL if length was invalid or string could not be allocated.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomAsciiString")] public static extern c_char* RandomAsciiString();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates random null-terminated string. The maximum length for
|
||||||
|
* the string is defined by the maxLength parameter.
|
||||||
|
* String can contain ASCII characters from 32 to 126.
|
||||||
|
*
|
||||||
|
* Note: Returned string needs to be deallocated.
|
||||||
|
*
|
||||||
|
* \param maxLength The maximum length of the generated string.
|
||||||
|
*
|
||||||
|
* \returns a newly allocated random string; or NULL if maxLength was invalid or string could not be allocated.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomAsciiStringWithMaximumLength")] public static extern c_char* RandomAsciiStringWithMaximumLength(c_int maxLength);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates random null-terminated string. The length for
|
||||||
|
* the string is defined by the size parameter.
|
||||||
|
* String can contain ASCII characters from 32 to 126.
|
||||||
|
*
|
||||||
|
* Note: Returned string needs to be deallocated.
|
||||||
|
*
|
||||||
|
* \param size The length of the generated string
|
||||||
|
*
|
||||||
|
* \returns a newly allocated random string; or NULL if size was invalid or string could not be allocated.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandomAsciiStringOfSize")] public static extern c_char* RandomAsciiStringOfSize(c_int size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the invocation count for the fuzzer since last ...FuzzerInit.
|
||||||
|
*
|
||||||
|
* \returns the invocation count.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_GetFuzzerInvocationCount")] public static extern c_int GetFuzzerInvocationCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_test_fuzzer_h_ */
|
||||||
162
src/SDL_test_harness.bf
Normal file
162
src/SDL_test_harness.bf
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDLTest
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test suite related functions of SDL test framework.
|
||||||
|
*
|
||||||
|
* This code is a part of the SDL test library, not the main SDL library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Defines types for test case definitions and the test execution harness API.
|
||||||
|
|
||||||
|
Based on original GSOC code by Markus Kauppila <markus.kauppila@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDLTest_CommonState */
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ! Definitions for test case structures */
|
||||||
|
public const let TEST_ENABLED = 1;
|
||||||
|
public const let TEST_DISABLED = 0;
|
||||||
|
|
||||||
|
/* ! Definition of all the possible test return values of the test case method */
|
||||||
|
public const let TEST_ABORTED = -1;
|
||||||
|
public const let TEST_STARTED = 0;
|
||||||
|
public const let TEST_COMPLETED = 1;
|
||||||
|
public const let TEST_SKIPPED = 2;
|
||||||
|
|
||||||
|
/* ! Definition of all the possible test results for the harness */
|
||||||
|
public const let TEST_RESULT_PASSED = 0;
|
||||||
|
public const let TEST_RESULT_FAILED = 1;
|
||||||
|
public const let TEST_RESULT_NO_ASSERT = 2;
|
||||||
|
public const let TEST_RESULT_SKIPPED = 3;
|
||||||
|
public const let TEST_RESULT_SETUP_FAILURE = 4;
|
||||||
|
|
||||||
|
/* !< Function pointer to a test case setup function (run before every test) */
|
||||||
|
public function void TestCaseSetUpFp(void** arg);
|
||||||
|
|
||||||
|
/* !< Function pointer to a test case function */
|
||||||
|
public function c_int TestCaseFp(void* arg);
|
||||||
|
|
||||||
|
/* !< Function pointer to a test case teardown function (run after every test) */
|
||||||
|
public function void TestCaseTearDownFp(void* arg);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Holds information about a single test case.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct TestCaseReference {
|
||||||
|
/* !< Func2Stress */
|
||||||
|
public TestCaseFp testCase;
|
||||||
|
/* !< Short name (or function name) "Func2Stress" */
|
||||||
|
public c_char* name;
|
||||||
|
/* !< Long name or full description "This test pushes func2() to the limit." */
|
||||||
|
public c_char* description;
|
||||||
|
/* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */
|
||||||
|
public c_int enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Holds information about a test suite (multiple test cases).
|
||||||
|
*/
|
||||||
|
[CRepr] public struct TestSuiteReference {
|
||||||
|
/* !< "PlatformSuite" */
|
||||||
|
public c_char* name;
|
||||||
|
/* !< The function that is run before each test. NULL skips. */
|
||||||
|
public TestCaseSetUpFp testSetUp;
|
||||||
|
/* !< The test cases that are run as part of the suite. Last item should be NULL. */
|
||||||
|
public TestCaseReference** testCases;
|
||||||
|
/* !< The function that is run after each test. NULL skips. */
|
||||||
|
public TestCaseTearDownFp testTearDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generates a random run seed string for the harness. The generated seed
|
||||||
|
* will contain alphanumeric characters (0-9A-Z).
|
||||||
|
*
|
||||||
|
* \param buffer Buffer in which to generate the random seed. Must have a capacity of at least length + 1 characters.
|
||||||
|
* \param length Number of alphanumeric characters to write to buffer, must be >0
|
||||||
|
*
|
||||||
|
* \returns A null-terminated seed string and equal to the in put buffer on success, NULL on failure
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_GenerateRunSeed")] public static extern c_char* GenerateRunSeed(c_char* buffer, c_int length);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Holds information about the execution of test suites.
|
||||||
|
* */
|
||||||
|
[CRepr] public struct TestSuiteRunner;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a new test suite runner, that will execute the given test suites.
|
||||||
|
* It will register the harness cli arguments to the common SDL state.
|
||||||
|
*
|
||||||
|
* \param state Common SDL state on which to register CLI arguments.
|
||||||
|
* \param testSuites NULL-terminated test suites containing test cases.
|
||||||
|
*
|
||||||
|
* \returns the test run result: 0 when all tests passed, 1 if any tests failed.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_CreateTestSuiteRunner")] public static extern TestSuiteRunner* CreateTestSuiteRunner(CommonState* state, TestSuiteReference** testSuites);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Destroy a test suite runner.
|
||||||
|
* It will unregister the harness cli arguments to the common SDL state.
|
||||||
|
*
|
||||||
|
* \param runner The runner that should be destroyed.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_DestroyTestSuiteRunner")] public static extern void DestroyTestSuiteRunner(TestSuiteRunner* runner);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Execute a test suite, using the configured run seed, execution key, filter, etc.
|
||||||
|
*
|
||||||
|
* \param runner The runner that should be executed.
|
||||||
|
*
|
||||||
|
* \returns the test run result: 0 when all tests passed, 1 if any tests failed.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_ExecuteTestSuiteRunner")] public static extern c_int ExecuteTestSuiteRunner(TestSuiteRunner* runner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_test_h_arness_h */
|
||||||
94
src/SDL_test_log.bf
Normal file
94
src/SDL_test_log.bf
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDLTest
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logging related functions of SDL test framework.
|
||||||
|
*
|
||||||
|
* This code is a part of the SDL test library, not the main SDL library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Wrapper to log in the TEST category
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints given message with a timestamp in the TEST category and given priority.
|
||||||
|
*
|
||||||
|
* \param priority Priority of the message
|
||||||
|
* \param fmt Message to be logged
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_LogMessage")] public static extern void LogMessage(LogPriority priority, c_char* fmt, ...);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints given message with a timestamp in the TEST category and INFO priority.
|
||||||
|
*
|
||||||
|
* \param fmt Message to be logged
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_Log")] public static extern void Log(c_char* fmt, ...);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints given prefix and buffer.
|
||||||
|
* Non-printible characters in the raw data are substituted by printible alternatives.
|
||||||
|
*
|
||||||
|
* \param prefix Prefix message.
|
||||||
|
* \param buffer Raw data to be escaped.
|
||||||
|
* \param size Number of bytes in buffer.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_LogEscapedString")] public static extern void LogEscapedString(c_char* prefix, void* buffer, c_size size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints given message with a timestamp in the TEST category and the ERROR priority.
|
||||||
|
*
|
||||||
|
* \param fmt Message to be logged
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_LogError")] public static extern void LogError(c_char* fmt, ...);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_test_log_h_ */
|
||||||
132
src/SDL_test_md5.bf
Normal file
132
src/SDL_test_md5.bf
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDLTest
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MD5 related functions of SDL test framework.
|
||||||
|
*
|
||||||
|
* This code is a part of the SDL test library, not the main SDL library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***********************************************************************
|
||||||
|
** Header file for implementation of MD5 **
|
||||||
|
** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
|
||||||
|
** Created: 2/17/90 RLR **
|
||||||
|
** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
|
||||||
|
** Revised (for MD5): RLR 4/27/91 **
|
||||||
|
** -- G modified to have y&~z instead of y&z **
|
||||||
|
** -- FF, GG, HH modified to add in last register done **
|
||||||
|
** -- Access pattern: round 2 works mod 5, round 3 works mod 3 **
|
||||||
|
** -- distinct additive constant for each step **
|
||||||
|
** -- round 4 added, working mod 7 **
|
||||||
|
***********************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
***********************************************************************
|
||||||
|
** Message-digest routines: **
|
||||||
|
** To form the message digest for a message M **
|
||||||
|
** (1) Initialize a context buffer mdContext using MD5Init **
|
||||||
|
** (2) Call MD5Update on mdContext and M **
|
||||||
|
** (3) Call MD5Final on mdContext **
|
||||||
|
** The message digest is now in mdContext->digest[0...15] **
|
||||||
|
***********************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------ Definitions --------- */
|
||||||
|
|
||||||
|
/* typedef a 32-bit type */
|
||||||
|
public typealias MD5UINT4 = Uint32;
|
||||||
|
|
||||||
|
/* Data structure for MD5 (Message-Digest) computation */
|
||||||
|
[CRepr] public struct Md5Context {
|
||||||
|
public MD5UINT4[2] i; /* number of _bits_ handled mod 2^64 */
|
||||||
|
public MD5UINT4[4] buf; /* scratch buffer */
|
||||||
|
public c_uchar[64] @in; /* input buffer */
|
||||||
|
public c_uchar[16] digest; /* actual digest after Md5Final call */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- Function Prototypes ------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initialize the context
|
||||||
|
*
|
||||||
|
* \param mdContext pointer to context variable
|
||||||
|
*
|
||||||
|
* Note: The function initializes the message-digest context
|
||||||
|
* mdContext. Call before each new use of the context -
|
||||||
|
* all fields are set to zero.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_Md5Init")] public static extern void Md5Init(Md5Context* mdContext);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update digest from variable length data
|
||||||
|
*
|
||||||
|
* \param mdContext pointer to context variable
|
||||||
|
* \param inBuf pointer to data array/string
|
||||||
|
* \param inLen length of data array/string
|
||||||
|
*
|
||||||
|
* Note: The function updates the message-digest context to account
|
||||||
|
* for the presence of each of the characters inBuf[0..inLen-1]
|
||||||
|
* in the message whose digest is being computed.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_Md5Update")] public static extern void Md5Update(Md5Context* mdContext, c_uchar* inBuf, c_uint inLen);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* complete digest computation
|
||||||
|
*
|
||||||
|
* \param mdContext pointer to context variable
|
||||||
|
*
|
||||||
|
* Note: The function terminates the message-digest computation and
|
||||||
|
* ends with the desired message digest in mdContext.digest[0..15].
|
||||||
|
* Always call before using the digest[] variable.
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_Md5Final")] public static extern void Md5Final(Md5Context* mdContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_test_md5_h_ */
|
||||||
77
src/SDL_test_memory.bf
Normal file
77
src/SDL_test_memory.bf
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDLTest
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Memory tracking related functions of SDL test framework.
|
||||||
|
*
|
||||||
|
* This code is a part of the SDL test library, not the main SDL library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start tracking SDL memory allocations
|
||||||
|
*
|
||||||
|
* \note This should be called before any other SDL functions for complete tracking coverage
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_TrackAllocations")] public static extern void TrackAllocations();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill allocations with random data
|
||||||
|
*
|
||||||
|
* \note This implicitly calls SDLTest_TrackAllocations()
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_RandFillAllocations")] public static extern void RandFillAllocations();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a log of any outstanding allocations
|
||||||
|
*
|
||||||
|
* \note This can be called after SDL_Quit()
|
||||||
|
*/
|
||||||
|
[LinkName("SDLTest_LogAllocations")] public static extern void LogAllocations();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_test_memory_h_ */
|
||||||
590
src/SDL_thread.bf
Normal file
590
src/SDL_thread.bf
Normal file
@@ -0,0 +1,590 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryThread
|
||||||
|
*
|
||||||
|
* SDL offers cross-platform thread management functions. These are mostly
|
||||||
|
* concerned with starting threads, setting their priority, and dealing with
|
||||||
|
* their termination.
|
||||||
|
*
|
||||||
|
* In addition, there is support for Thread Local Storage (data that is unique
|
||||||
|
* to each thread, but accessed from a single key).
|
||||||
|
*
|
||||||
|
* On platforms without thread support (such as Emscripten when built without
|
||||||
|
* pthreads), these functions still exist, but things like SDL_CreateThread()
|
||||||
|
* will report failure without doing anything.
|
||||||
|
*
|
||||||
|
* If you're going to work with threads, you almost certainly need to have a
|
||||||
|
* good understanding of thread safety measures: locking and synchronization
|
||||||
|
* mechanisms are handled by the functions in SDL_mutex.h.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Thread synchronization primitives */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* _beginthreadex() and _endthreadex() */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SDL thread object.
|
||||||
|
*
|
||||||
|
* These are opaque data.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateThread
|
||||||
|
* \sa SDL_WaitThread
|
||||||
|
*/
|
||||||
|
[CRepr] public struct Thread;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A unique numeric ID that identifies a thread.
|
||||||
|
*
|
||||||
|
* These are different from SDL_Thread objects, which are generally what an
|
||||||
|
* application will operate on, but having a way to uniquely identify a thread
|
||||||
|
* can be useful at times.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetThreadID
|
||||||
|
* \sa SDL_GetCurrentThreadID
|
||||||
|
*/
|
||||||
|
public typealias ThreadID = Uint64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thread local storage ID.
|
||||||
|
*
|
||||||
|
* 0 is the invalid ID. An app can create these and then set data for these
|
||||||
|
* IDs that is unique to each thread.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetTLS
|
||||||
|
* \sa SDL_SetTLS
|
||||||
|
*/
|
||||||
|
public typealias TLSID = AtomicInt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SDL thread priority.
|
||||||
|
*
|
||||||
|
* SDL will make system changes as necessary in order to apply the thread
|
||||||
|
* priority. Code which attempts to control thread state related to priority
|
||||||
|
* should be aware that calling SDL_SetCurrentThreadPriority may alter such
|
||||||
|
* state. SDL_HINT_THREAD_PRIORITY_POLICY can be used to control aspects of
|
||||||
|
* this behavior.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum ThreadPriority : c_int {
|
||||||
|
Low,
|
||||||
|
Normal,
|
||||||
|
High,
|
||||||
|
TimeCritical,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SDL thread state.
|
||||||
|
*
|
||||||
|
* The current state of a thread can be checked by calling SDL_GetThreadState.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetThreadState
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum ThreadState : c_int
|
||||||
|
{
|
||||||
|
Unknown, /**< The thread is not valid */
|
||||||
|
Alive, /**< The thread is currently running */
|
||||||
|
Detached, /**< The thread is detached and can't be waited on */
|
||||||
|
Complete, /**< The thread has finished and should be cleaned up with SDL_WaitThread() */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function passed to SDL_CreateThread() as the new thread's entry point.
|
||||||
|
*
|
||||||
|
* \param data what was passed as `data` to SDL_CreateThread().
|
||||||
|
* \returns a value that can be reported through SDL_WaitThread().
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public function c_int ThreadFunction(void* data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Note that these aren't the correct function signatures in this block, but
|
||||||
|
* this is what the API reference manual should look like for all intents and
|
||||||
|
* purposes.
|
||||||
|
*
|
||||||
|
* Technical details, not for the wiki (hello, header readers!)...
|
||||||
|
*
|
||||||
|
* On Windows (and maybe other platforms), a program might use a different
|
||||||
|
* C runtime than its libraries. Or, in SDL's case, it might use a C runtime
|
||||||
|
* while SDL uses none at all.
|
||||||
|
*
|
||||||
|
* C runtimes expect to initialize thread-specific details when a new thread
|
||||||
|
* is created, but to do this in SDL_CreateThread would require SDL to know
|
||||||
|
* intimate details about the caller's C runtime, which is not possible.
|
||||||
|
*
|
||||||
|
* So SDL_CreateThread has two extra parameters, which are
|
||||||
|
* hidden at compile time by macros: the C runtime's `_beginthreadex` and
|
||||||
|
* `_endthreadex` entry points. If these are not NULL, they are used to spin
|
||||||
|
* and terminate the new thread; otherwise the standard Win32 `CreateThread`
|
||||||
|
* function is used. When `SDL_CreateThread` is called from a compiler that
|
||||||
|
* needs this C runtime thread init function, macros insert the appropriate
|
||||||
|
* function pointers for SDL_CreateThread's caller (which might be a different
|
||||||
|
* compiler with a different runtime in different calls to SDL_CreateThread!).
|
||||||
|
*
|
||||||
|
* SDL_BeginThreadFunction defaults to `_beginthreadex` on Windows (and NULL
|
||||||
|
* everywhere else), but apps that have extremely specific special needs can
|
||||||
|
* define this to something else and the SDL headers will use it, passing the
|
||||||
|
* app-defined value to SDL_CreateThread calls. Redefine this with caution!
|
||||||
|
*
|
||||||
|
* Platforms that don't need _beginthread stuff (most everything) will fail
|
||||||
|
* SDL_CreateThread with an error if these pointers _aren't_ NULL.
|
||||||
|
*
|
||||||
|
* Unless you are doing something extremely complicated, like perhaps a
|
||||||
|
* language binding, **you should never deal with this directly**. Let SDL's
|
||||||
|
* macros handle this platform-specific detail transparently!
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new thread with a default stack size.
|
||||||
|
*
|
||||||
|
* This is a convenience function, equivalent to calling
|
||||||
|
* SDL_CreateThreadWithProperties with the following properties set:
|
||||||
|
*
|
||||||
|
* - `SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER`: `fn`
|
||||||
|
* - `SDL_PROP_THREAD_CREATE_NAME_STRING`: `name`
|
||||||
|
* - `SDL_PROP_THREAD_CREATE_USERDATA_POINTER`: `data`
|
||||||
|
*
|
||||||
|
* Note that this "function" is actually a macro that calls an internal
|
||||||
|
* function with two extra parameters not listed here; they are hidden through
|
||||||
|
* preprocessor macros and are needed to support various C runtimes at the
|
||||||
|
* point of the function call. Language bindings that aren't using the C
|
||||||
|
* headers will need to deal with this.
|
||||||
|
*
|
||||||
|
* Usually, apps should just call this function the same way on every platform
|
||||||
|
* and let the macros hide the details.
|
||||||
|
*
|
||||||
|
* \param fn the SDL_ThreadFunction function to call in the new thread.
|
||||||
|
* \param name the name of the thread.
|
||||||
|
* \param data a pointer that is passed to `fn`.
|
||||||
|
* \returns an opaque pointer to the new thread object on success, NULL if the
|
||||||
|
* new thread could not be created; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateThreadWithProperties
|
||||||
|
* \sa SDL_WaitThread
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new thread with with the specified properties.
|
||||||
|
*
|
||||||
|
* These are the supported properties:
|
||||||
|
*
|
||||||
|
* - `SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER`: an SDL_ThreadFunction
|
||||||
|
* value that will be called at the start of the new thread's life.
|
||||||
|
* Required.
|
||||||
|
* - `SDL_PROP_THREAD_CREATE_NAME_STRING`: the name of the new thread, which
|
||||||
|
* might be available to debuggers. Optional, defaults to NULL.
|
||||||
|
* - `SDL_PROP_THREAD_CREATE_USERDATA_POINTER`: an arbitrary app-defined
|
||||||
|
* pointer, which is passed to the entry function on the new thread, as its
|
||||||
|
* only parameter. Optional, defaults to NULL.
|
||||||
|
* - `SDL_PROP_THREAD_CREATE_STACKSIZE_NUMBER`: the size, in bytes, of the new
|
||||||
|
* thread's stack. Optional, defaults to 0 (system-defined default).
|
||||||
|
*
|
||||||
|
* SDL makes an attempt to report `SDL_PROP_THREAD_CREATE_NAME_STRING` to the
|
||||||
|
* system, so that debuggers can display it. Not all platforms support this.
|
||||||
|
*
|
||||||
|
* Thread naming is a little complicated: Most systems have very small limits
|
||||||
|
* for the string length (Haiku has 32 bytes, Linux currently has 16, Visual
|
||||||
|
* C++ 6.0 has _nine_!), and possibly other arbitrary rules. You'll have to
|
||||||
|
* see what happens with your system's debugger. The name should be UTF-8 (but
|
||||||
|
* using the naming limits of C identifiers is a better bet). There are no
|
||||||
|
* requirements for thread naming conventions, so long as the string is
|
||||||
|
* null-terminated UTF-8, but these guidelines are helpful in choosing a name:
|
||||||
|
*
|
||||||
|
* https://stackoverflow.com/questions/149932/naming-conventions-for-threads
|
||||||
|
*
|
||||||
|
* If a system imposes requirements, SDL will try to munge the string for it
|
||||||
|
* (truncate, etc), but the original string contents will be available from
|
||||||
|
* SDL_GetThreadName().
|
||||||
|
*
|
||||||
|
* The size (in bytes) of the new stack can be specified with
|
||||||
|
* `SDL_PROP_THREAD_CREATE_STACKSIZE_NUMBER`. Zero means "use the system
|
||||||
|
* default" which might be wildly different between platforms. x86 Linux
|
||||||
|
* generally defaults to eight megabytes, an embedded device might be a few
|
||||||
|
* kilobytes instead. You generally need to specify a stack that is a multiple
|
||||||
|
* of the system's page size (in many cases, this is 4 kilobytes, but check
|
||||||
|
* your system documentation).
|
||||||
|
*
|
||||||
|
* Note that this "function" is actually a macro that calls an internal
|
||||||
|
* function with two extra parameters not listed here; they are hidden through
|
||||||
|
* preprocessor macros and are needed to support various C runtimes at the
|
||||||
|
* point of the function call. Language bindings that aren't using the C
|
||||||
|
* headers will need to deal with this.
|
||||||
|
*
|
||||||
|
* The actual symbol in SDL is `SDL_CreateThreadWithPropertiesRuntime`, so
|
||||||
|
* there is no symbol clash, but trying to load an SDL shared library and look
|
||||||
|
* for "SDL_CreateThreadWithProperties" will fail.
|
||||||
|
*
|
||||||
|
* Usually, apps should just call this function the same way on every platform
|
||||||
|
* and let the macros hide the details.
|
||||||
|
*
|
||||||
|
* \param props the properties to use.
|
||||||
|
* \returns an opaque pointer to the new thread object on success, NULL if the
|
||||||
|
* new thread could not be created; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateThread
|
||||||
|
* \sa SDL_WaitThread
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* end wiki documentation for macros that are meant to look like functions. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* The real implementation, hidden from the wiki, so it can show this as real functions that don't have macro magic. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* currently no other platforms than Windows use _beginthreadex/_endthreadex things. */
|
||||||
|
|
||||||
|
|
||||||
|
public const let BeginThreadFunction = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public const let EndThreadFunction = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* These are the actual functions exported from SDL! Don't use them directly! Use the SDL_CreateThread and SDL_CreateThreadWithProperties macros! */
|
||||||
|
/**
|
||||||
|
* The actual entry point for SDL_CreateThread.
|
||||||
|
*
|
||||||
|
* \param fn the SDL_ThreadFunction function to call in the new thread
|
||||||
|
* \param name the name of the thread
|
||||||
|
* \param data a pointer that is passed to `fn`
|
||||||
|
* \param pfnBeginThread the C runtime's _beginthreadex (or whatnot). Can be NULL.
|
||||||
|
* \param pfnEndThread the C runtime's _endthreadex (or whatnot). Can be NULL.
|
||||||
|
* \returns an opaque pointer to the new thread object on success, NULL if the
|
||||||
|
* new thread could not be created; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateThreadRuntime")] public static extern Thread* CreateThreadRuntime(ThreadFunction fn, c_char* name, void* data, FunctionPointer pfnBeginThread, FunctionPointer pfnEndThread);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The actual entry point for SDL_CreateThreadWithProperties.
|
||||||
|
*
|
||||||
|
* \param props the properties to use
|
||||||
|
* \param pfnBeginThread the C runtime's _beginthreadex (or whatnot). Can be NULL.
|
||||||
|
* \param pfnEndThread the C runtime's _endthreadex (or whatnot). Can be NULL.
|
||||||
|
* \returns an opaque pointer to the new thread object on success, NULL if the
|
||||||
|
* new thread could not be created; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateThreadWithPropertiesRuntime")] public static extern Thread* CreateThreadWithPropertiesRuntime(PropertiesID props, FunctionPointer pfnBeginThread, FunctionPointer pfnEndThread);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public const let PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER = "SDL.thread.create.entry_function";
|
||||||
|
public const let PROP_THREAD_CREATE_NAME_STRING = "SDL.thread.create.name";
|
||||||
|
public const let PROP_THREAD_CREATE_USERDATA_POINTER = "SDL.thread.create.userdata";
|
||||||
|
public const let PROP_THREAD_CREATE_STACKSIZE_NUMBER = "SDL.thread.create.stacksize";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the thread name as it was specified in SDL_CreateThread().
|
||||||
|
*
|
||||||
|
* \param thread the thread to query.
|
||||||
|
* \returns a pointer to a UTF-8 string that names the specified thread, or
|
||||||
|
* NULL if it doesn't have a name.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetThreadName")] public static extern c_char* GetThreadName(Thread* thread);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the thread identifier for the current thread.
|
||||||
|
*
|
||||||
|
* This thread identifier is as reported by the underlying operating system.
|
||||||
|
* If SDL is running on a platform that does not support threads the return
|
||||||
|
* value will always be zero.
|
||||||
|
*
|
||||||
|
* This function also returns a valid thread ID when called from the main
|
||||||
|
* thread.
|
||||||
|
*
|
||||||
|
* \returns the ID of the current thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetThreadID
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetCurrentThreadID")] public static extern ThreadID GetCurrentThreadID();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the thread identifier for the specified thread.
|
||||||
|
*
|
||||||
|
* This thread identifier is as reported by the underlying operating system.
|
||||||
|
* If SDL is running on a platform that does not support threads the return
|
||||||
|
* value will always be zero.
|
||||||
|
*
|
||||||
|
* \param thread the thread to query.
|
||||||
|
* \returns the ID of the specified thread, or the ID of the current thread if
|
||||||
|
* `thread` is NULL.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetCurrentThreadID
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetThreadID")] public static extern ThreadID GetThreadID(Thread* thread);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the priority for the current thread.
|
||||||
|
*
|
||||||
|
* Note that some platforms will not let you alter the priority (or at least,
|
||||||
|
* promote the thread to a higher priority) at all, and some require you to be
|
||||||
|
* an administrator account. Be prepared for this to fail.
|
||||||
|
*
|
||||||
|
* \param priority the SDL_ThreadPriority to set.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetCurrentThreadPriority")] public static extern bool SetCurrentThreadPriority(ThreadPriority priority);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait for a thread to finish.
|
||||||
|
*
|
||||||
|
* Threads that haven't been detached will remain until this function cleans
|
||||||
|
* them up. Not doing so is a resource leak.
|
||||||
|
*
|
||||||
|
* Once a thread has been cleaned up through this function, the SDL_Thread
|
||||||
|
* that references it becomes invalid and should not be referenced again. As
|
||||||
|
* such, only one thread may call SDL_WaitThread() on another.
|
||||||
|
*
|
||||||
|
* The return code from the thread function is placed in the area pointed to
|
||||||
|
* by `status`, if `status` is not NULL.
|
||||||
|
*
|
||||||
|
* You may not wait on a thread that has been used in a call to
|
||||||
|
* SDL_DetachThread(). Use either that function or this one, but not both, or
|
||||||
|
* behavior is undefined.
|
||||||
|
*
|
||||||
|
* It is safe to pass a NULL thread to this function; it is a no-op.
|
||||||
|
*
|
||||||
|
* Note that the thread pointer is freed by this function and is not valid
|
||||||
|
* afterward.
|
||||||
|
*
|
||||||
|
* \param thread the SDL_Thread pointer that was returned from the
|
||||||
|
* SDL_CreateThread() call that started this thread.
|
||||||
|
* \param status a pointer filled in with the value returned from the thread
|
||||||
|
* function by its 'return', or -1 if the thread has been
|
||||||
|
* detached or isn't valid, may be NULL.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateThread
|
||||||
|
* \sa SDL_DetachThread
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_WaitThread")] public static extern void WaitThread(Thread* thread, out c_int status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current state of a thread.
|
||||||
|
*
|
||||||
|
* \param thread the thread to query.
|
||||||
|
* \returns the current state of a thread, or SDL_THREAD_UNKNOWN if the thread
|
||||||
|
* isn't valid.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_ThreadState
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetThreadState")] public static extern ThreadState GetThreadState(Thread* thread);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Let a thread clean up on exit without intervention.
|
||||||
|
*
|
||||||
|
* A thread may be "detached" to signify that it should not remain until
|
||||||
|
* another thread has called SDL_WaitThread() on it. Detaching a thread is
|
||||||
|
* useful for long-running threads that nothing needs to synchronize with or
|
||||||
|
* further manage. When a detached thread is done, it simply goes away.
|
||||||
|
*
|
||||||
|
* There is no way to recover the return code of a detached thread. If you
|
||||||
|
* need this, don't detach the thread and instead use SDL_WaitThread().
|
||||||
|
*
|
||||||
|
* Once a thread is detached, you should usually assume the SDL_Thread isn't
|
||||||
|
* safe to reference again, as it will become invalid immediately upon the
|
||||||
|
* detached thread's exit, instead of remaining until someone has called
|
||||||
|
* SDL_WaitThread() to finally clean it up. As such, don't detach the same
|
||||||
|
* thread more than once.
|
||||||
|
*
|
||||||
|
* If a thread has already exited when passed to SDL_DetachThread(), it will
|
||||||
|
* stop waiting for a call to SDL_WaitThread() and clean up immediately. It is
|
||||||
|
* not safe to detach a thread that might be used with SDL_WaitThread().
|
||||||
|
*
|
||||||
|
* You may not call SDL_WaitThread() on a thread that has been detached. Use
|
||||||
|
* either that function or this one, but not both, or behavior is undefined.
|
||||||
|
*
|
||||||
|
* It is safe to pass NULL to this function; it is a no-op.
|
||||||
|
*
|
||||||
|
* \param thread the SDL_Thread pointer that was returned from the
|
||||||
|
* SDL_CreateThread() call that started this thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateThread
|
||||||
|
* \sa SDL_WaitThread
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_DetachThread")] public static extern void DetachThread(Thread* thread);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current thread's value associated with a thread local storage ID.
|
||||||
|
*
|
||||||
|
* \param id a pointer to the thread local storage ID, may not be NULL.
|
||||||
|
* \returns the value associated with the ID for the current thread or NULL if
|
||||||
|
* no value has been set; call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetTLS
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTLS")] public static extern void* GetTLS(TLSID* id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The callback used to cleanup data passed to SDL_SetTLS.
|
||||||
|
*
|
||||||
|
* This is called when a thread exits, to allow an app to free any resources.
|
||||||
|
*
|
||||||
|
* \param value a pointer previously handed to SDL_SetTLS.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetTLS
|
||||||
|
*/
|
||||||
|
public function void TLSDestructorCallback(void* value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current thread's value associated with a thread local storage ID.
|
||||||
|
*
|
||||||
|
* If the thread local storage ID is not initialized (the value is 0), a new
|
||||||
|
* ID will be created in a thread-safe way, so all calls using a pointer to
|
||||||
|
* the same ID will refer to the same local storage.
|
||||||
|
*
|
||||||
|
* Note that replacing a value from a previous call to this function on the
|
||||||
|
* same thread does _not_ call the previous value's destructor!
|
||||||
|
*
|
||||||
|
* `destructor` can be NULL; it is assumed that `value` does not need to be
|
||||||
|
* cleaned up if so.
|
||||||
|
*
|
||||||
|
* \param id a pointer to the thread local storage ID, may not be NULL.
|
||||||
|
* \param value the value to associate with the ID for the current thread.
|
||||||
|
* \param destructor a function called when the thread exits, to free the
|
||||||
|
* value, may be NULL.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetTLS
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetTLS")] public static extern bool SetTLS(TLSID* id, void* value, TLSDestructorCallback destructor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup all TLS data for this thread.
|
||||||
|
*
|
||||||
|
* If you are creating your threads outside of SDL and then calling SDL
|
||||||
|
* functions, you should call this function before your thread exits, to
|
||||||
|
* properly clean up SDL memory.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CleanupTLS")] public static extern void CleanupTLS();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_thread_h_ */
|
||||||
242
src/SDL_time.bf
Normal file
242
src/SDL_time.bf
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryTime
|
||||||
|
*
|
||||||
|
* SDL realtime clock and date/time routines.
|
||||||
|
*
|
||||||
|
* There are two data types that are used in this category: SDL_Time, which
|
||||||
|
* represents the nanoseconds since a specific moment (an "epoch"), and
|
||||||
|
* SDL_DateTime, which breaks time down into human-understandable components:
|
||||||
|
* years, months, days, hours, etc.
|
||||||
|
*
|
||||||
|
* Much of the functionality is involved in converting those two types to
|
||||||
|
* other useful forms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A structure holding a calendar date and time broken down into its
|
||||||
|
* components.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct DateTime
|
||||||
|
{
|
||||||
|
public c_int year; /**< Year */
|
||||||
|
public c_int month; /**< Month [01-12] */
|
||||||
|
public c_int day; /**< Day of the month [01-31] */
|
||||||
|
public c_int hour; /**< Hour [0-23] */
|
||||||
|
public c_int minute; /**< Minute [0-59] */
|
||||||
|
public c_int second; /**< Seconds [0-60] */
|
||||||
|
public c_int nanosecond; /**< Nanoseconds [0-999999999] */
|
||||||
|
public c_int day_of_week; /**< Day of the week [0-6] (0 being Sunday) */
|
||||||
|
public c_int utc_offset; /**< Seconds east of UTC */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The preferred date format of the current system locale.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetDateTimeLocalePreferences
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum DateFormat : c_int
|
||||||
|
{
|
||||||
|
Yyyymmdd = 0, /**< Year/Month/Day */
|
||||||
|
Ddmmyyyy = 1, /**< Day/Month/Year */
|
||||||
|
Mmddyyyy = 2, /**< Month/Day/Year */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The preferred time format of the current system locale.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetDateTimeLocalePreferences
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum TimeFormat : c_int
|
||||||
|
{
|
||||||
|
_24hr = 0, /**< 24 hour time */
|
||||||
|
_12hr = 1, /**< 12 hour time */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current preferred date and time format for the system locale.
|
||||||
|
*
|
||||||
|
* This might be a "slow" call that has to query the operating system. It's
|
||||||
|
* best to ask for this once and save the results. However, the preferred
|
||||||
|
* formats can change, usually because the user has changed a system
|
||||||
|
* preference outside of your program.
|
||||||
|
*
|
||||||
|
* \param dateFormat a pointer to the SDL_DateFormat to hold the returned date
|
||||||
|
* format, may be NULL.
|
||||||
|
* \param timeFormat a pointer to the SDL_TimeFormat to hold the returned time
|
||||||
|
* format, may be NULL.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetDateTimeLocalePreferences")] public static extern bool GetDateTimeLocalePreferences(DateFormat* dateFormat, TimeFormat* timeFormat);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current value of the system realtime clock in nanoseconds since
|
||||||
|
* Jan 1, 1970 in Universal Coordinated Time (UTC).
|
||||||
|
*
|
||||||
|
* \param ticks the SDL_Time to hold the returned tick count.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetCurrentTime")] public static extern bool GetCurrentTime(Time* ticks);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts an SDL_Time in nanoseconds since the epoch to a calendar time in
|
||||||
|
* the SDL_DateTime format.
|
||||||
|
*
|
||||||
|
* \param ticks the SDL_Time to be converted.
|
||||||
|
* \param dt the resulting SDL_DateTime.
|
||||||
|
* \param localTime the resulting SDL_DateTime will be expressed in local time
|
||||||
|
* if true, otherwise it will be in Universal Coordinated
|
||||||
|
* Time (UTC).
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_TimeToDateTime")] public static extern bool TimeToDateTime(Time ticks, DateTime* dt, bool localTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a calendar time to an SDL_Time in nanoseconds since the epoch.
|
||||||
|
*
|
||||||
|
* This function ignores the day_of_week member of the SDL_DateTime struct, so
|
||||||
|
* it may remain unset.
|
||||||
|
*
|
||||||
|
* \param dt the source SDL_DateTime.
|
||||||
|
* \param ticks the resulting SDL_Time.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_DateTimeToTime")] public static extern bool DateTimeToTime(DateTime* dt, Time* ticks);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts an SDL time into a Windows FILETIME (100-nanosecond intervals
|
||||||
|
* since January 1, 1601).
|
||||||
|
*
|
||||||
|
* This function fills in the two 32-bit values of the FILETIME structure.
|
||||||
|
*
|
||||||
|
* \param ticks the time to convert.
|
||||||
|
* \param dwLowDateTime a pointer filled in with the low portion of the
|
||||||
|
* Windows FILETIME value.
|
||||||
|
* \param dwHighDateTime a pointer filled in with the high portion of the
|
||||||
|
* Windows FILETIME value.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_TimeToWindows")] public static extern void TimeToWindows(Time ticks, out Uint32 dwLowDateTime, out Uint32 dwHighDateTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a Windows FILETIME (100-nanosecond intervals since January 1,
|
||||||
|
* 1601) to an SDL time.
|
||||||
|
*
|
||||||
|
* This function takes the two 32-bit values of the FILETIME structure as
|
||||||
|
* parameters.
|
||||||
|
*
|
||||||
|
* \param dwLowDateTime the low portion of the Windows FILETIME value.
|
||||||
|
* \param dwHighDateTime the high portion of the Windows FILETIME value.
|
||||||
|
* \returns the converted SDL time.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_TimeFromWindows")] public static extern Time TimeFromWindows(Uint32 dwLowDateTime, Uint32 dwHighDateTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of days in a month for a given year.
|
||||||
|
*
|
||||||
|
* \param year the year.
|
||||||
|
* \param month the month [1-12].
|
||||||
|
* \returns the number of days in the requested month or -1 on failure; call
|
||||||
|
* SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetDaysInMonth")] public static extern c_int GetDaysInMonth(c_int year, c_int month);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the day of year for a calendar date.
|
||||||
|
*
|
||||||
|
* \param year the year component of the date.
|
||||||
|
* \param month the month component of the date.
|
||||||
|
* \param day the day component of the date.
|
||||||
|
* \returns the day of year [0-365] if the date is valid or -1 on failure;
|
||||||
|
* call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetDayOfYear")] public static extern c_int GetDayOfYear(c_int year, c_int month, c_int day);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the day of week for a calendar date.
|
||||||
|
*
|
||||||
|
* \param year the year component of the date.
|
||||||
|
* \param month the month component of the date.
|
||||||
|
* \param day the day component of the date.
|
||||||
|
* \returns a value between 0 and 6 (0 being Sunday) if the date is valid or
|
||||||
|
* -1 on failure; call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetDayOfWeek")] public static extern c_int GetDayOfWeek(c_int year, c_int month, c_int day);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_time_h_ */
|
||||||
464
src/SDL_timer.bf
Normal file
464
src/SDL_timer.bf
Normal file
@@ -0,0 +1,464 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryTimer
|
||||||
|
*
|
||||||
|
* SDL provides time management functionality. It is useful for dealing with
|
||||||
|
* (usually) small durations of time.
|
||||||
|
*
|
||||||
|
* This is not to be confused with _calendar time_ management, which is
|
||||||
|
* provided by [CategoryTime](CategoryTime).
|
||||||
|
*
|
||||||
|
* This category covers measuring time elapsed (SDL_GetTicks(),
|
||||||
|
* SDL_GetPerformanceCounter()), putting a thread to sleep for a certain
|
||||||
|
* amount of time (SDL_Delay(), SDL_DelayNS(), SDL_DelayPrecise()), and firing
|
||||||
|
* a callback function after a certain amount of time has elapsed
|
||||||
|
* (SDL_AddTimer(), etc).
|
||||||
|
*
|
||||||
|
* There are also useful macros to convert between time units, like
|
||||||
|
* SDL_SECONDS_TO_NS() and such.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL time constants */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of milliseconds in a second.
|
||||||
|
*
|
||||||
|
* This is always 1000.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public const let MS_PER_SECOND = 1000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of microseconds in a second.
|
||||||
|
*
|
||||||
|
* This is always 1000000.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public const let US_PER_SECOND = 1000000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of nanoseconds in a second.
|
||||||
|
*
|
||||||
|
* This is always 1000000000.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public const let NS_PER_SECOND = 1000000000L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of nanoseconds in a millisecond.
|
||||||
|
*
|
||||||
|
* This is always 1000000.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public const let NS_PER_MS = 1000000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of nanoseconds in a microsecond.
|
||||||
|
*
|
||||||
|
* This is always 1000.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public const let NS_PER_US = 1000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert seconds to nanoseconds.
|
||||||
|
*
|
||||||
|
* This only converts whole numbers, not fractional seconds.
|
||||||
|
*
|
||||||
|
* \param S the number of seconds to convert.
|
||||||
|
* \returns S, expressed in nanoseconds.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert nanoseconds to seconds.
|
||||||
|
*
|
||||||
|
* This performs a division, so the results can be dramatically different if
|
||||||
|
* `NS` is an integer or floating point value.
|
||||||
|
*
|
||||||
|
* \param NS the number of nanoseconds to convert.
|
||||||
|
* \returns NS, expressed in seconds.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert milliseconds to nanoseconds.
|
||||||
|
*
|
||||||
|
* This only converts whole numbers, not fractional milliseconds.
|
||||||
|
*
|
||||||
|
* \param MS the number of milliseconds to convert.
|
||||||
|
* \returns MS, expressed in nanoseconds.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert nanoseconds to milliseconds.
|
||||||
|
*
|
||||||
|
* This performs a division, so the results can be dramatically different if
|
||||||
|
* `NS` is an integer or floating point value.
|
||||||
|
*
|
||||||
|
* \param NS the number of nanoseconds to convert.
|
||||||
|
* \returns NS, expressed in milliseconds.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert microseconds to nanoseconds.
|
||||||
|
*
|
||||||
|
* This only converts whole numbers, not fractional microseconds.
|
||||||
|
*
|
||||||
|
* \param US the number of microseconds to convert.
|
||||||
|
* \returns US, expressed in nanoseconds.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert nanoseconds to microseconds.
|
||||||
|
*
|
||||||
|
* This performs a division, so the results can be dramatically different if
|
||||||
|
* `NS` is an integer or floating point value.
|
||||||
|
*
|
||||||
|
* \param NS the number of nanoseconds to convert.
|
||||||
|
* \returns NS, expressed in microseconds.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this macro from any thread.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of milliseconds that have elapsed since the SDL library
|
||||||
|
* initialization.
|
||||||
|
*
|
||||||
|
* \returns an unsigned 64‑bit integer that represents the number of
|
||||||
|
* milliseconds that have elapsed since the SDL library was
|
||||||
|
* initialized (typically via a call to SDL_Init).
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetTicksNS
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTicks")] public static extern Uint64 GetTicks();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of nanoseconds since SDL library initialization.
|
||||||
|
*
|
||||||
|
* \returns an unsigned 64-bit value representing the number of nanoseconds
|
||||||
|
* since the SDL library initialized.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTicksNS")] public static extern Uint64 GetTicksNS();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current value of the high resolution counter.
|
||||||
|
*
|
||||||
|
* This function is typically used for profiling.
|
||||||
|
*
|
||||||
|
* The counter values are only meaningful relative to each other. Differences
|
||||||
|
* between values can be converted to times by using
|
||||||
|
* SDL_GetPerformanceFrequency().
|
||||||
|
*
|
||||||
|
* \returns the current counter value.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetPerformanceFrequency
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetPerformanceCounter")] public static extern Uint64 GetPerformanceCounter();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the count per second of the high resolution counter.
|
||||||
|
*
|
||||||
|
* \returns a platform-specific count per second.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetPerformanceCounter
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetPerformanceFrequency")] public static extern Uint64 GetPerformanceFrequency();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait a specified number of milliseconds before returning.
|
||||||
|
*
|
||||||
|
* This function waits a specified number of milliseconds before returning. It
|
||||||
|
* waits at least the specified time, but possibly longer due to OS
|
||||||
|
* scheduling.
|
||||||
|
*
|
||||||
|
* \param ms the number of milliseconds to delay.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_DelayNS
|
||||||
|
* \sa SDL_DelayPrecise
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_Delay")] public static extern void Delay(Uint32 ms);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait a specified number of nanoseconds before returning.
|
||||||
|
*
|
||||||
|
* This function waits a specified number of nanoseconds before returning. It
|
||||||
|
* waits at least the specified time, but possibly longer due to OS
|
||||||
|
* scheduling.
|
||||||
|
*
|
||||||
|
* \param ns the number of nanoseconds to delay.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Delay
|
||||||
|
* \sa SDL_DelayPrecise
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_DelayNS")] public static extern void DelayNS(Uint64 ns);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait a specified number of nanoseconds before returning.
|
||||||
|
*
|
||||||
|
* This function waits a specified number of nanoseconds before returning. It
|
||||||
|
* will attempt to wait as close to the requested time as possible, busy
|
||||||
|
* waiting if necessary, but could return later due to OS scheduling.
|
||||||
|
*
|
||||||
|
* \param ns the number of nanoseconds to delay.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Delay
|
||||||
|
* \sa SDL_DelayNS
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_DelayPrecise")] public static extern void DelayPrecise(Uint64 ns);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Definition of the timer ID type.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public typealias TimerID = Uint32;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function prototype for the millisecond timer callback function.
|
||||||
|
*
|
||||||
|
* The callback function is passed the current timer interval and returns the
|
||||||
|
* next timer interval, in milliseconds. If the returned value is the same as
|
||||||
|
* the one passed in, the periodic alarm continues, otherwise a new alarm is
|
||||||
|
* scheduled. If the callback returns 0, the periodic alarm is canceled and
|
||||||
|
* will be removed.
|
||||||
|
*
|
||||||
|
* \param userdata an arbitrary pointer provided by the app through
|
||||||
|
* SDL_AddTimer, for its own use.
|
||||||
|
* \param timerID the current timer being processed.
|
||||||
|
* \param interval the current callback time interval.
|
||||||
|
* \returns the new callback time interval, or 0 to disable further runs of
|
||||||
|
* the callback.
|
||||||
|
*
|
||||||
|
* \threadsafety SDL may call this callback at any time from a background
|
||||||
|
* thread; the application is responsible for locking resources
|
||||||
|
* the callback touches that need to be protected.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AddTimer
|
||||||
|
*/
|
||||||
|
public function Uint32 TimerCallback(void* userdata, TimerID timerID, Uint32 interval);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call a callback function at a future time.
|
||||||
|
*
|
||||||
|
* The callback function is passed the current timer interval and the user
|
||||||
|
* supplied parameter from the SDL_AddTimer() call and should return the next
|
||||||
|
* timer interval. If the value returned from the callback is 0, the timer is
|
||||||
|
* canceled and will be removed.
|
||||||
|
*
|
||||||
|
* The callback is run on a separate thread, and for short timeouts can
|
||||||
|
* potentially be called before this function returns.
|
||||||
|
*
|
||||||
|
* Timers take into account the amount of time it took to execute the
|
||||||
|
* callback. For example, if the callback took 250 ms to execute and returned
|
||||||
|
* 1000 (ms), the timer would only wait another 750 ms before its next
|
||||||
|
* iteration.
|
||||||
|
*
|
||||||
|
* Timing may be inexact due to OS scheduling. Be sure to note the current
|
||||||
|
* time with SDL_GetTicksNS() or SDL_GetPerformanceCounter() in case your
|
||||||
|
* callback needs to adjust for variances.
|
||||||
|
*
|
||||||
|
* \param interval the timer delay, in milliseconds, passed to `callback`.
|
||||||
|
* \param callback the SDL_TimerCallback function to call when the specified
|
||||||
|
* `interval` elapses.
|
||||||
|
* \param userdata a pointer that is passed to `callback`.
|
||||||
|
* \returns a timer ID or 0 on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AddTimerNS
|
||||||
|
* \sa SDL_RemoveTimer
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_AddTimer")] public static extern TimerID AddTimer(Uint32 interval, TimerCallback callback, void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function prototype for the nanosecond timer callback function.
|
||||||
|
*
|
||||||
|
* The callback function is passed the current timer interval and returns the
|
||||||
|
* next timer interval, in nanoseconds. If the returned value is the same as
|
||||||
|
* the one passed in, the periodic alarm continues, otherwise a new alarm is
|
||||||
|
* scheduled. If the callback returns 0, the periodic alarm is canceled and
|
||||||
|
* will be removed.
|
||||||
|
*
|
||||||
|
* \param userdata an arbitrary pointer provided by the app through
|
||||||
|
* SDL_AddTimer, for its own use.
|
||||||
|
* \param timerID the current timer being processed.
|
||||||
|
* \param interval the current callback time interval.
|
||||||
|
* \returns the new callback time interval, or 0 to disable further runs of
|
||||||
|
* the callback.
|
||||||
|
*
|
||||||
|
* \threadsafety SDL may call this callback at any time from a background
|
||||||
|
* thread; the application is responsible for locking resources
|
||||||
|
* the callback touches that need to be protected.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AddTimerNS
|
||||||
|
*/
|
||||||
|
public function Uint64 NSTimerCallback(void* userdata, TimerID timerID, Uint64 interval);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call a callback function at a future time.
|
||||||
|
*
|
||||||
|
* The callback function is passed the current timer interval and the user
|
||||||
|
* supplied parameter from the SDL_AddTimerNS() call and should return the
|
||||||
|
* next timer interval. If the value returned from the callback is 0, the
|
||||||
|
* timer is canceled and will be removed.
|
||||||
|
*
|
||||||
|
* The callback is run on a separate thread, and for short timeouts can
|
||||||
|
* potentially be called before this function returns.
|
||||||
|
*
|
||||||
|
* Timers take into account the amount of time it took to execute the
|
||||||
|
* callback. For example, if the callback took 250 ns to execute and returned
|
||||||
|
* 1000 (ns), the timer would only wait another 750 ns before its next
|
||||||
|
* iteration.
|
||||||
|
*
|
||||||
|
* Timing may be inexact due to OS scheduling. Be sure to note the current
|
||||||
|
* time with SDL_GetTicksNS() or SDL_GetPerformanceCounter() in case your
|
||||||
|
* callback needs to adjust for variances.
|
||||||
|
*
|
||||||
|
* \param interval the timer delay, in nanoseconds, passed to `callback`.
|
||||||
|
* \param callback the SDL_TimerCallback function to call when the specified
|
||||||
|
* `interval` elapses.
|
||||||
|
* \param userdata a pointer that is passed to `callback`.
|
||||||
|
* \returns a timer ID or 0 on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AddTimer
|
||||||
|
* \sa SDL_RemoveTimer
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_AddTimerNS")] public static extern TimerID AddTimerNS(Uint64 interval, NSTimerCallback callback, void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a timer created with SDL_AddTimer().
|
||||||
|
*
|
||||||
|
* \param id the ID of the timer to remove.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety It is safe to call this function from any thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_AddTimer
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_RemoveTimer")] public static extern bool RemoveTimer(TimerID id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_timer_h_ */
|
||||||
195
src/SDL_touch.bf
Normal file
195
src/SDL_touch.bf
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryTouch
|
||||||
|
*
|
||||||
|
* SDL offers touch input, on platforms that support it. It can manage
|
||||||
|
* multiple touch devices and track multiple fingers on those devices.
|
||||||
|
*
|
||||||
|
* Touches are mostly dealt with through the event system, in the
|
||||||
|
* SDL_EVENT_FINGER_DOWN, SDL_EVENT_FINGER_MOTION, and SDL_EVENT_FINGER_UP
|
||||||
|
* events, but there are also functions to query for hardware details, etc.
|
||||||
|
*
|
||||||
|
* The touch system, by default, will also send virtual mouse events; this can
|
||||||
|
* be useful for making a some desktop apps work on a phone without
|
||||||
|
* significant changes. For apps that care about mouse and touch input
|
||||||
|
* separately, they should ignore mouse events that have a `which` field of
|
||||||
|
* SDL_TOUCH_MOUSEID.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A unique ID for a touch device.
|
||||||
|
*
|
||||||
|
* This ID is valid for the time the device is connected to the system, and is
|
||||||
|
* never reused for the lifetime of the application.
|
||||||
|
*
|
||||||
|
* The value 0 is an invalid ID.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public typealias TouchID = Uint64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A unique ID for a single finger on a touch device.
|
||||||
|
*
|
||||||
|
* This ID is valid for the time the finger (stylus, etc) is touching and will
|
||||||
|
* be unique for all fingers currently in contact, so this ID tracks the
|
||||||
|
* lifetime of a single continuous touch. This value may represent an index, a
|
||||||
|
* pointer, or some other unique ID, depending on the platform.
|
||||||
|
*
|
||||||
|
* The value 0 is an invalid ID.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public typealias FingerID = Uint64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An enum that describes the type of a touch device.
|
||||||
|
*
|
||||||
|
* \since This enum is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[AllowDuplicates] public enum TouchDeviceType : c_int
|
||||||
|
{
|
||||||
|
Invalid = -1,
|
||||||
|
Direct, /**< touch screen with window-relative coordinates */
|
||||||
|
IndirectAbsolute, /**< trackpad with absolute device coordinates */
|
||||||
|
IndirectRelative, /**< trackpad with screen cursor-relative coordinates */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data about a single finger in a multitouch event.
|
||||||
|
*
|
||||||
|
* Each touch event is a collection of fingers that are simultaneously in
|
||||||
|
* contact with the touch device (so a "touch" can be a "multitouch," in
|
||||||
|
* reality), and this struct reports details of the specific fingers.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetTouchFingers
|
||||||
|
*/
|
||||||
|
[CRepr] public struct Finger
|
||||||
|
{
|
||||||
|
public FingerID id; /**< the finger ID */
|
||||||
|
public float x; /**< the x-axis location of the touch event, normalized (0...1) */
|
||||||
|
public float y; /**< the y-axis location of the touch event, normalized (0...1) */
|
||||||
|
public float pressure; /**< the quantity of pressure applied, normalized (0...1) */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SDL_MouseID for mouse events simulated with touch input.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public const let TOUCH_MOUSEID = ((SDL.MouseID)-1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The SDL_TouchID for touch events simulated with mouse input.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public const let MOUSE_TOUCHID = ((SDL.TouchID)-1);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of registered touch devices.
|
||||||
|
*
|
||||||
|
* On some platforms SDL first sees the touch device if it was actually used.
|
||||||
|
* Therefore the returned list might be empty, although devices are available.
|
||||||
|
* After using all devices at least once the number will be correct.
|
||||||
|
*
|
||||||
|
* \param count a pointer filled in with the number of devices returned, may
|
||||||
|
* be NULL.
|
||||||
|
* \returns a 0 terminated array of touch device IDs or NULL on failure; call
|
||||||
|
* SDL_GetError() for more information. This should be freed with
|
||||||
|
* SDL_free() when it is no longer needed.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTouchDevices")] public static extern TouchID* GetTouchDevices(out c_int count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the touch device name as reported from the driver.
|
||||||
|
*
|
||||||
|
* \param touchID the touch device instance ID.
|
||||||
|
* \returns touch device name, or NULL on failure; call SDL_GetError() for
|
||||||
|
* more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTouchDeviceName")] public static extern c_char* GetTouchDeviceName(TouchID touchID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type of the given touch device.
|
||||||
|
*
|
||||||
|
* \param touchID the ID of a touch device.
|
||||||
|
* \returns touch device type.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTouchDeviceType")] public static extern TouchDeviceType GetTouchDeviceType(TouchID touchID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of active fingers for a given touch device.
|
||||||
|
*
|
||||||
|
* \param touchID the ID of a touch device.
|
||||||
|
* \param count a pointer filled in with the number of fingers returned, can
|
||||||
|
* be NULL.
|
||||||
|
* \returns a NULL terminated array of SDL_Finger pointers or NULL on failure;
|
||||||
|
* call SDL_GetError() for more information. This is a single
|
||||||
|
* allocation that should be freed with SDL_free() when it is no
|
||||||
|
* longer needed.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTouchFingers")] public static extern Finger** GetTouchFingers(TouchID touchID, out c_int count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_touch_h_ */
|
||||||
556
src/SDL_tray.bf
Normal file
556
src/SDL_tray.bf
Normal file
@@ -0,0 +1,556 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryTray
|
||||||
|
*
|
||||||
|
* SDL offers a way to add items to the "system tray" (more correctly called
|
||||||
|
* the "notification area" on Windows). On platforms that offer this concept,
|
||||||
|
* an SDL app can add a tray icon, submenus, checkboxes, and clickable
|
||||||
|
* entries, and register a callback that is fired when the user clicks on
|
||||||
|
* these pieces.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An opaque handle representing a toplevel system tray object.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct Tray;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An opaque handle representing a menu/submenu on a system tray object.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct TrayMenu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An opaque handle representing an entry on a system tray object.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[CRepr] public struct TrayEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flags that control the creation of system tray entries.
|
||||||
|
*
|
||||||
|
* Some of these flags are required; exactly one of them must be specified at
|
||||||
|
* the time a tray entry is created. Other flags are optional; zero or more of
|
||||||
|
* those can be OR'ed together with the required flag.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_InsertTrayEntryAt
|
||||||
|
*/
|
||||||
|
public enum TrayEntryFlags : Uint32
|
||||||
|
{
|
||||||
|
Button = 0x00000001u, /**< Make the entry a simple button. Required. */
|
||||||
|
Checkbox = 0x00000002u, /**< Make the entry a checkbox. Required. */
|
||||||
|
Submenu = 0x00000004u, /**< Prepare the entry to have a submenu. Required */
|
||||||
|
Disabled = 0x80000000u, /**< Make the entry disabled. Optional. */
|
||||||
|
Checked = 0x40000000u, /**< Make the entry checked. This is valid only for checkboxes. Optional. */
|
||||||
|
} /**< Make the entry checked. This is valid only for checkboxes. Optional. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A callback that is invoked when a tray entry is selected.
|
||||||
|
*
|
||||||
|
* \param userdata an optional pointer to pass extra data to the callback when
|
||||||
|
* it will be invoked.
|
||||||
|
* \param entry the tray entry that was selected.
|
||||||
|
*
|
||||||
|
* \since This datatype is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_SetTrayEntryCallback
|
||||||
|
*/
|
||||||
|
public function void TrayCallback(void* userdata, TrayEntry* entry);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an icon to be placed in the operating system's tray, or equivalent.
|
||||||
|
*
|
||||||
|
* Many platforms advise not using a system tray unless persistence is a
|
||||||
|
* necessary feature. Avoid needlessly creating a tray icon, as the user may
|
||||||
|
* feel like it clutters their interface.
|
||||||
|
*
|
||||||
|
* Using tray icons require the video subsystem.
|
||||||
|
*
|
||||||
|
* \param icon a surface to be used as icon. May be NULL.
|
||||||
|
* \param tooltip a tooltip to be displayed when the mouse hovers the icon in
|
||||||
|
* UTF-8 encoding. Not supported on all platforms. May be NULL.
|
||||||
|
* \returns The newly created system tray icon.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateTrayMenu
|
||||||
|
* \sa SDL_GetTrayMenu
|
||||||
|
* \sa SDL_DestroyTray
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateTray")] public static extern Tray* CreateTray(Surface* icon, c_char* tooltip);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the system tray icon's icon.
|
||||||
|
*
|
||||||
|
* \param tray the tray icon to be updated.
|
||||||
|
* \param icon the new icon. May be NULL.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateTray
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetTrayIcon")] public static extern void SetTrayIcon(Tray* tray, Surface* icon);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the system tray icon's tooltip.
|
||||||
|
*
|
||||||
|
* \param tray the tray icon to be updated.
|
||||||
|
* \param tooltip the new tooltip in UTF-8 encoding. May be NULL.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateTray
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetTrayTooltip")] public static extern void SetTrayTooltip(Tray* tray, c_char* tooltip);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a menu for a system tray.
|
||||||
|
*
|
||||||
|
* This should be called at most once per tray icon.
|
||||||
|
*
|
||||||
|
* This function does the same thing as SDL_CreateTraySubmenu(), except that
|
||||||
|
* it takes a SDL_Tray instead of a SDL_TrayEntry.
|
||||||
|
*
|
||||||
|
* A menu does not need to be destroyed; it will be destroyed with the tray.
|
||||||
|
*
|
||||||
|
* \param tray the tray to bind the menu to.
|
||||||
|
* \returns the newly created menu.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateTray
|
||||||
|
* \sa SDL_GetTrayMenu
|
||||||
|
* \sa SDL_GetTrayMenuParentTray
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateTrayMenu")] public static extern TrayMenu* CreateTrayMenu(Tray* tray);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a submenu for a system tray entry.
|
||||||
|
*
|
||||||
|
* This should be called at most once per tray entry.
|
||||||
|
*
|
||||||
|
* This function does the same thing as SDL_CreateTrayMenu, except that it
|
||||||
|
* takes a SDL_TrayEntry instead of a SDL_Tray.
|
||||||
|
*
|
||||||
|
* A menu does not need to be destroyed; it will be destroyed with the tray.
|
||||||
|
*
|
||||||
|
* \param entry the tray entry to bind the menu to.
|
||||||
|
* \returns the newly created menu.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_InsertTrayEntryAt
|
||||||
|
* \sa SDL_GetTraySubmenu
|
||||||
|
* \sa SDL_GetTrayMenuParentEntry
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_CreateTraySubmenu")] public static extern TrayMenu* CreateTraySubmenu(TrayEntry* entry);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a previously created tray menu.
|
||||||
|
*
|
||||||
|
* You should have called SDL_CreateTrayMenu() on the tray object. This
|
||||||
|
* function allows you to fetch it again later.
|
||||||
|
*
|
||||||
|
* This function does the same thing as SDL_GetTraySubmenu(), except that it
|
||||||
|
* takes a SDL_Tray instead of a SDL_TrayEntry.
|
||||||
|
*
|
||||||
|
* A menu does not need to be destroyed; it will be destroyed with the tray.
|
||||||
|
*
|
||||||
|
* \param tray the tray entry to bind the menu to.
|
||||||
|
* \returns the newly created menu.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateTray
|
||||||
|
* \sa SDL_CreateTrayMenu
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTrayMenu")] public static extern TrayMenu* GetTrayMenu(Tray* tray);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a previously created tray entry submenu.
|
||||||
|
*
|
||||||
|
* You should have called SDL_CreateTraySubmenu() on the entry object. This
|
||||||
|
* function allows you to fetch it again later.
|
||||||
|
*
|
||||||
|
* This function does the same thing as SDL_GetTrayMenu(), except that it
|
||||||
|
* takes a SDL_TrayEntry instead of a SDL_Tray.
|
||||||
|
*
|
||||||
|
* A menu does not need to be destroyed; it will be destroyed with the tray.
|
||||||
|
*
|
||||||
|
* \param entry the tray entry to bind the menu to.
|
||||||
|
* \returns the newly created menu.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_InsertTrayEntryAt
|
||||||
|
* \sa SDL_CreateTraySubmenu
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTraySubmenu")] public static extern TrayMenu* GetTraySubmenu(TrayEntry* entry);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of entries in the menu, in order.
|
||||||
|
*
|
||||||
|
* \param menu The menu to get entries from.
|
||||||
|
* \param count An optional pointer to obtain the number of entries in the
|
||||||
|
* menu.
|
||||||
|
* \returns a NULL-terminated list of entries within the given menu. The
|
||||||
|
* pointer becomes invalid when any function that inserts or deletes
|
||||||
|
* entries in the menu is called.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_RemoveTrayEntry
|
||||||
|
* \sa SDL_InsertTrayEntryAt
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTrayEntries")] public static extern TrayEntry** GetTrayEntries(TrayMenu* menu, c_int* count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a tray entry.
|
||||||
|
*
|
||||||
|
* \param entry The entry to be deleted.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetTrayEntries
|
||||||
|
* \sa SDL_InsertTrayEntryAt
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_RemoveTrayEntry")] public static extern void RemoveTrayEntry(TrayEntry* entry);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert a tray entry at a given position.
|
||||||
|
*
|
||||||
|
* If label is NULL, the entry will be a separator. Many functions won't work
|
||||||
|
* for an entry that is a separator.
|
||||||
|
*
|
||||||
|
* An entry does not need to be destroyed; it will be destroyed with the tray.
|
||||||
|
*
|
||||||
|
* \param menu the menu to append the entry to.
|
||||||
|
* \param pos the desired position for the new entry. Entries at or following
|
||||||
|
* this place will be moved. If pos is -1, the entry is appended.
|
||||||
|
* \param label the text to be displayed on the entry, in UTF-8 encoding, or
|
||||||
|
* NULL for a separator.
|
||||||
|
* \param flags a combination of flags, some of which are mandatory.
|
||||||
|
* \returns the newly created entry, or NULL if pos is out of bounds.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_TrayEntryFlags
|
||||||
|
* \sa SDL_GetTrayEntries
|
||||||
|
* \sa SDL_RemoveTrayEntry
|
||||||
|
* \sa SDL_GetTrayEntryParent
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_InsertTrayEntryAt")] public static extern TrayEntry* InsertTrayEntryAt(TrayMenu* menu, c_int pos, c_char* label, TrayEntryFlags flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the label of an entry.
|
||||||
|
*
|
||||||
|
* An entry cannot change between a separator and an ordinary entry; that is,
|
||||||
|
* it is not possible to set a non-NULL label on an entry that has a NULL
|
||||||
|
* label (separators), or to set a NULL label to an entry that has a non-NULL
|
||||||
|
* label. The function will silently fail if that happens.
|
||||||
|
*
|
||||||
|
* \param entry the entry to be updated.
|
||||||
|
* \param label the new label for the entry in UTF-8 encoding.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetTrayEntries
|
||||||
|
* \sa SDL_InsertTrayEntryAt
|
||||||
|
* \sa SDL_GetTrayEntryLabel
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetTrayEntryLabel")] public static extern void SetTrayEntryLabel(TrayEntry* entry, c_char* label);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the label of an entry.
|
||||||
|
*
|
||||||
|
* If the returned value is NULL, the entry is a separator.
|
||||||
|
*
|
||||||
|
* \param entry the entry to be read.
|
||||||
|
* \returns the label of the entry in UTF-8 encoding.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetTrayEntries
|
||||||
|
* \sa SDL_InsertTrayEntryAt
|
||||||
|
* \sa SDL_SetTrayEntryLabel
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTrayEntryLabel")] public static extern c_char* GetTrayEntryLabel(TrayEntry* entry);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether or not an entry is checked.
|
||||||
|
*
|
||||||
|
* The entry must have been created with the SDL_TRAYENTRY_CHECKBOX flag.
|
||||||
|
*
|
||||||
|
* \param entry the entry to be updated.
|
||||||
|
* \param checked true if the entry should be checked; false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetTrayEntries
|
||||||
|
* \sa SDL_InsertTrayEntryAt
|
||||||
|
* \sa SDL_GetTrayEntryChecked
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetTrayEntryChecked")] public static extern void SetTrayEntryChecked(TrayEntry* entry, bool @checked);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether or not an entry is checked.
|
||||||
|
*
|
||||||
|
* The entry must have been created with the SDL_TRAYENTRY_CHECKBOX flag.
|
||||||
|
*
|
||||||
|
* \param entry the entry to be read.
|
||||||
|
* \returns true if the entry is checked; false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetTrayEntries
|
||||||
|
* \sa SDL_InsertTrayEntryAt
|
||||||
|
* \sa SDL_SetTrayEntryChecked
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTrayEntryChecked")] public static extern bool GetTrayEntryChecked(TrayEntry* entry);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether or not an entry is enabled.
|
||||||
|
*
|
||||||
|
* \param entry the entry to be updated.
|
||||||
|
* \param enabled true if the entry should be enabled; false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetTrayEntries
|
||||||
|
* \sa SDL_InsertTrayEntryAt
|
||||||
|
* \sa SDL_GetTrayEntryEnabled
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetTrayEntryEnabled")] public static extern void SetTrayEntryEnabled(TrayEntry* entry, bool enabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether or not an entry is enabled.
|
||||||
|
*
|
||||||
|
* \param entry the entry to be read.
|
||||||
|
* \returns true if the entry is enabled; false otherwise.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetTrayEntries
|
||||||
|
* \sa SDL_InsertTrayEntryAt
|
||||||
|
* \sa SDL_SetTrayEntryEnabled
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTrayEntryEnabled")] public static extern bool GetTrayEntryEnabled(TrayEntry* entry);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a callback to be invoked when the entry is selected.
|
||||||
|
*
|
||||||
|
* \param entry the entry to be updated.
|
||||||
|
* \param callback a callback to be invoked when the entry is selected.
|
||||||
|
* \param userdata an optional pointer to pass extra data to the callback when
|
||||||
|
* it will be invoked.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetTrayEntries
|
||||||
|
* \sa SDL_InsertTrayEntryAt
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_SetTrayEntryCallback")] public static extern void SetTrayEntryCallback(TrayEntry* entry, TrayCallback callback, void* userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simulate a click on a tray entry.
|
||||||
|
*
|
||||||
|
* \param entry The entry to activate.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_ClickTrayEntry")] public static extern void ClickTrayEntry(TrayEntry* entry);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys a tray object.
|
||||||
|
*
|
||||||
|
* This also destroys all associated menus and entries.
|
||||||
|
*
|
||||||
|
* \param tray the tray icon to be destroyed.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateTray
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_DestroyTray")] public static extern void DestroyTray(Tray* tray);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the menu containing a certain tray entry.
|
||||||
|
*
|
||||||
|
* \param entry the entry for which to get the parent menu.
|
||||||
|
* \returns the parent menu.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_InsertTrayEntryAt
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTrayEntryParent")] public static extern TrayMenu* GetTrayEntryParent(TrayEntry* entry);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the entry for which the menu is a submenu, if the current menu is a
|
||||||
|
* submenu.
|
||||||
|
*
|
||||||
|
* Either this function or SDL_GetTrayMenuParentTray() will return non-NULL
|
||||||
|
* for any given menu.
|
||||||
|
*
|
||||||
|
* \param menu the menu for which to get the parent entry.
|
||||||
|
* \returns the parent entry, or NULL if this menu is not a submenu.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateTraySubmenu
|
||||||
|
* \sa SDL_GetTrayMenuParentTray
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTrayMenuParentEntry")] public static extern TrayEntry* GetTrayMenuParentEntry(TrayMenu* menu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the tray for which this menu is the first-level menu, if the current
|
||||||
|
* menu isn't a submenu.
|
||||||
|
*
|
||||||
|
* Either this function or SDL_GetTrayMenuParentEntry() will return non-NULL
|
||||||
|
* for any given menu.
|
||||||
|
*
|
||||||
|
* \param menu the menu for which to get the parent enttrayry.
|
||||||
|
* \returns the parent tray, or NULL if this menu is a submenu.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should be called on the thread that created the
|
||||||
|
* tray.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateTrayMenu
|
||||||
|
* \sa SDL_GetTrayMenuParentEntry
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetTrayMenuParentTray")] public static extern Tray* GetTrayMenuParentTray(TrayMenu* menu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the trays.
|
||||||
|
*
|
||||||
|
* This is called automatically by the event loop and is only needed if you're
|
||||||
|
* using trays but aren't handling SDL events.
|
||||||
|
*
|
||||||
|
* \threadsafety This function should only be called on the main thread.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_UpdateTrays")] public static extern void UpdateTrays();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_tray_h_ */
|
||||||
195
src/SDL_version.bf
Normal file
195
src/SDL_version.bf
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryVersion
|
||||||
|
*
|
||||||
|
* Functionality to query the current SDL version, both as headers the app was
|
||||||
|
* compiled against, and a library the app is linked to.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current major version of SDL headers.
|
||||||
|
*
|
||||||
|
* If this were SDL version 3.2.1, this value would be 3.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public const let MAJOR_VERSION = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current minor version of the SDL headers.
|
||||||
|
*
|
||||||
|
* If this were SDL version 3.2.1, this value would be 2.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public const let MINOR_VERSION = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current micro (or patchlevel) version of the SDL headers.
|
||||||
|
*
|
||||||
|
* If this were SDL version 3.2.1, this value would be 1.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public const let MICRO_VERSION = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This macro turns the version numbers into a numeric value.
|
||||||
|
*
|
||||||
|
* (1,2,3) becomes 1002003.
|
||||||
|
*
|
||||||
|
* \param major the major version number.
|
||||||
|
* \param minor the minorversion number.
|
||||||
|
* \param patch the patch version number.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public static c_int VERSIONNUM(c_int major, c_int minor, c_int patch) => ((major)*1000000+(minor)*1000+(patch));
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This macro extracts the major version from a version number
|
||||||
|
*
|
||||||
|
* 1002003 becomes 1.
|
||||||
|
*
|
||||||
|
* \param version the version number.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public static c_int VERSIONNUM_MAJOR(c_int version) => ((version)/1000000);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This macro extracts the minor version from a version number
|
||||||
|
*
|
||||||
|
* 1002003 becomes 2.
|
||||||
|
*
|
||||||
|
* \param version the version number.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public static c_int VERSIONNUM_MINOR(c_int version) => (((version)/1000)%1000);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This macro extracts the micro version from a version number
|
||||||
|
*
|
||||||
|
* 1002003 becomes 3.
|
||||||
|
*
|
||||||
|
* \param version the version number.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public static c_int VERSIONNUM_MICRO(c_int version) => ((version)%1000);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the version number macro for the current SDL version.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetVersion
|
||||||
|
*/
|
||||||
|
public const let VERSION
|
||||||
|
= VERSIONNUM(MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This macro will evaluate to true if compiled with SDL at least X.Y.Z.
|
||||||
|
*
|
||||||
|
* \since This macro is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
public static bool VERSION_ATLEAST(c_int X, c_int Y, c_int Z) => (VERSION>=VERSIONNUM(X,Y,Z));
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the version of SDL that is linked against your program.
|
||||||
|
*
|
||||||
|
* If you are linking to SDL dynamically, then it is possible that the current
|
||||||
|
* version will be different than the version you compiled against. This
|
||||||
|
* function returns the current version, while SDL_VERSION is the version you
|
||||||
|
* compiled with.
|
||||||
|
*
|
||||||
|
* This function may be called safely at any time, even before SDL_Init().
|
||||||
|
*
|
||||||
|
* \returns the version of the linked library.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetRevision
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetVersion")] public static extern c_int GetVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the code revision of the SDL library that is linked against your
|
||||||
|
* program.
|
||||||
|
*
|
||||||
|
* This value is the revision of the code you are linking against and may be
|
||||||
|
* different from the code you are compiling with, which is found in the
|
||||||
|
* constant SDL_REVISION if you explicitly include SDL_revision.h
|
||||||
|
*
|
||||||
|
* The revision is an arbitrary string (a hash value) uniquely identifying the
|
||||||
|
* exact revision of the SDL library in use, and is only useful in comparing
|
||||||
|
* against other revisions. It is NOT an incrementing number.
|
||||||
|
*
|
||||||
|
* If SDL wasn't built from a git repository with the appropriate tools, this
|
||||||
|
* will return an empty string.
|
||||||
|
*
|
||||||
|
* You shouldn't use this function for anything but logging it for debugging
|
||||||
|
* purposes. The string is not intended to be reliable in any way.
|
||||||
|
*
|
||||||
|
* \returns an arbitrary string, uniquely identifying the exact revision of
|
||||||
|
* the SDL library in use.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetVersion
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_GetRevision")] public static extern c_char* GetRevision();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_version_h_ */
|
||||||
3448
src/SDL_video.bf
Normal file
3448
src/SDL_video.bf
Normal file
File diff suppressed because it is too large
Load Diff
291
src/SDL_vulkan.bf
Normal file
291
src/SDL_vulkan.bf
Normal file
@@ -0,0 +1,291 @@
|
|||||||
|
// This file was generated by Cpp2Beef
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
using static SDL3.SDL;
|
||||||
|
|
||||||
|
namespace SDL3;
|
||||||
|
|
||||||
|
extension SDL
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Simple DirectMedia Layer
|
||||||
|
Copyright (C) 2017, Mark Callow
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* # CategoryVulkan
|
||||||
|
*
|
||||||
|
* Functions for creating Vulkan surfaces on SDL windows.
|
||||||
|
*
|
||||||
|
* For the most part, Vulkan operates independent of SDL, but it benefits from
|
||||||
|
* a little support during setup.
|
||||||
|
*
|
||||||
|
* Use SDL_Vulkan_GetInstanceExtensions() to get platform-specific bits for
|
||||||
|
* creating a VkInstance, then SDL_Vulkan_GetVkGetInstanceProcAddr() to get
|
||||||
|
* the appropriate function for querying Vulkan entry points. Then
|
||||||
|
* SDL_Vulkan_CreateSurface() will get you the final pieces you need to
|
||||||
|
* prepare for rendering into an SDL_Window with Vulkan.
|
||||||
|
*
|
||||||
|
* Unlike OpenGL, most of the details of "context" creation and window buffer
|
||||||
|
* swapping are handled by the Vulkan API directly, so SDL doesn't provide
|
||||||
|
* Vulkan equivalents of SDL_GL_SwapWindow(), etc; they aren't necessary.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Avoid including vulkan_core.h, don't define VkInstance if it's already included */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[CRepr] public struct VkInstance_T;public typealias VkInstance = VkInstance_T*;
|
||||||
|
[CRepr] public struct VkPhysicalDevice_T;public typealias VkPhysicalDevice = VkPhysicalDevice_T*;
|
||||||
|
[CRepr] public struct VkSurfaceKHR_T;public typealias VkSurfaceKHR = VkSurfaceKHR_T*;
|
||||||
|
[CRepr] public struct VkAllocationCallbacks;
|
||||||
|
|
||||||
|
/* Make sure to undef to avoid issues in case of later vulkan include */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* !NO_SDL_VULKAN_TYPEDEFS */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \name Vulkan support functions
|
||||||
|
*/
|
||||||
|
/* @{ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamically load the Vulkan loader library.
|
||||||
|
*
|
||||||
|
* This should be called after initializing the video driver, but before
|
||||||
|
* creating any Vulkan windows. If no Vulkan loader library is loaded, the
|
||||||
|
* default library will be loaded upon creation of the first Vulkan window.
|
||||||
|
*
|
||||||
|
* SDL keeps a counter of how many times this function has been successfully
|
||||||
|
* called, so it is safe to call this function multiple times, so long as it
|
||||||
|
* is eventually paired with an equivalent number of calls to
|
||||||
|
* SDL_Vulkan_UnloadLibrary. The `path` argument is ignored unless there is no
|
||||||
|
* library currently loaded, and and the library isn't actually unloaded until
|
||||||
|
* there have been an equivalent number of calls to SDL_Vulkan_UnloadLibrary.
|
||||||
|
*
|
||||||
|
* It is fairly common for Vulkan applications to link with libvulkan instead
|
||||||
|
* of explicitly loading it at run time. This will work with SDL provided the
|
||||||
|
* application links to a dynamic library and both it and SDL use the same
|
||||||
|
* search path.
|
||||||
|
*
|
||||||
|
* If you specify a non-NULL `path`, an application should retrieve all of the
|
||||||
|
* Vulkan functions it uses from the dynamic library using
|
||||||
|
* SDL_Vulkan_GetVkGetInstanceProcAddr unless you can guarantee `path` points
|
||||||
|
* to the same vulkan loader library the application linked to.
|
||||||
|
*
|
||||||
|
* On Apple devices, if `path` is NULL, SDL will attempt to find the
|
||||||
|
* `vkGetInstanceProcAddr` address within all the Mach-O images of the current
|
||||||
|
* process. This is because it is fairly common for Vulkan applications to
|
||||||
|
* link with libvulkan (and historically MoltenVK was provided as a static
|
||||||
|
* library). If it is not found, on macOS, SDL will attempt to load
|
||||||
|
* `vulkan.framework/vulkan`, `libvulkan.1.dylib`,
|
||||||
|
* `MoltenVK.framework/MoltenVK`, and `libMoltenVK.dylib`, in that order. On
|
||||||
|
* iOS, SDL will attempt to load `libMoltenVK.dylib`. Applications using a
|
||||||
|
* dynamic framework or .dylib must ensure it is included in its application
|
||||||
|
* bundle.
|
||||||
|
*
|
||||||
|
* On non-Apple devices, application linking with a static libvulkan is not
|
||||||
|
* supported. Either do not link to the Vulkan loader or link to a dynamic
|
||||||
|
* library version.
|
||||||
|
*
|
||||||
|
* \param path the platform dependent Vulkan loader library name or NULL.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Vulkan_GetVkGetInstanceProcAddr
|
||||||
|
* \sa SDL_Vulkan_UnloadLibrary
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_Vulkan_LoadLibrary")] public static extern bool Vulkan_LoadLibrary(c_char* path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the address of the `vkGetInstanceProcAddr` function.
|
||||||
|
*
|
||||||
|
* This should be called after either calling SDL_Vulkan_LoadLibrary() or
|
||||||
|
* creating an SDL_Window with the `SDL_WINDOW_VULKAN` flag.
|
||||||
|
*
|
||||||
|
* The actual type of the returned function pointer is
|
||||||
|
* PFN_vkGetInstanceProcAddr, but that isn't available because the Vulkan
|
||||||
|
* headers are not included here. You should cast the return value of this
|
||||||
|
* function to that type, e.g.
|
||||||
|
*
|
||||||
|
* `vkGetInstanceProcAddr =
|
||||||
|
* (PFN_vkGetInstanceProcAddr)SDL_Vulkan_GetVkGetInstanceProcAddr();`
|
||||||
|
*
|
||||||
|
* \returns the function pointer for `vkGetInstanceProcAddr` or NULL on
|
||||||
|
* failure; call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_Vulkan_GetVkGetInstanceProcAddr")] public static extern FunctionPointer Vulkan_GetVkGetInstanceProcAddr();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unload the Vulkan library previously loaded by SDL_Vulkan_LoadLibrary().
|
||||||
|
*
|
||||||
|
* SDL keeps a counter of how many times this function has been called, so it
|
||||||
|
* is safe to call this function multiple times, so long as it is paired with
|
||||||
|
* an equivalent number of calls to SDL_Vulkan_LoadLibrary. The library isn't
|
||||||
|
* actually unloaded until there have been an equivalent number of calls to
|
||||||
|
* SDL_Vulkan_UnloadLibrary.
|
||||||
|
*
|
||||||
|
* Once the library has actually been unloaded, if any Vulkan instances
|
||||||
|
* remain, they will likely crash the program. Clean up any existing Vulkan
|
||||||
|
* resources, and destroy appropriate windows, renderers and GPU devices
|
||||||
|
* before calling this function.
|
||||||
|
*
|
||||||
|
* \threadsafety This function is not thread safe.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Vulkan_LoadLibrary
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_Vulkan_UnloadLibrary")] public static extern void Vulkan_UnloadLibrary();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Vulkan instance extensions needed for vkCreateInstance.
|
||||||
|
*
|
||||||
|
* This should be called after either calling SDL_Vulkan_LoadLibrary() or
|
||||||
|
* creating an SDL_Window with the `SDL_WINDOW_VULKAN` flag.
|
||||||
|
*
|
||||||
|
* On return, the variable pointed to by `count` will be set to the number of
|
||||||
|
* elements returned, suitable for using with
|
||||||
|
* VkInstanceCreateInfo::enabledExtensionCount, and the returned array can be
|
||||||
|
* used with VkInstanceCreateInfo::ppEnabledExtensionNames, for calling
|
||||||
|
* Vulkan's vkCreateInstance API.
|
||||||
|
*
|
||||||
|
* You should not free the returned array; it is owned by SDL.
|
||||||
|
*
|
||||||
|
* \param count a pointer filled in with the number of extensions returned.
|
||||||
|
* \returns an array of extension name strings on success, NULL on failure;
|
||||||
|
* call SDL_GetError() for more information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Vulkan_CreateSurface
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_Vulkan_GetInstanceExtensions")] public static extern c_char** Vulkan_GetInstanceExtensions(out Uint32 count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Vulkan rendering surface for a window.
|
||||||
|
*
|
||||||
|
* The `window` must have been created with the `SDL_WINDOW_VULKAN` flag and
|
||||||
|
* `instance` must have been created with extensions returned by
|
||||||
|
* SDL_Vulkan_GetInstanceExtensions() enabled.
|
||||||
|
*
|
||||||
|
* If `allocator` is NULL, Vulkan will use the system default allocator. This
|
||||||
|
* argument is passed directly to Vulkan and isn't used by SDL itself.
|
||||||
|
*
|
||||||
|
* \param window the window to which to attach the Vulkan surface.
|
||||||
|
* \param instance the Vulkan instance handle.
|
||||||
|
* \param allocator a VkAllocationCallbacks struct, which lets the app set the
|
||||||
|
* allocator that creates the surface. Can be NULL.
|
||||||
|
* \param surface a pointer to a VkSurfaceKHR handle to output the newly
|
||||||
|
* created surface.
|
||||||
|
* \returns true on success or false on failure; call SDL_GetError() for more
|
||||||
|
* information.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Vulkan_GetInstanceExtensions
|
||||||
|
* \sa SDL_Vulkan_DestroySurface
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_Vulkan_CreateSurface")] public static extern bool Vulkan_CreateSurface(Window* window, VkInstance instance, VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy the Vulkan rendering surface of a window.
|
||||||
|
*
|
||||||
|
* This should be called before SDL_DestroyWindow, if SDL_Vulkan_CreateSurface
|
||||||
|
* was called after SDL_CreateWindow.
|
||||||
|
*
|
||||||
|
* The `instance` must have been created with extensions returned by
|
||||||
|
* SDL_Vulkan_GetInstanceExtensions() enabled and `surface` must have been
|
||||||
|
* created successfully by an SDL_Vulkan_CreateSurface() call.
|
||||||
|
*
|
||||||
|
* If `allocator` is NULL, Vulkan will use the system default allocator. This
|
||||||
|
* argument is passed directly to Vulkan and isn't used by SDL itself.
|
||||||
|
*
|
||||||
|
* \param instance the Vulkan instance handle.
|
||||||
|
* \param surface vkSurfaceKHR handle to destroy.
|
||||||
|
* \param allocator a VkAllocationCallbacks struct, which lets the app set the
|
||||||
|
* allocator that destroys the surface. Can be NULL.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Vulkan_GetInstanceExtensions
|
||||||
|
* \sa SDL_Vulkan_CreateSurface
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_Vulkan_DestroySurface")] public static extern void Vulkan_DestroySurface(VkInstance instance, VkSurfaceKHR surface, VkAllocationCallbacks* allocator);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query support for presentation via a given physical device and queue
|
||||||
|
* family.
|
||||||
|
*
|
||||||
|
* The `instance` must have been created with extensions returned by
|
||||||
|
* SDL_Vulkan_GetInstanceExtensions() enabled.
|
||||||
|
*
|
||||||
|
* \param instance the Vulkan instance handle.
|
||||||
|
* \param physicalDevice a valid Vulkan physical device handle.
|
||||||
|
* \param queueFamilyIndex a valid queue family index for the given physical
|
||||||
|
* device.
|
||||||
|
* \returns true if supported, false if unsupported or an error occurred.
|
||||||
|
*
|
||||||
|
* \since This function is available since SDL 3.2.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_Vulkan_GetInstanceExtensions
|
||||||
|
*/
|
||||||
|
[LinkName("SDL_Vulkan_GetPresentationSupport")] public static extern bool Vulkan_GetPresentationSupport(VkInstance instance, VkPhysicalDevice physicalDevice, Uint32 queueFamilyIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @} */ /* Vulkan support functions */
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* SDL_vulkan_h_ */
|
||||||
Reference in New Issue
Block a user