Skip to content

Commit 7522d7d

Browse files
author
ejaquay
committed
Add key Map Editor documentation
File docs/KeyMapEditor.txt briefly describes the editor operation Also bug where the keymap modified status was lost when leaving the key map editor has been fixed.
1 parent 428bf09 commit 7522d7d

File tree

2 files changed

+118
-6
lines changed

2 files changed

+118
-6
lines changed

docs/KeyMapEditor.txt

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
2+
Vcc KeyMap Editor
3+
Description of operation
4+
5+
The Vcc key map editor consists of two main components; the Vcc
6+
Custom Keyboard Map file and the Edit Custom Key Map dialog.
7+
These are discussed below.
8+
9+
Vcc Custom Keyboard Map File
10+
----------------------------
11+
12+
The keyboard map file is used to map host PC key codes into Color
13+
Computer 3 keys. This file has the default name "custom.keymap" and
14+
resides in the user's Vcc appdata directory. The file contains
15+
lines of text and can be edited using Notepad if that is desired.
16+
17+
Each line contains four fields (two pairs) seperated by one or
18+
more spaces or tabs. Blank lines, lines starting with "#",
19+
or anything on a line beyond four fields are comments. The first
20+
two fields on each non-comment line are the PC code and it's
21+
modifier. The second two fields are the CoCo key and it's
22+
modifier.
23+
24+
PC keynames start with "DIK_" and CoCo key names start with
25+
"COCO_". Key modifiers are specified with a single digit as
26+
follows:
27+
28+
0=not modified, 1=shift, 2=control, 3=alt.
29+
30+
A list of valid PC and CoCo key names can be found in keynames.h
31+
in Vcc sources.
32+
33+
Here is an sample entry line:
34+
35+
# PC key name Mod CoCo name Mod
36+
# ----------- --- ----------- ---
37+
DIK_EQUALS 0 COCO_MINUS 1 # "=" Coco
38+
DIK_MINUS 1 COCO_MINUS 2 # "_" NitrOS-9
39+
40+
This above example maps the "Equals" key on the host PC to
41+
"Shift" + "-" keys in Vcc and the "Shift" + "-" keys on the
42+
host PC keyboard to "Alt" + "-" keys in Vcc. This matches
43+
what is printed on the keycaps of many keyboards with what
44+
the CoCo uses.
45+
46+
The file contents are loaded into Vcc when the KeyBoard Mapping
47+
is changed to "Custom" in the Vcc Options "Keyboard" tab dialog.
48+
If the file does not exist Vcc will use default values for the
49+
custom keymapping. In this later case the "Select File" function
50+
in the Edit Custom Key Map Dialog can be used to generate the
51+
file.
52+
53+
Any CoCo key that is not mapped in the keymap file will be
54+
"dead" in Vcc. However shifted letter keys do not need to be
55+
mapped to make them uppercase because DECB and NitrOS-9 will
56+
handle this internally.
57+
58+
Whenever Vcc updates the keymap file all comments after the first
59+
valid map entry will be removed. This means user comments should
60+
be confined to the head of the file. Also entry order may be
61+
changed by the Edit Custom Key Map dialog.
62+
63+
Edit Custom Key Map dialog
64+
--------------------------
65+
66+
The edit key map dialog is activated by clicking the EDIT button
67+
in the Vcc Options "Keyboard" tab dialog. The dialog has a virtual
68+
Color Computer 3 keyboard, a file name text box, a CoCo Key text
69+
box, and Host Key text box, and the following buttons:
70+
71+
"Save Keymap" Used to save key map modfications to keymap file
72+
"Select File" Used to select the keymap file to use.
73+
"Set" Used to modify a key mapping in Vcc
74+
"Clear" Used to clear out the CoCo and Host text boxes
75+
"Exit" Used to exit the dialog.
76+
77+
Other than selecting which PC key and modifier to map the dialog
78+
can not be navigated using the PC keyboard. Buttons can only be
79+
activated with a pointing device or touch keyboard.
80+
81+
Once the dialog is entered pressing any key on the PC keyboard will
82+
cause the corresponding key button on the virtual CoCo keyboard to
83+
be pushed in and text describing the keys to appear in the CoCo
84+
Key and Host Key text boxes. If the PC key has no mapping the
85+
CoCo key text box will be blank and no button on the virtual CoCo
86+
keyboard will be pushed. Keys toggle - if the same key is pressed
87+
twice it toggled on-off. Modifier keys can be toggled either
88+
before or after non-modifier keys. This functionality allows user
89+
to quickly toggle through various PC key combinations to see the
90+
Vcc mapping of each.
91+
92+
To change a keymapping user first selects a PC key and optional
93+
modifier by the above method and then clicks on a key button(s)
94+
on the virtual CoCo keyboard. This causes the "Set" button to
95+
become active. One the desired keymapping is seen clicking the
96+
"Set" button commits the mapping to Vcc. If instead the "Clear"
97+
button is clicked or any PC key is pushed the "Set" button will
98+
be deactivated and the keymap change is canceled.
99+
100+
Changing the mapping of a key by the above method is temporary
101+
until the change is saved to the keymap file using the
102+
"Save Keymap" button (which activates if the keymap has been
103+
changed). It is considered normal to leave the Edit Key Map
104+
dialog without saving a map change. This allows user to use
105+
the change for the duration of the session without having it
106+
be permanant.
107+
108+
The keymap file name can be changed with the "Select File" button.
109+
Pressing this button brings up an open file dialog which allows
110+
user to choose a different keymap file. When a file is selected
111+
the current custom keymapping is automatically saved to it. If
112+
the file selected does not exist the user is prompted if they
113+
want to create it.
114+

