# VICE keyboard mapping file
#
# A Keyboard map is read in as patch to the current map.
#
# File format:
# - comment lines start with '#'
# - keyword lines start with '!keyword'
# - normal lines have 'keysym/scancode row column shiftflag'
#
# Keywords and their lines are:
# '!CLEAR'               clear whole table
# '!INCLUDE filename'    read file as mapping file
# '!LSHIFT row col'      left shift keyboard row/column
# '!RSHIFT row col'      right shift keyboard row/column
# '!VSHIFT shiftkey'     virtual shift key (RSHIFT or LSHIFT)
# '!SHIFTL shiftkey'     shift lock key (RSHIFT or LSHIFT)
#  for emulated keyboards that have only one shift key, set both LSHIFT
#  and RSHIFT to the same row/col and use RSHIFT for VSHIFT and SHIFTL.
# '!LCTRL row col'       left control keyboard row/column
# '!VCTRL ctrlkey'       virtual control key (LCTRL)
# '!LCBM row col'        left CBM keyboard row/column
# '!VCBM cbmkey'         virtual CBM key (LCBM)
# '!UNDEF keysym'        remove keysym from table
#
# Shiftflag can have these values, flags can be ORed to combine them:
# 0x0000      0  key is not shifted for this keysym/scancode
# 0x0001      1  key is combined with shift for this keysym/scancode
# 0x0002      2  key is left shift on emulated machine
# 0x0004      4  key is right shift on emulated machine (use only this one
#                for emulated keyboards that have only one shift key)
# 0x0008      8  key can be shifted or not with this keysym/scancode
# 0x0010     16  deshift key for this keysym/scancode
# 0x0020     32  another definition for this keysym/scancode follows
# 0x0040     64  key is shift-lock on emulated machine
# 0x0080    128  shift modifier required on host
# 0x0100    256  key is used for an alternative keyboard mapping, e.g. C64 mode in x128
# 0x0200    512  alt-r (alt-gr) modifier required on host
# 0x0400   1024  ctrl modifier required on host
# 0x0800   2048  key is combined with cbm for this keysym/scancode
# 0x1000   4096  key is combined with ctrl for this keysym/scancode
# 0x2000   8192  key is (left) cbm on emulated machine
# 0x4000  16384  key is (left) ctrl on emulated machine
#
# Negative row values:
# 'keysym -1 n' joystick keymap A, direction n
# 'keysym -2 n' joystick keymap B, direction n
# 'keysym -3 0' first RESTORE key
# 'keysym -3 1' second RESTORE key
# 'keysym -4 0' 40/80 column key (x128)
# 'keysym -4 1' CAPS (ASCII/DIN) key (x128)
# 'keysym -5 n' joyport keypad, key n (not supported in x128)
#
# Joystick direction values:
# 0      Fire
# 1      South/West
# 2      South
# 3      South/East
# 4      West
# 5      East
# 6      North/West
# 7      North
# 8      North/East
#
# Joyport keypad key layout:
# --------------------------
# |  0 |  1 |  2 |  3 |  4 |
# --------------------------
# |  5 |  6 |  7 |  8 |  9 |
# --------------------------
# | 10 | 11 | 12 | 13 | 14 |
# --------------------------
# | 15 | 16 | 17 | 18 | 19 |
# --------------------------
#
# When a bigger spaced key is used,
# it uses the upper left most key value.

# Symbolic Mapping, US Layout, CBM2, GTK

