forked from Ports/perfect_dark
port: load gamecontrollerdb if available
This commit is contained in:
1 parent
116dc7e8b6
commit
31ad9351f5
1 file changed
+12
@@ -10,6 +10,9 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include "fs.h"
|
||||||
|
|
||||||
|
#define CONTROLLERDB_FNAME "gamecontrollerdb.txt"
|
||||||
|
|
||||||
#define MAX_BIND_STR 256
|
#define MAX_BIND_STR 256
|
||||||
|
|
||||||
@@ -637,6 +640,15 @@ s32 inputInit(void)
|
|||||||
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC);
|
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// try to load controller db from an external file in the save folder
|
||||||
|
if (fsFileSize("$S/" CONTROLLERDB_FNAME)) {
|
||||||
|
const char *dbpath = fsFullPath("$S/" CONTROLLERDB_FNAME);
|
||||||
|
const s32 dbcount = SDL_GameControllerAddMappingsFromFile(dbpath);
|
||||||
|
if (dbcount >= 0) {
|
||||||
|
sysLogPrintf(LOG_NOTE, "input: added %d controller mappings from %s", dbcount, dbpath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inputInitAllControllers();
|
inputInitAllControllers();
|
||||||
|
|
||||||
// since the main event loop is elsewhere, we can receive some events we need using a watcher
|
// since the main event loop is elsewhere, we can receive some events we need using a watcher
|
||||||
|
|||||||
Reference in new issue
Block a user