Skip to content

Commit a2ddf99

Browse files
authored
Merge pull request #81 from ejaquay/VCC_2.0.1c
keyboardLayout.c
2 parents 1c8f9ab + f38779c commit a2ddf99

File tree

3 files changed

+37
-20
lines changed

3 files changed

+37
-20
lines changed

config.c

Lines changed: 24 additions & 16 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,18 +920,23 @@ LRESULT CALLBACK InputConfig(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
917920
break;
918921

919922
case WM_COMMAND:
920-
TempConfig.KeyMap = (unsigned char)
921-
SendDlgItemMessage(hDlg,IDC_KBCONFIG,CB_GETCURSEL,0,0);
922-
if (LOWORD(wParam)==IDC_KEYMAPED) {
923-
// Notify user if custom keyboard if not selected but allow edit anyway.
924-
if (CurrentConfig.KeyMap != 3) {
925-
MessageBox(0, "The custom keyboard map is not currently applied. For edits "
926-
"to take effect select Custom mapping AND Apply when done.",
927-
"Notice", 0);
928-
}
929-
DialogBox( EmuState.WindowInstance, (LPCTSTR) IDD_KEYMAPEDIT, hDlg,
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
932+
DialogBox( EmuState.WindowInstance, (LPCTSTR) IDD_KEYMAPEDIT, hDlg,
930933
(DLGPROC) KeyMapProc );
931-
}
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);
938+
}
939+
932940
break;
933941
}
934942
return(0);

keyboard.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ This file is part of VCC (Virtual Color Computer).
4747

4848
#include "xDebug.h"
4949

50+
5051
/*****************************************************************************/
5152
/*
5253
Forward declarations
5354
*/
5455

55-
char SetMouseStatus(char, unsigned char);
56+
unsigned char SetMouseStatus(unsigned char, unsigned char);
5657
bool pasting = false; //Are the keyboard functions in the middle of a paste operation?
5758

5859
/*****************************************************************************/
@@ -671,11 +672,13 @@ unsigned short get_pot_value(unsigned char pot)
671672
/*****************************************************************************/
672673
/**
673674
*/
674-
char SetMouseStatus(char ScanCode,unsigned char Phase)
675+
unsigned char SetMouseStatus(unsigned char ScanCode,unsigned char Phase)
675676
{
676677
char ReturnValue=ScanCode;
677678

678-
// Allow extended keyboard arrow keys
679+
// Mask scan code high bit to accept keys from extended keyboard arrow
680+
// keypad. A more elegant solution would be to use the virtual key code
681+
// for joystick mappings but that would require changes to config.c as well.
679682
ScanCode = ScanCode & 0x7F;
680683

681684
switch (Phase)

keyboardLayout.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ keytranslationentry_t keyTranslationsCoCo[] =
164164

165165
{ DIK_RETURN, 0, 64, 0, 0, 0 }, // ENTER
166166
{ DIK_NUMPAD7, 0, 64, 1, 0, 0 }, // HOME (CLEAR)
167-
{ DIK_NUMPAD1, 0, 64, 2, 0, 0 }, // ESCAPE (BREAK)
167+
{ DIK_HOME, 0, 64, 1, 0, 0 }, // HOME (CLEAR)
168+
{ DIK_NUMPAD1, 0, 64, 2, 0, 0 }, // ESCAPE (BREAK)
169+
{ DIK_END, 0, 64, 2, 0, 0 }, // ESCAPE (BREAK)
168170
{ DIK_F1, 0, 64, 5, 0, 0 }, // F1
169171
{ DIK_F2, 0, 64, 6, 0, 0 }, // F2
170172
{ DIK_BACK, 0, 8, 5, 0, 0 }, // BACKSPACE -> CoCo left arrow
@@ -298,9 +300,11 @@ keytranslationentry_t keyTranslationsNatural[] =
298300

299301
{ DIK_RETURN, 0, 64, 0, 0, 0 }, // ENTER
300302
{ DIK_NUMPAD7, 0, 64, 1, 0, 0 }, // HOME (CLEAR)
303+
{ DIK_HOME, 0, 64, 1, 0, 0 }, // HOME (CLEAR)
301304
{ DIK_ESCAPE, 0, 64, 2, 0, 0 }, // ESCAPE (BREAK)
302305
{ DIK_F12, 0, 64, 2, 0, 0 }, // Alternate ESCAPE (BREAK) (fixes <CNTRL><BRK> sequence)
303306
{ DIK_NUMPAD1, 0, 64, 7, 8, 6 }, // END OF LINE (SHIFT)(RIGHT)
307+
{ DIK_END, 0, 64, 7, 8, 6 }, // END OF LINE (SHIFT)(RIGHT)
304308
{ DIK_NUMPADPERIOD, 0, 64, 4, 8, 5 }, // DELETE (CTRL)(LEFT)
305309
{ DIK_NUMPAD0, 0, 64, 4, 8, 6 }, // INSERT (CTRL)(RIGHT)
306310
{ DIK_NUMPAD9, 0, 64, 7, 8, 3 }, // PAGEUP (SHFT)(UP)
@@ -574,8 +578,10 @@ keytranslationentry_t keyTranslationsCustom[MAX_CTRANSTBLSIZ] =
574578

575579
{ DIK_RETURN, 0, 64, 0, 0, 0 }, // ENTER
576580
{ DIK_NUMPAD7, 0, 64, 1, 0, 0 }, // HOME (CLEAR)
581+
{ DIK_HOME, 0, 64, 1, 0, 0 }, // HOME (CLEAR)
577582
{ DIK_ESCAPE, 0, 64, 2, 0, 0 }, // ESCAPE (BREAK)
578583
{ DIK_NUMPAD1, 0, 64, 7, 8, 6 }, // END OF LINE (SHIFT)(RIGHT)
584+
{ DIK_END, 0, 64, 7, 8, 6 }, // END OF LINE (SHIFT)(RIGHT)
579585
{ DIK_NUMPADPERIOD, 0, 64, 4, 8, 5 }, // DELETE (CTRL)(LEFT)
580586
{ DIK_NUMPAD0, 0, 64, 4, 8, 6 }, // INSERT (CTRL)(RIGHT)
581587
{ DIK_NUMPAD9, 0, 64, 7, 8, 3 }, // PAGEUP (SHFT)(UP)

0 commit comments

Comments
 (0)