load external gamecontrollerdb file if it's present

This commit is contained in:
fgsfds 2020-06-03 00:10:42 +03:00
parent 4ade5a8654
commit 71db1904e4
1 changed files with 12 additions and 0 deletions

View File

@ -13,6 +13,7 @@
#include "controller_api.h"
#include "controller_sdl.h"
#include "../configfile.h"
#include "../platform.h"
#include "game/level_update.h"
@ -89,6 +90,17 @@ static void controller_sdl_init(void) {
return;
}
// try loading an external gamecontroller mapping file
char gcpath[SYS_MAX_PATH];
snprintf(gcpath, sizeof(gcpath), "%s/gamecontrollerdb.txt", sys_save_path());
int nummaps = SDL_GameControllerAddMappingsFromFile(gcpath);
if (nummaps < 0) {
snprintf(gcpath, sizeof(gcpath), "%s/gamecontrollerdb.txt", sys_data_path());
nummaps = SDL_GameControllerAddMappingsFromFile(gcpath);
}
if (nummaps >= 0)
printf("loaded %d controller mappings from '%s'\n", nummaps, gcpath);
#ifdef BETTERCAMERA
if (newcam_mouse == 1)
SDL_SetRelativeMouseMode(SDL_TRUE);