# Commodore cbm2 keyboard matrix:
#
# references:
#  http://www.zimmers.net/anonftp/pub/cbm/b/documents/de/keyboard-matrix.gif
#  http://www.zimmers.net/anonftp/pub/cbm/b/documents/keymap-us.gif
#  http://www.zimmers.net/anonftp/pub/cbm/schematics/computers/b/p500-keyboard.txt
#  http://www.floodgap.com/retrobits/ckb/secret/cbm-610-keyboard.jpg
#
# Keys starting with 'KP' are on the number pad. Both shifts and shift lock
# are in parallel at one point in matrix.
#
#       0        1        2        3        4        5
#   +--------+--------+--------+--------+--------+--------+
# 0 |   F9   |  9  (  |   O    |   L    |  ;  :  |  /  ?  |
#   +--------+--------+--------+--------+--------+--------+
# 1 |  F10   |  0  )  |   -    |   P    |   [    |  '  "  |
#   +--------+--------+--------+--------+--------+--------+
# 2 | c.down |  =  +  |<- pound|   ]    | return |  pi    |
#   +--------+--------+--------+--------+--------+--------+
# 3 | c.up   | c.left | c.right|del ins | CBM    |########|
#   +--------+--------+--------+--------+--------+--------+
# 4 |home/clr|KP ?    |KP 7    |KP 4    |KP 1    |KP 0    |
#   +--------+--------+--------+--------+--------+--------+
# 5 |rvs/off |KP CE   |KP 8    |KP 5    |KP 2    |KP .    |
#   +--------+--------+--------+--------+--------+--------+
# 6 | graph  |KP *    |KP 9    |KP 6    |KP 3    |KP 00   |
#   +--------+--------+--------+--------+--------+--------+
# 7 |run/stop|KP /    |KP -    |KP +    |KP enter|########|
#   +--------+--------+--------+--------+--------+--------+
# 8 |   F1   | escape |  TAB   |########| Shift  | CTRL   |
#   +--------+--------+--------+--------+--------+--------+
# 9 |   F2   |  1  !  |   Q    |   A    |   Z    |########|
#   +--------+--------+--------+--------+--------+--------+
#10 |   F3   |  2  @  |   W    |   S    |   X    |   C    |
#   +--------+--------+--------+--------+--------+--------+
#11 |   F4   |  3  #  |   E    |   D    |   F    |   V    |
#   +--------+--------+--------+--------+--------+--------+
#12 |   F5   |  4  $  |   R    |   T    |   G    |   B    |
#   +--------+--------+--------+--------+--------+--------+
#13 |   F6   |  5  %  |  6  ^  |   Y    |   H    |   N    |
#   +--------+--------+--------+--------+--------+--------+
#14 |   F7   |  7  &  |   U    |   J    |   M    | space  |
#   +--------+--------+--------+--------+--------+--------+
#15 |   F8   |  8  *  |   I    |   K    |  ,  <  |  .  >  |
#   +--------+--------+--------+--------+--------+--------+

#   CBM2 Keyboard layout:
#
#   F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 down up left right clr rvs graph r/s
#
#   ESC 1!  2@  3#  4$  5%  6^  7&  8*  9(  0)  -   =+  arrow/pound del     ?   CE  *   /
#    TAB q   w   e   r   t   y   u   i   o   p   [   ]   return             7   8   9   -
#     SL  a   s   d   f   g   h   j   k   l   ;:  '"  pi                    4   5   6   +
#      LS  z   x   c   v   b   n   m   ,<  .>  /?  RS   CBM                 1   2   3
#       CTRL    SPACE                                                       0   .   00  enter

!CLEAR
!LSHIFT 8 4
!RSHIFT 8 4
!VSHIFT RSHIFT
!SHIFTL RSHIFT
!LCBM 3 4
!VCBM LCBM
!LCTRL 8 5
!VCTRL LCTRL

#Escape          7 0 8         /*       Escape -> Run/Stop     */
Escape          8 1 8         /*      Escape  -> ESC          */

F11             2 5 8         /*    F11 -> pi */

Tab             8 2 8
KP_Tab          8 2 8
ISO_Left_Tab    8 2 1

Control_L       8 5 16384     /* left ctrl -> CTRL */
Control_R       3 4 8192      /* right ctrl -> CBM */

Shift_L         8 4 4
Shift_R         8 4 4

Caps_Lock       8 4 64        /*    Caps Lock -> Shift-Lock   */

Down            2 0 8
Right           3 2 8
Left            3 1 0
Up              3 0 0

#Insert          3 3 1
#Delete          3 3 0
Insert          6 5 8       /* insert -> kp 00 */
Delete          5 1 0       /* delete -> kp CE */
Home            4 0 8
End             5 0 8        /* End -> RVS OFF */

#Page_Up         8 1 8         /*      Page up -> ESC          */
#Prior           8 1 8         /*      Page up -> ESC          */
#F12             8 1 8         /*          F12 -> ESC          */
Page_Up         7 0 8         /*      Page up -> Run/Stop          */
Prior           7 0 8         /*      Page up -> Run/Stop          */
F12             7 0 8         /*          F12 -> Run/Stop          */
Next            6 0 8

# top row, no shift
grave           1 5 16    /* ` -> */
dead_grave      1 5 16    /* US-Int. dead key support */
minus           1 2 0
equal           2 1 0
BackSpace       3 3 8

