mirror of https://github.com/encounter/SDL.git
Added the hint SDL_HINT_GAMECONTROLLERCONFIG_FILE to specify a file to load at initialization containing SDL game controller mappings
This commit is contained in:
parent
898644d18e
commit
70ce0f2e06
|
@ -436,6 +436,16 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG"
|
#define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief A variable that lets you provide a file with extra gamecontroller db entries.
|
||||||
|
*
|
||||||
|
* The file should contain lines of gamecontroller config data, see SDL_gamecontroller.h
|
||||||
|
*
|
||||||
|
* This hint must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER)
|
||||||
|
* You can update mappings after the system is initialized with SDL_GameControllerMappingForGUID() and SDL_GameControllerAddMapping()
|
||||||
|
*/
|
||||||
|
#define SDL_HINT_GAMECONTROLLERCONFIG_FILE "SDL_GAMECONTROLLERCONFIG_FILE"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A variable containing a list of devices to skip when scanning for game controllers.
|
* \brief A variable containing a list of devices to skip when scanning for game controllers.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1308,15 +1308,17 @@ SDL_GameControllerLoadHints()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fill the given buffer with the expected controller mapping filepath.
|
* Fill the given buffer with the expected controller mapping filepath.
|
||||||
* Usually this will just be CONTROLLER_MAPPING_FILE, but for Android,
|
* Usually this will just be SDL_HINT_GAMECONTROLLERCONFIG_FILE, but for
|
||||||
* we want to get the internal storage path.
|
* Android, we want to get the internal storage path.
|
||||||
*/
|
*/
|
||||||
static SDL_bool SDL_GetControllerMappingFilePath(char *path, size_t size)
|
static SDL_bool SDL_GetControllerMappingFilePath(char *path, size_t size)
|
||||||
{
|
{
|
||||||
#ifdef CONTROLLER_MAPPING_FILE
|
const char *hint = SDL_GetHint(SDL_HINT_GAMECONTROLLERCONFIG_FILE);
|
||||||
#define STRING(X) SDL_STRINGIFY_ARG(X)
|
if (hint && *hint) {
|
||||||
return SDL_strlcpy(path, STRING(CONTROLLER_MAPPING_FILE), size) < size;
|
return SDL_strlcpy(path, hint, size) < size;
|
||||||
#elif defined(__ANDROID__)
|
}
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
return SDL_snprintf(path, size, "%s/controller_map.txt", SDL_AndroidGetInternalStoragePath()) < size;
|
return SDL_snprintf(path, size, "%s/controller_map.txt", SDL_AndroidGetInternalStoragePath()) < size;
|
||||||
#else
|
#else
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
|
|
Loading…
Reference in New Issue