Skip to content

Commit

Permalink
Merge pull request #81 from ejaquay/VCC_2.0.1c
Browse files Browse the repository at this point in the history
keyboardLayout.c
  • Loading branch information
ejaquay committed Jul 24, 2021
2 parents 1c8f9ab + f38779c commit a2ddf99
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 20 deletions.
40 changes: 24 additions & 16 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,14 @@ void LoadConfig(SystemState *LCState)
unsigned char WriteIniFile(void)
{
POINT tp = GetCurWindowSize();
CurrentConfig.Resize = 1;
CurrentConfig.Resize = 1; // How to restore default window size?

// Prevent bad window size being written to the inifile
if ((tp.x < 20) || (tp.y < 20)) {
tp.x = 640;
tp.y = 480;
}

GetCurrentModule(CurrentConfig.ModulePath);
ValidatePath(CurrentConfig.ModulePath);
ValidatePath(CurrentConfig.ExternalBasicImage);
Expand Down Expand Up @@ -449,8 +456,6 @@ LRESULT CALLBACK Config(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
SoundInit(EmuState.WindowHandle,SoundCards[TempConfig.SndOutDev].Guid,TempConfig.AudioRate);

CurrentConfig=TempConfig;

if (CurrentConfig.KeyMap == kKBLayoutCustom) LoadCustomKeyMap(GetKeyMapFilePath());
vccKeyboardBuildRuntimeTable((keyboardlayout_e)CurrentConfig.KeyMap);

Right=TempRight;
Expand All @@ -477,8 +482,6 @@ LRESULT CALLBACK Config(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
SoundInit(EmuState.WindowHandle,SoundCards[TempConfig.SndOutDev].Guid,TempConfig.AudioRate);

CurrentConfig=TempConfig;

if (CurrentConfig.KeyMap == kKBLayoutCustom) LoadCustomKeyMap(GetKeyMapFilePath());
vccKeyboardBuildRuntimeTable((keyboardlayout_e)CurrentConfig.KeyMap);

Right=TempRight;
Expand Down Expand Up @@ -917,18 +920,23 @@ LRESULT CALLBACK InputConfig(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
break;

case WM_COMMAND:
TempConfig.KeyMap = (unsigned char)
SendDlgItemMessage(hDlg,IDC_KBCONFIG,CB_GETCURSEL,0,0);
if (LOWORD(wParam)==IDC_KEYMAPED) {
// Notify user if custom keyboard if not selected but allow edit anyway.
if (CurrentConfig.KeyMap != 3) {
MessageBox(0, "The custom keyboard map is not currently applied. For edits "
"to take effect select Custom mapping AND Apply when done.",
"Notice", 0);
}
DialogBox( EmuState.WindowInstance, (LPCTSTR) IDD_KEYMAPEDIT, hDlg,
// If Custom keymap button pushed
if (LOWORD(wParam)==IDC_KEYMAPED) {
// Insure custom keyboard is selected.
if (TempConfig.KeyMap != kKBLayoutCustom) {
TempConfig.KeyMap = kKBLayoutCustom;
SendDlgItemMessage(hDlg,IDC_KBCONFIG,CB_SETCURSEL,
(WPARAM)TempConfig.KeyMap,0);
}
// Run the keymap editor
DialogBox( EmuState.WindowInstance, (LPCTSTR) IDD_KEYMAPEDIT, hDlg,
(DLGPROC) KeyMapProc );
}
} else {
// Set temporary keymap to the one currently selected
TempConfig.KeyMap = (unsigned char)
SendDlgItemMessage(hDlg,IDC_KBCONFIG,CB_GETCURSEL,0,0);
}

break;
}
return(0);
Expand Down
9 changes: 6 additions & 3 deletions keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ This file is part of VCC (Virtual Color Computer).

#include "xDebug.h"


/*****************************************************************************/
/*
Forward declarations
*/

char SetMouseStatus(char, unsigned char);
unsigned char SetMouseStatus(unsigned char, unsigned char);
bool pasting = false; //Are the keyboard functions in the middle of a paste operation?

/*****************************************************************************/
Expand Down Expand Up @@ -671,11 +672,13 @@ unsigned short get_pot_value(unsigned char pot)
/*****************************************************************************/
/**
*/
char SetMouseStatus(char ScanCode,unsigned char Phase)
unsigned char SetMouseStatus(unsigned char ScanCode,unsigned char Phase)
{
char ReturnValue=ScanCode;

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

switch (Phase)
Expand Down
8 changes: 7 additions & 1 deletion keyboardLayout.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ keytranslationentry_t keyTranslationsCoCo[] =

{ DIK_RETURN, 0, 64, 0, 0, 0 }, // ENTER
{ DIK_NUMPAD7, 0, 64, 1, 0, 0 }, // HOME (CLEAR)
{ DIK_NUMPAD1, 0, 64, 2, 0, 0 }, // ESCAPE (BREAK)
{ DIK_HOME, 0, 64, 1, 0, 0 }, // HOME (CLEAR)
{ DIK_NUMPAD1, 0, 64, 2, 0, 0 }, // ESCAPE (BREAK)
{ DIK_END, 0, 64, 2, 0, 0 }, // ESCAPE (BREAK)
{ DIK_F1, 0, 64, 5, 0, 0 }, // F1
{ DIK_F2, 0, 64, 6, 0, 0 }, // F2
{ DIK_BACK, 0, 8, 5, 0, 0 }, // BACKSPACE -> CoCo left arrow
Expand Down Expand Up @@ -298,9 +300,11 @@ keytranslationentry_t keyTranslationsNatural[] =

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

{ DIK_RETURN, 0, 64, 0, 0, 0 }, // ENTER
{ DIK_NUMPAD7, 0, 64, 1, 0, 0 }, // HOME (CLEAR)
{ DIK_HOME, 0, 64, 1, 0, 0 }, // HOME (CLEAR)
{ DIK_ESCAPE, 0, 64, 2, 0, 0 }, // ESCAPE (BREAK)
{ DIK_NUMPAD1, 0, 64, 7, 8, 6 }, // END OF LINE (SHIFT)(RIGHT)
{ DIK_END, 0, 64, 7, 8, 6 }, // END OF LINE (SHIFT)(RIGHT)
{ DIK_NUMPADPERIOD, 0, 64, 4, 8, 5 }, // DELETE (CTRL)(LEFT)
{ DIK_NUMPAD0, 0, 64, 4, 8, 6 }, // INSERT (CTRL)(RIGHT)
{ DIK_NUMPAD9, 0, 64, 7, 8, 3 }, // PAGEUP (SHFT)(UP)
Expand Down

0 comments on commit a2ddf99

Please sign in to comment.