# top row, with shift
asciitilde          2 2 16    /* ~ -> arrow left */
dead_tilde          2 2 16    /* US-Int. dead key support */
dead_perispomeni    2 2 16    /* US-Int. dead key support */
exclam          9 1 1
at             10 1 1
numbersign     11 1 1
dollar         12 1 1
percent        13 1 1
asciicircum         13 2 8
dead_circumflex     13 2 8     /* US-Int. dead key support */
ampersand      14 1 1
asterisk       15 1 1
parenleft       0 1 1
parenright      1 1 1
underscore      2 2 16
plus            2 1 1

# 2nd row, no shift
bracketleft     1 4 0
bracketright    2 3 0
backslash       2 2 0   /* \ -> pound */

# 2nd row, with shift
bar             2 2 1   /* | -> arrow left */

# 3rd row, no shift
semicolon       0 4 0
apostrophe      1 5 0
dead_acute      1 5 0     /* US-Int. dead key support */
Return          2 4 0

# 3rd row, with shift
colon           0 4 1
quotedbl        1 5 1
dead_diaeresis  1 5 1     /* US-Int. dead key support */

# 4th row, no shift
comma          15 4 0
period         15 5 0
question        0 5 0x21
slash           0 5 0x20
slash           4 1 0x0400     /* ctrl+/ -> KP ? + shift */
question        4 1 0x0401     /* ctrl+/ -> KP ? + shift */

# 4th row, with shift
less           15 4 1
greater        15 5 1
#question        4 1 0

space          14 5 8

#Clear 4 0 1

0               1 1 0
1               9 1 0
2              10 1 0
3              11 1 0
4              12 1 0
5              13 1 0
6              13 2 0
7              14 1 0
8              15 1 0
9               0 1 0

a               9 3 0
b              12 5 0
c              10 5 0
d              11 3 0
e              11 2 0
f              11 4 0
g              12 4 0
h              13 4 0
i              15 2 0
j              14 3 0
k              15 3 0
l               0 3 0
m              14 4 0
n              13 5 0
o               0 2 0
p               1 3 0
q               9 2 0
r              12 2 0
s              10 3 0
t              12 3 0
u              14 2 0
v              11 5 0
w              10 2 0
x              10 4 0
y              13 3 0
z               9 4 0

W              10 2 1
A               9 3 1
Z               9 4 1
S              10 3 1
E              11 2 1
R              12 2 1
D              11 3 1
C              10 5 1
F              11 4 1
T              12 3 1
X              10 4 1
Y              13 3 1
G              12 4 1
B              12 5 1
H              13 4 1
U              14 2 1
V              11 5 1
I              15 2 1
J              14 3 1
M              14 4 1
K              15 3 1
O               0 2 1
N              13 5 1
P               1 3 1
L               0 3 1
Q               9 2 1

F1              8 0 8
F2              9 0 8
F3             10 0 8
F4             11 0 8
F5             12 0 8
F6             13 0 8
F7             14 0 8
F8             15 0 8
F9              0 0 8
F10             1 0 8

# numeric keypad

KP_0            4 5 8
KP_Insert       4 5 8         /*         KP 0 -> KP 0 + Shift */
KP_1            4 4 8
KP_End          4 4 8         /*         KP 1 -> KP 1 + Shift */
KP_2            5 4 8
KP_Down         5 4 8         /*         KP 2 -> KP 2 + Shift */
KP_3            6 4 8
KP_Next         6 4 8         /*         KP 3 -> KP 3 + Shift */
KP_4            4 3 8
KP_Left         4 3 8         /*         KP 4 -> KP 4 + Shift */
KP_5            5 3 8
KP_Begin        5 3 8         /*         KP 5 -> KP 5 + Shift */
KP_6            6 3 8
KP_Right        6 3 8         /*         KP 6 -> KP 6 + Shift */
KP_7            4 2 8
KP_Home         4 2 8         /*         KP 7 -> KP 7 + Shift */
KP_8            5 2 8
KP_Up           5 2 8         /*         KP 8 -> KP 8 + Shift */
KP_9            6 2 8
KP_Page_Up      6 2 8         /*         KP 9 -> KP 9 + Shift */

# Seperator and Decimal are really the same thing for all practical purposes
KP_Separator    5 5 8
KP_Decimal      5 5 8
KP_Delete       5 5 8         /*         KP , -> KP , + Shift     */

KP_Divide       7 1 8
KP_Multiply     6 1 8
KP_Subtract     7 2 8
KP_Add          7 3 8
KP_Enter        7 4 8
