# 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 line has '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)
# '!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 the values:
# 0      key is not shifted for this keysym/scancode
# 1      key is combined with shift for this keysym/scancode
# 2      key is left shift on emulated machine
# 4      key is right shift on emulated machine
# 8      key can be shifted or not with this keysym/scancode
# 16     deshift key for this keysym/scancode
# 32     another definition for this keysym/scancode follows
# 64     key is shift-lock on emulated machine
# 128    shift modifier required on host
# 256    key is used for an alternative keyboard mapping
# 512    alt-r (alt-gr) modifier required on host
# 1024   ctrl modifier required on host
# 2048   key is combined with cbm for this keysym/scancode
# 4096   key is combined with ctrl for this keysym/scancode
# 8192   key is (left) cbm on emulated machine
# 16384  key is (left) ctrl on emulated machine
#
# to migrate older keymaps and use the CBM and/or CTRL related features:
#
# - define !LCTRL, !VCTRL, !LCBM, !VCBM
# - add 'key is (left) cbm/ctrl on emulated machine' flags to
#   all keys that map to the cbm or ctrl key respectively.
#
# after that the virtual cbm/ctrl flags and requiring host modifiers
# should work as expected. keep an eye on the error messages.
#
# 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
# 'keysym -4 1' CAPS (ASCII/DIN) key
# 'keysym -5 n' joyport keypad, key n
#
# 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.

# this is a PET graphics keyboard mapping (positional)

#
# Graphics keyboard matrix:
#
#       0        1        2        3        4        5        6        7
#   +--------+--------+--------+--------+--------+--------+--------+--------+
# 0 |   !    |   #    |   %    |   &    |   (    |  <--   |  home  |crsr rgt|
#   +--------+--------+--------+--------+--------+--------+--------+--------+
# 1 |   "    |   $    |   '    |   \    |   )    |--------|crsr dwn|  del   |
#   +--------+--------+--------+--------+--------+--------+--------+--------+
# 2 |   q    |   e    |   t    |   u    |   o    |   ^    |   7    |   9    |
#   +--------+--------+--------+--------+--------+--------+--------+--------+
# 3 |   w    |   r    |   y    |   i    |   p    |--------|   8    |   /    |
#   +--------+--------+--------+--------+--------+--------+--------+--------+
# 4 |   a    |   d    |   g    |   j    |   l    |--------|   4    |   6    |
#   +--------+--------+--------+--------+--------+--------+--------+--------+
# 5 |   s    |   f    |   h    |   k    |   :    |--------|   5    |   *    |
#   +--------+--------+--------+--------+--------+--------+--------+--------+
# 6 |   z    |   c    |   b    |   m    |   ;    | return |   1    |   3    |
#   +--------+--------+--------+--------+--------+--------+--------+--------+
# 7 |   x    |   v    |   n    |   ,    |   ?    |--------|   2    |   +    |
#   +--------+--------+--------+--------+--------+--------+--------+--------+
# 8 |l shift |   @    |   ]    |--------|   >    |r shift |   0    |   -    |
#   +--------+--------+--------+--------+--------+--------+--------+--------+
# 9 | rvs on |   [    | space  |   <    |  stop  |--------|   .    |   =    |
#   +--------+--------+--------+--------+--------+--------+--------+--------+
#
# The original gfx keyboard reflects the matrix perfectly:
#
#         @ !  "  #  $  %  '  &  \  (  )  <-     ^s ^q ^] ^t
#       RVS  q  w  e  r  t  y  u  i  o  p  ^      7  8  9  /
#         SL  a  s  d  f  g  h  j  k  l  : ^m     4  5  6  *
#          LS  z  x  c  v  b  n  m  ,  ;  ? ^m    1  2  3  +
#                 SPACE                           0  .  -  =
#
# http://www.6502.org/users/andre/petindex/keyboards.html

!CLEAR
!LSHIFT 8 0
!RSHIFT 8 5
!VSHIFT RSHIFT

