SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL3pp_gamepad.h
1#ifndef SDL3PP_GAMEPAD_H_
2#define SDL3PP_GAMEPAD_H_
3
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"
13
14namespace SDL {
15
71// Forward decl
72struct Gamepad;
73
75using GamepadRaw = SDL_Gamepad*;
76
77// Forward decl
78struct GamepadRef;
79
82{
84
87 : value(value)
88 {
89 }
90
92 constexpr GamepadParam(std::nullptr_t = nullptr)
93 : value(nullptr)
94 {
95 }
96
98 constexpr explicit operator bool() const { return !!value; }
99
101 constexpr auto operator<=>(const GamepadParam& other) const = default;
102
104 constexpr operator GamepadRaw() const { return value; }
105};
106
116using GamepadType = SDL_GamepadType;
117
119 SDL_GAMEPAD_TYPE_UNKNOWN;
120
122 SDL_GAMEPAD_TYPE_STANDARD;
123
125 SDL_GAMEPAD_TYPE_XBOX360;
126
128 SDL_GAMEPAD_TYPE_XBOXONE;
129
131 SDL_GAMEPAD_TYPE_PS3;
132
134 SDL_GAMEPAD_TYPE_PS4;
135
137 SDL_GAMEPAD_TYPE_PS5;
138
140 SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO;
141
143 SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT;
144
146 SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT;
147
149 SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR;
150
151#if SDL_VERSION_ATLEAST(3, 4, 0)
152
154 SDL_GAMEPAD_TYPE_GAMECUBE;
155
156#endif // SDL_VERSION_ATLEAST(3, 4, 0)
157
159 SDL_GAMEPAD_TYPE_COUNT;
160
184using GamepadButton = SDL_GamepadButton;
185
187 SDL_GAMEPAD_BUTTON_INVALID;
188
190 SDL_GAMEPAD_BUTTON_SOUTH;
191
193 SDL_GAMEPAD_BUTTON_EAST;
194
196 SDL_GAMEPAD_BUTTON_WEST;
197
199 SDL_GAMEPAD_BUTTON_NORTH;
200
202 SDL_GAMEPAD_BUTTON_BACK;
203
205 SDL_GAMEPAD_BUTTON_GUIDE;
206
208 SDL_GAMEPAD_BUTTON_START;
209
211 SDL_GAMEPAD_BUTTON_LEFT_STICK;
212
214 SDL_GAMEPAD_BUTTON_RIGHT_STICK;
215
217 SDL_GAMEPAD_BUTTON_LEFT_SHOULDER;
218
220 SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER;
221
223 SDL_GAMEPAD_BUTTON_DPAD_UP;
224
226 SDL_GAMEPAD_BUTTON_DPAD_DOWN;
227
229 SDL_GAMEPAD_BUTTON_DPAD_LEFT;
230
232 SDL_GAMEPAD_BUTTON_DPAD_RIGHT;
233
239constexpr GamepadButton GAMEPAD_BUTTON_MISC1 = SDL_GAMEPAD_BUTTON_MISC1;
240
246 SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1;
247
253 SDL_GAMEPAD_BUTTON_LEFT_PADDLE1;
254
260 SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2;
261
267 SDL_GAMEPAD_BUTTON_LEFT_PADDLE2;
268
270 SDL_GAMEPAD_BUTTON_TOUCHPAD;
271
273 SDL_GAMEPAD_BUTTON_MISC2;
274
276constexpr GamepadButton GAMEPAD_BUTTON_MISC3 = SDL_GAMEPAD_BUTTON_MISC3;
277
279constexpr GamepadButton GAMEPAD_BUTTON_MISC4 = SDL_GAMEPAD_BUTTON_MISC4;
280
282 SDL_GAMEPAD_BUTTON_MISC5;
283
285 SDL_GAMEPAD_BUTTON_MISC6;
286
288 SDL_GAMEPAD_BUTTON_COUNT;
289
301using GamepadButtonLabel = SDL_GamepadButtonLabel;
302
304 SDL_GAMEPAD_BUTTON_LABEL_UNKNOWN;
305
307 SDL_GAMEPAD_BUTTON_LABEL_A;
308
310 SDL_GAMEPAD_BUTTON_LABEL_B;
311
313 SDL_GAMEPAD_BUTTON_LABEL_X;
314
316 SDL_GAMEPAD_BUTTON_LABEL_Y;
317
319 SDL_GAMEPAD_BUTTON_LABEL_CROSS;
320
322 SDL_GAMEPAD_BUTTON_LABEL_CIRCLE;
323
325 SDL_GAMEPAD_BUTTON_LABEL_SQUARE;
326
328 SDL_GAMEPAD_BUTTON_LABEL_TRIANGLE;
329
343using GamepadAxis = SDL_GamepadAxis;
344
346 SDL_GAMEPAD_AXIS_INVALID;
347
349 SDL_GAMEPAD_AXIS_LEFTX;
350
352 SDL_GAMEPAD_AXIS_LEFTY;
353
355 SDL_GAMEPAD_AXIS_RIGHTX;
356
358 SDL_GAMEPAD_AXIS_RIGHTY;
359
361 SDL_GAMEPAD_AXIS_LEFT_TRIGGER;
362
364 SDL_GAMEPAD_AXIS_RIGHT_TRIGGER;
365
367 SDL_GAMEPAD_AXIS_COUNT;
368
379using GamepadBindingType = SDL_GamepadBindingType;
380
382 SDL_GAMEPAD_BINDTYPE_NONE;
383
385 SDL_GAMEPAD_BINDTYPE_BUTTON;
386
388 SDL_GAMEPAD_BINDTYPE_AXIS;
389
391 SDL_GAMEPAD_BINDTYPE_HAT;
392
408using GamepadBinding = SDL_GamepadBinding;
409
418{
419 GamepadRaw m_resource = nullptr;
420
421public:
423 constexpr Gamepad(std::nullptr_t = nullptr) noexcept
424 : m_resource(0)
425 {
426 }
427
435 constexpr explicit Gamepad(const GamepadRaw resource) noexcept
436 : m_resource(resource)
437 {
438 }
439
440protected:
442 constexpr Gamepad(const Gamepad& other) noexcept = default;
443
444public:
446 constexpr Gamepad(Gamepad&& other) noexcept
447 : Gamepad(other.release())
448 {
449 }
450
451 constexpr Gamepad(const GamepadRef& other) = delete;
452
453 constexpr Gamepad(GamepadRef&& other) = delete;
454
469 Gamepad(JoystickID instance_id)
470 : m_resource(SDL_OpenGamepad(instance_id))
471 {
472 }
473
475 ~Gamepad() { SDL_CloseGamepad(m_resource); }
476
478 constexpr Gamepad& operator=(Gamepad&& other) noexcept
479 {
480 std::swap(m_resource, other.m_resource);
481 return *this;
482 }
483
484protected:
486 constexpr Gamepad& operator=(const Gamepad& other) noexcept = default;
487
488public:
490 constexpr GamepadRaw get() const noexcept { return m_resource; }
491
493 constexpr GamepadRaw release() noexcept
494 {
495 auto r = m_resource;
496 m_resource = nullptr;
497 return r;
498 }
499
501 constexpr auto operator<=>(const Gamepad& other) const noexcept = default;
502
504 constexpr explicit operator bool() const noexcept { return !!m_resource; }
505
507 constexpr operator GamepadParam() const noexcept { return {m_resource}; }
508
518 void Close();
519
538
565
577
590 const char* GetName();
591
604 const char* GetPath();
605
618
631
645 int GetPlayerIndex();
646
660 void SetPlayerIndex(int player_index);
661
676
691
706
719
732 const char* GetSerial();
733
747
759
779 PowerState GetPowerInfo(int* percent);
780
791 bool Connected();
792
813
826
843 bool HasAxis(GamepadAxis axis);
844
871
887 bool HasButton(GamepadButton button);
888
902 bool GetButton(GamepadButton button);
903
917
929 int GetNumTouchpads();
930
945 int GetNumTouchpadFingers(int touchpad);
946
967 void GetTouchpadFinger(int touchpad,
968 int finger,
969 bool* down,
970 float* x,
971 float* y,
972 float* pressure);
973
988 bool HasSensor(SensorType type);
989
1004 void SetSensorEnabled(SensorType type, bool enabled);
1005
1018 bool SensorEnabled(SensorType type);
1019
1030 float GetSensorDataRate(SensorType type);
1031
1047 void GetSensorData(SensorType type, float* data, int num_values);
1048
1069 void Rumble(Uint16 low_frequency_rumble,
1070 Uint16 high_frequency_rumble,
1071 Uint32 duration_ms);
1072
1099 void RumbleTriggers(Uint16 left_rumble,
1100 Uint16 right_rumble,
1101 Uint32 duration_ms);
1102
1121 void SetLED(Uint8 red, Uint8 green, Uint8 blue);
1122
1134 void SendEffect(const void* data, int size);
1135
1150
1163 const char* GetAppleSFSymbolsNameForAxis(GamepadAxis axis);
1164};
1165
1168{
1169 using Gamepad::Gamepad;
1170
1178 GamepadRef(GamepadParam resource) noexcept
1179 : Gamepad(resource.value)
1180 {
1181 }
1182
1190 GamepadRef(GamepadRaw resource) noexcept
1191 : Gamepad(resource)
1192 {
1193 }
1194
1196 constexpr GamepadRef(const GamepadRef& other) noexcept = default;
1197
1200};
1201
1245{
1246 return SDL_AddGamepadMapping(mapping);
1247}
1248
1287inline int AddGamepadMappingsFromIO(IOStreamParam src, bool closeio)
1288{
1289 return SDL_AddGamepadMappingsFromIO(src, closeio);
1290}
1291
1325{
1326 return SDL_AddGamepadMappingsFromFile(file);
1327}
1328
1340inline void ReloadGamepadMappings() { CheckError(SDL_ReloadGamepadMappings()); }
1341
1353{
1354 int count;
1355 auto data = SDL_GetGamepadMappings(&count);
1356 return OwnArray<char*>(data);
1357}
1358
1374{
1375 return StringResult(SDL_GetGamepadMappingForGUID(guid));
1376}
1377
1397{
1398 return StringResult(SDL_GetGamepadMapping(gamepad));
1399}
1400
1402{
1403 return SDL::GetGamepadMapping(m_resource);
1404}
1405
1423inline void SetGamepadMapping(JoystickID instance_id, StringParam mapping)
1424{
1425 CheckError(SDL_SetGamepadMapping(instance_id, mapping));
1426}
1427
1439inline bool HasGamepad() { return SDL_HasGamepad(); }
1440
1455{
1456 int count;
1457 auto r = reinterpret_cast<JoystickID*>(SDL_GetGamepads(&count));
1458 return OwnArray<JoystickID>(r, count);
1459}
1460
1475inline bool IsGamepad(JoystickID instance_id)
1476{
1477 return SDL_IsGamepad(instance_id);
1478}
1479
1496inline const char* GetGamepadNameForID(JoystickID instance_id)
1497{
1498 return SDL_GetGamepadNameForID(instance_id);
1499}
1500
1517inline const char* GetGamepadPathForID(JoystickID instance_id)
1518{
1519 return SDL_GetGamepadPathForID(instance_id);
1520}
1521
1538{
1539 return SDL_GetGamepadPlayerIndexForID(instance_id);
1540}
1541
1559{
1560 return SDL_GetGamepadGUIDForID(instance_id);
1561}
1562
1581{
1582 return SDL_GetGamepadVendorForID(instance_id);
1583}
1584
1603{
1604 return SDL_GetGamepadProductForID(instance_id);
1605}
1606
1625{
1626 return SDL_GetGamepadProductVersionForID(instance_id);
1627}
1628
1646{
1647 return SDL_GetGamepadTypeForID(instance_id);
1648}
1649
1667{
1668 return SDL_GetRealGamepadTypeForID(instance_id);
1669}
1670
1687inline char* GetGamepadMappingForID(JoystickID instance_id)
1688{
1689 return SDL_GetGamepadMappingForID(instance_id);
1690}
1691
1706inline Gamepad OpenGamepad(JoystickID instance_id)
1707{
1708 return Gamepad(instance_id);
1709}
1710
1724{
1725 return {CheckError(SDL_GetGamepadFromID(instance_id))};
1726}
1727
1742{
1743 return {SDL_GetGamepadFromPlayerIndex(player_index)};
1744}
1745
1773{
1774 return {CheckError(SDL_GetGamepadProperties(gamepad))};
1775}
1776
1778{
1779 return SDL::GetGamepadProperties(m_resource);
1780}
1781
1782namespace prop::GamepadCap {
1783
1784constexpr auto MONO_LED_BOOLEAN = SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN;
1785
1786constexpr auto RGB_LED_BOOLEAN = SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN;
1787
1788constexpr auto PLAYER_LED_BOOLEAN = SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN;
1789
1790constexpr auto RUMBLE_BOOLEAN = SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN;
1791
1792constexpr auto TRIGGER_RUMBLE_BOOLEAN =
1793 SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN;
1794
1795} // namespace prop::GamepadCap
1796
1809{
1810 return CheckError(SDL_GetGamepadID(gamepad));
1811}
1812
1813inline JoystickID Gamepad::GetID() { return SDL::GetGamepadID(m_resource); }
1814
1828inline const char* GetGamepadName(GamepadParam gamepad)
1829{
1830 return SDL_GetGamepadName(gamepad);
1831}
1832
1833inline const char* Gamepad::GetName()
1834{
1835 return SDL::GetGamepadName(m_resource);
1836}
1837
1851inline const char* GetGamepadPath(GamepadParam gamepad)
1852{
1853 return SDL_GetGamepadPath(gamepad);
1854}
1855
1856inline const char* Gamepad::GetPath()
1857{
1858 return SDL::GetGamepadPath(m_resource);
1859}
1860
1874{
1875 return SDL_GetGamepadType(gamepad);
1876}
1877
1879{
1880 return SDL::GetGamepadType(m_resource);
1881}
1882
1896{
1897 return SDL_GetRealGamepadType(gamepad);
1898}
1899
1901{
1902 return SDL::GetRealGamepadType(m_resource);
1903}
1904
1920{
1921 return SDL_GetGamepadPlayerIndex(gamepad);
1922}
1923
1925{
1926 return SDL::GetGamepadPlayerIndex(m_resource);
1927}
1928
1943inline void SetGamepadPlayerIndex(GamepadParam gamepad, int player_index)
1944{
1945 CheckError(SDL_SetGamepadPlayerIndex(gamepad, player_index));
1946}
1947
1948inline void Gamepad::SetPlayerIndex(int player_index)
1949{
1950 SDL::SetGamepadPlayerIndex(m_resource, player_index);
1951}
1952
1968{
1969 return SDL_GetGamepadVendor(gamepad);
1970}
1971
1972inline Uint16 Gamepad::GetVendor() { return SDL::GetGamepadVendor(m_resource); }
1973
1989{
1990 return SDL_GetGamepadProduct(gamepad);
1991}
1992
1994{
1995 return SDL::GetGamepadProduct(m_resource);
1996}
1997
2013{
2014 return SDL_GetGamepadProductVersion(gamepad);
2015}
2016
2018{
2019 return SDL::GetGamepadProductVersion(m_resource);
2020}
2021
2035{
2036 return SDL_GetGamepadFirmwareVersion(gamepad);
2037}
2038
2040{
2041 return SDL::GetGamepadFirmwareVersion(m_resource);
2042}
2043
2056inline const char* GetGamepadSerial(GamepadParam gamepad)
2057{
2058 return SDL_GetGamepadSerial(gamepad);
2059}
2060
2061inline const char* Gamepad::GetSerial()
2062{
2063 return SDL::GetGamepadSerial(m_resource);
2064}
2065
2080{
2081 return SDL_GetGamepadSteamHandle(gamepad);
2082}
2083
2085{
2086 return SDL::GetGamepadSteamHandle(m_resource);
2087}
2088
2101{
2102 return CheckError(SDL_GetGamepadConnectionState(gamepad));
2103}
2104
2106{
2107 return SDL::GetGamepadConnectionState(m_resource);
2108}
2109
2129inline PowerState GetGamepadPowerInfo(GamepadParam gamepad, int* percent)
2130{
2131 return SDL_GetGamepadPowerInfo(gamepad, percent);
2132}
2133
2135{
2136 return SDL::GetGamepadPowerInfo(m_resource, percent);
2137}
2138
2150inline bool GamepadConnected(GamepadParam gamepad)
2151{
2152 return SDL_GamepadConnected(gamepad);
2153}
2154
2155inline bool Gamepad::Connected() { return SDL::GamepadConnected(m_resource); }
2156
2178{
2179 return {SDL_GetGamepadJoystick(gamepad)};
2180}
2181
2183{
2184 return SDL::GetGamepadJoystick(m_resource);
2185}
2186
2202inline void SetGamepadEventsEnabled(bool enabled)
2203{
2204 SDL_SetGamepadEventsEnabled(enabled);
2205}
2206
2221inline bool GamepadEventsEnabled() { return SDL_GamepadEventsEnabled(); }
2222
2235{
2236 int count;
2237 auto r = (SDL_GetGamepadBindings(gamepad, &count));
2238 return OwnArray<GamepadBinding*>(r, count);
2239}
2240
2242{
2243 return SDL::GetGamepadBindings(m_resource);
2244}
2245
2257inline void UpdateGamepads() { SDL_UpdateGamepads(); }
2258
2278{
2279 return SDL_GetGamepadTypeFromString(str);
2280}
2281
2296inline const char* GetGamepadStringForType(GamepadType type)
2297{
2298 return SDL_GetGamepadStringForType(type);
2299}
2300
2323{
2324 return SDL_GetGamepadAxisFromString(str);
2325}
2326
2341inline const char* GetGamepadStringForAxis(GamepadAxis axis)
2342{
2343 return SDL_GetGamepadStringForAxis(axis);
2344}
2345
2363inline bool GamepadHasAxis(GamepadParam gamepad, GamepadAxis axis)
2364{
2365 return SDL_GamepadHasAxis(gamepad, axis);
2366}
2367
2369{
2370 return SDL::GamepadHasAxis(m_resource, axis);
2371}
2372
2400{
2401 return SDL_GetGamepadAxis(gamepad, axis);
2402}
2403
2405{
2406 return SDL::GetGamepadAxis(m_resource, axis);
2407}
2408
2428{
2429 return SDL_GetGamepadButtonFromString(str);
2430}
2431
2447{
2448 return SDL_GetGamepadStringForButton(button);
2449}
2450
2467inline bool GamepadHasButton(GamepadParam gamepad, GamepadButton button)
2468{
2469 return SDL_GamepadHasButton(gamepad, button);
2470}
2471
2473{
2474 return SDL::GamepadHasButton(m_resource, button);
2475}
2476
2491inline bool GetGamepadButton(GamepadParam gamepad, GamepadButton button)
2492{
2493 return SDL_GetGamepadButton(gamepad, button);
2494}
2495
2497{
2498 return SDL::GetGamepadButton(m_resource, button);
2499}
2500
2515 GamepadButton button)
2516{
2517 return SDL_GetGamepadButtonLabelForType(type, button);
2518}
2519
2534 GamepadButton button)
2535{
2536 return SDL_GetGamepadButtonLabel(gamepad, button);
2537}
2538
2540{
2541 return SDL::GetGamepadButtonLabel(m_resource, button);
2542}
2543
2557{
2558 return SDL_GetNumGamepadTouchpads(gamepad);
2559}
2560
2562{
2563 return SDL::GetNumGamepadTouchpads(m_resource);
2564}
2565
2581inline int GetNumGamepadTouchpadFingers(GamepadParam gamepad, int touchpad)
2582{
2583 return SDL_GetNumGamepadTouchpadFingers(gamepad, touchpad);
2584}
2585
2586inline int Gamepad::GetNumTouchpadFingers(int touchpad)
2587{
2588 return SDL::GetNumGamepadTouchpadFingers(m_resource, touchpad);
2589}
2590
2613 int touchpad,
2614 int finger,
2615 bool* down,
2616 float* x,
2617 float* y,
2618 float* pressure)
2619{
2620 CheckError(SDL_GetGamepadTouchpadFinger(
2621 gamepad, touchpad, finger, down, x, y, pressure));
2622}
2623
2624inline void Gamepad::GetTouchpadFinger(int touchpad,
2625 int finger,
2626 bool* down,
2627 float* x,
2628 float* y,
2629 float* pressure)
2630{
2632 m_resource, touchpad, finger, down, x, y, pressure);
2633}
2634
2650inline bool GamepadHasSensor(GamepadParam gamepad, SensorType type)
2651{
2652 return SDL_GamepadHasSensor(gamepad, type);
2653}
2654
2656{
2657 return SDL::GamepadHasSensor(m_resource, type);
2658}
2659
2676 SensorType type,
2677 bool enabled)
2678{
2679 CheckError(SDL_SetGamepadSensorEnabled(gamepad, type, enabled));
2680}
2681
2682inline void Gamepad::SetSensorEnabled(SensorType type, bool enabled)
2683{
2684 SDL::SetGamepadSensorEnabled(m_resource, type, enabled);
2685}
2686
2701{
2702 return SDL_GamepadSensorEnabled(gamepad, type);
2703}
2704
2706{
2707 return SDL::GamepadSensorEnabled(m_resource, type);
2708}
2709
2722{
2723 return SDL_GetGamepadSensorDataRate(gamepad, type);
2724}
2725
2727{
2728 return SDL::GetGamepadSensorDataRate(m_resource, type);
2729}
2730
2748 SensorType type,
2749 float* data,
2750 int num_values)
2751{
2752 CheckError(SDL_GetGamepadSensorData(gamepad, type, data, num_values));
2753}
2754
2755inline void Gamepad::GetSensorData(SensorType type, float* data, int num_values)
2756{
2757 SDL::GetGamepadSensorData(m_resource, type, data, num_values);
2758}
2759
2781inline void RumbleGamepad(GamepadParam gamepad,
2782 Uint16 low_frequency_rumble,
2783 Uint16 high_frequency_rumble,
2784 Uint32 duration_ms)
2785{
2786 CheckError(SDL_RumbleGamepad(
2787 gamepad, low_frequency_rumble, high_frequency_rumble, duration_ms));
2788}
2789
2790inline void Gamepad::Rumble(Uint16 low_frequency_rumble,
2791 Uint16 high_frequency_rumble,
2792 Uint32 duration_ms)
2793{
2795 m_resource, low_frequency_rumble, high_frequency_rumble, duration_ms);
2796}
2797
2826 Uint16 left_rumble,
2827 Uint16 right_rumble,
2828 Uint32 duration_ms)
2829{
2830 CheckError(
2831 SDL_RumbleGamepadTriggers(gamepad, left_rumble, right_rumble, duration_ms));
2832}
2833
2834inline void Gamepad::RumbleTriggers(Uint16 left_rumble,
2835 Uint16 right_rumble,
2836 Uint32 duration_ms)
2837{
2839 m_resource, left_rumble, right_rumble, duration_ms);
2840}
2841
2861inline void SetGamepadLED(GamepadParam gamepad,
2862 Uint8 red,
2863 Uint8 green,
2864 Uint8 blue)
2865{
2866 CheckError(SDL_SetGamepadLED(gamepad, red, green, blue));
2867}
2868
2869inline void Gamepad::SetLED(Uint8 red, Uint8 green, Uint8 blue)
2870{
2871 SDL::SetGamepadLED(m_resource, red, green, blue);
2872}
2873
2886inline void SendGamepadEffect(GamepadParam gamepad, const void* data, int size)
2887{
2888 CheckError(SDL_SendGamepadEffect(gamepad, data, size));
2889}
2890
2891inline void Gamepad::SendEffect(const void* data, int size)
2892{
2893 SDL::SendGamepadEffect(m_resource, data, size);
2894}
2895
2907inline void CloseGamepad(GamepadRaw gamepad) { SDL_CloseGamepad(gamepad); }
2908
2910
2925 GamepadButton button)
2926{
2927 return SDL_GetGamepadAppleSFSymbolsNameForButton(gamepad, button);
2928}
2929
2931{
2932 return SDL::GetGamepadAppleSFSymbolsNameForButton(m_resource, button);
2933}
2934
2949 GamepadAxis axis)
2950{
2951 return SDL_GetGamepadAppleSFSymbolsNameForAxis(gamepad, axis);
2952}
2953
2955{
2956 return SDL::GetGamepadAppleSFSymbolsNameForAxis(m_resource, axis);
2957}
2958
2960
2961} // namespace SDL
2962
2963#endif /* SDL3PP_GAMEPAD_H_ */
The structure used to identify an SDL gamepad.
Definition: SDL3pp_gamepad.h:418
Gamepad(JoystickID instance_id)
Open a gamepad for use.
Definition: SDL3pp_gamepad.h:469
constexpr Gamepad(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_gamepad.h:423
constexpr Gamepad & operator=(const Gamepad &other) noexcept=default
Assignment operator.
constexpr GamepadRaw release() noexcept
Retrieves underlying GamepadRaw and clear this.
Definition: SDL3pp_gamepad.h:493
constexpr Gamepad(Gamepad &&other) noexcept
Move constructor.
Definition: SDL3pp_gamepad.h:446
constexpr Gamepad(const GamepadRaw resource) noexcept
Constructs from GamepadParam.
Definition: SDL3pp_gamepad.h:435
constexpr Gamepad(const Gamepad &other) noexcept=default
Copy constructor.
~Gamepad()
Destructor.
Definition: SDL3pp_gamepad.h:475
constexpr GamepadRaw get() const noexcept
Retrieves underlying GamepadRaw.
Definition: SDL3pp_gamepad.h:490
constexpr Gamepad & operator=(Gamepad &&other) noexcept
Assignment operator.
Definition: SDL3pp_gamepad.h:478
constexpr auto operator<=>(const Gamepad &other) const noexcept=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:164
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:2755
const char * GetAppleSFSymbolsNameForAxis(GamepadAxis axis)
Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
Definition: SDL3pp_gamepad.h:2954
void SetSensorEnabled(SensorType type, bool enabled)
Set whether data reporting for a gamepad sensor is enabled.
Definition: SDL3pp_gamepad.h:2682
constexpr GamepadButton GAMEPAD_BUTTON_MISC6
Additional button.
Definition: SDL3pp_gamepad.h:284
OwnArray< GamepadBinding * > GetBindings()
Get the SDL joystick layer bindings for a gamepad.
Definition: SDL3pp_gamepad.h:2241
SDL_GamepadType GamepadType
Standard gamepad types.
Definition: SDL3pp_gamepad.h:116
constexpr GamepadBindingType GAMEPAD_BINDTYPE_AXIS
GAMEPAD_BINDTYPE_AXIS.
Definition: SDL3pp_gamepad.h:387
int AddGamepadMappingsFromFile(StringParam file)
Load a set of gamepad mappings from a file.
Definition: SDL3pp_gamepad.h:1324
bool HasButton(GamepadButton button)
Query whether a gamepad has a given button.
Definition: SDL3pp_gamepad.h:2472
constexpr GamepadType GAMEPAD_TYPE_NINTENDO_SWITCH_PRO
GAMEPAD_TYPE_NINTENDO_SWITCH_PRO.
Definition: SDL3pp_gamepad.h:139
constexpr GamepadType GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT
GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT.
Definition: SDL3pp_gamepad.h:142
void Rumble(Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
Start a rumble effect on a gamepad.
Definition: SDL3pp_gamepad.h:2790
int GetNumGamepadTouchpads(GamepadParam gamepad)
Get the number of touchpads on a gamepad.
Definition: SDL3pp_gamepad.h:2556
Uint16 GetProductVersion()
Get the product version of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:2017
GamepadType GetGamepadType(GamepadParam gamepad)
Get the type of an opened gamepad.
Definition: SDL3pp_gamepad.h:1873
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_SQUARE
GAMEPAD_BUTTON_LABEL_SQUARE.
Definition: SDL3pp_gamepad.h:324
constexpr GamepadAxis GAMEPAD_AXIS_RIGHTX
GAMEPAD_AXIS_RIGHTX.
Definition: SDL3pp_gamepad.h:354
JoystickID GetGamepadID(GamepadParam gamepad)
Get the instance ID of an opened gamepad.
Definition: SDL3pp_gamepad.h:1808
const char * GetGamepadName(GamepadParam gamepad)
Get the implementation-dependent name for an opened gamepad.
Definition: SDL3pp_gamepad.h:1828
constexpr GamepadButton GAMEPAD_BUTTON_MISC4
Additional button (e.g. Nintendo GameCube right trigger click)
Definition: SDL3pp_gamepad.h:279
GamepadRef GetGamepadFromPlayerIndex(int player_index)
Get the Gamepad associated with a player index.
Definition: SDL3pp_gamepad.h:1741
constexpr GamepadAxis GAMEPAD_AXIS_LEFTY
GAMEPAD_AXIS_LEFTY.
Definition: SDL3pp_gamepad.h:351
GamepadAxis GetGamepadAxisFromString(StringParam str)
Convert a string into GamepadAxis enum.
Definition: SDL3pp_gamepad.h:2322
constexpr GamepadButton GAMEPAD_BUTTON_LEFT_PADDLE2
Lower or secondary paddle, under your left hand (e.g.
Definition: SDL3pp_gamepad.h:266
const char * GetAppleSFSymbolsNameForButton(GamepadButton button)
Return the sfSymbolsName for a given button on a gamepad on Apple platforms.
Definition: SDL3pp_gamepad.h:2930
GamepadButton GetGamepadButtonFromString(StringParam str)
Convert a string into an GamepadButton enum.
Definition: SDL3pp_gamepad.h:2427
GamepadRef GetGamepadFromID(JoystickID instance_id)
Get the Gamepad associated with a joystick instance ID, if it has been opened.
Definition: SDL3pp_gamepad.h:1723
constexpr GamepadBindingType GAMEPAD_BINDTYPE_BUTTON
GAMEPAD_BINDTYPE_BUTTON.
Definition: SDL3pp_gamepad.h:384
Uint16 GetVendor()
Get the USB vendor ID of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1972
GamepadButtonLabel GetGamepadButtonLabel(GamepadParam gamepad, GamepadButton button)
Get the label of a button on a gamepad.
Definition: SDL3pp_gamepad.h:2533
GamepadType GetType()
Get the type of an opened gamepad.
Definition: SDL3pp_gamepad.h:1878
constexpr GamepadButton GAMEPAD_BUTTON_DPAD_UP
GAMEPAD_BUTTON_DPAD_UP.
Definition: SDL3pp_gamepad.h:222
void SetGamepadLED(GamepadParam gamepad, Uint8 red, Uint8 green, Uint8 blue)
Update a gamepad's LED color.
Definition: SDL3pp_gamepad.h:2861
constexpr GamepadType GAMEPAD_TYPE_GAMECUBE
GAMEPAD_TYPE_GAMECUBE.
Definition: SDL3pp_gamepad.h:153
bool HasAxis(GamepadAxis axis)
Query whether a gamepad has a given axis.
Definition: SDL3pp_gamepad.h:2368
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_B
GAMEPAD_BUTTON_LABEL_B.
Definition: SDL3pp_gamepad.h:309
bool GamepadEventsEnabled()
Query the state of gamepad event processing.
Definition: SDL3pp_gamepad.h:2221
GamepadType GetRealGamepadType(GamepadParam gamepad)
Get the type of an opened gamepad, ignoring any mapping override.
Definition: SDL3pp_gamepad.h:1895
constexpr GamepadButton GAMEPAD_BUTTON_LEFT_SHOULDER
GAMEPAD_BUTTON_LEFT_SHOULDER.
Definition: SDL3pp_gamepad.h:216
constexpr GamepadType GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR
GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR.
Definition: SDL3pp_gamepad.h:148
GamepadType GetRealGamepadTypeForID(JoystickID instance_id)
Get the type of a gamepad, ignoring any mapping override.
Definition: SDL3pp_gamepad.h:1666
GamepadButtonLabel GetButtonLabel(GamepadButton button)
Get the label of a button on a gamepad.
Definition: SDL3pp_gamepad.h:2539
float GetGamepadSensorDataRate(GamepadParam gamepad, SensorType type)
Get the data rate (number of events per second) of a gamepad sensor.
Definition: SDL3pp_gamepad.h:2721
Uint16 GetGamepadVendorForID(JoystickID instance_id)
Get the USB vendor ID of a gamepad, if available.
Definition: SDL3pp_gamepad.h:1580
bool Connected()
Check if a gamepad has been opened and is currently connected.
Definition: SDL3pp_gamepad.h:2155
PowerState GetGamepadPowerInfo(GamepadParam gamepad, int *percent)
Get the battery state of a gamepad.
Definition: SDL3pp_gamepad.h:2129
Uint16 GetGamepadProductForID(JoystickID instance_id)
Get the USB product ID of a gamepad, if available.
Definition: SDL3pp_gamepad.h:1602
PowerState GetPowerInfo(int *percent)
Get the battery state of a gamepad.
Definition: SDL3pp_gamepad.h:2134
int GetNumTouchpads()
Get the number of touchpads on a gamepad.
Definition: SDL3pp_gamepad.h:2561
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:2825
int GetNumTouchpadFingers(int touchpad)
Get the number of supported simultaneous fingers on a touchpad on a game gamepad.
Definition: SDL3pp_gamepad.h:2586
const char * GetGamepadAppleSFSymbolsNameForAxis(GamepadParam gamepad, GamepadAxis axis)
Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.
Definition: SDL3pp_gamepad.h:2948
StringResult GetGamepadMapping(GamepadParam gamepad)
Get the current mapping of a gamepad.
Definition: SDL3pp_gamepad.h:1396
const char * GetSerial()
Get the serial number of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:2061
PropertiesRef GetProperties()
Get the properties associated with an opened gamepad.
Definition: SDL3pp_gamepad.h:1777
const char * GetName()
Get the implementation-dependent name for an opened gamepad.
Definition: SDL3pp_gamepad.h:1833
const char * GetGamepadNameForID(JoystickID instance_id)
Get the implementation dependent name of a gamepad.
Definition: SDL3pp_gamepad.h:1496
OwnArray< char * > GetGamepadMappings()
Get the current gamepad mappings.
Definition: SDL3pp_gamepad.h:1352
constexpr GamepadButton GAMEPAD_BUTTON_DPAD_LEFT
GAMEPAD_BUTTON_DPAD_LEFT.
Definition: SDL3pp_gamepad.h:228
GUID GetGamepadGUIDForID(JoystickID instance_id)
Get the implementation-dependent GUID of a gamepad.
Definition: SDL3pp_gamepad.h:1558
Uint16 GetGamepadVendor(GamepadParam gamepad)
Get the USB vendor ID of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1967
constexpr GamepadAxis GAMEPAD_AXIS_RIGHT_TRIGGER
GAMEPAD_AXIS_RIGHT_TRIGGER.
Definition: SDL3pp_gamepad.h:363
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:2624
void SetPlayerIndex(int player_index)
Set the player index of an opened gamepad.
Definition: SDL3pp_gamepad.h:1948
bool GamepadHasSensor(GamepadParam gamepad, SensorType type)
Return whether a gamepad has a particular sensor.
Definition: SDL3pp_gamepad.h:2650
constexpr GamepadBindingType GAMEPAD_BINDTYPE_HAT
GAMEPAD_BINDTYPE_HAT.
Definition: SDL3pp_gamepad.h:390
constexpr GamepadType GAMEPAD_TYPE_COUNT
GAMEPAD_TYPE_COUNT.
Definition: SDL3pp_gamepad.h:158
constexpr GamepadType GAMEPAD_TYPE_XBOXONE
GAMEPAD_TYPE_XBOXONE.
Definition: SDL3pp_gamepad.h:127
Uint16 GetGamepadProductVersion(GamepadParam gamepad)
Get the product version of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:2012
void RumbleTriggers(Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms)
Start a rumble effect in the gamepad's triggers.
Definition: SDL3pp_gamepad.h:2834
JoystickID GetID()
Get the instance ID of an opened gamepad.
Definition: SDL3pp_gamepad.h:1813
OwnArray< GamepadBinding * > GetGamepadBindings(GamepadParam gamepad)
Get the SDL joystick layer bindings for a gamepad.
Definition: SDL3pp_gamepad.h:2234
constexpr GamepadAxis GAMEPAD_AXIS_LEFTX
GAMEPAD_AXIS_LEFTX.
Definition: SDL3pp_gamepad.h:348
constexpr GamepadButton GAMEPAD_BUTTON_EAST
Right face button (e.g. Xbox B button)
Definition: SDL3pp_gamepad.h:192
constexpr GamepadType GAMEPAD_TYPE_STANDARD
GAMEPAD_TYPE_STANDARD.
Definition: SDL3pp_gamepad.h:121
void SendEffect(const void *data, int size)
Send a gamepad specific effect packet.
Definition: SDL3pp_gamepad.h:2891
constexpr GamepadType GAMEPAD_TYPE_PS3
GAMEPAD_TYPE_PS3.
Definition: SDL3pp_gamepad.h:130
Uint16 GetGamepadFirmwareVersion(GamepadParam gamepad)
Get the firmware version of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:2034
constexpr GamepadType GAMEPAD_TYPE_PS4
GAMEPAD_TYPE_PS4.
Definition: SDL3pp_gamepad.h:133
constexpr GamepadButton GAMEPAD_BUTTON_RIGHT_PADDLE2
Lower or secondary paddle, under your right hand (e.g.
Definition: SDL3pp_gamepad.h:259
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_CROSS
GAMEPAD_BUTTON_LABEL_CROSS.
Definition: SDL3pp_gamepad.h:318
StringResult GetMapping()
Get the current mapping of a gamepad.
Definition: SDL3pp_gamepad.h:1401
void SetGamepadSensorEnabled(GamepadParam gamepad, SensorType type, bool enabled)
Set whether data reporting for a gamepad sensor is enabled.
Definition: SDL3pp_gamepad.h:2675
constexpr GamepadButton GAMEPAD_BUTTON_SOUTH
Bottom face button (e.g. Xbox A button)
Definition: SDL3pp_gamepad.h:189
constexpr GamepadAxis GAMEPAD_AXIS_LEFT_TRIGGER
GAMEPAD_AXIS_LEFT_TRIGGER.
Definition: SDL3pp_gamepad.h:360
Uint16 GetGamepadProductVersionForID(JoystickID instance_id)
Get the product version of a gamepad, if available.
Definition: SDL3pp_gamepad.h:1624
const char * GetGamepadSerial(GamepadParam gamepad)
Get the serial number of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:2056
int GetGamepadPlayerIndexForID(JoystickID instance_id)
Get the player index of a gamepad.
Definition: SDL3pp_gamepad.h:1537
JoystickConnectionState GetConnectionState()
Get the connection state of a gamepad.
Definition: SDL3pp_gamepad.h:2105
const char * GetGamepadPathForID(JoystickID instance_id)
Get the implementation dependent path of a gamepad.
Definition: SDL3pp_gamepad.h:1517
void Close()
Close a gamepad previously opened with Gamepad.Gamepad().
Definition: SDL3pp_gamepad.h:2909
SDL_GamepadAxis GamepadAxis
The list of axes available on a gamepad.
Definition: SDL3pp_gamepad.h:343
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_UNKNOWN
GAMEPAD_BUTTON_LABEL_UNKNOWN.
Definition: SDL3pp_gamepad.h:303
SDL_Gamepad * GamepadRaw
Alias to raw representation for Gamepad.
Definition: SDL3pp_gamepad.h:75
void SetLED(Uint8 red, Uint8 green, Uint8 blue)
Update a gamepad's LED color.
Definition: SDL3pp_gamepad.h:2869
const char * GetGamepadStringForAxis(GamepadAxis axis)
Convert from an GamepadAxis enum to a string.
Definition: SDL3pp_gamepad.h:2341
GamepadType GetRealType()
Get the type of an opened gamepad, ignoring any mapping override.
Definition: SDL3pp_gamepad.h:1900
Sint16 GetAxis(GamepadAxis axis)
Get the current state of an axis control on a gamepad.
Definition: SDL3pp_gamepad.h:2404
bool HasSensor(SensorType type)
Return whether a gamepad has a particular sensor.
Definition: SDL3pp_gamepad.h:2655
constexpr GamepadButton GAMEPAD_BUTTON_BACK
GAMEPAD_BUTTON_BACK.
Definition: SDL3pp_gamepad.h:201
Uint16 GetProduct()
Get the USB product ID of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1993
bool GetGamepadButton(GamepadParam gamepad, GamepadButton button)
Get the current state of a button on a gamepad.
Definition: SDL3pp_gamepad.h:2491
StringResult GetGamepadMappingForGUID(GUID guid)
Get the gamepad mapping string for a given GUID.
Definition: SDL3pp_gamepad.h:1373
constexpr GamepadButton GAMEPAD_BUTTON_DPAD_RIGHT
GAMEPAD_BUTTON_DPAD_RIGHT.
Definition: SDL3pp_gamepad.h:231
Uint16 GetFirmwareVersion()
Get the firmware version of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:2039
Uint16 GetGamepadProduct(GamepadParam gamepad)
Get the USB product ID of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:1988
Uint64 GetSteamHandle()
Get the Steam Input handle of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:2084
SDL_GamepadBinding GamepadBinding
A mapping between one joystick input to a gamepad control.
Definition: SDL3pp_gamepad.h:408
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_X
GAMEPAD_BUTTON_LABEL_X.
Definition: SDL3pp_gamepad.h:312
GamepadButtonLabel GetGamepadButtonLabelForType(GamepadType type, GamepadButton button)
Get the label of a button on a gamepad.
Definition: SDL3pp_gamepad.h:2514
constexpr GamepadButton GAMEPAD_BUTTON_RIGHT_PADDLE1
Upper or primary paddle, under your right hand (e.g.
Definition: SDL3pp_gamepad.h:245
PropertiesRef GetGamepadProperties(GamepadParam gamepad)
Get the properties associated with an opened gamepad.
Definition: SDL3pp_gamepad.h:1772
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:1244
constexpr GamepadButton GAMEPAD_BUTTON_INVALID
GAMEPAD_BUTTON_INVALID.
Definition: SDL3pp_gamepad.h:186
constexpr GamepadAxis GAMEPAD_AXIS_RIGHTY
GAMEPAD_AXIS_RIGHTY.
Definition: SDL3pp_gamepad.h:357
JoystickRef GetGamepadJoystick(GamepadParam gamepad)
Get the underlying joystick from a gamepad.
Definition: SDL3pp_gamepad.h:2177
GamepadType GetGamepadTypeForID(JoystickID instance_id)
Get the type of a gamepad.
Definition: SDL3pp_gamepad.h:1645
float GetSensorDataRate(SensorType type)
Get the data rate (number of events per second) of a gamepad sensor.
Definition: SDL3pp_gamepad.h:2726
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_CIRCLE
GAMEPAD_BUTTON_LABEL_CIRCLE.
Definition: SDL3pp_gamepad.h:321
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_TRIANGLE
GAMEPAD_BUTTON_LABEL_TRIANGLE.
Definition: SDL3pp_gamepad.h:327
constexpr GamepadButton GAMEPAD_BUTTON_MISC3
Additional button (e.g. Nintendo GameCube left trigger click)
Definition: SDL3pp_gamepad.h:276
SDL_GamepadButtonLabel GamepadButtonLabel
The set of gamepad button labels.
Definition: SDL3pp_gamepad.h:301
char * GetGamepadMappingForID(JoystickID instance_id)
Get the mapping of a gamepad.
Definition: SDL3pp_gamepad.h:1687
constexpr GamepadButton GAMEPAD_BUTTON_LEFT_PADDLE1
Upper or primary paddle, under your left hand (e.g.
Definition: SDL3pp_gamepad.h:252
bool GamepadConnected(GamepadParam gamepad)
Check if a gamepad has been opened and is currently connected.
Definition: SDL3pp_gamepad.h:2150
Uint64 GetGamepadSteamHandle(GamepadParam gamepad)
Get the Steam Input handle of an opened gamepad, if available.
Definition: SDL3pp_gamepad.h:2079
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:2612
bool HasGamepad()
Return whether a gamepad is currently connected.
Definition: SDL3pp_gamepad.h:1439
SDL_GamepadButton GamepadButton
The list of buttons available on a gamepad.
Definition: SDL3pp_gamepad.h:184
int GetGamepadPlayerIndex(GamepadParam gamepad)
Get the player index of an opened gamepad.
Definition: SDL3pp_gamepad.h:1919
JoystickConnectionState GetGamepadConnectionState(GamepadParam gamepad)
Get the connection state of a gamepad.
Definition: SDL3pp_gamepad.h:2100
void SetGamepadPlayerIndex(GamepadParam gamepad, int player_index)
Set the player index of an opened gamepad.
Definition: SDL3pp_gamepad.h:1943
void ReloadGamepadMappings()
Reinitialize the SDL mapping database to its initial state.
Definition: SDL3pp_gamepad.h:1340
constexpr GamepadButton GAMEPAD_BUTTON_START
GAMEPAD_BUTTON_START.
Definition: SDL3pp_gamepad.h:207
const char * GetGamepadStringForButton(GamepadButton button)
Convert from an GamepadButton enum to a string.
Definition: SDL3pp_gamepad.h:2446
constexpr GamepadButton GAMEPAD_BUTTON_MISC1
Additional button (e.g.
Definition: SDL3pp_gamepad.h:239
constexpr GamepadAxis GAMEPAD_AXIS_COUNT
GAMEPAD_AXIS_COUNT.
Definition: SDL3pp_gamepad.h:366
constexpr GamepadAxis GAMEPAD_AXIS_INVALID
GAMEPAD_AXIS_INVALID.
Definition: SDL3pp_gamepad.h:345
const char * GetGamepadAppleSFSymbolsNameForButton(GamepadParam gamepad, GamepadButton button)
Return the sfSymbolsName for a given button on a gamepad on Apple platforms.
Definition: SDL3pp_gamepad.h:2924
int AddGamepadMappingsFromIO(IOStreamParam src, bool closeio)
Load a set of gamepad mappings from an IOStream.
Definition: SDL3pp_gamepad.h:1287
GamepadType GetGamepadTypeFromString(StringParam str)
Convert a string into GamepadType enum.
Definition: SDL3pp_gamepad.h:2277
bool GamepadHasAxis(GamepadParam gamepad, GamepadAxis axis)
Query whether a gamepad has a given axis.
Definition: SDL3pp_gamepad.h:2363
constexpr GamepadButton GAMEPAD_BUTTON_WEST
Left face button (e.g. Xbox X button)
Definition: SDL3pp_gamepad.h:195
bool IsGamepad(JoystickID instance_id)
Check if the given joystick is supported by the gamepad interface.
Definition: SDL3pp_gamepad.h:1475
constexpr GamepadType GAMEPAD_TYPE_XBOX360
GAMEPAD_TYPE_XBOX360.
Definition: SDL3pp_gamepad.h:124
SDL_GamepadBindingType GamepadBindingType
Types of gamepad control bindings.
Definition: SDL3pp_gamepad.h:379
constexpr GamepadType GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT
GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT.
Definition: SDL3pp_gamepad.h:145
constexpr GamepadButton GAMEPAD_BUTTON_LEFT_STICK
GAMEPAD_BUTTON_LEFT_STICK.
Definition: SDL3pp_gamepad.h:210
constexpr GamepadButton GAMEPAD_BUTTON_RIGHT_STICK
GAMEPAD_BUTTON_RIGHT_STICK.
Definition: SDL3pp_gamepad.h:213
Sint16 GetGamepadAxis(GamepadParam gamepad, GamepadAxis axis)
Get the current state of an axis control on a gamepad.
Definition: SDL3pp_gamepad.h:2399
constexpr GamepadButton GAMEPAD_BUTTON_DPAD_DOWN
GAMEPAD_BUTTON_DPAD_DOWN.
Definition: SDL3pp_gamepad.h:225
constexpr GamepadButton GAMEPAD_BUTTON_MISC5
Additional button.
Definition: SDL3pp_gamepad.h:281
void SetGamepadMapping(JoystickID instance_id, StringParam mapping)
Set the current mapping of a joystick or gamepad.
Definition: SDL3pp_gamepad.h:1423
void GetGamepadSensorData(GamepadParam gamepad, SensorType type, float *data, int num_values)
Get the current state of a gamepad sensor.
Definition: SDL3pp_gamepad.h:2747
int GetNumGamepadTouchpadFingers(GamepadParam gamepad, int touchpad)
Get the number of supported simultaneous fingers on a touchpad on a game gamepad.
Definition: SDL3pp_gamepad.h:2581
void SetGamepadEventsEnabled(bool enabled)
Set the state of gamepad event processing.
Definition: SDL3pp_gamepad.h:2202
constexpr GamepadType GAMEPAD_TYPE_PS5
GAMEPAD_TYPE_PS5.
Definition: SDL3pp_gamepad.h:136
constexpr GamepadButton GAMEPAD_BUTTON_MISC2
Additional button.
Definition: SDL3pp_gamepad.h:272
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_Y
GAMEPAD_BUTTON_LABEL_Y.
Definition: SDL3pp_gamepad.h:315
bool GetButton(GamepadButton button)
Get the current state of a button on a gamepad.
Definition: SDL3pp_gamepad.h:2496
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:2781
JoystickRef GetJoystick()
Get the underlying joystick from a gamepad.
Definition: SDL3pp_gamepad.h:2182
Gamepad OpenGamepad(JoystickID instance_id)
Open a gamepad for use.
Definition: SDL3pp_gamepad.h:1706
void UpdateGamepads()
Manually pump gamepad updates if not using the loop.
Definition: SDL3pp_gamepad.h:2257
OwnArray< JoystickID > GetGamepads()
Get a list of currently connected gamepads.
Definition: SDL3pp_gamepad.h:1454
constexpr GamepadButton GAMEPAD_BUTTON_TOUCHPAD
PS4/PS5 touchpad button.
Definition: SDL3pp_gamepad.h:269
const char * GetGamepadStringForType(GamepadType type)
Convert from an GamepadType enum to a string.
Definition: SDL3pp_gamepad.h:2296
constexpr GamepadButton GAMEPAD_BUTTON_GUIDE
GAMEPAD_BUTTON_GUIDE.
Definition: SDL3pp_gamepad.h:204
int GetPlayerIndex()
Get the player index of an opened gamepad.
Definition: SDL3pp_gamepad.h:1924
bool SensorEnabled(SensorType type)
Query whether sensor data reporting is enabled for a gamepad.
Definition: SDL3pp_gamepad.h:2705
constexpr GamepadButtonLabel GAMEPAD_BUTTON_LABEL_A
GAMEPAD_BUTTON_LABEL_A.
Definition: SDL3pp_gamepad.h:306
constexpr GamepadButton GAMEPAD_BUTTON_COUNT
GAMEPAD_BUTTON_COUNT.
Definition: SDL3pp_gamepad.h:287
const char * GetGamepadPath(GamepadParam gamepad)
Get the implementation-dependent path for an opened gamepad.
Definition: SDL3pp_gamepad.h:1851
const char * GetPath()
Get the implementation-dependent path for an opened gamepad.
Definition: SDL3pp_gamepad.h:1856
void SendGamepadEffect(GamepadParam gamepad, const void *data, int size)
Send a gamepad specific effect packet.
Definition: SDL3pp_gamepad.h:2886
bool GamepadHasButton(GamepadParam gamepad, GamepadButton button)
Query whether a gamepad has a given button.
Definition: SDL3pp_gamepad.h:2467
constexpr GamepadBindingType GAMEPAD_BINDTYPE_NONE
GAMEPAD_BINDTYPE_NONE.
Definition: SDL3pp_gamepad.h:381
void CloseGamepad(GamepadRaw gamepad)
Close a gamepad previously opened with Gamepad.Gamepad().
Definition: SDL3pp_gamepad.h:2907
constexpr GamepadType GAMEPAD_TYPE_UNKNOWN
GAMEPAD_TYPE_UNKNOWN.
Definition: SDL3pp_gamepad.h:118
bool GamepadSensorEnabled(GamepadParam gamepad, SensorType type)
Query whether sensor data reporting is enabled for a gamepad.
Definition: SDL3pp_gamepad.h:2700
constexpr GamepadButton GAMEPAD_BUTTON_NORTH
Top face button (e.g. Xbox Y button)
Definition: SDL3pp_gamepad.h:198
constexpr GamepadButton GAMEPAD_BUTTON_RIGHT_SHOULDER
GAMEPAD_BUTTON_RIGHT_SHOULDER.
Definition: SDL3pp_gamepad.h:219
SDL_JoystickConnectionState JoystickConnectionState
Possible connection states for a joystick device.
Definition: SDL3pp_joystick.h:386
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:82
constexpr GamepadParam(GamepadRaw value)
Constructs from GamepadRaw.
Definition: SDL3pp_gamepad.h:86
constexpr auto operator<=>(const GamepadParam &other) const =default
Comparison.
constexpr GamepadParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_gamepad.h:92
GamepadRaw value
parameter's GamepadRaw
Definition: SDL3pp_gamepad.h:83
Semi-safe reference for Gamepad.
Definition: SDL3pp_gamepad.h:1168
GamepadRef(GamepadParam resource) noexcept
Constructs from GamepadParam.
Definition: SDL3pp_gamepad.h:1178
~GamepadRef()
Destructor.
Definition: SDL3pp_gamepad.h:1199
GamepadRef(GamepadRaw resource) noexcept
Constructs from GamepadParam.
Definition: SDL3pp_gamepad.h:1190
constexpr GamepadRef(const GamepadRef &other) noexcept=default
Copy constructor.
Safely wrap IOStream for non owning parameters.
Definition: SDL3pp_iostream.h:34
Semi-safe reference for Joystick.
Definition: SDL3pp_joystick.h:1210
Semi-safe reference for Properties.
Definition: SDL3pp_properties.h:716
A simple std::string-like interface for SDL allocated strings.
Definition: SDL3pp_strings.h:153