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
68// Forward decl
69struct Gamepad;
70
72using GamepadRaw = SDL_Gamepad*;
73
74// Forward decl
75struct GamepadRef;
76
79{
81
84 : value(value)
85 {
86 }
87
89 constexpr GamepadParam(std::nullptr_t _ = nullptr)
90 : value(nullptr)
91 {
92 }
93
95 constexpr explicit operator bool() const { return !!value; }
96
98 constexpr auto operator<=>(const GamepadParam& other) const = default;
99
101 constexpr operator GamepadRaw() const { return value; }
102};
103
113using GamepadType = SDL_GamepadType;
114
116 SDL_GAMEPAD_TYPE_UNKNOWN;
117
119 SDL_GAMEPAD_TYPE_STANDARD;
120
122 SDL_GAMEPAD_TYPE_XBOX360;
123
125 SDL_GAMEPAD_TYPE_XBOXONE;
126
128 SDL_GAMEPAD_TYPE_PS3;
129
131 SDL_GAMEPAD_TYPE_PS4;
132
134 SDL_GAMEPAD_TYPE_PS5;
135
137 SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO;
138
140 SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT;
141
143 SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT;
144
146 SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR;
147
149 SDL_GAMEPAD_TYPE_COUNT;
150
173using GamepadButton = SDL_GamepadButton;
174
176 SDL_GAMEPAD_BUTTON_INVALID;
177
179 SDL_GAMEPAD_BUTTON_SOUTH;
180
182 SDL_GAMEPAD_BUTTON_EAST;
183
185 SDL_GAMEPAD_BUTTON_WEST;
186
188 SDL_GAMEPAD_BUTTON_NORTH;
189
191 SDL_GAMEPAD_BUTTON_BACK;
192
194 SDL_GAMEPAD_BUTTON_GUIDE;
195
197 SDL_GAMEPAD_BUTTON_START;
198
200 SDL_GAMEPAD_BUTTON_LEFT_STICK;
201
203 SDL_GAMEPAD_BUTTON_RIGHT_STICK;
204
206 SDL_GAMEPAD_BUTTON_LEFT_SHOULDER;
207
209 SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER;
210
212 SDL_GAMEPAD_BUTTON_DPAD_UP;
213
215 SDL_GAMEPAD_BUTTON_DPAD_DOWN;
216
218 SDL_GAMEPAD_BUTTON_DPAD_LEFT;
219
221 SDL_GAMEPAD_BUTTON_DPAD_RIGHT;
222
228constexpr GamepadButton GAMEPAD_BUTTON_MISC1 = SDL_GAMEPAD_BUTTON_MISC1;
229
232 SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1;
233
236 SDL_GAMEPAD_BUTTON_LEFT_PADDLE1;
237
242 SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2;
243
246 SDL_GAMEPAD_BUTTON_LEFT_PADDLE2;
247
249 SDL_GAMEPAD_BUTTON_TOUCHPAD;
250
252 SDL_GAMEPAD_BUTTON_MISC2;
253
255 SDL_GAMEPAD_BUTTON_MISC3;
256
258 SDL_GAMEPAD_BUTTON_MISC4;
259
261 SDL_GAMEPAD_BUTTON_MISC5;
262
264 SDL_GAMEPAD_BUTTON_MISC6;
265
267 SDL_GAMEPAD_BUTTON_COUNT;
268
280using GamepadButtonLabel = SDL_GamepadButtonLabel;
281
283 SDL_GAMEPAD_BUTTON_LABEL_UNKNOWN;
284
286 SDL_GAMEPAD_BUTTON_LABEL_A;
287
289 SDL_GAMEPAD_BUTTON_LABEL_B;
290
292 SDL_GAMEPAD_BUTTON_LABEL_X;
293
295 SDL_GAMEPAD_BUTTON_LABEL_Y;
296
298 SDL_GAMEPAD_BUTTON_LABEL_CROSS;
299
301 SDL_GAMEPAD_BUTTON_LABEL_CIRCLE;
302
304 SDL_GAMEPAD_BUTTON_LABEL_SQUARE;
305
307 SDL_GAMEPAD_BUTTON_LABEL_TRIANGLE;
308
322using GamepadAxis = SDL_GamepadAxis;
323
325 SDL_GAMEPAD_AXIS_INVALID;
326
328 SDL_GAMEPAD_AXIS_LEFTX;
329
331 SDL_GAMEPAD_AXIS_LEFTY;
332
334 SDL_GAMEPAD_AXIS_RIGHTX;
335
337 SDL_GAMEPAD_AXIS_RIGHTY;
338
340 SDL_GAMEPAD_AXIS_LEFT_TRIGGER;
341
343 SDL_GAMEPAD_AXIS_RIGHT_TRIGGER;
344
346 SDL_GAMEPAD_AXIS_COUNT;
347
358using GamepadBindingType = SDL_GamepadBindingType;
359
361 SDL_GAMEPAD_BINDTYPE_NONE;
362
364 SDL_GAMEPAD_BINDTYPE_BUTTON;
365
367 SDL_GAMEPAD_BINDTYPE_AXIS;
368
370 SDL_GAMEPAD_BINDTYPE_HAT;
371
387using GamepadBinding = SDL_GamepadBinding;
388
397{
398 GamepadRaw m_resource = nullptr;
399
400public:
402 constexpr Gamepad() = default;
403
411 constexpr explicit Gamepad(const GamepadRaw resource)
412 : m_resource(resource)
413 {
414 }
415
417 constexpr Gamepad(const Gamepad& other) = delete;
418
420 constexpr Gamepad(Gamepad&& other)
421 : Gamepad(other.release())
422 {
423 }
424
425 constexpr Gamepad(const GamepadRef& other) = delete;
426
427 constexpr Gamepad(GamepadRef&& other) = delete;
428
441 Gamepad(JoystickID instance_id)
442 : m_resource(SDL_OpenGamepad(instance_id))
443 {
444 }
445
447 ~Gamepad() { SDL_CloseGamepad(m_resource); }
448
451 {
452 std::swap(m_resource, other.m_resource);
453 return *this;
454 }
455
457 constexpr GamepadRaw get() const { return m_resource; }
458
460 constexpr GamepadRaw release()
461 {
462 auto r = m_resource;
463 m_resource = nullptr;
464 return r;
465 }
466
468 constexpr auto operator<=>(const Gamepad& other) const = default;
469
471 constexpr bool operator==(std::nullptr_t _) const { return !m_resource; }
472
474 constexpr explicit operator bool() const { return !!m_resource; }
475
477 constexpr operator GamepadParam() const { return {m_resource}; }
478
486 void Close();
487
504
529
539
550 const char* GetName();
551
562 const char* GetPath();
563
574
585
597 int GetPlayerIndex();
598
610 void SetPlayerIndex(int player_index);
611
624
637
650
661
672 const char* GetSerial();
673
685
695
713 PowerState GetPowerInfo(int* percent);
714
723 bool Connected();
724
743
755 SDL_GamepadBinding** GetBindings(int* count);
756
771 bool HasAxis(GamepadAxis axis);
772
795
809 bool HasButton(GamepadButton button);
810
822 bool GetButton(GamepadButton button);
823
835
845 int GetNumTouchpads();
846
859 int GetNumTouchpadFingers(int touchpad);
860
879 void GetTouchpadFinger(int touchpad,
880 int finger,
881 bool* down,
882 float* x,
883 float* y,
884 float* pressure);
885
898 bool HasSensor(SensorType type);
899
912 void SetSensorEnabled(SensorType type, bool enabled);
913
924 bool SensorEnabled(SensorType type);
925
934 float GetSensorDataRate(SensorType type);
935
949 void GetSensorData(SensorType type, float* data, int num_values);
950
969 void Rumble(Uint16 low_frequency_rumble,
970 Uint16 high_frequency_rumble,
971 Uint32 duration_ms);
972
997 void RumbleTriggers(Uint16 left_rumble,
998 Uint16 right_rumble,
999 Uint32 duration_ms);
1000
1017 void SetLED(Uint8 red, Uint8 green, Uint8 blue);
1018
1028 void SendEffect(const void* data, int size);
1029
1042
1053 const char* GetAppleSFSymbolsNameForAxis(GamepadAxis axis);
1054};
1055
1058{
1067 : Gamepad(resource.value)
1068 {
1069 }
1070
1073 : Gamepad(other.get())
1074 {
1075 }
1076
1079};
1080
1124{
1125 return SDL_AddGamepadMapping(mapping);
1126}
1127
1166inline int AddGamepadMappingsFromIO(IOStreamParam src, bool closeio)
1167{
1168 return SDL_AddGamepadMappingsFromIO(src, closeio);
1169}
1170
1204{
1205 return SDL_AddGamepadMappingsFromFile(file);
1206}
1207
1217inline void ReloadGamepadMappings() { CheckError(SDL_ReloadGamepadMappings()); }
1218
1228{
1229 int count;
1230 auto data = SDL_GetGamepadMappings(&count);
1231 return OwnArray<char*>(data);
1232}
1233
1247{
1248 return StringResult(SDL_GetGamepadMappingForGUID(guid));
1249}
1250
1268{
1269 return StringResult(SDL_GetGamepadMapping(gamepad));
1270}
1271
1273{
1274 return SDL::GetGamepadMapping(m_resource);
1275}
1276
1292inline void SetGamepadMapping(JoystickID instance_id, StringParam mapping)
1293{
1294 CheckError(SDL_SetGamepadMapping(instance_id, mapping));
1295}
1296
1306inline bool HasGamepad() { return SDL_HasGamepad(); }
1307
1320{
1321 int count;
1322 auto r = reinterpret_cast<JoystickID*>(SDL_GetGamepads(&count));
1323 return OwnArray<JoystickID>(r, count);
1324}
1325
1338inline bool IsGamepad(JoystickID instance_id)
1339{
1340 return SDL_IsGamepad(instance_id);
1341}
1342
1357inline const char* GetGamepadNameForID(JoystickID instance_id)
1358{
1359 return SDL_GetGamepadNameForID(instance_id);
1360}
1361
1376inline const char* GetGamepadPathForID(JoystickID instance_id)
1377{
1378 return SDL_GetGamepadPathForID(instance_id);
1379}
1380
1395{
1396 return SDL_GetGamepadPlayerIndexForID(instance_id);
1397}
1398
1414{
1415 return SDL_GetGamepadGUIDForID(instance_id);
1416}
1417
1434{
1435 return SDL_GetGamepadVendorForID(instance_id);
1436}
1437
1454{
1455 return SDL_GetGamepadProductForID(instance_id);
1456}
1457
1474{
1475 return SDL_GetGamepadProductVersionForID(instance_id);
1476}
1477
1493{
1494 return SDL_GetGamepadTypeForID(instance_id);
1495}
1496
1512{
1513 return SDL_GetRealGamepadTypeForID(instance_id);
1514}
1515
1530inline char* GetGamepadMappingForID(JoystickID instance_id)
1531{
1532 return SDL_GetGamepadMappingForID(instance_id);
1533}
1534
1547inline Gamepad OpenGamepad(JoystickID instance_id)
1548{
1549 return Gamepad(instance_id);
1550}
1551
1563{
1564 return {CheckError(SDL_GetGamepadFromID(instance_id))};
1565}
1566
1579{
1580 return {SDL_GetGamepadFromPlayerIndex(player_index)};
1581}
1582
1608{
1609 return {CheckError(SDL_GetGamepadProperties(gamepad))};
1610}
1611
1613{
1614 return SDL::GetGamepadProperties(m_resource);
1615}
1616
1617namespace prop::GamepadCap {
1618
1619constexpr auto MONO_LED_BOOLEAN = SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN;
1620
1621constexpr auto RGB_LED_BOOLEAN = SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN;
1622
1623constexpr auto PLAYER_LED_BOOLEAN = SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN;
1624
1625constexpr auto RUMBLE_BOOLEAN = SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN;
1626
1627constexpr auto TRIGGER_RUMBLE_BOOLEAN =
1628 SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN;
1629
1630} // namespace prop::GamepadCap
1631
1642{
1643 return CheckError(SDL_GetGamepadID(gamepad));
1644}
1645
1646inline JoystickID Gamepad::GetID() { return SDL::GetGamepadID(m_resource); }
1647
1659inline const char* GetGamepadName(GamepadParam gamepad)
1660{
1661 return SDL_GetGamepadName(gamepad);
1662}
1663
1664inline const char* Gamepad::GetName()
1665{
1666 return SDL::GetGamepadName(m_resource);
1667}
1668
1680inline const char* GetGamepadPath(GamepadParam gamepad)
1681{
1682 return SDL_GetGamepadPath(gamepad);
1683}
1684
1685inline const char* Gamepad::GetPath()
1686{
1687 return SDL::GetGamepadPath(m_resource);
1688}
1689
1701{
1702 return SDL_GetGamepadType(gamepad);
1703}
1704
1706{
1707 return SDL::GetGamepadType(m_resource);
1708}
1709
1721{
1722 return SDL_GetRealGamepadType(gamepad);
1723}
1724
1726{
1727 return SDL::GetRealGamepadType(m_resource);
1728}
1729
1743{
1744 return SDL_GetGamepadPlayerIndex(gamepad);
1745}
1746
1748{
1749 return SDL::GetGamepadPlayerIndex(m_resource);
1750}
1751
1764inline void SetGamepadPlayerIndex(GamepadParam gamepad, int player_index)
1765{
1766 CheckError(SDL_SetGamepadPlayerIndex(gamepad, player_index));
1767}
1768
1769inline void Gamepad::SetPlayerIndex(int player_index)
1770{
1771 SDL::SetGamepadPlayerIndex(m_resource, player_index);
1772}
1773
1787{
1788 return SDL_GetGamepadVendor(gamepad);
1789}
1790
1791inline Uint16 Gamepad::GetVendor() { return SDL::GetGamepadVendor(m_resource); }
1792
1806{
1807 return SDL_GetGamepadProduct(gamepad);
1808}
1809
1811{
1812 return SDL::GetGamepadProduct(m_resource);
1813}
1814
1828{
1829 return SDL_GetGamepadProductVersion(gamepad);
1830}
1831
1833{
1834 return SDL::GetGamepadProductVersion(m_resource);
1835}
1836
1848{
1849 return SDL_GetGamepadFirmwareVersion(gamepad);
1850}
1851
1853{
1854 return SDL::GetGamepadFirmwareVersion(m_resource);
1855}
1856
1867inline const char* GetGamepadSerial(GamepadParam gamepad)
1868{
1869 return SDL_GetGamepadSerial(gamepad);
1870}
1871
1872inline const char* Gamepad::GetSerial()
1873{
1874 return SDL::GetGamepadSerial(m_resource);
1875}
1876
1889{
1890 return SDL_GetGamepadSteamHandle(gamepad);
1891}
1892
1894{
1895 return SDL::GetGamepadSteamHandle(m_resource);
1896}
1897
1908{
1909 return CheckError(SDL_GetGamepadConnectionState(gamepad));
1910}
1911
1913{
1914 return SDL::GetGamepadConnectionState(m_resource);
1915}
1916
1934inline PowerState GetGamepadPowerInfo(GamepadParam gamepad, int* percent)
1935{
1936 return SDL_GetGamepadPowerInfo(gamepad, percent);
1937}
1938
1940{
1941 return SDL::GetGamepadPowerInfo(m_resource, percent);
1942}
1943
1953inline bool GamepadConnected(GamepadParam gamepad)
1954{
1955 return SDL_GamepadConnected(gamepad);
1956}
1957
1958inline bool Gamepad::Connected() { return SDL::GamepadConnected(m_resource); }
1959
1979{
1980 return {SDL_GetGamepadJoystick(gamepad)};
1981}
1982
1984{
1985 return SDL::GetGamepadJoystick(m_resource);
1986}
1987
2001inline void SetGamepadEventsEnabled(bool enabled)
2002{
2003 SDL_SetGamepadEventsEnabled(enabled);
2004}
2005
2018inline bool GamepadEventsEnabled() { return SDL_GamepadEventsEnabled(); }
2019
2032inline SDL_GamepadBinding** GetGamepadBindings(GamepadParam gamepad, int* count)
2033{
2034 return SDL_GetGamepadBindings(gamepad, count);
2035}
2036
2037inline SDL_GamepadBinding** Gamepad::GetBindings(int* count)
2038{
2039 return SDL::GetGamepadBindings(m_resource, count);
2040}
2041
2051inline void UpdateGamepads() { SDL_UpdateGamepads(); }
2052
2070{
2071 return SDL_GetGamepadTypeFromString(str);
2072}
2073
2086inline const char* GetGamepadStringForType(GamepadType type)
2087{
2088 return SDL_GetGamepadStringForType(type);
2089}
2090
2111{
2112 return SDL_GetGamepadAxisFromString(str);
2113}
2114
2127inline const char* GetGamepadStringForAxis(GamepadAxis axis)
2128{
2129 return SDL_GetGamepadStringForAxis(axis);
2130}
2131
2147inline bool GamepadHasAxis(GamepadParam gamepad, GamepadAxis axis)
2148{
2149 return SDL_GamepadHasAxis(gamepad, axis);
2150}
2151
2153{
2154 return SDL::GamepadHasAxis(m_resource, axis);
2155}
2156
2180{
2181 return CheckError(SDL_GetGamepadAxis(gamepad, axis));
2182}
2183
2185{
2186 return SDL::GetGamepadAxis(m_resource, axis);
2187}
2188
2206{
2207 return SDL_GetGamepadButtonFromString(str);
2208}
2209
2223{
2224 return SDL_GetGamepadStringForButton(button);
2225}
2226
2241inline bool GamepadHasButton(GamepadParam gamepad, GamepadButton button)
2242{
2243 return SDL_GamepadHasButton(gamepad, button);
2244}
2245
2247{
2248 return SDL::GamepadHasButton(m_resource, button);
2249}
2250
2263inline bool GetGamepadButton(GamepadParam gamepad, GamepadButton button)
2264{
2265 return SDL_GetGamepadButton(gamepad, button);
2266}
2267
2269{
2270 return SDL::GetGamepadButton(m_resource, button);
2271}
2272
2285 GamepadButton button)
2286{
2287 return SDL_GetGamepadButtonLabelForType(type, button);
2288}
2289
2302 GamepadButton button)
2303{
2304 return SDL_GetGamepadButtonLabel(gamepad, button);
2305}
2306
2308{
2309 return SDL::GetGamepadButtonLabel(m_resource, button);
2310}
2311
2323{
2324 return SDL_GetNumGamepadTouchpads(gamepad);
2325}
2326
2328{
2329 return SDL::GetNumGamepadTouchpads(m_resource);
2330}
2331
2345inline int GetNumGamepadTouchpadFingers(GamepadParam gamepad, int touchpad)
2346{
2347 return SDL_GetNumGamepadTouchpadFingers(gamepad, touchpad);
2348}
2349
2350inline int Gamepad::GetNumTouchpadFingers(int touchpad)
2351{
2352 return SDL::GetNumGamepadTouchpadFingers(m_resource, touchpad);
2353}
2354
2375 int touchpad,
2376 int finger,
2377 bool* down,
2378 float* x,
2379 float* y,
2380 float* pressure)
2381{
2382 CheckError(SDL_GetGamepadTouchpadFinger(
2383 gamepad, touchpad, finger, down, x, y, pressure));
2384}
2385
2386inline void Gamepad::GetTouchpadFinger(int touchpad,
2387 int finger,
2388 bool* down,
2389 float* x,
2390 float* y,
2391 float* pressure)
2392{
2394 m_resource, touchpad, finger, down, x, y, pressure);
2395}
2396
2410inline bool GamepadHasSensor(GamepadParam gamepad, SensorType type)
2411{
2412 return SDL_GamepadHasSensor(gamepad, type);
2413}
2414
2416{
2417 return SDL::GamepadHasSensor(m_resource, type);
2418}
2419
2434 SensorType type,
2435 bool enabled)
2436{
2437 CheckError(SDL_SetGamepadSensorEnabled(gamepad, type, enabled));
2438}
2439
2440inline void Gamepad::SetSensorEnabled(SensorType type, bool enabled)
2441{
2442 SDL::SetGamepadSensorEnabled(m_resource, type, enabled);
2443}
2444
2457{
2458 return SDL_GamepadSensorEnabled(gamepad, type);
2459}
2460
2462{
2463 return SDL::GamepadSensorEnabled(m_resource, type);
2464}
2465
2476{
2477 return SDL_GetGamepadSensorDataRate(gamepad, type);
2478}
2479
2481{
2482 return SDL::GetGamepadSensorDataRate(m_resource, type);
2483}
2484
2500 SensorType type,
2501 float* data,
2502 int num_values)
2503{
2504 CheckError(SDL_GetGamepadSensorData(gamepad, type, data, num_values));
2505}
2506
2507inline void Gamepad::GetSensorData(SensorType type, float* data, int num_values)
2508{
2509 SDL::GetGamepadSensorData(m_resource, type, data, num_values);
2510}
2511
2531inline void RumbleGamepad(GamepadParam gamepad,
2532 Uint16 low_frequency_rumble,
2533 Uint16 high_frequency_rumble,
2534 Uint32 duration_ms)
2535{
2536 CheckError(SDL_RumbleGamepad(
2537 gamepad, low_frequency_rumble, high_frequency_rumble, duration_ms));
2538}
2539
2540inline void Gamepad::Rumble(Uint16 low_frequency_rumble,
2541 Uint16 high_frequency_rumble,
2542 Uint32 duration_ms)
2543{
2545 m_resource, low_frequency_rumble, high_frequency_rumble, duration_ms);
2546}
2547
2574 Uint16 left_rumble,
2575 Uint16 right_rumble,
2576 Uint32 duration_ms)
2577{
2578 CheckError(
2579 SDL_RumbleGamepadTriggers(gamepad, left_rumble, right_rumble, duration_ms));
2580}
2581
2582inline void Gamepad::RumbleTriggers(Uint16 left_rumble,
2583 Uint16 right_rumble,
2584 Uint32 duration_ms)
2585{
2587 m_resource, left_rumble, right_rumble, duration_ms);
2588}
2589
2607inline void SetGamepadLED(GamepadParam gamepad,
2608 Uint8 red,
2609 Uint8 green,
2610 Uint8 blue)
2611{
2612 CheckError(SDL_SetGamepadLED(gamepad, red, green, blue));
2613}
2614
2615inline void Gamepad::SetLED(Uint8 red, Uint8 green, Uint8 blue)
2616{
2617 SDL::SetGamepadLED(m_resource, red, green, blue);
2618}
2619
2630inline void SendGamepadEffect(GamepadParam gamepad, const void* data, int size)
2631{
2632 CheckError(SDL_SendGamepadEffect(gamepad, data, size));
2633}
2634
2635inline void Gamepad::SendEffect(const void* data, int size)
2636{
2637 SDL::SendGamepadEffect(m_resource, data, size);
2638}
2639
2649inline void CloseGamepad(GamepadRaw gamepad) { SDL_CloseGamepad(gamepad); }
2650
2652
2665 GamepadButton button)
2666{
2667 return SDL_GetGamepadAppleSFSymbolsNameForButton(gamepad, button);
2668}
2669
2671{
2672 return SDL::GetGamepadAppleSFSymbolsNameForButton(m_resource, button);
2673}
2674
2687 GamepadAxis axis)
2688{
2689 return SDL_GetGamepadAppleSFSymbolsNameForAxis(gamepad, axis);
2690}
2691
2693{
2694 return SDL::GetGamepadAppleSFSymbolsNameForAxis(m_resource, axis);
2695}
2696
2698
2699} // namespace SDL
2700
2701#endif /* SDL3PP_GAMEPAD_H_ */
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