| Index: ui/events/keycodes/dom4/keycode_converter.cc
|
| diff --git a/ui/events/keycodes/dom4/keycode_converter.cc b/ui/events/keycodes/dom4/keycode_converter.cc
|
| index 63689f0e5467e41c7536f05cc80d279435746bb7..8ccce108966d6a8383af010c981d34a895228b42 100644
|
| --- a/ui/events/keycodes/dom4/keycode_converter.cc
|
| +++ b/ui/events/keycodes/dom4/keycode_converter.cc
|
| @@ -4,6 +4,11 @@
|
|
|
| #include "ui/events/keycodes/dom4/keycode_converter.h"
|
|
|
| +#include <algorithm>
|
| +
|
| +#include "ui/events/keycodes/dom3/dom_code.h"
|
| +#include "ui/events/keycodes/dom3/dom_key.h"
|
| +
|
| namespace ui {
|
|
|
| namespace {
|
| @@ -21,6 +26,470 @@ namespace {
|
|
|
| const size_t kKeycodeMapEntries = arraysize(usb_keycode_map);
|
|
|
| +// Mappings from string to enumeration value for DOM |code| and |key|.
|
| +template <typename T>
|
| +struct DomKeyCodeEntry {
|
| + const char* string;
|
| + T enumeration;
|
| +
|
| + // Table search operations.
|
| + static bool CompareStrings(const DomKeyCodeEntry<T>& a,
|
| + const DomKeyCodeEntry<T>& b) {
|
| + if (!a.string)
|
| + return false;
|
| + if (!b.string)
|
| + return true;
|
| + return strcmp(a.string, b.string) < 0;
|
| + }
|
| + static T Map(const DomKeyCodeEntry<T>* begin,
|
| + const DomKeyCodeEntry<T>* end,
|
| + const char* s) {
|
| + if (s) {
|
| + const DomKeyCodeEntry<T> key = {s, T::NONE};
|
| + const DomKeyCodeEntry<T>* found =
|
| + std::lower_bound(begin, end, key, CompareStrings);
|
| + if (found && found->string && strcmp(found->string, s) == 0)
|
| + return found->enumeration;
|
| + }
|
| + return T::NONE;
|
| + }
|
| +};
|
| +
|
| +const DomKeyCodeEntry<DomCode> dom_code_by_string[] = {
|
| + // This table is in ASCII order, which can be maintained by 'LANG=C sort'.
|
| + {"", DomCode::NONE},
|
| + {"Abort", DomCode::ABORT},
|
| + {"Again", DomCode::AGAIN},
|
| + {"AltLeft", DomCode::ALT_LEFT},
|
| + {"AltRight", DomCode::ALT_RIGHT},
|
| + {"ArrowDown", DomCode::ARROW_DOWN},
|
| + {"ArrowLeft", DomCode::ARROW_LEFT},
|
| + {"ArrowRight", DomCode::ARROW_RIGHT},
|
| + {"ArrowUp", DomCode::ARROW_UP},
|
| + {"Backquote", DomCode::BACKQUOTE},
|
| + {"Backslash", DomCode::BACKSLASH},
|
| + {"Backspace", DomCode::BACKSPACE},
|
| + {"BracketLeft", DomCode::BRACKET_LEFT},
|
| + {"BracketRight", DomCode::BRACKET_RIGHT},
|
| + {"BrowserBack", DomCode::BROWSER_BACK},
|
| + {"BrowserFavorites", DomCode::BROWSER_FAVORITES},
|
| + {"BrowserForward", DomCode::BROWSER_FORWARD},
|
| + {"BrowserHome", DomCode::BROWSER_HOME},
|
| + {"BrowserRefresh", DomCode::BROWSER_REFRESH},
|
| + {"BrowserSearch", DomCode::BROWSER_SEARCH},
|
| + {"BrowserStop", DomCode::BROWSER_STOP},
|
| + {"CapsLock", DomCode::CAPS_LOCK},
|
| + {"Comma", DomCode::COMMA},
|
| + {"ContextMenu", DomCode::CONTEXT_MENU},
|
| + {"ControlLeft", DomCode::CONTROL_LEFT},
|
| + {"ControlRight", DomCode::CONTROL_RIGHT},
|
| + {"Convert", DomCode::CONVERT},
|
| + {"Copy", DomCode::COPY},
|
| + {"Cut", DomCode::CUT},
|
| + {"Delete", DomCode::DELETE},
|
| + {"Digit0", DomCode::DIGIT0},
|
| + {"Digit1", DomCode::DIGIT1},
|
| + {"Digit2", DomCode::DIGIT2},
|
| + {"Digit3", DomCode::DIGIT3},
|
| + {"Digit4", DomCode::DIGIT4},
|
| + {"Digit5", DomCode::DIGIT5},
|
| + {"Digit6", DomCode::DIGIT6},
|
| + {"Digit7", DomCode::DIGIT7},
|
| + {"Digit8", DomCode::DIGIT8},
|
| + {"Digit9", DomCode::DIGIT9},
|
| + {"Eject", DomCode::EJECT},
|
| + {"End", DomCode::END},
|
| + {"Enter", DomCode::ENTER},
|
| + {"Equal", DomCode::EQUAL},
|
| + {"Escape", DomCode::ESCAPE},
|
| + {"F1", DomCode::F1},
|
| + {"F10", DomCode::F10},
|
| + {"F11", DomCode::F11},
|
| + {"F12", DomCode::F12},
|
| + {"F13", DomCode::F13},
|
| + {"F14", DomCode::F14},
|
| + {"F15", DomCode::F15},
|
| + {"F16", DomCode::F16},
|
| + {"F17", DomCode::F17},
|
| + {"F18", DomCode::F18},
|
| + {"F19", DomCode::F19},
|
| + {"F2", DomCode::F2},
|
| + {"F20", DomCode::F20},
|
| + {"F21", DomCode::F21},
|
| + {"F22", DomCode::F22},
|
| + {"F23", DomCode::F23},
|
| + {"F24", DomCode::F24},
|
| + {"F3", DomCode::F3},
|
| + {"F4", DomCode::F4},
|
| + {"F5", DomCode::F5},
|
| + {"F6", DomCode::F6},
|
| + {"F7", DomCode::F7},
|
| + {"F8", DomCode::F8},
|
| + {"F9", DomCode::F9},
|
| + {"FLock", DomCode::FN_LOCK},
|
| + {"Find", DomCode::FIND},
|
| + {"Fn", DomCode::FN},
|
| + {"Help", DomCode::HELP},
|
| + {"Home", DomCode::HOME},
|
| + {"Hyper", DomCode::HYPER},
|
| + {"Insert", DomCode::INSERT},
|
| + {"IntlBackslash", DomCode::INTL_BACKSLASH},
|
| + {"IntlHash", DomCode::INTL_HASH},
|
| + {"IntlRo", DomCode::INTL_RO},
|
| + {"IntlYen", DomCode::INTL_YEN},
|
| + {"KanaMode", DomCode::KANA_MODE},
|
| + {"KeyA", DomCode::KEY_A},
|
| + {"KeyB", DomCode::KEY_B},
|
| + {"KeyC", DomCode::KEY_C},
|
| + {"KeyD", DomCode::KEY_D},
|
| + {"KeyE", DomCode::KEY_E},
|
| + {"KeyF", DomCode::KEY_F},
|
| + {"KeyG", DomCode::KEY_G},
|
| + {"KeyH", DomCode::KEY_H},
|
| + {"KeyI", DomCode::KEY_I},
|
| + {"KeyJ", DomCode::KEY_J},
|
| + {"KeyK", DomCode::KEY_K},
|
| + {"KeyL", DomCode::KEY_L},
|
| + {"KeyM", DomCode::KEY_M},
|
| + {"KeyN", DomCode::KEY_N},
|
| + {"KeyO", DomCode::KEY_O},
|
| + {"KeyP", DomCode::KEY_P},
|
| + {"KeyQ", DomCode::KEY_Q},
|
| + {"KeyR", DomCode::KEY_R},
|
| + {"KeyS", DomCode::KEY_S},
|
| + {"KeyT", DomCode::KEY_T},
|
| + {"KeyU", DomCode::KEY_U},
|
| + {"KeyV", DomCode::KEY_V},
|
| + {"KeyW", DomCode::KEY_W},
|
| + {"KeyX", DomCode::KEY_X},
|
| + {"KeyY", DomCode::KEY_Y},
|
| + {"KeyZ", DomCode::KEY_Z},
|
| + {"Lang1", DomCode::LANG1},
|
| + {"Lang2", DomCode::LANG2},
|
| + {"Lang3", DomCode::LANG3},
|
| + {"Lang4", DomCode::LANG4},
|
| + {"Lang5", DomCode::LANG5},
|
| + {"LaunchApp1", DomCode::LAUNCH_APP1},
|
| + {"LaunchApp2", DomCode::LAUNCH_APP2},
|
| + {"LaunchMail", DomCode::LAUNCH_MAIL},
|
| + {"MediaPlayPause", DomCode::MEDIA_PLAY_PAUSE},
|
| + {"MediaSelect", DomCode::MEDIA_SELECT},
|
| + {"MediaStop", DomCode::MEDIA_STOP},
|
| + {"MediaTrackNext", DomCode::MEDIA_TRACK_NEXT},
|
| + {"MediaTrackPrevious", DomCode::MEDIA_TRACK_PREVIOUS},
|
| + {"Minus", DomCode::MINUS},
|
| + {"NonConvert", DomCode::NON_CONVERT},
|
| + {"NumLock", DomCode::NUM_LOCK},
|
| + {"Numpad0", DomCode::NUMPAD0},
|
| + {"Numpad1", DomCode::NUMPAD1},
|
| + {"Numpad2", DomCode::NUMPAD2},
|
| + {"Numpad3", DomCode::NUMPAD3},
|
| + {"Numpad4", DomCode::NUMPAD4},
|
| + {"Numpad5", DomCode::NUMPAD5},
|
| + {"Numpad6", DomCode::NUMPAD6},
|
| + {"Numpad7", DomCode::NUMPAD7},
|
| + {"Numpad8", DomCode::NUMPAD8},
|
| + {"Numpad9", DomCode::NUMPAD9},
|
| + {"NumpadAdd", DomCode::NUMPAD_ADD},
|
| + {"NumpadBackspace", DomCode::NUMPAD_BACKSPACE},
|
| + {"NumpadClear", DomCode::NUMPAD_CLEAR},
|
| + {"NumpadClearEntry", DomCode::NUMPAD_CLEAR_ENTRY},
|
| + {"NumpadComma", DomCode::NUMPAD_COMMA},
|
| + {"NumpadDecimal", DomCode::NUMPAD_DECIMAL},
|
| + {"NumpadDivide", DomCode::NUMPAD_DIVIDE},
|
| + {"NumpadEnter", DomCode::NUMPAD_ENTER},
|
| + {"NumpadEqual", DomCode::NUMPAD_EQUAL},
|
| + {"NumpadMemoryAdd", DomCode::NUMPAD_MEMORY_ADD},
|
| + {"NumpadMemoryClear", DomCode::NUMPAD_MEMORY_CLEAR},
|
| + {"NumpadMemoryRecall", DomCode::NUMPAD_MEMORY_RECALL},
|
| + {"NumpadMemoryStore", DomCode::NUMPAD_MEMORY_STORE},
|
| + {"NumpadMemorySubtract", DomCode::NUMPAD_MEMORY_SUBTRACT},
|
| + {"NumpadMultiply", DomCode::NUMPAD_MULTIPLY},
|
| + {"NumpadParenLeft", DomCode::NUMPAD_PAREN_LEFT},
|
| + {"NumpadParenRight", DomCode::NUMPAD_PAREN_RIGHT},
|
| + {"NumpadSubtract", DomCode::NUMPAD_SUBTRACT},
|
| + {"OSLeft", DomCode::OS_LEFT},
|
| + {"OSRight", DomCode::OS_RIGHT},
|
| + {"Open", DomCode::OPEN},
|
| + {"PageDown", DomCode::PAGE_DOWN},
|
| + {"PageUp", DomCode::PAGE_UP},
|
| + {"Paste", DomCode::PASTE},
|
| + {"Pause", DomCode::PAUSE},
|
| + {"Period", DomCode::PERIOD},
|
| + {"Power", DomCode::POWER},
|
| + {"PrintScreen", DomCode::PRINT_SCREEN},
|
| + {"Props", DomCode::PROPS},
|
| + {"Quote", DomCode::QUOTE},
|
| + {"Resume", DomCode::RESUME},
|
| + {"ScrollLock", DomCode::SCROLL_LOCK},
|
| + {"Select", DomCode::SELECT},
|
| + {"Semicolon", DomCode::SEMICOLON},
|
| + {"ShiftLeft", DomCode::SHIFT_LEFT},
|
| + {"ShiftRight", DomCode::SHIFT_RIGHT},
|
| + {"Slash", DomCode::SLASH},
|
| + {"Sleep", DomCode::SLEEP},
|
| + {"Space", DomCode::SPACE},
|
| + {"Super", DomCode::SUPER},
|
| + {"Suspend", DomCode::SUSPEND},
|
| + {"Tab", DomCode::TAB},
|
| + {"Turbo", DomCode::TURBO},
|
| + {"Undo", DomCode::UNDO},
|
| + {"VolumeDown", DomCode::VOLUME_DOWN},
|
| + {"VolumeMute", DomCode::VOLUME_MUTE},
|
| + {"VolumeUp", DomCode::VOLUME_UP},
|
| + {"WakeUp", DomCode::WAKE_UP},
|
| +};
|
| +
|
| +const size_t kDomCodeMapEntries = arraysize(dom_code_by_string);
|
| +
|
| +const DomKeyCodeEntry<DomKey> dom_key_by_string[] = {
|
| + // This table is in ASCII order, which can be maintained by 'LANG=C sort'.
|
| + {"", DomKey::NONE},
|
| + {"AVRInput", DomKey::AVR_INPUT},
|
| + {"AVRPower", DomKey::AVR_POWER},
|
| + {"Accel", DomKey::ACCEL},
|
| + {"Accept", DomKey::ACCEPT},
|
| + {"Again", DomKey::AGAIN},
|
| + {"AllCandidates", DomKey::ALL_CANDIDATES},
|
| + {"Alphanumeric", DomKey::ALPHANUMERIC},
|
| + {"Alt", DomKey::ALT},
|
| + {"AltGraph", DomKey::ALT_GRAPH},
|
| + {"ArrowDown", DomKey::ARROW_DOWN},
|
| + {"ArrowLeft", DomKey::ARROW_LEFT},
|
| + {"ArrowRight", DomKey::ARROW_RIGHT},
|
| + {"ArrowUp", DomKey::ARROW_UP},
|
| + {"Attn", DomKey::ATTN},
|
| + {"AudioBalanceLeft", DomKey::AUDIO_BALANCE_LEFT},
|
| + {"AudioBalanceRight", DomKey::AUDIO_BALANCE_RIGHT},
|
| + {"AudioBassBoostDown", DomKey::AUDIO_BASS_BOOST_DOWN},
|
| + {"AudioBassBoostUp", DomKey::AUDIO_BASS_BOOST_UP},
|
| + {"AudioFaderFront", DomKey::AUDIO_FADER_FRONT},
|
| + {"AudioFaderRear", DomKey::AUDIO_FADER_REAR},
|
| + {"AudioSurroundModeNext", DomKey::AUDIO_SURROUND_MODE_NEXT},
|
| + {"Backspace", DomKey::BACKSPACE},
|
| + {"BrightnessDown", DomKey::BRIGHTNESS_DOWN},
|
| + {"BrightnessUp", DomKey::BRIGHTNESS_UP},
|
| + {"BrowserBack", DomKey::BROWSER_BACK},
|
| + {"BrowserFavorites", DomKey::BROWSER_FAVORITES},
|
| + {"BrowserForward", DomKey::BROWSER_FORWARD},
|
| + {"BrowserHome", DomKey::BROWSER_HOME},
|
| + {"BrowserRefresh", DomKey::BROWSER_REFRESH},
|
| + {"BrowserSearch", DomKey::BROWSER_SEARCH},
|
| + {"BrowserStop", DomKey::BROWSER_STOP},
|
| + {"Camera", DomKey::CAMERA},
|
| + {"Cancel", DomKey::CANCEL},
|
| + {"CapsLock", DomKey::CAPS_LOCK},
|
| + {"ChannelDown", DomKey::CHANNEL_DOWN},
|
| + {"ChannelUp", DomKey::CHANNEL_UP},
|
| + {"Clear", DomKey::CLEAR},
|
| + {"Close", DomKey::CLOSE},
|
| + {"ClosedCaptionToggle", DomKey::CLOSED_CAPTION_TOGGLE},
|
| + {"CodeInput", DomKey::CODE_INPUT},
|
| + {"ColorF0Red", DomKey::COLOR_F0_RED},
|
| + {"ColorF1Green", DomKey::COLOR_F1_GREEN},
|
| + {"ColorF2Yellow", DomKey::COLOR_F2_YELLOW},
|
| + {"ColorF3Blue", DomKey::COLOR_F3_BLUE},
|
| + {"ColorF4Grey", DomKey::COLOR_F4_GREY},
|
| + {"ColorF5Brown", DomKey::COLOR_F5_BROWN},
|
| + {"Compose", DomKey::COMPOSE},
|
| + {"ContextMenu", DomKey::CONTEXT_MENU},
|
| + {"Control", DomKey::CONTROL},
|
| + {"Convert", DomKey::CONVERT},
|
| + {"Copy", DomKey::COPY},
|
| + {"CrSel", DomKey::CR_SEL},
|
| + {"Cut", DomKey::CUT},
|
| + {"Dead", DomKey::DEAD},
|
| + {"Delete", DomKey::DELETE},
|
| + {"Dimmer", DomKey::DIMMER},
|
| + {"DisplaySwap", DomKey::DISPLAY_SWAP},
|
| + {"Eisu", DomKey::EISU},
|
| + {"Eject", DomKey::EJECT},
|
| + {"End", DomKey::END},
|
| + {"Enter", DomKey::ENTER},
|
| + {"EraseEof", DomKey::ERASE_EOF},
|
| + {"Escape", DomKey::ESCAPE},
|
| + {"ExSel", DomKey::EX_SEL},
|
| + {"Execute", DomKey::EXECUTE},
|
| + {"Exit", DomKey::EXIT},
|
| + {"F1", DomKey::F1},
|
| + {"F10", DomKey::F10},
|
| + {"F11", DomKey::F11},
|
| + {"F12", DomKey::F12},
|
| + {"F13", DomKey::F13},
|
| + {"F14", DomKey::F14},
|
| + {"F15", DomKey::F15},
|
| + {"F16", DomKey::F16},
|
| + {"F17", DomKey::F17},
|
| + {"F18", DomKey::F18},
|
| + {"F19", DomKey::F19},
|
| + {"F2", DomKey::F2},
|
| + {"F20", DomKey::F20},
|
| + {"F21", DomKey::F21},
|
| + {"F22", DomKey::F22},
|
| + {"F23", DomKey::F23},
|
| + {"F24", DomKey::F24},
|
| + {"F3", DomKey::F3},
|
| + {"F4", DomKey::F4},
|
| + {"F5", DomKey::F5},
|
| + {"F6", DomKey::F6},
|
| + {"F7", DomKey::F7},
|
| + {"F8", DomKey::F8},
|
| + {"F9", DomKey::F9},
|
| + {"FavoriteClear0", DomKey::FAVORITE_CLEAR0},
|
| + {"FavoriteClear1", DomKey::FAVORITE_CLEAR1},
|
| + {"FavoriteClear2", DomKey::FAVORITE_CLEAR2},
|
| + {"FavoriteClear3", DomKey::FAVORITE_CLEAR3},
|
| + {"FavoriteRecall0", DomKey::FAVORITE_RECALL0},
|
| + {"FavoriteRecall1", DomKey::FAVORITE_RECALL1},
|
| + {"FavoriteRecall2", DomKey::FAVORITE_RECALL2},
|
| + {"FavoriteRecall3", DomKey::FAVORITE_RECALL3},
|
| + {"FavoriteStore0", DomKey::FAVORITE_STORE0},
|
| + {"FavoriteStore1", DomKey::FAVORITE_STORE1},
|
| + {"FavoriteStore2", DomKey::FAVORITE_STORE2},
|
| + {"FavoriteStore3", DomKey::FAVORITE_STORE3},
|
| + {"FinalMode", DomKey::FINAL_MODE},
|
| + {"Find", DomKey::FIND},
|
| + {"Fn", DomKey::FN},
|
| + {"FnLock", DomKey::FN_LOCK},
|
| + {"GroupFirst", DomKey::GROUP_FIRST},
|
| + {"GroupLast", DomKey::GROUP_LAST},
|
| + {"GroupNext", DomKey::GROUP_NEXT},
|
| + {"GroupPrevious", DomKey::GROUP_PREVIOUS},
|
| + {"Guide", DomKey::GUIDE},
|
| + {"GuideNextDay", DomKey::GUIDE_NEXT_DAY},
|
| + {"GuidePreviousDay", DomKey::GUIDE_PREVIOUS_DAY},
|
| + {"HangulMode", DomKey::HANGUL_MODE},
|
| + {"HanjaMode", DomKey::HANJA_MODE},
|
| + {"Hankaku", DomKey::HANKAKU},
|
| + {"Help", DomKey::HELP},
|
| + {"Hibernate", DomKey::HIBERNATE},
|
| + {"Hiragana", DomKey::HIRAGANA},
|
| + {"HiraganaKatakana", DomKey::HIRAGANA_KATAKANA},
|
| + {"Home", DomKey::HOME},
|
| + {"Hyper", DomKey::HYPER},
|
| + {"Info", DomKey::INFO},
|
| + {"Insert", DomKey::INSERT},
|
| + {"InstantReplay", DomKey::INSTANT_REPLAY},
|
| + {"JunjaMode", DomKey::JUNJA_MODE},
|
| + {"KanaMode", DomKey::KANA_MODE},
|
| + {"KanjiMode", DomKey::KANJI_MODE},
|
| + {"Katakana", DomKey::KATAKANA},
|
| + {"LaunchCalculator", DomKey::LAUNCH_CALCULATOR},
|
| + {"LaunchCalendar", DomKey::LAUNCH_CALENDAR},
|
| + {"LaunchMail", DomKey::LAUNCH_MAIL},
|
| + {"LaunchMediaPlayer", DomKey::LAUNCH_MEDIA_PLAYER},
|
| + {"LaunchMusicPlayer", DomKey::LAUNCH_MUSIC_PLAYER},
|
| + {"LaunchMyComputer", DomKey::LAUNCH_MY_COMPUTER},
|
| + {"LaunchScreenSaver", DomKey::LAUNCH_SCREEN_SAVER},
|
| + {"LaunchSpreadsheet", DomKey::LAUNCH_SPREADSHEET},
|
| + {"LaunchWebBrowser", DomKey::LAUNCH_WEB_BROWSER},
|
| + {"LaunchWebCam", DomKey::LAUNCH_WEB_CAM},
|
| + {"LaunchWordProcessor", DomKey::LAUNCH_WORD_PROCESSOR},
|
| + {"Link", DomKey::LINK},
|
| + {"ListProgram", DomKey::LIST_PROGRAM},
|
| + {"LiveContent", DomKey::LIVE_CONTENT},
|
| + {"Lock", DomKey::LOCK},
|
| + {"LogOff", DomKey::LOG_OFF},
|
| + {"MailForward", DomKey::MAIL_FORWARD},
|
| + {"MailReply", DomKey::MAIL_REPLY},
|
| + {"MailSend", DomKey::MAIL_SEND},
|
| + {"MediaApps", DomKey::MEDIA_APPS},
|
| + {"MediaFastForward", DomKey::MEDIA_FAST_FORWARD},
|
| + {"MediaLast", DomKey::MEDIA_LAST},
|
| + {"MediaPause", DomKey::MEDIA_PAUSE},
|
| + {"MediaPlay", DomKey::MEDIA_PLAY},
|
| + {"MediaPlayPause", DomKey::MEDIA_PLAY_PAUSE},
|
| + {"MediaRecord", DomKey::MEDIA_RECORD},
|
| + {"MediaRewind", DomKey::MEDIA_REWIND},
|
| + {"MediaSelect", DomKey::MEDIA_SELECT},
|
| + {"MediaSkip", DomKey::MEDIA_SKIP},
|
| + {"MediaStop", DomKey::MEDIA_STOP},
|
| + {"MediaTrackNext", DomKey::MEDIA_TRACK_NEXT},
|
| + {"MediaTrackPrevious", DomKey::MEDIA_TRACK_PREVIOUS},
|
| + {"Meta", DomKey::META},
|
| + {"ModeChange", DomKey::MODE_CHANGE},
|
| + {"New", DomKey::NEW},
|
| + {"NextCandidate", DomKey::NEXT_CANDIDATE},
|
| + {"NextFavoriteChannel", DomKey::NEXT_FAVORITE_CHANNEL},
|
| + {"NextUserProfile", DomKey::NEXT_USER_PROFILE},
|
| + {"NonConvert", DomKey::NON_CONVERT},
|
| + {"NumLock", DomKey::NUM_LOCK},
|
| + {"OS", DomKey::OS},
|
| + {"OnDemand", DomKey::ON_DEMAND},
|
| + {"Open", DomKey::OPEN},
|
| + {"PageDown", DomKey::PAGE_DOWN},
|
| + {"PageUp", DomKey::PAGE_UP},
|
| + {"Paste", DomKey::PASTE},
|
| + {"Pause", DomKey::PAUSE},
|
| + {"PinPDown", DomKey::PIN_P_DOWN},
|
| + {"PinPMove", DomKey::PIN_P_MOVE},
|
| + {"PinPToggle", DomKey::PIN_P_TOGGLE},
|
| + {"PinPUp", DomKey::PIN_P_UP},
|
| + {"Play", DomKey::PLAY},
|
| + {"PlaySpeedDown", DomKey::PLAY_SPEED_DOWN},
|
| + {"PlaySpeedReset", DomKey::PLAY_SPEED_RESET},
|
| + {"PlaySpeedUp", DomKey::PLAY_SPEED_UP},
|
| + {"Power", DomKey::POWER},
|
| + {"PowerOff", DomKey::POWER_OFF},
|
| + {"PreviousCandidate", DomKey::PREVIOUS_CANDIDATE},
|
| + {"Print", DomKey::PRINT},
|
| + {"PrintScreen", DomKey::PRINT_SCREEN},
|
| + {"Process", DomKey::PROCESS},
|
| + {"Props", DomKey::PROPS},
|
| + {"RandomToggle", DomKey::RANDOM_TOGGLE},
|
| + {"RcLowBattery", DomKey::RC_LOW_BATTERY},
|
| + {"RecordSpeedNext", DomKey::RECORD_SPEED_NEXT},
|
| + {"Redo", DomKey::REDO},
|
| + {"RfBypass", DomKey::RF_BYPASS},
|
| + {"Romaji", DomKey::ROMAJI},
|
| + {"STBInput", DomKey::STB_INPUT},
|
| + {"STBPower", DomKey::STB_POWER},
|
| + {"Save", DomKey::SAVE},
|
| + {"ScanChannelsToggle", DomKey::SCAN_CHANNELS_TOGGLE},
|
| + {"ScreenModeNext", DomKey::SCREEN_MODE_NEXT},
|
| + {"ScrollLock", DomKey::SCROLL_LOCK},
|
| + {"Select", DomKey::SELECT},
|
| + {"Separator", DomKey::SEPARATOR},
|
| + {"Settings", DomKey::SETTINGS},
|
| + {"Shift", DomKey::SHIFT},
|
| + {"SingleCandidate", DomKey::SINGLE_CANDIDATE},
|
| + {"Soft1", DomKey::SOFT1},
|
| + {"Soft2", DomKey::SOFT2},
|
| + {"Soft3", DomKey::SOFT3},
|
| + {"Soft4", DomKey::SOFT4},
|
| + {"Soft5", DomKey::SOFT5},
|
| + {"Soft6", DomKey::SOFT6},
|
| + {"Soft7", DomKey::SOFT7},
|
| + {"Soft8", DomKey::SOFT8},
|
| + {"SpellCheck", DomKey::SPELL_CHECK},
|
| + {"SplitScreenToggle", DomKey::SPLIT_SCREEN_TOGGLE},
|
| + {"Standby", DomKey::STANDBY},
|
| + {"Subtitle", DomKey::SUBTITLE},
|
| + {"Super", DomKey::SUPER},
|
| + {"Symbol", DomKey::SYMBOL},
|
| + {"SymbolLock", DomKey::SYMBOL_LOCK},
|
| + {"TV", DomKey::TV},
|
| + {"TVInput", DomKey::TV_INPUT},
|
| + {"TVPower", DomKey::TV_POWER},
|
| + {"Tab", DomKey::TAB},
|
| + {"Teletext", DomKey::TELETEXT},
|
| + {"Undo", DomKey::UNDO},
|
| + {"Unidentified", DomKey::UNIDENTIFIED},
|
| + {"VideoModeNext", DomKey::VIDEO_MODE_NEXT},
|
| + {"VolumeDown", DomKey::VOLUME_DOWN},
|
| + {"VolumeMute", DomKey::VOLUME_MUTE},
|
| + {"VolumeUp", DomKey::VOLUME_UP},
|
| + {"WakeUp", DomKey::WAKE_UP},
|
| + {"Wink", DomKey::WINK},
|
| + {"Zenkaku", DomKey::ZENKAKU},
|
| + {"ZenkakuHankaku", DomKey::ZENKAKU_HANKAKU},
|
| + {"ZoomIn", DomKey::ZOOM_IN},
|
| + {"ZoomOut", DomKey::ZOOM_OUT},
|
| + {"ZoomToggle", DomKey::ZOOM_TOGGLE},
|
| +};
|
| +
|
| +const size_t kDomKeyMapEntries = arraysize(dom_key_by_string);
|
| +
|
| } // namespace
|
|
|
| // static
|
| @@ -34,6 +503,20 @@ const KeycodeMapEntry* KeycodeConverter::GetKeycodeMapForTest() {
|
| }
|
|
|
| // static
|
| +const char* KeycodeConverter::DomCodeStringForTest(size_t index) {
|
| + if (index >= kDomCodeMapEntries)
|
| + return nullptr;
|
| + return dom_code_by_string[index].string;
|
| +}
|
| +
|
| +// static
|
| +const char* KeycodeConverter::DomKeyStringForTest(size_t index) {
|
| + if (index >= kDomKeyMapEntries)
|
| + return nullptr;
|
| + return dom_key_by_string[index].string;
|
| +}
|
| +
|
| +// static
|
| uint16_t KeycodeConverter::InvalidNativeKeycode() {
|
| return usb_keycode_map[0].native_keycode;
|
| }
|
| @@ -44,33 +527,50 @@ const char* KeycodeConverter::InvalidKeyboardEventCode() {
|
| }
|
|
|
| // static
|
| -const char* KeycodeConverter::NativeKeycodeToCode(uint16_t native_keycode) {
|
| - for (size_t i = 0; i < kKeycodeMapEntries; ++i) {
|
| - if (usb_keycode_map[i].native_keycode == native_keycode) {
|
| - if (usb_keycode_map[i].code != NULL)
|
| - return usb_keycode_map[i].code;
|
| - break;
|
| - }
|
| +const char* KeycodeConverter::DomCodeToCodeString(DomCode dom_code) {
|
| + for (size_t i = 0; i < kDomCodeMapEntries; ++i) {
|
| + if (dom_code == dom_code_by_string[i].enumeration)
|
| + return dom_code_by_string[i].string;
|
| }
|
| return InvalidKeyboardEventCode();
|
| }
|
|
|
| // static
|
| -uint16_t KeycodeConverter::CodeToNativeKeycode(const char* code) {
|
| - if (!code ||
|
| - strcmp(code, InvalidKeyboardEventCode()) == 0) {
|
| - return InvalidNativeKeycode();
|
| +DomCode KeycodeConverter::CodeStringToDomCode(const char* code) {
|
| + return DomKeyCodeEntry<DomCode>::Map(
|
| + dom_code_by_string,
|
| + dom_code_by_string + kDomCodeMapEntries,
|
| + code);
|
| +}
|
| +
|
| +// static
|
| +DomCode KeycodeConverter::NativeKeycodeToDomCode(uint16_t native_keycode) {
|
| + for (size_t i = 0; i < kKeycodeMapEntries; ++i) {
|
| + if (usb_keycode_map[i].native_keycode == native_keycode)
|
| + return usb_keycode_map[i].code;
|
| }
|
| + return DomCode::NONE;
|
| +}
|
|
|
| +// static
|
| +uint16_t KeycodeConverter::DomCodeToNativeKeycode(DomCode code) {
|
| for (size_t i = 0; i < kKeycodeMapEntries; ++i) {
|
| - if (usb_keycode_map[i].code &&
|
| - strcmp(usb_keycode_map[i].code, code) == 0) {
|
| + if (usb_keycode_map[i].code == code)
|
| return usb_keycode_map[i].native_keycode;
|
| - }
|
| }
|
| return InvalidNativeKeycode();
|
| }
|
|
|
| +// static
|
| +const char* KeycodeConverter::NativeKeycodeToCode(uint16_t native_keycode) {
|
| + return DomCodeToCodeString(NativeKeycodeToDomCode(native_keycode));
|
| +}
|
| +
|
| +// static
|
| +uint16_t KeycodeConverter::CodeToNativeKeycode(const char* code_string) {
|
| + return DomCodeToNativeKeycode(CodeStringToDomCode(code_string));
|
| +}
|
| +
|
| // USB keycodes
|
| // Note that USB keycodes are not part of any web standard.
|
| // Please don't use USB keycodes in new code.
|
| @@ -110,25 +610,39 @@ uint32_t KeycodeConverter::NativeKeycodeToUsbKeycode(uint16_t native_keycode) {
|
| const char* KeycodeConverter::UsbKeycodeToCode(uint32_t usb_keycode) {
|
| for (size_t i = 0; i < kKeycodeMapEntries; ++i) {
|
| if (usb_keycode_map[i].usb_keycode == usb_keycode)
|
| - return usb_keycode_map[i].code;
|
| + return DomCodeToCodeString(usb_keycode_map[i].code);
|
| }
|
| return InvalidKeyboardEventCode();
|
| }
|
|
|
| // static
|
| -uint32_t KeycodeConverter::CodeToUsbKeycode(const char* code) {
|
| - if (!code ||
|
| - strcmp(code, InvalidKeyboardEventCode()) == 0) {
|
| - return InvalidUsbKeycode();
|
| - }
|
| -
|
| - for (size_t i = 0; i < kKeycodeMapEntries; ++i) {
|
| - if (usb_keycode_map[i].code &&
|
| - strcmp(usb_keycode_map[i].code, code) == 0) {
|
| - return usb_keycode_map[i].usb_keycode;
|
| +uint32_t KeycodeConverter::CodeToUsbKeycode(const char* code_string) {
|
| + DomCode code = CodeStringToDomCode(code_string);
|
| + if (code != DomCode::NONE) {
|
| + for (size_t i = 0; i < kKeycodeMapEntries; ++i) {
|
| + if (usb_keycode_map[i].code == code) {
|
| + return usb_keycode_map[i].usb_keycode;
|
| + }
|
| }
|
| }
|
| return InvalidUsbKeycode();
|
| }
|
|
|
| +// static
|
| +const char* KeycodeConverter::DomKeyToKeyString(DomKey dom_key) {
|
| + for (size_t i = 0; i < kDomKeyMapEntries; ++i) {
|
| + if (dom_key == dom_key_by_string[i].enumeration)
|
| + return dom_key_by_string[i].string;
|
| + }
|
| + return dom_key_by_string[0].string;
|
| +}
|
| +
|
| +// static
|
| +DomKey KeycodeConverter::KeyStringToDomKey(const char* key) {
|
| + return DomKeyCodeEntry<DomKey>::Map(
|
| + dom_key_by_string,
|
| + dom_key_by_string + kDomKeyMapEntries,
|
| + key);
|
| +}
|
| +
|
| } // namespace ui
|
|
|