Skip to content

Commit

Permalink
docs: Explain events for already plugged in controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
xordspar0 authored and slouken committed Oct 27, 2024
1 parent e5348c6 commit a22baaf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/SDL_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,11 @@ typedef struct SDL_JoyButtonEvent

/**
* Joystick device event structure (event.jdevice.*)
*
* SDL will send JOYSTICK_ADDED events for devices that
* are already plugged in during SDL_Init.
*
* \sa SDL_ControllerDeviceEvent
*/
typedef struct SDL_JoyDeviceEvent
{
Expand Down Expand Up @@ -465,6 +470,12 @@ typedef struct SDL_ControllerButtonEvent

/**
* Controller device event structure (event.cdevice.*)
*
* Joysticks that are supported game controllers receive both an
* SDL_JoyDeviceEvent and an SDL_ControllerDeviceEvent.
*
* SDL will send CONTROLLERDEVICEADDED events for joysticks that are already plugged
* in during SDL_Init() and are recognized as game controllers.
*/
typedef struct SDL_ControllerDeviceEvent
{
Expand Down
10 changes: 10 additions & 0 deletions include/SDL_gamecontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ typedef struct SDL_GameControllerButtonBind
* If a new mapping is loaded for an already known controller GUID, the later
* version will overwrite the one currently loaded.
*
* If this function is called before SDL_Init, SDL will generate
* an SDL_CONTROLLERDEVICEADDED event for matching controllers that are
* plugged in at the time that SDL_Init is called.
*
* Mappings not belonging to the current platform or with no platform field
* specified will be ignored (i.e. mappings for Linux will be ignored in
* Windows, etc).
Expand All @@ -164,6 +168,7 @@ typedef struct SDL_GameControllerButtonBind
* \sa SDL_GameControllerAddMapping
* \sa SDL_GameControllerAddMappingsFromFile
* \sa SDL_GameControllerMappingForGUID
* \sa SDL_CONTROLLERDEVICEADDED
*/
extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw);

Expand Down Expand Up @@ -193,6 +198,10 @@ extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw,
* "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"
* ```
*
* If this function is called before SDL_Init, SDL will generate
* an SDL_CONTROLLERDEVICEADDED event for matching controllers that are
* plugged in at the time that SDL_Init is called.
*
* \param mappingString the mapping string.
* \returns 1 if a new mapping is added, 0 if an existing mapping is updated,
* -1 on error; call SDL_GetError() for more information.
Expand All @@ -201,6 +210,7 @@ extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw,
*
* \sa SDL_GameControllerMapping
* \sa SDL_GameControllerMappingForGUID
* \sa SDL_CONTROLLERDEVICEADDED
*/
extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString);

Expand Down

0 comments on commit a22baaf

Please sign in to comment.