Wiki Page Content

Differences between revisions 10 and 11
Revision 10 as of 2016-04-10 22:35:21
Size: 1775
Comment: Changed wording and added missing ().
Revision 11 as of 2016-04-10 22:38:02
Size: 1813
Comment: Added content from header file and moved remark into Remarks section.
Deletions are marked like this. Additions are marked like this.
Line 26: Line 26:
Returns a string that has the controller's mapping. More information about the mapping can be found on the page for [[SDL_GameControllerAddMapping]](); call [[SDL_GetError]]() for more information. Returns a string that has the controller's mapping or NULL if no mapping is available; call [[SDL_GetError]]() for more information.
Line 56: Line 56:
More information about the mapping can be found on the page for [[SDL_GameControllerAddMapping]]().

DRAFT

SDL_GameControllerMapping

Use this function to get the current mapping of a Game Controller.

Syntax

char* SDL_GameControllerMapping(SDL_GameController* gamecontroller)

Function Parameters

gamecontroller

the game controller you want to get the current mapping for

Return Value

Returns a string that has the controller's mapping or NULL if no mapping is available; call SDL_GetError() for more information.

Code Examples

#include "SDL.h"

/* ... */

SDL_GameController *ctrl;
int i;

SDL_Init(SDL_INIT_GAMECONTROLLER);

for (i = 0; i < SDL_NumJoysticks(); ++i) {
    if (SDL_IsGameController(i)) {
        char *mapping;
        SDL_Log("Index \'%i\' is a compatible controller, named \'%s\'", i, SDL_GameControllerNameForIndex(i));
        ctrl = SDL_GameControllerOpen(i);
        mapping = SDL_GameControllerMapping(ctrl);
        SDL_Log("Controller %i is mapped as \"%s\".", i, mapping);
        SDL_free(mapping);
    } else {
        SDL_Log("Index \'%i\' is not a compatible controller.", i);
    }
}

Remarks

The returned string must be freed with SDL_free().

More information about the mapping can be found on the page for SDL_GameControllerAddMapping().


CategoryAPI, CategoryGameController

None: SDL_GameControllerMapping (last edited 2016-04-10 22:39:25 by PhilippWiesemann)

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