1#ifndef SDL3PP_GAMEPAD_H_
2#define SDL3PP_GAMEPAD_H_
4#include <SDL3/SDL_gamepad.h>
5#include "SDL3pp_error.h"
6#include "SDL3pp_guid.h"
7#include "SDL3pp_iostream.h"
8#include "SDL3pp_joystick.h"
9#include "SDL3pp_power.h"
10#include "SDL3pp_properties.h"
11#include "SDL3pp_sensor.h"
12#include "SDL3pp_stdinc.h"
95 constexpr explicit operator bool()
const {
return !!
value; }
116 SDL_GAMEPAD_TYPE_UNKNOWN;
119 SDL_GAMEPAD_TYPE_STANDARD;
122 SDL_GAMEPAD_TYPE_XBOX360;
125 SDL_GAMEPAD_TYPE_XBOXONE;
128 SDL_GAMEPAD_TYPE_PS3;
131 SDL_GAMEPAD_TYPE_PS4;
134 SDL_GAMEPAD_TYPE_PS5;
137 SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO;
140 SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT;
143 SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT;
146 SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR;
149 SDL_GAMEPAD_TYPE_COUNT;
176 SDL_GAMEPAD_BUTTON_INVALID;
179 SDL_GAMEPAD_BUTTON_SOUTH;
182 SDL_GAMEPAD_BUTTON_EAST;
185 SDL_GAMEPAD_BUTTON_WEST;
188 SDL_GAMEPAD_BUTTON_NORTH;
191 SDL_GAMEPAD_BUTTON_BACK;
194 SDL_GAMEPAD_BUTTON_GUIDE;
197 SDL_GAMEPAD_BUTTON_START;
200 SDL_GAMEPAD_BUTTON_LEFT_STICK;
203 SDL_GAMEPAD_BUTTON_RIGHT_STICK;
206 SDL_GAMEPAD_BUTTON_LEFT_SHOULDER;
209 SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER;
212 SDL_GAMEPAD_BUTTON_DPAD_UP;
215 SDL_GAMEPAD_BUTTON_DPAD_DOWN;
218 SDL_GAMEPAD_BUTTON_DPAD_LEFT;
221 SDL_GAMEPAD_BUTTON_DPAD_RIGHT;
232 SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1;
236 SDL_GAMEPAD_BUTTON_LEFT_PADDLE1;
242 SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2;
246 SDL_GAMEPAD_BUTTON_LEFT_PADDLE2;
249 SDL_GAMEPAD_BUTTON_TOUCHPAD;
252 SDL_GAMEPAD_BUTTON_MISC2;
255 SDL_GAMEPAD_BUTTON_MISC3;
258 SDL_GAMEPAD_BUTTON_MISC4;
261 SDL_GAMEPAD_BUTTON_MISC5;
264 SDL_GAMEPAD_BUTTON_MISC6;
267 SDL_GAMEPAD_BUTTON_COUNT;
283 SDL_GAMEPAD_BUTTON_LABEL_UNKNOWN;
286 SDL_GAMEPAD_BUTTON_LABEL_A;
289 SDL_GAMEPAD_BUTTON_LABEL_B;
292 SDL_GAMEPAD_BUTTON_LABEL_X;
295 SDL_GAMEPAD_BUTTON_LABEL_Y;
298 SDL_GAMEPAD_BUTTON_LABEL_CROSS;
301 SDL_GAMEPAD_BUTTON_LABEL_CIRCLE;
304 SDL_GAMEPAD_BUTTON_LABEL_SQUARE;
307 SDL_GAMEPAD_BUTTON_LABEL_TRIANGLE;
325 SDL_GAMEPAD_AXIS_INVALID;
328 SDL_GAMEPAD_AXIS_LEFTX;
331 SDL_GAMEPAD_AXIS_LEFTY;
334 SDL_GAMEPAD_AXIS_RIGHTX;
337 SDL_GAMEPAD_AXIS_RIGHTY;
340 SDL_GAMEPAD_AXIS_LEFT_TRIGGER;
343 SDL_GAMEPAD_AXIS_RIGHT_TRIGGER;
346 SDL_GAMEPAD_AXIS_COUNT;
361 SDL_GAMEPAD_BINDTYPE_NONE;
364 SDL_GAMEPAD_BINDTYPE_BUTTON;
367 SDL_GAMEPAD_BINDTYPE_AXIS;
370 SDL_GAMEPAD_BINDTYPE_HAT;
412 : m_resource(resource)
442 : m_resource(SDL_OpenGamepad(instance_id))
452 std::swap(m_resource, other.m_resource);
463 m_resource =
nullptr;
471 constexpr bool operator==(std::nullptr_t _)
const {
return !m_resource; }
474 constexpr explicit operator bool()
const {
return !!m_resource; }
970 Uint16 high_frequency_rumble,
1125 return SDL_AddGamepadMapping(mapping);
1168 return SDL_AddGamepadMappingsFromIO(src, closeio);
1205 return SDL_AddGamepadMappingsFromFile(file);
1230 auto data = SDL_GetGamepadMappings(&count);
1248 return StringResult(SDL_GetGamepadMappingForGUID(guid));
1294 CheckError(SDL_SetGamepadMapping(instance_id, mapping));
1322 auto r =
reinterpret_cast<JoystickID*
>(SDL_GetGamepads(&count));
1340 return SDL_IsGamepad(instance_id);
1359 return SDL_GetGamepadNameForID(instance_id);
1378 return SDL_GetGamepadPathForID(instance_id);
1396 return SDL_GetGamepadPlayerIndexForID(instance_id);
1415 return SDL_GetGamepadGUIDForID(instance_id);
1435 return SDL_GetGamepadVendorForID(instance_id);
1455 return SDL_GetGamepadProductForID(instance_id);
1475 return SDL_GetGamepadProductVersionForID(instance_id);
1494 return SDL_GetGamepadTypeForID(instance_id);
1513 return SDL_GetRealGamepadTypeForID(instance_id);
1532 return SDL_GetGamepadMappingForID(instance_id);
1564 return {
CheckError(SDL_GetGamepadFromID(instance_id))};
1580 return {SDL_GetGamepadFromPlayerIndex(player_index)};
1609 return {
CheckError(SDL_GetGamepadProperties(gamepad))};
1617namespace prop::GamepadCap {
1619constexpr auto MONO_LED_BOOLEAN = SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN;
1621constexpr auto RGB_LED_BOOLEAN = SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN;
1623constexpr auto PLAYER_LED_BOOLEAN = SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN;
1625constexpr auto RUMBLE_BOOLEAN = SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN;
1627constexpr auto TRIGGER_RUMBLE_BOOLEAN =
1628 SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN;
1643 return CheckError(SDL_GetGamepadID(gamepad));
1661 return SDL_GetGamepadName(gamepad);
1682 return SDL_GetGamepadPath(gamepad);
1702 return SDL_GetGamepadType(gamepad);
1722 return SDL_GetRealGamepadType(gamepad);
1744 return SDL_GetGamepadPlayerIndex(gamepad);
1766 CheckError(SDL_SetGamepadPlayerIndex(gamepad, player_index));
1788 return SDL_GetGamepadVendor(gamepad);
1807 return SDL_GetGamepadProduct(gamepad);
1829 return SDL_GetGamepadProductVersion(gamepad);
1849 return SDL_GetGamepadFirmwareVersion(gamepad);
1869 return SDL_GetGamepadSerial(gamepad);
1890 return SDL_GetGamepadSteamHandle(gamepad);
1909 return CheckError(SDL_GetGamepadConnectionState(gamepad));
1936 return SDL_GetGamepadPowerInfo(gamepad, percent);
1955 return SDL_GamepadConnected(gamepad);
1980 return {SDL_GetGamepadJoystick(gamepad)};
2003 SDL_SetGamepadEventsEnabled(enabled);
2034 return SDL_GetGamepadBindings(gamepad, count);
2071 return SDL_GetGamepadTypeFromString(str);
2088 return SDL_GetGamepadStringForType(type);
2112 return SDL_GetGamepadAxisFromString(str);
2129 return SDL_GetGamepadStringForAxis(axis);
2149 return SDL_GamepadHasAxis(gamepad, axis);
2181 return CheckError(SDL_GetGamepadAxis(gamepad, axis));
2207 return SDL_GetGamepadButtonFromString(str);
2224 return SDL_GetGamepadStringForButton(button);
2243 return SDL_GamepadHasButton(gamepad, button);
2265 return SDL_GetGamepadButton(gamepad, button);
2287 return SDL_GetGamepadButtonLabelForType(type, button);
2304 return SDL_GetGamepadButtonLabel(gamepad, button);
2324 return SDL_GetNumGamepadTouchpads(gamepad);
2347 return SDL_GetNumGamepadTouchpadFingers(gamepad, touchpad);
2383 gamepad, touchpad, finger, down, x, y, pressure));
2394 m_resource, touchpad, finger, down, x, y, pressure);
2412 return SDL_GamepadHasSensor(gamepad, type);
2437 CheckError(SDL_SetGamepadSensorEnabled(gamepad, type, enabled));
2458 return SDL_GamepadSensorEnabled(gamepad, type);
2477 return SDL_GetGamepadSensorDataRate(gamepad, type);
2504 CheckError(SDL_GetGamepadSensorData(gamepad, type, data, num_values));
2532 Uint16 low_frequency_rumble,
2533 Uint16 high_frequency_rumble,
2537 gamepad, low_frequency_rumble, high_frequency_rumble, duration_ms));
2541 Uint16 high_frequency_rumble,
2545 m_resource, low_frequency_rumble, high_frequency_rumble, duration_ms);
2579 SDL_RumbleGamepadTriggers(gamepad, left_rumble, right_rumble, duration_ms));
2587 m_resource, left_rumble, right_rumble, duration_ms);
2612 CheckError(SDL_SetGamepadLED(gamepad, red, green, blue));
2632 CheckError(SDL_SendGamepadEffect(gamepad, data, size));
2667 return SDL_GetGamepadAppleSFSymbolsNameForButton(gamepad, button);
2689 return SDL_GetGamepadAppleSFSymbolsNameForAxis(gamepad, axis);
The structure used to identify an SDL gamepad.
Definition: SDL3pp_gamepad.h:397
Gamepad(JoystickID instance_id)
Open a gamepad for use.
Definition: SDL3pp_gamepad.h:441
constexpr Gamepad()=default
Default ctor.
constexpr GamepadRaw release()
Retrieves underlying GamepadRaw and clear this.
Definition: SDL3pp_gamepad.h:460
constexpr GamepadRaw get() const
Retrieves underlying GamepadRaw.
Definition: SDL3pp_gamepad.h:457
constexpr bool operator==(std::nullptr_t _) const
Comparison.
Definition: SDL3pp_gamepad.h:471
constexpr Gamepad(Gamepad &&other)
Move constructor.
Definition: SDL3pp_gamepad.h:420
~Gamepad()
Destructor.
Definition: SDL3pp_gamepad.h:447
Gamepad & operator=(Gamepad other)
Assignment operator.
Definition: SDL3pp_gamepad.h:450
constexpr Gamepad(const Gamepad &other)=delete
Copy constructor.
constexpr Gamepad(const GamepadRaw resource)
Constructs from GamepadParam.
Definition: SDL3pp_gamepad.h:411
constexpr auto operator<=>(const Gamepad &other) const =default
Comparison.
This is a unique ID for a joystick for the time it is connected to the system, and is never reused fo...
Definition: SDL3pp_joystick.h:149
Base class for SDL memory allocated array wrap.
Definition: SDL3pp_ownPtr.h:44
Helpers to use C++ strings parameters.
Definition: SDL3pp_strings.h:43
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:197
void GetSensorData(SensorType type, float *data, int num_values)
Get the current state of a gamepad sensor.
Definition: SDL3pp_gamepad.h:2507
const char * GetAppleSFSymbolsNameForAxis(GamepadAxis axis)
Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
Definition: SDL3pp_gamepad.h:2692
void SetSensorEnabled(SensorType type, bool enabled)
Set whether data reporting for a gamepad sensor is enabled.
Definition: SDL3pp_gamepad.h:2440
constexpr GamepadButton GAMEPAD_BUTTON_MISC6
Additional button.
Definition: SDL3pp_gamepad.h:263
SDL_GamepadType GamepadType
Standard gamepad types.
Definition: SDL3pp_gamepad.h:113
constexpr GamepadBindingType GAMEPAD_BINDTYPE_AXIS
GAMEPAD_BINDTYPE_AXIS.
Definition: SDL3pp_gamepad.h:366
int AddGamepadMappingsFromFile(StringParam file)
Load a set of gamepad mappings from a file.
Definition: SDL3pp_gamepad.h:1203
bool HasButton(GamepadButton button)
Query whether a gamepad has a given button.
Definition: SDL3pp_gamepad.h:2246
constexpr GamepadType GAMEPAD_TYPE_NINTENDO_SWITCH_PRO
GAMEPAD_TYPE_NINTENDO_SWITCH_PRO.
Definition: SDL3pp_gamepad.h:136
constexpr GamepadType GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT
GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT.
Definition: SDL3pp_gamepad.h:139
void Rumble(Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
Start a rumble effect on a gamepad.
Definition: SDL3pp_gamepad.h:2540
int GetNumGamepadTouchpads(GamepadParam gamepad)
Get the number of touchpads on a gamepad.
Definition: SDL3pp_gamepad.h:2322
Uint16 GetProductVersion()
Get the product version of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1832
GamepadType GetGamepadType(GamepadParam gamepad)
Get the type of an opened gamepad.
Definition: SDL3pp_gamepad.h:1700
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_SQUARE
GAMEPAD_BUTTON_LABEL_SQUARE.
Definition: SDL3pp_gamepad.h:303
constexpr GamepadAxis GAMEPAD_AXIS_RIGHTX
GAMEPAD_AXIS_RIGHTX.
Definition: SDL3pp_gamepad.h:333
JoystickID GetGamepadID(GamepadParam gamepad)
Get the instance ID of an opened gamepad.
Definition: SDL3pp_gamepad.h:1641
const char * GetGamepadName(GamepadParam gamepad)
Get the implementation-dependent name for an opened gamepad.
Definition: SDL3pp_gamepad.h:1659
constexpr GamepadButton GAMEPAD_BUTTON_MISC4
Additional button.
Definition: SDL3pp_gamepad.h:257
GamepadRef GetGamepadFromPlayerIndex(int player_index)
Get the Gamepad associated with a player index.
Definition: SDL3pp_gamepad.h:1578
constexpr GamepadAxis GAMEPAD_AXIS_LEFTY
GAMEPAD_AXIS_LEFTY.
Definition: SDL3pp_gamepad.h:330
GamepadAxis GetGamepadAxisFromString(StringParam str)
Convert a string into GamepadAxis enum.
Definition: SDL3pp_gamepad.h:2110
constexpr GamepadButton GAMEPAD_BUTTON_LEFT_PADDLE2
Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4)
Definition: SDL3pp_gamepad.h:245
const char * GetAppleSFSymbolsNameForButton(GamepadButton button)
Return the sfSymbolsName for a given button on a gamepad on Apple platforms.
Definition: SDL3pp_gamepad.h:2670
GamepadButton GetGamepadButtonFromString(StringParam str)
Convert a string into an GamepadButton enum.
Definition: SDL3pp_gamepad.h:2205
GamepadRef GetGamepadFromID(JoystickID instance_id)
Get the Gamepad associated with a joystick instance ID, if it has been opened.
Definition: SDL3pp_gamepad.h:1562
constexpr GamepadBindingType GAMEPAD_BINDTYPE_BUTTON
GAMEPAD_BINDTYPE_BUTTON.
Definition: SDL3pp_gamepad.h:363
Uint16 GetVendor()
Get the USB vendor ID of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1791
GamepadButtonLabel GetGamepadButtonLabel(GamepadParam gamepad, GamepadButton button)
Get the label of a button on a gamepad.
Definition: SDL3pp_gamepad.h:2301
GamepadType GetType()
Get the type of an opened gamepad.
Definition: SDL3pp_gamepad.h:1705
constexpr GamepadButton GAMEPAD_BUTTON_DPAD_UP
GAMEPAD_BUTTON_DPAD_UP.
Definition: SDL3pp_gamepad.h:211
void SetGamepadLED(GamepadParam gamepad, Uint8 red, Uint8 green, Uint8 blue)
Update a gamepad's LED color.
Definition: SDL3pp_gamepad.h:2607
bool HasAxis(GamepadAxis axis)
Query whether a gamepad has a given axis.
Definition: SDL3pp_gamepad.h:2152
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_B
GAMEPAD_BUTTON_LABEL_B.
Definition: SDL3pp_gamepad.h:288
bool GamepadEventsEnabled()
Query the state of gamepad event processing.
Definition: SDL3pp_gamepad.h:2018
GamepadType GetRealGamepadType(GamepadParam gamepad)
Get the type of an opened gamepad, ignoring any mapping override.
Definition: SDL3pp_gamepad.h:1720
constexpr GamepadButton GAMEPAD_BUTTON_LEFT_SHOULDER
GAMEPAD_BUTTON_LEFT_SHOULDER.
Definition: SDL3pp_gamepad.h:205
constexpr GamepadType GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR
GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR.
Definition: SDL3pp_gamepad.h:145
GamepadType GetRealGamepadTypeForID(JoystickID instance_id)
Get the type of a gamepad, ignoring any mapping override.
Definition: SDL3pp_gamepad.h:1511
GamepadButtonLabel GetButtonLabel(GamepadButton button)
Get the label of a button on a gamepad.
Definition: SDL3pp_gamepad.h:2307
float GetGamepadSensorDataRate(GamepadParam gamepad, SensorType type)
Get the data rate (number of events per second) of a gamepad sensor.
Definition: SDL3pp_gamepad.h:2475
Uint16 GetGamepadVendorForID(JoystickID instance_id)
Get the USB vendor ID of a gamepad, if available.
Definition: SDL3pp_gamepad.h:1433
bool Connected()
Check if a gamepad has been opened and is currently connected.
Definition: SDL3pp_gamepad.h:1958
PowerState GetGamepadPowerInfo(GamepadParam gamepad, int *percent)
Get the battery state of a gamepad.
Definition: SDL3pp_gamepad.h:1934
Uint16 GetGamepadProductForID(JoystickID instance_id)
Get the USB product ID of a gamepad, if available.
Definition: SDL3pp_gamepad.h:1453
PowerState GetPowerInfo(int *percent)
Get the battery state of a gamepad.
Definition: SDL3pp_gamepad.h:1939
int GetNumTouchpads()
Get the number of touchpads on a gamepad.
Definition: SDL3pp_gamepad.h:2327
void RumbleGamepadTriggers(GamepadParam gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms)
Start a rumble effect in the gamepad's triggers.
Definition: SDL3pp_gamepad.h:2573
int GetNumTouchpadFingers(int touchpad)
Get the number of supported simultaneous fingers on a touchpad on a game gamepad.
Definition: SDL3pp_gamepad.h:2350
const char * GetGamepadAppleSFSymbolsNameForAxis(GamepadParam gamepad, GamepadAxis axis)
Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
Definition: SDL3pp_gamepad.h:2686
StringResult GetGamepadMapping(GamepadParam gamepad)
Get the current mapping of a gamepad.
Definition: SDL3pp_gamepad.h:1267
const char * GetSerial()
Get the serial number of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1872
PropertiesRef GetProperties()
Get the properties associated with an opened gamepad.
Definition: SDL3pp_gamepad.h:1612
const char * GetName()
Get the implementation-dependent name for an opened gamepad.
Definition: SDL3pp_gamepad.h:1664
const char * GetGamepadNameForID(JoystickID instance_id)
Get the implementation dependent name of a gamepad.
Definition: SDL3pp_gamepad.h:1357
OwnArray< char * > GetGamepadMappings()
Get the current gamepad mappings.
Definition: SDL3pp_gamepad.h:1227
constexpr GamepadButton GAMEPAD_BUTTON_DPAD_LEFT
GAMEPAD_BUTTON_DPAD_LEFT.
Definition: SDL3pp_gamepad.h:217
GUID GetGamepadGUIDForID(JoystickID instance_id)
Get the implementation-dependent GUID of a gamepad.
Definition: SDL3pp_gamepad.h:1413
Uint16 GetGamepadVendor(GamepadParam gamepad)
Get the USB vendor ID of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1786
constexpr GamepadAxis GAMEPAD_AXIS_RIGHT_TRIGGER
GAMEPAD_AXIS_RIGHT_TRIGGER.
Definition: SDL3pp_gamepad.h:342
void GetTouchpadFinger(int touchpad, int finger, bool *down, float *x, float *y, float *pressure)
Get the current state of a finger on a touchpad on a gamepad.
Definition: SDL3pp_gamepad.h:2386
void SetPlayerIndex(int player_index)
Set the player index of an opened gamepad.
Definition: SDL3pp_gamepad.h:1769
bool GamepadHasSensor(GamepadParam gamepad, SensorType type)
Return whether a gamepad has a particular sensor.
Definition: SDL3pp_gamepad.h:2410
constexpr GamepadBindingType GAMEPAD_BINDTYPE_HAT
GAMEPAD_BINDTYPE_HAT.
Definition: SDL3pp_gamepad.h:369
constexpr GamepadType GAMEPAD_TYPE_COUNT
GAMEPAD_TYPE_COUNT.
Definition: SDL3pp_gamepad.h:148
constexpr GamepadType GAMEPAD_TYPE_XBOXONE
GAMEPAD_TYPE_XBOXONE.
Definition: SDL3pp_gamepad.h:124
Uint16 GetGamepadProductVersion(GamepadParam gamepad)
Get the product version of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1827
void RumbleTriggers(Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms)
Start a rumble effect in the gamepad's triggers.
Definition: SDL3pp_gamepad.h:2582
JoystickID GetID()
Get the instance ID of an opened gamepad.
Definition: SDL3pp_gamepad.h:1646
constexpr GamepadAxis GAMEPAD_AXIS_LEFTX
GAMEPAD_AXIS_LEFTX.
Definition: SDL3pp_gamepad.h:327
constexpr GamepadButton GAMEPAD_BUTTON_EAST
Right face button (e.g. Xbox B button)
Definition: SDL3pp_gamepad.h:181
constexpr GamepadType GAMEPAD_TYPE_STANDARD
GAMEPAD_TYPE_STANDARD.
Definition: SDL3pp_gamepad.h:118
void SendEffect(const void *data, int size)
Send a gamepad specific effect packet.
Definition: SDL3pp_gamepad.h:2635
constexpr GamepadType GAMEPAD_TYPE_PS3
GAMEPAD_TYPE_PS3.
Definition: SDL3pp_gamepad.h:127
SDL_GamepadBinding ** GetGamepadBindings(GamepadParam gamepad, int *count)
Get the SDL joystick layer bindings for a gamepad.
Definition: SDL3pp_gamepad.h:2032
Uint16 GetGamepadFirmwareVersion(GamepadParam gamepad)
Get the firmware version of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1847
constexpr GamepadType GAMEPAD_TYPE_PS4
GAMEPAD_TYPE_PS4.
Definition: SDL3pp_gamepad.h:130
constexpr GamepadButton GAMEPAD_BUTTON_RIGHT_PADDLE2
Lower or secondary paddle, under your right hand (e.g.
Definition: SDL3pp_gamepad.h:241
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_CROSS
GAMEPAD_BUTTON_LABEL_CROSS.
Definition: SDL3pp_gamepad.h:297
StringResult GetMapping()
Get the current mapping of a gamepad.
Definition: SDL3pp_gamepad.h:1272
void SetGamepadSensorEnabled(GamepadParam gamepad, SensorType type, bool enabled)
Set whether data reporting for a gamepad sensor is enabled.
Definition: SDL3pp_gamepad.h:2433
constexpr GamepadButton GAMEPAD_BUTTON_SOUTH
Bottom face button (e.g. Xbox A button)
Definition: SDL3pp_gamepad.h:178
constexpr GamepadAxis GAMEPAD_AXIS_LEFT_TRIGGER
GAMEPAD_AXIS_LEFT_TRIGGER.
Definition: SDL3pp_gamepad.h:339
Uint16 GetGamepadProductVersionForID(JoystickID instance_id)
Get the product version of a gamepad, if available.
Definition: SDL3pp_gamepad.h:1473
const char * GetGamepadSerial(GamepadParam gamepad)
Get the serial number of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1867
int GetGamepadPlayerIndexForID(JoystickID instance_id)
Get the player index of a gamepad.
Definition: SDL3pp_gamepad.h:1394
JoystickConnectionState GetConnectionState()
Get the connection state of a gamepad.
Definition: SDL3pp_gamepad.h:1912
const char * GetGamepadPathForID(JoystickID instance_id)
Get the implementation dependent path of a gamepad.
Definition: SDL3pp_gamepad.h:1376
void Close()
Close a gamepad previously opened with Gamepad.Gamepad().
Definition: SDL3pp_gamepad.h:2651
SDL_GamepadAxis GamepadAxis
The list of axes available on a gamepad.
Definition: SDL3pp_gamepad.h:322
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_UNKNOWN
GAMEPAD_BUTTON_LABEL_UNKNOWN.
Definition: SDL3pp_gamepad.h:282
SDL_Gamepad * GamepadRaw
Alias to raw representation for Gamepad.
Definition: SDL3pp_gamepad.h:72
void SetLED(Uint8 red, Uint8 green, Uint8 blue)
Update a gamepad's LED color.
Definition: SDL3pp_gamepad.h:2615
const char * GetGamepadStringForAxis(GamepadAxis axis)
Convert from an GamepadAxis enum to a string.
Definition: SDL3pp_gamepad.h:2127
GamepadType GetRealType()
Get the type of an opened gamepad, ignoring any mapping override.
Definition: SDL3pp_gamepad.h:1725
Sint16 GetAxis(GamepadAxis axis)
Get the current state of an axis control on a gamepad.
Definition: SDL3pp_gamepad.h:2184
bool HasSensor(SensorType type)
Return whether a gamepad has a particular sensor.
Definition: SDL3pp_gamepad.h:2415
constexpr GamepadButton GAMEPAD_BUTTON_BACK
GAMEPAD_BUTTON_BACK.
Definition: SDL3pp_gamepad.h:190
Uint16 GetProduct()
Get the USB product ID of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1810
bool GetGamepadButton(GamepadParam gamepad, GamepadButton button)
Get the current state of a button on a gamepad.
Definition: SDL3pp_gamepad.h:2263
StringResult GetGamepadMappingForGUID(GUID guid)
Get the gamepad mapping string for a given GUID.
Definition: SDL3pp_gamepad.h:1246
constexpr GamepadButton GAMEPAD_BUTTON_DPAD_RIGHT
GAMEPAD_BUTTON_DPAD_RIGHT.
Definition: SDL3pp_gamepad.h:220
Uint16 GetFirmwareVersion()
Get the firmware version of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1852
Uint16 GetGamepadProduct(GamepadParam gamepad)
Get the USB product ID of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1805
Uint64 GetSteamHandle()
Get the Steam Input handle of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1893
SDL_GamepadBinding GamepadBinding
A mapping between one joystick input to a gamepad control.
Definition: SDL3pp_gamepad.h:387
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_X
GAMEPAD_BUTTON_LABEL_X.
Definition: SDL3pp_gamepad.h:291
GamepadButtonLabel GetGamepadButtonLabelForType(GamepadType type, GamepadButton button)
Get the label of a button on a gamepad.
Definition: SDL3pp_gamepad.h:2284
constexpr GamepadButton GAMEPAD_BUTTON_RIGHT_PADDLE1
Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1)
Definition: SDL3pp_gamepad.h:231
PropertiesRef GetGamepadProperties(GamepadParam gamepad)
Get the properties associated with an opened gamepad.
Definition: SDL3pp_gamepad.h:1607
int AddGamepadMapping(StringParam mapping)
Add support for gamepads that SDL is unaware of or change the binding of an existing gamepad.
Definition: SDL3pp_gamepad.h:1123
constexpr GamepadButton GAMEPAD_BUTTON_INVALID
GAMEPAD_BUTTON_INVALID.
Definition: SDL3pp_gamepad.h:175
constexpr GamepadAxis GAMEPAD_AXIS_RIGHTY
GAMEPAD_AXIS_RIGHTY.
Definition: SDL3pp_gamepad.h:336
JoystickRef GetGamepadJoystick(GamepadParam gamepad)
Get the underlying joystick from a gamepad.
Definition: SDL3pp_gamepad.h:1978
GamepadType GetGamepadTypeForID(JoystickID instance_id)
Get the type of a gamepad.
Definition: SDL3pp_gamepad.h:1492
float GetSensorDataRate(SensorType type)
Get the data rate (number of events per second) of a gamepad sensor.
Definition: SDL3pp_gamepad.h:2480
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_CIRCLE
GAMEPAD_BUTTON_LABEL_CIRCLE.
Definition: SDL3pp_gamepad.h:300
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_TRIANGLE
GAMEPAD_BUTTON_LABEL_TRIANGLE.
Definition: SDL3pp_gamepad.h:306
constexpr GamepadButton GAMEPAD_BUTTON_MISC3
Additional button.
Definition: SDL3pp_gamepad.h:254
SDL_GamepadButtonLabel GamepadButtonLabel
The set of gamepad button labels.
Definition: SDL3pp_gamepad.h:280
char * GetGamepadMappingForID(JoystickID instance_id)
Get the mapping of a gamepad.
Definition: SDL3pp_gamepad.h:1530
constexpr GamepadButton GAMEPAD_BUTTON_LEFT_PADDLE1
Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3)
Definition: SDL3pp_gamepad.h:235
bool GamepadConnected(GamepadParam gamepad)
Check if a gamepad has been opened and is currently connected.
Definition: SDL3pp_gamepad.h:1953
Uint64 GetGamepadSteamHandle(GamepadParam gamepad)
Get the Steam Input handle of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1888
void GetGamepadTouchpadFinger(GamepadParam gamepad, int touchpad, int finger, bool *down, float *x, float *y, float *pressure)
Get the current state of a finger on a touchpad on a gamepad.
Definition: SDL3pp_gamepad.h:2374
bool HasGamepad()
Return whether a gamepad is currently connected.
Definition: SDL3pp_gamepad.h:1306
SDL_GamepadButton GamepadButton
The list of buttons available on a gamepad.
Definition: SDL3pp_gamepad.h:173
int GetGamepadPlayerIndex(GamepadParam gamepad)
Get the player index of an opened gamepad.
Definition: SDL3pp_gamepad.h:1742
JoystickConnectionState GetGamepadConnectionState(GamepadParam gamepad)
Get the connection state of a gamepad.
Definition: SDL3pp_gamepad.h:1907
void SetGamepadPlayerIndex(GamepadParam gamepad, int player_index)
Set the player index of an opened gamepad.
Definition: SDL3pp_gamepad.h:1764
void ReloadGamepadMappings()
Reinitialize the SDL mapping database to its initial state.
Definition: SDL3pp_gamepad.h:1217
constexpr GamepadButton GAMEPAD_BUTTON_START
GAMEPAD_BUTTON_START.
Definition: SDL3pp_gamepad.h:196
const char * GetGamepadStringForButton(GamepadButton button)
Convert from an GamepadButton enum to a string.
Definition: SDL3pp_gamepad.h:2222
constexpr GamepadButton GAMEPAD_BUTTON_MISC1
Additional button (e.g.
Definition: SDL3pp_gamepad.h:228
constexpr GamepadAxis GAMEPAD_AXIS_COUNT
GAMEPAD_AXIS_COUNT.
Definition: SDL3pp_gamepad.h:345
constexpr GamepadAxis GAMEPAD_AXIS_INVALID
GAMEPAD_AXIS_INVALID.
Definition: SDL3pp_gamepad.h:324
const char * GetGamepadAppleSFSymbolsNameForButton(GamepadParam gamepad, GamepadButton button)
Return the sfSymbolsName for a given button on a gamepad on Apple platforms.
Definition: SDL3pp_gamepad.h:2664
int AddGamepadMappingsFromIO(IOStreamParam src, bool closeio)
Load a set of gamepad mappings from an IOStream.
Definition: SDL3pp_gamepad.h:1166
GamepadType GetGamepadTypeFromString(StringParam str)
Convert a string into GamepadType enum.
Definition: SDL3pp_gamepad.h:2069
bool GamepadHasAxis(GamepadParam gamepad, GamepadAxis axis)
Query whether a gamepad has a given axis.
Definition: SDL3pp_gamepad.h:2147
constexpr GamepadButton GAMEPAD_BUTTON_WEST
Left face button (e.g. Xbox X button)
Definition: SDL3pp_gamepad.h:184
bool IsGamepad(JoystickID instance_id)
Check if the given joystick is supported by the gamepad interface.
Definition: SDL3pp_gamepad.h:1338
constexpr GamepadType GAMEPAD_TYPE_XBOX360
GAMEPAD_TYPE_XBOX360.
Definition: SDL3pp_gamepad.h:121
SDL_GamepadBindingType GamepadBindingType
Types of gamepad control bindings.
Definition: SDL3pp_gamepad.h:358
constexpr GamepadType GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT
GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT.
Definition: SDL3pp_gamepad.h:142
constexpr GamepadButton GAMEPAD_BUTTON_LEFT_STICK
GAMEPAD_BUTTON_LEFT_STICK.
Definition: SDL3pp_gamepad.h:199
constexpr GamepadButton GAMEPAD_BUTTON_RIGHT_STICK
GAMEPAD_BUTTON_RIGHT_STICK.
Definition: SDL3pp_gamepad.h:202
Sint16 GetGamepadAxis(GamepadParam gamepad, GamepadAxis axis)
Get the current state of an axis control on a gamepad.
Definition: SDL3pp_gamepad.h:2179
constexpr GamepadButton GAMEPAD_BUTTON_DPAD_DOWN
GAMEPAD_BUTTON_DPAD_DOWN.
Definition: SDL3pp_gamepad.h:214
constexpr GamepadButton GAMEPAD_BUTTON_MISC5
Additional button.
Definition: SDL3pp_gamepad.h:260
void SetGamepadMapping(JoystickID instance_id, StringParam mapping)
Set the current mapping of a joystick or gamepad.
Definition: SDL3pp_gamepad.h:1292
void GetGamepadSensorData(GamepadParam gamepad, SensorType type, float *data, int num_values)
Get the current state of a gamepad sensor.
Definition: SDL3pp_gamepad.h:2499
int GetNumGamepadTouchpadFingers(GamepadParam gamepad, int touchpad)
Get the number of supported simultaneous fingers on a touchpad on a game gamepad.
Definition: SDL3pp_gamepad.h:2345
void SetGamepadEventsEnabled(bool enabled)
Set the state of gamepad event processing.
Definition: SDL3pp_gamepad.h:2001
constexpr GamepadType GAMEPAD_TYPE_PS5
GAMEPAD_TYPE_PS5.
Definition: SDL3pp_gamepad.h:133
constexpr GamepadButton GAMEPAD_BUTTON_MISC2
Additional button.
Definition: SDL3pp_gamepad.h:251
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_Y
GAMEPAD_BUTTON_LABEL_Y.
Definition: SDL3pp_gamepad.h:294
bool GetButton(GamepadButton button)
Get the current state of a button on a gamepad.
Definition: SDL3pp_gamepad.h:2268
void RumbleGamepad(GamepadParam gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
Start a rumble effect on a gamepad.
Definition: SDL3pp_gamepad.h:2531
JoystickRef GetJoystick()
Get the underlying joystick from a gamepad.
Definition: SDL3pp_gamepad.h:1983
Gamepad OpenGamepad(JoystickID instance_id)
Open a gamepad for use.
Definition: SDL3pp_gamepad.h:1547
void UpdateGamepads()
Manually pump gamepad updates if not using the loop.
Definition: SDL3pp_gamepad.h:2051
OwnArray< JoystickID > GetGamepads()
Get a list of currently connected gamepads.
Definition: SDL3pp_gamepad.h:1319
constexpr GamepadButton GAMEPAD_BUTTON_TOUCHPAD
PS4/PS5 touchpad button.
Definition: SDL3pp_gamepad.h:248
const char * GetGamepadStringForType(GamepadType type)
Convert from an GamepadType enum to a string.
Definition: SDL3pp_gamepad.h:2086
constexpr GamepadButton GAMEPAD_BUTTON_GUIDE
GAMEPAD_BUTTON_GUIDE.
Definition: SDL3pp_gamepad.h:193
int GetPlayerIndex()
Get the player index of an opened gamepad.
Definition: SDL3pp_gamepad.h:1747
bool SensorEnabled(SensorType type)
Query whether sensor data reporting is enabled for a gamepad.
Definition: SDL3pp_gamepad.h:2461
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_A
GAMEPAD_BUTTON_LABEL_A.
Definition: SDL3pp_gamepad.h:285
constexpr GamepadButton GAMEPAD_BUTTON_COUNT
GAMEPAD_BUTTON_COUNT.
Definition: SDL3pp_gamepad.h:266
SDL_GamepadBinding ** GetBindings(int *count)
Get the SDL joystick layer bindings for a gamepad.
Definition: SDL3pp_gamepad.h:2037
const char * GetGamepadPath(GamepadParam gamepad)
Get the implementation-dependent path for an opened gamepad.
Definition: SDL3pp_gamepad.h:1680
const char * GetPath()
Get the implementation-dependent path for an opened gamepad.
Definition: SDL3pp_gamepad.h:1685
void SendGamepadEffect(GamepadParam gamepad, const void *data, int size)
Send a gamepad specific effect packet.
Definition: SDL3pp_gamepad.h:2630
bool GamepadHasButton(GamepadParam gamepad, GamepadButton button)
Query whether a gamepad has a given button.
Definition: SDL3pp_gamepad.h:2241
constexpr GamepadBindingType GAMEPAD_BINDTYPE_NONE
GAMEPAD_BINDTYPE_NONE.
Definition: SDL3pp_gamepad.h:360
void CloseGamepad(GamepadRaw gamepad)
Close a gamepad previously opened with Gamepad.Gamepad().
Definition: SDL3pp_gamepad.h:2649
constexpr GamepadType GAMEPAD_TYPE_UNKNOWN
GAMEPAD_TYPE_UNKNOWN.
Definition: SDL3pp_gamepad.h:115
bool GamepadSensorEnabled(GamepadParam gamepad, SensorType type)
Query whether sensor data reporting is enabled for a gamepad.
Definition: SDL3pp_gamepad.h:2456
constexpr GamepadButton GAMEPAD_BUTTON_NORTH
Top face button (e.g. Xbox Y button)
Definition: SDL3pp_gamepad.h:187
constexpr GamepadButton GAMEPAD_BUTTON_RIGHT_SHOULDER
GAMEPAD_BUTTON_RIGHT_SHOULDER.
Definition: SDL3pp_gamepad.h:208
SDL_JoystickConnectionState JoystickConnectionState
Possible connection states for a joystick device.
Definition: SDL3pp_joystick.h:347
SDL_PowerState PowerState
The basic state for the system's power supply.
Definition: SDL3pp_power.h:38
SDL_SensorType SensorType
The different sensors defined by SDL.
Definition: SDL3pp_sensor.h:125
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:341
::Uint64 Uint64
An unsigned 64-bit integer type.
Definition: SDL3pp_stdinc.h:371
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition: SDL3pp_stdinc.h:289
::Sint16 Sint16
A signed 16-bit integer type.
Definition: SDL3pp_stdinc.h:302
::Uint16 Uint16
An unsigned 16-bit integer type.
Definition: SDL3pp_stdinc.h:315
Main include header for the SDL3pp library.
An GUID is a 128-bit identifier for an input device that identifies that device across runs of SDL pr...
Definition: SDL3pp_guid.h:44
Safely wrap Gamepad for non owning parameters.
Definition: SDL3pp_gamepad.h:79
constexpr GamepadParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_gamepad.h:89
constexpr GamepadParam(GamepadRaw value)
Constructs from GamepadRaw.
Definition: SDL3pp_gamepad.h:83
constexpr auto operator<=>(const GamepadParam &other) const =default
Comparison.
GamepadRaw value
parameter's GamepadRaw
Definition: SDL3pp_gamepad.h:80
Semi-safe reference for Gamepad.
Definition: SDL3pp_gamepad.h:1058
~GamepadRef()
Destructor.
Definition: SDL3pp_gamepad.h:1078
GamepadRef(GamepadParam resource)
Constructs from GamepadParam.
Definition: SDL3pp_gamepad.h:1066
GamepadRef(const GamepadRef &other)
Copy constructor.
Definition: SDL3pp_gamepad.h:1072
Safely wrap IOStream for non owning parameters.
Definition: SDL3pp_iostream.h:34
Semi-safe reference for Joystick.
Definition: SDL3pp_joystick.h:1054
Semi-safe reference for Properties.
Definition: SDL3pp_properties.h:701
A simple std::string-like interface for SDL allocated strings.
Definition: SDL3pp_strings.h:153