Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(915)

Unified Diff: Source/core/events/KeyboardCode.h

Issue 663523002: Adding support for DOM3 KeyboardEvents Code in KeyboardEvents (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use native code instead of usb code mapping. Also updated to match firefox values. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/events/KeyboardCode.h
diff --git a/Source/core/events/KeyboardCode.h b/Source/core/events/KeyboardCode.h
new file mode 100644
index 0000000000000000000000000000000000000000..1f79295f4aa9f3f0e200de9b7cd205bbdbff7ad0
--- /dev/null
+++ b/Source/core/events/KeyboardCode.h
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2014 The Chromium Authors. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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 KeyboardCode_h
+#define KeyboardCode_h
+
+#if defined (__linux)
+#define NATIVETOCODE(linux, win, mac, code) {linux, code}
+#elif defined(_WIN32)
+#define NATIVETOCODE(linux, win, mac, code) {win, code}
+#elif defined(__APPLE__)
+#define NATIVETOCODE(linux, win, mac, code) {mac, code}
+#else
+#define NATIVETOCODE(linux, win, mac, code) {0, code}
+#endif
+
+struct NativeCodeToCodeMapEntry {
+ int nativeCode;
+ const char* code;
+};
+
+const NativeCodeToCodeMapEntry keyCodeMap[] = {
Wez 2014/10/25 00:23:02 As previously discussed, Chromium already has this
Habib Virji 2014/10/27 16:48:36 I have added a new embedder API, this file is remo
+ // 2.1.1.1 AlphaNumeric Section
+ NATIVETOCODE(0x0031, 0x0029, 0x0032, "Backquote"),
+ NATIVETOCODE(0x0033, 0x002b, 0x002a, "Backslash"),
+ NATIVETOCODE(0x0016, 0x000e, 0x0033, "Backspace"),
+ NATIVETOCODE(0x0022, 0x001a, 0x0021, "BracketLeft"),
+ NATIVETOCODE(0x0023, 0x001b, 0x001e, "BracketRight"),
+ NATIVETOCODE(0x003b, 0x0033, 0x002b, "Comma"),
+ NATIVETOCODE(0x0013, 0x000b, 0x001d, "Digit0"),
+ NATIVETOCODE(0x000a, 0x0002, 0x0012, "Digit1"),
+ NATIVETOCODE(0x000b, 0x0003, 0x0013, "Digit2"),
+ NATIVETOCODE(0x000c, 0x0004, 0x0014, "Digit3"),
+ NATIVETOCODE(0x000d, 0x0005, 0x0015, "Digit4"),
+ NATIVETOCODE(0x000e, 0x0006, 0x0017, "Digit5"),
+ NATIVETOCODE(0x000f, 0x0007, 0x0016, "Digit6"),
+ NATIVETOCODE(0x0010, 0x0008, 0x001a, "Digit7"),
+ NATIVETOCODE(0x0011, 0x0009, 0x001c, "Digit8"),
+ NATIVETOCODE(0x0012, 0x000a, 0x0019, "Digit9"),
+ NATIVETOCODE(0x0015, 0x000d, 0x0018, "Equal"),
+ NATIVETOCODE(0x005e, 0x0056, 0x000a, "IntlBackslash"),
+ NATIVETOCODE(0x0061, 0x0073, 0x005e, "IntlRo"),
+ NATIVETOCODE(0x0084, 0x007d, 0x005d, "IntlYen"),
+ NATIVETOCODE(0x0026, 0x001e, 0x0000, "KeyA"),
+ NATIVETOCODE(0x0038, 0x0030, 0x000b, "KeyB"),
+ NATIVETOCODE(0x0036, 0x002e, 0x0008, "KeyC"),
+ NATIVETOCODE(0x0028, 0x0020, 0x0002, "KeyD"),
+ NATIVETOCODE(0x001a, 0x0012, 0x000e, "KeyE"),
+ NATIVETOCODE(0x0029, 0x0021, 0x0003, "KeyF"),
+ NATIVETOCODE(0x002a, 0x0022, 0x0005, "KeyG"),
+ NATIVETOCODE(0x002b, 0x0023, 0x0004, "KeyH"),
+ NATIVETOCODE(0x001f, 0x0017, 0x0022, "KeyI"),
+ NATIVETOCODE(0x002c, 0x0024, 0x0026, "KeyJ"),
+ NATIVETOCODE(0x002d, 0x0025, 0x0028, "KeyK"),
+ NATIVETOCODE(0x002e, 0x0026, 0x0025, "KeyL"),
+ NATIVETOCODE(0x003a, 0x0032, 0x002e, "KeyM"),
+ NATIVETOCODE(0x0039, 0x0031, 0x002d, "KeyN"),
+ NATIVETOCODE(0x0020, 0x0018, 0x001f, "KeyO"),
+ NATIVETOCODE(0x0021, 0x0019, 0x0023, "KeyP"),
+ NATIVETOCODE(0x0018, 0x0010, 0x000c, "KeyQ"),
+ NATIVETOCODE(0x001b, 0x0013, 0x000f, "KeyR"),
+ NATIVETOCODE(0x0027, 0x001f, 0x0001, "KeyS"),
+ NATIVETOCODE(0x001c, 0x0014, 0x0011, "KeyT"),
+ NATIVETOCODE(0x001e, 0x0016, 0x0020, "KeyU"),
+ NATIVETOCODE(0x0037, 0x002f, 0x0009, "KeyV"),
+ NATIVETOCODE(0x0019, 0x0011, 0x000d, "KeyW"),
+ NATIVETOCODE(0x0035, 0x002d, 0x0007, "KeyX"),
+ NATIVETOCODE(0x001d, 0x0015, 0x0010, "KeyY"),
+ NATIVETOCODE(0x0034, 0x002c, 0x0006, "KeyZ"),
+ NATIVETOCODE(0x0014, 0x000c, 0x001b, "Minus"),
+ NATIVETOCODE(0x003c, 0x0034, 0x002f, "Period"),
+ NATIVETOCODE(0x0030, 0x0028, 0x0027, "Quote"),
+ NATIVETOCODE(0x002f, 0x0027, 0x0029, "Semicolon"),
+ NATIVETOCODE(0x003d, 0x0035, 0x002c, "Slash"),
+
+ // 2.1.1.2 Functional Keys
+ NATIVETOCODE(0x0040, 0x0038, 0x003a, "AltLeft"),
+ NATIVETOCODE(0x006c, 0xe038, 0x003d, "AltRight"),
+ NATIVETOCODE(0x005c, 0x0000, 0xffff, "AltRight"),
+ NATIVETOCODE(0x0042, 0x003a, 0x0039, "CapsLock"),
+ NATIVETOCODE(0x0087, 0xe05d, 0x006e, "ContextMenu"),
+ NATIVETOCODE(0x0025, 0x001d, 0x003b, "ControlLeft"),
+ NATIVETOCODE(0x0069, 0xe01d, 0x003e, "ControlRight"),
+ NATIVETOCODE(0x0024, 0x001c, 0x0024, "Enter"),
+ NATIVETOCODE(0x0085, 0xe05b, 0x0037, "OSLeft"),
+ NATIVETOCODE(0x0086, 0xe05c, 0x0036, "OSRight"),
+ NATIVETOCODE(0x0032, 0x002a, 0x0038, "ShiftLeft"),
+ NATIVETOCODE(0x003e, 0x0036, 0x003c, "ShiftRight"),
+ NATIVETOCODE(0x0041, 0x0039, 0x0031, "Space"),
+ NATIVETOCODE(0x0017, 0x000f, 0x0030, "Tab"),
+
+ // Japanese/Korean Keyboard keys
+ NATIVETOCODE(0x0064, 0x0079, 0xffff, "Convert"),
+ NATIVETOCODE(0x0065, 0x0070, 0xffff, "KanaMode"),
+ NATIVETOCODE(0x0082, 0x0072, 0xffff, "Lang1"),
+ NATIVETOCODE(0x0082, 0xe072, 0xffff, "Lang1"),
+ NATIVETOCODE(0x0083, 0x0071, 0xffff, "Lang2"),
+ NATIVETOCODE(0x0083, 0xe0f1, 0xffff, "Lang2"),
+ NATIVETOCODE(0x0066, 0x007b, 0xffff, "NoConvert"),
+
+ // 2.1.2 Control Pad
+ NATIVETOCODE(0x0077, 0xe053, 0x0075, "Delete"),
+ NATIVETOCODE(0x0073, 0xe04f, 0x0077, "End"),
+ NATIVETOCODE(0x0092, 0xe03b, 0x0072, "Help"),
+ NATIVETOCODE(0x006e, 0xe047, 0x0073, "Home"),
+ NATIVETOCODE(0x0076, 0xe052, 0xffff, "Insert"),
+ NATIVETOCODE(0x0075, 0xe051, 0x0079, "PageDown"),
+ NATIVETOCODE(0x0070, 0xe049, 0x0074, "PageUp"),
+
+ // 2.1.3 Arrow Pad
+ NATIVETOCODE(0x0074, 0xe050, 0x007d, "ArrowDown"),
+ NATIVETOCODE(0x0071, 0xe04b, 0x007b, "ArrowLeft"),
+ NATIVETOCODE(0x0072, 0xe04d, 0x007c, "ArrowRight"),
+ NATIVETOCODE(0x006f, 0xe048, 0x007e, "ArrowUp"),
+
+ // 2.1.4 Numpad
+ NATIVETOCODE(0x004d, 0x0045, 0x0047, "NumLock"),
+ NATIVETOCODE(0x005a, 0x0052, 0x0052, "Numpad0"),
+ NATIVETOCODE(0x0057, 0x004f, 0x0053, "Numpad1"),
+ NATIVETOCODE(0x0058, 0x0050, 0x0054, "Numpad2"),
+ NATIVETOCODE(0x0059, 0x0051, 0x0055, "Numpad3"),
+ NATIVETOCODE(0x0053, 0x004b, 0x0056, "Numpad4"),
+ NATIVETOCODE(0x0054, 0x004c, 0x0057, "Numpad5"),
+ NATIVETOCODE(0x0055, 0x004d, 0x0058, "Numpad6"),
+ NATIVETOCODE(0x004f, 0x0047, 0x0059, "Numpad7"),
+ NATIVETOCODE(0x0050, 0x0048, 0x005b, "Numpad8"),
+ NATIVETOCODE(0x0051, 0x0049, 0x005c, "Numpad9"),
+ NATIVETOCODE(0x0056, 0x004e, 0x0045, "NumpadAdd"),
+ NATIVETOCODE(0x0081, 0x007e, 0x005f, "NumpadComma"),
+ NATIVETOCODE(0x005b, 0x0053, 0x0041, "NumpadDecimal"),
+ NATIVETOCODE(0x006a, 0xe035, 0x004b, "NumpadDivide"),
+ NATIVETOCODE(0x0068, 0xe01c, 0x004c, "NumpadEnter"),
+ NATIVETOCODE(0x007d, 0x0059, 0x0051, "NumpadEqual"),
+ NATIVETOCODE(0x003f, 0x0037, 0x0043, "NumpadMultiply"),
+ NATIVETOCODE(0x0052, 0x004a, 0x004e, "NumpadSubtract"),
+ NATIVETOCODE(0x00bb, 0x0000, 0xffff, "NumpadParenLeft"),
+ NATIVETOCODE(0x00bc, 0x0000, 0xffff, "NumpadParenRight"),
+
+ // 2.1.5 Function Section
+ NATIVETOCODE(0x0009, 0x0001, 0x0035, "Escape"),
+ NATIVETOCODE(0x0043, 0x003b, 0x007a, "F1"),
+ NATIVETOCODE(0x0044, 0x003c, 0x0078, "F2"),
+ NATIVETOCODE(0x0045, 0x003d, 0x0063, "F3"),
+ NATIVETOCODE(0x0046, 0x003e, 0x0076, "F4"),
+ NATIVETOCODE(0x0047, 0x003f, 0x0060, "F5"),
+ NATIVETOCODE(0x0048, 0x0040, 0x0061, "F6"),
+ NATIVETOCODE(0x0049, 0x0041, 0x0062, "F7"),
+ NATIVETOCODE(0x004a, 0x0042, 0x0064, "F8"),
+ NATIVETOCODE(0x004b, 0x0043, 0x0065, "F9"),
+ NATIVETOCODE(0x004c, 0x0044, 0x006d, "F10"),
+ NATIVETOCODE(0x005f, 0x0057, 0x0067, "F11"),
+ NATIVETOCODE(0x0060, 0x0058, 0x006f, "F12"),
+ NATIVETOCODE(0x006b, 0xe037, 0xffff, "PrintScreen"),
+ NATIVETOCODE(0x006b, 0x0054, 0xffff, "PrintScreen"),
+ NATIVETOCODE(0x004e, 0x0046, 0xffff, "ScrollLock"),
+ NATIVETOCODE(0x007f, 0x0045, 0xffff, "Pause"),
+ NATIVETOCODE(0x007f, 0xe046, 0xffff, "Pause"),
+
+ // 2.1.6 Media Keys
+ NATIVETOCODE(0x00a6, 0xe06a, 0xffff, "BrowserBack"),
+ NATIVETOCODE(0x00a4, 0xe066, 0xffff, "BrowserFavorites"),
+ NATIVETOCODE(0x00a7, 0xe069, 0xffff, "BrowserForward"),
+ NATIVETOCODE(0x00b4, 0xe032, 0xffff, "BrowserHome"),
+ NATIVETOCODE(0x00b5, 0xe067, 0xffff, "BrowserRefresh"),
+ NATIVETOCODE(0x00e1, 0xe065, 0xffff, "BrowserSearch"),
+ NATIVETOCODE(0x0088, 0xe068, 0xffff, "BrowserStop"),
+ NATIVETOCODE(0x00a9, 0xe02c, 0xffff, "Eject"),
+ NATIVETOCODE(0x0098, 0xe06B, 0xffff, "LaunchApp1"),
+ NATIVETOCODE(0x0094, 0xe021, 0xffff, "LaunchApp2"),
+ NATIVETOCODE(0x00a3, 0xe06c, 0xffff, "LaunchMail"),
+ NATIVETOCODE(0x00ac, 0xe022, 0xffff, "MediaPlayPause"),
+ NATIVETOCODE(0x00B3, 0xE06D, 0xffff, "MediaSelect"),
+ NATIVETOCODE(0x00ae, 0xe024, 0xffff, "MediaStop"),
+ NATIVETOCODE(0x00ab, 0xe019, 0xffff, "MediaTrackNext"),
+ NATIVETOCODE(0x00ad, 0xe010, 0xffff, "MediaTrackPrevious"),
+ NATIVETOCODE(0x007c, 0xe05e, 0x007f, "Power"),
+ NATIVETOCODE(0x0096, 0x0000, 0xffff, "Sleep"),
+ NATIVETOCODE(0x007a, 0xe02e, 0x0049, "VolumeDown"),
+ NATIVETOCODE(0x0079, 0xe020, 0x004a, "VolumeMute"),
+ NATIVETOCODE(0x007b, 0xe030, 0x0048, "VolumeUp"),
+ NATIVETOCODE(0x0097, 0x0000, 0xffff, "WakeUp"),
+};
+
+#endif /* KeyboardCode_h */

Powered by Google App Engine
This is Rietveld 408576698