Source/ThirdParty/SDL/src/joystick/SDL_gamecontroller.c
/*
 * Add or update an entry into the Mappings Database
 */
Add or update an entry into the Mappings Database
Add or update an entry into the Mappings Database
int
SDL_GameControllerAddMapping(const char *mappingString)
{
    char *pchGUID;
    SDL_JoystickGUID jGUID;
    SDL_bool is_xinput_mapping = SDL_FALSE;
    SDL_bool is_emscripten_mapping = SDL_FALSE;
    SDL_bool existing = SDL_FALSE;
    ControllerMapping_t *pControllerMapping;
    if (!mappingString) {
        return SDL_InvalidParamError("mappingString");
    }
    pchGUID = SDL_PrivateGetControllerGUIDFromMappingString(mappingString);
    if (!pchGUID) {
        return SDL_SetError("Couldn't parse GUID from %s", mappingString);
    }
    if (!SDL_strcasecmp(pchGUID, "xinput")) {
        is_xinput_mapping = SDL_TRUE;
    }
    if (!SDL_strcasecmp(pchGUID, "emscripten")) {
        is_emscripten_mapping = SDL_TRUE;
    }
    jGUID = SDL_JoystickGetGUIDFromString(pchGUID);
    SDL_free(pchGUID);
    pControllerMapping = SDL_PrivateAddMappingForGUID(jGUID, mappingString, &existing);
    if (!pControllerMapping) {
        return -1;
    }
    if (existing) {
        return 0;
    } else {
        if (is_xinput_mapping) {
            s_pXInputMapping = pControllerMapping;
        }
        if (is_emscripten_mapping) {
            s_pEmscriptenMapping = pControllerMapping;
        }
        return 1;
    }
}
int SDL_GameControllerAddMapping ( const char * mappingString ) { char * pchGUID ; SDL_JoystickGUID jGUID ; SDL_bool is_xinput_mapping = SDL_FALSE ; SDL_bool is_emscripten_mapping = SDL_FALSE ; SDL_bool existing = SDL_FALSE ; ControllerMapping_t * pControllerMapping ; if ( ! mappingString ) { return SDL_InvalidParamError ( " " ) ; } pchGUID = SDL_PrivateGetControllerGUIDFromMappingString ( mappingString ) ; if ( ! pchGUID ) { return SDL_SetError ( " " , mappingString ) ; } if ( ! SDL_strcasecmp ( pchGUID , " " ) ) { is_xinput_mapping = SDL_TRUE ; } if ( ! SDL_strcasecmp ( pchGUID , " " ) ) { is_emscripten_mapping = SDL_TRUE ; } jGUID = SDL_JoystickGetGUIDFromString ( pchGUID ) ; SDL_free ( pchGUID ) ; pControllerMapping = SDL_PrivateAddMappingForGUID ( jGUID , mappingString , & existing ) ; if ( ! pControllerMapping ) { return -1 ; } if ( existing ) { return 0 ; } else { if ( is_xinput_mapping ) { s_pXInputMapping = pControllerMapping ; } if ( is_emscripten_mapping ) { s_pEmscriptenMapping = pControllerMapping ; } return 1 ; } }
Add or update an entry into the Mappings Database
Add or update an entry into the Mappings Database