MCPcopy Create free account
hub / github.com/TASEmulators/fceux / saveInputSettingsToFile

Function saveInputSettingsToFile

src/drivers/Qt/input.cpp:2418–2464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2416}
2417
2418int saveInputSettingsToFile(const char *filename)
2419{
2420 QDir dir;
2421 std::string path;
2422 const char *baseDir = FCEUI_GetBaseDirectory();
2423 char base[512];
2424
2425 path = std::string(baseDir) + "/input/presets/";
2426
2427 dir.mkpath(QString::fromStdString(path));
2428
2429 if (filename != NULL)
2430 {
2431 getFileBaseName(filename, base, NULL);
2432
2433 path += std::string(base) + ".pre";
2434 }
2435 else
2436 {
2437 const char *romFile = getRomFile();
2438
2439 if (romFile == NULL)
2440 {
2441 return -1;
2442 }
2443 getFileBaseName(romFile, base, NULL);
2444
2445 path += std::string(base) + ".pre";
2446 }
2447
2448 FILE *fp = fopen(path.c_str(), "w");
2449
2450 if (fp == NULL)
2451 {
2452 return -1;
2453 }
2454 fprintf(fp, "# Input Port Settings\n");
2455 fprintf(fp, "InputTypePort1 = %s \n", stdPortInputEncode(CurInputType[0]));
2456 fprintf(fp, "InputTypePort2 = %s \n", stdPortInputEncode(CurInputType[1]));
2457 fprintf(fp, "InputTypeExpPort = %s \n", expPortInputEncode(CurInputType[2]));
2458 fprintf(fp, "Enable4Score = %i \n", (eoptions & EO_FOURSCORE) ? 1 : 0);
2459 fprintf(fp, "EnableMicPort2 = %i \n", replaceP2StartWithMicrophone);
2460
2461 fclose(fp);
2462
2463 return 0;
2464}
2465
2466int loadInputSettingsFromFile(const char *filename)
2467{

Callers 2

CloseGameFunction · 0.85
openSavePresetFileMethod · 0.85

Calls 5

FCEUI_GetBaseDirectoryFunction · 0.85
getFileBaseNameFunction · 0.85
stdPortInputEncodeFunction · 0.85
expPortInputEncodeFunction · 0.85
getRomFileFunction · 0.70

Tested by

no test coverage detected