# -*- Mode: text; tab-width: 2; indent-tabs-mode: nil -*-
# Copyright Opera Software ASA 2007-2012. Do not distribute.

# Virtual keycode mapping - standard mapping.
#
# Comments are designated by a # in position 0 of the line. The
# keycodes will be assigned in an enum, and the names are used
# in the mapping functions. The comments are, well, comments --
# lines that are ignored when processing this file to generate
# the key mapping.

# The virtual key mapping configuration has the following format:
#
# keycode  offset(hex, optional) keyname(string) flags(optional)

# The 'keycode' is the CPP virtual key name.
#
# The 'offset' is the virtual key code offset (the base being some
# implementation internal value); if not supplied it will be the derived
# from the previous entry (+1)
#
# The 'keyname' is the name used in the key value set for a given key.
# The symbolic name for a key when reporting key events, for instance.
#
# Flags are one of the following:
#
#  modifier       key is a modifier (shift, control, alt.)
#
#  function       the key's primary function is not to produce
#                 its own character value upon being pressed.
#                 Such function keys do not generate keypress
#                 events upon keydown, non-function ones do.
#
#  no_key_value   the key does not have an entry in the
#                 "key value set." This has bearing on
#                 how its character and key value is
#                 reported for key events. With no_key_value,
#                 the value reported with the virtual key will
#                 always be used. If not set, the keyname will
#                 be reported.
#
#  char_value=CP  Use codepoint(CP) as the character value
#                 for the virtual key. 'codepoint' is assumed
#                 to be a numeric value within the range of
#                 values supported by uni_char (non zero.)
#
#  type_only      only add key to the type for virtual keys,
#                 but leave it unmapped in the various predicates
#                 and helper methods over keys. For internal
#                 use.
#
#  extended       the key is an extended key. Meaning: it is
#                 defined outside the fixed range of virtual
#                 keycodes, and and must be
#                 mapped at the given offset from the base
#                 of the extended range of virtual keycodes.
#
#  enabled        this virtual key is always enabled. A product
#                 must declare what keys it is willing to support
#                 via its PRODUCT_OPKEY_FILE, and which it cannot.
#                 An 'enabled' key does not have to be declared
#                 as enabled by a product and attempts to
#                 disable them will result in a compilation error.
#                 US alphanumeric keys are by default always enabled
#                 as a convenience.
#
#  key_synonym=X  provide X as a synonym for the OP_KEY being defined.
#                 For the generated enumeration, X will equal value
#                 to that of the key being defined.
#                 (e.g., OP_KEY_RETURN is a synonym for OP_KEY_ENTER.)
#
#  synonym=Key    make Key a synonym keyname of the OP_KEY being defined.
#                 Keynames are visible for keys producing no character
#                 value in DOM properties and as shortcut names.
#                 (e.g., "Esc" is a synonym for "Escape".)
#
#  standard       key occurs in the "standard" area of the keyboard.
#  left           key is located on the left.
#  right          key is located on the right.
#  numpad         key is located on the numeric keypad.
#  mobile         key is located on a "mobile" keyboard.
#  joystick       key is located on a joystick.
#
# The attributes: standard, left, right, numpad, mobile, and joystick are
# mutually exclusive. Used by DOM key events to tell apart keys that
# report the same virtual key.

# The format ("[..]" indicating an optional field):
#
# keycode           [offset]      keyname(string)  [flags]
OP_KEY_CANCEL       0x03          Cancel           standard, function
OP_KEY_BACKSPACE    0x08          Backspace        standard, function
OP_KEY_TAB                        Tab              standard, char_value=0x09
OP_KEY_CLEAR        0x0c          Clear            standard, function
OP_KEY_ENTER                      Enter            standard, key_synonym=OP_KEY_RETURN
# Note: left vs right distinction for Shift,Ctrl,Alt
# is captured by the location attribute of a key action.
OP_KEY_SHIFT        0x10          Shift            modifier
OP_KEY_CTRL                       Control          modifier
OP_KEY_ALT                        Alt              modifier
OP_KEY_PAUSE                      Pause            function
OP_KEY_CAPS_LOCK    0x14          CapsLock         function, left
OP_KEY_KANA         0x15          Kana             standard, function
OP_KEY_FINAL        0x18          Final            standard, function
OP_KEY_KANJI        0x19          Kanji            standard, function
OP_KEY_ESCAPE       0x1b          Esc              standard, char_value=0x1b
OP_KEY_CONVERT                    Convert          standard, function
OP_KEY_NONCONVERT                 NonConvert       standard, function
OP_KEY_ACCEPT                     Accept           standard, function
OP_KEY_MODECHANGE                 ModeChange       standard, function
OP_KEY_SPACE        0x20          Spacebar         standard, char_value=0x20, synonym=Space
OP_KEY_PAGEUP                     PageUp           standard, function
OP_KEY_PAGEDOWN                   PageDown         standard, function
OP_KEY_END                        End              standard, function
OP_KEY_HOME                       Home             standard, function
OP_KEY_LEFT                       Left             standard, function
OP_KEY_UP                         Up               standard, function
OP_KEY_RIGHT                      Right            standard, function
OP_KEY_DOWN                       Down             standard, function
OP_KEY_SELECT                     Select           standard, function
OP_KEY_PRINT                      Print            standard, function
OP_KEY_EXECUTE                    Execute          standard, function
OP_KEY_PRINTSCREEN 0x2c           PrintScreen      standard, function
OP_KEY_INSERT                     Insert           standard, function, synonym=Ins
OP_KEY_DELETE                     Delete           standard, function, synonym=Del
OP_KEY_HELP                       Help             standard, function
OP_KEY_0           0x30           0                standard, no_key_value, enabled
OP_KEY_1                          1                standard, no_key_value, enabled
OP_KEY_2                          2                standard, no_key_value, enabled
OP_KEY_3                          3                standard, no_key_value, enabled
OP_KEY_4                          4                standard, no_key_value, enabled
OP_KEY_5                          5                standard, no_key_value, enabled
OP_KEY_6                          6                standard, no_key_value, enabled
OP_KEY_7                          7                standard, no_key_value, enabled
OP_KEY_8                          8                standard, no_key_value, enabled
OP_KEY_9           0x39           9                standard, no_key_value, enabled
#
# 0x3a-0x40: unassigned.
#
OP_KEY_A           0x41           A                standard, no_key_value, enabled
OP_KEY_B                          B                standard, no_key_value, enabled
OP_KEY_C                          C                standard, no_key_value, enabled
OP_KEY_D                          D                standard, no_key_value, enabled
OP_KEY_E                          E                standard, no_key_value, enabled
OP_KEY_F                          F                standard, no_key_value, enabled
OP_KEY_G                          G                standard, no_key_value, enabled
OP_KEY_H                          H                standard, no_key_value, enabled
OP_KEY_I                          I                standard, no_key_value, enabled
OP_KEY_J                          J                standard, no_key_value, enabled
OP_KEY_K                          K                standard, no_key_value, enabled
OP_KEY_L                          L                standard, no_key_value, enabled
OP_KEY_M                          M                standard, no_key_value, enabled
OP_KEY_N                          N                standard, no_key_value, enabled
OP_KEY_O                          O                standard, no_key_value, enabled
OP_KEY_P                          P                standard, no_key_value, enabled
OP_KEY_Q                          Q                standard, no_key_value, enabled
OP_KEY_R                          R                standard, no_key_value, enabled
OP_KEY_S                          S                standard, no_key_value, enabled
OP_KEY_T                          T                standard, no_key_value, enabled
OP_KEY_U                          U                standard, no_key_value, enabled
OP_KEY_V                          V                standard, no_key_value, enabled
OP_KEY_W                          W                standard, no_key_value, enabled
OP_KEY_X                          X                standard, no_key_value, enabled
OP_KEY_Y                          Y                standard, no_key_value, enabled
OP_KEY_Z            0x5a          Z                standard, no_key_value, enabled
#
# Note: left and right window keys not distinguished by virtual key.
# Key events and actions separately carry their location.
#
OP_KEY_WINDOW       0x5b          Window           function
OP_KEY_MAC_CTRL     0x5c          MacControl       function, left
OP_KEY_CONTEXT_MENU 0x5d          ContextMenu      function, right
#
# 0x5e: reserved.
#
OP_KEY_SLEEP        0x5f          Sleep            function
OP_KEY_NUMPAD0      0x60          NumPad0          numpad, no_key_value, char_value=0x30
OP_KEY_NUMPAD1                    NumPad1          numpad, no_key_value, char_value=0x31
OP_KEY_NUMPAD2                    NumPad2          numpad, no_key_value, char_value=0x32
OP_KEY_NUMPAD3                    NumPad3          numpad, no_key_value, char_value=0x33
OP_KEY_NUMPAD4                    NumPad4          numpad, no_key_value, char_value=0x34
OP_KEY_NUMPAD5                    NumPad5          numpad, no_key_value, char_value=0x35
OP_KEY_NUMPAD6                    NumPad6          numpad, no_key_value, char_value=0x36
OP_KEY_NUMPAD7                    NumPad7          numpad, no_key_value, char_value=0x37
OP_KEY_NUMPAD8                    NumPad8          numpad, no_key_value, char_value=0x38
OP_KEY_NUMPAD9                    NumPad9          numpad, no_key_value, char_value=0x39
OP_KEY_MULTIPLY                   Mul              numpad,
OP_KEY_ADD                        Add              numpad, char_value=0x2b
OP_KEY_SEPARATOR                  Separator        numpad
OP_KEY_SUBTRACT                   Subtract         numpad, char_value=0x2d
OP_KEY_DECIMAL                    Decimal          numpad, char_value=0x2e, synonym=Dec
OP_KEY_DIVIDE                     Divide           numpad, char_value=0x2f
#
OP_KEY_F1                         F1               standard, function
OP_KEY_F2                         F2               standard, function
OP_KEY_F3                         F3               standard, function
OP_KEY_F4                         F4               standard, function
OP_KEY_F5                         F5               standard, function
OP_KEY_F6                         F6               standard, function
OP_KEY_F7                         F7               standard, function
OP_KEY_F8                         F8               standard, function
OP_KEY_F9                         F9               standard, function
OP_KEY_F10                        F10              standard, function
OP_KEY_F11                        F11              standard, function
OP_KEY_F12                        F12              standard, function
OP_KEY_F13                        F13              standard, function
OP_KEY_F14                        F14              standard, function
OP_KEY_F15                        F15              standard, function
OP_KEY_F16                        F16              standard, function
OP_KEY_F17                        F17              standard, function
OP_KEY_F18                        F18              standard, function
OP_KEY_F19                        F19              standard, function
OP_KEY_F20                        F20              standard, function
OP_KEY_F21                        F21              standard, function
OP_KEY_F22                        F22              standard, function
OP_KEY_F23                        F23              standard, function
OP_KEY_F24          0x87          F24              standard, function
#
# 0x88 - 0x8f: unassigned.
#
# extended set:
#
OP_KEY_NUM_LOCK     0x90          NumLock          standard, function
OP_KEY_SCROLL_LOCK                ScrollLock       standard, function
#
# 0x92 - 0x96: OEM specific.
#
# NOTE: META is not defined by Windows virtual key codes,
# (but MENU is, used for ALT). Map META to the unassigned 0x97.
#
OP_KEY_META         0x97          Meta             modifier
#
# 0x98 - 0x9f: unassigned.
#
# 0xa0 - 0xb7: unmapped.
# [this range holds the browser navigation + media keys in newer
#  versions of Windows (desktop versions.) If we can reliably
#  intercept them, then worth defining and exposing.]
#
# 0xb8 - 0xb9: reserved.
#
# Note: the synonyms are US keyboard layout centric. Easier
# to work with than their general OEM 'standard' names.
#
OP_KEY_OEM_1        0xba          Oem1             standard, no_key_value, key_synonym=OP_KEY_SEMICOLON
OP_KEY_OEM_PLUS                   OemPlus          standard, no_key_value, key_synonym=OP_KEY_PLUS
OP_KEY_OEM_COMMA                  OemComma         standard, no_key_value, key_synonym=OP_KEY_COMMA
OP_KEY_OEM_MINUS                  OemMinus         standard, no_key_value, key_synonym=OP_KEY_MINUS
OP_KEY_OEM_PERIOD                 OemPeriod        standard, no_key_value, key_synonym=OP_KEY_PERIOD
OP_KEY_OEM_2                      Oem2             standard, no_key_value, key_synonym=OP_KEY_SLASH
OP_KEY_OEM_3        0xc0          Oem3             standard, no_key_value, key_synonym=OP_KEY_TICK
#
# 0xc1 - 0xd7: reserved.
#
# 0xd8 - 0xda: unassigned.
#
OP_KEY_OEM_4        0xdb          Oem4             standard, no_key_value, key_synonym=OP_KEY_OPEN_BRACKET
OP_KEY_OEM_5                      Oem5             standard, no_key_value, key_synonym=OP_KEY_OPEN_BACKSLASH
OP_KEY_OEM_6                      Oem6             standard, no_key_value, key_synonym=OP_KEY_CLOSE_BRACKET
OP_KEY_OEM_7                      Oem7             standard, no_key_value, key_synonym=OP_KEY_QUOTE
OP_KEY_OEM_8                      Oem8             standard, no_key_value
#
# 0xe0: reserved.
#
# 0xe1: unmapped.
#
OP_KEY_OEM_102      0xe2          Oem102           standard, no_key_value
#
# 0xe3-0xe4: unmapped.
#
OP_KEY_PROCESSKEY   0xe5          IMEProcess       standard, no_key_value, function
#
# 0xe6: unmapped.
#
# Keycode (VK_PACKET) for transmitting any unicode character (string) not
# corresponding to a virtual key.
OP_KEY_UNICODE      0xe7          KeyInput         standard, no_key_value
#
# 0xe8: unassigned.
#
# 0xe9-f5: OEM keys, unassigned.
#
# 0xf6-0xff: unassigned.

#
# Keys mapped outside the [0,255] range are extensions to the
# standard virtual key mapping provided by Core. Extended keys
# can be freely assigned here through separate module.keys inputs,
# annotating each with the "extended" flag.
#
# Defining non-extended keys at unmapped entries within the [0,255]
# range defined by Core should be done with some care, but isn't
# prohibited. Please contact Core if you do so that these can be
# considered for direct inclusion.
#
# Notice that a small collection of internal keys are defined
# further down in this shared value space. The base offset used
# for these is arbitrary, but picked to avoid any accidental overlaps.

# The extended key baseline, not a real key but a symbolic marker.
OP_KEY_FIRST_EXTENDED  0x100      ExtensionStart   type_only, enabled

#
# Key values used internally for non keyboard keys, mouse
# buttons and gestures.
#

OP_KEY_FIRST_INTERNAL  0x5fe0     InternalStart    type_only, enabled
# mouse
OP_KEY_MOUSE_BUTTON_1             Button1          mouse_button
OP_KEY_MOUSE_BUTTON_2             Button2          mouse_button
OP_KEY_MOUSE_BUTTON_3             Button3          mouse_button
OP_KEY_MOUSE_BUTTON_4             Button4          mouse_button
OP_KEY_MOUSE_BUTTON_5             Button5          mouse_button
OP_KEY_MOUSE_BUTTON_6             Button6          mouse_button
OP_KEY_MOUSE_BUTTON_7             Button7          mouse_button
OP_KEY_MOUSE_BUTTON_8             Button8          mouse_button
OP_KEY_MOUSE_BUTTON_9             Button9          mouse_button

OP_KEY_GESTURE_UP                 GestureUp        gesture
OP_KEY_GESTURE_RIGHT              GestureRight     gesture
OP_KEY_GESTURE_DOWN               GestureDown      gesture
OP_KEY_GESTURE_LEFT               GestureLeft      gesture

# diagonal gestures
OP_KEY_GESTURE_UP_LEFT            GestureUpLeft    gesture
OP_KEY_GESTURE_UP_RIGHT           GestureUpRight   gesture
OP_KEY_GESTURE_DOWN_LEFT          GestureDownLeft  gesture
OP_KEY_GESTURE_DOWN_RIGHT         GestureDownRight gesture

OP_KEY_FLIP_BACK                  FlipBack         flip
OP_KEY_FLIP_FORWARD               FlipForward      flip
OP_KEY_LAST_INTERNAL              InternalEnd      type_only, enabled
