void G_LoadDefaults(void) { char *temp = NULL; size_t len; DWFILE dwfile, *file = &dwfile; len = M_StringAlloca(&temp, 1, 18, usergamepath); // haleyjd 11/23/06: use basegamepath // haleyjd 08/29/09: allow use_doom_config override if(GameModeInfo->type == Game_DOOM && use_doom_config) psnprintf(temp, len, "%s/doom/keys.csc", userpath); else psnprintf(temp, len, "%s/keys.csc", usergamepath); cfg_file = estrdup(temp); if(access(cfg_file, R_OK)) { C_Printf("keys.csc not found, using defaults\n"); D_OpenLump(file, W_GetNumForName("KEYDEFS")); } else D_OpenFile(file, cfg_file, "r"); if(!D_IsOpen(file)) I_Error("G_LoadDefaults: couldn't open default key bindings\n"); // haleyjd 03/08/06: test for zero length if(!D_IsLump(file) && D_FileLength(file) == 0) { // try the lump because the file is zero-length... C_Printf("keys.csc is zero length, trying KEYDEFS\n"); D_Fclose(file); D_OpenLump(file, W_GetNumForName("KEYDEFS")); if(!D_IsOpen(file) || D_FileLength(file) == 0) I_Error("G_LoadDefaults: KEYDEFS lump is empty\n"); } C_RunScript(file); D_Fclose(file); }
// // G_ExecuteGamepadProfile // // haleyjd 05/11/13: Run a console script that can setup default bindings // for a particular model/brand of gamepad. // bool G_ExecuteGamepadProfile(const char *name) { int lumpnum; if((lumpnum = G_profileForName(name)) >= 0) { DWFILE dwfile; dwfile.openLump(lumpnum); if(dwfile.isOpen()) { G_clearGamepadBindings(); C_RunScript(&dwfile); return true; } } return false; }