in Lilypad/Config.cpp [723:815]
int SaveSettings(wchar_t *file=0) {
// Need this either way for saving path.
if (!file) {
file = iniFile;
}
else {
wchar_t *c = wcsrchr(file, '\\');
if (*c) {
*c = 0;
wcscpy(config.lastSaveConfigPath, file);
wcscpy(config.lastSaveConfigFileName, c+1);
*c = '\\';
}
}
DeleteFileW(file);
WritePrivateProfileStringW(L"General Settings", L"Last Config Path", config.lastSaveConfigPath, iniFile);
WritePrivateProfileStringW(L"General Settings", L"Last Config Name", config.lastSaveConfigFileName, iniFile);
// Just check first, last, and all pad bindings. Should be more than enough. No real need to check
// config path.
int noError = 1;
for (int i=0; i<sizeof(BoolOptionsInfo)/sizeof(BoolOptionsInfo[0]); i++) {
noError &= WritePrivateProfileInt(L"General Settings", BoolOptionsInfo[i].name, config.bools[i], file);
}
WritePrivateProfileInt(L"General Settings", L"Close Hacks", config.closeHacks, file);
WritePrivateProfileInt(L"General Settings", L"Keyboard Mode", config.keyboardApi, file);
WritePrivateProfileInt(L"General Settings", L"Mouse Mode", config.mouseApi, file);
WritePrivateProfileInt(L"General Settings", L"Volume", config.volume, file);
for (int port=0; port<2; port++) {
for (int slot=0; slot<4; slot++) {
wchar_t temp[50];
wsprintf(temp, L"Pad %i %i", port, slot);
WritePrivateProfileInt(temp, L"Mode", config.padConfigs[port][slot].type, file);
noError &= WritePrivateProfileInt(temp, L"Auto Analog", config.padConfigs[port][slot].autoAnalog, file);
}
}
for (int i=0; i<dm->numDevices; i++) {
wchar_t id[50];
wchar_t temp[50], temp2[1000];
wsprintfW(id, L"Device %i", i);
Device *dev = dm->devices[i];
wchar_t *name = dev->displayName;
while (name[0] == '[') {
wchar_t *name2 = wcschr(name, ']');
if (!name2) break;
name = name2+1;
while (iswspace(name[0])) name++;
}
WritePrivateProfileStringW(id, L"Display Name", name, file);
WritePrivateProfileStringW(id, L"Instance ID", dev->instanceID, file);
if (dev->productID) {
WritePrivateProfileStringW(id, L"Product ID", dev->productID, file);
}
WritePrivateProfileInt(id, L"API", dev->api, file);
WritePrivateProfileInt(id, L"Type", dev->type, file);
int ffBindingCount = 0;
int bindingCount = 0;
for (int port=0; port<2; port++) {
for (int slot=0; slot<4; slot++) {
for (int j=0; j<dev->pads[port][slot].numBindings; j++) {
Binding *b = dev->pads[port][slot].bindings+j;
VirtualControl *c = &dev->virtualControls[b->controlIndex];
wsprintfW(temp, L"Binding %i", bindingCount++);
wsprintfW(temp2, L"0x%08X, %i, %i, %i, %i, %i, %i", c->uid, port, b->command, b->sensitivity, b->turbo, slot, b->deadZone);
noError &= WritePrivateProfileStringW(id, temp, temp2, file);
}
for (int j=0; j<dev->pads[port][slot].numFFBindings; j++) {
ForceFeedbackBinding *b = dev->pads[port][slot].ffBindings+j;
ForceFeedbackEffectType *eff = &dev->ffEffectTypes[b->effectIndex];
wsprintfW(temp, L"FF Binding %i", ffBindingCount++);
wsprintfW(temp2, L"%s %i, %i, %i", eff->effectID, port, b->motor, slot);
for (int k=0; k<dev->numFFAxes; k++) {
ForceFeedbackAxis *axis = dev->ffAxes + k;
AxisEffectInfo *info = b->axes + k;
wsprintfW(wcschr(temp2,0), L", %i, %i", axis->id, info->force);
}
noError &= WritePrivateProfileStringW(id, temp, temp2, file);
}
}
}
}
if (!noError) {
MessageBoxA(hWndProp, "Unable to save settings. Make sure the disk is not full or write protected, the file isn't write protected, and that the app has permissions to write to the directory. On Vista, try running in administrator mode.", "Error Writing Configuration File", MB_OK | MB_ICONERROR);
}
return !noError;
}