This is new wiki software and old wiki content. It's a work in progress!
Here's the explanation.
Be gentle, report bugs, leave feedback on pages, or just edit them yourself! Thanks!

SDL Wiki

Draft

THIS PAGE IS A WORK IN PROGRESS ... Please make edits to this page to improve it!

SDL_GameControllerMapping

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.

Remarks

The returned string must be freed with SDL_free().

Details about mappings are discussed with SDL_GameControllerAddMapping().

Version

This function is available since SDL 2.0.0.

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);
    }
}
SDL_GameControllerAddMapping
SDL_GameControllerMappingForGUID

CategoryAPI, CategoryGameController, CategoryDraft


[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.