keyboardEdit.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@ int LoadCustomKeyMap(char* keymapfile)
126126
if (! UserWarned) {
127127
UserWarned = 1;
128128
sprintf(buf,"%s open failed. Using defaults", keymapfile);
129-
// MessageBox(hKeyMapDlg,buf,"Warning",0);
130129
MessageBox(GetActiveWindow(),buf,"Warning",0);
131-
// TODO: Clear keymap file path?
132130
}
133131
return 1;
134132
}
@@ -601,7 +599,7 @@ BOOL InitKeymapDialog(HWND hWnd)
601599
CoCoKeySet = 0;
602600
CoCoModSet = 0;
603601

604-
EnableWindow(GetDlgItem(hKeyMapDlg,IDC_SAVE_KEYMAP),FALSE);
602+
EnableWindow(GetDlgItem(hKeyMapDlg,IDC_SAVE_KEYMAP),KeyMapChanged);
605603
EnableWindow(GetDlgItem(hKeyMapDlg,IDC_SET_CUST_KEYMAP),FALSE);
606604
EnableWindow(GetDlgItem(hKeyMapDlg,IDC_CLR_CUST_KEYMAP),FALSE);
607605

@@ -681,7 +679,7 @@ BOOL SelectCustKeymapFile() {
681679
//-----------------------------------------------------
682680
BOOL SaveCustKeymap() {
683681
if (WriteKeymap(GetKeyMapFilePath())) KeyMapChanged = FALSE;
684-
EnableWindow(GetDlgItem(hKeyMapDlg,IDC_SAVE_KEYMAP),FALSE);
682+
EnableWindow(GetDlgItem(hKeyMapDlg,IDC_SAVE_KEYMAP),KeyMapChanged);
685683
SetDialogFocus(hText_PC);
686684
return TRUE;
687685
}
@@ -757,7 +755,7 @@ BOOL SetCustomKeymap() {
757755

758756
} else {
759757
// Remove PC key from translation table
760-
//TODO: Warn user key is being unmapped
758+
//TODO: Warn user key is being unmapped?
761759
while (pKeyTran->ScanCode1 > 0) {
762760
memcpy(pKeyTran,pKeyTran+1,sizeof(keytranslationentry_t));
763761
pKeyTran++;
@@ -773,7 +771,7 @@ BOOL SetCustomKeymap() {
773771

774772
// Set map changed flag
775773
KeyMapChanged = TRUE;
776-
EnableWindow(GetDlgItem(hKeyMapDlg,IDC_SAVE_KEYMAP),TRUE);
774+
EnableWindow(GetDlgItem(hKeyMapDlg,IDC_SAVE_KEYMAP),KeyMapChanged);
777775

778776
// Reset focus
779777
SetDialogFocus(hText_PC);

0 commit comments

Comments
 (0)