MCPcopy Create free account
hub / github.com/CalcProgrammer1/KeyboardVisualizer / SaveSettings

Method SaveSettings

KeyboardVisualizerCommon/Visualizer.cpp:299–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297}
298
299void Visualizer::SaveSettings()
300{
301 std::ofstream outfile;
302 char filename[2048];
303 char out_str[1024];
304
305 //Check background flags, they both should not be set
306 if ((silent_bkgd == TRUE) && (reactive_bkgd == TRUE))
307 {
308 silent_bkgd = FALSE;
309 }
310
311 //Get file path in executable directory
312//#ifdef WIN32
313// GetModuleFileName(NULL, filename, 2048);
314// strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
315// strcat(filename, "\\settings.txt");
316//#else
317// char arg1[64];
318// snprintf(arg1, 64, "/proc/%d/exe", getpid());
319// readlink(arg1, filename, 1024);
320// strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
321// strcat(filename, "/settings.txt");
322//#endif
323
324 //Open settings file
325 outfile.open(filename);
326
327 //Save Amplitude
328 snprintf(out_str, 1024, "amplitude=%d\r\n", amplitude);
329 outfile.write(out_str, strlen(out_str));
330
331 //Save Background Brightness
332 snprintf(out_str, 1024, "bkgd_bright=%d\r\n", bkgd_bright);
333 outfile.write(out_str, strlen(out_str));
334
335 //Save Average Size
336 snprintf(out_str, 1024, "avg_size=%d\r\n", avg_size);
337 outfile.write(out_str, strlen(out_str));
338
339 //Save Decay
340 snprintf(out_str, 1024, "decay=%d\r\n", decay);
341 outfile.write(out_str, strlen(out_str));
342
343 //Save Delay
344 snprintf(out_str, 1024, "delay=%d\r\n", delay);
345 outfile.write(out_str, strlen(out_str));
346
347 //Save Normalization Offset
348 snprintf(out_str, 1024, "nrml_ofst=%f\r\n", nrml_ofst);
349 outfile.write(out_str, strlen(out_str));
350
351 //Save Normalization Scale
352 snprintf(out_str, 1024, "nrml_scl=%f\r\n", nrml_scl);
353 outfile.write(out_str, strlen(out_str));
354
355 //Save Filter Constant
356 snprintf(out_str, 1024, "fltr_const=%f\r\n", filter_constant);

Calls

no outgoing calls

Tested by

no test coverage detected