Source/ThirdParty/SDL/src/joystick/SDL_gamecontroller.c
/*
 * Get the mapping string for this GUID
 */
Get the mapping string for this GUID
Get the mapping string for this GUID
char *
SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid)
{
    char *pMappingString = NULL;
    ControllerMapping_t *mapping = SDL_PrivateGetControllerMappingForGUID(&guid);
    if (mapping) {
        char pchGUID[33];
        size_t needed;
        SDL_JoystickGetGUIDString(guid, pchGUID, sizeof(pchGUID));
        needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1;
        pMappingString = SDL_malloc(needed);
        if (!pMappingString) {
            SDL_OutOfMemory();
            return NULL;
        }
        SDL_snprintf(pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping);
    }
    return pMappingString;
}
char * SDL_GameControllerMappingForGUID ( SDL_JoystickGUID guid ) { char * pMappingString = NULL ; ControllerMapping_t * mapping = SDL_PrivateGetControllerMappingForGUID ( & guid ) ; if ( mapping ) { char pchGUID [ 33 ] ; size_t needed ; SDL_JoystickGetGUIDString ( guid , pchGUID , sizeof ( pchGUID ) ) ; needed = SDL_strlen ( pchGUID ) + 1 + SDL_strlen ( mapping -> name ) + 1 + SDL_strlen ( mapping -> mapping ) + 1 ; pMappingString = SDL_malloc ( needed ) ; if ( ! pMappingString ) { SDL_OutOfMemory ( ) ; return NULL ; } SDL_snprintf ( pMappingString , needed , " " , pchGUID , mapping -> name , mapping -> mapping ) ; } return pMappingString ; }
Get the mapping string for this GUID
Get the mapping string for this GUID
/* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */