# 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, AZERTY Layout, VIC20, GTK

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

# to convert from C64 to VIC20:
# change rows 7 -> 0, 0 -> 7
# change columns 7 -> 3, 3 -> 7

# VIC20 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 3
!RSHIFT 6 4
!VSHIFT RSHIFT
!SHIFTL LSHIFT
!LCBM 0 5
!VCBM LCBM
!LCTRL 0 2
!VCTRL LCTRL

#####################
# |Bit 0| 1 ! |A_LFT| CTRL| R/S |SPACE|  C= |  Q  | 2 " |

exclam          0 0 1
# underscore = arrow left
underscore      0 1 0
End             0 1 8
# Tab = CTRL
Tab             0 2 16392
# Shift + Tab = CTRL
ISO_Left_Tab    0 2 16392
# Escape = run/stop
Escape          0 3 8
Help            0 3 8
space           0 4 8
# Control_L = CBM
Control_L       0 5 8200
quotedbl        0 7 1

#####################
# |Bit 1| 3 # |  W  |  A  | S_L |  Z  |  S  |  E  | 4 $ |

numbersign      1 0 1
# left shift
# key is left shift
Shift_L          1 3 2
# shift lock
# key is (left) shift-lock
Caps_Lock        1 3 64
dollar          1 7 1

#####################
# |Bit 2| 5 % |  R  |  D  |  X  |  C  |  F  |  T  | 6 & |

percent         2 0 1
ampersand       2 7 1

#####################
# |Bit 3| 7 ' |  Y  |  G  |  V  |  B  |  H  |  U  | 8 ( |

apostrophe      3 0 1
grave           3 0 1
parenleft       3 7 1

#####################
# |Bit 4| 9 ) |  I  |  J  |  N  |  M  |  K  |  O  |  0  |

parenright      4 0 1

#####################
# |Bit 5|  +  |  P  |  L  | , < | . > | : [ |  @  |  -  |

plus            5 0 16
comma           5 3 0
less            5 3 1
period          5 4 16
greater         5 4 1
colon           5 5 0
bracketleft     5 5 1
at              5 6 0
minus           5 7 0

#####################
# |Bit 6|POUND|  *  | ; ] | / ? | S_R |  =  | A_UP| HOME|

sterling        6 0 16
bar             6 0 8
backslash       6 0 0
asterisk        6 1 0
semicolon       6 2 0
bracketright    6 2 1
slash           6 3 16
question        6 3 1
Shift_R         6 4 4
equal           6 5 0
# Page down -> Arrow Up
asciicircum     6 6 0
asciitilde      6 6 0
Page_Down       6 6 8
Home            6 7 8
Find            6 7 8

#####################
# |Bit 7| DEL |Retrn|C_L/R|C_U/D|  F1 |  F3 |  F5 |  F7 |

BackSpace       7 0 8
Delete          7 0 8
Insert          7 0 16
Return          7 1 8
Linefeed        7 1 1
Right           7 2 8
Left            7 2 1
KP_F4           7 2 8
Up              7 3 1
Down            7 3 8
F1              7 4 8
KP_F1           7 4 8
F2              7 4 1
F3              7 5 8
KP_F2           7 5 8
F4              7 5 1
F5              7 6 8
KP_F3           7 6 8
F6              7 6 1
F7              7 7 8
F8              7 7 1

#####################
# letters and numbers

0 4 7 16
1 0 0 16
2 0 7 16
3 1 0 16
4 1 7 16
5 2 0 16
6 2 7 16
7 3 0 16
8 3 7 16
9 4 0 16

w 1 1 8
a 1 2 8
z 1 4 8
s 1 5 8
e 1 6 8
p 5 1 8
l 5 2 8
r 2 1 8
d 2 2 8
c 2 4 8
f 2 5 8
t 2 6 8
x 2 3 8
y 3 1 8
g 3 2 8
b 3 4 8
h 3 5 8
u 3 6 8
v 3 3 8
i 4 1 8
j 4 2 8
m 4 4 8
k 4 5 8
o 4 6 8
n 4 3 8
q 0 6 8
W 1 1 1
A 1 2 1
Z 1 4 1
S 1 5 1
E 1 6 1
R 2 1 1
D 2 2 1
C 2 4 1
F 2 5 1
T 2 6 1
X 2 3 1
Y 3 1 1
G 3 2 1
B 3 4 1
H 3 5 1
U 3 6 1
V 3 3 1
I 4 1 1
J 4 2 1
M 4 4 1
K 4 5 1
O 4 6 1
N 4 3 1
P 5 1 1
L 5 2 1
Q 0 6 1

# Restore key mappings
Page_Up -3 0
Prior -3 1

# Dead keys support for those using US-International keyboard layout.
dead_acute      3 0 1  # '
dead_grave      3 0 1  # '
dead_circumflex 6 6 0  # A_UP
dead_tilde      6 6 0  # A_UP
dead_diaeresis  0 7 1  # "

#
# joyport attached keypad
#
Num_Lock    -5 0
KP_7        -5 1
KP_8        -5 2
KP_9        -5 3
KP_Divide   -5 4
Scroll_Lock -5 5
KP_4        -5 6
KP_5        -5 7
KP_6        -5 8
KP_Multiply -5 9
Sys_Req     -5 10
KP_1        -5 11
KP_2        -5 12
KP_3        -5 13
KP_Subtract -5 14
Print       -5 15
KP_0        -5 16
KP_Delete   -5 17
KP_Enter    -5 18
KP_Add      -5 19