Return       6 5 8
Down         1 6 8
Right        0 7 8
Home         0 6 8
BackSpace    1 7 8
Delete       1 7 0
Tab          9 0 8
KP_Tab       9 0 8
ISO_Left_Tab 9 0 1
Escape       9 4 8  # Stop
Control_L    -1 -1 0
Find         0 6 0
Shift_L      8 0 2
Shift_R      8 5 4

a            4 0 0
b            6 2 0
c            6 1 0
d            4 1 0
e            2 1 0
f            5 1 0
g            4 2 0
h            5 2 0
i            3 3 0
j            4 3 0
k            5 3 0
l            4 4 0
m            6 3 0
n            7 2 0
o            2 4 0
p            3 4 0
q            2 0 0
r            3 1 0
s            5 0 0
t            2 2 0
u            2 3 0
v            7 1 0
w            3 0 0
x            7 0 0
y            3 2 0
z            6 0 0

KP_Separator 7 3 0  # ,
KP_0         8 6 0  # 0
KP_1         6 6 0  # 1
KP_2         7 6 0  # 2
KP_3         6 7 0  # 3
KP_4         4 6 0  # 4
KP_5         5 6 0  # 5
KP_6         4 7 0  # 6
KP_7         2 6 0  # 7
KP_8         3 6 0  # 8
KP_9         2 7 0  # 9

KP_Delete    7 3 1  # , + SHIFT
KP_Insert    8 6 1  # 0 + SHIFT
KP_End       6 6 1  # 1 + SHIFT
KP_Down      7 6 1  # 2 + SHIFT
KP_Next      6 7 1  # 3 + SHIFT
KP_Left      4 6 1  # 4 + SHIFT
KP_Begin     5 6 1  # 5 + SHIFT
KP_Right     4 7 1  # 6 + SHIFT
KP_Home      2 6 1  # 7 + SHIFT
KP_Up        3 6 1  # 8 + SHIFT
KP_Page_Up   2 7 1  # 9 + SHIFT

KP_Multiply  5 7 8  #
KP_Divide    3 7 8  #
KP_Add       7 7 8  #
KP_Subtract  8 7 8  #
KP_Enter     6 5 8  #
KP_Decimal   9 6 8  #

grave        8 1 0  # `
1            0 0 0
2            1 0 0
3            0 1 0
4            1 1 0
5            0 2 0
6            1 2 0
7            0 3 0
8            1 3 0
9            0 4 0
0            1 4 0
minus        0 5 0
equal        9 7 0


asciitilde   8 1 1  # ~
exclam       0 0 1
at           1 0 1
numbersign   0 1 1
dollar       1 1 1
percent      0 2 1
asciicircum  1 2 1
ampersand    0 3 1
asterisk     1 3 1
parenleft    0 4 1
parenright   1 4 1
underscore   0 5 1  # _
plus         9 7 1

End          9 3 8  # <
Page_Down    8 4 8  # >

backslash    2 5 0  # up_arrow
bar          2 5 1  # pi

slash        7 4 0  # ?
question     7 4 1

bracketleft  9 1 0  # [
bracketright 8 2 0  # ]
braceleft    9 1 1
braceright   8 2 1

semicolon    5 4 0  # :
colon        5 4 1

apostrophe   -1 -1 0
quotedbl     -1 -1 0

sterling     1 3 0
space        9 2 8

comma        7 3 0
period       6 4 0
less         7 3 1
greater      6 4 1

Up           1 6 1
Left         0 7 1
Insert       1 7 1
Clear        0 6 1

A            4 0 1
B            6 2 1
C            6 1 1
D            4 1 1
E            2 1 1
F            5 1 1
G            4 2 1
H            5 2 1
I            3 3 1
J            4 3 1
K            5 3 1
L            4 4 1
M            6 3 1
N            7 2 1
O            2 4 1
P            3 4 1
Q            2 0 1
R            3 1 1
S            5 0 1
T            2 2 1
U            2 3 1
V            7 1 1
W            3 0 1
X            7 0 1
Y            3 2 1
Z            6 0 1 
