Commit f44179f9 authored by kpschoedel's avatar kpschoedel Committed by Commit bot

Revise DOM Level 3 US Layout maps.

Changes to more closely match GetCharacterFromKeyCode().

BUG=44048

Review URL: https://codereview.chromium.org/1108893002

Cr-Commit-Position: refs/heads/master@{#329897}
parent 22a6783c
...@@ -108,13 +108,7 @@ int KeycodeConverter::CodeToNativeKeycode(const char* code) { ...@@ -108,13 +108,7 @@ int KeycodeConverter::CodeToNativeKeycode(const char* code) {
// static // static
int KeycodeConverter::DomCodeToNativeKeycode(DomCode code) { int KeycodeConverter::DomCodeToNativeKeycode(DomCode code) {
if (code == DomCode::NONE) return UsbKeycodeToNativeKeycode(static_cast<uint32_t>(code));
return InvalidNativeKeycode();
for (size_t i = 0; i < kKeycodeMapEntries; ++i) {
if (usb_keycode_map[i].usb_keycode == static_cast<uint32_t>(code))
return usb_keycode_map[i].native_keycode;
}
return InvalidNativeKeycode();
} }
// static // static
......
...@@ -117,10 +117,12 @@ USB_KEYMAP_DECLARATION { ...@@ -117,10 +117,12 @@ USB_KEYMAP_DECLARATION {
USB_KEYMAP(0x070031, 0x0033, 0x002b, 0x002a, "Backslash", BACKSLASH), // \| USB_KEYMAP(0x070031, 0x0033, 0x002b, 0x002a, "Backslash", BACKSLASH), // \|
// USB#070032 never appears on keyboards that have USB#070031. // USB#070032 never appears on keyboards that have USB#070031.
// Platforms use the same scancode as for the two keys. // Platforms use the same scancode as for the two keys.
// Hence this code can only be generated synthetically
// (e.g. in a DOM Level 3 KeyboardEvent).
// The keycap varies on international keyboards: // The keycap varies on international keyboards:
// Dan: '* Dutch: <> Ger: #' UK: #~ // Dan: '* Dutch: <> Ger: #' UK: #~
// TODO(garykac): Verify Mac intl keyboard. // TODO(garykac): Verify Mac intl keyboard.
//USB_KEYMAP(0x070032, 0x0033, 0x002b, 0x002a, "IntlHash", INTL_HASH), USB_KEYMAP(0x070032, 0x0000, 0x0000, 0xffff, "IntlHash", INTL_HASH),
USB_KEYMAP(0x070033, 0x002f, 0x0027, 0x0029, "Semicolon", SEMICOLON), // ;: USB_KEYMAP(0x070033, 0x002f, 0x0027, 0x0029, "Semicolon", SEMICOLON), // ;:
USB_KEYMAP(0x070034, 0x0030, 0x0028, 0x0027, "Quote", QUOTE), // '" USB_KEYMAP(0x070034, 0x0030, 0x0028, 0x0027, "Quote", QUOTE), // '"
USB_KEYMAP(0x070035, 0x0031, 0x0029, 0x0032, "Backquote", BACKQUOTE), // `~ USB_KEYMAP(0x070035, 0x0031, 0x0029, 0x0032, "Backquote", BACKQUOTE), // `~
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
namespace ui { namespace ui {
// This table maps a DomCode to a printable character, assuming US layout. // This table maps a DomCode to a printable character, assuming US layout.
// It is used by DomCodeToUsLayoutMeaning(), which provides a fallback
// interpretation when there is no other way to map a physical key.
const struct PrintableCodeEntry { const struct PrintableCodeEntry {
DomCode dom_code; DomCode dom_code;
base::char16 character[2]; // normal, shift base::char16 character[2]; // normal, shift
...@@ -60,7 +62,8 @@ const struct PrintableCodeEntry { ...@@ -60,7 +62,8 @@ const struct PrintableCodeEntry {
{DomCode::COMMA, {',', '<'}}, {DomCode::COMMA, {',', '<'}},
{DomCode::PERIOD, {'.', '>'}}, {DomCode::PERIOD, {'.', '>'}},
{DomCode::SLASH, {'/', '?'}}, {DomCode::SLASH, {'/', '?'}},
{DomCode::INTL_BACKSLASH, {'\\', '|'}}, {DomCode::INTL_BACKSLASH, {'<', '>'}},
{DomCode::INTL_HASH, {'\\', '|'}},
{DomCode::INTL_YEN, {0x00A5, '|'}}, {DomCode::INTL_YEN, {0x00A5, '|'}},
{DomCode::NUMPAD_DIVIDE, {'/', '/'}}, {DomCode::NUMPAD_DIVIDE, {'/', '/'}},
{DomCode::NUMPAD_MULTIPLY, {'*', '*'}}, {DomCode::NUMPAD_MULTIPLY, {'*', '*'}},
...@@ -85,6 +88,8 @@ const struct PrintableCodeEntry { ...@@ -85,6 +88,8 @@ const struct PrintableCodeEntry {
}; };
// This table maps a DomCode to a DomKey, assuming US keyboard layout. // This table maps a DomCode to a DomKey, assuming US keyboard layout.
// It is used by DomCodeToUsLayoutMeaning(), which provides a fallback
// interpretation when there is no other way to map a physical key.
const struct NonPrintableCodeEntry { const struct NonPrintableCodeEntry {
DomCode dom_code; DomCode dom_code;
DomKey dom_key; DomKey dom_key;
...@@ -427,7 +432,7 @@ const struct DomCodeToKeyboardCodeEntry { ...@@ -427,7 +432,7 @@ const struct DomCodeToKeyboardCodeEntry {
{DomCode::BRACKET_LEFT, VKEY_OEM_4}, // 0x07002F BracketLeft {DomCode::BRACKET_LEFT, VKEY_OEM_4}, // 0x07002F BracketLeft
{DomCode::BRACKET_RIGHT, VKEY_OEM_6}, // 0x070030 BracketRight {DomCode::BRACKET_RIGHT, VKEY_OEM_6}, // 0x070030 BracketRight
{DomCode::BACKSLASH, VKEY_OEM_5}, // 0x070031 Backslash {DomCode::BACKSLASH, VKEY_OEM_5}, // 0x070031 Backslash
// DomCode::INTL_HASH, VKEY_OEM_5 // 0x070032 IntlHash {DomCode::INTL_HASH, VKEY_OEM_5}, // 0x070032 IntlHash
{DomCode::SEMICOLON, VKEY_OEM_1}, // 0x070033 Semicolon {DomCode::SEMICOLON, VKEY_OEM_1}, // 0x070033 Semicolon
{DomCode::QUOTE, VKEY_OEM_7}, // 0x070034 Quote {DomCode::QUOTE, VKEY_OEM_7}, // 0x070034 Quote
{DomCode::BACKQUOTE, VKEY_OEM_3}, // 0x070035 Backquote {DomCode::BACKQUOTE, VKEY_OEM_3}, // 0x070035 Backquote
...@@ -580,7 +585,6 @@ const struct DomCodeToKeyboardCodeEntry { ...@@ -580,7 +585,6 @@ const struct DomCodeToKeyboardCodeEntry {
const DomCodeToKeyboardCodeEntry kFallbackKeyboardCodeToDomCodeMap[] = { const DomCodeToKeyboardCodeEntry kFallbackKeyboardCodeToDomCodeMap[] = {
{DomCode::ALT_LEFT, VKEY_MENU}, {DomCode::ALT_LEFT, VKEY_MENU},
{DomCode::ALT_RIGHT, VKEY_ALTGR}, {DomCode::ALT_RIGHT, VKEY_ALTGR},
{DomCode::BACKQUOTE, VKEY_DBE_SBCSCHAR},
#if defined(OS_POSIX) #if defined(OS_POSIX)
{DomCode::CONTEXT_MENU, VKEY_COMPOSE}, {DomCode::CONTEXT_MENU, VKEY_COMPOSE},
#endif #endif
...@@ -589,34 +593,37 @@ const DomCodeToKeyboardCodeEntry kFallbackKeyboardCodeToDomCodeMap[] = { ...@@ -589,34 +593,37 @@ const DomCodeToKeyboardCodeEntry kFallbackKeyboardCodeToDomCodeMap[] = {
{DomCode::LANG2, VKEY_HANJA}, {DomCode::LANG2, VKEY_HANJA},
{DomCode::LANG5, VKEY_DBE_DBCSCHAR}, {DomCode::LANG5, VKEY_DBE_DBCSCHAR},
{DomCode::NUMPAD_CLEAR, VKEY_OEM_CLEAR}, {DomCode::NUMPAD_CLEAR, VKEY_OEM_CLEAR},
{DomCode::NUMPAD_DECIMAL, VKEY_SEPARATOR},
{DomCode::PROPS, VKEY_CRSEL}, {DomCode::PROPS, VKEY_CRSEL},
{DomCode::SHIFT_LEFT, VKEY_SHIFT}, {DomCode::SHIFT_LEFT, VKEY_SHIFT},
{DomCode::SUPER, VKEY_OEM_8}, {DomCode::SUPER, VKEY_OEM_8},
// //
// VKEYs with no existing corresponding DomCode, but a USB usage code: // VKEYs with no directly corresponding DomCode, but a USB usage code:
// {DomCode::SYS_REQ, VKEY_ATTN}, // 0x07009A SysReq // VKEY_ATTN // 0x07009A SysReq
// {DomCode::SEPARATOR, VKEY_SEPARATOR}, // 0x07009F Separator // VKEY_SEPARATOR // 0x07009F Separator
// {DomCode::EX_SEL, VKEY_EXSEL}, // 0x0700A4 ExSel // VKEY_EXSEL // 0x0700A4 ExSel
// {DomCode::PRINT, VKEY_PRINT}, // 0x0C0208 AC Print // VKEY_PRINT // 0x0C0208 AC Print
// {DomCode::MEDIA_PLAY, VKEY_PLAY}, // 0x0C00B0 MediaPlay // VKEY_PLAY // 0x0C00B0 MediaPlay
// {DomCode::MEDIA_REWIND, VKEY_OEM_103}, // 0x0C00B4 MediaRewind // VKEY_OEM_103 // 0x0C00B4 MediaRewind
// {DomCode::MEDIA_FAST_FORWARD, VKEY_OEM_104}, // VKEY_OEM_104 // 0x0C00B3 MediaFastForward
// // 0x0C00B3 MediaFastForward //
// VKEYs with no corresponding DomCode, but a Linux evdev usage code:
// VKEY_KBD_BRIGHTNESS_DOWN // evdev KEY_KBDILLUMDOWN
// VKEY_KBD_BRIGHTNESS_UP // evdev KEY_KBDILLUMUP
// VKEY_WLAN // evdev KEY_WLAN
// //
// VKEYs with no corresponding DomCode and no obvious USB usage code: // VKEYs with no corresponding DomCode and no obvious USB usage code:
// VKEY_ACCEPT // VKEY_ACCEPT
// VKEY_BACKTAB // VKEY_BACKTAB
// VKEY_DBE_SBCSCHAR
// VKEY_EREOF // VKEY_EREOF
// VKEY_FINAL // VKEY_FINAL
// VKEY_JUNJA // VKEY_JUNJA
// VKEY_KBD_BRIGHTNESS_DOWN
// VKEY_KBD_BRIGHTNESS_UP
// VKEY_MODECHANGE // VKEY_MODECHANGE
// VKEY_NONAME // VKEY_NONAME
// VKEY_PA1 // VKEY_PA1
// VKEY_PACKET // VKEY_PACKET
// VKEY_PROCESSKEY // VKEY_PROCESSKEY
// VKEY_WLAN
}; };
} // namespace ui } // namespace ui
......
...@@ -441,8 +441,8 @@ TEST(KeyboardCodeConversion, UsLayout) { ...@@ -441,8 +441,8 @@ TEST(KeyboardCodeConversion, UsLayout) {
{true, ui::DomKey::CHARACTER, '/', ui::VKEY_OEM_2}, {true, ui::DomKey::CHARACTER, '/', ui::VKEY_OEM_2},
{true, ui::DomKey::CHARACTER, '?', ui::VKEY_OEM_2}}, {true, ui::DomKey::CHARACTER, '?', ui::VKEY_OEM_2}},
{ui::DomCode::INTL_BACKSLASH, {ui::DomCode::INTL_BACKSLASH,
{true, ui::DomKey::CHARACTER, '\\', ui::VKEY_OEM_102}, {true, ui::DomKey::CHARACTER, '<', ui::VKEY_OEM_102},
{true, ui::DomKey::CHARACTER, '|', ui::VKEY_OEM_102}}, {true, ui::DomKey::CHARACTER, '>', ui::VKEY_OEM_102}},
{ui::DomCode::INTL_YEN, {ui::DomCode::INTL_YEN,
{true, ui::DomKey::CHARACTER, 0x00A5, ui::VKEY_OEM_5}, {true, ui::DomKey::CHARACTER, 0x00A5, ui::VKEY_OEM_5},
{true, ui::DomKey::CHARACTER, '|', ui::VKEY_OEM_5}}, {true, ui::DomKey::CHARACTER, '|', ui::VKEY_OEM_5}},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment