Wiki Page Content

Differences between revisions 5 and 7 (spanning 2 versions)
Revision 5 as of 2014-03-02 13:46:03
Size: 1888
Comment: This is a macro not the function.
Revision 7 as of 2014-08-30 19:06:32
Size: 2107
Comment: Added missing semicolon in example.
Deletions are marked like this. Additions are marked like this.
Line 9: Line 9:
= SDL_GameControllerAddMappingsFromFile =
Use this function to load a set of [[CategoryGameController|Game Controller]] mappings from a file, filtered by the current [[SDL_GetPlatform]]().
= SDL_GameControllerAddMappingsFromRW =
Use this function to load a set of [[CategoryGameController|Game Controller]] mappings from a seekable SDL data stream (memory or file), filtered by the current [[SDL_GetPlatform]]().
Line 18: Line 18:
int SDL_GameControllerAddMappingsFromFile(const char* filename) int SDL_GameControllerAddMappingsFromRW(SDL_RWops* rw,
                                        
int        freerw)
Line 23: Line 24:
||'''filename'''||the name of the database you want to load|| ||'''rw'''||the data stream for the mappings to be added||
||'''freerw'''||non-zero to close the stream after being read||
Line 32: Line 34:
SDL_GameControllerAddMappingsFromFile("gamecontrollerdb.txt"); SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile("gamecontrollerdb.txt", "rb"), 1);
Line 46: Line 48:
This function is available in SDL 2.0.2. This function is available since SDL 2.0.2.
Line 50: Line 52:
 .[[SDL_GameControllerAddMappingsFromFile]]

DRAFT

SDL_GameControllerAddMappingsFromRW

Use this function to load a set of Game Controller mappings from a seekable SDL data stream (memory or file), filtered by the current SDL_GetPlatform(). A community sourced database of controllers is available here (on GitHub).

Syntax

int SDL_GameControllerAddMappingsFromRW(SDL_RWops* rw,
                                        int        freerw)

Function Parameters

rw

the data stream for the mappings to be added

freerw

non-zero to close the stream after being read

Return Value

Returns the number of mappings added or -1 on error; call SDL_GetError() for more information.

Code Examples

SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile("gamecontrollerdb.txt", "rb"), 1);

Remarks

You can call this function several times if needed to load different database files.

If a new mapping is loaded for an already known controller GUID, the later version will overwrite the one currently loaded.

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).

This function will load the text database entirely in memory before processing it, so take this into consideration if you are in a memory constrained environment.

Version

This function is available since SDL 2.0.2.


CategoryAPI, CategoryGameController

None: SDL_GameControllerAddMappingsFromRW (last edited 2014-08-30 19:09:21 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit