Skip to content

Commit 3cd014d

Browse files
author
ejaquay
committed
Prevent bad window size when Vcc.ini is missing
config.c prevent write bad window size (x or y < 20 pixels) to inifile clean up reloading of custom keymap keyboardLayout.c add home key mapping to custom keymap fallback
1 parent e16dd98 commit 3cd014d

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

config.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,14 @@ void LoadConfig(SystemState *LCState)
221221
unsigned 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);

keyboardLayout.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ keytranslationentry_t keyTranslationsCustom[MAX_CTRANSTBLSIZ] =
576576

577577
{ DIK_RETURN, 0, 64, 0, 0, 0 }, // ENTER
578578
{ DIK_NUMPAD7, 0, 64, 1, 0, 0 }, // HOME (CLEAR)
579+
{ DIK_HOME, 0, 64, 1, 0, 0 }, // HOME (CLEAR)
579580
{ DIK_ESCAPE, 0, 64, 2, 0, 0 }, // ESCAPE (BREAK)
580581
{ DIK_NUMPAD1, 0, 64, 7, 8, 6 }, // END OF LINE (SHIFT)(RIGHT)
581582
{ DIK_NUMPADPERIOD, 0, 64, 4, 8, 5 }, // DELETE (CTRL)(LEFT)

0 commit comments

Comments
 (0)