Skip to content

Commit e5e859d

Browse files
committed
docs: Explain events for already plugged in controllers
1 parent e5348c6 commit e5e859d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

include/SDL_events.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,11 @@ typedef struct SDL_JoyButtonEvent
412412

413413
/**
414414
* Joystick device event structure (event.jdevice.*)
415+
*
416+
* SDL will send JOYSTICK_ADDED events for devices that
417+
* are already plugged in during SDL_Init.
418+
*
419+
* \sa SDL_ControllerDeviceEvent
415420
*/
416421
typedef struct SDL_JoyDeviceEvent
417422
{
@@ -465,6 +470,12 @@ typedef struct SDL_ControllerButtonEvent
465470

466471
/**
467472
* Controller device event structure (event.cdevice.*)
473+
*
474+
* Joysticks that are supported game controllers receive both an
475+
* SDL_JoyDeviceEvent and an SDL_ControllerDeviceEvent.
476+
*
477+
* SDL will send CONTROLLERDEVICEADDED events for joysticks that are already plugged
478+
* in during SDL_Init() and are recognized as gamepads.
468479
*/
469480
typedef struct SDL_ControllerDeviceEvent
470481
{

include/SDL_gamecontroller.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ typedef struct SDL_GameControllerButtonBind
146146
* If a new mapping is loaded for an already known controller GUID, the later
147147
* version will overwrite the one currently loaded.
148148
*
149+
* If this function is called before SDL_Init, SDL will generate
150+
* an SDL_CONTROLLERDEVICEADDED event for matching controllers that are
151+
* plugged in at the time that SDL_Init is called.
152+
*
149153
* Mappings not belonging to the current platform or with no platform field
150154
* specified will be ignored (i.e. mappings for Linux will be ignored in
151155
* Windows, etc).
@@ -193,6 +197,10 @@ extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw,
193197
* "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"
194198
* ```
195199
*
200+
* If this function is called before SDL_Init, SDL will generate
201+
* an SDL_CONTROLLERDEVICEADDED event for matching controllers that are
202+
* plugged in at the time that SDL_Init is called.
203+
*
196204
* \param mappingString the mapping string.
197205
* \returns 1 if a new mapping is added, 0 if an existing mapping is updated,
198206
* -1 on error; call SDL_GetError() for more information.
@@ -201,6 +209,7 @@ extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw,
201209
*
202210
* \sa SDL_GameControllerMapping
203211
* \sa SDL_GameControllerMappingForGUID
212+
* \sa SDL_CONTROLLERDEVICEADDED
204213
*/
205214
extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString);
206215

0 commit comments

Comments
 (0)