//
// 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
{
///
/// Add support for gamepads that SDL is unaware of or change the binding of an
/// existing gamepad.
///
/// the mapping string.
///
/// 1 if a new mapping is added, 0 if an existing mapping is updated,
/// -1 on failure; call SDL_GetError() for more information.
///
///
///
/// 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:
///
///
/// - bX: a joystick button, index X
/// - hX.Y: hat X with value Y
/// - aX: axis X of the joystick
///
///
/// Buttons can be used as a gamepad axes and vice versa.
///
///
/// If a device with this GUID is already plugged in, SDL will generate an
/// SDL_EVENT_GAMEPAD_ADDED event.
///
///
/// This string shows an example of a valid mapping for a gamepad:
///
///
/// ```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"
/// ```
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
///
public static int AddGamepadMapping(string mapping) => PInvoke.AddGamepadMapping(mapping);
///
/// Load a set of gamepad mappings from an SDL_IOStream.
///
/// the data stream for the mappings to be added.
///
/// if true, calls SDL_CloseIO() on src before returning, even
/// in the case of an error.
///
///
/// the number of mappings added or -1 on failure; call SDL_GetError()
/// for more information.
///
///
///
/// You can call this function several times, if needed, to load different
/// database files.
///
///
/// If a new mapping is loaded for an already known gamepad GUID, the later
/// version will overwrite the one currently loaded.
///
///
/// Any new mappings for already plugged in controllers will generate
/// SDL_EVENT_GAMEPAD_ADDED events.
///
///
/// 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).
///
///
/// 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.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
///
public static int AddGamepadMappingsFromIO(nint src, bool closeio) =>
PInvoke.AddGamepadMappingsFromIO(src, closeio ? (byte)1 : (byte)0);
///
/// Load a set of gamepad mappings from a file.
///
/// the mappings file to load.
///
/// the number of mappings added or -1 on failure; call SDL_GetError()
/// for more information.
///
///
///
/// You can call this function several times, if needed, to load different
/// database files.
///
///
/// If a new mapping is loaded for an already known gamepad GUID, the later
/// version will overwrite the one currently loaded.
///
///
/// Any new mappings for already plugged in controllers will generate
/// SDL_EVENT_GAMEPAD_ADDED events.
///
///
/// 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).
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
///
public static int AddGamepadMappingsFromFile(string file) => PInvoke.AddGamepadMappingsFromFile(file);
///
/// Reinitialize the SDL mapping database to its initial state.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// This will generate gamepad events as needed if device mappings change.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static bool ReloadGamepadMappings() => PInvoke.ReloadGamepadMappings() != 0;
///
/// Ergonomic wrapper over SDL_GetGamepadMappings.
///
/// The SDL call failed; the message carries the
/// SDL_GetError text.
///
/// SDL returns a freshly SDL_malloc'd buffer for this call; the returned array is a managed copy,
/// and the native buffer is freed with SDL_free before this method returns.
///
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);
}
}
///
/// Set the current mapping of a joystick or gamepad.
///
/// the joystick instance ID.
///
/// the mapping to use for this device, or NULL to clear the
/// mapping.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Details about mappings are discussed with SDL_AddGamepadMapping().
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool SetGamepadMapping(uint instance_id, string mapping) =>
PInvoke.SetGamepadMapping(instance_id, mapping) != 0;
///
/// Return whether a gamepad is currently connected.
///
/// true if a gamepad is connected, false otherwise.
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool HasGamepad() => PInvoke.HasGamepad() != 0;
///
/// Ergonomic wrapper over SDL_GetGamepads.
///
/// The SDL call failed; the message carries the
/// SDL_GetError text.
///
/// SDL returns a freshly SDL_malloc'd buffer for this call; the returned array is a managed copy,
/// and the native buffer is freed with SDL_free before this method returns.
///
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(ptr, count).ToArray();
}
finally
{
PInvoke.Free(ptr);
}
}
///
/// Check if the given joystick is supported by the gamepad interface.
///
/// the joystick instance ID.
///
/// true if the given joystick is supported by the gamepad interface,
/// false if it isn't or it's an invalid index.
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool IsGamepad(uint instance_id) => PInvoke.IsGamepad(instance_id) != 0;
///
/// Get the implementation dependent name of a gamepad.
///
/// the joystick instance ID.
///
/// the name of the selected gamepad. If no name can be found, this
/// function returns NULL; call SDL_GetError() for more information.
///
///
///
/// This can be called before any gamepads are opened.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static string? GetGamepadNameForID(uint instance_id) => PInvoke.GetGamepadNameForID(instance_id);
///
/// Get the implementation dependent path of a gamepad.
///
/// the joystick instance ID.
///
/// the path of the selected gamepad. If no path can be found, this
/// function returns NULL; call SDL_GetError() for more information.
///
///
///
/// This can be called before any gamepads are opened.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static string? GetGamepadPathForID(uint instance_id) => PInvoke.GetGamepadPathForID(instance_id);
///
/// Get the player index of a gamepad.
///
/// the joystick instance ID.
/// the player index of a gamepad, or -1 if it's not available.
///
///
/// This can be called before any gamepads are opened.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static int GetGamepadPlayerIndexForID(uint instance_id) =>
PInvoke.GetGamepadPlayerIndexForID(instance_id);
///
/// Get the implementation-dependent GUID of a gamepad.
///
/// the joystick instance ID.
///
/// the GUID of the selected gamepad. If called on an invalid index,
/// this function returns a zero GUID.
///
///
///
/// This can be called before any gamepads are opened.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static SdlGuid GetGamepadGuidForID(uint instance_id) => PInvoke.GetGamepadGuidForID(instance_id);
///
/// Get the USB vendor ID of a gamepad, if available.
///
/// the joystick instance ID.
///
/// the USB vendor ID of the selected gamepad. If called on an invalid
/// index, this function returns zero.
///
///
///
/// This can be called before any gamepads are opened. If the vendor ID isn't
/// available this function returns 0.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static ushort GetGamepadVendorForID(uint instance_id) => PInvoke.GetGamepadVendorForID(instance_id);
///
/// Get the USB product ID of a gamepad, if available.
///
/// the joystick instance ID.
///
/// the USB product ID of the selected gamepad. If called on an
/// invalid index, this function returns zero.
///
///
///
/// This can be called before any gamepads are opened. If the product ID isn't
/// available this function returns 0.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static ushort GetGamepadProductForID(uint instance_id) =>
PInvoke.GetGamepadProductForID(instance_id);
///
/// Get the product version of a gamepad, if available.
///
/// the joystick instance ID.
///
/// the product version of the selected gamepad. If called on an
/// invalid index, this function returns zero.
///
///
///
/// This can be called before any gamepads are opened. If the product version
/// isn't available this function returns 0.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static ushort GetGamepadProductVersionForID(uint instance_id) =>
PInvoke.GetGamepadProductVersionForID(instance_id);
///
/// Get the type of a gamepad.
///
/// the joystick instance ID.
/// the gamepad type.
///
///
/// This can be called before any gamepads are opened.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
public static SdlGamepadType GetGamepadTypeForID(uint instance_id) =>
PInvoke.GetGamepadTypeForID(instance_id);
///
/// Get the type of a gamepad, ignoring any mapping override.
///
/// the joystick instance ID.
/// the gamepad type.
///
///
/// This can be called before any gamepads are opened.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
public static SdlGamepadType GetRealGamepadTypeForID(uint instance_id) =>
PInvoke.GetRealGamepadTypeForID(instance_id);
///
/// Ergonomic wrapper over SDL_OpenGamepad. Throws instead of returning a null handle on failure.
///
/// the joystick instance ID.
/// The created handle (never a null handle).
/// The SDL call failed; the message carries the
/// SDL_GetError text.
public static SdlGamepad OpenGamepad(uint instance_id)
{
SdlGamepad result = PInvoke.OpenGamepad(instance_id);
if (result.IsNull())
{
throw SdlException.FromError("SDL_OpenGamepad failed");
}
return result;
}
///
/// Ergonomic wrapper over SDL_GetGamepadFromID.
///
/// the joystick instance ID of the gamepad.
///
/// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be
/// disposed. Do not call on it; doing so would free a resource
/// this call does not own. A null handle is returned on failure.
///
public static SdlGamepad GetGamepadFromID(uint instance_id) => PInvoke.GetGamepadFromID(instance_id);
///
/// Ergonomic wrapper over SDL_GetGamepadFromPlayerIndex.
///
/// the player index, which different from the instance ID.
///
/// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be
/// disposed. Do not call on it; doing so would free a resource
/// this call does not own. A null handle is returned on failure.
///
public static SdlGamepad GetGamepadFromPlayerIndex(int player_index) =>
PInvoke.GetGamepadFromPlayerIndex(player_index);
///
/// Get the properties associated with an opened gamepad.
///
///
/// a gamepad identifier previously returned by
/// SDL_OpenGamepad().
///
///
/// a valid property ID on success or 0 on failure; call
/// SDL_GetError() for more information.
///
///
///
/// These properties are shared with the underlying joystick object.
///
///
/// The following read-only properties are provided by SDL:
///
///
/// - SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN: true if this gamepad has an LED
/// that has adjustable brightness
/// - SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN: true if this gamepad has an LED
/// that has adjustable color
/// - SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN: true if this gamepad has a
/// player LED
/// - SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN: true if this gamepad has
/// left/right rumble
/// - SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN: true if this gamepad has
/// simple trigger rumble
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static uint GetGamepadProperties(SdlGamepad gamepad) => PInvoke.GetGamepadProperties(gamepad);
///
/// Get the instance ID of an opened gamepad.
///
///
/// a gamepad identifier previously returned by
/// SDL_OpenGamepad().
///
///
/// the instance ID of the specified gamepad on success or 0 on
/// failure; call SDL_GetError() for more information.
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static uint GetGamepadID(SdlGamepad gamepad) => PInvoke.GetGamepadID(gamepad);
///
/// Get the implementation-dependent name for an opened gamepad.
///
///
/// a gamepad identifier previously returned by
/// SDL_OpenGamepad().
///
///
/// the implementation dependent name for the gamepad, or NULL if
/// there is no name or the identifier passed is invalid.
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static string? GetGamepadName(SdlGamepad gamepad) => PInvoke.GetGamepadName(gamepad);
///
/// Get the implementation-dependent path for an opened gamepad.
///
///
/// a gamepad identifier previously returned by
/// SDL_OpenGamepad().
///
///
/// the implementation dependent path for the gamepad, or NULL if
/// there is no path or the identifier passed is invalid.
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static string? GetGamepadPath(SdlGamepad gamepad) => PInvoke.GetGamepadPath(gamepad);
///
/// Get the type of an opened gamepad.
///
/// the gamepad object to query.
///
/// the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
/// available.
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static SdlGamepadType GetGamepadType(SdlGamepad gamepad) => PInvoke.GetGamepadType(gamepad);
///
/// Get the type of an opened gamepad, ignoring any mapping override.
///
/// the gamepad object to query.
///
/// the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not
/// available.
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static SdlGamepadType GetRealGamepadType(SdlGamepad gamepad) => PInvoke.GetRealGamepadType(gamepad);
///
/// Get the player index of an opened gamepad.
///
/// the gamepad object to query.
/// the player index for gamepad, or -1 if it's not available.
///
///
/// For XInput gamepads this returns the XInput user index.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static int GetGamepadPlayerIndex(SdlGamepad gamepad) => PInvoke.GetGamepadPlayerIndex(gamepad);
///
/// Set the player index of an opened gamepad.
///
/// the gamepad object to adjust.
///
/// player index to assign to this gamepad, or -1 to clear
/// the player index and turn off player LEDs.
///
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool SetGamepadPlayerIndex(SdlGamepad gamepad, int player_index) =>
PInvoke.SetGamepadPlayerIndex(gamepad, player_index) != 0;
///
/// Get the USB vendor ID of an opened gamepad, if available.
///
/// the gamepad object to query.
/// the USB vendor ID, or zero if unavailable.
///
///
/// If the vendor ID isn't available this function returns 0.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static ushort GetGamepadVendor(SdlGamepad gamepad) => PInvoke.GetGamepadVendor(gamepad);
///
/// Get the USB product ID of an opened gamepad, if available.
///
/// the gamepad object to query.
/// the USB product ID, or zero if unavailable.
///
///
/// If the product ID isn't available this function returns 0.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static ushort GetGamepadProduct(SdlGamepad gamepad) => PInvoke.GetGamepadProduct(gamepad);
///
/// Get the product version of an opened gamepad, if available.
///
/// the gamepad object to query.
/// the USB product version, or zero if unavailable.
///
///
/// If the product version isn't available this function returns 0.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static ushort GetGamepadProductVersion(SdlGamepad gamepad) =>
PInvoke.GetGamepadProductVersion(gamepad);
///
/// Get the firmware version of an opened gamepad, if available.
///
/// the gamepad object to query.
/// the gamepad firmware version, or zero if unavailable.
///
///
/// If the firmware version isn't available this function returns 0.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static ushort GetGamepadFirmwareVersion(SdlGamepad gamepad) =>
PInvoke.GetGamepadFirmwareVersion(gamepad);
///
/// Get the serial number of an opened gamepad, if available.
///
/// the gamepad object to query.
/// the serial number, or NULL if unavailable.
///
///
/// Returns the serial number of the gamepad, or NULL if it is not available.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static string? GetGamepadSerial(SdlGamepad gamepad) => PInvoke.GetGamepadSerial(gamepad);
///
/// Get the Steam Input handle of an opened gamepad, if available.
///
/// the gamepad object to query.
/// the gamepad handle, or 0 if unavailable.
///
///
/// Returns an InputHandle_t for the gamepad that can be used with Steam Input
/// API: https://partner.steamgames.com/doc/api/ISteamInput
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static ulong GetGamepadSteamHandle(SdlGamepad gamepad) => PInvoke.GetGamepadSteamHandle(gamepad);
///
/// Get the connection state of a gamepad.
///
/// the gamepad object to query.
///
/// the connection state on success or
/// SDL_JOYSTICK_CONNECTION_INVALID on failure; call SDL_GetError()
/// for more information.
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static SdlJoystickConnectionState GetGamepadConnectionState(SdlGamepad gamepad) =>
PInvoke.GetGamepadConnectionState(gamepad);
///
/// Get the battery state of a gamepad.
///
/// the gamepad object to query.
///
/// 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.
///
/// the current battery state.
///
///
/// 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.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static SdlPowerState GetGamepadPowerInfo(SdlGamepad gamepad, out int percent)
{
percent = default;
fixed (int* percentPtr = &percent)
{
return PInvoke.GetGamepadPowerInfo(gamepad, percentPtr);
}
}
///
/// Check if a gamepad has been opened and is currently connected.
///
///
/// a gamepad identifier previously returned by
/// SDL_OpenGamepad().
///
///
/// true if the gamepad has been opened and is currently connected, or
/// false if not.
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static bool GamepadConnected(SdlGamepad gamepad) => PInvoke.GamepadConnected(gamepad) != 0;
///
/// Ergonomic wrapper over SDL_GetGamepadJoystick.
///
/// the gamepad object that you want to get a joystick from.
///
/// Borrowed handle: the returned handle is owned by SDL (or by another object) and must not be
/// disposed. Do not call on it; doing so would free a resource
/// this call does not own. A null handle is returned on failure.
///
public static SdlJoystick GetGamepadJoystick(SdlGamepad gamepad) => PInvoke.GetGamepadJoystick(gamepad);
///
/// Set the state of gamepad event processing.
///
/// whether to process gamepad events or not.
///
///
/// If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
/// and check the state of the gamepad when you want gamepad information.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static void SetGamepadEventsEnabled(bool enabled) =>
PInvoke.SetGamepadEventsEnabled(enabled ? (byte)1 : (byte)0);
///
/// Query the state of gamepad event processing.
///
/// true if gamepad events are being processed, false otherwise.
///
///
/// If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself
/// and check the state of the gamepad when you want gamepad information.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool GamepadEventsEnabled() => PInvoke.GamepadEventsEnabled() != 0;
///
/// Ergonomic wrapper over SDL_GetGamepadBindings.
///
/// a gamepad.
/// The SDL call failed; the message carries the
/// SDL_GetError text.
///
/// SDL returns a freshly SDL_malloc'd buffer for this call; the returned array is a managed copy,
/// and the native buffer is freed with SDL_free before this method returns.
///
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);
}
}
///
/// Manually pump gamepad updates if not using the loop.
///
///
///
/// 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.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static void UpdateGamepads() => PInvoke.UpdateGamepads();
///
/// Convert a string into SDL_GamepadType enum.
///
/// string representing a SDL_GamepadType type.
///
/// the SDL_GamepadType enum corresponding to the input string, or
/// SDL_GAMEPAD_TYPE_UNKNOWN if no match was found.
///
///
///
/// 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.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static SdlGamepadType GetGamepadTypeFromString(string str) => PInvoke.GetGamepadTypeFromString(str);
///
/// Convert from an SDL_GamepadType enum to a string.
///
/// an enum value for a given SDL_GamepadType.
///
/// 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.
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static string? GetGamepadStringForType(SdlGamepadType type) => PInvoke.GetGamepadStringForType(type);
///
/// Convert a string into SDL_GamepadAxis enum.
///
/// string representing a SDL_Gamepad axis.
///
/// the SDL_GamepadAxis enum corresponding to the input string, or
/// SDL_GAMEPAD_AXIS_INVALID if no match was found.
///
///
///
/// 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.
///
///
/// Note specially that "righttrigger" and "lefttrigger" map to
/// SDL_GAMEPAD_AXIS_RIGHT_TRIGGER and SDL_GAMEPAD_AXIS_LEFT_TRIGGER,
/// respectively.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static SdlGamepadAxis GetGamepadAxisFromString(string str) => PInvoke.GetGamepadAxisFromString(str);
///
/// Convert from an SDL_GamepadAxis enum to a string.
///
/// an enum value for a given SDL_GamepadAxis.
///
/// 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.
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static string? GetGamepadStringForAxis(SdlGamepadAxis axis) => PInvoke.GetGamepadStringForAxis(axis);
///
/// Query whether a gamepad has a given axis.
///
/// a gamepad.
/// an axis enum value (an SDL_GamepadAxis value).
/// true if the gamepad has this axis, false otherwise.
///
///
/// This merely reports whether the gamepad's mapping defined this axis, as
/// that is all the information SDL has about the physical device.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool GamepadHasAxis(SdlGamepad gamepad, SdlGamepadAxis axis) =>
PInvoke.GamepadHasAxis(gamepad, axis) != 0;
///
/// Get the current state of an axis control on a gamepad.
///
/// a gamepad.
/// an axis index (one of the SDL_GamepadAxis values).
/// axis state.
///
///
/// The axis indices start at index 0.
///
///
/// For thumbsticks, the state is a value ranging from -32768 (up/left) to
/// 32767 (down/right).
///
///
/// 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.
///
///
/// 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.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static short GetGamepadAxis(SdlGamepad gamepad, SdlGamepadAxis axis) =>
PInvoke.GetGamepadAxis(gamepad, axis);
///
/// Convert a string into an SDL_GamepadButton enum.
///
/// string representing a SDL_Gamepad button.
///
/// the SDL_GamepadButton enum corresponding to the input string, or
/// SDL_GAMEPAD_BUTTON_INVALID if no match was found.
///
///
///
/// 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.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static SdlGamepadButton GetGamepadButtonFromString(string str) =>
PInvoke.GetGamepadButtonFromString(str);
///
/// Convert from an SDL_GamepadButton enum to a string.
///
/// an enum value for a given SDL_GamepadButton.
///
/// 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.
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static string? GetGamepadStringForButton(SdlGamepadButton button) =>
PInvoke.GetGamepadStringForButton(button);
///
/// Query whether a gamepad has a given button.
///
/// a gamepad.
/// a button enum value (an SDL_GamepadButton value).
/// true if the gamepad has this button, false otherwise.
///
///
/// This merely reports whether the gamepad's mapping defined this button, as
/// that is all the information SDL has about the physical device.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool GamepadHasButton(SdlGamepad gamepad, SdlGamepadButton button) =>
PInvoke.GamepadHasButton(gamepad, button) != 0;
///
/// Get the current state of a button on a gamepad.
///
/// a gamepad.
/// a button index (one of the SDL_GamepadButton values).
/// true if the button is pressed, false otherwise.
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool GetGamepadButton(SdlGamepad gamepad, SdlGamepadButton button) =>
PInvoke.GetGamepadButton(gamepad, button) != 0;
///
/// Get the label of a button on a gamepad.
///
/// the type of gamepad to check.
/// a button index (one of the SDL_GamepadButton values).
/// the SDL_GamepadButtonLabel enum corresponding to the button label.
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static SdlGamepadButtonLabel GetGamepadButtonLabelForType(
SdlGamepadType type,
SdlGamepadButton button
) => PInvoke.GetGamepadButtonLabelForType(type, button);
///
/// Get the label of a button on a gamepad.
///
/// a gamepad.
/// a button index (one of the SDL_GamepadButton values).
/// the SDL_GamepadButtonLabel enum corresponding to the button label.
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static SdlGamepadButtonLabel GetGamepadButtonLabel(SdlGamepad gamepad, SdlGamepadButton button) =>
PInvoke.GetGamepadButtonLabel(gamepad, button);
///
/// Get the number of touchpads on a gamepad.
///
/// a gamepad.
/// number of touchpads.
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static int GetNumGamepadTouchpads(SdlGamepad gamepad) => PInvoke.GetNumGamepadTouchpads(gamepad);
///
/// Get the number of supported simultaneous fingers on a touchpad on a game
/// gamepad.
///
/// a gamepad.
/// a touchpad.
/// number of supported simultaneous fingers.
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static int GetNumGamepadTouchpadFingers(SdlGamepad gamepad, int touchpad) =>
PInvoke.GetNumGamepadTouchpadFingers(gamepad, touchpad);
///
/// Return whether a gamepad has a particular sensor.
///
/// the gamepad to query.
/// the type of sensor to query.
/// true if the sensor exists, false otherwise.
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
///
public static bool GamepadHasSensor(SdlGamepad gamepad, SdlSensorType type) =>
PInvoke.GamepadHasSensor(gamepad, type) != 0;
///
/// Set whether data reporting for a gamepad sensor is enabled.
///
/// the gamepad to update.
/// the type of sensor to enable/disable.
/// whether data reporting should be enabled.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
///
public static bool SetGamepadSensorEnabled(SdlGamepad gamepad, SdlSensorType type, bool enabled) =>
PInvoke.SetGamepadSensorEnabled(gamepad, type, enabled ? (byte)1 : (byte)0) != 0;
///
/// Query whether sensor data reporting is enabled for a gamepad.
///
/// the gamepad to query.
/// the type of sensor to query.
/// true if the sensor is enabled, false otherwise.
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static bool GamepadSensorEnabled(SdlGamepad gamepad, SdlSensorType type) =>
PInvoke.GamepadSensorEnabled(gamepad, type) != 0;
///
/// Get the data rate (number of events per second) of a gamepad sensor.
///
/// the gamepad to query.
/// the type of sensor to query.
/// the data rate, or 0.0f if the data rate is not available.
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static float GetGamepadSensorDataRate(SdlGamepad gamepad, SdlSensorType type) =>
PInvoke.GetGamepadSensorDataRate(gamepad, type);
///
/// Get the current state of a gamepad sensor.
///
/// the gamepad to query.
/// the type of sensor to query.
/// a pointer filled with the current sensor state.
/// the number of values to write to data.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// 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.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static bool GetGamepadSensorData(
SdlGamepad gamepad,
SdlSensorType type,
float* data,
int num_values
) => PInvoke.GetGamepadSensorData(gamepad, type, data, num_values) != 0;
///
/// Start a rumble effect on a gamepad.
///
/// the gamepad to vibrate.
///
/// the intensity of the low frequency (left)
/// rumble motor, from 0 to 0xFFFF.
///
///
/// the intensity of the high frequency (right)
/// rumble motor, from 0 to 0xFFFF.
///
/// the duration of the rumble effect, in milliseconds.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Each call to this function cancels any previous rumble effect, and calling
/// it with 0 intensity stops any rumbling.
///
///
/// This function requires you to process SDL events or call
/// SDL_UpdateJoysticks() to update rumble state.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
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;
///
/// Start a rumble effect in the gamepad's triggers.
///
/// the gamepad to vibrate.
///
/// the intensity of the left trigger rumble motor, from 0
/// to 0xFFFF.
///
///
/// the intensity of the right trigger rumble motor, from 0
/// to 0xFFFF.
///
/// the duration of the rumble effect, in milliseconds.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// Each call to this function cancels any previous trigger rumble effect, and
/// calling it with 0 intensity stops any rumbling.
///
///
/// Note that this is rumbling of the triggers 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.
///
///
/// This function requires you to process SDL events or call
/// SDL_UpdateJoysticks() to update rumble state.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
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;
///
/// Update a gamepad's LED color.
///
/// the gamepad to update.
/// the intensity of the red LED.
/// the intensity of the green LED.
/// the intensity of the blue LED.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
///
/// An example of a joystick LED is the light on the back of a PlayStation 4's
/// DualShock 4 controller.
///
///
/// For gamepads with a single color LED, the maximum of the RGB values will be
/// used as the LED brightness.
///
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static bool SetGamepadLED(SdlGamepad gamepad, byte red, byte green, byte blue) =>
PInvoke.SetGamepadLED(gamepad, red, green, blue) != 0;
///
/// Send a gamepad specific effect packet.
///
/// the gamepad to affect.
/// the data to send to the gamepad.
/// the size of the data to send to the gamepad.
///
/// true on success or false on failure; call SDL_GetError() for more
/// information.
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
public static bool SendGamepadEffect(SdlGamepad gamepad, void* data, int size) =>
PInvoke.SendGamepadEffect(gamepad, data, size) != 0;
///
/// Close a gamepad previously opened with SDL_OpenGamepad().
///
///
/// a gamepad identifier previously returned by
/// SDL_OpenGamepad().
///
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static void CloseGamepad(SdlGamepad gamepad) => PInvoke.CloseGamepad(gamepad);
///
/// Return the sfSymbolsName for a given button on a gamepad on Apple
/// platforms.
///
/// the gamepad to query.
/// a button on the gamepad.
/// the sfSymbolsName or NULL if the name can't be found.
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static string? GetGamepadAppleSFSymbolsNameForButton(SdlGamepad gamepad, SdlGamepadButton button) =>
PInvoke.GetGamepadAppleSFSymbolsNameForButton(gamepad, button);
///
/// Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
///
/// the gamepad to query.
/// an axis on the gamepad.
/// the sfSymbolsName or NULL if the name can't be found.
///
/// It is safe to call this function from any thread.
///
///
/// This function is available since SDL 3.2.0.
///
///
public static string? GetGamepadAppleSFSymbolsNameForAxis(SdlGamepad gamepad, SdlGamepadAxis axis) =>
PInvoke.GetGamepadAppleSFSymbolsNameForAxis(gamepad, axis);
}
}
}