mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-08 10:56:27 +00:00
Added Steam Input API support for game controllers
Added support for getting the real controller info, as well as the function SDL_GameControllerGetSteamHandle() to get the Steam Input API handle, from the virtual gamepads provided by Steam.
Also added an event SDL_CONTROLLERSTEAMHANDLEUPDATED which is triggered when a controller's API handle changes, e.g. the controllers were reassigned slots in the Steam UI.
(cherry picked from commit c981a597dc
)
This commit is contained in:
@@ -131,6 +131,8 @@ typedef enum
|
||||
SDL_CONTROLLERTOUCHPADMOTION, /**< Game controller touchpad finger was moved */
|
||||
SDL_CONTROLLERTOUCHPADUP, /**< Game controller touchpad finger was lifted */
|
||||
SDL_CONTROLLERSENSORUPDATE, /**< Game controller sensor was updated */
|
||||
SDL_CONTROLLERUPDATECOMPLETE_RESERVED_FOR_SDL3,
|
||||
SDL_CONTROLLERSTEAMHANDLEUPDATED, /**< Game controller Steam handle has changed */
|
||||
|
||||
/* Touch events */
|
||||
SDL_FINGERDOWN = 0x700,
|
||||
@@ -446,7 +448,7 @@ typedef struct SDL_ControllerButtonEvent
|
||||
*/
|
||||
typedef struct SDL_ControllerDeviceEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */
|
||||
Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, ::SDL_CONTROLLERDEVICEREMAPPED, or ::SDL_CONTROLLERSTEAMHANDLEUPDATED */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
|
||||
} SDL_ControllerDeviceEvent;
|
||||
|
@@ -524,6 +524,20 @@ extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetFirmwareVersion(SDL_GameCont
|
||||
*/
|
||||
extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Get the Steam Input handle of an opened controller, if available.
|
||||
*
|
||||
* Returns an InputHandle_t for the controller that can be used with Steam Input API:
|
||||
* https://partner.steamgames.com/doc/api/ISteamInput
|
||||
*
|
||||
* \param gamecontroller the game controller object to query.
|
||||
* \returns the gamepad handle, or 0 if unavailable.
|
||||
*
|
||||
* \since This function is available since SDL 2.30.0.
|
||||
*/
|
||||
extern DECLSPEC Uint64 SDLCALL SDL_GameControllerGetSteamHandle(SDL_GameController *gamecontroller);
|
||||
|
||||
|
||||
/**
|
||||
* Check if a controller has been opened and is currently connected.
|
||||
*
|
||||
|
Reference in New Issue
Block a user