summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/keycodes/keyboard_code_conversion.cc296
-rw-r--r--ui/base/keycodes/keyboard_code_conversion.h22
-rw-r--r--ui/base/keycodes/keyboard_code_conversion_gtk.cc617
-rw-r--r--ui/base/keycodes/keyboard_code_conversion_gtk.h50
-rw-r--r--ui/base/keycodes/keyboard_code_conversion_mac.h35
-rw-r--r--ui/base/keycodes/keyboard_code_conversion_mac.mm293
-rw-r--r--ui/base/keycodes/keyboard_code_conversion_unittest.cc43
-rw-r--r--ui/base/keycodes/keyboard_code_conversion_win.cc17
-rw-r--r--ui/base/keycodes/keyboard_code_conversion_win.h19
-rw-r--r--ui/base/keycodes/keyboard_code_conversion_x.cc281
-rw-r--r--ui/base/keycodes/keyboard_code_conversion_x.h18
-rw-r--r--ui/base/keycodes/keyboard_codes.h17
-rw-r--r--ui/base/keycodes/keyboard_codes_posix.h210
-rw-r--r--ui/base/keycodes/keyboard_codes_win.h186
14 files changed, 2104 insertions, 0 deletions
diff --git a/ui/base/keycodes/keyboard_code_conversion.cc b/ui/base/keycodes/keyboard_code_conversion.cc
new file mode 100644
index 0000000..fe4db85
--- /dev/null
+++ b/ui/base/keycodes/keyboard_code_conversion.cc
@@ -0,0 +1,296 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/keycodes/keyboard_code_conversion.h"
+
+#include <string.h>
+
+#include "ui/base/keycodes/keyboard_codes.h"
+
+namespace ui {
+
+namespace {
+
+typedef struct KeyIdentifier {
+ const char* key_name;
+ const char character;
+ const char* unicode_codepoint;
+ const KeyboardCode key_code;
+} KeyIdentifier;
+
+// Taken from Section 6.3.3 here:
+// http://www.w3.org/TR/DOM-Level-3-Events/#keyset-keyidentifiers
+// TODO(bryeung): keycodes could be wrong: I took the keydown code only
+static const KeyIdentifier kKeyIdentifiers[] = {
+ { "Accept", '\0', "", VKEY_ACCEPT },
+ { "Add", '\0', "", VKEY_ADD },
+ { "Again", '\0', "", VKEY_UNKNOWN },
+ { "AllCandidates", '\0', "", VKEY_UNKNOWN },
+ { "Alphanumeric", '\0', "", VKEY_UNKNOWN },
+ { "Alt", '\0', "", VKEY_MENU },
+ { "AltGraph", '\0', "", VKEY_UNKNOWN },
+ { "Apps", '\0', "", VKEY_APPS },
+ { "Attn", '\0', "", VKEY_ATTN },
+ { "BrowserBack", '\0', "", VKEY_BROWSER_BACK },
+ { "BrowserFavorites", '\0', "", VKEY_BROWSER_FAVORITES },
+ { "BrowserForward", '\0', "", VKEY_BROWSER_FAVORITES },
+ { "BrowserHome", '\0', "", VKEY_BROWSER_HOME },
+ { "BrowserRefresh", '\0', "", VKEY_BROWSER_REFRESH },
+ { "BrowserSearch", '\0', "", VKEY_BROWSER_SEARCH },
+ { "BrowserStop", '\0', "", VKEY_BROWSER_STOP },
+ { "CapsLock", '\0', "", VKEY_CAPITAL },
+ { "Clear", '\0', "", VKEY_OEM_CLEAR },
+ { "CodeInput", '\0', "", VKEY_UNKNOWN },
+ { "Compose", '\0', "", VKEY_UNKNOWN },
+ { "Control", '\0', "", VKEY_CONTROL },
+ { "Crsel", '\0', "", VKEY_CRSEL },
+ { "Convert", '\0', "", VKEY_CONVERT },
+ { "Copy", '\0', "", VKEY_UNKNOWN },
+ { "Cut", '\0', "", VKEY_UNKNOWN },
+ { "Decimal", '\0', "", VKEY_DECIMAL },
+ { "Divide", '\0', "", VKEY_DIVIDE },
+ { "Down", '\0', "", VKEY_DOWN },
+ { "DownLeft", '\0', "", VKEY_UNKNOWN },
+ { "DownRight", '\0', "", VKEY_UNKNOWN },
+ { "End", '\0', "", VKEY_END },
+ { "Enter", '\0', "", VKEY_RETURN },
+ { "EraseEof", '\0', "", VKEY_EREOF },
+ { "Execute", '\0', "", VKEY_EXECUTE },
+ { "Exsel", '\0', "", VKEY_EXSEL },
+ { "Fn", '\0', "", VKEY_UNKNOWN },
+ { "F1", '\0', "", VKEY_F1 },
+ { "F2", '\0', "", VKEY_F2 },
+ { "F3", '\0', "", VKEY_F3 },
+ { "F4", '\0', "", VKEY_F4 },
+ { "F5", '\0', "", VKEY_F5 },
+ { "F6", '\0', "", VKEY_F6 },
+ { "F7", '\0', "", VKEY_F7 },
+ { "F8", '\0', "", VKEY_F8 },
+ { "F9", '\0', "", VKEY_F9 },
+ { "F10", '\0', "", VKEY_F10 },
+ { "F11", '\0', "", VKEY_F11 },
+ { "F12", '\0', "", VKEY_F12 },
+ { "F13", '\0', "", VKEY_F13 },
+ { "F14", '\0', "", VKEY_F14 },
+ { "F15", '\0', "", VKEY_F15 },
+ { "F16", '\0', "", VKEY_F16 },
+ { "F17", '\0', "", VKEY_F17 },
+ { "F18", '\0', "", VKEY_F18 },
+ { "F19", '\0', "", VKEY_F19 },
+ { "F20", '\0', "", VKEY_F20 },
+ { "F21", '\0', "", VKEY_F21 },
+ { "F22", '\0', "", VKEY_F22 },
+ { "F23", '\0', "", VKEY_F23 },
+ { "F24", '\0', "", VKEY_F24 },
+ { "FinalMode", '\0', "", VKEY_FINAL },
+ { "Find", '\0', "", VKEY_UNKNOWN },
+ { "FullWidth", '\0', "", VKEY_UNKNOWN },
+ { "HalfWidth", '\0', "", VKEY_UNKNOWN },
+ { "HangulMode", '\0', "", VKEY_HANGUL },
+ { "HanjaMode", '\0', "", VKEY_HANJA },
+ { "Help", '\0', "", VKEY_HELP },
+ { "Hiragana", '\0', "", VKEY_UNKNOWN },
+ { "Home", '\0', "", VKEY_HOME },
+ { "Insert", '\0', "", VKEY_INSERT },
+ { "JapaneseHiragana", '\0', "", VKEY_UNKNOWN },
+ { "JapaneseKatakana", '\0', "", VKEY_UNKNOWN },
+ { "JapaneseRomaji", '\0', "", VKEY_UNKNOWN },
+ { "JunjaMode", '\0', "", VKEY_JUNJA },
+ { "KanaMode", '\0', "", VKEY_KANA },
+ { "KanjiMode", '\0', "", VKEY_KANJI },
+ { "Katakana", '\0', "", VKEY_UNKNOWN },
+ { "LaunchApplication1", '\0', "", VKEY_MEDIA_LAUNCH_APP1 },
+ { "LaunchApplication2", '\0', "", VKEY_MEDIA_LAUNCH_APP2 },
+ { "LaunchMail", '\0', "", VKEY_MEDIA_LAUNCH_MAIL },
+ { "Left", '\0', "", VKEY_LEFT },
+ { "Menu", '\0', "", VKEY_MENU },
+ { "Meta", '\0', "", VKEY_UNKNOWN },
+ { "MediaNextTrack", '\0', "", VKEY_MEDIA_NEXT_TRACK },
+ { "MediaPlayPause", '\0', "", VKEY_MEDIA_PLAY_PAUSE },
+ { "MediaPreviousTrack", '\0', "", VKEY_MEDIA_PREV_TRACK },
+ { "MediaStop", '\0', "", VKEY_MEDIA_STOP },
+ { "ModeChange", '\0', "", VKEY_MODECHANGE },
+ { "Multiply", '\0', "", VKEY_MULTIPLY },
+ { "NextCandidate", '\0', "", VKEY_UNKNOWN },
+ { "Nonconvert", '\0', "", VKEY_NONCONVERT },
+ { "NumLock", '\0', "", VKEY_NUMLOCK },
+ { "PageDown", '\0', "", VKEY_NEXT },
+ { "PageUp", '\0', "", VKEY_PRIOR },
+ { "Paste", '\0', "", VKEY_UNKNOWN },
+ { "Pause", '\0', "", VKEY_PAUSE },
+ { "Play", '\0', "", VKEY_PLAY },
+ { "PreviousCandidate", '\0', "", VKEY_UNKNOWN },
+ { "PrintScreen", '\0', "", VKEY_SNAPSHOT },
+ { "Process", '\0', "", VKEY_PROCESSKEY },
+ { "Props", '\0', "", VKEY_UNKNOWN },
+ { "Right", '\0', "", VKEY_RIGHT },
+ { "RomanCharacters", '\0', "", VKEY_UNKNOWN },
+ { "Scroll", '\0', "", VKEY_SCROLL },
+ { "Select", '\0', "", VKEY_SELECT },
+ { "SelectMedia", '\0', "", VKEY_MEDIA_LAUNCH_MEDIA_SELECT },
+ { "Separator", '\0', "", VKEY_SEPARATOR },
+ { "Shift", '\0', "", VKEY_SHIFT },
+ { "Soft1", '\0', "", VKEY_UNKNOWN },
+ { "Soft2", '\0', "", VKEY_UNKNOWN },
+ { "Soft3", '\0', "", VKEY_UNKNOWN },
+ { "Soft4", '\0', "", VKEY_UNKNOWN },
+ { "Stop", '\0', "", VKEY_UNKNOWN },
+ { "Subtract", '\0', "", VKEY_SUBTRACT },
+ { "Up", '\0', "", VKEY_UP },
+ { "UpLeft", '\0', "", VKEY_UNKNOWN },
+ { "UpRight", '\0', "", VKEY_UNKNOWN },
+ { "Undo", '\0', "", VKEY_UNKNOWN },
+ { "VolumeDown", '\0', "", VKEY_VOLUME_DOWN },
+ { "VolumeMute", '\0', "", VKEY_VOLUME_MUTE },
+ { "VolumeUp", '\0', "", VKEY_VOLUME_UP },
+ { "Win", '\0', "", VKEY_LWIN },
+ { "Zoom", '\0', "", VKEY_ZOOM },
+ { "Backspace", '\0', "U+0008", VKEY_BACK },
+ { "Tab", '\0', "U+0009", VKEY_TAB },
+ { "Cancel", '\0', "U+0018", VKEY_UNKNOWN },
+ { "Esc", '\0', "U+001B", VKEY_ESCAPE },
+ { "Spacebar", ' ', "U+0020", VKEY_SPACE },
+ { "Exclamation", '!', "U+0021", VKEY_1 },
+ { "DoubleQuote", '\"', "U+0022", VKEY_OEM_7 },
+ { "Hash", '\0', "U+0023", VKEY_3 },
+ { "Dollar", '$', "U+0024", VKEY_4 },
+ { "Ampersand", '&', "U+0026", VKEY_5 },
+ { "Apostrophe", '\'', "U+0027", VKEY_OEM_7 },
+ { "LeftParen", '(', "U+0028", VKEY_9 },
+ { "RightParen", ')', "U+0029", VKEY_0 },
+ { "Asterisk", '*', "U+002A", VKEY_8 },
+ { "Plus", '+', "U+002B", VKEY_OEM_PLUS },
+ { "Percent", '+', "U+0025", VKEY_5 },
+ { "Comma", ',', "U+002C", VKEY_OEM_COMMA },
+ { "HyphenMinus", '-', "U+002D", VKEY_OEM_MINUS },
+ { "Period", '.', "U+002E", VKEY_OEM_PERIOD },
+ { "Solidus", '/', "U+002F", VKEY_OEM_2 },
+ { "", '0', "U+0030", VKEY_0 },
+ { "", '1', "U+0031", VKEY_1 },
+ { "", '2', "U+0032", VKEY_2 },
+ { "", '3', "U+0033", VKEY_3 },
+ { "", '4', "U+0034", VKEY_4 },
+ { "", '5', "U+0035", VKEY_5 },
+ { "", '6', "U+0036", VKEY_6 },
+ { "", '7', "U+0037", VKEY_7 },
+ { "", '8', "U+0038", VKEY_8 },
+ { "", '9', "U+0039", VKEY_9 },
+ { "Colon", ':', "U+003A", VKEY_OEM_1 },
+ { "Semicolon", ';', "U+003B", VKEY_OEM_1 },
+ { "LessThan", '<', "U+003C", VKEY_OEM_COMMA },
+ { "Equals", '=', "U+003D", VKEY_OEM_PLUS },
+ { "GreaterThan", '>', "U+003E", VKEY_OEM_PERIOD },
+ { "QuestionMark", '?', "U+003F", VKEY_OEM_2 },
+ { "At", '@', "U+0040", VKEY_2 },
+ { "", 'A', "U+0041", VKEY_A },
+ { "", 'B', "U+0042", VKEY_B },
+ { "", 'C', "U+0043", VKEY_C },
+ { "", 'D', "U+0044", VKEY_D },
+ { "", 'E', "U+0045", VKEY_E },
+ { "", 'F', "U+0046", VKEY_F },
+ { "", 'G', "U+0047", VKEY_G },
+ { "", 'H', "U+0048", VKEY_H },
+ { "", 'I', "U+0049", VKEY_I },
+ { "", 'J', "U+004A", VKEY_J },
+ { "", 'K', "U+004B", VKEY_K },
+ { "", 'L', "U+004C", VKEY_L },
+ { "", 'M', "U+004D", VKEY_M },
+ { "", 'N', "U+004E", VKEY_N },
+ { "", 'O', "U+004F", VKEY_O },
+ { "", 'P', "U+0050", VKEY_P },
+ { "", 'Q', "U+0051", VKEY_Q },
+ { "", 'R', "U+0052", VKEY_R },
+ { "", 'S', "U+0053", VKEY_S },
+ { "", 'T', "U+0054", VKEY_T },
+ { "", 'U', "U+0055", VKEY_U },
+ { "", 'V', "U+0056", VKEY_V },
+ { "", 'W', "U+0057", VKEY_W },
+ { "", 'X', "U+0058", VKEY_X },
+ { "", 'Y', "U+0059", VKEY_Y },
+ { "", 'Z', "U+005A", VKEY_Z },
+ { "", 'a', "U+0061", VKEY_A },
+ { "", 'b', "U+0062", VKEY_B },
+ { "", 'c', "U+0063", VKEY_C },
+ { "", 'd', "U+0064", VKEY_D },
+ { "", 'e', "U+0065", VKEY_E },
+ { "", 'f', "U+0066", VKEY_F },
+ { "", 'g', "U+0067", VKEY_G },
+ { "", 'h', "U+0068", VKEY_H },
+ { "", 'i', "U+0069", VKEY_I },
+ { "", 'j', "U+006A", VKEY_J },
+ { "", 'k', "U+006B", VKEY_K },
+ { "", 'l', "U+006C", VKEY_L },
+ { "", 'm', "U+006D", VKEY_M },
+ { "", 'n', "U+006E", VKEY_N },
+ { "", 'o', "U+006F", VKEY_O },
+ { "", 'p', "U+0070", VKEY_P },
+ { "", 'q', "U+0071", VKEY_Q },
+ { "", 'r', "U+0072", VKEY_R },
+ { "", 's', "U+0073", VKEY_S },
+ { "", 't', "U+0074", VKEY_T },
+ { "", 'u', "U+0075", VKEY_U },
+ { "", 'v', "U+0076", VKEY_V },
+ { "", 'w', "U+0077", VKEY_W },
+ { "", 'x', "U+0078", VKEY_X },
+ { "", 'y', "U+0079", VKEY_Y },
+ { "", 'z', "U+007A", VKEY_Z },
+ { "LeftSquareBracket", '[', "U+005B", VKEY_OEM_4 },
+ { "Backslash", '\\', "U+005C", VKEY_OEM_5 },
+ { "RightSquareBracket", ']', "U+005D", VKEY_OEM_6 },
+ { "Circumflex", '^', "U+005E", VKEY_OEM_6 },
+ { "Underscore", '_', "U+005F", VKEY_OEM_MINUS },
+ { "Grave", '`', "U+0060", VKEY_OEM_3 },
+ { "LeftCurlyBracket", '{', "U+007B", VKEY_OEM_4 },
+ { "Pipe", '|', "U+007C", VKEY_OEM_5 },
+ { "RightCurlyBracket", '}', "U+007D", VKEY_OEM_6 },
+ { "Del", '\0', "U+007F", VKEY_DELETE },
+ { "InvertedExclamation", '\0', "U+00A1", VKEY_UNKNOWN },
+ { "DeadGrave", '\0', "U+0300", VKEY_UNKNOWN },
+ { "DeadEacute", '\0', "U+0301", VKEY_UNKNOWN },
+ { "DeadCircumflex", '\0', "U+0302", VKEY_UNKNOWN },
+ { "DeadTilde", '\0', "U+0303", VKEY_UNKNOWN },
+ { "DeadMacron", '\0', "U+0304", VKEY_UNKNOWN },
+ { "DeadBreve", '\0', "U+0306", VKEY_UNKNOWN },
+ { "DeadAboveDot", '\0', "U+0307", VKEY_UNKNOWN },
+ { "DeadUmlaut", '\0', "U+0308", VKEY_UNKNOWN },
+ { "DeadAboveRing", '\0', "U+030A", VKEY_UNKNOWN },
+ { "DeadDoubleacute", '\0', "U+030B", VKEY_UNKNOWN },
+ { "DeadCaron", '\0', "U+030C", VKEY_UNKNOWN },
+ { "DeadCedilla", '\0', "U+0327", VKEY_UNKNOWN },
+ { "DeadOgonek", '\0', "U+0328", VKEY_UNKNOWN },
+ { "DeadIota", '\0', "U+0345", VKEY_UNKNOWN },
+ { "Euro", '\0', "U+20AC", VKEY_UNKNOWN },
+ { "DeadVoicedSound", '\0', "U+3099", VKEY_UNKNOWN },
+ { "DeadSemivoicedSound", '\0', "U+309A", VKEY_UNKNOWN }
+};
+
+static const int kNumKeyIdentifiers =
+ sizeof(kKeyIdentifiers)/sizeof(KeyIdentifier);
+
+static const KeyIdentifier* GetKeyIdentifierData(const std::string& id) {
+ for (int i = 0; i < kNumKeyIdentifiers; ++i) {
+ const KeyIdentifier& key = kKeyIdentifiers[i];
+ if ((key.key_name[0] != '\0' && strcmp(id.c_str(), key.key_name) == 0) ||
+ (id.length() == 1 && id[0] == key.character) ||
+ (key.unicode_codepoint[0] != '\0' &&
+ strcmp(id.c_str(), key.unicode_codepoint) == 0)) {
+ return &key;
+ }
+ }
+
+ return NULL;
+}
+
+} // namespace
+
+
+KeyboardCode KeyCodeFromKeyIdentifier(const std::string& key_identifier) {
+ const KeyIdentifier* id = GetKeyIdentifierData(key_identifier);
+ if (!id) {
+ return VKEY_UNKNOWN;
+ }
+ return id->key_code;
+}
+
+} // namespace ui
diff --git a/ui/base/keycodes/keyboard_code_conversion.h b/ui/base/keycodes/keyboard_code_conversion.h
new file mode 100644
index 0000000..a7a8331
--- /dev/null
+++ b/ui/base/keycodes/keyboard_code_conversion.h
@@ -0,0 +1,22 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_BASE_KEYCODES_KEYBOARD_CODE_CONVERSION_H_
+#define UI_BASE_KEYCODES_KEYBOARD_CODE_CONVERSION_H_
+#pragma once
+
+#include "ui/base/keycodes/keyboard_codes.h"
+
+#include <string>
+
+namespace ui {
+
+// Convert a KeyIdentifer (see Section 6.3.3 here:
+// http://www.w3.org/TR/DOM-Level-3-Events/#keyset-keyidentifiers)
+// to a ui::KeyboardCode.
+KeyboardCode KeyCodeFromKeyIdentifier(const std::string& key_identifier);
+
+} // namespace ui
+
+#endif // UI_BASE_KEYCODES_KEYBOARD_CODE_CONVERSION_H_
diff --git a/ui/base/keycodes/keyboard_code_conversion_gtk.cc b/ui/base/keycodes/keyboard_code_conversion_gtk.cc
new file mode 100644
index 0000000..f2e65a5
--- /dev/null
+++ b/ui/base/keycodes/keyboard_code_conversion_gtk.cc
@@ -0,0 +1,617 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
+ * Copyright (C) 2007 Holger Hans Peter Freyther
+ * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
+ * Copyright (C) 2008, 2009 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// WindowsKeyCodeForGdkKeyCode is copied from platform/gtk/KeyEventGtk.cpp
+
+#include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
+
+#include <gdk/gdkkeysyms.h>
+
+#include "ui/base/keycodes/keyboard_codes_posix.h"
+
+namespace ui {
+
+KeyboardCode WindowsKeyCodeForGdkKeyCode(int keycode) {
+ switch (keycode) {
+ case GDK_KP_0:
+ return VKEY_NUMPAD0; // (60) Numeric keypad 0 key
+ case GDK_KP_1:
+ return VKEY_NUMPAD1; // (61) Numeric keypad 1 key
+ case GDK_KP_2:
+ return VKEY_NUMPAD2; // (62) Numeric keypad 2 key
+ case GDK_KP_3:
+ return VKEY_NUMPAD3; // (63) Numeric keypad 3 key
+ case GDK_KP_4:
+ return VKEY_NUMPAD4; // (64) Numeric keypad 4 key
+ case GDK_KP_5:
+ return VKEY_NUMPAD5; // (65) Numeric keypad 5 key
+ case GDK_KP_6:
+ return VKEY_NUMPAD6; // (66) Numeric keypad 6 key
+ case GDK_KP_7:
+ return VKEY_NUMPAD7; // (67) Numeric keypad 7 key
+ case GDK_KP_8:
+ return VKEY_NUMPAD8; // (68) Numeric keypad 8 key
+ case GDK_KP_9:
+ return VKEY_NUMPAD9; // (69) Numeric keypad 9 key
+ case GDK_KP_Multiply:
+ return VKEY_MULTIPLY; // (6A) Multiply key
+ case GDK_KP_Add:
+ return VKEY_ADD; // (6B) Add key
+ case GDK_KP_Subtract:
+ return VKEY_SUBTRACT; // (6D) Subtract key
+ case GDK_KP_Decimal:
+ return VKEY_DECIMAL; // (6E) Decimal key
+ case GDK_KP_Divide:
+ return VKEY_DIVIDE; // (6F) Divide key
+
+ case GDK_BackSpace:
+ return VKEY_BACK; // (08) BACKSPACE key
+ case GDK_ISO_Left_Tab:
+ case GDK_3270_BackTab:
+ case GDK_Tab:
+ return VKEY_TAB; // (09) TAB key
+ case GDK_Clear:
+ return VKEY_CLEAR; // (0C) CLEAR key
+ case GDK_ISO_Enter:
+ case GDK_KP_Enter:
+ case GDK_Return:
+ return VKEY_RETURN; // (0D) Return key
+ case GDK_Shift_L:
+ case GDK_Shift_R:
+ return VKEY_SHIFT; // (10) SHIFT key
+ case GDK_Control_L:
+ case GDK_Control_R:
+ return VKEY_CONTROL; // (11) CTRL key
+ case GDK_Menu:
+ return VKEY_APPS; // (5D) Applications key (Natural keyboard)
+ case GDK_Alt_L:
+ case GDK_Alt_R:
+ return VKEY_MENU; // (12) ALT key
+
+ case GDK_Pause:
+ return VKEY_PAUSE; // (13) PAUSE key
+ case GDK_Caps_Lock:
+ return VKEY_CAPITAL; // (14) CAPS LOCK key
+ case GDK_Kana_Lock:
+ case GDK_Kana_Shift:
+ return VKEY_KANA; // (15) Input Method Editor (IME) Kana mode
+ case GDK_Hangul:
+ return VKEY_HANGUL; // VKEY_HANGUL (15) IME Hangul mode
+ // VKEY_JUNJA (17) IME Junja mode
+ // VKEY_FINAL (18) IME final mode
+ case GDK_Hangul_Hanja:
+ return VKEY_HANJA; // (19) IME Hanja mode
+ case GDK_Kanji:
+ return VKEY_KANJI; // (19) IME Kanji mode
+ case GDK_Escape:
+ return VKEY_ESCAPE; // (1B) ESC key
+ // VKEY_CONVERT (1C) IME convert
+ // VKEY_NONCONVERT (1D) IME nonconvert
+ // VKEY_ACCEPT (1E) IME accept
+ // VKEY_MODECHANGE (1F) IME mode change request
+ case GDK_space:
+ return VKEY_SPACE; // (20) SPACEBAR
+ case GDK_Page_Up:
+ return VKEY_PRIOR; // (21) PAGE UP key
+ case GDK_Page_Down:
+ return VKEY_NEXT; // (22) PAGE DOWN key
+ case GDK_End:
+ return VKEY_END; // (23) END key
+ case GDK_Home:
+ return VKEY_HOME; // (24) HOME key
+ case GDK_Left:
+ return VKEY_LEFT; // (25) LEFT ARROW key
+ case GDK_Up:
+ return VKEY_UP; // (26) UP ARROW key
+ case GDK_Right:
+ return VKEY_RIGHT; // (27) RIGHT ARROW key
+ case GDK_Down:
+ return VKEY_DOWN; // (28) DOWN ARROW key
+ case GDK_Select:
+ return VKEY_SELECT; // (29) SELECT key
+ case GDK_Print:
+ return VKEY_PRINT; // (2A) PRINT key
+ case GDK_Execute:
+ return VKEY_EXECUTE; // (2B) EXECUTE key
+ // dunno on this
+ // case GDK_PrintScreen:
+ // return VKEY_SNAPSHOT; // (2C) PRINT SCREEN key
+ case GDK_Insert:
+ return VKEY_INSERT; // (2D) INS key
+ case GDK_Delete:
+ return VKEY_DELETE; // (2E) DEL key
+ case GDK_Help:
+ return VKEY_HELP; // (2F) HELP key
+ case GDK_0:
+ case GDK_parenright:
+ return VKEY_0; // (30) 0) key
+ case GDK_1:
+ case GDK_exclam:
+ return VKEY_1; // (31) 1 ! key
+ case GDK_2:
+ case GDK_at:
+ return VKEY_2; // (32) 2 & key
+ case GDK_3:
+ case GDK_numbersign:
+ return VKEY_3; // case '3': case '#';
+ case GDK_4:
+ case GDK_dollar: // (34) 4 key '$';
+ return VKEY_4;
+ case GDK_5:
+ case GDK_percent:
+ return VKEY_5; // (35) 5 key '%'
+ case GDK_6:
+ case GDK_asciicircum:
+ return VKEY_6; // (36) 6 key '^'
+ case GDK_7:
+ case GDK_ampersand:
+ return VKEY_7; // (37) 7 key case '&'
+ case GDK_8:
+ case GDK_asterisk:
+ return VKEY_8; // (38) 8 key '*'
+ case GDK_9:
+ case GDK_parenleft:
+ return VKEY_9; // (39) 9 key '('
+ case GDK_a:
+ case GDK_A:
+ return VKEY_A; // (41) A key case 'a': case 'A': return 0x41;
+ case GDK_b:
+ case GDK_B:
+ return VKEY_B; // (42) B key case 'b': case 'B': return 0x42;
+ case GDK_c:
+ case GDK_C:
+ return VKEY_C; // (43) C key case 'c': case 'C': return 0x43;
+ case GDK_d:
+ case GDK_D:
+ return VKEY_D; // (44) D key case 'd': case 'D': return 0x44;
+ case GDK_e:
+ case GDK_E:
+ return VKEY_E; // (45) E key case 'e': case 'E': return 0x45;
+ case GDK_f:
+ case GDK_F:
+ return VKEY_F; // (46) F key case 'f': case 'F': return 0x46;
+ case GDK_g:
+ case GDK_G:
+ return VKEY_G; // (47) G key case 'g': case 'G': return 0x47;
+ case GDK_h:
+ case GDK_H:
+ return VKEY_H; // (48) H key case 'h': case 'H': return 0x48;
+ case GDK_i:
+ case GDK_I:
+ return VKEY_I; // (49) I key case 'i': case 'I': return 0x49;
+ case GDK_j:
+ case GDK_J:
+ return VKEY_J; // (4A) J key case 'j': case 'J': return 0x4A;
+ case GDK_k:
+ case GDK_K:
+ return VKEY_K; // (4B) K key case 'k': case 'K': return 0x4B;
+ case GDK_l:
+ case GDK_L:
+ return VKEY_L; // (4C) L key case 'l': case 'L': return 0x4C;
+ case GDK_m:
+ case GDK_M:
+ return VKEY_M; // (4D) M key case 'm': case 'M': return 0x4D;
+ case GDK_n:
+ case GDK_N:
+ return VKEY_N; // (4E) N key case 'n': case 'N': return 0x4E;
+ case GDK_o:
+ case GDK_O:
+ return VKEY_O; // (4F) O key case 'o': case 'O': return 0x4F;
+ case GDK_p:
+ case GDK_P:
+ return VKEY_P; // (50) P key case 'p': case 'P': return 0x50;
+ case GDK_q:
+ case GDK_Q:
+ return VKEY_Q; // (51) Q key case 'q': case 'Q': return 0x51;
+ case GDK_r:
+ case GDK_R:
+ return VKEY_R; // (52) R key case 'r': case 'R': return 0x52;
+ case GDK_s:
+ case GDK_S:
+ return VKEY_S; // (53) S key case 's': case 'S': return 0x53;
+ case GDK_t:
+ case GDK_T:
+ return VKEY_T; // (54) T key case 't': case 'T': return 0x54;
+ case GDK_u:
+ case GDK_U:
+ return VKEY_U; // (55) U key case 'u': case 'U': return 0x55;
+ case GDK_v:
+ case GDK_V:
+ return VKEY_V; // (56) V key case 'v': case 'V': return 0x56;
+ case GDK_w:
+ case GDK_W:
+ return VKEY_W; // (57) W key case 'w': case 'W': return 0x57;
+ case GDK_x:
+ case GDK_X:
+ return VKEY_X; // (58) X key case 'x': case 'X': return 0x58;
+ case GDK_y:
+ case GDK_Y:
+ return VKEY_Y; // (59) Y key case 'y': case 'Y': return 0x59;
+ case GDK_z:
+ case GDK_Z:
+ return VKEY_Z; // (5A) Z key case 'z': case 'Z': return 0x5A;
+ case GDK_Meta_L:
+ case GDK_Super_L:
+ return VKEY_LWIN; // (5B) Left Windows key (Microsoft Natural keyboard)
+ case GDK_Meta_R:
+ case GDK_Super_R:
+ return VKEY_RWIN; // (5C) Right Windows key (Natural keyboard)
+ // VKEY_SLEEP (5F) Computer Sleep key
+ // VKEY_SEPARATOR (6C) Separator key
+ // VKEY_SUBTRACT (6D) Subtract key
+ // VKEY_DECIMAL (6E) Decimal key
+ // VKEY_DIVIDE (6F) Divide key
+ // handled by key code above
+
+ case GDK_Num_Lock:
+ return VKEY_NUMLOCK; // (90) NUM LOCK key
+
+ case GDK_Scroll_Lock:
+ return VKEY_SCROLL; // (91) SCROLL LOCK key
+
+ // VKEY_LSHIFT (A0) Left SHIFT key
+ // VKEY_RSHIFT (A1) Right SHIFT key
+ // VKEY_LCONTROL (A2) Left CONTROL key
+ // VKEY_RCONTROL (A3) Right CONTROL key
+ // VKEY_LMENU (A4) Left MENU key
+ // VKEY_RMENU (A5) Right MENU key
+ // VKEY_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
+ // VKEY_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key
+ // VKEY_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key
+ // VKEY_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key
+ // VKEY_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key
+ // VKEY_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key
+ // VKEY_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key
+ // VKEY_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key
+ // VKEY_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key
+ // VKEY_VOLUME_UP (AF) Windows 2000/XP: Volume Up key
+ // VKEY_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key
+ // VKEY_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key
+ // VKEY_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key
+ // VKEY_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
+ // VKEY_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
+ // VKEY_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key
+ // VKEY_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
+ // VKEY_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
+
+ // VKEY_OEM_1 (BA) Used for miscellaneous characters; it can vary by
+ // keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
+ case GDK_semicolon:
+ case GDK_colon:
+ return VKEY_OEM_1; // case ';': case ':': return 0xBA;
+ // VKEY_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
+ case GDK_plus:
+ case GDK_equal:
+ return VKEY_OEM_PLUS; // case '=': case '+': return 0xBB;
+ // VKEY_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ','
+ // key
+ case GDK_comma:
+ case GDK_less:
+ return VKEY_OEM_COMMA; // case ',': case '<': return 0xBC;
+ // VKEY_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-'
+ // key
+ case GDK_minus:
+ case GDK_underscore:
+ return VKEY_OEM_MINUS; // case '-': case '_': return 0xBD;
+ // VKEY_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.'
+ // key
+ case GDK_period:
+ case GDK_greater:
+ return VKEY_OEM_PERIOD; // case '.': case '>': return 0xBE;
+ // VKEY_OEM_2 (BF) Used for miscellaneous characters; it can vary by
+ // keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
+ case GDK_slash:
+ case GDK_question:
+ return VKEY_OEM_2; // case '/': case '?': return 0xBF;
+ // VKEY_OEM_3 (C0) Used for miscellaneous characters; it can vary by
+ // keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
+ case GDK_asciitilde:
+ case GDK_quoteleft:
+ return VKEY_OEM_3; // case '`': case '~': return 0xC0;
+ // VKEY_OEM_4 (DB) Used for miscellaneous characters; it can vary by
+ // keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
+ case GDK_bracketleft:
+ case GDK_braceleft:
+ return VKEY_OEM_4; // case '[': case '{': return 0xDB;
+ // VKEY_OEM_5 (DC) Used for miscellaneous characters; it can vary by
+ // keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
+ case GDK_backslash:
+ case GDK_bar:
+ return VKEY_OEM_5; // case '\\': case '|': return 0xDC;
+ // VKEY_OEM_6 (DD) Used for miscellaneous characters; it can vary by
+ // keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
+ case GDK_bracketright:
+ case GDK_braceright:
+ return VKEY_OEM_6; // case ']': case '}': return 0xDD;
+ // VKEY_OEM_7 (DE) Used for miscellaneous characters; it can vary by
+ // keyboard. Windows 2000/XP: For the US standard keyboard, the
+ // 'single-quote/double-quote' key
+ case GDK_quoteright:
+ case GDK_quotedbl:
+ return VKEY_OEM_7; // case '\'': case '"': return 0xDE;
+ // VKEY_OEM_8 (DF) Used for miscellaneous characters; it can vary by
+ // keyboard.
+ // VKEY_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the
+ // backslash key on the RT 102-key keyboard
+ // VKEY_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP:
+ // IME PROCESS key
+ // VKEY_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if
+ // they were keystrokes. The VKEY_PACKET key is the low word of a 32-bit
+ // Virtual Key value used for non-keyboard input methods. For more
+ // information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and
+ // WM_KEYUP
+ // VKEY_ATTN (F6) Attn key
+ // VKEY_CRSEL (F7) CrSel key
+ // VKEY_EXSEL (F8) ExSel key
+ // VKEY_EREOF (F9) Erase EOF key
+ // VKEY_PLAY (FA) Play key
+ // VKEY_ZOOM (FB) Zoom key
+ // VKEY_NONAME (FC) Reserved for future use
+ // VKEY_PA1 (FD) PA1 key
+ // VKEY_OEM_CLEAR (FE) Clear key
+ case GDK_F1:
+ case GDK_F2:
+ case GDK_F3:
+ case GDK_F4:
+ case GDK_F5:
+ case GDK_F6:
+ case GDK_F7:
+ case GDK_F8:
+ case GDK_F9:
+ case GDK_F10:
+ case GDK_F11:
+ case GDK_F12:
+ case GDK_F13:
+ case GDK_F14:
+ case GDK_F15:
+ case GDK_F16:
+ case GDK_F17:
+ case GDK_F18:
+ case GDK_F19:
+ case GDK_F20:
+ case GDK_F21:
+ case GDK_F22:
+ case GDK_F23:
+ case GDK_F24:
+ return static_cast<KeyboardCode>(VKEY_F1 + (keycode - GDK_F1));
+ default:
+ return VKEY_UNKNOWN;
+ }
+}
+
+// TODO(jcampan): this method might be incomplete.
+int GdkKeyCodeForWindowsKeyCode(KeyboardCode keycode, bool shift) {
+ switch (keycode) {
+ case VKEY_NUMPAD0:
+ return GDK_KP_0;
+ case VKEY_NUMPAD1:
+ return GDK_KP_1;
+ case VKEY_NUMPAD2:
+ return GDK_KP_2;
+ case VKEY_NUMPAD3:
+ return GDK_KP_3;
+ case VKEY_NUMPAD4:
+ return GDK_KP_4;
+ case VKEY_NUMPAD5:
+ return GDK_KP_5;
+ case VKEY_NUMPAD6:
+ return GDK_KP_6;
+ case VKEY_NUMPAD7:
+ return GDK_KP_7;
+ case VKEY_NUMPAD8:
+ return GDK_KP_8;
+ case VKEY_NUMPAD9:
+ return GDK_KP_9;
+ case VKEY_MULTIPLY:
+ return GDK_KP_Multiply;
+ case VKEY_ADD:
+ return GDK_KP_Add;
+ case VKEY_SUBTRACT:
+ return GDK_KP_Subtract;
+ case VKEY_DECIMAL:
+ return GDK_KP_Decimal;
+ case VKEY_DIVIDE:
+ return GDK_KP_Divide;
+
+ case VKEY_BACK:
+ return GDK_BackSpace;
+ case VKEY_TAB:
+ return shift ? GDK_ISO_Left_Tab : GDK_Tab;
+ case VKEY_CLEAR:
+ return GDK_Clear;
+ case VKEY_RETURN:
+ return GDK_Return;
+ case VKEY_SHIFT:
+ return GDK_Shift_L;
+ case VKEY_CONTROL:
+ return GDK_Control_L;
+ case VKEY_MENU:
+ return GDK_Alt_L;
+ case VKEY_APPS:
+ return GDK_Menu;
+
+ case VKEY_PAUSE:
+ return GDK_Pause;
+ case VKEY_CAPITAL:
+ return GDK_Caps_Lock;
+ case VKEY_KANA:
+ return GDK_Kana_Lock;
+ case VKEY_HANJA:
+ return GDK_Hangul_Hanja;
+ case VKEY_ESCAPE:
+ return GDK_Escape;
+ case VKEY_SPACE:
+ return GDK_space;
+ case VKEY_PRIOR:
+ return GDK_Page_Up;
+ case VKEY_NEXT:
+ return GDK_Page_Down;
+ case VKEY_END:
+ return GDK_End;
+ case VKEY_HOME:
+ return GDK_Home;
+ case VKEY_LEFT:
+ return GDK_Left;
+ case VKEY_UP:
+ return GDK_Up;
+ case VKEY_RIGHT:
+ return GDK_Right;
+ case VKEY_DOWN:
+ return GDK_Down;
+ case VKEY_SELECT:
+ return GDK_Select;
+ case VKEY_PRINT:
+ return GDK_Print;
+ case VKEY_EXECUTE:
+ return GDK_Execute;
+ case VKEY_INSERT:
+ return GDK_Insert;
+ case VKEY_DELETE:
+ return GDK_Delete;
+ case VKEY_HELP:
+ return GDK_Help;
+ case VKEY_0:
+ return shift ? GDK_parenright : GDK_0;
+ case VKEY_1:
+ return shift ? GDK_exclam : GDK_1;
+ case VKEY_2:
+ return shift ? GDK_at : GDK_2;
+ case VKEY_3:
+ return shift ? GDK_numbersign : GDK_3;
+ case VKEY_4:
+ return shift ? GDK_dollar : GDK_4;
+ case VKEY_5:
+ return shift ? GDK_percent : GDK_5;
+ case VKEY_6:
+ return shift ? GDK_asciicircum : GDK_6;
+ case VKEY_7:
+ return shift ? GDK_ampersand : GDK_7;
+ case VKEY_8:
+ return shift ? GDK_asterisk : GDK_8;
+ case VKEY_9:
+ return shift ? GDK_parenleft : GDK_9;
+
+ case VKEY_A:
+ case VKEY_B:
+ case VKEY_C:
+ case VKEY_D:
+ case VKEY_E:
+ case VKEY_F:
+ case VKEY_G:
+ case VKEY_H:
+ case VKEY_I:
+ case VKEY_J:
+ case VKEY_K:
+ case VKEY_L:
+ case VKEY_M:
+ case VKEY_N:
+ case VKEY_O:
+ case VKEY_P:
+ case VKEY_Q:
+ case VKEY_R:
+ case VKEY_S:
+ case VKEY_T:
+ case VKEY_U:
+ case VKEY_V:
+ case VKEY_W:
+ case VKEY_X:
+ case VKEY_Y:
+ case VKEY_Z:
+ return (shift ? GDK_A : GDK_a) + (keycode - VKEY_A);
+
+ case VKEY_LWIN:
+ return GDK_Meta_L;
+ case VKEY_RWIN:
+ return GDK_Meta_R;
+
+ case VKEY_NUMLOCK:
+ return GDK_Num_Lock;
+
+ case VKEY_SCROLL:
+ return GDK_Scroll_Lock;
+
+ case VKEY_OEM_1:
+ return shift ? GDK_colon : GDK_semicolon;
+ case VKEY_OEM_PLUS:
+ return shift ? GDK_plus : GDK_equal;
+ case VKEY_OEM_COMMA:
+ return shift ? GDK_less : GDK_comma;
+ case VKEY_OEM_MINUS:
+ return shift ? GDK_underscore : GDK_minus;
+ case VKEY_OEM_PERIOD:
+ return shift ? GDK_greater : GDK_period;
+ case VKEY_OEM_2:
+ return shift ? GDK_question : GDK_slash;
+ case VKEY_OEM_3:
+ return shift ? GDK_asciitilde : GDK_quoteleft;
+ case VKEY_OEM_4:
+ return shift ? GDK_braceleft : GDK_bracketleft;
+ case VKEY_OEM_5:
+ return shift ? GDK_bar : GDK_backslash;
+ case VKEY_OEM_6:
+ return shift ? GDK_braceright : GDK_bracketright;
+ case VKEY_OEM_7:
+ return shift ? GDK_quotedbl : GDK_quoteright;
+
+ case VKEY_F1:
+ case VKEY_F2:
+ case VKEY_F3:
+ case VKEY_F4:
+ case VKEY_F5:
+ case VKEY_F6:
+ case VKEY_F7:
+ case VKEY_F8:
+ case VKEY_F9:
+ case VKEY_F10:
+ case VKEY_F11:
+ case VKEY_F12:
+ case VKEY_F13:
+ case VKEY_F14:
+ case VKEY_F15:
+ case VKEY_F16:
+ case VKEY_F17:
+ case VKEY_F18:
+ case VKEY_F19:
+ case VKEY_F20:
+ case VKEY_F21:
+ case VKEY_F22:
+ case VKEY_F23:
+ case VKEY_F24:
+ return GDK_F1 + (keycode - VKEY_F1);
+
+ default:
+ return 0;
+ }
+}
+
+} // namespace ui
diff --git a/ui/base/keycodes/keyboard_code_conversion_gtk.h b/ui/base/keycodes/keyboard_code_conversion_gtk.h
new file mode 100644
index 0000000..e30d8d9
--- /dev/null
+++ b/ui/base/keycodes/keyboard_code_conversion_gtk.h
@@ -0,0 +1,50 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
+ * Copyright (C) 2007 Holger Hans Peter Freyther
+ * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
+ * Copyright (C) 2008, 2009 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// WindowsKeyCodeForGdkKeyCode is copied from platform/gtk/KeyEventGtk.cpp
+
+#ifndef UI_BASE_KEYCODES_KEYBOARD_CODE_CONVERSION_GTK_H_
+#define UI_BASE_KEYCODES_KEYBOARD_CODE_CONVERSION_GTK_H_
+#pragma once
+
+#include "ui/base/keycodes/keyboard_codes_posix.h"
+
+namespace ui {
+
+KeyboardCode WindowsKeyCodeForGdkKeyCode(int keycode);
+
+int GdkKeyCodeForWindowsKeyCode(KeyboardCode keycode, bool shift);
+
+} // namespace ui
+
+#endif // UI_BASE_KEYCODES_KEYBOARD_CODE_CONVERSION_GTK_H_
diff --git a/ui/base/keycodes/keyboard_code_conversion_mac.h b/ui/base/keycodes/keyboard_code_conversion_mac.h
new file mode 100644
index 0000000..f277718
--- /dev/null
+++ b/ui/base/keycodes/keyboard_code_conversion_mac.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_BASE_KEYCODES_KEYBOARD_CODE_CONVERSION_MAC_H_
+#define UI_BASE_KEYCODES_KEYBOARD_CODE_CONVERSION_MAC_H_
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/basictypes.h"
+#include "ui/base/keycodes/keyboard_codes_posix.h"
+
+namespace ui {
+
+// We use windows virtual keycodes throughout our keyboard event related code,
+// including unit tests. But Mac uses a different set of virtual keycodes.
+// This function converts a windows virtual keycode into Mac's virtual key code
+// and corresponding unicode character. |flags| is the modifiers mask such
+// as NSControlKeyMask, NSShiftKeyMask, etc.
+// When success, the corresponding Mac's virtual key code will be returned.
+// The corresponding unicode character will be stored in |character|, and the
+// corresponding unicode character ignoring the modifiers will be stored in
+// |characterIgnoringModifiers|.
+// -1 will be returned if the keycode can't be converted.
+// This function is mainly for simulating keyboard events in unit tests.
+// See third_party/WebKit/WebKit/chromium/src/mac/WebInputEventFactory.mm for
+// reverse conversion.
+int MacKeyCodeForWindowsKeyCode(KeyboardCode keycode,
+ NSUInteger flags,
+ unichar* character,
+ unichar* characterIgnoringModifiers);
+
+} // namespace ui
+
+#endif // UI_BASE_KEYCODES_KEYBOARD_CODE_CONVERSION_MAC_H_
diff --git a/ui/base/keycodes/keyboard_code_conversion_mac.mm b/ui/base/keycodes/keyboard_code_conversion_mac.mm
new file mode 100644
index 0000000..e3c3665
--- /dev/null
+++ b/ui/base/keycodes/keyboard_code_conversion_mac.mm
@@ -0,0 +1,293 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ui/base/keycodes/keyboard_code_conversion_mac.h"
+
+#include <algorithm>
+#import <Carbon/Carbon.h>
+
+#include "base/logging.h"
+
+namespace ui {
+
+namespace {
+
+// A struct to hold a Windows keycode to Mac virtual keycode mapping.
+struct KeyCodeMap {
+ KeyboardCode keycode;
+ int macKeycode;
+ unichar characterIgnoringModifiers;
+};
+
+// Customized less operator for using std::lower_bound() on a KeyCodeMap array.
+bool operator<(const KeyCodeMap& a, const KeyCodeMap& b) {
+ return a.keycode < b.keycode;
+}
+
+// This array must keep sorted ascending according to the value of |keycode|,
+// so that we can binary search it.
+// TODO(suzhe): This map is not complete, missing entries have macKeycode == -1.
+const KeyCodeMap kKeyCodesMap[] = {
+ { VKEY_BACK /* 0x08 */, kVK_Delete, kBackspaceCharCode },
+ { VKEY_TAB /* 0x09 */, kVK_Tab, kTabCharCode },
+ { VKEY_CLEAR /* 0x0C */, kVK_ANSI_KeypadClear, kClearCharCode },
+ { VKEY_RETURN /* 0x0D */, kVK_Return, kReturnCharCode },
+ { VKEY_SHIFT /* 0x10 */, kVK_Shift, 0 },
+ { VKEY_CONTROL /* 0x11 */, kVK_Control, 0 },
+ { VKEY_MENU /* 0x12 */, kVK_Option, 0 },
+ { VKEY_PAUSE /* 0x13 */, -1, NSPauseFunctionKey },
+ { VKEY_CAPITAL /* 0x14 */, kVK_CapsLock, 0 },
+ { VKEY_KANA /* 0x15 */, kVK_JIS_Kana, 0 },
+ { VKEY_HANGUL /* 0x15 */, -1, 0 },
+ { VKEY_JUNJA /* 0x17 */, -1, 0 },
+ { VKEY_FINAL /* 0x18 */, -1, 0 },
+ { VKEY_HANJA /* 0x19 */, -1, 0 },
+ { VKEY_KANJI /* 0x19 */, -1, 0 },
+ { VKEY_ESCAPE /* 0x1B */, kVK_Escape, kEscapeCharCode },
+ { VKEY_CONVERT /* 0x1C */, -1, 0 },
+ { VKEY_NONCONVERT /* 0x1D */, -1, 0 },
+ { VKEY_ACCEPT /* 0x1E */, -1, 0 },
+ { VKEY_MODECHANGE /* 0x1F */, -1, 0 },
+ { VKEY_SPACE /* 0x20 */, kVK_Space, kSpaceCharCode },
+ { VKEY_PRIOR /* 0x21 */, kVK_PageUp, NSPageUpFunctionKey },
+ { VKEY_NEXT /* 0x22 */, kVK_PageDown, NSPageDownFunctionKey },
+ { VKEY_END /* 0x23 */, kVK_End, NSEndFunctionKey },
+ { VKEY_HOME /* 0x24 */, kVK_Home, NSHomeFunctionKey },
+ { VKEY_LEFT /* 0x25 */, kVK_LeftArrow, NSLeftArrowFunctionKey },
+ { VKEY_UP /* 0x26 */, kVK_UpArrow, NSUpArrowFunctionKey },
+ { VKEY_RIGHT /* 0x27 */, kVK_RightArrow, NSRightArrowFunctionKey },
+ { VKEY_DOWN /* 0x28 */, kVK_DownArrow, NSDownArrowFunctionKey },
+ { VKEY_SELECT /* 0x29 */, -1, 0 },
+ { VKEY_PRINT /* 0x2A */, -1, NSPrintFunctionKey },
+ { VKEY_EXECUTE /* 0x2B */, -1, NSExecuteFunctionKey },
+ { VKEY_SNAPSHOT /* 0x2C */, -1, NSPrintScreenFunctionKey },
+ { VKEY_INSERT /* 0x2D */, -1, NSInsertFunctionKey },
+ { VKEY_DELETE /* 0x2E */, kVK_ForwardDelete, kDeleteCharCode },
+ { VKEY_HELP /* 0x2F */, kVK_Help, kHelpCharCode },
+ { VKEY_0 /* 0x30 */, kVK_ANSI_0, '0' },
+ { VKEY_1 /* 0x31 */, kVK_ANSI_1, '1' },
+ { VKEY_2 /* 0x32 */, kVK_ANSI_2, '2' },
+ { VKEY_3 /* 0x33 */, kVK_ANSI_3, '3' },
+ { VKEY_4 /* 0x34 */, kVK_ANSI_4, '4' },
+ { VKEY_5 /* 0x35 */, kVK_ANSI_5, '5' },
+ { VKEY_6 /* 0x36 */, kVK_ANSI_6, '6' },
+ { VKEY_7 /* 0x37 */, kVK_ANSI_7, '7' },
+ { VKEY_8 /* 0x38 */, kVK_ANSI_8, '8' },
+ { VKEY_9 /* 0x39 */, kVK_ANSI_9, '9' },
+ { VKEY_A /* 0x41 */, kVK_ANSI_A, 'a' },
+ { VKEY_B /* 0x42 */, kVK_ANSI_B, 'b' },
+ { VKEY_C /* 0x43 */, kVK_ANSI_C, 'c' },
+ { VKEY_D /* 0x44 */, kVK_ANSI_D, 'd' },
+ { VKEY_E /* 0x45 */, kVK_ANSI_E, 'e' },
+ { VKEY_F /* 0x46 */, kVK_ANSI_F, 'f' },
+ { VKEY_G /* 0x47 */, kVK_ANSI_G, 'g' },
+ { VKEY_H /* 0x48 */, kVK_ANSI_H, 'h' },
+ { VKEY_I /* 0x49 */, kVK_ANSI_I, 'i' },
+ { VKEY_J /* 0x4A */, kVK_ANSI_J, 'j' },
+ { VKEY_K /* 0x4B */, kVK_ANSI_K, 'k' },
+ { VKEY_L /* 0x4C */, kVK_ANSI_L, 'l' },
+ { VKEY_M /* 0x4D */, kVK_ANSI_M, 'm' },
+ { VKEY_N /* 0x4E */, kVK_ANSI_N, 'n' },
+ { VKEY_O /* 0x4F */, kVK_ANSI_O, 'o' },
+ { VKEY_P /* 0x50 */, kVK_ANSI_P, 'p' },
+ { VKEY_Q /* 0x51 */, kVK_ANSI_Q, 'q' },
+ { VKEY_R /* 0x52 */, kVK_ANSI_R, 'r' },
+ { VKEY_S /* 0x53 */, kVK_ANSI_S, 's' },
+ { VKEY_T /* 0x54 */, kVK_ANSI_T, 't' },
+ { VKEY_U /* 0x55 */, kVK_ANSI_U, 'u' },
+ { VKEY_V /* 0x56 */, kVK_ANSI_V, 'v' },
+ { VKEY_W /* 0x57 */, kVK_ANSI_W, 'w' },
+ { VKEY_X /* 0x58 */, kVK_ANSI_X, 'x' },
+ { VKEY_Y /* 0x59 */, kVK_ANSI_Y, 'y' },
+ { VKEY_Z /* 0x5A */, kVK_ANSI_Z, 'z' },
+ { VKEY_LWIN /* 0x5B */, kVK_Command, 0 },
+ { VKEY_RWIN /* 0x5C */, 0x36, 0 },
+ { VKEY_APPS /* 0x5D */, 0x36, 0 },
+ { VKEY_SLEEP /* 0x5F */, -1, 0 },
+ { VKEY_NUMPAD0 /* 0x60 */, kVK_ANSI_Keypad0, '0' },
+ { VKEY_NUMPAD1 /* 0x61 */, kVK_ANSI_Keypad1, '1' },
+ { VKEY_NUMPAD2 /* 0x62 */, kVK_ANSI_Keypad2, '2' },
+ { VKEY_NUMPAD3 /* 0x63 */, kVK_ANSI_Keypad3, '3' },
+ { VKEY_NUMPAD4 /* 0x64 */, kVK_ANSI_Keypad4, '4' },
+ { VKEY_NUMPAD5 /* 0x65 */, kVK_ANSI_Keypad5, '5' },
+ { VKEY_NUMPAD6 /* 0x66 */, kVK_ANSI_Keypad6, '6' },
+ { VKEY_NUMPAD7 /* 0x67 */, kVK_ANSI_Keypad7, '7' },
+ { VKEY_NUMPAD8 /* 0x68 */, kVK_ANSI_Keypad8, '8' },
+ { VKEY_NUMPAD9 /* 0x69 */, kVK_ANSI_Keypad9, '9' },
+ { VKEY_MULTIPLY /* 0x6A */, kVK_ANSI_KeypadMultiply, '*' },
+ { VKEY_ADD /* 0x6B */, kVK_ANSI_KeypadPlus, '+' },
+ { VKEY_SEPARATOR /* 0x6C */, -1, 0 },
+ { VKEY_SUBTRACT /* 0x6D */, kVK_ANSI_KeypadMinus, '-' },
+ { VKEY_DECIMAL /* 0x6E */, kVK_ANSI_KeypadDecimal, '.' },
+ { VKEY_DIVIDE /* 0x6F */, kVK_ANSI_KeypadDivide, '/' },
+ { VKEY_F1 /* 0x70 */, kVK_F1, NSF1FunctionKey },
+ { VKEY_F2 /* 0x71 */, kVK_F2, NSF2FunctionKey },
+ { VKEY_F3 /* 0x72 */, kVK_F3, NSF3FunctionKey },
+ { VKEY_F4 /* 0x73 */, kVK_F4, NSF4FunctionKey },
+ { VKEY_F5 /* 0x74 */, kVK_F5, NSF5FunctionKey },
+ { VKEY_F6 /* 0x75 */, kVK_F6, NSF6FunctionKey },
+ { VKEY_F7 /* 0x76 */, kVK_F7, NSF7FunctionKey },
+ { VKEY_F8 /* 0x77 */, kVK_F8, NSF8FunctionKey },
+ { VKEY_F9 /* 0x78 */, kVK_F9, NSF9FunctionKey },
+ { VKEY_F10 /* 0x79 */, kVK_F10, NSF10FunctionKey },
+ { VKEY_F11 /* 0x7A */, kVK_F11, NSF11FunctionKey },
+ { VKEY_F12 /* 0x7B */, kVK_F12, NSF12FunctionKey },
+ { VKEY_F13 /* 0x7C */, kVK_F13, NSF13FunctionKey },
+ { VKEY_F14 /* 0x7D */, kVK_F14, NSF14FunctionKey },
+ { VKEY_F15 /* 0x7E */, kVK_F15, NSF15FunctionKey },
+ { VKEY_F16 /* 0x7F */, kVK_F16, NSF16FunctionKey },
+ { VKEY_F17 /* 0x80 */, kVK_F17, NSF17FunctionKey },
+ { VKEY_F18 /* 0x81 */, kVK_F18, NSF18FunctionKey },
+ { VKEY_F19 /* 0x82 */, kVK_F19, NSF19FunctionKey },
+ { VKEY_F20 /* 0x83 */, kVK_F20, NSF20FunctionKey },
+ { VKEY_F21 /* 0x84 */, -1, NSF21FunctionKey },
+ { VKEY_F22 /* 0x85 */, -1, NSF22FunctionKey },
+ { VKEY_F23 /* 0x86 */, -1, NSF23FunctionKey },
+ { VKEY_F24 /* 0x87 */, -1, NSF24FunctionKey },
+ { VKEY_NUMLOCK /* 0x90 */, -1, 0 },
+ { VKEY_SCROLL /* 0x91 */, -1, NSScrollLockFunctionKey },
+ { VKEY_LSHIFT /* 0xA0 */, kVK_Shift, 0 },
+ { VKEY_RSHIFT /* 0xA1 */, kVK_Shift, 0 },
+ { VKEY_LCONTROL /* 0xA2 */, kVK_Control, 0 },
+ { VKEY_RCONTROL /* 0xA3 */, kVK_Control, 0 },
+ { VKEY_LMENU /* 0xA4 */, -1, 0 },
+ { VKEY_RMENU /* 0xA5 */, -1, 0 },
+ { VKEY_BROWSER_BACK /* 0xA6 */, -1, 0 },
+ { VKEY_BROWSER_FORWARD /* 0xA7 */, -1, 0 },
+ { VKEY_BROWSER_REFRESH /* 0xA8 */, -1, 0 },
+ { VKEY_BROWSER_STOP /* 0xA9 */, -1, 0 },
+ { VKEY_BROWSER_SEARCH /* 0xAA */, -1, 0 },
+ { VKEY_BROWSER_FAVORITES /* 0xAB */, -1, 0 },
+ { VKEY_BROWSER_HOME /* 0xAC */, -1, 0 },
+ { VKEY_VOLUME_MUTE /* 0xAD */, -1, 0 },
+ { VKEY_VOLUME_DOWN /* 0xAE */, -1, 0 },
+ { VKEY_VOLUME_UP /* 0xAF */, -1, 0 },
+ { VKEY_MEDIA_NEXT_TRACK /* 0xB0 */, -1, 0 },
+ { VKEY_MEDIA_PREV_TRACK /* 0xB1 */, -1, 0 },
+ { VKEY_MEDIA_STOP /* 0xB2 */, -1, 0 },
+ { VKEY_MEDIA_PLAY_PAUSE /* 0xB3 */, -1, 0 },
+ { VKEY_MEDIA_LAUNCH_MAIL /* 0xB4 */, -1, 0 },
+ { VKEY_MEDIA_LAUNCH_MEDIA_SELECT /* 0xB5 */, -1, 0 },
+ { VKEY_MEDIA_LAUNCH_APP1 /* 0xB6 */, -1, 0 },
+ { VKEY_MEDIA_LAUNCH_APP2 /* 0xB7 */, -1, 0 },
+ { VKEY_OEM_1 /* 0xBA */, kVK_ANSI_Semicolon, ';' },
+ { VKEY_OEM_PLUS /* 0xBB */, kVK_ANSI_Equal, '=' },
+ { VKEY_OEM_COMMA /* 0xBC */, kVK_ANSI_Comma, ',' },
+ { VKEY_OEM_MINUS /* 0xBD */, kVK_ANSI_Minus, '-' },
+ { VKEY_OEM_PERIOD /* 0xBE */, kVK_ANSI_Period, '.' },
+ { VKEY_OEM_2 /* 0xBF */, kVK_ANSI_Slash, '/' },
+ { VKEY_OEM_3 /* 0xC0 */, kVK_ANSI_Grave, '`' },
+ { VKEY_OEM_4 /* 0xDB */, kVK_ANSI_LeftBracket, '[' },
+ { VKEY_OEM_5 /* 0xDC */, kVK_ANSI_Backslash, '\\' },
+ { VKEY_OEM_6 /* 0xDD */, kVK_ANSI_RightBracket, ']' },
+ { VKEY_OEM_7 /* 0xDE */, kVK_ANSI_Quote, '\'' },
+ { VKEY_OEM_8 /* 0xDF */, -1, 0 },
+ { VKEY_OEM_102 /* 0xE2 */, -1, 0 },
+ { VKEY_PROCESSKEY /* 0xE5 */, -1, 0 },
+ { VKEY_PACKET /* 0xE7 */, -1, 0 },
+ { VKEY_ATTN /* 0xF6 */, -1, 0 },
+ { VKEY_CRSEL /* 0xF7 */, -1, 0 },
+ { VKEY_EXSEL /* 0xF8 */, -1, 0 },
+ { VKEY_EREOF /* 0xF9 */, -1, 0 },
+ { VKEY_PLAY /* 0xFA */, -1, 0 },
+ { VKEY_ZOOM /* 0xFB */, -1, 0 },
+ { VKEY_NONAME /* 0xFC */, -1, 0 },
+ { VKEY_PA1 /* 0xFD */, -1, 0 },
+ { VKEY_OEM_CLEAR /* 0xFE */, kVK_ANSI_KeypadClear, kClearCharCode }
+};
+
+// A convenient array for getting symbol characters on the number keys.
+const char kShiftCharsForNumberKeys[] = ")!@#$%^&*(";
+
+} // anonymous namespace
+
+int MacKeyCodeForWindowsKeyCode(KeyboardCode keycode,
+ NSUInteger flags,
+ unichar* character,
+ unichar* characterIgnoringModifiers) {
+ KeyCodeMap from;
+ from.keycode = keycode;
+
+ const KeyCodeMap* ptr = std::lower_bound(
+ kKeyCodesMap, kKeyCodesMap + arraysize(kKeyCodesMap), from);
+
+ if (ptr >= kKeyCodesMap + arraysize(kKeyCodesMap) ||
+ ptr->keycode != keycode || ptr->macKeycode == -1) {
+ NOTREACHED() << "Unsupported keycode:" << keycode;
+ return -1;
+ }
+
+ int macKeycode = ptr->macKeycode;
+ if (characterIgnoringModifiers)
+ *characterIgnoringModifiers = ptr->characterIgnoringModifiers;
+
+ if (!character)
+ return macKeycode;
+
+ *character = ptr->characterIgnoringModifiers;
+
+ // Fill in |character| according to flags.
+ if (flags & NSShiftKeyMask) {
+ if (keycode >= VKEY_0 && keycode <= VKEY_9) {
+ *character = kShiftCharsForNumberKeys[keycode - VKEY_0];
+ } else if (keycode >= VKEY_A && keycode <= VKEY_Z) {
+ *character = 'A' + (keycode - VKEY_A);
+ } else {
+ switch (macKeycode) {
+ case kVK_ANSI_Grave:
+ *character = '~';
+ break;
+ case kVK_ANSI_Minus:
+ *character = '_';
+ break;
+ case kVK_ANSI_Equal:
+ *character = '+';
+ break;
+ case kVK_ANSI_LeftBracket:
+ *character = '{';
+ break;
+ case kVK_ANSI_RightBracket:
+ *character = '}';
+ break;
+ case kVK_ANSI_Backslash:
+ *character = '|';
+ break;
+ case kVK_ANSI_Semicolon:
+ *character = ':';
+ break;
+ case kVK_ANSI_Quote:
+ *character = '\"';
+ break;
+ case kVK_ANSI_Comma:
+ *character = '<';
+ break;
+ case kVK_ANSI_Period:
+ *character = '>';
+ break;
+ case kVK_ANSI_Slash:
+ *character = '?';
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ // Control characters.
+ if (flags & NSControlKeyMask) {
+ if (keycode >= VKEY_A && keycode <= VKEY_Z)
+ *character = 1 + keycode - VKEY_A;
+ else if (macKeycode == kVK_ANSI_LeftBracket)
+ *character = 27;
+ else if (macKeycode == kVK_ANSI_Backslash)
+ *character = 28;
+ else if (macKeycode == kVK_ANSI_RightBracket)
+ *character = 29;
+ }
+
+ // TODO(suzhe): Support characters for Option key bindings.
+ return macKeycode;
+}
+
+} // namespace ui
diff --git a/ui/base/keycodes/keyboard_code_conversion_unittest.cc b/ui/base/keycodes/keyboard_code_conversion_unittest.cc
new file mode 100644
index 0000000..689145a
--- /dev/null
+++ b/ui/base/keycodes/keyboard_code_conversion_unittest.cc
@@ -0,0 +1,43 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/keycodes/keyboard_code_conversion.h"
+#include "ui/base/keycodes/keyboard_codes.h"
+#include "base/logging.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace ui {
+
+TEST(KeyCodeFromKeyIdentifierTest, MatchOnIdentifier) {
+ EXPECT_EQ(VKEY_APPS, KeyCodeFromKeyIdentifier("Apps"));
+ EXPECT_EQ(VKEY_UNKNOWN, KeyCodeFromKeyIdentifier("Nonsense"));
+}
+
+TEST(KeyCodeFromKeyIdentifierTest, MatchOnCharacter) {
+ EXPECT_EQ(VKEY_A, KeyCodeFromKeyIdentifier("a"));
+ EXPECT_EQ(VKEY_A, KeyCodeFromKeyIdentifier("A"));
+ EXPECT_EQ(VKEY_OEM_PERIOD, KeyCodeFromKeyIdentifier(">"));
+
+ std::string non_printing_char(" ");
+ non_printing_char[0] = static_cast<char>(1);
+ EXPECT_EQ(VKEY_UNKNOWN, KeyCodeFromKeyIdentifier(non_printing_char));
+}
+
+TEST(KeyCodeFromKeyIdentifierTest, MatchOnUnicodeCodepoint) {
+ EXPECT_EQ(VKEY_A, KeyCodeFromKeyIdentifier("U+0041"));
+ EXPECT_EQ(VKEY_A, KeyCodeFromKeyIdentifier("U+0061"));
+ EXPECT_EQ(VKEY_DELETE, KeyCodeFromKeyIdentifier("U+007F"));
+
+ // this one exists in the map, but has no valid VKEY
+ EXPECT_EQ(VKEY_UNKNOWN, KeyCodeFromKeyIdentifier("U+030A"));
+
+ // this one is not in the map
+ EXPECT_EQ(VKEY_UNKNOWN, KeyCodeFromKeyIdentifier("U+0001"));
+}
+
+TEST(KeyCodeFromKeyIdentifierTest, DoesNotMatchEmptyString) {
+ EXPECT_EQ(VKEY_UNKNOWN, KeyCodeFromKeyIdentifier(""));
+}
+
+} // namespace ui
diff --git a/ui/base/keycodes/keyboard_code_conversion_win.cc b/ui/base/keycodes/keyboard_code_conversion_win.cc
new file mode 100644
index 0000000..f85cc50
--- /dev/null
+++ b/ui/base/keycodes/keyboard_code_conversion_win.cc
@@ -0,0 +1,17 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/keycodes/keyboard_code_conversion_win.h"
+
+namespace ui {
+
+WORD WindowsKeyCodeForKeyboardCode(KeyboardCode keycode) {
+ return static_cast<WORD>(keycode);
+}
+
+KeyboardCode KeyboardCodeForWindowsKeyCode(WORD keycode) {
+ return static_cast<KeyboardCode>(keycode);
+}
+
+} // namespace ui
diff --git a/ui/base/keycodes/keyboard_code_conversion_win.h b/ui/base/keycodes/keyboard_code_conversion_win.h
new file mode 100644
index 0000000..98310a1
--- /dev/null
+++ b/ui/base/keycodes/keyboard_code_conversion_win.h
@@ -0,0 +1,19 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_BASE_KEYCODES_KEYBOARD_CODE_CONVERSION_WIN_H_
+#define UI_BASE_KEYCODES_KEYBOARD_CODE_CONVERSION_WIN_H_
+#pragma once
+
+#include "ui/base/keycodes/keyboard_codes.h"
+
+namespace ui {
+
+// Methods to convert ui::KeyboardCode/Windows virtual key type methods.
+WORD WindowsKeyCodeForKeyboardCode(KeyboardCode keycode);
+KeyboardCode KeyboardCodeForWindowsKeyCode(WORD keycode);
+
+} // namespace ui
+
+#endif // UI_BASE_KEYCODES_KEYBOARD_CODE_CONVERSION_WIN_H_
diff --git a/ui/base/keycodes/keyboard_code_conversion_x.cc b/ui/base/keycodes/keyboard_code_conversion_x.cc
new file mode 100644
index 0000000..47ce830
--- /dev/null
+++ b/ui/base/keycodes/keyboard_code_conversion_x.cc
@@ -0,0 +1,281 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/keycodes/keyboard_code_conversion_x.h"
+
+#include <X11/keysym.h>
+#include <X11/Xlib.h>
+
+#include "base/logging.h"
+
+namespace ui {
+
+// Get an ui::KeyboardCode from an X keyevent
+KeyboardCode KeyboardCodeFromXKeyEvent(XEvent* xev) {
+ KeySym keysym = XLookupKeysym(&xev->xkey, 0);
+
+ // Consult GDK key translation (in WindowsKeyCodeForGdkKeyCode) for details
+ // about the following translations.
+
+ // TODO(sad): Have |keysym| go through the X map list?
+
+ switch (keysym) {
+ case XK_BackSpace:
+ return VKEY_BACK;
+ case XK_Delete:
+ case XK_KP_Delete:
+ return VKEY_DELETE;
+ case XK_Tab:
+ case XK_KP_Tab:
+ return VKEY_TAB;
+ case XK_Linefeed:
+ case XK_Return:
+ case XK_KP_Enter:
+ return VKEY_RETURN;
+ case XK_Clear:
+ return VKEY_CLEAR;
+ case XK_KP_Space:
+ case XK_space:
+ return VKEY_SPACE;
+ case XK_Home:
+ case XK_KP_Home:
+ return VKEY_HOME;
+ case XK_End:
+ case XK_KP_End:
+ return VKEY_END;
+ case XK_Page_Up:
+ case XK_KP_Page_Up:
+ return VKEY_PRIOR;
+ case XK_Page_Down:
+ case XK_KP_Page_Down:
+ return VKEY_NEXT;
+ case XK_Left:
+ case XK_KP_Left:
+ return VKEY_LEFT;
+ case XK_Right:
+ case XK_KP_Right:
+ return VKEY_RIGHT;
+ case XK_Down:
+ case XK_KP_Down:
+ return VKEY_DOWN;
+ case XK_Up:
+ case XK_KP_Up:
+ return VKEY_UP;
+ case XK_Escape:
+ return VKEY_ESCAPE;
+ case XK_A:
+ case XK_a:
+ return VKEY_A;
+ case XK_B:
+ case XK_b:
+ return VKEY_B;
+ case XK_C:
+ case XK_c:
+ return VKEY_C;
+ case XK_D:
+ case XK_d:
+ return VKEY_D;
+ case XK_E:
+ case XK_e:
+ return VKEY_E;
+ case XK_F:
+ case XK_f:
+ return VKEY_F;
+ case XK_G:
+ case XK_g:
+ return VKEY_G;
+ case XK_H:
+ case XK_h:
+ return VKEY_H;
+ case XK_I:
+ case XK_i:
+ return VKEY_I;
+ case XK_J:
+ case XK_j:
+ return VKEY_J;
+ case XK_K:
+ case XK_k:
+ return VKEY_K;
+ case XK_L:
+ case XK_l:
+ return VKEY_L;
+ case XK_M:
+ case XK_m:
+ return VKEY_M;
+ case XK_N:
+ case XK_n:
+ return VKEY_N;
+ case XK_O:
+ case XK_o:
+ return VKEY_O;
+ case XK_P:
+ case XK_p:
+ return VKEY_P;
+ case XK_Q:
+ case XK_q:
+ return VKEY_Q;
+ case XK_R:
+ case XK_r:
+ return VKEY_R;
+ case XK_S:
+ case XK_s:
+ return VKEY_S;
+ case XK_T:
+ case XK_t:
+ return VKEY_T;
+ case XK_U:
+ case XK_u:
+ return VKEY_U;
+ case XK_V:
+ case XK_v:
+ return VKEY_V;
+ case XK_W:
+ case XK_w:
+ return VKEY_W;
+ case XK_X:
+ case XK_x:
+ return VKEY_X;
+ case XK_Y:
+ case XK_y:
+ return VKEY_Y;
+ case XK_Z:
+ case XK_z:
+ return VKEY_Z;
+ case XK_0:
+ return VKEY_0;
+ case XK_1:
+ return VKEY_1;
+ case XK_2:
+ return VKEY_2;
+ case XK_3:
+ return VKEY_3;
+ case XK_4:
+ return VKEY_4;
+ case XK_5:
+ return VKEY_5;
+ case XK_6:
+ return VKEY_6;
+ case XK_7:
+ return VKEY_7;
+ case XK_8:
+ return VKEY_8;
+ case XK_9:
+ return VKEY_9;
+
+ case XK_multiply:
+ case XK_KP_Multiply:
+ return VKEY_MULTIPLY;
+ case XK_KP_Add:
+ return VKEY_ADD;
+ case XK_KP_Separator:
+ return VKEY_SEPARATOR;
+ case XK_KP_Subtract:
+ return VKEY_SUBTRACT;
+ case XK_KP_Decimal:
+ return VKEY_DECIMAL;
+ case XK_KP_Divide:
+ return VKEY_DIVIDE;
+ case XK_equal:
+ case XK_plus:
+ return VKEY_OEM_PLUS;
+ case XK_comma:
+ case XK_less:
+ return VKEY_OEM_COMMA;
+ case XK_minus:
+ case XK_underscore:
+ return VKEY_OEM_MINUS;
+ case XK_greater:
+ case XK_period:
+ return VKEY_OEM_PERIOD;
+ case XK_colon:
+ case XK_semicolon:
+ return VKEY_OEM_1;
+ case XK_question:
+ case XK_slash:
+ return VKEY_OEM_2;
+ case XK_asciitilde:
+ case XK_quoteleft:
+ return VKEY_OEM_3;
+ case XK_bracketleft:
+ case XK_braceleft:
+ return VKEY_OEM_4;
+ case XK_backslash:
+ case XK_bar:
+ return VKEY_OEM_5;
+ case XK_bracketright:
+ case XK_braceright:
+ return VKEY_OEM_6;
+ case XK_quoteright:
+ case XK_quotedbl:
+ return VKEY_OEM_7;
+ case XK_Shift_L:
+ case XK_Shift_R:
+ return VKEY_SHIFT;
+ case XK_Control_L:
+ case XK_Control_R:
+ return VKEY_CONTROL;
+ case XK_Alt_L:
+ case XK_Alt_R:
+ return VKEY_MENU;
+ case XK_Pause:
+ return VKEY_PAUSE;
+ case XK_Caps_Lock:
+ return VKEY_CAPITAL;
+ case XK_Num_Lock:
+ return VKEY_NUMLOCK;
+ case XK_Scroll_Lock:
+ return VKEY_SCROLL;
+ case XK_Select:
+ return VKEY_SELECT;
+ case XK_Print:
+ return VKEY_PRINT;
+ case XK_Execute:
+ return VKEY_EXECUTE;
+ case XK_Insert:
+ case XK_KP_Insert:
+ return VKEY_INSERT;
+ case XK_Help:
+ return VKEY_HELP;
+ case XK_Meta_L:
+ case XK_Super_L:
+ return VKEY_LWIN;
+ case XK_Meta_R:
+ case XK_Super_R:
+ return VKEY_RWIN;
+ case XK_Menu:
+ return VKEY_APPS;
+ case XK_F1:
+ case XK_F2:
+ case XK_F3:
+ case XK_F4:
+ case XK_F5:
+ case XK_F6:
+ case XK_F7:
+ case XK_F8:
+ case XK_F9:
+ case XK_F10:
+ case XK_F11:
+ case XK_F12:
+ case XK_F13:
+ case XK_F14:
+ case XK_F15:
+ case XK_F16:
+ case XK_F17:
+ case XK_F18:
+ case XK_F19:
+ case XK_F20:
+ case XK_F21:
+ case XK_F22:
+ case XK_F23:
+ case XK_F24:
+ return static_cast<KeyboardCode>(VKEY_F1 + (keysym - XK_F1));
+
+ // TODO(sad): some keycodes are still missing.
+ }
+
+ DLOG(WARNING) << "Unknown keycode: " << keysym;
+ return VKEY_UNKNOWN;
+}
+
+} // namespace ui
diff --git a/ui/base/keycodes/keyboard_code_conversion_x.h b/ui/base/keycodes/keyboard_code_conversion_x.h
new file mode 100644
index 0000000..3f780a2
--- /dev/null
+++ b/ui/base/keycodes/keyboard_code_conversion_x.h
@@ -0,0 +1,18 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_BASE_KEYCODES_KEYBOARD_CODE_CONVERSION_X_H_
+#define UI_BASE_KEYCODES_KEYBOARD_CODE_CONVERSION_X_H_
+
+#include "ui/base/keycodes/keyboard_codes_posix.h"
+
+typedef union _XEvent XEvent;
+
+namespace ui {
+
+KeyboardCode KeyboardCodeFromXKeyEvent(XEvent* xev);
+
+} // namespace ui
+
+#endif // UI_BASE_KEYCODES_KEYBOARD_CODE_CONVERSION_X_H_
diff --git a/ui/base/keycodes/keyboard_codes.h b/ui/base/keycodes/keyboard_codes.h
new file mode 100644
index 0000000..53cf8ff
--- /dev/null
+++ b/ui/base/keycodes/keyboard_codes.h
@@ -0,0 +1,17 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_BASE_KEYCODES_KEYBOARD_CODES_H_
+#define UI_BASE_KEYCODES_KEYBOARD_CODES_H_
+#pragma once
+
+#include "build/build_config.h"
+
+#if defined(OS_WIN)
+#include "ui/base/keycodes/keyboard_codes_win.h"
+#elif defined(OS_POSIX)
+#include "ui/base/keycodes/keyboard_codes_posix.h"
+#endif
+
+#endif // UI_BASE_KEYCODES_KEYBOARD_CODES_H_
diff --git a/ui/base/keycodes/keyboard_codes_posix.h b/ui/base/keycodes/keyboard_codes_posix.h
new file mode 100644
index 0000000..023701e
--- /dev/null
+++ b/ui/base/keycodes/keyboard_codes_posix.h
@@ -0,0 +1,210 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/*
+ * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com. All rights reserved.
+ * Copyright (C) 2008, 2009 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF USE, DATA, OR
+ * PROFITS, OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef UI_BASE_KEYCODES_KEYBOARD_CODES_POSIX_H_
+#define UI_BASE_KEYCODES_KEYBOARD_CODES_POSIX_H_
+#pragma once
+
+namespace ui {
+
+typedef enum {
+ VKEY_BACK = 0x08,
+ VKEY_TAB = 0x09,
+ VKEY_CLEAR = 0x0C,
+ VKEY_RETURN = 0x0D,
+ VKEY_SHIFT = 0x10,
+ VKEY_CONTROL = 0x11,
+ VKEY_MENU = 0x12,
+ VKEY_PAUSE = 0x13,
+ VKEY_CAPITAL = 0x14,
+ VKEY_KANA = 0x15,
+ VKEY_HANGUL = 0x15,
+ VKEY_JUNJA = 0x17,
+ VKEY_FINAL = 0x18,
+ VKEY_HANJA = 0x19,
+ VKEY_KANJI = 0x19,
+ VKEY_ESCAPE = 0x1B,
+ VKEY_CONVERT = 0x1C,
+ VKEY_NONCONVERT = 0x1D,
+ VKEY_ACCEPT = 0x1E,
+ VKEY_MODECHANGE = 0x1F,
+ VKEY_SPACE = 0x20,
+ VKEY_PRIOR = 0x21,
+ VKEY_NEXT = 0x22,
+ VKEY_END = 0x23,
+ VKEY_HOME = 0x24,
+ VKEY_LEFT = 0x25,
+ VKEY_UP = 0x26,
+ VKEY_RIGHT = 0x27,
+ VKEY_DOWN = 0x28,
+ VKEY_SELECT = 0x29,
+ VKEY_PRINT = 0x2A,
+ VKEY_EXECUTE = 0x2B,
+ VKEY_SNAPSHOT = 0x2C,
+ VKEY_INSERT = 0x2D,
+ VKEY_DELETE = 0x2E,
+ VKEY_HELP = 0x2F,
+ VKEY_0 = 0x30,
+ VKEY_1 = 0x31,
+ VKEY_2 = 0x32,
+ VKEY_3 = 0x33,
+ VKEY_4 = 0x34,
+ VKEY_5 = 0x35,
+ VKEY_6 = 0x36,
+ VKEY_7 = 0x37,
+ VKEY_8 = 0x38,
+ VKEY_9 = 0x39,
+ VKEY_A = 0x41,
+ VKEY_B = 0x42,
+ VKEY_C = 0x43,
+ VKEY_D = 0x44,
+ VKEY_E = 0x45,
+ VKEY_F = 0x46,
+ VKEY_G = 0x47,
+ VKEY_H = 0x48,
+ VKEY_I = 0x49,
+ VKEY_J = 0x4A,
+ VKEY_K = 0x4B,
+ VKEY_L = 0x4C,
+ VKEY_M = 0x4D,
+ VKEY_N = 0x4E,
+ VKEY_O = 0x4F,
+ VKEY_P = 0x50,
+ VKEY_Q = 0x51,
+ VKEY_R = 0x52,
+ VKEY_S = 0x53,
+ VKEY_T = 0x54,
+ VKEY_U = 0x55,
+ VKEY_V = 0x56,
+ VKEY_W = 0x57,
+ VKEY_X = 0x58,
+ VKEY_Y = 0x59,
+ VKEY_Z = 0x5A,
+ VKEY_LWIN = 0x5B,
+ VKEY_COMMAND = VKEY_LWIN, // Provide the Mac name for convenience.
+ VKEY_RWIN = 0x5C,
+ VKEY_APPS = 0x5D,
+ VKEY_SLEEP = 0x5F,
+ VKEY_NUMPAD0 = 0x60,
+ VKEY_NUMPAD1 = 0x61,
+ VKEY_NUMPAD2 = 0x62,
+ VKEY_NUMPAD3 = 0x63,
+ VKEY_NUMPAD4 = 0x64,
+ VKEY_NUMPAD5 = 0x65,
+ VKEY_NUMPAD6 = 0x66,
+ VKEY_NUMPAD7 = 0x67,
+ VKEY_NUMPAD8 = 0x68,
+ VKEY_NUMPAD9 = 0x69,
+ VKEY_MULTIPLY = 0x6A,
+ VKEY_ADD = 0x6B,
+ VKEY_SEPARATOR = 0x6C,
+ VKEY_SUBTRACT = 0x6D,
+ VKEY_DECIMAL = 0x6E,
+ VKEY_DIVIDE = 0x6F,
+ VKEY_F1 = 0x70,
+ VKEY_F2 = 0x71,
+ VKEY_F3 = 0x72,
+ VKEY_F4 = 0x73,
+ VKEY_F5 = 0x74,
+ VKEY_F6 = 0x75,
+ VKEY_F7 = 0x76,
+ VKEY_F8 = 0x77,
+ VKEY_F9 = 0x78,
+ VKEY_F10 = 0x79,
+ VKEY_F11 = 0x7A,
+ VKEY_F12 = 0x7B,
+ VKEY_F13 = 0x7C,
+ VKEY_F14 = 0x7D,
+ VKEY_F15 = 0x7E,
+ VKEY_F16 = 0x7F,
+ VKEY_F17 = 0x80,
+ VKEY_F18 = 0x81,
+ VKEY_F19 = 0x82,
+ VKEY_F20 = 0x83,
+ VKEY_F21 = 0x84,
+ VKEY_F22 = 0x85,
+ VKEY_F23 = 0x86,
+ VKEY_F24 = 0x87,
+ VKEY_NUMLOCK = 0x90,
+ VKEY_SCROLL = 0x91,
+ VKEY_LSHIFT = 0xA0,
+ VKEY_RSHIFT = 0xA1,
+ VKEY_LCONTROL = 0xA2,
+ VKEY_RCONTROL = 0xA3,
+ VKEY_LMENU = 0xA4,
+ VKEY_RMENU = 0xA5,
+ VKEY_BROWSER_BACK = 0xA6,
+ VKEY_BROWSER_FORWARD = 0xA7,
+ VKEY_BROWSER_REFRESH = 0xA8,
+ VKEY_BROWSER_STOP = 0xA9,
+ VKEY_BROWSER_SEARCH = 0xAA,
+ VKEY_BROWSER_FAVORITES = 0xAB,
+ VKEY_BROWSER_HOME = 0xAC,
+ VKEY_VOLUME_MUTE = 0xAD,
+ VKEY_VOLUME_DOWN = 0xAE,
+ VKEY_VOLUME_UP = 0xAF,
+ VKEY_MEDIA_NEXT_TRACK = 0xB0,
+ VKEY_MEDIA_PREV_TRACK = 0xB1,
+ VKEY_MEDIA_STOP = 0xB2,
+ VKEY_MEDIA_PLAY_PAUSE = 0xB3,
+ VKEY_MEDIA_LAUNCH_MAIL = 0xB4,
+ VKEY_MEDIA_LAUNCH_MEDIA_SELECT = 0xB5,
+ VKEY_MEDIA_LAUNCH_APP1 = 0xB6,
+ VKEY_MEDIA_LAUNCH_APP2 = 0xB7,
+ VKEY_OEM_1 = 0xBA,
+ VKEY_OEM_PLUS = 0xBB,
+ VKEY_OEM_COMMA = 0xBC,
+ VKEY_OEM_MINUS = 0xBD,
+ VKEY_OEM_PERIOD = 0xBE,
+ VKEY_OEM_2 = 0xBF,
+ VKEY_OEM_3 = 0xC0,
+ VKEY_OEM_4 = 0xDB,
+ VKEY_OEM_5 = 0xDC,
+ VKEY_OEM_6 = 0xDD,
+ VKEY_OEM_7 = 0xDE,
+ VKEY_OEM_8 = 0xDF,
+ VKEY_OEM_102 = 0xE2,
+ VKEY_PROCESSKEY = 0xE5,
+ VKEY_PACKET = 0xE7,
+ VKEY_ATTN = 0xF6,
+ VKEY_CRSEL = 0xF7,
+ VKEY_EXSEL = 0xF8,
+ VKEY_EREOF = 0xF9,
+ VKEY_PLAY = 0xFA,
+ VKEY_ZOOM = 0xFB,
+ VKEY_NONAME = 0xFC,
+ VKEY_PA1 = 0xFD,
+ VKEY_OEM_CLEAR = 0xFE,
+ VKEY_UNKNOWN = 0
+} KeyboardCode;
+
+} // namespace ui
+
+#endif // UI_BASE_KEYCODES_KEYBOARD_CODES_POSIX_H_
diff --git a/ui/base/keycodes/keyboard_codes_win.h b/ui/base/keycodes/keyboard_codes_win.h
new file mode 100644
index 0000000..362fc5f
--- /dev/null
+++ b/ui/base/keycodes/keyboard_codes_win.h
@@ -0,0 +1,186 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_BASE_KEYCODES_KEYBOARD_CODES_WIN_H_
+#define UI_BASE_KEYCODES_KEYBOARD_CODES_WIN_H_
+#pragma once
+
+#include <windows.h>
+
+namespace ui {
+
+typedef enum {
+ VKEY_BACK = VK_BACK,
+ VKEY_TAB = VK_TAB,
+ VKEY_CLEAR = VK_CLEAR,
+ VKEY_RETURN = VK_RETURN,
+ VKEY_SHIFT = VK_SHIFT,
+ VKEY_CONTROL = VK_CONTROL,
+ VKEY_MENU = VK_MENU, // a.k.a. ALT
+ VKEY_PAUSE = VK_PAUSE,
+ VKEY_CAPITAL = VK_CAPITAL,
+ VKEY_KANA = VK_KANA,
+ VKEY_HANGUL = VK_HANGUL,
+ VKEY_JUNJA = VK_JUNJA,
+ VKEY_FINAL = VK_FINAL,
+ VKEY_HANJA = VK_HANJA,
+ VKEY_KANJI = VK_KANJI,
+ VKEY_ESCAPE = VK_ESCAPE,
+ VKEY_CONVERT = VK_CONVERT,
+ VKEY_NONCONVERT = VK_NONCONVERT,
+ VKEY_ACCEPT = VK_ACCEPT,
+ VKEY_MODECHANGE = VK_MODECHANGE,
+ VKEY_SPACE = VK_SPACE,
+ VKEY_PRIOR = VK_PRIOR,
+ VKEY_NEXT = VK_NEXT,
+ VKEY_END = VK_END,
+ VKEY_HOME = VK_HOME,
+ VKEY_LEFT = VK_LEFT,
+ VKEY_UP = VK_UP,
+ VKEY_RIGHT = VK_RIGHT,
+ VKEY_DOWN = VK_DOWN,
+ VKEY_SELECT = VK_SELECT,
+ VKEY_PRINT = VK_PRINT,
+ VKEY_EXECUTE = VK_EXECUTE,
+ VKEY_SNAPSHOT = VK_SNAPSHOT,
+ VKEY_INSERT = VK_INSERT,
+ VKEY_DELETE = VK_DELETE,
+ VKEY_HELP = VK_HELP,
+ VKEY_0 = '0',
+ VKEY_1 = '1',
+ VKEY_2 = '2',
+ VKEY_3 = '3',
+ VKEY_4 = '4',
+ VKEY_5 = '5',
+ VKEY_6 = '6',
+ VKEY_7 = '7',
+ VKEY_8 = '8',
+ VKEY_9 = '9',
+ VKEY_A = 'A',
+ VKEY_B = 'B',
+ VKEY_C = 'C',
+ VKEY_D = 'D',
+ VKEY_E = 'E',
+ VKEY_F = 'F',
+ VKEY_G = 'G',
+ VKEY_H = 'H',
+ VKEY_I = 'I',
+ VKEY_J = 'J',
+ VKEY_K = 'K',
+ VKEY_L = 'L',
+ VKEY_M = 'M',
+ VKEY_N = 'N',
+ VKEY_O = 'O',
+ VKEY_P = 'P',
+ VKEY_Q = 'Q',
+ VKEY_R = 'R',
+ VKEY_S = 'S',
+ VKEY_T = 'T',
+ VKEY_U = 'U',
+ VKEY_V = 'V',
+ VKEY_W = 'W',
+ VKEY_X = 'X',
+ VKEY_Y = 'Y',
+ VKEY_Z = 'Z',
+ VKEY_LWIN = VK_LWIN,
+ VKEY_COMMAND = VKEY_LWIN, // Provide the Mac name for convenience.
+ VKEY_RWIN = VK_RWIN,
+ VKEY_APPS = VK_APPS,
+ VKEY_SLEEP = VK_SLEEP,
+ VKEY_NUMPAD0 = VK_NUMPAD0,
+ VKEY_NUMPAD1 = VK_NUMPAD1,
+ VKEY_NUMPAD2 = VK_NUMPAD2,
+ VKEY_NUMPAD3 = VK_NUMPAD3,
+ VKEY_NUMPAD4 = VK_NUMPAD4,
+ VKEY_NUMPAD5 = VK_NUMPAD5,
+ VKEY_NUMPAD6 = VK_NUMPAD6,
+ VKEY_NUMPAD7 = VK_NUMPAD7,
+ VKEY_NUMPAD8 = VK_NUMPAD8,
+ VKEY_NUMPAD9 = VK_NUMPAD9,
+ VKEY_MULTIPLY = VK_MULTIPLY,
+ VKEY_ADD = VK_ADD,
+ VKEY_SEPARATOR = VK_SEPARATOR,
+ VKEY_SUBTRACT = VK_SUBTRACT,
+ VKEY_DECIMAL = VK_DECIMAL,
+ VKEY_DIVIDE = VK_DIVIDE,
+ VKEY_F1 = VK_F1,
+ VKEY_F2 = VK_F2,
+ VKEY_F3 = VK_F3,
+ VKEY_F4 = VK_F4,
+ VKEY_F5 = VK_F5,
+ VKEY_F6 = VK_F6,
+ VKEY_F7 = VK_F7,
+ VKEY_F8 = VK_F8,
+ VKEY_F9 = VK_F9,
+ VKEY_F10 = VK_F10,
+ VKEY_F11 = VK_F11,
+ VKEY_F12 = VK_F12,
+ VKEY_F13 = VK_F13,
+ VKEY_F14 = VK_F14,
+ VKEY_F15 = VK_F15,
+ VKEY_F16 = VK_F16,
+ VKEY_F17 = VK_F17,
+ VKEY_F18 = VK_F18,
+ VKEY_F19 = VK_F19,
+ VKEY_F20 = VK_F20,
+ VKEY_F21 = VK_F21,
+ VKEY_F22 = VK_F22,
+ VKEY_F23 = VK_F23,
+ VKEY_F24 = VK_F24,
+ VKEY_NUMLOCK = VK_NUMLOCK,
+ VKEY_SCROLL = VK_SCROLL,
+ VKEY_LSHIFT = VK_LSHIFT,
+ VKEY_RSHIFT = VK_RSHIFT,
+ VKEY_LCONTROL = VK_LCONTROL,
+ VKEY_RCONTROL = VK_RCONTROL,
+ VKEY_LMENU = VK_LMENU,
+ VKEY_RMENU = VK_RMENU,
+ VKEY_BROWSER_BACK = VK_BROWSER_BACK,
+ VKEY_BROWSER_FORWARD = VK_BROWSER_FORWARD,
+ VKEY_BROWSER_REFRESH = VK_BROWSER_REFRESH,
+ VKEY_BROWSER_STOP = VK_BROWSER_STOP,
+ VKEY_BROWSER_SEARCH = VK_BROWSER_SEARCH,
+ VKEY_BROWSER_FAVORITES = VK_BROWSER_FAVORITES,
+ VKEY_BROWSER_HOME = VK_BROWSER_HOME,
+ VKEY_VOLUME_MUTE = VK_VOLUME_MUTE,
+ VKEY_VOLUME_DOWN = VK_VOLUME_DOWN,
+ VKEY_VOLUME_UP = VK_VOLUME_UP,
+ VKEY_MEDIA_NEXT_TRACK = VK_MEDIA_NEXT_TRACK,
+ VKEY_MEDIA_PREV_TRACK = VK_MEDIA_PREV_TRACK,
+ VKEY_MEDIA_STOP = VK_MEDIA_STOP,
+ VKEY_MEDIA_PLAY_PAUSE = VK_MEDIA_PLAY_PAUSE,
+ VKEY_MEDIA_LAUNCH_MAIL = 0xB4,
+ VKEY_MEDIA_LAUNCH_MEDIA_SELECT = 0xB5,
+ VKEY_MEDIA_LAUNCH_APP1 = 0xB6,
+ VKEY_MEDIA_LAUNCH_APP2 = 0xB7,
+ VKEY_OEM_1 = VK_OEM_1,
+ VKEY_OEM_PLUS = VK_OEM_PLUS,
+ VKEY_OEM_COMMA = VK_OEM_COMMA,
+ VKEY_OEM_MINUS = VK_OEM_MINUS,
+ VKEY_OEM_PERIOD = VK_OEM_PERIOD,
+ VKEY_OEM_2 = VK_OEM_2,
+ VKEY_OEM_3 = VK_OEM_3,
+ VKEY_OEM_4 = VK_OEM_4,
+ VKEY_OEM_5 = VK_OEM_5,
+ VKEY_OEM_6 = VK_OEM_6,
+ VKEY_OEM_7 = VK_OEM_7,
+ VKEY_OEM_8 = VK_OEM_8,
+ VKEY_OEM_102 = VK_OEM_102,
+ VKEY_PROCESSKEY = VK_PROCESSKEY,
+ VKEY_PACKET = VK_PACKET,
+ VKEY_ATTN = VK_ATTN,
+ VKEY_CRSEL = VK_CRSEL,
+ VKEY_EXSEL = VK_EXSEL,
+ VKEY_EREOF = VK_EREOF,
+ VKEY_PLAY = VK_PLAY,
+ VKEY_ZOOM = VK_ZOOM,
+ VKEY_NONAME = VK_NONAME,
+ VKEY_PA1 = VK_PA1,
+ VKEY_OEM_CLEAR = VK_OEM_CLEAR,
+ VKEY_UNKNOWN = 0
+} KeyboardCode;
+
+} // namespace ui
+
+#endif // UI_BASE_KEYCODES_KEYBOARD_CODES_WIN_H_