Path: blob/master/thirdparty/sdl/include/SDL3/SDL_gamepad.h
9912 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2025 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/2021/**22* # CategoryGamepad23*24* SDL provides a low-level joystick API, which just treats joysticks as an25* arbitrary pile of buttons, axes, and hat switches. If you're planning to26* write your own control configuration screen, this can give you a lot of27* flexibility, but that's a lot of work, and most things that we consider28* "joysticks" now are actually console-style gamepads. So SDL provides the29* gamepad API on top of the lower-level joystick functionality.30*31* The difference between a joystick and a gamepad is that a gamepad tells you32* _where_ a button or axis is on the device. You don't speak to gamepads in33* terms of arbitrary numbers like "button 3" or "axis 2" but in standard34* locations: the d-pad, the shoulder buttons, triggers, A/B/X/Y (or35* X/O/Square/Triangle, if you will).36*37* One turns a joystick into a gamepad by providing a magic configuration38* string, which tells SDL the details of a specific device: when you see this39* specific hardware, if button 2 gets pressed, this is actually D-Pad Up,40* etc.41*42* SDL has many popular controllers configured out of the box, and users can43* add their own controller details through an environment variable if it's44* otherwise unknown to SDL.45*46* In order to use these functions, SDL_Init() must have been called with the47* SDL_INIT_GAMEPAD flag. This causes SDL to scan the system for gamepads, and48* load appropriate drivers.49*50* If you would like to receive gamepad updates while the application is in51* the background, you should set the following hint before calling52* SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS53*54* Gamepads support various optional features such as rumble, color LEDs,55* touchpad, gyro, etc. The support for these features varies depending on the56* controller and OS support available. You can check for LED and rumble57* capabilities at runtime by calling SDL_GetGamepadProperties() and checking58* the various capability properties. You can check for touchpad by calling59* SDL_GetNumGamepadTouchpads() and check for gyro and accelerometer by60* calling SDL_GamepadHasSensor().61*62* By default SDL will try to use the most capable driver available, but you63* can tune which OS drivers to use with the various joystick hints in64* SDL_hints.h.65*66* Your application should always support gamepad hotplugging. On some67* platforms like Xbox, Steam Deck, etc., this is a requirement for68* certification. On other platforms, like macOS and Windows when using69* Windows.Gaming.Input, controllers may not be available at startup and will70* come in at some point after you've started processing events.71*/7273#ifndef SDL_gamepad_h_74#define SDL_gamepad_h_7576#include <SDL3/SDL_stdinc.h>77#include <SDL3/SDL_error.h>78#include <SDL3/SDL_guid.h>79#include <SDL3/SDL_iostream.h>80#include <SDL3/SDL_joystick.h>81#include <SDL3/SDL_power.h>82#include <SDL3/SDL_properties.h>83#include <SDL3/SDL_sensor.h>8485#include <SDL3/SDL_begin_code.h>86/* Set up for C function definitions, even when using C++ */87#ifdef __cplusplus88extern "C" {89#endif9091/**92* The structure used to identify an SDL gamepad93*94* \since This struct is available since SDL 3.2.0.95*/96typedef struct SDL_Gamepad SDL_Gamepad;9798/**99* Standard gamepad types.100*101* This type does not necessarily map to first-party controllers from102* Microsoft/Sony/Nintendo; in many cases, third-party controllers can report103* as these, either because they were designed for a specific console, or they104* simply most closely match that console's controllers (does it have A/B/X/Y105* buttons or X/O/Square/Triangle? Does it have a touchpad? etc).106*/107typedef enum SDL_GamepadType108{109SDL_GAMEPAD_TYPE_UNKNOWN = 0,110SDL_GAMEPAD_TYPE_STANDARD,111SDL_GAMEPAD_TYPE_XBOX360,112SDL_GAMEPAD_TYPE_XBOXONE,113SDL_GAMEPAD_TYPE_PS3,114SDL_GAMEPAD_TYPE_PS4,115SDL_GAMEPAD_TYPE_PS5,116SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO,117SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT,118SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT,119SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR,120SDL_GAMEPAD_TYPE_COUNT121} SDL_GamepadType;122123/**124* The list of buttons available on a gamepad125*126* For controllers that use a diamond pattern for the face buttons, the127* south/east/west/north buttons below correspond to the locations in the128* diamond pattern. For Xbox controllers, this would be A/B/X/Y, for Nintendo129* Switch controllers, this would be B/A/Y/X, for PlayStation controllers this130* would be Cross/Circle/Square/Triangle.131*132* For controllers that don't use a diamond pattern for the face buttons, the133* south/east/west/north buttons indicate the buttons labeled A, B, C, D, or134* 1, 2, 3, 4, or for controllers that aren't labeled, they are the primary,135* secondary, etc. buttons.136*137* The activate action is often the south button and the cancel action is138* often the east button, but in some regions this is reversed, so your game139* should allow remapping actions based on user preferences.140*141* You can query the labels for the face buttons using142* SDL_GetGamepadButtonLabel()143*144* \since This enum is available since SDL 3.2.0.145*/146typedef enum SDL_GamepadButton147{148SDL_GAMEPAD_BUTTON_INVALID = -1,149SDL_GAMEPAD_BUTTON_SOUTH, /**< Bottom face button (e.g. Xbox A button) */150SDL_GAMEPAD_BUTTON_EAST, /**< Right face button (e.g. Xbox B button) */151SDL_GAMEPAD_BUTTON_WEST, /**< Left face button (e.g. Xbox X button) */152SDL_GAMEPAD_BUTTON_NORTH, /**< Top face button (e.g. Xbox Y button) */153SDL_GAMEPAD_BUTTON_BACK,154SDL_GAMEPAD_BUTTON_GUIDE,155SDL_GAMEPAD_BUTTON_START,156SDL_GAMEPAD_BUTTON_LEFT_STICK,157SDL_GAMEPAD_BUTTON_RIGHT_STICK,158SDL_GAMEPAD_BUTTON_LEFT_SHOULDER,159SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER,160SDL_GAMEPAD_BUTTON_DPAD_UP,161SDL_GAMEPAD_BUTTON_DPAD_DOWN,162SDL_GAMEPAD_BUTTON_DPAD_LEFT,163SDL_GAMEPAD_BUTTON_DPAD_RIGHT,164SDL_GAMEPAD_BUTTON_MISC1, /**< Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button, Google Stadia capture button) */165SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, /**< Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1) */166SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, /**< Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3) */167SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, /**< Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2) */168SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, /**< Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4) */169SDL_GAMEPAD_BUTTON_TOUCHPAD, /**< PS4/PS5 touchpad button */170SDL_GAMEPAD_BUTTON_MISC2, /**< Additional button */171SDL_GAMEPAD_BUTTON_MISC3, /**< Additional button */172SDL_GAMEPAD_BUTTON_MISC4, /**< Additional button */173SDL_GAMEPAD_BUTTON_MISC5, /**< Additional button */174SDL_GAMEPAD_BUTTON_MISC6, /**< Additional button */175SDL_GAMEPAD_BUTTON_COUNT176} SDL_GamepadButton;177178/**179* The set of gamepad button labels180*181* This isn't a complete set, just the face buttons to make it easy to show182* button prompts.183*184* For a complete set, you should look at the button and gamepad type and have185* a set of symbols that work well with your art style.186*187* \since This enum is available since SDL 3.2.0.188*/189typedef enum SDL_GamepadButtonLabel190{191SDL_GAMEPAD_BUTTON_LABEL_UNKNOWN,192SDL_GAMEPAD_BUTTON_LABEL_A,193SDL_GAMEPAD_BUTTON_LABEL_B,194SDL_GAMEPAD_BUTTON_LABEL_X,195SDL_GAMEPAD_BUTTON_LABEL_Y,196SDL_GAMEPAD_BUTTON_LABEL_CROSS,197SDL_GAMEPAD_BUTTON_LABEL_CIRCLE,198SDL_GAMEPAD_BUTTON_LABEL_SQUARE,199SDL_GAMEPAD_BUTTON_LABEL_TRIANGLE200} SDL_GamepadButtonLabel;201202/**203* The list of axes available on a gamepad204*205* Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to206* SDL_JOYSTICK_AXIS_MAX, and are centered within ~8000 of zero, though207* advanced UI will allow users to set or autodetect the dead zone, which208* varies between gamepads.209*210* Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX (fully211* pressed) when reported by SDL_GetGamepadAxis(). Note that this is not the212* same range that will be reported by the lower-level SDL_GetJoystickAxis().213*214* \since This enum is available since SDL 3.2.0.215*/216typedef enum SDL_GamepadAxis217{218SDL_GAMEPAD_AXIS_INVALID = -1,219SDL_GAMEPAD_AXIS_LEFTX,220SDL_GAMEPAD_AXIS_LEFTY,221SDL_GAMEPAD_AXIS_RIGHTX,222SDL_GAMEPAD_AXIS_RIGHTY,223SDL_GAMEPAD_AXIS_LEFT_TRIGGER,224SDL_GAMEPAD_AXIS_RIGHT_TRIGGER,225SDL_GAMEPAD_AXIS_COUNT226} SDL_GamepadAxis;227228/**229* Types of gamepad control bindings.230*231* A gamepad is a collection of bindings that map arbitrary joystick buttons,232* axes and hat switches to specific positions on a generic console-style233* gamepad. This enum is used as part of SDL_GamepadBinding to specify those234* mappings.235*236* \since This enum is available since SDL 3.2.0.237*/238typedef enum SDL_GamepadBindingType239{240SDL_GAMEPAD_BINDTYPE_NONE = 0,241SDL_GAMEPAD_BINDTYPE_BUTTON,242SDL_GAMEPAD_BINDTYPE_AXIS,243SDL_GAMEPAD_BINDTYPE_HAT244} SDL_GamepadBindingType;245246/**247* A mapping between one joystick input to a gamepad control.248*249* A gamepad has a collection of several bindings, to say, for example, when250* joystick button number 5 is pressed, that should be treated like the251* gamepad's "start" button.252*253* SDL has these bindings built-in for many popular controllers, and can add254* more with a simple text string. Those strings are parsed into a collection255* of these structs to make it easier to operate on the data.256*257* \since This struct is available since SDL 3.2.0.258*259* \sa SDL_GetGamepadBindings260*/261typedef struct SDL_GamepadBinding262{263SDL_GamepadBindingType input_type;264union265{266int button;267268struct269{270int axis;271int axis_min;272int axis_max;273} axis;274275struct276{277int hat;278int hat_mask;279} hat;280281} input;282283SDL_GamepadBindingType output_type;284union285{286SDL_GamepadButton button;287288struct289{290SDL_GamepadAxis axis;291int axis_min;292int axis_max;293} axis;294295} output;296} SDL_GamepadBinding;297298299/**300* Add support for gamepads that SDL is unaware of or change the binding of an301* existing gamepad.302*303* The mapping string has the format "GUID,name,mapping", where GUID is the304* string value from SDL_GUIDToString(), name is the human readable string for305* the device and mappings are gamepad mappings to joystick ones. Under306* Windows there is a reserved GUID of "xinput" that covers all XInput307* devices. The mapping format for joystick is:308*309* - `bX`: a joystick button, index X310* - `hX.Y`: hat X with value Y311* - `aX`: axis X of the joystick312*313* Buttons can be used as a gamepad axes and vice versa.314*315* If a device with this GUID is already plugged in, SDL will generate an316* SDL_EVENT_GAMEPAD_ADDED event.317*318* This string shows an example of a valid mapping for a gamepad:319*320* ```c321* "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7"322* ```323*324* \param mapping the mapping string.325* \returns 1 if a new mapping is added, 0 if an existing mapping is updated,326* -1 on failure; call SDL_GetError() for more information.327*328* \threadsafety It is safe to call this function from any thread.329*330* \since This function is available since SDL 3.2.0.331*332* \sa SDL_AddGamepadMappingsFromFile333* \sa SDL_AddGamepadMappingsFromIO334* \sa SDL_GetGamepadMapping335* \sa SDL_GetGamepadMappingForGUID336* \sa SDL_HINT_GAMECONTROLLERCONFIG337* \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE338* \sa SDL_EVENT_GAMEPAD_ADDED339*/340extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mapping);341342/**343* Load a set of gamepad mappings from an SDL_IOStream.344*345* You can call this function several times, if needed, to load different346* database files.347*348* If a new mapping is loaded for an already known gamepad GUID, the later349* version will overwrite the one currently loaded.350*351* Any new mappings for already plugged in controllers will generate352* SDL_EVENT_GAMEPAD_ADDED events.353*354* Mappings not belonging to the current platform or with no platform field355* specified will be ignored (i.e. mappings for Linux will be ignored in356* Windows, etc).357*358* This function will load the text database entirely in memory before359* processing it, so take this into consideration if you are in a memory360* constrained environment.361*362* \param src the data stream for the mappings to be added.363* \param closeio if true, calls SDL_CloseIO() on `src` before returning, even364* in the case of an error.365* \returns the number of mappings added or -1 on failure; call SDL_GetError()366* for more information.367*368* \threadsafety It is safe to call this function from any thread.369*370* \since This function is available since SDL 3.2.0.371*372* \sa SDL_AddGamepadMapping373* \sa SDL_AddGamepadMappingsFromFile374* \sa SDL_GetGamepadMapping375* \sa SDL_GetGamepadMappingForGUID376* \sa SDL_HINT_GAMECONTROLLERCONFIG377* \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE378* \sa SDL_EVENT_GAMEPAD_ADDED379*/380extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, bool closeio);381382/**383* Load a set of gamepad mappings from a file.384*385* You can call this function several times, if needed, to load different386* database files.387*388* If a new mapping is loaded for an already known gamepad GUID, the later389* version will overwrite the one currently loaded.390*391* Any new mappings for already plugged in controllers will generate392* SDL_EVENT_GAMEPAD_ADDED events.393*394* Mappings not belonging to the current platform or with no platform field395* specified will be ignored (i.e. mappings for Linux will be ignored in396* Windows, etc).397*398* \param file the mappings file to load.399* \returns the number of mappings added or -1 on failure; call SDL_GetError()400* for more information.401*402* \threadsafety It is safe to call this function from any thread.403*404* \since This function is available since SDL 3.2.0.405*406* \sa SDL_AddGamepadMapping407* \sa SDL_AddGamepadMappingsFromIO408* \sa SDL_GetGamepadMapping409* \sa SDL_GetGamepadMappingForGUID410* \sa SDL_HINT_GAMECONTROLLERCONFIG411* \sa SDL_HINT_GAMECONTROLLERCONFIG_FILE412* \sa SDL_EVENT_GAMEPAD_ADDED413*/414extern SDL_DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromFile(const char *file);415416/**417* Reinitialize the SDL mapping database to its initial state.418*419* This will generate gamepad events as needed if device mappings change.420*421* \returns true on success or false on failure; call SDL_GetError() for more422* information.423*424* \since This function is available since SDL 3.2.0.425*/426extern SDL_DECLSPEC bool SDLCALL SDL_ReloadGamepadMappings(void);427428/**429* Get the current gamepad mappings.430*431* \param count a pointer filled in with the number of mappings returned, can432* be NULL.433* \returns an array of the mapping strings, NULL-terminated, or NULL on434* failure; call SDL_GetError() for more information. This is a435* single allocation that should be freed with SDL_free() when it is436* no longer needed.437*438* \since This function is available since SDL 3.2.0.439*/440extern SDL_DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count);441442/**443* Get the gamepad mapping string for a given GUID.444*445* \param guid a structure containing the GUID for which a mapping is desired.446* \returns a mapping string or NULL on failure; call SDL_GetError() for more447* information. This should be freed with SDL_free() when it is no448* longer needed.449*450* \since This function is available since SDL 3.2.0.451*452* \sa SDL_GetJoystickGUIDForID453* \sa SDL_GetJoystickGUID454*/455extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_GUID guid);456457/**458* Get the current mapping of a gamepad.459*460* Details about mappings are discussed with SDL_AddGamepadMapping().461*462* \param gamepad the gamepad you want to get the current mapping for.463* \returns a string that has the gamepad's mapping or NULL if no mapping is464* available; call SDL_GetError() for more information. This should465* be freed with SDL_free() when it is no longer needed.466*467* \since This function is available since SDL 3.2.0.468*469* \sa SDL_AddGamepadMapping470* \sa SDL_GetGamepadMappingForID471* \sa SDL_GetGamepadMappingForGUID472* \sa SDL_SetGamepadMapping473*/474extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMapping(SDL_Gamepad *gamepad);475476/**477* Set the current mapping of a joystick or gamepad.478*479* Details about mappings are discussed with SDL_AddGamepadMapping().480*481* \param instance_id the joystick instance ID.482* \param mapping the mapping to use for this device, or NULL to clear the483* mapping.484* \returns true on success or false on failure; call SDL_GetError() for more485* information.486*487* \since This function is available since SDL 3.2.0.488*489* \sa SDL_AddGamepadMapping490* \sa SDL_GetGamepadMapping491*/492extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping);493494/**495* Return whether a gamepad is currently connected.496*497* \returns true if a gamepad is connected, false otherwise.498*499* \since This function is available since SDL 3.2.0.500*501* \sa SDL_GetGamepads502*/503extern SDL_DECLSPEC bool SDLCALL SDL_HasGamepad(void);504505/**506* Get a list of currently connected gamepads.507*508* \param count a pointer filled in with the number of gamepads returned, may509* be NULL.510* \returns a 0 terminated array of joystick instance IDs or NULL on failure;511* call SDL_GetError() for more information. This should be freed512* with SDL_free() when it is no longer needed.513*514* \since This function is available since SDL 3.2.0.515*516* \sa SDL_HasGamepad517* \sa SDL_OpenGamepad518*/519extern SDL_DECLSPEC SDL_JoystickID * SDLCALL SDL_GetGamepads(int *count);520521/**522* Check if the given joystick is supported by the gamepad interface.523*524* \param instance_id the joystick instance ID.525* \returns true if the given joystick is supported by the gamepad interface,526* false if it isn't or it's an invalid index.527*528* \since This function is available since SDL 3.2.0.529*530* \sa SDL_GetJoysticks531* \sa SDL_OpenGamepad532*/533extern SDL_DECLSPEC bool SDLCALL SDL_IsGamepad(SDL_JoystickID instance_id);534535/**536* Get the implementation dependent name of a gamepad.537*538* This can be called before any gamepads are opened.539*540* \param instance_id the joystick instance ID.541* \returns the name of the selected gamepad. If no name can be found, this542* function returns NULL; call SDL_GetError() for more information.543*544* \since This function is available since SDL 3.2.0.545*546* \sa SDL_GetGamepadName547* \sa SDL_GetGamepads548*/549extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadNameForID(SDL_JoystickID instance_id);550551/**552* Get the implementation dependent path of a gamepad.553*554* This can be called before any gamepads are opened.555*556* \param instance_id the joystick instance ID.557* \returns the path of the selected gamepad. If no path can be found, this558* function returns NULL; call SDL_GetError() for more information.559*560* \since This function is available since SDL 3.2.0.561*562* \sa SDL_GetGamepadPath563* \sa SDL_GetGamepads564*/565extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPathForID(SDL_JoystickID instance_id);566567/**568* Get the player index of a gamepad.569*570* This can be called before any gamepads are opened.571*572* \param instance_id the joystick instance ID.573* \returns the player index of a gamepad, or -1 if it's not available.574*575* \since This function is available since SDL 3.2.0.576*577* \sa SDL_GetGamepadPlayerIndex578* \sa SDL_GetGamepads579*/580extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndexForID(SDL_JoystickID instance_id);581582/**583* Get the implementation-dependent GUID of a gamepad.584*585* This can be called before any gamepads are opened.586*587* \param instance_id the joystick instance ID.588* \returns the GUID of the selected gamepad. If called on an invalid index,589* this function returns a zero GUID.590*591* \since This function is available since SDL 3.2.0.592*593* \sa SDL_GUIDToString594* \sa SDL_GetGamepads595*/596extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetGamepadGUIDForID(SDL_JoystickID instance_id);597598/**599* Get the USB vendor ID of a gamepad, if available.600*601* This can be called before any gamepads are opened. If the vendor ID isn't602* available this function returns 0.603*604* \param instance_id the joystick instance ID.605* \returns the USB vendor ID of the selected gamepad. If called on an invalid606* index, this function returns zero.607*608* \since This function is available since SDL 3.2.0.609*610* \sa SDL_GetGamepadVendor611* \sa SDL_GetGamepads612*/613extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendorForID(SDL_JoystickID instance_id);614615/**616* Get the USB product ID of a gamepad, if available.617*618* This can be called before any gamepads are opened. If the product ID isn't619* available this function returns 0.620*621* \param instance_id the joystick instance ID.622* \returns the USB product ID of the selected gamepad. If called on an623* invalid index, this function returns zero.624*625* \since This function is available since SDL 3.2.0.626*627* \sa SDL_GetGamepadProduct628* \sa SDL_GetGamepads629*/630extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductForID(SDL_JoystickID instance_id);631632/**633* Get the product version of a gamepad, if available.634*635* This can be called before any gamepads are opened. If the product version636* isn't available this function returns 0.637*638* \param instance_id the joystick instance ID.639* \returns the product version of the selected gamepad. If called on an640* invalid index, this function returns zero.641*642* \since This function is available since SDL 3.2.0.643*644* \sa SDL_GetGamepadProductVersion645* \sa SDL_GetGamepads646*/647extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersionForID(SDL_JoystickID instance_id);648649/**650* Get the type of a gamepad.651*652* This can be called before any gamepads are opened.653*654* \param instance_id the joystick instance ID.655* \returns the gamepad type.656*657* \since This function is available since SDL 3.2.0.658*659* \sa SDL_GetGamepadType660* \sa SDL_GetGamepads661* \sa SDL_GetRealGamepadTypeForID662*/663extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeForID(SDL_JoystickID instance_id);664665/**666* Get the type of a gamepad, ignoring any mapping override.667*668* This can be called before any gamepads are opened.669*670* \param instance_id the joystick instance ID.671* \returns the gamepad type.672*673* \since This function is available since SDL 3.2.0.674*675* \sa SDL_GetGamepadTypeForID676* \sa SDL_GetGamepads677* \sa SDL_GetRealGamepadType678*/679extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadTypeForID(SDL_JoystickID instance_id);680681/**682* Get the mapping of a gamepad.683*684* This can be called before any gamepads are opened.685*686* \param instance_id the joystick instance ID.687* \returns the mapping string. Returns NULL if no mapping is available. This688* should be freed with SDL_free() when it is no longer needed.689*690* \since This function is available since SDL 3.2.0.691*692* \sa SDL_GetGamepads693* \sa SDL_GetGamepadMapping694*/695extern SDL_DECLSPEC char * SDLCALL SDL_GetGamepadMappingForID(SDL_JoystickID instance_id);696697/**698* Open a gamepad for use.699*700* \param instance_id the joystick instance ID.701* \returns a gamepad identifier or NULL if an error occurred; call702* SDL_GetError() for more information.703*704* \since This function is available since SDL 3.2.0.705*706* \sa SDL_CloseGamepad707* \sa SDL_IsGamepad708*/709extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_OpenGamepad(SDL_JoystickID instance_id);710711/**712* Get the SDL_Gamepad associated with a joystick instance ID, if it has been713* opened.714*715* \param instance_id the joystick instance ID of the gamepad.716* \returns an SDL_Gamepad on success or NULL on failure or if it hasn't been717* opened yet; call SDL_GetError() for more information.718*719* \since This function is available since SDL 3.2.0.720*/721extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromID(SDL_JoystickID instance_id);722723/**724* Get the SDL_Gamepad associated with a player index.725*726* \param player_index the player index, which different from the instance ID.727* \returns the SDL_Gamepad associated with a player index.728*729* \since This function is available since SDL 3.2.0.730*731* \sa SDL_GetGamepadPlayerIndex732* \sa SDL_SetGamepadPlayerIndex733*/734extern SDL_DECLSPEC SDL_Gamepad * SDLCALL SDL_GetGamepadFromPlayerIndex(int player_index);735736/**737* Get the properties associated with an opened gamepad.738*739* These properties are shared with the underlying joystick object.740*741* The following read-only properties are provided by SDL:742*743* - `SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN`: true if this gamepad has an LED744* that has adjustable brightness745* - `SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN`: true if this gamepad has an LED746* that has adjustable color747* - `SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN`: true if this gamepad has a748* player LED749* - `SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN`: true if this gamepad has750* left/right rumble751* - `SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN`: true if this gamepad has752* simple trigger rumble753*754* \param gamepad a gamepad identifier previously returned by755* SDL_OpenGamepad().756* \returns a valid property ID on success or 0 on failure; call757* SDL_GetError() for more information.758*759* \since This function is available since SDL 3.2.0.760*/761extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad);762763#define SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_MONO_LED_BOOLEAN764#define SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN765#define SDL_PROP_GAMEPAD_CAP_PLAYER_LED_BOOLEAN SDL_PROP_JOYSTICK_CAP_PLAYER_LED_BOOLEAN766#define SDL_PROP_GAMEPAD_CAP_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN767#define SDL_PROP_GAMEPAD_CAP_TRIGGER_RUMBLE_BOOLEAN SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN768769/**770* Get the instance ID of an opened gamepad.771*772* \param gamepad a gamepad identifier previously returned by773* SDL_OpenGamepad().774* \returns the instance ID of the specified gamepad on success or 0 on775* failure; call SDL_GetError() for more information.776*777* \since This function is available since SDL 3.2.0.778*/779extern SDL_DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadID(SDL_Gamepad *gamepad);780781/**782* Get the implementation-dependent name for an opened gamepad.783*784* \param gamepad a gamepad identifier previously returned by785* SDL_OpenGamepad().786* \returns the implementation dependent name for the gamepad, or NULL if787* there is no name or the identifier passed is invalid.788*789* \since This function is available since SDL 3.2.0.790*791* \sa SDL_GetGamepadNameForID792*/793extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadName(SDL_Gamepad *gamepad);794795/**796* Get the implementation-dependent path for an opened gamepad.797*798* \param gamepad a gamepad identifier previously returned by799* SDL_OpenGamepad().800* \returns the implementation dependent path for the gamepad, or NULL if801* there is no path or the identifier passed is invalid.802*803* \since This function is available since SDL 3.2.0.804*805* \sa SDL_GetGamepadPathForID806*/807extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadPath(SDL_Gamepad *gamepad);808809/**810* Get the type of an opened gamepad.811*812* \param gamepad the gamepad object to query.813* \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not814* available.815*816* \since This function is available since SDL 3.2.0.817*818* \sa SDL_GetGamepadTypeForID819*/820extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadType(SDL_Gamepad *gamepad);821822/**823* Get the type of an opened gamepad, ignoring any mapping override.824*825* \param gamepad the gamepad object to query.826* \returns the gamepad type, or SDL_GAMEPAD_TYPE_UNKNOWN if it's not827* available.828*829* \since This function is available since SDL 3.2.0.830*831* \sa SDL_GetRealGamepadTypeForID832*/833extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetRealGamepadType(SDL_Gamepad *gamepad);834835/**836* Get the player index of an opened gamepad.837*838* For XInput gamepads this returns the XInput user index.839*840* \param gamepad the gamepad object to query.841* \returns the player index for gamepad, or -1 if it's not available.842*843* \since This function is available since SDL 3.2.0.844*845* \sa SDL_SetGamepadPlayerIndex846*/847extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad);848849/**850* Set the player index of an opened gamepad.851*852* \param gamepad the gamepad object to adjust.853* \param player_index player index to assign to this gamepad, or -1 to clear854* the player index and turn off player LEDs.855* \returns true on success or false on failure; call SDL_GetError() for more856* information.857*858* \since This function is available since SDL 3.2.0.859*860* \sa SDL_GetGamepadPlayerIndex861*/862extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index);863864/**865* Get the USB vendor ID of an opened gamepad, if available.866*867* If the vendor ID isn't available this function returns 0.868*869* \param gamepad the gamepad object to query.870* \returns the USB vendor ID, or zero if unavailable.871*872* \since This function is available since SDL 3.2.0.873*874* \sa SDL_GetGamepadVendorForID875*/876extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendor(SDL_Gamepad *gamepad);877878/**879* Get the USB product ID of an opened gamepad, if available.880*881* If the product ID isn't available this function returns 0.882*883* \param gamepad the gamepad object to query.884* \returns the USB product ID, or zero if unavailable.885*886* \since This function is available since SDL 3.2.0.887*888* \sa SDL_GetGamepadProductForID889*/890extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProduct(SDL_Gamepad *gamepad);891892/**893* Get the product version of an opened gamepad, if available.894*895* If the product version isn't available this function returns 0.896*897* \param gamepad the gamepad object to query.898* \returns the USB product version, or zero if unavailable.899*900* \since This function is available since SDL 3.2.0.901*902* \sa SDL_GetGamepadProductVersionForID903*/904extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersion(SDL_Gamepad *gamepad);905906/**907* Get the firmware version of an opened gamepad, if available.908*909* If the firmware version isn't available this function returns 0.910*911* \param gamepad the gamepad object to query.912* \returns the gamepad firmware version, or zero if unavailable.913*914* \since This function is available since SDL 3.2.0.915*/916extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad);917918/**919* Get the serial number of an opened gamepad, if available.920*921* Returns the serial number of the gamepad, or NULL if it is not available.922*923* \param gamepad the gamepad object to query.924* \returns the serial number, or NULL if unavailable.925*926* \since This function is available since SDL 3.2.0.927*/928extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad);929930/**931* Get the Steam Input handle of an opened gamepad, if available.932*933* Returns an InputHandle_t for the gamepad that can be used with Steam Input934* API: https://partner.steamgames.com/doc/api/ISteamInput935*936* \param gamepad the gamepad object to query.937* \returns the gamepad handle, or 0 if unavailable.938*939* \since This function is available since SDL 3.2.0.940*/941extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad);942943/**944* Get the connection state of a gamepad.945*946* \param gamepad the gamepad object to query.947* \returns the connection state on success or948* `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError()949* for more information.950*951* \since This function is available since SDL 3.2.0.952*/953extern SDL_DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetGamepadConnectionState(SDL_Gamepad *gamepad);954955/**956* Get the battery state of a gamepad.957*958* You should never take a battery status as absolute truth. Batteries959* (especially failing batteries) are delicate hardware, and the values960* reported here are best estimates based on what that hardware reports. It's961* not uncommon for older batteries to lose stored power much faster than it962* reports, or completely drain when reporting it has 20 percent left, etc.963*964* \param gamepad the gamepad object to query.965* \param percent a pointer filled in with the percentage of battery life966* left, between 0 and 100, or NULL to ignore. This will be967* filled in with -1 we can't determine a value or there is no968* battery.969* \returns the current battery state.970*971* \since This function is available since SDL 3.2.0.972*/973extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetGamepadPowerInfo(SDL_Gamepad *gamepad, int *percent);974975/**976* Check if a gamepad has been opened and is currently connected.977*978* \param gamepad a gamepad identifier previously returned by979* SDL_OpenGamepad().980* \returns true if the gamepad has been opened and is currently connected, or981* false if not.982*983* \since This function is available since SDL 3.2.0.984*/985extern SDL_DECLSPEC bool SDLCALL SDL_GamepadConnected(SDL_Gamepad *gamepad);986987/**988* Get the underlying joystick from a gamepad.989*990* This function will give you a SDL_Joystick object, which allows you to use991* the SDL_Joystick functions with a SDL_Gamepad object. This would be useful992* for getting a joystick's position at any given time, even if it hasn't993* moved (moving it would produce an event, which would have the axis' value).994*995* The pointer returned is owned by the SDL_Gamepad. You should not call996* SDL_CloseJoystick() on it, for example, since doing so will likely cause997* SDL to crash.998*999* \param gamepad the gamepad object that you want to get a joystick from.1000* \returns an SDL_Joystick object, or NULL on failure; call SDL_GetError()1001* for more information.1002*1003* \since This function is available since SDL 3.2.0.1004*/1005extern SDL_DECLSPEC SDL_Joystick * SDLCALL SDL_GetGamepadJoystick(SDL_Gamepad *gamepad);10061007/**1008* Set the state of gamepad event processing.1009*1010* If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself1011* and check the state of the gamepad when you want gamepad information.1012*1013* \param enabled whether to process gamepad events or not.1014*1015* \since This function is available since SDL 3.2.0.1016*1017* \sa SDL_GamepadEventsEnabled1018* \sa SDL_UpdateGamepads1019*/1020extern SDL_DECLSPEC void SDLCALL SDL_SetGamepadEventsEnabled(bool enabled);10211022/**1023* Query the state of gamepad event processing.1024*1025* If gamepad events are disabled, you must call SDL_UpdateGamepads() yourself1026* and check the state of the gamepad when you want gamepad information.1027*1028* \returns true if gamepad events are being processed, false otherwise.1029*1030* \since This function is available since SDL 3.2.0.1031*1032* \sa SDL_SetGamepadEventsEnabled1033*/1034extern SDL_DECLSPEC bool SDLCALL SDL_GamepadEventsEnabled(void);10351036/**1037* Get the SDL joystick layer bindings for a gamepad.1038*1039* \param gamepad a gamepad.1040* \param count a pointer filled in with the number of bindings returned.1041* \returns a NULL terminated array of pointers to bindings or NULL on1042* failure; call SDL_GetError() for more information. This is a1043* single allocation that should be freed with SDL_free() when it is1044* no longer needed.1045*1046* \since This function is available since SDL 3.2.0.1047*/1048extern SDL_DECLSPEC SDL_GamepadBinding ** SDLCALL SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count);10491050/**1051* Manually pump gamepad updates if not using the loop.1052*1053* This function is called automatically by the event loop if events are1054* enabled. Under such circumstances, it will not be necessary to call this1055* function.1056*1057* \since This function is available since SDL 3.2.0.1058*/1059extern SDL_DECLSPEC void SDLCALL SDL_UpdateGamepads(void);10601061/**1062* Convert a string into SDL_GamepadType enum.1063*1064* This function is called internally to translate SDL_Gamepad mapping strings1065* for the underlying joystick device into the consistent SDL_Gamepad mapping.1066* You do not normally need to call this function unless you are parsing1067* SDL_Gamepad mappings in your own code.1068*1069* \param str string representing a SDL_GamepadType type.1070* \returns the SDL_GamepadType enum corresponding to the input string, or1071* `SDL_GAMEPAD_TYPE_UNKNOWN` if no match was found.1072*1073* \since This function is available since SDL 3.2.0.1074*1075* \sa SDL_GetGamepadStringForType1076*/1077extern SDL_DECLSPEC SDL_GamepadType SDLCALL SDL_GetGamepadTypeFromString(const char *str);10781079/**1080* Convert from an SDL_GamepadType enum to a string.1081*1082* \param type an enum value for a given SDL_GamepadType.1083* \returns a string for the given type, or NULL if an invalid type is1084* specified. The string returned is of the format used by1085* SDL_Gamepad mapping strings.1086*1087* \since This function is available since SDL 3.2.0.1088*1089* \sa SDL_GetGamepadTypeFromString1090*/1091extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForType(SDL_GamepadType type);10921093/**1094* Convert a string into SDL_GamepadAxis enum.1095*1096* This function is called internally to translate SDL_Gamepad mapping strings1097* for the underlying joystick device into the consistent SDL_Gamepad mapping.1098* You do not normally need to call this function unless you are parsing1099* SDL_Gamepad mappings in your own code.1100*1101* Note specially that "righttrigger" and "lefttrigger" map to1102* `SDL_GAMEPAD_AXIS_RIGHT_TRIGGER` and `SDL_GAMEPAD_AXIS_LEFT_TRIGGER`,1103* respectively.1104*1105* \param str string representing a SDL_Gamepad axis.1106* \returns the SDL_GamepadAxis enum corresponding to the input string, or1107* `SDL_GAMEPAD_AXIS_INVALID` if no match was found.1108*1109* \since This function is available since SDL 3.2.0.1110*1111* \sa SDL_GetGamepadStringForAxis1112*/1113extern SDL_DECLSPEC SDL_GamepadAxis SDLCALL SDL_GetGamepadAxisFromString(const char *str);11141115/**1116* Convert from an SDL_GamepadAxis enum to a string.1117*1118* \param axis an enum value for a given SDL_GamepadAxis.1119* \returns a string for the given axis, or NULL if an invalid axis is1120* specified. The string returned is of the format used by1121* SDL_Gamepad mapping strings.1122*1123* \since This function is available since SDL 3.2.0.1124*1125* \sa SDL_GetGamepadAxisFromString1126*/1127extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForAxis(SDL_GamepadAxis axis);11281129/**1130* Query whether a gamepad has a given axis.1131*1132* This merely reports whether the gamepad's mapping defined this axis, as1133* that is all the information SDL has about the physical device.1134*1135* \param gamepad a gamepad.1136* \param axis an axis enum value (an SDL_GamepadAxis value).1137* \returns true if the gamepad has this axis, false otherwise.1138*1139* \since This function is available since SDL 3.2.0.1140*1141* \sa SDL_GamepadHasButton1142* \sa SDL_GetGamepadAxis1143*/1144extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);11451146/**1147* Get the current state of an axis control on a gamepad.1148*1149* The axis indices start at index 0.1150*1151* For thumbsticks, the state is a value ranging from -32768 (up/left) to1152* 32767 (down/right).1153*1154* Triggers range from 0 when released to 32767 when fully pressed, and never1155* return a negative value. Note that this differs from the value reported by1156* the lower-level SDL_GetJoystickAxis(), which normally uses the full range.1157*1158* \param gamepad a gamepad.1159* \param axis an axis index (one of the SDL_GamepadAxis values).1160* \returns axis state (including 0) on success or 0 (also) on failure; call1161* SDL_GetError() for more information.1162*1163* \since This function is available since SDL 3.2.0.1164*1165* \sa SDL_GamepadHasAxis1166* \sa SDL_GetGamepadButton1167*/1168extern SDL_DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);11691170/**1171* Convert a string into an SDL_GamepadButton enum.1172*1173* This function is called internally to translate SDL_Gamepad mapping strings1174* for the underlying joystick device into the consistent SDL_Gamepad mapping.1175* You do not normally need to call this function unless you are parsing1176* SDL_Gamepad mappings in your own code.1177*1178* \param str string representing a SDL_Gamepad axis.1179* \returns the SDL_GamepadButton enum corresponding to the input string, or1180* `SDL_GAMEPAD_BUTTON_INVALID` if no match was found.1181*1182* \since This function is available since SDL 3.2.0.1183*1184* \sa SDL_GetGamepadStringForButton1185*/1186extern SDL_DECLSPEC SDL_GamepadButton SDLCALL SDL_GetGamepadButtonFromString(const char *str);11871188/**1189* Convert from an SDL_GamepadButton enum to a string.1190*1191* \param button an enum value for a given SDL_GamepadButton.1192* \returns a string for the given button, or NULL if an invalid button is1193* specified. The string returned is of the format used by1194* SDL_Gamepad mapping strings.1195*1196* \since This function is available since SDL 3.2.0.1197*1198* \sa SDL_GetGamepadButtonFromString1199*/1200extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadStringForButton(SDL_GamepadButton button);12011202/**1203* Query whether a gamepad has a given button.1204*1205* This merely reports whether the gamepad's mapping defined this button, as1206* that is all the information SDL has about the physical device.1207*1208* \param gamepad a gamepad.1209* \param button a button enum value (an SDL_GamepadButton value).1210* \returns true if the gamepad has this button, false otherwise.1211*1212* \since This function is available since SDL 3.2.0.1213*1214* \sa SDL_GamepadHasAxis1215*/1216extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);12171218/**1219* Get the current state of a button on a gamepad.1220*1221* \param gamepad a gamepad.1222* \param button a button index (one of the SDL_GamepadButton values).1223* \returns true if the button is pressed, false otherwise.1224*1225* \since This function is available since SDL 3.2.0.1226*1227* \sa SDL_GamepadHasButton1228* \sa SDL_GetGamepadAxis1229*/1230extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);12311232/**1233* Get the label of a button on a gamepad.1234*1235* \param type the type of gamepad to check.1236* \param button a button index (one of the SDL_GamepadButton values).1237* \returns the SDL_GamepadButtonLabel enum corresponding to the button label.1238*1239* \since This function is available since SDL 3.2.0.1240*1241* \sa SDL_GetGamepadButtonLabel1242*/1243extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabelForType(SDL_GamepadType type, SDL_GamepadButton button);12441245/**1246* Get the label of a button on a gamepad.1247*1248* \param gamepad a gamepad.1249* \param button a button index (one of the SDL_GamepadButton values).1250* \returns the SDL_GamepadButtonLabel enum corresponding to the button label.1251*1252* \since This function is available since SDL 3.2.0.1253*1254* \sa SDL_GetGamepadButtonLabelForType1255*/1256extern SDL_DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabel(SDL_Gamepad *gamepad, SDL_GamepadButton button);12571258/**1259* Get the number of touchpads on a gamepad.1260*1261* \param gamepad a gamepad.1262* \returns number of touchpads.1263*1264* \since This function is available since SDL 3.2.0.1265*1266* \sa SDL_GetNumGamepadTouchpadFingers1267*/1268extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad);12691270/**1271* Get the number of supported simultaneous fingers on a touchpad on a game1272* gamepad.1273*1274* \param gamepad a gamepad.1275* \param touchpad a touchpad.1276* \returns number of supported simultaneous fingers.1277*1278* \since This function is available since SDL 3.2.0.1279*1280* \sa SDL_GetGamepadTouchpadFinger1281* \sa SDL_GetNumGamepadTouchpads1282*/1283extern SDL_DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepad, int touchpad);12841285/**1286* Get the current state of a finger on a touchpad on a gamepad.1287*1288* \param gamepad a gamepad.1289* \param touchpad a touchpad.1290* \param finger a finger.1291* \param down a pointer filled with true if the finger is down, false1292* otherwise, may be NULL.1293* \param x a pointer filled with the x position, normalized 0 to 1, with the1294* origin in the upper left, may be NULL.1295* \param y a pointer filled with the y position, normalized 0 to 1, with the1296* origin in the upper left, may be NULL.1297* \param pressure a pointer filled with pressure value, may be NULL.1298* \returns true on success or false on failure; call SDL_GetError() for more1299* information.1300*1301* \since This function is available since SDL 3.2.0.1302*1303* \sa SDL_GetNumGamepadTouchpadFingers1304*/1305extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, bool *down, float *x, float *y, float *pressure);13061307/**1308* Return whether a gamepad has a particular sensor.1309*1310* \param gamepad the gamepad to query.1311* \param type the type of sensor to query.1312* \returns true if the sensor exists, false otherwise.1313*1314* \since This function is available since SDL 3.2.0.1315*1316* \sa SDL_GetGamepadSensorData1317* \sa SDL_GetGamepadSensorDataRate1318* \sa SDL_SetGamepadSensorEnabled1319*/1320extern SDL_DECLSPEC bool SDLCALL SDL_GamepadHasSensor(SDL_Gamepad *gamepad, SDL_SensorType type);13211322/**1323* Set whether data reporting for a gamepad sensor is enabled.1324*1325* \param gamepad the gamepad to update.1326* \param type the type of sensor to enable/disable.1327* \param enabled whether data reporting should be enabled.1328* \returns true on success or false on failure; call SDL_GetError() for more1329* information.1330*1331* \since This function is available since SDL 3.2.0.1332*1333* \sa SDL_GamepadHasSensor1334* \sa SDL_GamepadSensorEnabled1335*/1336extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type, bool enabled);13371338/**1339* Query whether sensor data reporting is enabled for a gamepad.1340*1341* \param gamepad the gamepad to query.1342* \param type the type of sensor to query.1343* \returns true if the sensor is enabled, false otherwise.1344*1345* \since This function is available since SDL 3.2.0.1346*1347* \sa SDL_SetGamepadSensorEnabled1348*/1349extern SDL_DECLSPEC bool SDLCALL SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad, SDL_SensorType type);13501351/**1352* Get the data rate (number of events per second) of a gamepad sensor.1353*1354* \param gamepad the gamepad to query.1355* \param type the type of sensor to query.1356* \returns the data rate, or 0.0f if the data rate is not available.1357*1358* \since This function is available since SDL 3.2.0.1359*/1360extern SDL_DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad, SDL_SensorType type);13611362/**1363* Get the current state of a gamepad sensor.1364*1365* The number of values and interpretation of the data is sensor dependent.1366* See SDL_sensor.h for the details for each type of sensor.1367*1368* \param gamepad the gamepad to query.1369* \param type the type of sensor to query.1370* \param data a pointer filled with the current sensor state.1371* \param num_values the number of values to write to data.1372* \returns true on success or false on failure; call SDL_GetError() for more1373* information.1374*1375* \since This function is available since SDL 3.2.0.1376*/1377extern SDL_DECLSPEC bool SDLCALL SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *data, int num_values);13781379/**1380* Start a rumble effect on a gamepad.1381*1382* Each call to this function cancels any previous rumble effect, and calling1383* it with 0 intensity stops any rumbling.1384*1385* This function requires you to process SDL events or call1386* SDL_UpdateJoysticks() to update rumble state.1387*1388* \param gamepad the gamepad to vibrate.1389* \param low_frequency_rumble the intensity of the low frequency (left)1390* rumble motor, from 0 to 0xFFFF.1391* \param high_frequency_rumble the intensity of the high frequency (right)1392* rumble motor, from 0 to 0xFFFF.1393* \param duration_ms the duration of the rumble effect, in milliseconds.1394* \returns true on success or false on failure; call SDL_GetError() for more1395* information.1396*1397* \since This function is available since SDL 3.2.0.1398*/1399extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);14001401/**1402* Start a rumble effect in the gamepad's triggers.1403*1404* Each call to this function cancels any previous trigger rumble effect, and1405* calling it with 0 intensity stops any rumbling.1406*1407* Note that this is rumbling of the _triggers_ and not the gamepad as a1408* whole. This is currently only supported on Xbox One gamepads. If you want1409* the (more common) whole-gamepad rumble, use SDL_RumbleGamepad() instead.1410*1411* This function requires you to process SDL events or call1412* SDL_UpdateJoysticks() to update rumble state.1413*1414* \param gamepad the gamepad to vibrate.1415* \param left_rumble the intensity of the left trigger rumble motor, from 01416* to 0xFFFF.1417* \param right_rumble the intensity of the right trigger rumble motor, from 01418* to 0xFFFF.1419* \param duration_ms the duration of the rumble effect, in milliseconds.1420* \returns true on success or false on failure; call SDL_GetError() for more1421* information.1422*1423* \since This function is available since SDL 3.2.0.1424*1425* \sa SDL_RumbleGamepad1426*/1427extern SDL_DECLSPEC bool SDLCALL SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);14281429/**1430* Update a gamepad's LED color.1431*1432* An example of a joystick LED is the light on the back of a PlayStation 4's1433* DualShock 4 controller.1434*1435* For gamepads with a single color LED, the maximum of the RGB values will be1436* used as the LED brightness.1437*1438* \param gamepad the gamepad to update.1439* \param red the intensity of the red LED.1440* \param green the intensity of the green LED.1441* \param blue the intensity of the blue LED.1442* \returns true on success or false on failure; call SDL_GetError() for more1443* information.1444*1445* \since This function is available since SDL 3.2.0.1446*/1447extern SDL_DECLSPEC bool SDLCALL SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue);14481449/**1450* Send a gamepad specific effect packet.1451*1452* \param gamepad the gamepad to affect.1453* \param data the data to send to the gamepad.1454* \param size the size of the data to send to the gamepad.1455* \returns true on success or false on failure; call SDL_GetError() for more1456* information.1457*1458* \since This function is available since SDL 3.2.0.1459*/1460extern SDL_DECLSPEC bool SDLCALL SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size);14611462/**1463* Close a gamepad previously opened with SDL_OpenGamepad().1464*1465* \param gamepad a gamepad identifier previously returned by1466* SDL_OpenGamepad().1467*1468* \since This function is available since SDL 3.2.0.1469*1470* \sa SDL_OpenGamepad1471*/1472extern SDL_DECLSPEC void SDLCALL SDL_CloseGamepad(SDL_Gamepad *gamepad);14731474/**1475* Return the sfSymbolsName for a given button on a gamepad on Apple1476* platforms.1477*1478* \param gamepad the gamepad to query.1479* \param button a button on the gamepad.1480* \returns the sfSymbolsName or NULL if the name can't be found.1481*1482* \since This function is available since SDL 3.2.0.1483*1484* \sa SDL_GetGamepadAppleSFSymbolsNameForAxis1485*/1486extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);14871488/**1489* Return the sfSymbolsName for a given axis on a gamepad on Apple platforms.1490*1491* \param gamepad the gamepad to query.1492* \param axis an axis on the gamepad.1493* \returns the sfSymbolsName or NULL if the name can't be found.1494*1495* \since This function is available since SDL 3.2.0.1496*1497* \sa SDL_GetGamepadAppleSFSymbolsNameForButton1498*/1499extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadAppleSFSymbolsNameForAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis);150015011502/* Ends C function definitions when using C++ */1503#ifdef __cplusplus1504}1505#endif1506#include <SDL3/SDL_close_code.h>15071508#endif /* SDL_gamepad_h_ */150915101511