brutal/Brutal.Sdl/Generated/Libraries/Sdl.Gamepad.gen.cs
Rian Drake b578433e37 first
2026-10-15 17:10:50 +13:00

1571 lines
75 KiB
C#

// <auto-generated/>
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
namespace Brutal.SdlApi
{
public static unsafe partial class Sdl
{
public static unsafe partial class Gamepad
{
/// <summary>
/// Add support for gamepads that SDL is unaware of or change the binding of an
/// existing gamepad.
/// </summary>
/// <param name="mapping">the mapping string.</param>
/// <returns>
/// 1 if a new mapping is added, 0 if an existing mapping is updated,
/// -1 on failure; call SDL_GetError() for more information.
/// </returns>
/// <remarks>
/// <para>
/// The mapping string has the format "GUID,name,mapping", where GUID is the
/// string value from SDL_GUIDToString(), name is the human readable string for
/// the device and mappings are gamepad mappings to joystick ones. Under
/// Windows there is a reserved GUID of "xinput" that covers all XInput
/// devices. The mapping format for joystick is:
/// </para>
/// <para>
/// - <c>bX</c>: a joystick button, index X
/// - <c>hX.Y</c>: hat X with value Y
/// - <c>aX</c>: axis X of the joystick
/// </para>
/// <para>
/// Buttons can be used as a gamepad axes and vice versa.
/// </para>
/// <para>
/// If a device with this GUID is already plugged in, SDL will generate an
/// SDL_EVENT_GAMEPAD_ADDED event.
/// </para>
/// <para>
/// This string shows an example of a valid mapping for a gamepad:
/// </para>
/// <para>
/// ```c
/// "341a3608000000000000504944564944,Afterglow PS3
/// Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7"
/// ```
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.AddGamepadMappingsFromFile"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.AddGamepadMappingsFromIO"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadMapping"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadMappingForGuid"/>
public static int AddGamepadMapping(string mapping) => PInvoke.AddGamepadMapping(mapping);
/// <summary>
/// Load a set of gamepad mappings from an SDL_IOStream.
/// </summary>
/// <param name="src">the data stream for the mappings to be added.</param>
/// <param name="closeio">
/// if true, calls SDL_CloseIO() on <c>src</c> before returning, even
/// in the case of an error.
/// </param>
/// <returns>
/// the number of mappings added or -1 on failure; call SDL_GetError()
/// for more information.
/// </returns>
/// <remarks>
/// <para>
/// You can call this function several times, if needed, to load different
/// database files.
/// </para>
/// <para>
/// If a new mapping is loaded for an already known gamepad GUID, the later
/// version will overwrite the one currently loaded.
/// </para>
/// <para>
/// Any new mappings for already plugged in controllers will generate
/// SDL_EVENT_GAMEPAD_ADDED events.
/// </para>
/// <para>
/// Mappings not belonging to the current platform or with no platform field
/// specified will be ignored (i.e. mappings for Linux will be ignored in
/// Windows, etc).
/// </para>
/// <para>
/// This function will load the text database entirely in memory before
/// processing it, so take this into consideration if you are in a memory
/// constrained environment.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.AddGamepadMapping"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.AddGamepadMappingsFromFile"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadMapping"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadMappingForGuid"/>
public static int AddGamepadMappingsFromIO(nint src, bool closeio) =>
PInvoke.AddGamepadMappingsFromIO(src, closeio ? (byte)1 : (byte)0);
/// <summary>
/// Load a set of gamepad mappings from a file.
/// </summary>
/// <param name="file">the mappings file to load.</param>
/// <returns>
/// the number of mappings added or -1 on failure; call SDL_GetError()
/// for more information.
/// </returns>
/// <remarks>
/// <para>
/// You can call this function several times, if needed, to load different
/// database files.
/// </para>
/// <para>
/// If a new mapping is loaded for an already known gamepad GUID, the later
/// version will overwrite the one currently loaded.
/// </para>
/// <para>
/// Any new mappings for already plugged in controllers will generate
/// SDL_EVENT_GAMEPAD_ADDED events.
/// </para>
/// <para>
/// Mappings not belonging to the current platform or with no platform field
/// specified will be ignored (i.e. mappings for Linux will be ignored in
/// Windows, etc).
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.AddGamepadMapping"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.AddGamepadMappingsFromIO"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadMapping"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadMappingForGuid"/>
public static int AddGamepadMappingsFromFile(string file) => PInvoke.AddGamepadMappingsFromFile(file);
/// <summary>
/// Reinitialize the SDL mapping database to its initial state.
/// </summary>
/// <returns>
/// true on success or false on failure; call SDL_GetError() for more
/// information.
/// </returns>
/// <remarks>
/// <para>
/// This will generate gamepad events as needed if device mappings change.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
public static bool ReloadGamepadMappings() => PInvoke.ReloadGamepadMappings() != 0;
/// <summary>
/// Ergonomic wrapper over <c>SDL_GetGamepadMappings</c>.
/// </summary>
/// <exception cref="SdlException">The SDL call failed; the message carries the
/// <c>SDL_GetError</c> text.</exception>
/// <remarks>
/// SDL returns a freshly <c>SDL_malloc</c>'d buffer for this call; the returned array is a managed copy,
/// and the native buffer is freed with <c>SDL_free</c> before this method returns.
/// </remarks>
public static string[] GetGamepadMappings()
{
int count;
var ptr = PInvoke.GetGamepadMappings(&count);
if (ptr is null)
throw SdlException.FromError("SDL_GetGamepadMappings failed");
try
{
var result = new string[count];
for (var i = 0; i < count; i++)
result[i] = Marshal.PtrToStringUTF8((nint)ptr[i])!;
return result;
}
finally
{
PInvoke.Free(ptr);
}
}
/// <summary>
/// Set the current mapping of a joystick or gamepad.
/// </summary>
/// <param name="instance_id">the joystick instance ID.</param>
/// <param name="mapping">
/// the mapping to use for this device, or NULL to clear the
/// mapping.
/// </param>
/// <returns>
/// true on success or false on failure; call SDL_GetError() for more
/// information.
/// </returns>
/// <remarks>
/// <para>
/// Details about mappings are discussed with SDL_AddGamepadMapping().
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.AddGamepadMapping"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadMapping"/>
public static bool SetGamepadMapping(uint instance_id, string mapping) =>
PInvoke.SetGamepadMapping(instance_id, mapping) != 0;
/// <summary>
/// Return whether a gamepad is currently connected.
/// </summary>
/// <returns>true if a gamepad is connected, false otherwise.</returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepads"/>
public static bool HasGamepad() => PInvoke.HasGamepad() != 0;
/// <summary>
/// Ergonomic wrapper over <c>SDL_GetGamepads</c>.
/// </summary>
/// <exception cref="SdlException">The SDL call failed; the message carries the
/// <c>SDL_GetError</c> text.</exception>
/// <remarks>
/// SDL returns a freshly <c>SDL_malloc</c>'d buffer for this call; the returned array is a managed copy,
/// and the native buffer is freed with <c>SDL_free</c> before this method returns.
/// </remarks>
public static uint[] GetGamepads()
{
int count;
var ptr = PInvoke.GetGamepads(&count);
if (ptr is null)
throw SdlException.FromError("SDL_GetGamepads failed");
try
{
return new ReadOnlySpan<uint>(ptr, count).ToArray();
}
finally
{
PInvoke.Free(ptr);
}
}
/// <summary>
/// Check if the given joystick is supported by the gamepad interface.
/// </summary>
/// <param name="instance_id">the joystick instance ID.</param>
/// <returns>
/// true if the given joystick is supported by the gamepad interface,
/// false if it isn't or it's an invalid index.
/// </returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetJoysticks"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.OpenGamepad"/>
public static bool IsGamepad(uint instance_id) => PInvoke.IsGamepad(instance_id) != 0;
/// <summary>
/// Get the implementation dependent name of a gamepad.
/// </summary>
/// <param name="instance_id">the joystick instance ID.</param>
/// <returns>
/// the name of the selected gamepad. If no name can be found, this
/// function returns NULL; call SDL_GetError() for more information.
/// </returns>
/// <remarks>
/// <para>
/// This can be called before any gamepads are opened.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadName"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepads"/>
public static string? GetGamepadNameForID(uint instance_id) => PInvoke.GetGamepadNameForID(instance_id);
/// <summary>
/// Get the implementation dependent path of a gamepad.
/// </summary>
/// <param name="instance_id">the joystick instance ID.</param>
/// <returns>
/// the path of the selected gamepad. If no path can be found, this
/// function returns NULL; call SDL_GetError() for more information.
/// </returns>
/// <remarks>
/// <para>
/// This can be called before any gamepads are opened.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadPath"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepads"/>
public static string? GetGamepadPathForID(uint instance_id) => PInvoke.GetGamepadPathForID(instance_id);
/// <summary>
/// Get the player index of a gamepad.
/// </summary>
/// <param name="instance_id">the joystick instance ID.</param>
/// <returns>the player index of a gamepad, or -1 if it's not available.</returns>
/// <remarks>
/// <para>
/// This can be called before any gamepads are opened.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadPlayerIndex"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepads"/>
public static int GetGamepadPlayerIndexForID(uint instance_id) =>
PInvoke.GetGamepadPlayerIndexForID(instance_id);
/// <summary>
/// Get the implementation-dependent GUID of a gamepad.
/// </summary>
/// <param name="instance_id">the joystick instance ID.</param>
/// <returns>
/// the GUID of the selected gamepad. If called on an invalid index,
/// this function returns a zero GUID.
/// </returns>
/// <remarks>
/// <para>
/// This can be called before any gamepads are opened.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GuidToString"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepads"/>
public static SdlGuid GetGamepadGuidForID(uint instance_id) => PInvoke.GetGamepadGuidForID(instance_id);
/// <summary>
/// Get the USB vendor ID of a gamepad, if available.
/// </summary>
/// <param name="instance_id">the joystick instance ID.</param>
/// <returns>
/// the USB vendor ID of the selected gamepad. If called on an invalid
/// index, this function returns zero.
/// </returns>
/// <remarks>
/// <para>
/// This can be called before any gamepads are opened. If the vendor ID isn't
/// available this function returns 0.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadVendor"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepads"/>
public static ushort GetGamepadVendorForID(uint instance_id) => PInvoke.GetGamepadVendorForID(instance_id);
/// <summary>
/// Get the USB product ID of a gamepad, if available.
/// </summary>
/// <param name="instance_id">the joystick instance ID.</param>
/// <returns>
/// the USB product ID of the selected gamepad. If called on an
/// invalid index, this function returns zero.
/// </returns>
/// <remarks>
/// <para>
/// This can be called before any gamepads are opened. If the product ID isn't
/// available this function returns 0.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadProduct"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepads"/>
public static ushort GetGamepadProductForID(uint instance_id) =>
PInvoke.GetGamepadProductForID(instance_id);
/// <summary>
/// Get the product version of a gamepad, if available.
/// </summary>
/// <param name="instance_id">the joystick instance ID.</param>
/// <returns>
/// the product version of the selected gamepad. If called on an
/// invalid index, this function returns zero.
/// </returns>
/// <remarks>
/// <para>
/// This can be called before any gamepads are opened. If the product version
/// isn't available this function returns 0.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadProductVersion"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepads"/>
public static ushort GetGamepadProductVersionForID(uint instance_id) =>
PInvoke.GetGamepadProductVersionForID(instance_id);
/// <summary>
/// Get the type of a gamepad.
/// </summary>
/// <param name="instance_id">the joystick instance ID.</param>
/// <returns>the gamepad type.</returns>
/// <remarks>
/// <para>
/// This can be called before any gamepads are opened.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadType"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepads"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRealGamepadTypeForID"/>
public static SdlGamepadType GetGamepadTypeForID(uint instance_id) =>
PInvoke.GetGamepadTypeForID(instance_id);
/// <summary>
/// Get the type of a gamepad, ignoring any mapping override.
/// </summary>
/// <param name="instance_id">the joystick instance ID.</param>
/// <returns>the gamepad type.</returns>
/// <remarks>
/// <para>
/// This can be called before any gamepads are opened.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadTypeForID"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepads"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRealGamepadType"/>
public static SdlGamepadType GetRealGamepadTypeForID(uint instance_id) =>
PInvoke.GetRealGamepadTypeForID(instance_id);
/// <summary>
/// Ergonomic wrapper over <c>SDL_OpenGamepad</c>. Throws instead of returning a null handle on failure.
/// </summary>
/// <param name="instance_id">the joystick instance ID.</param>
/// <returns>The created handle (never a null handle).</returns>
/// <exception cref="SdlException">The SDL call failed; the message carries the
/// <c>SDL_GetError</c> text.</exception>
public static SdlGamepad OpenGamepad(uint instance_id)
{
SdlGamepad result = PInvoke.OpenGamepad(instance_id);
if (result.IsNull())
{
throw SdlException.FromError("SDL_OpenGamepad failed");
}
return result;
}
/// <summary>
/// Ergonomic wrapper over <c>SDL_GetGamepadFromID</c>.
/// </summary>
/// <param name="instance_id">the joystick instance ID of the gamepad.</param>
/// <remarks>
/// <b>Borrowed handle:</b> the returned handle is owned by SDL (or by another object) and must not be
/// disposed. Do not call <see cref="System.IDisposable.Dispose"/> on it; doing so would free a resource
/// this call does not own. A null handle is returned on failure.
/// </remarks>
public static SdlGamepad GetGamepadFromID(uint instance_id) => PInvoke.GetGamepadFromID(instance_id);
/// <summary>
/// Ergonomic wrapper over <c>SDL_GetGamepadFromPlayerIndex</c>.
/// </summary>
/// <param name="player_index">the player index, which different from the instance ID.</param>
/// <remarks>
/// <b>Borrowed handle:</b> the returned handle is owned by SDL (or by another object) and must not be
/// disposed. Do not call <see cref="System.IDisposable.Dispose"/> on it; doing so would free a resource
/// this call does not own. A null handle is returned on failure.
/// </remarks>
public static SdlGamepad GetGamepadFromPlayerIndex(int player_index) =>
PInvoke.GetGamepadFromPlayerIndex(player_index);
/// <summary>
/// Get the properties associated with an opened gamepad.
/// </summary>
/// <param name="gamepad">
/// a gamepad identifier previously returned by
/// SDL_OpenGamepad().
/// </param>
/// <returns>
/// a valid property ID on success or 0 on failure; call
/// SDL_GetError() for more information.
/// </returns>
/// <remarks>
/// <para>
/// These properties are shared with the underlying joystick object.
/// </para>
/// <para>
/// The following read-only properties are provided by SDL:
/// </para>
/// <para>
/// - <c>SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN</c>: true if this gamepad has an LED
/// that has adjustable brightness
/// - <c>SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN</c>: true if this gamepad has an LED
/// that has adjustable color
/// - <c>SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN</c>: true if this gamepad has a
/// player LED
/// - <c>SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN</c>: true if this gamepad has
/// left/right rumble
/// - <c>SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN</c>: true if this gamepad has
/// simple trigger rumble
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
public static uint GetGamepadProperties(SdlGamepad gamepad) => PInvoke.GetGamepadProperties(gamepad);
/// <summary>
/// Get the instance ID of an opened gamepad.
/// </summary>
/// <param name="gamepad">
/// a gamepad identifier previously returned by
/// SDL_OpenGamepad().
/// </param>
/// <returns>
/// the instance ID of the specified gamepad on success or 0 on
/// failure; call SDL_GetError() for more information.
/// </returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
public static uint GetGamepadID(SdlGamepad gamepad) => PInvoke.GetGamepadID(gamepad);
/// <summary>
/// Get the implementation-dependent name for an opened gamepad.
/// </summary>
/// <param name="gamepad">
/// a gamepad identifier previously returned by
/// SDL_OpenGamepad().
/// </param>
/// <returns>
/// the implementation dependent name for the gamepad, or NULL if
/// there is no name or the identifier passed is invalid.
/// </returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadNameForID"/>
public static string? GetGamepadName(SdlGamepad gamepad) => PInvoke.GetGamepadName(gamepad);
/// <summary>
/// Get the implementation-dependent path for an opened gamepad.
/// </summary>
/// <param name="gamepad">
/// a gamepad identifier previously returned by
/// SDL_OpenGamepad().
/// </param>
/// <returns>
/// the implementation dependent path for the gamepad, or NULL if
/// there is no path or the identifier passed is invalid.
/// </returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadPathForID"/>
public static string? GetGamepadPath(SdlGamepad gamepad) => PInvoke.GetGamepadPath(gamepad);
/// <summary>
/// Get the type of an opened gamepad.
/// </summary>
/// <param name="gamepad">the gamepad object to query.</param>
/// <returns>
/// the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
/// available.
/// </returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadTypeForID"/>
public static SdlGamepadType GetGamepadType(SdlGamepad gamepad) => PInvoke.GetGamepadType(gamepad);
/// <summary>
/// Get the type of an opened gamepad, ignoring any mapping override.
/// </summary>
/// <param name="gamepad">the gamepad object to query.</param>
/// <returns>
/// the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
/// available.
/// </returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetRealGamepadTypeForID"/>
public static SdlGamepadType GetRealGamepadType(SdlGamepad gamepad) => PInvoke.GetRealGamepadType(gamepad);
/// <summary>
/// Get the player index of an opened gamepad.
/// </summary>
/// <param name="gamepad">the gamepad object to query.</param>
/// <returns>the player index for gamepad, or -1 if it's not available.</returns>
/// <remarks>
/// <para>
/// For XInput gamepads this returns the XInput user index.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetGamepadPlayerIndex"/>
public static int GetGamepadPlayerIndex(SdlGamepad gamepad) => PInvoke.GetGamepadPlayerIndex(gamepad);
/// <summary>
/// Set the player index of an opened gamepad.
/// </summary>
/// <param name="gamepad">the gamepad object to adjust.</param>
/// <param name="player_index">
/// player index to assign to this gamepad, or -1 to clear
/// the player index and turn off player LEDs.
/// </param>
/// <returns>
/// true on success or false on failure; call SDL_GetError() for more
/// information.
/// </returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadPlayerIndex"/>
public static bool SetGamepadPlayerIndex(SdlGamepad gamepad, int player_index) =>
PInvoke.SetGamepadPlayerIndex(gamepad, player_index) != 0;
/// <summary>
/// Get the USB vendor ID of an opened gamepad, if available.
/// </summary>
/// <param name="gamepad">the gamepad object to query.</param>
/// <returns>the USB vendor ID, or zero if unavailable.</returns>
/// <remarks>
/// <para>
/// If the vendor ID isn't available this function returns 0.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadVendorForID"/>
public static ushort GetGamepadVendor(SdlGamepad gamepad) => PInvoke.GetGamepadVendor(gamepad);
/// <summary>
/// Get the USB product ID of an opened gamepad, if available.
/// </summary>
/// <param name="gamepad">the gamepad object to query.</param>
/// <returns>the USB product ID, or zero if unavailable.</returns>
/// <remarks>
/// <para>
/// If the product ID isn't available this function returns 0.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadProductForID"/>
public static ushort GetGamepadProduct(SdlGamepad gamepad) => PInvoke.GetGamepadProduct(gamepad);
/// <summary>
/// Get the product version of an opened gamepad, if available.
/// </summary>
/// <param name="gamepad">the gamepad object to query.</param>
/// <returns>the USB product version, or zero if unavailable.</returns>
/// <remarks>
/// <para>
/// If the product version isn't available this function returns 0.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadProductVersionForID"/>
public static ushort GetGamepadProductVersion(SdlGamepad gamepad) =>
PInvoke.GetGamepadProductVersion(gamepad);
/// <summary>
/// Get the firmware version of an opened gamepad, if available.
/// </summary>
/// <param name="gamepad">the gamepad object to query.</param>
/// <returns>the gamepad firmware version, or zero if unavailable.</returns>
/// <remarks>
/// <para>
/// If the firmware version isn't available this function returns 0.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
public static ushort GetGamepadFirmwareVersion(SdlGamepad gamepad) =>
PInvoke.GetGamepadFirmwareVersion(gamepad);
/// <summary>
/// Get the serial number of an opened gamepad, if available.
/// </summary>
/// <param name="gamepad">the gamepad object to query.</param>
/// <returns>the serial number, or NULL if unavailable.</returns>
/// <remarks>
/// <para>
/// Returns the serial number of the gamepad, or NULL if it is not available.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
public static string? GetGamepadSerial(SdlGamepad gamepad) => PInvoke.GetGamepadSerial(gamepad);
/// <summary>
/// Get the Steam Input handle of an opened gamepad, if available.
/// </summary>
/// <param name="gamepad">the gamepad object to query.</param>
/// <returns>the gamepad handle, or 0 if unavailable.</returns>
/// <remarks>
/// <para>
/// Returns an InputHandle_t for the gamepad that can be used with Steam Input
/// API: https://partner.steamgames.com/doc/api/ISteamInput
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
public static ulong GetGamepadSteamHandle(SdlGamepad gamepad) => PInvoke.GetGamepadSteamHandle(gamepad);
/// <summary>
/// Get the connection state of a gamepad.
/// </summary>
/// <param name="gamepad">the gamepad object to query.</param>
/// <returns>
/// the connection state on success or
/// <c>SDL_JOYSTICK_CONNECTION_INVALID</c> on failure; call SDL_GetError()
/// for more information.
/// </returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
public static SdlJoystickConnectionState GetGamepadConnectionState(SdlGamepad gamepad) =>
PInvoke.GetGamepadConnectionState(gamepad);
/// <summary>
/// Get the battery state of a gamepad.
/// </summary>
/// <param name="gamepad">the gamepad object to query.</param>
/// <param name="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 we can't determine a value or there is no
/// battery.
/// </param>
/// <returns>the current battery state.</returns>
/// <remarks>
/// <para>
/// 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.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
public static SdlPowerState GetGamepadPowerInfo(SdlGamepad gamepad, out int percent)
{
percent = default;
fixed (int* percentPtr = &percent)
{
return PInvoke.GetGamepadPowerInfo(gamepad, percentPtr);
}
}
/// <summary>
/// Check if a gamepad has been opened and is currently connected.
/// </summary>
/// <param name="gamepad">
/// a gamepad identifier previously returned by
/// SDL_OpenGamepad().
/// </param>
/// <returns>
/// true if the gamepad has been opened and is currently connected, or
/// false if not.
/// </returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
public static bool GamepadConnected(SdlGamepad gamepad) => PInvoke.GamepadConnected(gamepad) != 0;
/// <summary>
/// Ergonomic wrapper over <c>SDL_GetGamepadJoystick</c>.
/// </summary>
/// <param name="gamepad">the gamepad object that you want to get a joystick from.</param>
/// <remarks>
/// <b>Borrowed handle:</b> the returned handle is owned by SDL (or by another object) and must not be
/// disposed. Do not call <see cref="System.IDisposable.Dispose"/> on it; doing so would free a resource
/// this call does not own. A null handle is returned on failure.
/// </remarks>
public static SdlJoystick GetGamepadJoystick(SdlGamepad gamepad) => PInvoke.GetGamepadJoystick(gamepad);
/// <summary>
/// Set the state of gamepad event processing.
/// </summary>
/// <param name="enabled">whether to process gamepad events or not.</param>
/// <remarks>
/// <para>
/// If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
/// and check the state of the gamepad when you want gamepad information.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GamepadEventsEnabled"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.UpdateGamepads"/>
public static void SetGamepadEventsEnabled(bool enabled) =>
PInvoke.SetGamepadEventsEnabled(enabled ? (byte)1 : (byte)0);
/// <summary>
/// Query the state of gamepad event processing.
/// </summary>
/// <returns>true if gamepad events are being processed, false otherwise.</returns>
/// <remarks>
/// <para>
/// If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
/// and check the state of the gamepad when you want gamepad information.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetGamepadEventsEnabled"/>
public static bool GamepadEventsEnabled() => PInvoke.GamepadEventsEnabled() != 0;
/// <summary>
/// Ergonomic wrapper over <c>SDL_GetGamepadBindings</c>.
/// </summary>
/// <param name="gamepad">a gamepad.</param>
/// <exception cref="SdlException">The SDL call failed; the message carries the
/// <c>SDL_GetError</c> text.</exception>
/// <remarks>
/// SDL returns a freshly <c>SDL_malloc</c>'d buffer for this call; the returned array is a managed copy,
/// and the native buffer is freed with <c>SDL_free</c> before this method returns.
/// </remarks>
public static SdlGamepadBinding[] GetGamepadBindings(SdlGamepad gamepad)
{
int count;
var ptr = PInvoke.GetGamepadBindings(gamepad, &count);
if (ptr is null)
throw SdlException.FromError("SDL_GetGamepadBindings failed");
try
{
var result = new SdlGamepadBinding[count];
for (var i = 0; i < count; i++)
result[i] = *(SdlGamepadBinding*)ptr[i];
return result;
}
finally
{
PInvoke.Free(ptr);
}
}
/// <summary>
/// Manually pump gamepad updates if not using the loop.
/// </summary>
/// <remarks>
/// <para>
/// This function is called automatically by the event loop if events are
/// enabled. Under such circumstances, it will not be necessary to call this
/// function.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
public static void UpdateGamepads() => PInvoke.UpdateGamepads();
/// <summary>
/// Convert a string into SDL_GamepadType enum.
/// </summary>
/// <param name="str">string representing a SDL_GamepadType type.</param>
/// <returns>
/// the SDL_GamepadType enum corresponding to the input string, or
/// <c>SDL_GAMEPAD_TYPE_UNKNOWN</c> if no match was found.
/// </returns>
/// <remarks>
/// <para>
/// This function is called internally to translate SDL_Gamepad mapping strings
/// for the underlying joystick device into the consistent SDL_Gamepad mapping.
/// You do not normally need to call this function unless you are parsing
/// SDL_Gamepad mappings in your own code.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadStringForType"/>
public static SdlGamepadType GetGamepadTypeFromString(string str) => PInvoke.GetGamepadTypeFromString(str);
/// <summary>
/// Convert from an SDL_GamepadType enum to a string.
/// </summary>
/// <param name="type">an enum value for a given SDL_GamepadType.</param>
/// <returns>
/// a string for the given type, or NULL if an invalid type is
/// specified. The string returned is of the format used by
/// SDL_Gamepad mapping strings.
/// </returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadTypeFromString"/>
public static string? GetGamepadStringForType(SdlGamepadType type) => PInvoke.GetGamepadStringForType(type);
/// <summary>
/// Convert a string into SDL_GamepadAxis enum.
/// </summary>
/// <param name="str">string representing a SDL_Gamepad axis.</param>
/// <returns>
/// the SDL_GamepadAxis enum corresponding to the input string, or
/// <c>SDL_GAMEPAD_AXIS_INVALID</c> if no match was found.
/// </returns>
/// <remarks>
/// <para>
/// This function is called internally to translate SDL_Gamepad mapping strings
/// for the underlying joystick device into the consistent SDL_Gamepad mapping.
/// You do not normally need to call this function unless you are parsing
/// SDL_Gamepad mappings in your own code.
/// </para>
/// <para>
/// Note specially that "righttrigger" and "lefttrigger" map to
/// <c>SDL_GAMEPAD_AXIS_RIGHT_TRIGGER</c> and <c>SDL_GAMEPAD_AXIS_LEFT_TRIGGER</c>,
/// respectively.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadStringForAxis"/>
public static SdlGamepadAxis GetGamepadAxisFromString(string str) => PInvoke.GetGamepadAxisFromString(str);
/// <summary>
/// Convert from an SDL_GamepadAxis enum to a string.
/// </summary>
/// <param name="axis">an enum value for a given SDL_GamepadAxis.</param>
/// <returns>
/// a string for the given axis, or NULL if an invalid axis is
/// specified. The string returned is of the format used by
/// SDL_Gamepad mapping strings.
/// </returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadAxisFromString"/>
public static string? GetGamepadStringForAxis(SdlGamepadAxis axis) => PInvoke.GetGamepadStringForAxis(axis);
/// <summary>
/// Query whether a gamepad has a given axis.
/// </summary>
/// <param name="gamepad">a gamepad.</param>
/// <param name="axis">an axis enum value (an SDL_GamepadAxis value).</param>
/// <returns>true if the gamepad has this axis, false otherwise.</returns>
/// <remarks>
/// <para>
/// This merely reports whether the gamepad's mapping defined this axis, as
/// that is all the information SDL has about the physical device.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GamepadHasButton"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadAxis"/>
public static bool GamepadHasAxis(SdlGamepad gamepad, SdlGamepadAxis axis) =>
PInvoke.GamepadHasAxis(gamepad, axis) != 0;
/// <summary>
/// Get the current state of an axis control on a gamepad.
/// </summary>
/// <param name="gamepad">a gamepad.</param>
/// <param name="axis">an axis index (one of the SDL_GamepadAxis values).</param>
/// <returns>axis state.</returns>
/// <remarks>
/// <para>
/// The axis indices start at index 0.
/// </para>
/// <para>
/// For thumbsticks, the state is a value ranging from -32768 (up/left) to
/// 32767 (down/right).
/// </para>
/// <para>
/// Triggers range from 0 when released to 32767 when fully pressed, and never
/// return a negative value. Note that this differs from the value reported by
/// the lower-level SDL_GetJoystickAxis(), which normally uses the full range.
/// </para>
/// <para>
/// Note that for invalid gamepads or axes, this will return 0. Zero is also a
/// valid value in normal operation; usually it means a centered axis.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GamepadHasAxis"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadButton"/>
public static short GetGamepadAxis(SdlGamepad gamepad, SdlGamepadAxis axis) =>
PInvoke.GetGamepadAxis(gamepad, axis);
/// <summary>
/// Convert a string into an SDL_GamepadButton enum.
/// </summary>
/// <param name="str">string representing a SDL_Gamepad button.</param>
/// <returns>
/// the SDL_GamepadButton enum corresponding to the input string, or
/// <c>SDL_GAMEPAD_BUTTON_INVALID</c> if no match was found.
/// </returns>
/// <remarks>
/// <para>
/// This function is called internally to translate SDL_Gamepad mapping strings
/// for the underlying joystick device into the consistent SDL_Gamepad mapping.
/// You do not normally need to call this function unless you are parsing
/// SDL_Gamepad mappings in your own code.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadStringForButton"/>
public static SdlGamepadButton GetGamepadButtonFromString(string str) =>
PInvoke.GetGamepadButtonFromString(str);
/// <summary>
/// Convert from an SDL_GamepadButton enum to a string.
/// </summary>
/// <param name="button">an enum value for a given SDL_GamepadButton.</param>
/// <returns>
/// a string for the given button, or NULL if an invalid button is
/// specified. The string returned is of the format used by
/// SDL_Gamepad mapping strings.
/// </returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadButtonFromString"/>
public static string? GetGamepadStringForButton(SdlGamepadButton button) =>
PInvoke.GetGamepadStringForButton(button);
/// <summary>
/// Query whether a gamepad has a given button.
/// </summary>
/// <param name="gamepad">a gamepad.</param>
/// <param name="button">a button enum value (an SDL_GamepadButton value).</param>
/// <returns>true if the gamepad has this button, false otherwise.</returns>
/// <remarks>
/// <para>
/// This merely reports whether the gamepad's mapping defined this button, as
/// that is all the information SDL has about the physical device.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GamepadHasAxis"/>
public static bool GamepadHasButton(SdlGamepad gamepad, SdlGamepadButton button) =>
PInvoke.GamepadHasButton(gamepad, button) != 0;
/// <summary>
/// Get the current state of a button on a gamepad.
/// </summary>
/// <param name="gamepad">a gamepad.</param>
/// <param name="button">a button index (one of the SDL_GamepadButton values).</param>
/// <returns>true if the button is pressed, false otherwise.</returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GamepadHasButton"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadAxis"/>
public static bool GetGamepadButton(SdlGamepad gamepad, SdlGamepadButton button) =>
PInvoke.GetGamepadButton(gamepad, button) != 0;
/// <summary>
/// Get the label of a button on a gamepad.
/// </summary>
/// <param name="type">the type of gamepad to check.</param>
/// <param name="button">a button index (one of the SDL_GamepadButton values).</param>
/// <returns>the SDL_GamepadButtonLabel enum corresponding to the button label.</returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadButtonLabel"/>
public static SdlGamepadButtonLabel GetGamepadButtonLabelForType(
SdlGamepadType type,
SdlGamepadButton button
) => PInvoke.GetGamepadButtonLabelForType(type, button);
/// <summary>
/// Get the label of a button on a gamepad.
/// </summary>
/// <param name="gamepad">a gamepad.</param>
/// <param name="button">a button index (one of the SDL_GamepadButton values).</param>
/// <returns>the SDL_GamepadButtonLabel enum corresponding to the button label.</returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadButtonLabelForType"/>
public static SdlGamepadButtonLabel GetGamepadButtonLabel(SdlGamepad gamepad, SdlGamepadButton button) =>
PInvoke.GetGamepadButtonLabel(gamepad, button);
/// <summary>
/// Get the number of touchpads on a gamepad.
/// </summary>
/// <param name="gamepad">a gamepad.</param>
/// <returns>number of touchpads.</returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetNumGamepadTouchpadFingers"/>
public static int GetNumGamepadTouchpads(SdlGamepad gamepad) => PInvoke.GetNumGamepadTouchpads(gamepad);
/// <summary>
/// Get the number of supported simultaneous fingers on a touchpad on a game
/// gamepad.
/// </summary>
/// <param name="gamepad">a gamepad.</param>
/// <param name="touchpad">a touchpad.</param>
/// <returns>number of supported simultaneous fingers.</returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadTouchpadFinger"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetNumGamepadTouchpads"/>
public static int GetNumGamepadTouchpadFingers(SdlGamepad gamepad, int touchpad) =>
PInvoke.GetNumGamepadTouchpadFingers(gamepad, touchpad);
/// <summary>
/// Return whether a gamepad has a particular sensor.
/// </summary>
/// <param name="gamepad">the gamepad to query.</param>
/// <param name="type">the type of sensor to query.</param>
/// <returns>true if the sensor exists, false otherwise.</returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadSensorData"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadSensorDataRate"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetGamepadSensorEnabled"/>
public static bool GamepadHasSensor(SdlGamepad gamepad, SdlSensorType type) =>
PInvoke.GamepadHasSensor(gamepad, type) != 0;
/// <summary>
/// Set whether data reporting for a gamepad sensor is enabled.
/// </summary>
/// <param name="gamepad">the gamepad to update.</param>
/// <param name="type">the type of sensor to enable/disable.</param>
/// <param name="enabled">whether data reporting should be enabled.</param>
/// <returns>
/// true on success or false on failure; call SDL_GetError() for more
/// information.
/// </returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GamepadHasSensor"/>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GamepadSensorEnabled"/>
public static bool SetGamepadSensorEnabled(SdlGamepad gamepad, SdlSensorType type, bool enabled) =>
PInvoke.SetGamepadSensorEnabled(gamepad, type, enabled ? (byte)1 : (byte)0) != 0;
/// <summary>
/// Query whether sensor data reporting is enabled for a gamepad.
/// </summary>
/// <param name="gamepad">the gamepad to query.</param>
/// <param name="type">the type of sensor to query.</param>
/// <returns>true if the sensor is enabled, false otherwise.</returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.SetGamepadSensorEnabled"/>
public static bool GamepadSensorEnabled(SdlGamepad gamepad, SdlSensorType type) =>
PInvoke.GamepadSensorEnabled(gamepad, type) != 0;
/// <summary>
/// Get the data rate (number of events per second) of a gamepad sensor.
/// </summary>
/// <param name="gamepad">the gamepad to query.</param>
/// <param name="type">the type of sensor to query.</param>
/// <returns>the data rate, or 0.0f if the data rate is not available.</returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
public static float GetGamepadSensorDataRate(SdlGamepad gamepad, SdlSensorType type) =>
PInvoke.GetGamepadSensorDataRate(gamepad, type);
/// <summary>
/// Get the current state of a gamepad sensor.
/// </summary>
/// <param name="gamepad">the gamepad to query.</param>
/// <param name="type">the type of sensor to query.</param>
/// <param name="data">a pointer filled with the current sensor state.</param>
/// <param name="num_values">the number of values to write to data.</param>
/// <returns>
/// true on success or false on failure; call SDL_GetError() for more
/// information.
/// </returns>
/// <remarks>
/// <para>
/// The number of values and interpretation of the data is sensor dependent.
/// See the remarks in SDL_SensorType for details for each type of sensor.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
public static bool GetGamepadSensorData(
SdlGamepad gamepad,
SdlSensorType type,
float* data,
int num_values
) => PInvoke.GetGamepadSensorData(gamepad, type, data, num_values) != 0;
/// <summary>
/// Start a rumble effect on a gamepad.
/// </summary>
/// <param name="gamepad">the gamepad to vibrate.</param>
/// <param name="low_frequency_rumble">
/// the intensity of the low frequency (left)
/// rumble motor, from 0 to 0xFFFF.
/// </param>
/// <param name="high_frequency_rumble">
/// the intensity of the high frequency (right)
/// rumble motor, from 0 to 0xFFFF.
/// </param>
/// <param name="duration_ms">the duration of the rumble effect, in milliseconds.</param>
/// <returns>
/// true on success or false on failure; call SDL_GetError() for more
/// information.
/// </returns>
/// <remarks>
/// <para>
/// Each call to this function cancels any previous rumble effect, and calling
/// it with 0 intensity stops any rumbling.
/// </para>
/// <para>
/// This function requires you to process SDL events or call
/// SDL_UpdateJoysticks() to update rumble state.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
public static bool RumbleGamepad(
SdlGamepad gamepad,
ushort low_frequency_rumble,
ushort high_frequency_rumble,
uint duration_ms
) => PInvoke.RumbleGamepad(gamepad, low_frequency_rumble, high_frequency_rumble, duration_ms) != 0;
/// <summary>
/// Start a rumble effect in the gamepad's triggers.
/// </summary>
/// <param name="gamepad">the gamepad to vibrate.</param>
/// <param name="left_rumble">
/// the intensity of the left trigger rumble motor, from 0
/// to 0xFFFF.
/// </param>
/// <param name="right_rumble">
/// the intensity of the right trigger rumble motor, from 0
/// to 0xFFFF.
/// </param>
/// <param name="duration_ms">the duration of the rumble effect, in milliseconds.</param>
/// <returns>
/// true on success or false on failure; call SDL_GetError() for more
/// information.
/// </returns>
/// <remarks>
/// <para>
/// Each call to this function cancels any previous trigger rumble effect, and
/// calling it with 0 intensity stops any rumbling.
/// </para>
/// <para>
/// Note that this is rumbling of the <em>triggers</em> and not the gamepad as a
/// whole. This is currently only supported on Xbox One gamepads. If you want
/// the (more common) whole-gamepad rumble, use SDL_RumbleGamepad() instead.
/// </para>
/// <para>
/// This function requires you to process SDL events or call
/// SDL_UpdateJoysticks() to update rumble state.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.RumbleGamepad"/>
public static bool RumbleGamepadTriggers(
SdlGamepad gamepad,
ushort left_rumble,
ushort right_rumble,
uint duration_ms
) => PInvoke.RumbleGamepadTriggers(gamepad, left_rumble, right_rumble, duration_ms) != 0;
/// <summary>
/// Update a gamepad's LED color.
/// </summary>
/// <param name="gamepad">the gamepad to update.</param>
/// <param name="red">the intensity of the red LED.</param>
/// <param name="green">the intensity of the green LED.</param>
/// <param name="blue">the intensity of the blue LED.</param>
/// <returns>
/// true on success or false on failure; call SDL_GetError() for more
/// information.
/// </returns>
/// <remarks>
/// <para>
/// An example of a joystick LED is the light on the back of a PlayStation 4's
/// DualShock 4 controller.
/// </para>
/// <para>
/// For gamepads with a single color LED, the maximum of the RGB values will be
/// used as the LED brightness.
/// </para>
/// </remarks>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
public static bool SetGamepadLED(SdlGamepad gamepad, byte red, byte green, byte blue) =>
PInvoke.SetGamepadLED(gamepad, red, green, blue) != 0;
/// <summary>
/// Send a gamepad specific effect packet.
/// </summary>
/// <param name="gamepad">the gamepad to affect.</param>
/// <param name="data">the data to send to the gamepad.</param>
/// <param name="size">the size of the data to send to the gamepad.</param>
/// <returns>
/// true on success or false on failure; call SDL_GetError() for more
/// information.
/// </returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
public static bool SendGamepadEffect(SdlGamepad gamepad, void* data, int size) =>
PInvoke.SendGamepadEffect(gamepad, data, size) != 0;
/// <summary>
/// Close a gamepad previously opened with SDL_OpenGamepad().
/// </summary>
/// <param name="gamepad">
/// a gamepad identifier previously returned by
/// SDL_OpenGamepad().
/// </param>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.OpenGamepad"/>
public static void CloseGamepad(SdlGamepad gamepad) => PInvoke.CloseGamepad(gamepad);
/// <summary>
/// Return the sfSymbolsName for a given button on a gamepad on Apple
/// platforms.
/// </summary>
/// <param name="gamepad">the gamepad to query.</param>
/// <param name="button">a button on the gamepad.</param>
/// <returns>the sfSymbolsName or NULL if the name can't be found.</returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadAppleSFSymbolsNameForAxis"/>
public static string? GetGamepadAppleSFSymbolsNameForButton(SdlGamepad gamepad, SdlGamepadButton button) =>
PInvoke.GetGamepadAppleSFSymbolsNameForButton(gamepad, button);
/// <summary>
/// Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
/// </summary>
/// <param name="gamepad">the gamepad to query.</param>
/// <param name="axis">an axis on the gamepad.</param>
/// <returns>the sfSymbolsName or NULL if the name can't be found.</returns>
/// <threadsafety>
/// It is safe to call this function from any thread.
/// </threadsafety>
/// <since>
/// This function is available since SDL 3.2.0.
/// </since>
/// <seealso cref="Brutal.SdlApi.Sdl.PInvoke.GetGamepadAppleSFSymbolsNameForButton"/>
public static string? GetGamepadAppleSFSymbolsNameForAxis(SdlGamepad gamepad, SdlGamepadAxis axis) =>
PInvoke.GetGamepadAppleSFSymbolsNameForAxis(gamepad, axis);
}
}
}