@@ -221,7 +221,14 @@ void LoadConfig(SystemState *LCState)
221221unsigned char WriteIniFile (void )
222222{
223223 POINT tp = GetCurWindowSize ();
224- CurrentConfig .Resize = 1 ;
224+ CurrentConfig .Resize = 1 ; // How to restore default window size?
225+
226+ // Prevent bad window size being written to the inifile
227+ if ((tp .x < 20 ) || (tp .y < 20 )) {
228+ tp .x = 640 ;
229+ tp .y = 480 ;
230+ }
231+
225232 GetCurrentModule (CurrentConfig .ModulePath );
226233 ValidatePath (CurrentConfig .ModulePath );
227234 ValidatePath (CurrentConfig .ExternalBasicImage );
@@ -449,8 +456,6 @@ LRESULT CALLBACK Config(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
449456 SoundInit (EmuState .WindowHandle ,SoundCards [TempConfig .SndOutDev ].Guid ,TempConfig .AudioRate );
450457
451458 CurrentConfig = TempConfig ;
452-
453- if (CurrentConfig .KeyMap == kKBLayoutCustom ) LoadCustomKeyMap (GetKeyMapFilePath ());
454459 vccKeyboardBuildRuntimeTable ((keyboardlayout_e )CurrentConfig .KeyMap );
455460
456461 Right = TempRight ;
@@ -477,8 +482,6 @@ LRESULT CALLBACK Config(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
477482 SoundInit (EmuState .WindowHandle ,SoundCards [TempConfig .SndOutDev ].Guid ,TempConfig .AudioRate );
478483
479484 CurrentConfig = TempConfig ;
480-
481- if (CurrentConfig .KeyMap == kKBLayoutCustom ) LoadCustomKeyMap (GetKeyMapFilePath ());
482485 vccKeyboardBuildRuntimeTable ((keyboardlayout_e )CurrentConfig .KeyMap );
483486
484487 Right = TempRight ;
@@ -917,19 +920,23 @@ LRESULT CALLBACK InputConfig(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
917920 break ;
918921
919922 case WM_COMMAND :
920- if (LOWORD (wParam )== IDC_KEYMAPED ) {
921- // Insure custom keyboard is selected (unless canceled).
922- if (CurrentConfig .KeyMap != 3 ) {
923- TempConfig .KeyMap = 3 ;
924- SendDlgItemMessage (hDlg ,IDC_KBCONFIG ,CB_SETCURSEL ,(WPARAM )TempConfig .KeyMap ,0 );
925- }
926-
923+ // If Custom keymap button pushed
924+ if (LOWORD (wParam )== IDC_KEYMAPED ) {
925+ // Insure custom keyboard is selected.
926+ if (TempConfig .KeyMap != kKBLayoutCustom ) {
927+ TempConfig .KeyMap = kKBLayoutCustom ;
928+ SendDlgItemMessage (hDlg ,IDC_KBCONFIG ,CB_SETCURSEL ,
929+ (WPARAM )TempConfig .KeyMap ,0 );
930+ }
931+ // Run the keymap editor
927932 DialogBox ( EmuState .WindowInstance , (LPCTSTR ) IDD_KEYMAPEDIT , hDlg ,
928933 (DLGPROC ) KeyMapProc );
929- } else {
930- TempConfig .KeyMap = (unsigned char )
931- SendDlgItemMessage (hDlg ,IDC_KBCONFIG ,CB_GETCURSEL ,0 ,0 );
934+ } else {
935+ // Set temporary keymap to the one currently selected
936+ TempConfig .KeyMap = (unsigned char )
937+ SendDlgItemMessage (hDlg ,IDC_KBCONFIG ,CB_GETCURSEL ,0 ,0 );
932938 }
939+
933940 break ;
934941 }
935942 return (0 );
0 commit comments