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

Function PresetExport

src/drivers/win/input.cpp:1912–1949  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1910}
1911
1912static void PresetExport(int preset)
1913{
1914 const char filter[]="Input Preset File (*.pre)\0*.pre\0All Files (*.*)\0*.*\0\0";
1915 char nameo[2048];
1916 OPENFILENAME ofn;
1917 memset(&ofn,0,sizeof(ofn));
1918 ofn.lStructSize=sizeof(ofn);
1919 ofn.hInstance=fceu_hInstance;
1920 ofn.lpstrTitle="Export Input Preset To...";
1921 ofn.lpstrFilter=filter;
1922 nameo[0]=0; //No default filename
1923 ofn.lpstrFile=nameo;
1924 ofn.lpstrDefExt="pre";
1925 ofn.nMaxFile=256;
1926 ofn.Flags=OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
1927 std::string initdir = FCEU_GetPath(FCEUMKF_INPUT).c_str();
1928 ofn.lpstrInitialDir=initdir.c_str();
1929 if(GetSaveFileName(&ofn))
1930 {
1931 //Save the directory
1932 if(ofn.nFileOffset < 1024)
1933 {
1934 free(InputPresetDir);
1935 InputPresetDir=(char*)malloc(strlen(ofn.lpstrFile)+1);
1936 strcpy(InputPresetDir,ofn.lpstrFile);
1937 InputPresetDir[ofn.nFileOffset]=0;
1938 }
1939
1940 FILE *fp=FCEUD_UTF8fopen(nameo,"w");
1941 switch(preset)
1942 {
1943 case 1: fwrite(GamePadPreset1,1,sizeof(GamePadPreset1),fp); break;
1944 case 2: fwrite(GamePadPreset2,1,sizeof(GamePadPreset2),fp); break;
1945 case 3: fwrite(GamePadPreset3,1,sizeof(GamePadPreset3),fp); break;
1946 }
1947 fclose(fp);
1948 }
1949}
1950
1951static void PresetImport(int preset)
1952{

Callers 1

InputConCallBFunction · 0.85

Calls 2

FCEU_GetPathFunction · 0.85
FCEUD_UTF8fopenFunction · 0.70

Tested by

no test coverage detected