# 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.

# C64 keyboard matrix:
#
#       +-----+-----+-----+-----+-----+-----+-----+-----+
#       |Bit 0|Bit 1|Bit 2|Bit 3|Bit 4|Bit 5|Bit 6|Bit 7|
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 0| DEL |Retrn|C_L/R|  F7 |  F1 |  F3 |  F5 |C_U/D|
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 1| 3 # |  W  |  A  | 4 $ |  Z  |  S  |  E  | S_L |
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 2| 5 % |  R  |  D  | 6 & |  C  |  F  |  T  |  X  |
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 3| 7 ' |  Y  |  G  | 8 ( |  B  |  H  |  U  |  V  |
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 4| 9 ) |  I  |  J  |  0  |  M  |  K  |  O  |  N  |
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 5|  +  |  P  |  L  |  -  | . > | : [ |  @  | , < |
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 6|POUND|  *  | ; ] | HOME| S_R |  =  | A_UP| / ? |
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 7| 1 ! |A_LFT| CTRL| 2 " |SPACE|  C= |  Q  | R/S |
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+

# C64 Keyboard layout:
#
#   arrow 1!  2"  3#  4$  5%  6&  7'  8(  9)  0   +   -   pound clr del     f1/f2
#    ctrl   q   w   e   r   t   y   u   i   o   p   @   *   ^   restore     f3/f4
#   r/s SL    a   s   d   f   g   h   j   k   l   :[  ;]  =   return        f5/f6
#   CBM LS      z   x   c   v   b   n   m   ,<  .>  /?  RS  u/d l/r         f7/f8
#                               space

!CLEAR
!LSHIFT 1 7
!RSHIFT 6 4
!VSHIFT RSHIFT
!SHIFTL LSHIFT
!LCBM 7 5
!VCBM LCBM
!LCTRL 7 2
!VCTRL LCTRL

Control_L 7 2 16392 /* Ctrl */
Super_L 7 5 8200     /* Commodore Key */
BackSpace 0 0 8
Down 0 7 8
Escape 7 7 8    /* RunStop */
F1 0 4 8
F2 0 4 1
F3 0 5 8
F4 0 5 1
F5 0 6 8
F6 0 6 1
F7 0 3 8
F8 0 3 1
Home 6 3 8      /* Clr */
Insert 0 0 16   /* Insert */
Left 0 2 1
Return 0 1 8
Right 0 2 8
Shift_L 1 7 2
Shift_R 6 4 4
Up 0 7 1
KP_Add 5 0 8               /* + */
KP_Subtract 5 3 8               /* - */
Apostrophe  6 6 8               /* Up Arrow */
LeftBracket  5 5 8               /* : -> : */
SemiColon  6 1 8               /* * -> * */
Comma  5 7 8               /* , -> , */
BackSlash  5 6 8               /* @ -> @ */
Pound 6 5 0           /* equal */
Equals  6 5 8               /* = -> = */
Period  5 4 8               /* . */
Dash  6 0 8               /* Pound */
SingleQuote 6 6 8     /* Up Arrow */
Slash  6 7 8               /* / -> / */
Space 7 4 8           /* space */
Insert 6 0 8          /* sterling */
RightBracket  6 2 8               /* ; -> ; */
BackQuote 7 1 0       /* arrowleft */
Del 6 6 8             /* arrowup */
0 4 3 8
1 7 0 8
2 7 3 8
3 1 0 8
4 1 3 8
5 2 0 8
6 2 3 8
7 3 0 8
8 3 3 8
9 4 0 8
a 1 2 8
b 3 4 8
c 2 4 8
d 2 2 8
e 1 6 8
f 2 5 8
g 3 2 8
h 3 5 8
i 4 1 8
j 4 2 8
k 4 5 8
l 5 2 8
m 4 4 8
n 4 7 8
o 4 6 8
p 5 1 8
q 7 6 8
r 2 1 8
s 1 5 8
t 2 6 8
u 3 6 8
v 3 7 8
w 1 1 8
x 2 7 8
y 3 1 8
z 1 4 8

# Restore key mappings
CapsLock -4 1
Caps_Lock -4 1
Tab -3 0
