From 1a71c7058708168a9c5b0509757d177115f84ffb Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Wed, 21 Jul 2021 01:58:09 -0700 Subject: [PATCH] Update key mapping to the latest logical key values (flutter/engine#25883) This PR updates the key mapping tables of every platform according to the change to keycode_gen. --- .../ci/licenses_golden/licenses_flutter | 1 + .../lib/web_ui/lib/src/engine/key_map.dart | 1275 ++++++++--------- .../lib/src/engine/keyboard_binding.dart | 36 +- .../web_ui/test/keyboard_converter_test.dart | 50 +- .../shell/platform/darwin/ios/BUILD.gn | 1 + .../Source/FlutterEmbedderKeyResponder.mm | 14 +- .../Source/FlutterEmbedderKeyResponderTest.mm | 21 +- .../darwin/ios/framework/Source/KeyCodeMap.mm | 234 ++- .../framework/Source/KeyCodeMap_Internal.h | 11 +- .../Source/FlutterEmbedderKeyResponder.mm | 49 +- .../FlutterEmbedderKeyResponderUnittests.mm | 19 +- .../macos/framework/Source/KeyCodeMap.mm | 387 +++-- .../framework/Source/KeyCodeMap_Internal.h | 21 +- .../flutter/shell/platform/embedder/BUILD.gn | 5 +- .../platform/embedder/test_utils/key_codes.h | 750 ++++++++++ .../linux/fl_key_embedder_responder.cc | 14 +- .../linux/fl_key_embedder_responder_test.cc | 16 +- .../shell/platform/linux/key_mapping.cc | 362 ++--- .../shell/platform/linux/key_mapping.h | 9 + .../shell/platform/windows/flutter_key_map.cc | 485 ++++--- .../windows/keyboard_key_embedder_handler.cc | 100 +- .../windows/keyboard_key_embedder_handler.h | 14 +- ...keyboard_key_embedder_handler_unittests.cc | 71 +- 23 files changed, 2249 insertions(+), 1696 deletions(-) create mode 100644 engine/src/flutter/shell/platform/embedder/test_utils/key_codes.h diff --git a/engine/src/flutter/ci/licenses_golden/licenses_flutter b/engine/src/flutter/ci/licenses_golden/licenses_flutter index d697aec989..a3bbef3c14 100755 --- a/engine/src/flutter/ci/licenses_golden/licenses_flutter +++ b/engine/src/flutter/ci/licenses_golden/licenses_flutter @@ -1309,6 +1309,7 @@ FILE: ../../../flutter/shell/platform/embedder/fixtures/verifyb143464703.png FILE: ../../../flutter/shell/platform/embedder/fixtures/verifyb143464703_soft_noxform.png FILE: ../../../flutter/shell/platform/embedder/platform_view_embedder.cc FILE: ../../../flutter/shell/platform/embedder/platform_view_embedder.h +FILE: ../../../flutter/shell/platform/embedder/test_utils/key_codes.h FILE: ../../../flutter/shell/platform/embedder/test_utils/proc_table_replacement.h FILE: ../../../flutter/shell/platform/embedder/vsync_waiter_embedder.cc FILE: ../../../flutter/shell/platform/embedder/vsync_waiter_embedder.h diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/key_map.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/key_map.dart index e7c22e1d11..5841e8adc5 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/key_map.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/key_map.dart @@ -9,655 +9,580 @@ // Edit the template dev/tools/gen_keycodes/data/web_key_map_dart.tmpl instead. // See dev/tools/gen_keycodes/README.md for more information. -/// Maps Web KeyboardEvent codes to the matching LogicalKeyboardKey id. +/// Maps Web KeyboardEvent keys to the matching LogicalKeyboardKey id. const Map kWebToLogicalKey = { - 'None': 0x0000000000, - 'Unidentified': 0x0000000001, - 'Backspace': 0x0000000008, - 'Tab': 0x0000000009, - 'Enter': 0x000000000d, - 'Escape': 0x000000001b, - 'Space': 0x0000000020, - 'Exclamation': 0x0000000021, - 'Quote': 0x0000000022, - 'NumberSign': 0x0000000023, - 'Dollar': 0x0000000024, - 'Ampersand': 0x0000000026, - 'QuoteSingle': 0x0000000027, - 'ParenthesisLeft': 0x0000000028, - 'ParenthesisRight': 0x0000000029, - 'Asterisk': 0x000000002a, - 'Add': 0x000000002b, - 'Comma': 0x000000002c, - 'Minus': 0x000000002d, - 'Period': 0x000000002e, - 'Slash': 0x000000002f, - 'Digit0': 0x0000000030, - 'Digit1': 0x0000000031, - 'Digit2': 0x0000000032, - 'Digit3': 0x0000000033, - 'Digit4': 0x0000000034, - 'Digit5': 0x0000000035, - 'Digit6': 0x0000000036, - 'Digit7': 0x0000000037, - 'Digit8': 0x0000000038, - 'Digit9': 0x0000000039, - 'Colon': 0x000000003a, - 'Semicolon': 0x000000003b, - 'Less': 0x000000003c, - 'Equal': 0x000000003d, - 'Greater': 0x000000003e, - 'Question': 0x000000003f, - 'At': 0x0000000040, - 'BracketLeft': 0x000000005b, - 'Backslash': 0x000000005c, - 'BracketRight': 0x000000005d, - 'Caret': 0x000000005e, - 'Underscore': 0x000000005f, - 'Backquote': 0x0000000060, - 'KeyA': 0x0000000061, - 'KeyB': 0x0000000062, - 'KeyC': 0x0000000063, - 'KeyD': 0x0000000064, - 'KeyE': 0x0000000065, - 'KeyF': 0x0000000066, - 'KeyG': 0x0000000067, - 'KeyH': 0x0000000068, - 'KeyI': 0x0000000069, - 'KeyJ': 0x000000006a, - 'KeyK': 0x000000006b, - 'KeyL': 0x000000006c, - 'KeyM': 0x000000006d, - 'KeyN': 0x000000006e, - 'KeyO': 0x000000006f, - 'KeyP': 0x0000000070, - 'KeyQ': 0x0000000071, - 'KeyR': 0x0000000072, - 'KeyS': 0x0000000073, - 'KeyT': 0x0000000074, - 'KeyU': 0x0000000075, - 'KeyV': 0x0000000076, - 'KeyW': 0x0000000077, - 'KeyX': 0x0000000078, - 'KeyY': 0x0000000079, - 'KeyZ': 0x000000007a, - 'BraceLeft': 0x000000007b, - 'Bar': 0x000000007c, - 'BraceRight': 0x000000007d, - 'Tilde': 0x000000007e, - 'Delete': 0x000000007f, - 'Accel': 0x0000000101, - 'AltGraph': 0x0000000103, - 'CapsLock': 0x0000000104, - 'Fn': 0x0000000106, - 'FnLock': 0x0000000107, - 'Hyper': 0x0000000108, - 'NumLock': 0x000000010a, - 'ScrollLock': 0x000000010c, - 'Super': 0x000000010e, - 'Symbol': 0x000000010f, - 'SymbolLock': 0x0000000110, - 'ShiftLevel5': 0x0000000111, - 'AltGraphLatch': 0x0000000112, - 'ArrowDown': 0x0000000301, - 'ArrowLeft': 0x0000000302, - 'ArrowRight': 0x0000000303, - 'ArrowUp': 0x0000000304, - 'End': 0x0000000305, - 'Home': 0x0000000306, - 'PageDown': 0x0000000307, - 'PageUp': 0x0000000308, - 'Clear': 0x0000000401, - 'Copy': 0x0000000402, - 'CrSel': 0x0000000403, - 'Cut': 0x0000000404, - 'EraseEof': 0x0000000405, - 'ExSel': 0x0000000406, - 'Insert': 0x0000000407, - 'Paste': 0x0000000408, - 'Redo': 0x0000000409, - 'Undo': 0x000000040a, - 'Accept': 0x0000000501, - 'Again': 0x0000000502, - 'Attn': 0x0000000503, - 'Cancel': 0x0000000504, - 'ContextMenu': 0x0000000505, - 'Execute': 0x0000000506, - 'Find': 0x0000000507, - 'Help': 0x0000000508, - 'Pause': 0x0000000509, - 'Play': 0x000000050a, - 'Props': 0x000000050b, - 'Select': 0x000000050c, - 'ZoomIn': 0x000000050d, - 'ZoomOut': 0x000000050e, - 'BrightnessDown': 0x0000000601, - 'BrightnessUp': 0x0000000602, - 'Camera': 0x0000000603, - 'Eject': 0x0000000604, - 'LogOff': 0x0000000605, - 'Power': 0x0000000606, - 'PowerOff': 0x0000000607, - 'PrintScreen': 0x0000000608, - 'Hibernate': 0x0000000609, - 'Standby': 0x000000060a, - 'WakeUp': 0x000000060b, - 'AllCandidates': 0x0000000701, - 'Alphanumeric': 0x0000000702, - 'CodeInput': 0x0000000703, - 'Compose': 0x0000000704, - 'Convert': 0x0000000705, - 'FinalMode': 0x0000000706, - 'GroupFirst': 0x0000000707, - 'GroupLast': 0x0000000708, - 'GroupNext': 0x0000000709, - 'GroupPrevious': 0x000000070a, - 'ModeChange': 0x000000070b, - 'NextCandidate': 0x000000070c, - 'NonConvert': 0x000000070d, - 'PreviousCandidate': 0x000000070e, - 'Process': 0x000000070f, - 'SingleCandidate': 0x0000000710, - 'HangulMode': 0x0000000711, - 'HanjaMode': 0x0000000712, - 'JunjaMode': 0x0000000713, - 'Eisu': 0x0000000714, - 'Hankaku': 0x0000000715, - 'Hiragana': 0x0000000716, - 'HiraganaKatakana': 0x0000000717, - 'KanaMode': 0x0000000718, - 'KanjiMode': 0x0000000719, - 'Katakana': 0x000000071a, - 'Romaji': 0x000000071b, - 'Zenkaku': 0x000000071c, - 'ZenkakuHankaku': 0x000000071d, - 'F1': 0x0000000801, - 'F2': 0x0000000802, - 'F3': 0x0000000803, - 'F4': 0x0000000804, - 'F5': 0x0000000805, - 'F6': 0x0000000806, - 'F7': 0x0000000807, - 'F8': 0x0000000808, - 'F9': 0x0000000809, - 'F10': 0x000000080a, - 'F11': 0x000000080b, - 'F12': 0x000000080c, - 'F13': 0x000000080d, - 'F14': 0x000000080e, - 'F15': 0x000000080f, - 'F16': 0x0000000810, - 'F17': 0x0000000811, - 'F18': 0x0000000812, - 'F19': 0x0000000813, - 'F20': 0x0000000814, - 'F21': 0x0000000815, - 'F22': 0x0000000816, - 'F23': 0x0000000817, - 'F24': 0x0000000818, - 'Soft1': 0x0000000901, - 'Soft2': 0x0000000902, - 'Soft3': 0x0000000903, - 'Soft4': 0x0000000904, - 'Soft5': 0x0000000905, - 'Soft6': 0x0000000906, - 'Soft7': 0x0000000907, - 'Soft8': 0x0000000908, - 'Close': 0x0000000a01, - 'MailForward': 0x0000000a02, - 'MailReply': 0x0000000a03, - 'MailSend': 0x0000000a04, - 'MediaPlayPause': 0x0000000a05, - 'MediaStop': 0x0000000a07, - 'MediaTrackNext': 0x0000000a08, - 'MediaTrackPrevious': 0x0000000a09, - 'New': 0x0000000a0a, - 'Open': 0x0000000a0b, - 'Print': 0x0000000a0c, - 'Save': 0x0000000a0d, - 'SpellCheck': 0x0000000a0e, - 'AudioVolumeDown': 0x0000000a0f, - 'AudioVolumeUp': 0x0000000a10, - 'AudioVolumeMute': 0x0000000a11, - 'LaunchApplication2': 0x0000000b01, - 'LaunchCalendar': 0x0000000b02, - 'LaunchMail': 0x0000000b03, - 'LaunchMediaPlayer': 0x0000000b04, - 'LaunchMusicPlayer': 0x0000000b05, - 'LaunchApplication1': 0x0000000b06, - 'LaunchScreenSaver': 0x0000000b07, - 'LaunchSpreadsheet': 0x0000000b08, - 'LaunchWebBrowser': 0x0000000b09, - 'LaunchWebCam': 0x0000000b0a, - 'LaunchWordProcessor': 0x0000000b0b, - 'LaunchContacts': 0x0000000b0c, - 'LaunchPhone': 0x0000000b0d, - 'LaunchAssistant': 0x0000000b0e, - 'LaunchControlPanel': 0x0000000b0f, - 'BrowserBack': 0x0000000c01, - 'BrowserFavorites': 0x0000000c02, - 'BrowserForward': 0x0000000c03, - 'BrowserHome': 0x0000000c04, - 'BrowserRefresh': 0x0000000c05, - 'BrowserSearch': 0x0000000c06, - 'BrowserStop': 0x0000000c07, - 'AudioBalanceLeft': 0x0000000d01, - 'AudioBalanceRight': 0x0000000d02, - 'AudioBassBoostDown': 0x0000000d03, - 'AudioBassBoostUp': 0x0000000d04, - 'AudioFaderFront': 0x0000000d05, - 'AudioFaderRear': 0x0000000d06, - 'AudioSurroundModeNext': 0x0000000d07, - 'AVRInput': 0x0000000d08, - 'AVRPower': 0x0000000d09, - 'ChannelDown': 0x0000000d0a, - 'ChannelUp': 0x0000000d0b, - 'ColorF0Red': 0x0000000d0c, - 'ColorF1Green': 0x0000000d0d, - 'ColorF2Yellow': 0x0000000d0e, - 'ColorF3Blue': 0x0000000d0f, - 'ColorF4Grey': 0x0000000d10, - 'ColorF5Brown': 0x0000000d11, - 'ClosedCaptionToggle': 0x0000000d12, - 'Dimmer': 0x0000000d13, - 'DisplaySwap': 0x0000000d14, - 'Exit': 0x0000000d15, - 'FavoriteClear0': 0x0000000d16, - 'FavoriteClear1': 0x0000000d17, - 'FavoriteClear2': 0x0000000d18, - 'FavoriteClear3': 0x0000000d19, - 'FavoriteRecall0': 0x0000000d1a, - 'FavoriteRecall1': 0x0000000d1b, - 'FavoriteRecall2': 0x0000000d1c, - 'FavoriteRecall3': 0x0000000d1d, - 'FavoriteStore0': 0x0000000d1e, - 'FavoriteStore1': 0x0000000d1f, - 'FavoriteStore2': 0x0000000d20, - 'FavoriteStore3': 0x0000000d21, - 'Guide': 0x0000000d22, - 'GuideNextDay': 0x0000000d23, - 'GuidePreviousDay': 0x0000000d24, - 'Info': 0x0000000d25, - 'InstantReplay': 0x0000000d26, - 'Link': 0x0000000d27, - 'ListProgram': 0x0000000d28, - 'LiveContent': 0x0000000d29, - 'Lock': 0x0000000d2a, - 'MediaApps': 0x0000000d2b, - 'MediaFastForward': 0x0000000d2c, - 'MediaLast': 0x0000000d2d, - 'MediaPause': 0x0000000d2e, - 'MediaPlay': 0x0000000d2f, - 'MediaRecord': 0x0000000d30, - 'MediaRewind': 0x0000000d31, - 'MediaSkip': 0x0000000d32, - 'NextFavoriteChannel': 0x0000000d33, - 'NextUserProfile': 0x0000000d34, - 'OnDemand': 0x0000000d35, - 'PinPDown': 0x0000000d36, - 'PinPMove': 0x0000000d37, - 'PinPToggle': 0x0000000d38, - 'PinPUp': 0x0000000d39, - 'PlaySpeedDown': 0x0000000d3a, - 'PlaySpeedReset': 0x0000000d3b, - 'PlaySpeedUp': 0x0000000d3c, - 'RandomToggle': 0x0000000d3d, - 'RcLowBattery': 0x0000000d3e, - 'RecordSpeedNext': 0x0000000d3f, - 'RfBypass': 0x0000000d40, - 'ScanChannelsToggle': 0x0000000d41, - 'ScreenModeNext': 0x0000000d42, - 'Settings': 0x0000000d43, - 'SplitScreenToggle': 0x0000000d44, - 'STBInput': 0x0000000d45, - 'STBPower': 0x0000000d46, - 'Subtitle': 0x0000000d47, - 'Teletext': 0x0000000d48, - 'TV': 0x0000000d49, - 'TVInput': 0x0000000d4a, - 'TVPower': 0x0000000d4b, - 'VideoModeNext': 0x0000000d4c, - 'Wink': 0x0000000d4d, - 'ZoomToggle': 0x0000000d4e, - 'DVR': 0x0000000d4f, - 'MediaAudioTrack': 0x0000000d50, - 'MediaSkipBackward': 0x0000000d51, - 'MediaSkipForward': 0x0000000d52, - 'MediaStepBackward': 0x0000000d53, - 'MediaStepForward': 0x0000000d54, - 'MediaTopMenu': 0x0000000d55, - 'NavigateIn': 0x0000000d56, - 'NavigateNext': 0x0000000d57, - 'NavigateOut': 0x0000000d58, - 'NavigatePrevious': 0x0000000d59, - 'Pairing': 0x0000000d5a, - 'MediaClose': 0x0000000d5b, - 'AudioBassBoostToggle': 0x0000000e02, - 'AudioTrebleDown': 0x0000000e04, - 'AudioTrebleUp': 0x0000000e05, - 'MicrophoneToggle': 0x0000000e06, - 'MicrophoneVolumeDown': 0x0000000e07, - 'MicrophoneVolumeUp': 0x0000000e08, - 'MicrophoneVolumeMute': 0x0000000e09, - 'SpeechCorrectionList': 0x0000000f01, - 'SpeechInputToggle': 0x0000000f02, - 'AppSwitch': 0x0000001001, - 'Call': 0x0000001002, - 'CameraFocus': 0x0000001003, - 'EndCall': 0x0000001004, - 'GoBack': 0x0000001005, - 'GoHome': 0x0000001006, - 'HeadsetHook': 0x0000001007, - 'LastNumberRedial': 0x0000001008, - 'Notification': 0x0000001009, - 'MannerMode': 0x000000100a, - 'VoiceDial': 0x000000100b, - 'TV3DMode': 0x0000001101, - 'TVAntennaCable': 0x0000001102, - 'TVAudioDescription': 0x0000001103, - 'TVAudioDescriptionMixDown': 0x0000001104, - 'TVAudioDescriptionMixUp': 0x0000001105, - 'TVContentsMenu': 0x0000001106, - 'TVDataService': 0x0000001107, - 'TVInputComponent1': 0x0000001108, - 'TVInputComponent2': 0x0000001109, - 'TVInputComposite1': 0x000000110a, - 'TVInputComposite2': 0x000000110b, - 'TVInputHDMI1': 0x000000110c, - 'TVInputHDMI2': 0x000000110d, - 'TVInputHDMI3': 0x000000110e, - 'TVInputHDMI4': 0x000000110f, - 'TVInputVGA1': 0x0000001110, - 'TVMediaContext': 0x0000001111, - 'TVNetwork': 0x0000001112, - 'TVNumberEntry': 0x0000001113, - 'TVRadioService': 0x0000001114, - 'TVSatellite': 0x0000001115, - 'TVSatelliteBS': 0x0000001116, - 'TVSatelliteCS': 0x0000001117, - 'TVSatelliteToggle': 0x0000001118, - 'TVTerrestrialAnalog': 0x0000001119, - 'TVTerrestrialDigital': 0x000000111a, - 'TVTimer': 0x000000111b, - 'Key11': 0x0000001201, - 'Key12': 0x0000001202, - 'GameButton1': 0x000005ff01, - 'GameButton2': 0x000005ff02, - 'GameButton3': 0x000005ff03, - 'GameButton4': 0x000005ff04, - 'GameButton5': 0x000005ff05, - 'GameButton6': 0x000005ff06, - 'GameButton7': 0x000005ff07, - 'GameButton8': 0x000005ff08, - 'GameButton9': 0x000005ff09, - 'GameButton10': 0x000005ff0a, - 'GameButton11': 0x000005ff0b, - 'GameButton12': 0x000005ff0c, - 'GameButton13': 0x000005ff0d, - 'GameButton14': 0x000005ff0e, - 'GameButton15': 0x000005ff0f, - 'GameButton16': 0x000005ff10, - 'GameButtonA': 0x000005ff11, - 'GameButtonB': 0x000005ff12, - 'GameButtonC': 0x000005ff13, - 'GameButtonLeft1': 0x000005ff14, - 'GameButtonLeft2': 0x000005ff15, - 'GameButtonMode': 0x000005ff16, - 'GameButtonRight1': 0x000005ff17, - 'GameButtonRight2': 0x000005ff18, - 'GameButtonSelect': 0x000005ff19, - 'GameButtonStart': 0x000005ff1a, - 'GameButtonThumbLeft': 0x000005ff1b, - 'GameButtonThumbRight': 0x000005ff1c, - 'GameButtonX': 0x000005ff1d, - 'GameButtonY': 0x000005ff1e, - 'GameButtonZ': 0x000005ff1f, - 'Suspend': 0x0100000014, - 'Resume': 0x0100000015, - 'Sleep': 0x0100010082, - 'IntlBackslash': 0x0100070064, - 'IntlRo': 0x0100070087, - 'IntlYen': 0x0100070089, - 'Lang1': 0x0100070090, - 'Lang2': 0x0100070091, - 'Lang3': 0x0100070092, - 'Lang4': 0x0100070093, - 'Lang5': 0x0100070094, - 'Abort': 0x010007009b, + 'AVRInput': 0x00100000d08, + 'AVRPower': 0x00100000d09, + 'Accel': 0x00100000101, + 'Accept': 0x00100000501, + 'Again': 0x00100000502, + 'AllCandidates': 0x00100000701, + 'Alphanumeric': 0x00100000702, + 'AltGraph': 0x00100000103, + 'AppSwitch': 0x00100001001, + 'ArrowDown': 0x00100000301, + 'ArrowLeft': 0x00100000302, + 'ArrowRight': 0x00100000303, + 'ArrowUp': 0x00100000304, + 'Attn': 0x00100000503, + 'AudioBalanceLeft': 0x00100000d01, + 'AudioBalanceRight': 0x00100000d02, + 'AudioBassBoostDown': 0x00100000d03, + 'AudioBassBoostToggle': 0x00100000e02, + 'AudioBassBoostUp': 0x00100000d04, + 'AudioFaderFront': 0x00100000d05, + 'AudioFaderRear': 0x00100000d06, + 'AudioSurroundModeNext': 0x00100000d07, + 'AudioTrebleDown': 0x00100000e04, + 'AudioTrebleUp': 0x00100000e05, + 'AudioVolumeDown': 0x00100000a0f, + 'AudioVolumeMute': 0x00100000a11, + 'AudioVolumeUp': 0x00100000a10, + 'Backspace': 0x00100000008, + 'BrightnessDown': 0x00100000601, + 'BrightnessUp': 0x00100000602, + 'BrowserBack': 0x00100000c01, + 'BrowserFavorites': 0x00100000c02, + 'BrowserForward': 0x00100000c03, + 'BrowserHome': 0x00100000c04, + 'BrowserRefresh': 0x00100000c05, + 'BrowserSearch': 0x00100000c06, + 'BrowserStop': 0x00100000c07, + 'Call': 0x00100001002, + 'Camera': 0x00100000603, + 'CameraFocus': 0x00100001003, + 'Cancel': 0x00100000504, + 'CapsLock': 0x00100000104, + 'ChannelDown': 0x00100000d0a, + 'ChannelUp': 0x00100000d0b, + 'Clear': 0x00100000401, + 'Close': 0x00100000a01, + 'ClosedCaptionToggle': 0x00100000d12, + 'CodeInput': 0x00100000703, + 'ColorF0Red': 0x00100000d0c, + 'ColorF1Green': 0x00100000d0d, + 'ColorF2Yellow': 0x00100000d0e, + 'ColorF3Blue': 0x00100000d0f, + 'ColorF4Grey': 0x00100000d10, + 'ColorF5Brown': 0x00100000d11, + 'Compose': 0x00100000704, + 'ContextMenu': 0x00100000505, + 'Convert': 0x00100000705, + 'Copy': 0x00100000402, + 'CrSel': 0x00100000403, + 'Cut': 0x00100000404, + 'DVR': 0x00100000d4f, + 'Delete': 0x0010000007f, + 'Dimmer': 0x00100000d13, + 'DisplaySwap': 0x00100000d14, + 'Eisu': 0x00100000714, + 'Eject': 0x00100000604, + 'End': 0x00100000305, + 'EndCall': 0x00100001004, + 'Enter': 0x0010000000d, + 'EraseEof': 0x00100000405, + 'Escape': 0x0010000001b, + 'ExSel': 0x00100000406, + 'Execute': 0x00100000506, + 'Exit': 0x00100000d15, + 'F1': 0x00100000801, + 'F10': 0x0010000080a, + 'F11': 0x0010000080b, + 'F12': 0x0010000080c, + 'F13': 0x0010000080d, + 'F14': 0x0010000080e, + 'F15': 0x0010000080f, + 'F16': 0x00100000810, + 'F17': 0x00100000811, + 'F18': 0x00100000812, + 'F19': 0x00100000813, + 'F2': 0x00100000802, + 'F20': 0x00100000814, + 'F21': 0x00100000815, + 'F22': 0x00100000816, + 'F23': 0x00100000817, + 'F24': 0x00100000818, + 'F3': 0x00100000803, + 'F4': 0x00100000804, + 'F5': 0x00100000805, + 'F6': 0x00100000806, + 'F7': 0x00100000807, + 'F8': 0x00100000808, + 'F9': 0x00100000809, + 'FavoriteClear0': 0x00100000d16, + 'FavoriteClear1': 0x00100000d17, + 'FavoriteClear2': 0x00100000d18, + 'FavoriteClear3': 0x00100000d19, + 'FavoriteRecall0': 0x00100000d1a, + 'FavoriteRecall1': 0x00100000d1b, + 'FavoriteRecall2': 0x00100000d1c, + 'FavoriteRecall3': 0x00100000d1d, + 'FavoriteStore0': 0x00100000d1e, + 'FavoriteStore1': 0x00100000d1f, + 'FavoriteStore2': 0x00100000d20, + 'FavoriteStore3': 0x00100000d21, + 'FinalMode': 0x00100000706, + 'Find': 0x00100000507, + 'Fn': 0x00100000106, + 'FnLock': 0x00100000107, + 'GoBack': 0x00100001005, + 'GoHome': 0x00100001006, + 'GroupFirst': 0x00100000707, + 'GroupLast': 0x00100000708, + 'GroupNext': 0x00100000709, + 'GroupPrevious': 0x0010000070a, + 'Guide': 0x00100000d22, + 'GuideNextDay': 0x00100000d23, + 'GuidePreviousDay': 0x00100000d24, + 'HangulMode': 0x00100000711, + 'HanjaMode': 0x00100000712, + 'Hankaku': 0x00100000715, + 'HeadsetHook': 0x00100001007, + 'Help': 0x00100000508, + 'Hibernate': 0x00100000609, + 'Hiragana': 0x00100000716, + 'HiraganaKatakana': 0x00100000717, + 'Home': 0x00100000306, + 'Hyper': 0x00100000108, + 'Info': 0x00100000d25, + 'Insert': 0x00100000407, + 'InstantReplay': 0x00100000d26, + 'JunjaMode': 0x00100000713, + 'KanaMode': 0x00100000718, + 'KanjiMode': 0x00100000719, + 'Katakana': 0x0010000071a, + 'Key11': 0x00100001201, + 'Key12': 0x00100001202, + 'LastNumberRedial': 0x00100001008, + 'LaunchApplication1': 0x00100000b06, + 'LaunchApplication2': 0x00100000b01, + 'LaunchAssistant': 0x00100000b0e, + 'LaunchCalendar': 0x00100000b02, + 'LaunchContacts': 0x00100000b0c, + 'LaunchControlPanel': 0x00100000b0f, + 'LaunchMail': 0x00100000b03, + 'LaunchMediaPlayer': 0x00100000b04, + 'LaunchMusicPlayer': 0x00100000b05, + 'LaunchPhone': 0x00100000b0d, + 'LaunchScreenSaver': 0x00100000b07, + 'LaunchSpreadsheet': 0x00100000b08, + 'LaunchWebBrowser': 0x00100000b09, + 'LaunchWebCam': 0x00100000b0a, + 'LaunchWordProcessor': 0x00100000b0b, + 'Link': 0x00100000d27, + 'ListProgram': 0x00100000d28, + 'LiveContent': 0x00100000d29, + 'Lock': 0x00100000d2a, + 'LogOff': 0x00100000605, + 'MailForward': 0x00100000a02, + 'MailReply': 0x00100000a03, + 'MailSend': 0x00100000a04, + 'MannerMode': 0x0010000100a, + 'MediaApps': 0x00100000d2b, + 'MediaAudioTrack': 0x00100000d50, + 'MediaClose': 0x00100000d5b, + 'MediaFastForward': 0x00100000d2c, + 'MediaLast': 0x00100000d2d, + 'MediaPause': 0x00100000d2e, + 'MediaPlay': 0x00100000d2f, + 'MediaPlayPause': 0x00100000a05, + 'MediaRecord': 0x00100000d30, + 'MediaRewind': 0x00100000d31, + 'MediaSkip': 0x00100000d32, + 'MediaSkipBackward': 0x00100000d51, + 'MediaSkipForward': 0x00100000d52, + 'MediaStepBackward': 0x00100000d53, + 'MediaStepForward': 0x00100000d54, + 'MediaStop': 0x00100000a07, + 'MediaTopMenu': 0x00100000d55, + 'MediaTrackNext': 0x00100000a08, + 'MediaTrackPrevious': 0x00100000a09, + 'MicrophoneToggle': 0x00100000e06, + 'MicrophoneVolumeDown': 0x00100000e07, + 'MicrophoneVolumeMute': 0x00100000e09, + 'MicrophoneVolumeUp': 0x00100000e08, + 'ModeChange': 0x0010000070b, + 'NavigateIn': 0x00100000d56, + 'NavigateNext': 0x00100000d57, + 'NavigateOut': 0x00100000d58, + 'NavigatePrevious': 0x00100000d59, + 'New': 0x00100000a0a, + 'NextCandidate': 0x0010000070c, + 'NextFavoriteChannel': 0x00100000d33, + 'NextUserProfile': 0x00100000d34, + 'NonConvert': 0x0010000070d, + 'Notification': 0x00100001009, + 'NumLock': 0x0010000010a, + 'OnDemand': 0x00100000d35, + 'Open': 0x00100000a0b, + 'PageDown': 0x00100000307, + 'PageUp': 0x00100000308, + 'Pairing': 0x00100000d5a, + 'Paste': 0x00100000408, + 'Pause': 0x00100000509, + 'PinPDown': 0x00100000d36, + 'PinPMove': 0x00100000d37, + 'PinPToggle': 0x00100000d38, + 'PinPUp': 0x00100000d39, + 'Play': 0x0010000050a, + 'PlaySpeedDown': 0x00100000d3a, + 'PlaySpeedReset': 0x00100000d3b, + 'PlaySpeedUp': 0x00100000d3c, + 'Power': 0x00100000606, + 'PowerOff': 0x00100000607, + 'PreviousCandidate': 0x0010000070e, + 'Print': 0x00100000a0c, + 'PrintScreen': 0x00100000608, + 'Process': 0x0010000070f, + 'Props': 0x0010000050b, + 'RandomToggle': 0x00100000d3d, + 'RcLowBattery': 0x00100000d3e, + 'RecordSpeedNext': 0x00100000d3f, + 'Redo': 0x00100000409, + 'RfBypass': 0x00100000d40, + 'Romaji': 0x0010000071b, + 'STBInput': 0x00100000d45, + 'STBPower': 0x00100000d46, + 'Save': 0x00100000a0d, + 'ScanChannelsToggle': 0x00100000d41, + 'ScreenModeNext': 0x00100000d42, + 'ScrollLock': 0x0010000010c, + 'Select': 0x0010000050c, + 'Settings': 0x00100000d43, + 'ShiftLevel5': 0x00100000111, + 'SingleCandidate': 0x00100000710, + 'Soft1': 0x00100000901, + 'Soft2': 0x00100000902, + 'Soft3': 0x00100000903, + 'Soft4': 0x00100000904, + 'Soft5': 0x00100000905, + 'Soft6': 0x00100000906, + 'Soft7': 0x00100000907, + 'Soft8': 0x00100000908, + 'SpeechCorrectionList': 0x00100000f01, + 'SpeechInputToggle': 0x00100000f02, + 'SpellCheck': 0x00100000a0e, + 'SplitScreenToggle': 0x00100000d44, + 'Standby': 0x0010000060a, + 'Subtitle': 0x00100000d47, + 'Super': 0x0010000010e, + 'Symbol': 0x0010000010f, + 'SymbolLock': 0x00100000110, + 'TV': 0x00100000d49, + 'TV3DMode': 0x00100001101, + 'TVAntennaCable': 0x00100001102, + 'TVAudioDescription': 0x00100001103, + 'TVAudioDescriptionMixDown': 0x00100001104, + 'TVAudioDescriptionMixUp': 0x00100001105, + 'TVContentsMenu': 0x00100001106, + 'TVDataService': 0x00100001107, + 'TVInput': 0x00100000d4a, + 'TVInputComponent1': 0x00100001108, + 'TVInputComponent2': 0x00100001109, + 'TVInputComposite1': 0x0010000110a, + 'TVInputComposite2': 0x0010000110b, + 'TVInputHDMI1': 0x0010000110c, + 'TVInputHDMI2': 0x0010000110d, + 'TVInputHDMI3': 0x0010000110e, + 'TVInputHDMI4': 0x0010000110f, + 'TVInputVGA1': 0x00100001110, + 'TVMediaContext': 0x00100001111, + 'TVNetwork': 0x00100001112, + 'TVNumberEntry': 0x00100001113, + 'TVPower': 0x00100000d4b, + 'TVRadioService': 0x00100001114, + 'TVSatellite': 0x00100001115, + 'TVSatelliteBS': 0x00100001116, + 'TVSatelliteCS': 0x00100001117, + 'TVSatelliteToggle': 0x00100001118, + 'TVTerrestrialAnalog': 0x00100001119, + 'TVTerrestrialDigital': 0x0010000111a, + 'TVTimer': 0x0010000111b, + 'Tab': 0x00100000009, + 'Teletext': 0x00100000d48, + 'Undo': 0x0010000040a, + 'Unidentified': 0x00100000001, + 'VideoModeNext': 0x00100000d4c, + 'VoiceDial': 0x0010000100b, + 'WakeUp': 0x0010000060b, + 'Wink': 0x00100000d4d, + 'Zenkaku': 0x0010000071c, + 'ZenkakuHankaku': 0x0010000071d, + 'ZoomIn': 0x0010000050d, + 'ZoomOut': 0x0010000050e, + 'ZoomToggle': 0x00100000d4e, }; /// Maps Web KeyboardEvent codes to the matching PhysicalKeyboardKey USB HID code. const Map kWebToPhysicalKey = { - 'None': 0x00000000, - 'Hyper': 0x00000010, - 'Super': 0x00000011, - 'FnLock': 0x00000013, - 'Suspend': 0x00000014, - 'Resume': 0x00000015, - 'Turbo': 0x00000016, - 'PrivacyScreenToggle': 0x00000017, - 'Sleep': 0x00010082, - 'WakeUp': 0x00010083, - 'DisplayToggleIntExt': 0x000100b5, - 'KeyA': 0x00070004, - 'KeyB': 0x00070005, - 'KeyC': 0x00070006, - 'KeyD': 0x00070007, - 'KeyE': 0x00070008, - 'KeyF': 0x00070009, - 'KeyG': 0x0007000a, - 'KeyH': 0x0007000b, - 'KeyI': 0x0007000c, - 'KeyJ': 0x0007000d, - 'KeyK': 0x0007000e, - 'KeyL': 0x0007000f, - 'KeyM': 0x00070010, - 'KeyN': 0x00070011, - 'KeyO': 0x00070012, - 'KeyP': 0x00070013, - 'KeyQ': 0x00070014, - 'KeyR': 0x00070015, - 'KeyS': 0x00070016, - 'KeyT': 0x00070017, - 'KeyU': 0x00070018, - 'KeyV': 0x00070019, - 'KeyW': 0x0007001a, - 'KeyX': 0x0007001b, - 'KeyY': 0x0007001c, - 'KeyZ': 0x0007001d, - 'Digit1': 0x0007001e, - 'Digit2': 0x0007001f, - 'Digit3': 0x00070020, - 'Digit4': 0x00070021, - 'Digit5': 0x00070022, - 'Digit6': 0x00070023, - 'Digit7': 0x00070024, - 'Digit8': 0x00070025, - 'Digit9': 0x00070026, - 'Digit0': 0x00070027, - 'Enter': 0x00070028, - 'Escape': 0x00070029, - 'Backspace': 0x0007002a, - 'Tab': 0x0007002b, - 'Space': 0x0007002c, - 'Minus': 0x0007002d, - 'Equal': 0x0007002e, - 'BracketLeft': 0x0007002f, - 'BracketRight': 0x00070030, - 'Backslash': 0x00070031, - 'Semicolon': 0x00070033, - 'Quote': 0x00070034, - 'Backquote': 0x00070035, - 'Comma': 0x00070036, - 'Period': 0x00070037, - 'Slash': 0x00070038, - 'CapsLock': 0x00070039, - 'F1': 0x0007003a, - 'F2': 0x0007003b, - 'F3': 0x0007003c, - 'F4': 0x0007003d, - 'F5': 0x0007003e, - 'F6': 0x0007003f, - 'F7': 0x00070040, - 'F8': 0x00070041, - 'F9': 0x00070042, - 'F10': 0x00070043, - 'F11': 0x00070044, - 'F12': 0x00070045, - 'PrintScreen': 0x00070046, - 'ScrollLock': 0x00070047, - 'Pause': 0x00070048, - 'Insert': 0x00070049, - 'Home': 0x0007004a, - 'PageUp': 0x0007004b, - 'Delete': 0x0007004c, - 'End': 0x0007004d, - 'PageDown': 0x0007004e, - 'ArrowRight': 0x0007004f, - 'ArrowLeft': 0x00070050, - 'ArrowDown': 0x00070051, - 'ArrowUp': 0x00070052, - 'NumLock': 0x00070053, - 'NumpadDivide': 0x00070054, - 'NumpadMultiply': 0x00070055, - 'NumpadSubtract': 0x00070056, - 'NumpadAdd': 0x00070057, - 'NumpadEnter': 0x00070058, - 'Numpad1': 0x00070059, - 'Numpad2': 0x0007005a, - 'Numpad3': 0x0007005b, - 'Numpad4': 0x0007005c, - 'Numpad5': 0x0007005d, - 'Numpad6': 0x0007005e, - 'Numpad7': 0x0007005f, - 'Numpad8': 0x00070060, - 'Numpad9': 0x00070061, - 'Numpad0': 0x00070062, - 'NumpadDecimal': 0x00070063, - 'IntlBackslash': 0x00070064, - 'ContextMenu': 0x00070065, - 'Power': 0x00070066, - 'NumpadEqual': 0x00070067, - 'F13': 0x00070068, - 'F14': 0x00070069, - 'F15': 0x0007006a, - 'F16': 0x0007006b, - 'F17': 0x0007006c, - 'F18': 0x0007006d, - 'F19': 0x0007006e, - 'F20': 0x0007006f, - 'F21': 0x00070070, - 'F22': 0x00070071, - 'F23': 0x00070072, - 'F24': 0x00070073, - 'Open': 0x00070074, - 'Help': 0x00070075, - 'Select': 0x00070077, - 'Again': 0x00070079, - 'Undo': 0x0007007a, - 'Cut': 0x0007007b, - 'Copy': 0x0007007c, - 'Paste': 0x0007007d, - 'Find': 0x0007007e, - 'AudioVolumeMute': 0x0007007f, - 'AudioVolumeUp': 0x00070080, - 'AudioVolumeDown': 0x00070081, - 'NumpadComma': 0x00070085, - 'IntlRo': 0x00070087, - 'KanaMode': 0x00070088, - 'IntlYen': 0x00070089, - 'Convert': 0x0007008a, - 'NonConvert': 0x0007008b, - 'Lang1': 0x00070090, - 'Lang2': 0x00070091, - 'Lang3': 0x00070092, - 'Lang4': 0x00070093, - 'Lang5': 0x00070094, - 'Abort': 0x0007009b, - 'Props': 0x000700a3, - 'NumpadParenLeft': 0x000700b6, - 'NumpadParenRight': 0x000700b7, - 'NumpadBackspace': 0x000700bb, - 'NumpadMemoryStore': 0x000700d0, - 'NumpadMemoryRecall': 0x000700d1, - 'NumpadMemoryClear': 0x000700d2, - 'NumpadMemoryAdd': 0x000700d3, - 'NumpadMemorySubtract': 0x000700d4, - 'NumpadClear': 0x000700d8, - 'NumpadClearEntry': 0x000700d9, - 'ControlLeft': 0x000700e0, - 'ShiftLeft': 0x000700e1, - 'AltLeft': 0x000700e2, - 'MetaLeft': 0x000700e3, - 'ControlRight': 0x000700e4, - 'ShiftRight': 0x000700e5, - 'AltRight': 0x000700e6, - 'MetaRight': 0x000700e7, - 'BrightnessUp': 0x000c006f, - 'BrightnessDown': 0x000c0070, - 'MediaPlay': 0x000c00b0, - 'MediaPause': 0x000c00b1, - 'MediaRecord': 0x000c00b2, - 'MediaFastForward': 0x000c00b3, - 'MediaRewind': 0x000c00b4, - 'MediaTrackNext': 0x000c00b5, - 'MediaTrackPrevious': 0x000c00b6, - 'MediaStop': 0x000c00b7, - 'Eject': 0x000c00b8, - 'MediaPlayPause': 0x000c00cd, - 'MediaSelect': 0x000c0183, - 'LaunchMail': 0x000c018a, - 'LaunchApp2': 0x000c0192, - 'LaunchApp1': 0x000c0194, - 'LaunchControlPanel': 0x000c019f, - 'SelectTask': 0x000c01a2, - 'LaunchScreenSaver': 0x000c01b1, - 'LaunchAssistant': 0x000c01cb, - 'BrowserSearch': 0x000c0221, - 'BrowserHome': 0x000c0223, - 'BrowserBack': 0x000c0224, - 'BrowserForward': 0x000c0225, - 'BrowserStop': 0x000c0226, - 'BrowserRefresh': 0x000c0227, - 'BrowserFavorites': 0x000c022a, - 'ZoomToggle': 0x000c0232, - 'MailReply': 0x000c0289, - 'MailForward': 0x000c028b, - 'MailSend': 0x000c028c, - 'KeyboardLayoutSelect': 0x000c029d, - 'ShowAllWindows': 0x000c029f, - 'GameButton1': 0x0005ff01, - 'GameButton2': 0x0005ff02, - 'GameButton3': 0x0005ff03, - 'GameButton4': 0x0005ff04, - 'GameButton5': 0x0005ff05, - 'GameButton6': 0x0005ff06, - 'GameButton7': 0x0005ff07, - 'GameButton8': 0x0005ff08, - 'GameButton9': 0x0005ff09, - 'GameButton10': 0x0005ff0a, - 'GameButton11': 0x0005ff0b, - 'GameButton12': 0x0005ff0c, - 'GameButton13': 0x0005ff0d, - 'GameButton14': 0x0005ff0e, - 'GameButton15': 0x0005ff0f, - 'GameButton16': 0x0005ff10, - 'GameButtonA': 0x0005ff11, - 'GameButtonB': 0x0005ff12, - 'GameButtonC': 0x0005ff13, - 'GameButtonLeft1': 0x0005ff14, - 'GameButtonLeft2': 0x0005ff15, - 'GameButtonMode': 0x0005ff16, - 'GameButtonRight1': 0x0005ff17, - 'GameButtonRight2': 0x0005ff18, - 'GameButtonSelect': 0x0005ff19, - 'GameButtonStart': 0x0005ff1a, - 'GameButtonThumbLeft': 0x0005ff1b, - 'GameButtonThumbRight': 0x0005ff1c, - 'GameButtonX': 0x0005ff1d, - 'GameButtonY': 0x0005ff1e, - 'GameButtonZ': 0x0005ff1f, - 'Fn': 0x00000012, + 'Abort': 0x0007009b, // abort + 'Again': 0x00070079, // again + 'AltLeft': 0x000700e2, // altLeft + 'AltRight': 0x000700e6, // altRight + 'ArrowDown': 0x00070051, // arrowDown + 'ArrowLeft': 0x00070050, // arrowLeft + 'ArrowRight': 0x0007004f, // arrowRight + 'ArrowUp': 0x00070052, // arrowUp + 'AudioVolumeDown': 0x00070081, // audioVolumeDown + 'AudioVolumeMute': 0x0007007f, // audioVolumeMute + 'AudioVolumeUp': 0x00070080, // audioVolumeUp + 'Backquote': 0x00070035, // backquote + 'Backslash': 0x00070031, // backslash + 'Backspace': 0x0007002a, // backspace + 'BassBoost': 0x000c00e5, // bassBoost + 'BracketLeft': 0x0007002f, // bracketLeft + 'BracketRight': 0x00070030, // bracketRight + 'BrightnessAuto': 0x000c0075, // brightnessAuto + 'BrightnessDown': 0x000c0070, // brightnessDown + 'BrightnessMaximum': 0x000c0074, // brightnessMaximum + 'BrightnessMinimum': 0x000c0073, // brightnessMinimum + 'BrightnessToggle': 0x000c0072, // brightnessToggle + 'BrightnessUp': 0x000c006f, // brightnessUp + 'BrowserBack': 0x000c0224, // browserBack + 'BrowserFavorites': 0x000c022a, // browserFavorites + 'BrowserForward': 0x000c0225, // browserForward + 'BrowserHome': 0x000c0223, // browserHome + 'BrowserRefresh': 0x000c0227, // browserRefresh + 'BrowserSearch': 0x000c0221, // browserSearch + 'BrowserStop': 0x000c0226, // browserStop + 'CapsLock': 0x00070039, // capsLock + 'ChannelDown': 0x000c009d, // channelDown + 'ChannelUp': 0x000c009c, // channelUp + 'Close': 0x000c0203, // close + 'ClosedCaptionToggle': 0x000c0061, // closedCaptionToggle + 'Comma': 0x00070036, // comma + 'ContextMenu': 0x00070065, // contextMenu + 'ControlLeft': 0x000700e0, // controlLeft + 'ControlRight': 0x000700e4, // controlRight + 'Convert': 0x0007008a, // convert + 'Copy': 0x0007007c, // copy + 'Cut': 0x0007007b, // cut + 'Delete': 0x0007004c, // delete + 'Digit0': 0x00070027, // digit0 + 'Digit1': 0x0007001e, // digit1 + 'Digit2': 0x0007001f, // digit2 + 'Digit3': 0x00070020, // digit3 + 'Digit4': 0x00070021, // digit4 + 'Digit5': 0x00070022, // digit5 + 'Digit6': 0x00070023, // digit6 + 'Digit7': 0x00070024, // digit7 + 'Digit8': 0x00070025, // digit8 + 'Digit9': 0x00070026, // digit9 + 'DisplayToggleIntExt': 0x000100b5, // displayToggleIntExt + 'Eject': 0x000c00b8, // eject + 'End': 0x0007004d, // end + 'Enter': 0x00070028, // enter + 'Equal': 0x0007002e, // equal + 'Escape': 0x00070029, // escape + 'Exit': 0x000c0094, // exit + 'F1': 0x0007003a, // f1 + 'F10': 0x00070043, // f10 + 'F11': 0x00070044, // f11 + 'F12': 0x00070045, // f12 + 'F13': 0x00070068, // f13 + 'F14': 0x00070069, // f14 + 'F15': 0x0007006a, // f15 + 'F16': 0x0007006b, // f16 + 'F17': 0x0007006c, // f17 + 'F18': 0x0007006d, // f18 + 'F19': 0x0007006e, // f19 + 'F2': 0x0007003b, // f2 + 'F20': 0x0007006f, // f20 + 'F21': 0x00070070, // f21 + 'F22': 0x00070071, // f22 + 'F23': 0x00070072, // f23 + 'F24': 0x00070073, // f24 + 'F3': 0x0007003c, // f3 + 'F4': 0x0007003d, // f4 + 'F5': 0x0007003e, // f5 + 'F6': 0x0007003f, // f6 + 'F7': 0x00070040, // f7 + 'F8': 0x00070041, // f8 + 'F9': 0x00070042, // f9 + 'Find': 0x0007007e, // find + 'Fn': 0x00000012, // fn + 'FnLock': 0x00000013, // fnLock + 'GameButton1': 0x0005ff01, // gameButton1 + 'GameButton10': 0x0005ff0a, // gameButton10 + 'GameButton11': 0x0005ff0b, // gameButton11 + 'GameButton12': 0x0005ff0c, // gameButton12 + 'GameButton13': 0x0005ff0d, // gameButton13 + 'GameButton14': 0x0005ff0e, // gameButton14 + 'GameButton15': 0x0005ff0f, // gameButton15 + 'GameButton16': 0x0005ff10, // gameButton16 + 'GameButton2': 0x0005ff02, // gameButton2 + 'GameButton3': 0x0005ff03, // gameButton3 + 'GameButton4': 0x0005ff04, // gameButton4 + 'GameButton5': 0x0005ff05, // gameButton5 + 'GameButton6': 0x0005ff06, // gameButton6 + 'GameButton7': 0x0005ff07, // gameButton7 + 'GameButton8': 0x0005ff08, // gameButton8 + 'GameButton9': 0x0005ff09, // gameButton9 + 'GameButtonA': 0x0005ff11, // gameButtonA + 'GameButtonB': 0x0005ff12, // gameButtonB + 'GameButtonC': 0x0005ff13, // gameButtonC + 'GameButtonLeft1': 0x0005ff14, // gameButtonLeft1 + 'GameButtonLeft2': 0x0005ff15, // gameButtonLeft2 + 'GameButtonMode': 0x0005ff16, // gameButtonMode + 'GameButtonRight1': 0x0005ff17, // gameButtonRight1 + 'GameButtonRight2': 0x0005ff18, // gameButtonRight2 + 'GameButtonSelect': 0x0005ff19, // gameButtonSelect + 'GameButtonStart': 0x0005ff1a, // gameButtonStart + 'GameButtonThumbLeft': 0x0005ff1b, // gameButtonThumbLeft + 'GameButtonThumbRight': 0x0005ff1c, // gameButtonThumbRight + 'GameButtonX': 0x0005ff1d, // gameButtonX + 'GameButtonY': 0x0005ff1e, // gameButtonY + 'GameButtonZ': 0x0005ff1f, // gameButtonZ + 'Help': 0x00070075, // help + 'Home': 0x0007004a, // home + 'Hyper': 0x00000010, // hyper + 'Info': 0x000c0060, // info + 'Insert': 0x00070049, // insert + 'IntlBackslash': 0x00070064, // intlBackslash + 'IntlRo': 0x00070087, // intlRo + 'IntlYen': 0x00070089, // intlYen + 'KanaMode': 0x00070088, // kanaMode + 'KbdIllumDown': 0x000c007a, // kbdIllumDown + 'KbdIllumUp': 0x000c0079, // kbdIllumUp + 'KeyA': 0x00070004, // keyA + 'KeyB': 0x00070005, // keyB + 'KeyC': 0x00070006, // keyC + 'KeyD': 0x00070007, // keyD + 'KeyE': 0x00070008, // keyE + 'KeyF': 0x00070009, // keyF + 'KeyG': 0x0007000a, // keyG + 'KeyH': 0x0007000b, // keyH + 'KeyI': 0x0007000c, // keyI + 'KeyJ': 0x0007000d, // keyJ + 'KeyK': 0x0007000e, // keyK + 'KeyL': 0x0007000f, // keyL + 'KeyM': 0x00070010, // keyM + 'KeyN': 0x00070011, // keyN + 'KeyO': 0x00070012, // keyO + 'KeyP': 0x00070013, // keyP + 'KeyQ': 0x00070014, // keyQ + 'KeyR': 0x00070015, // keyR + 'KeyS': 0x00070016, // keyS + 'KeyT': 0x00070017, // keyT + 'KeyU': 0x00070018, // keyU + 'KeyV': 0x00070019, // keyV + 'KeyW': 0x0007001a, // keyW + 'KeyX': 0x0007001b, // keyX + 'KeyY': 0x0007001c, // keyY + 'KeyZ': 0x0007001d, // keyZ + 'KeyboardLayoutSelect': 0x000c029d, // keyboardLayoutSelect + 'Lang1': 0x00070090, // lang1 + 'Lang2': 0x00070091, // lang2 + 'Lang3': 0x00070092, // lang3 + 'Lang4': 0x00070093, // lang4 + 'Lang5': 0x00070094, // lang5 + 'LaunchApp1': 0x000c0194, // launchApp1 + 'LaunchApp2': 0x000c0192, // launchApp2 + 'LaunchAssistant': 0x000c01cb, // launchAssistant + 'LaunchAudioBrowser': 0x000c01b7, // launchAudioBrowser + 'LaunchCalendar': 0x000c018e, // launchCalendar + 'LaunchContacts': 0x000c018d, // launchContacts + 'LaunchControlPanel': 0x000c019f, // launchControlPanel + 'LaunchDocuments': 0x000c01a7, // launchDocuments + 'LaunchInternetBrowser': 0x000c0196, // launchInternetBrowser + 'LaunchKeyboardLayout': 0x000c01ae, // launchKeyboardLayout + 'LaunchMail': 0x000c018a, // launchMail + 'LaunchPhone': 0x000c008c, // launchPhone + 'LaunchScreenSaver': 0x000c01b1, // launchScreenSaver + 'LaunchSpreadsheet': 0x000c0186, // launchSpreadsheet + 'LaunchWordProcessor': 0x000c0184, // launchWordProcessor + 'LockScreen': 0x000c019e, // lockScreen + 'LogOff': 0x000c019c, // logOff + 'MailForward': 0x000c028b, // mailForward + 'MailReply': 0x000c0289, // mailReply + 'MailSend': 0x000c028c, // mailSend + 'MediaFastForward': 0x000c00b3, // mediaFastForward + 'MediaLast': 0x000c0083, // mediaLast + 'MediaPause': 0x000c00b1, // mediaPause + 'MediaPlay': 0x000c00b0, // mediaPlay + 'MediaPlayPause': 0x000c00cd, // mediaPlayPause + 'MediaRecord': 0x000c00b2, // mediaRecord + 'MediaRewind': 0x000c00b4, // mediaRewind + 'MediaSelect': 0x000c0183, // mediaSelect + 'MediaStop': 0x000c00b7, // mediaStop + 'MediaTrackNext': 0x000c00b5, // mediaTrackNext + 'MediaTrackPrevious': 0x000c00b6, // mediaTrackPrevious + 'MetaLeft': 0x000700e3, // metaLeft + 'MetaRight': 0x000700e7, // metaRight + 'Minus': 0x0007002d, // minus + 'New': 0x000c0201, // newKey + 'NonConvert': 0x0007008b, // nonConvert + 'NumLock': 0x00070053, // numLock + 'Numpad0': 0x00070062, // numpad0 + 'Numpad1': 0x00070059, // numpad1 + 'Numpad2': 0x0007005a, // numpad2 + 'Numpad3': 0x0007005b, // numpad3 + 'Numpad4': 0x0007005c, // numpad4 + 'Numpad5': 0x0007005d, // numpad5 + 'Numpad6': 0x0007005e, // numpad6 + 'Numpad7': 0x0007005f, // numpad7 + 'Numpad8': 0x00070060, // numpad8 + 'Numpad9': 0x00070061, // numpad9 + 'NumpadAdd': 0x00070057, // numpadAdd + 'NumpadBackspace': 0x000700bb, // numpadBackspace + 'NumpadClear': 0x000700d8, // numpadClear + 'NumpadClearEntry': 0x000700d9, // numpadClearEntry + 'NumpadComma': 0x00070085, // numpadComma + 'NumpadDecimal': 0x00070063, // numpadDecimal + 'NumpadDivide': 0x00070054, // numpadDivide + 'NumpadEnter': 0x00070058, // numpadEnter + 'NumpadEqual': 0x00070067, // numpadEqual + 'NumpadMemoryAdd': 0x000700d3, // numpadMemoryAdd + 'NumpadMemoryClear': 0x000700d2, // numpadMemoryClear + 'NumpadMemoryRecall': 0x000700d1, // numpadMemoryRecall + 'NumpadMemoryStore': 0x000700d0, // numpadMemoryStore + 'NumpadMemorySubtract': 0x000700d4, // numpadMemorySubtract + 'NumpadMultiply': 0x00070055, // numpadMultiply + 'NumpadParenLeft': 0x000700b6, // numpadParenLeft + 'NumpadParenRight': 0x000700b7, // numpadParenRight + 'NumpadSignChange': 0x000700d7, // numpadSignChange + 'NumpadSubtract': 0x00070056, // numpadSubtract + 'Open': 0x00070074, // open + 'PageDown': 0x0007004e, // pageDown + 'PageUp': 0x0007004b, // pageUp + 'Paste': 0x0007007d, // paste + 'Pause': 0x00070048, // pause + 'Period': 0x00070037, // period + 'Power': 0x00070066, // power + 'Print': 0x000c0208, // print + 'PrintScreen': 0x00070046, // printScreen + 'PrivacyScreenToggle': 0x00000017, // privacyScreenToggle + 'ProgramGuide': 0x000c008d, // programGuide + 'Props': 0x000700a3, // props + 'Quote': 0x00070034, // quote + 'Redo': 0x000c0279, // redo + 'Resume': 0x00000015, // resume + 'Save': 0x000c0207, // save + 'ScrollLock': 0x00070047, // scrollLock + 'Select': 0x00070077, // select + 'SelectTask': 0x000c01a2, // selectTask + 'Semicolon': 0x00070033, // semicolon + 'ShiftLeft': 0x000700e1, // shiftLeft + 'ShiftRight': 0x000700e5, // shiftRight + 'ShowAllWindows': 0x000c029f, // showAllWindows + 'Slash': 0x00070038, // slash + 'Sleep': 0x00010082, // sleep + 'Space': 0x0007002c, // space + 'SpeechInputToggle': 0x000c00cf, // speechInputToggle + 'SpellCheck': 0x000c01ab, // spellCheck + 'Super': 0x00000011, // superKey + 'Suspend': 0x00000014, // suspend + 'Tab': 0x0007002b, // tab + 'Turbo': 0x00000016, // turbo + 'Undo': 0x0007007a, // undo + 'UsbErrorRollOver': 0x00070001, // usbErrorRollOver + 'UsbErrorUndefined': 0x00070003, // usbErrorUndefined + 'UsbPostFail': 0x00070002, // usbPostFail + 'UsbReserved': 0x00070000, // usbReserved + 'WakeUp': 0x00010083, // wakeUp + 'ZoomIn': 0x000c022d, // zoomIn + 'ZoomOut': 0x000c022e, // zoomOut + 'ZoomToggle': 0x000c0232, // zoomToggle }; /// Maps Web KeyboardEvent keys to Flutter logical IDs that depend on locations. @@ -669,35 +594,35 @@ const Map kWebToPhysicalKey = { /// * 2: Right /// * 3: Numpad const Map> kWebLogicalLocationMap = >{ - '0': [0x0000000030, null, null, 0x0200000030], - '1': [0x0000000031, null, null, 0x0200000031], - '2': [0x0000000032, null, null, 0x0200000032], - '3': [0x0000000033, null, null, 0x0200000033], - '4': [0x0000000034, null, null, 0x0200000034], - '5': [0x0000000035, null, null, 0x0200000035], - '6': [0x0000000036, null, null, 0x0200000036], - '7': [0x0000000037, null, null, 0x0200000037], - '8': [0x0000000038, null, null, 0x0200000038], - '9': [0x0000000039, null, null, 0x0200000039], - '.': [0x000000002e, null, null, 0x020000002e], - 'Insert': [0x0000000407, null, null, 0x0200000030], - 'End': [0x0000000305, null, null, 0x0200000031], - 'ArrowDown': [0x0000000301, null, null, 0x0200000032], - 'PageDown': [0x0000000307, null, null, 0x0200000033], - 'ArrowLeft': [0x0000000302, null, null, 0x0200000034], - 'Clear': [0x0000000401, null, null, 0x0200000035], - 'ArrowRight': [0x0000000303, null, null, 0x0200000036], - 'Home': [0x0000000306, null, null, 0x0200000037], - 'ArrowUp': [0x0000000304, null, null, 0x0200000038], - 'PageUp': [0x0000000308, null, null, 0x0200000039], - 'Delete': [0x000000007f, null, null, 0x020000002e], - '/': [0x000000002f, null, null, 0x020000002f], - '*': [0x000000002a, null, null, 0x020000002a], - '-': [0x000000002d, null, null, 0x020000002d], - '+': [0x000000002b, null, null, 0x020000002b], - 'Enter': [0x000000000d, null, null, 0x020000000d], - 'Shift': [null, 0x030000010d, 0x040000010d, null], - 'Control': [null, 0x0300000105, 0x0400000105, null], - 'Alt': [null, 0x0300000102, 0x0400000102, null], - 'Meta': [null, 0x0300000109, 0x0400000109, null], + '*': [0x0000000002a, null, null, 0x0020000022a], // asterisk, null, null, numpadMultiply + '+': [0x0000000002b, null, null, 0x0020000022b], // add, null, null, numpadAdd + '-': [0x0000000002d, null, null, 0x0020000022d], // minus, null, null, numpadSubtract + '.': [0x0000000002e, null, null, 0x0020000022e], // period, null, null, numpadDecimal + '/': [0x0000000002f, null, null, 0x0020000022f], // slash, null, null, numpadDivide + '0': [0x00000000030, null, null, 0x00200000230], // digit0, null, null, numpad0 + '1': [0x00000000031, null, null, 0x00200000231], // digit1, null, null, numpad1 + '2': [0x00000000032, null, null, 0x00200000232], // digit2, null, null, numpad2 + '3': [0x00000000033, null, null, 0x00200000233], // digit3, null, null, numpad3 + '4': [0x00000000034, null, null, 0x00200000234], // digit4, null, null, numpad4 + '5': [0x00000000035, null, null, 0x00200000235], // digit5, null, null, numpad5 + '6': [0x00000000036, null, null, 0x00200000236], // digit6, null, null, numpad6 + '7': [0x00000000037, null, null, 0x00200000237], // digit7, null, null, numpad7 + '8': [0x00000000038, null, null, 0x00200000238], // digit8, null, null, numpad8 + '9': [0x00000000039, null, null, 0x00200000239], // digit9, null, null, numpad9 + 'Alt': [null, 0x00200000104, 0x00200000105, null], // null, altLeft, altRight, null + 'ArrowDown': [0x00100000301, null, null, 0x00200000232], // arrowDown, null, null, numpad2 + 'ArrowLeft': [0x00100000302, null, null, 0x00200000234], // arrowLeft, null, null, numpad4 + 'ArrowRight': [0x00100000303, null, null, 0x00200000236], // arrowRight, null, null, numpad6 + 'ArrowUp': [0x00100000304, null, null, 0x00200000238], // arrowUp, null, null, numpad8 + 'Clear': [0x00100000401, null, null, 0x00200000235], // clear, null, null, numpad5 + 'Control': [null, 0x00200000100, 0x00200000101, null], // null, controlLeft, controlRight, null + 'Delete': [0x0010000007f, null, null, 0x0020000022e], // delete, null, null, numpadDecimal + 'End': [0x00100000305, null, null, 0x00200000231], // end, null, null, numpad1 + 'Enter': [0x0010000000d, null, null, 0x0020000020d], // enter, null, null, numpadEnter + 'Home': [0x00100000306, null, null, 0x00200000237], // home, null, null, numpad7 + 'Insert': [0x00100000407, null, null, 0x00200000230], // insert, null, null, numpad0 + 'Meta': [null, 0x00200000106, 0x00200000107, null], // null, metaLeft, metaRight, null + 'PageDown': [0x00100000307, null, null, 0x00200000233], // pageDown, null, null, numpad3 + 'PageUp': [0x00100000308, null, null, 0x00200000239], // pageUp, null, null, numpad9 + 'Shift': [null, 0x00200000102, 0x00200000103, null], // null, shiftLeft, shiftRight, null }; diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/keyboard_binding.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/keyboard_binding.dart index 9a32d3ea1d..b84bc6604d 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/keyboard_binding.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/keyboard_binding.dart @@ -19,14 +19,17 @@ typedef _ModifierGetter = bool Function(FlutterHtmlKeyboardEvent event); // Set this flag to true to see all the fired events in the console. const bool _debugLogKeyEvents = false; -const int _kLogicalAltLeft = 0x0300000102; -const int _kLogicalAltRight = 0x0400000102; -const int _kLogicalControlLeft = 0x0300000105; -const int _kLogicalControlRight = 0x0400000105; -const int _kLogicalShiftLeft = 0x030000010d; -const int _kLogicalShiftRight = 0x040000010d; -const int _kLogicalMetaLeft = 0x0300000109; -const int _kLogicalMetaRight = 0x0400000109; +const int _kLocationLeft = 1; +const int _kLocationRight = 2; + +final int _kLogicalAltLeft = kWebLogicalLocationMap['Alt']![_kLocationLeft]!; +final int _kLogicalAltRight = kWebLogicalLocationMap['Alt']![_kLocationRight]!; +final int _kLogicalControlLeft = kWebLogicalLocationMap['Control']![_kLocationLeft]!; +final int _kLogicalControlRight = kWebLogicalLocationMap['Control']![_kLocationRight]!; +final int _kLogicalShiftLeft = kWebLogicalLocationMap['Shift']![_kLocationLeft]!; +final int _kLogicalShiftRight = kWebLogicalLocationMap['Shift']![_kLocationRight]!; +final int _kLogicalMetaLeft = kWebLogicalLocationMap['Meta']![_kLocationLeft]!; +final int _kLogicalMetaRight = kWebLogicalLocationMap['Meta']![_kLocationRight]!; // Map logical keys for modifier keys to the functions that can get their // modifier flag out of an event. final Map _kLogicalKeyToModifierGetter = { @@ -62,17 +65,16 @@ const String _kPhysicalCapsLock = 'CapsLock'; const String _kLogicalDead = 'Dead'; -const int _kWebKeyIdPlane = 0x00800000000; -const int _kAutogeneratedMask = 0x10000000000; +const int _kWebKeyIdPlane = 0x1700000000; // Bits in a Flutter logical event to generate the logical key for dead keys. // // Logical keys for dead keys are generated by annotating physical keys with // modifiers (see `_getLogicalCode`). -const int _kDeadKeyCtrl = 0x100000000000; -const int _kDeadKeyShift = 0x200000000000; -const int _kDeadKeyAlt = 0x400000000000; -const int _kDeadKeyMeta = 0x800000000000; +const int _kDeadKeyCtrl = 0x10000000; +const int _kDeadKeyShift = 0x20000000; +const int _kDeadKeyAlt = 0x40000000; +const int _kDeadKeyMeta = 0x80000000; typedef DispatchKeyData = bool Function(ui.KeyData data); @@ -213,7 +215,7 @@ class KeyboardConverter { Duration get _keydownCancelDuration => onMacOs ? _kKeydownCancelDurationMacOs : _kKeydownCancelDurationNormal; static int _getPhysicalCode(String code) { - return kWebToPhysicalKey[code] ?? (code.hashCode + _kWebKeyIdPlane + _kAutogeneratedMask); + return kWebToPhysicalKey[code] ?? (code.hashCode + _kWebKeyIdPlane); } static int _getModifierMask(FlutterHtmlKeyboardEvent event) { @@ -258,11 +260,11 @@ class KeyboardConverter { // // Assume they can be told apart with the physical key and the modifiers // pressed. - return physicalKey + _getModifierMask(event) + _kWebKeyIdPlane + _kAutogeneratedMask; + return physicalKey + _getModifierMask(event) + _kWebKeyIdPlane; } static int _otherLogicalKey(String key) { - return kWebToLogicalKey[key] ?? (key.hashCode + _kWebKeyIdPlane + _kAutogeneratedMask); + return kWebToLogicalKey[key] ?? (key.hashCode + _kWebKeyIdPlane); } // Map from pressed physical key to corresponding pressed logical key. diff --git a/engine/src/flutter/lib/web_ui/test/keyboard_converter_test.dart b/engine/src/flutter/lib/web_ui/test/keyboard_converter_test.dart index f7127ab29b..5f32232f93 100644 --- a/engine/src/flutter/lib/web_ui/test/keyboard_converter_test.dart +++ b/engine/src/flutter/lib/web_ui/test/keyboard_converter_test.dart @@ -5,7 +5,7 @@ import 'package:quiver/testing/async.dart'; import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; -import 'package:ui/src/engine/keyboard_binding.dart'; +import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' as ui; import 'package:meta/meta.dart' show isTest; @@ -13,28 +13,28 @@ const int kLocationLeft = 1; const int kLocationRight = 2; const int kLocationNumpad = 3; -const int kPhysicalKeyA = 0x00070004; -const int kPhysicalKeyE = 0x00070008; -const int kPhysicalKeyU = 0x00070018; -const int kPhysicalDigit1 = 0x0007001e; -const int kPhysicalNumpad1 = 0x00070059; -const int kPhysicalShiftLeft = 0x000700e1; -const int kPhysicalShiftRight = 0x000700e5; -const int kPhysicalMetaLeft = 0x000700e3; -const int kPhysicalTab = 0x0007002b; -const int kPhysicalCapsLock = 0x00070039; -const int kPhysicalScrollLock = 0x00070047; +final int kPhysicalKeyA = kWebToPhysicalKey['KeyA']!; +final int kPhysicalKeyE = kWebToPhysicalKey['KeyE']!; +final int kPhysicalKeyU = kWebToPhysicalKey['KeyU']!; +final int kPhysicalDigit1 = kWebToPhysicalKey['Digit1']!; +final int kPhysicalNumpad1 = kWebToPhysicalKey['Numpad1']!; +final int kPhysicalShiftLeft = kWebToPhysicalKey['ShiftLeft']!; +final int kPhysicalShiftRight = kWebToPhysicalKey['ShiftRight']!; +final int kPhysicalMetaLeft = kWebToPhysicalKey['MetaLeft']!; +final int kPhysicalTab = kWebToPhysicalKey['Tab']!; +final int kPhysicalCapsLock = kWebToPhysicalKey['CapsLock']!; +final int kPhysicalScrollLock = kWebToPhysicalKey['ScrollLock']!; -const int kLogicalKeyA = 0x00000000061; -const int kLogicalKeyU = 0x00000000075; -const int kLogicalDigit1 = 0x00000000031; -const int kLogicalNumpad1 = 0x00200000031; -const int kLogicalShiftLeft = 0x030000010d; -const int kLogicalShiftRight = 0x040000010d; -const int kLogicalMetaLeft = 0x0300000109; -const int kLogicalTab = 0x0000000009; -const int kLogicalCapsLock = 0x00000000104; -const int kLogicalScrollLock = 0x0000000010c; +final int kLogicalKeyA = 0x00000000061; +final int kLogicalKeyU = 0x00000000075; +final int kLogicalDigit1 = 0x00000000031; +final int kLogicalNumpad1 = kWebLogicalLocationMap['1']![kLocationNumpad]!; +final int kLogicalShiftLeft = kWebLogicalLocationMap['Shift']![kLocationLeft]!; +final int kLogicalShiftRight = kWebLogicalLocationMap['Shift']![kLocationRight]!; +final int kLogicalMetaLeft = kWebLogicalLocationMap['Meta']![kLocationLeft]!; +final int kLogicalTab = 0x0000000009; +final int kLogicalCapsLock = kWebToLogicalKey['CapsLock']!; +final int kLogicalScrollLock = kWebToLogicalKey['ScrollLock']!; typedef VoidCallback = void Function(); @@ -283,9 +283,9 @@ void testMain() { }); // The absolute values of the following logical keys are not guaranteed. - const int kLogicalAltE = 0x410800070008; - const int kLogicalAltU = 0x410800070018; - const int kLogicalAltShiftE = 0x610800070008; + const int kLogicalAltE = 0x1740070008; + const int kLogicalAltU = 0x1740070018; + const int kLogicalAltShiftE = 0x1760070008; // The values must be distinguishable. expect(kLogicalAltE, isNot(equals(kLogicalAltU))); expect(kLogicalAltE, isNot(equals(kLogicalAltShiftE))); diff --git a/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn b/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn index d9f008ff2a..100d06916d 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn +++ b/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn @@ -258,6 +258,7 @@ shared_library("ios_test_flutter") { "//flutter/lib/ui:ui", "//flutter/shell/platform/darwin/common:framework_shared", "//flutter/shell/platform/embedder:embedder_as_internal_library", + "//flutter/shell/platform/embedder:embedder_test_utils", "//flutter/third_party/tonic", "//flutter/third_party/txt", "//third_party/ocmock:ocmock_shared", diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.mm index 6c8fbf85c6..45f7639738 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.mm @@ -83,7 +83,7 @@ static uint64_t GetLogicalKeyForModifier(UInt32 keyCode, uint64_t hidCode) { if (fromKeyCode != keyCodeToLogicalKey.end()) { return fromKeyCode->second; } - return KeyOfPlane(hidCode, kHidPlane); + return KeyOfPlane(hidCode, kIosPlane); } /** @@ -180,19 +180,9 @@ static uint64_t GetLogicalKeyForEvent(FlutterUIPressProxy* press, uint64_t physi return KeyOfPlane(toLower(codeUnit), kUnicodePlane); } - // Control keys like "backspace" and movement keys like arrow keys don't have - // a printable representation, but are present on the physical keyboard. Since - // there is no logical keycode map for iOS (iOS uses the keycode to - // reference physical keys), a LogicalKeyboardKey is created with the physical - // key's HID usage and debugName. This avoids duplicating the physical key - // map. - if (physicalKey != 0) { - return KeyOfPlane(physicalKey, kHidPlane); - } - // This is a non-printable key that is unrecognized, so a new code is minted // with the autogenerated bit set. - return KeyOfPlane(press.key.keyCode, kIOSPlane | kAutogeneratedMask); + return KeyOfPlane(press.key.keyCode, kIosPlane); } /** diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponderTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponderTest.mm index 825744bd4f..6d1f45e2ba 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponderTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponderTest.mm @@ -12,6 +12,9 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterFakeKeyEvents.h" #import "flutter/shell/platform/darwin/ios/framework/Source/KeyCodeMap_Internal.h" #include "flutter/shell/platform/embedder/embedder.h" +#include "flutter/shell/platform/embedder/test_utils/key_codes.h" + +using namespace flutter::testing::keycodes; FLUTTER_ASSERT_ARC; @@ -87,24 +90,8 @@ API_AVAILABLE(ios(13.4)) constexpr UIKeyboardHIDUsage kKeyCodeAltRight = (UIKeyboardHIDUsage)0xe6; constexpr uint64_t kPhysicalKeyUndefined = 0x00070003; -constexpr uint64_t kPhysicalKeyA = 0x00070004; -constexpr uint64_t kPhysicalKeyW = 0x0007001a; -constexpr uint64_t kPhysicalShiftLeft = 0x000700e1; -constexpr uint64_t kPhysicalShiftRight = 0x000700e5; -constexpr uint64_t kPhysicalCapsLock = 0x00070039; -constexpr uint64_t kPhysicalNumpad1 = 0x00070059; -constexpr uint64_t kPhysicalF1 = 0x0007003a; -constexpr uint64_t kPhysicalAltRight = 0x000700e6; -constexpr uint64_t kLogicalKeyUndefined = 0x0100070003; -constexpr uint64_t kLogicalKeyA = 0x0000000061; -constexpr uint64_t kLogicalKeyW = 0x0000000077; -constexpr uint64_t kLogicalShiftLeft = 0x3000000010d; -constexpr uint64_t kLogicalShiftRight = 0x4000000010d; -constexpr uint64_t kLogicalCapsLock = 0x01000000104; -constexpr uint64_t kLogicalNumpad1 = 0x50000000031; -constexpr uint64_t kLogicalF1 = 0x01000000801; -constexpr uint64_t kLogicalAltRight = 0x40000000102; +constexpr uint64_t kLogicalKeyUndefined = 0x1300000003; constexpr uint64_t kModifierFlagNone = 0x0; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/KeyCodeMap.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/KeyCodeMap.mm index cb1e4d0e6c..3ad9b290df 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/KeyCodeMap.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/KeyCodeMap.mm @@ -12,60 +12,24 @@ // be edited directly. // // Edit the template -// flutter/flutter:dev/tools/gen_keycodes/data/ios_key_code_map_cc.tmpl instead. +// flutter/flutter:dev/tools/gen_keycodes/data/ios_key_code_map_mm.tmpl instead. // // See flutter/flutter:dev/tools/gen_keycodes/README.md for more information. /** * Mask for the 32-bit value portion of the key code. - * - * This is used by platform-specific code to generate Flutter key codes. */ const uint64_t kValueMask = 0x000ffffffff; /** - * Mask for the platform prefix portion of the key code. - * - * This is used by platform-specific code to generate Flutter key codes. - */ -const uint64_t kPlatformMask = 0x0ff00000000; - -/** - * The code prefix for keys which have a Unicode representation. - * - * This is used by platform-specific code to generate Flutter key codes. + * The plane value for keys which have a Unicode representation. */ const uint64_t kUnicodePlane = 0x00000000000; /** - * Mask for the auto-generated bit portion of the key code. - * - * This is used by platform-specific code to generate new Flutter key codes for - * keys which are not recognized. + * The plane value for the private keys defined by the iOS embedding. */ -const uint64_t kAutogeneratedMask = 0x10000000000; - -/** - * Mask for the synonym pseudo-keys generated for keys which appear in more than - * one place on the keyboard. - * - * IDs in this range are used to represent keys which appear in multiple places - * on the keyboard, such as the SHIFT, ALT, CTRL, and numeric keypad keys. These - * key codes will never be generated by the key event system, but may be used in - * key maps to represent the union of all the keys of each type in order to - * match them. - * - * To look up the synonyms that are defined, look in the [synonyms] map. - */ -const uint64_t kSynonymMask = 0x20000000000; - -/** - * The code prefix for keys which do not have a Unicode representation. - * - * This is used by platform-specific code to generate Flutter key codes using - * HID Usage codes. - */ -const uint64_t kHidPlane = 0x00100000000; +const uint64_t kIosPlane = 0x01300000000; // Maps iOS-specific key code values representing PhysicalKeyboardKey. // @@ -235,114 +199,104 @@ const std::map keyCodeToPhysicalKey = { // Maps iOS-specific virtual key code values to logical keys representing // LogicalKeyboardKey const std::map keyCodeToLogicalKey = { - {0x0000002a, 0x01000000008}, // Backspace - {0x0000002b, 0x01000000009}, // Tab - {0x00000028, 0x0100000000d}, // Enter - {0x00000029, 0x0100000001b}, // Escape - {0x0000004c, 0x0100000007f}, // Delete - {0x00000039, 0x01000000104}, // CapsLock - {0x00000053, 0x0100000010a}, // NumLock - {0x00000051, 0x01000000301}, // ArrowDown - {0x00000050, 0x01000000302}, // ArrowLeft - {0x0000004f, 0x01000000303}, // ArrowRight - {0x00000052, 0x01000000304}, // ArrowUp - {0x0000004d, 0x01000000305}, // End - {0x0000004a, 0x01000000306}, // Home - {0x0000004e, 0x01000000307}, // PageDown - {0x0000004b, 0x01000000308}, // PageUp - {0x00000049, 0x01000000407}, // Insert - {0x00000065, 0x01000000505}, // ContextMenu - {0x0000003a, 0x01000000801}, // F1 - {0x0000003b, 0x01000000802}, // F2 - {0x0000003c, 0x01000000803}, // F3 - {0x0000003d, 0x01000000804}, // F4 - {0x0000003e, 0x01000000805}, // F5 - {0x0000003f, 0x01000000806}, // F6 - {0x00000040, 0x01000000807}, // F7 - {0x00000041, 0x01000000808}, // F8 - {0x00000042, 0x01000000809}, // F9 - {0x00000043, 0x0100000080a}, // F10 - {0x00000044, 0x0100000080b}, // F11 - {0x00000045, 0x0100000080c}, // F12 - {0x00000068, 0x0100000080d}, // F13 - {0x00000069, 0x0100000080e}, // F14 - {0x0000006a, 0x0100000080f}, // F15 - {0x0000006b, 0x01000000810}, // F16 - {0x0000006c, 0x01000000811}, // F17 - {0x0000006d, 0x01000000812}, // F18 - {0x0000006e, 0x01000000813}, // F19 - {0x0000006f, 0x01000000814}, // F20 - {0x00000081, 0x01000000a0f}, // AudioVolumeDown - {0x00000080, 0x01000000a10}, // AudioVolumeUp - {0x0000007f, 0x01000000a11}, // AudioVolumeMute - {0x00000087, 0x01100070087}, // IntlRo - {0x00000089, 0x01100070089}, // IntlYen - {0x00000090, 0x01100070090}, // Lang1 - {0x00000091, 0x01100070091}, // Lang2 - {0x00000092, 0x01100070092}, // Lang3 - {0x00000093, 0x01100070093}, // Lang4 - {0x00000094, 0x01100070094}, // Lang5 - {0x000000e2, 0x30000000102}, // AltLeft - {0x000000e0, 0x30000000105}, // ControlLeft - {0x000000e3, 0x30000000109}, // MetaLeft - {0x000000e1, 0x3000000010d}, // ShiftLeft - {0x000000e6, 0x40000000102}, // AltRight - {0x000000e4, 0x40000000105}, // ControlRight - {0x000000e7, 0x40000000109}, // MetaRight - {0x000000e5, 0x4000000010d}, // ShiftRight - {0x00000058, 0x5000000000d}, // NumpadEnter - {0x00000055, 0x5000000002a}, // NumpadMultiply - {0x00000057, 0x5000000002b}, // NumpadAdd - {0x00000085, 0x5000000002c}, // NumpadComma - {0x00000056, 0x5000000002d}, // NumpadSubtract - {0x00000063, 0x5000000002e}, // NumpadDecimal - {0x00000054, 0x5000000002f}, // NumpadDivide - {0x00000062, 0x50000000030}, // Numpad0 - {0x00000059, 0x50000000031}, // Numpad1 - {0x0000005a, 0x50000000032}, // Numpad2 - {0x0000005b, 0x50000000033}, // Numpad3 - {0x0000005c, 0x50000000034}, // Numpad4 - {0x0000005d, 0x50000000035}, // Numpad5 - {0x0000005e, 0x50000000036}, // Numpad6 - {0x0000005f, 0x50000000037}, // Numpad7 - {0x00000060, 0x50000000038}, // Numpad8 - {0x00000061, 0x50000000039}, // Numpad9 - {0x00000067, 0x5000000003d}, // NumpadEqual + {0x00000028, 0x0010000000d}, // Enter + {0x00000029, 0x0010000001b}, // Escape + {0x0000002a, 0x00100000008}, // Backspace + {0x0000002b, 0x00100000009}, // Tab + {0x00000039, 0x00100000104}, // CapsLock + {0x0000003a, 0x00100000801}, // F1 + {0x0000003b, 0x00100000802}, // F2 + {0x0000003c, 0x00100000803}, // F3 + {0x0000003d, 0x00100000804}, // F4 + {0x0000003e, 0x00100000805}, // F5 + {0x0000003f, 0x00100000806}, // F6 + {0x00000040, 0x00100000807}, // F7 + {0x00000041, 0x00100000808}, // F8 + {0x00000042, 0x00100000809}, // F9 + {0x00000043, 0x0010000080a}, // F10 + {0x00000044, 0x0010000080b}, // F11 + {0x00000045, 0x0010000080c}, // F12 + {0x00000049, 0x00100000407}, // Insert + {0x0000004a, 0x00100000306}, // Home + {0x0000004b, 0x00100000308}, // PageUp + {0x0000004c, 0x0010000007f}, // Delete + {0x0000004d, 0x00100000305}, // End + {0x0000004e, 0x00100000307}, // PageDown + {0x0000004f, 0x00100000303}, // ArrowRight + {0x00000050, 0x00100000302}, // ArrowLeft + {0x00000051, 0x00100000301}, // ArrowDown + {0x00000052, 0x00100000304}, // ArrowUp + {0x00000053, 0x0010000010a}, // NumLock + {0x00000054, 0x0020000022f}, // NumpadDivide + {0x00000055, 0x0020000022a}, // NumpadMultiply + {0x00000056, 0x0020000022d}, // NumpadSubtract + {0x00000057, 0x0020000022b}, // NumpadAdd + {0x00000058, 0x0020000020d}, // NumpadEnter + {0x00000059, 0x00200000231}, // Numpad1 + {0x0000005a, 0x00200000232}, // Numpad2 + {0x0000005b, 0x00200000233}, // Numpad3 + {0x0000005c, 0x00200000234}, // Numpad4 + {0x0000005d, 0x00200000235}, // Numpad5 + {0x0000005e, 0x00200000236}, // Numpad6 + {0x0000005f, 0x00200000237}, // Numpad7 + {0x00000060, 0x00200000238}, // Numpad8 + {0x00000061, 0x00200000239}, // Numpad9 + {0x00000062, 0x00200000230}, // Numpad0 + {0x00000063, 0x0020000022e}, // NumpadDecimal + {0x00000065, 0x00100000505}, // ContextMenu + {0x00000067, 0x0020000023d}, // NumpadEqual + {0x00000068, 0x0010000080d}, // F13 + {0x00000069, 0x0010000080e}, // F14 + {0x0000006a, 0x0010000080f}, // F15 + {0x0000006b, 0x00100000810}, // F16 + {0x0000006c, 0x00100000811}, // F17 + {0x0000006d, 0x00100000812}, // F18 + {0x0000006e, 0x00100000813}, // F19 + {0x0000006f, 0x00100000814}, // F20 + {0x0000007f, 0x00100000a11}, // AudioVolumeMute + {0x00000080, 0x00100000a10}, // AudioVolumeUp + {0x00000081, 0x00100000a0f}, // AudioVolumeDown + {0x00000085, 0x0020000022c}, // NumpadComma + {0x00000087, 0x00200000021}, // IntlRo + {0x00000089, 0x00200000022}, // IntlYen + {0x00000090, 0x00200000010}, // Lang1 + {0x00000091, 0x00200000011}, // Lang2 + {0x00000092, 0x00200000012}, // Lang3 + {0x00000093, 0x00200000013}, // Lang4 + {0x00000094, 0x00200000014}, // Lang5 + {0x000000e0, 0x00200000100}, // ControlLeft + {0x000000e1, 0x00200000102}, // ShiftLeft + {0x000000e2, 0x00200000104}, // AltLeft + {0x000000e3, 0x00200000106}, // MetaLeft + {0x000000e4, 0x00200000101}, // ControlRight + {0x000000e5, 0x00200000103}, // ShiftRight + {0x000000e6, 0x00200000105}, // AltRight + {0x000000e7, 0x00200000107}, // MetaRight }; // Maps iOS-specific virtual key codes to an equivalent modifier flag enum // value. const std::map keyCodeToModifierFlag = { - {0x000000e1, kModifierFlagShiftLeft}, {0x000000e5, kModifierFlagShiftRight}, - {0x000000e0, kModifierFlagControlLeft}, {0x000000e4, kModifierFlagControlRight}, - {0x000000e2, kModifierFlagAltLeft}, {0x000000e6, kModifierFlagAltRight}, - {0x000000e3, kModifierFlagMetaLeft}, {0x000000e7, kModifierFlagMetaRight}, + {0x000000e1, kModifierFlagShiftLeft}, // ShiftLeft + {0x000000e5, kModifierFlagShiftRight}, // ShiftRight + {0x000000e0, kModifierFlagControlLeft}, // ControlLeft + {0x000000e4, kModifierFlagControlRight}, // ControlRight + {0x000000e2, kModifierFlagAltLeft}, // AltLeft + {0x000000e6, kModifierFlagAltRight}, // AltRight + {0x000000e3, kModifierFlagMetaLeft}, // MetaLeft + {0x000000e7, kModifierFlagMetaRight}, // MetaRight }; // Maps modifier flag enum values to an iOS-specific virtual key code. const std::map modifierFlagToKeyCode = { - {kModifierFlagShiftLeft, 0x000000e1}, {kModifierFlagShiftRight, 0x000000e5}, - {kModifierFlagControlLeft, 0x000000e0}, {kModifierFlagControlRight, 0x000000e4}, - {kModifierFlagAltLeft, 0x000000e2}, {kModifierFlagAltRight, 0x000000e6}, - {kModifierFlagMetaLeft, 0x000000e3}, {kModifierFlagMetaRight, 0x000000e7}, -}; - -const std::map sidedModifierToAny = { - {kModifierFlagShiftLeft, kModifierFlagShiftAny}, - {kModifierFlagShiftRight, kModifierFlagShiftAny}, - {kModifierFlagControlLeft, kModifierFlagControlAny}, - {kModifierFlagControlRight, kModifierFlagControlAny}, - {kModifierFlagAltLeft, kModifierFlagAltAny}, - {kModifierFlagAltRight, kModifierFlagAltAny}, - {kModifierFlagMetaLeft, kModifierFlagMetaAny}, - {kModifierFlagMetaRight, kModifierFlagMetaAny}, -}; - -const std::map anyModifierToLeft = { - {kModifierFlagShiftAny, kModifierFlagShiftLeft}, - {kModifierFlagControlAny, kModifierFlagControlLeft}, - {kModifierFlagAltAny, kModifierFlagAltLeft}, - {kModifierFlagMetaAny, kModifierFlagMetaLeft}, + {kModifierFlagShiftLeft, 0x000000e1}, // ShiftLeft + {kModifierFlagShiftRight, 0x000000e5}, // ShiftRight + {kModifierFlagControlLeft, 0x000000e0}, // ControlLeft + {kModifierFlagControlRight, 0x000000e4}, // ControlRight + {kModifierFlagAltLeft, 0x000000e2}, // AltLeft + {kModifierFlagAltRight, 0x000000e6}, // AltRight + {kModifierFlagMetaLeft, 0x000000e3}, // MetaLeft + {kModifierFlagMetaRight, 0x000000e7}, // MetaRight }; // A set of virtual key codes mapping to function keys, so that may be @@ -375,4 +329,4 @@ const std::set functionKeyCodes = { }; const uint64_t kCapsLockPhysicalKey = 0x00070039; -const uint64_t kCapsLockLogicalKey = 0x1000000104; +const uint64_t kCapsLockLogicalKey = 0x100000104; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/KeyCodeMap_Internal.h b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/KeyCodeMap_Internal.h index d303571ae5..61a0b96a38 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/KeyCodeMap_Internal.h +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/KeyCodeMap_Internal.h @@ -28,17 +28,8 @@ extern const std::map keyCodeToLogicalKey; // Several mask constants. See KeyCodeMap.mm for their descriptions. extern const uint64_t kValueMask; -extern const uint64_t kPlatformMask; extern const uint64_t kUnicodePlane; -extern const uint64_t kHidPlane; -extern const uint64_t kAutogeneratedMask; -extern const uint64_t kSynonymMask; - -/** - * The code prefix for keys from iOS which do not have a Unicode - * representation. - */ -static const uint64_t kIOSPlane = 0x00400000000; +extern const uint64_t kIosPlane; /** * The physical key for CapsLock, which needs special handling. diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponder.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponder.mm index 5d5dcd2249..faae4348ce 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponder.mm +++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponder.mm @@ -67,8 +67,9 @@ static uint64_t KeyOfPlane(uint64_t baseKey, uint64_t plane) { */ static uint64_t GetPhysicalKeyForKeyCode(unsigned short keyCode) { NSNumber* physicalKey = [keyCodeToPhysicalKey objectForKey:@(keyCode)]; - if (physicalKey == nil) - return 0; + if (physicalKey == nil) { + return KeyOfPlane(keyCode, kMacosPlane); + } return physicalKey.unsignedLongLongValue; } @@ -79,7 +80,7 @@ static uint64_t GetLogicalKeyForModifier(unsigned short keyCode, uint64_t hidCod NSNumber* fromKeyCode = [keyCodeToLogicalKey objectForKey:@(keyCode)]; if (fromKeyCode != nil) return fromKeyCode.unsignedLongLongValue; - return KeyOfPlane(hidCode, kHidPlane); + return KeyOfPlane(hidCode, kMacosPlane); } /** @@ -88,13 +89,27 @@ static uint64_t GetLogicalKeyForModifier(unsigned short keyCode, uint64_t hidCod * * Independent of locale. */ -static uint64_t toLower(uint64_t ch) { - const uint64_t lowerA = 0x61; - const uint64_t upperA = 0x41; - const uint64_t upperZ = 0x5a; - if (ch >= upperA && ch <= upperZ) - return ch + (lowerA - upperA); - return ch; +static uint64_t toLower(uint64_t n) { + constexpr uint64_t lowerA = 0x61; + constexpr uint64_t upperA = 0x41; + constexpr uint64_t upperZ = 0x5a; + + constexpr uint64_t lowerAGrave = 0xe0; + constexpr uint64_t upperAGrave = 0xc0; + constexpr uint64_t upperThorn = 0xde; + constexpr uint64_t division = 0xf7; + + // ASCII range. + if (n >= upperA && n <= upperZ) { + return n - upperA + lowerA; + } + + // EASCII range. + if (n >= upperAGrave && n <= upperThorn && n != division) { + return n - upperAGrave + lowerAGrave; + } + + return n; } /** @@ -130,19 +145,9 @@ static uint64_t GetLogicalKeyForEvent(NSEvent* event, uint64_t physicalKey) { return KeyOfPlane(toLower(codeUnit), kUnicodePlane); } - // Control keys like "backspace" and movement keys like arrow keys don't have - // a printable representation, but are present on the physical keyboard. Since - // there is no logical keycode map for macOS (macOS uses the keycode to - // reference physical keys), a LogicalKeyboardKey is created with the physical - // key's HID usage and debugName. This avoids duplicating the physical key - // map. - if (physicalKey != 0) { - return KeyOfPlane(physicalKey, kHidPlane); - } - // This is a non-printable key that is unrecognized, so a new code is minted - // with the autogenerated bit set. - return KeyOfPlane(event.keyCode, kMacosPlane | kAutogeneratedMask); + // to the macOS plane. + return KeyOfPlane(event.keyCode, kMacosPlane); } /** diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponderUnittests.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponderUnittests.mm index 67974abcb6..d7b6f93f5c 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponderUnittests.mm +++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponderUnittests.mm @@ -6,6 +6,7 @@ #import #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponder.h" +#include "flutter/shell/platform/embedder/test_utils/key_codes.h" #import "flutter/testing/testing.h" #include "third_party/googletest/googletest/include/gtest/gtest.h" @@ -68,23 +69,7 @@ constexpr uint64_t kKeyCodeNumpad1 = 0x53; constexpr uint64_t kKeyCodeF1 = 0x7a; constexpr uint64_t kKeyCodeAltRight = 0x3d; -constexpr uint64_t kPhysicalKeyA = 0x00070004; -constexpr uint64_t kPhysicalKeyW = 0x0007001a; -constexpr uint64_t kPhysicalShiftLeft = 0x000700e1; -constexpr uint64_t kPhysicalShiftRight = 0x000700e5; -constexpr uint64_t kPhysicalCapsLock = 0x00070039; -constexpr uint64_t kPhysicalNumpad1 = 0x00070059; -constexpr uint64_t kPhysicalF1 = 0x0007003a; -constexpr uint64_t kPhysicalAltRight = 0x000700e6; - -constexpr uint64_t kLogicalKeyA = 0x00000061; -constexpr uint64_t kLogicalKeyW = 0x00000077; -constexpr uint64_t kLogicalShiftLeft = 0x0030000010d; -constexpr uint64_t kLogicalShiftRight = 0x0040000010d; -constexpr uint64_t kLogicalCapsLock = 0x00000000104; -constexpr uint64_t kLogicalNumpad1 = 0x00200000031; -constexpr uint64_t kLogicalF1 = 0x00000000801; -constexpr uint64_t kLogicalAltRight = 0x00400000102; +using namespace ::flutter::testing::keycodes; typedef void (^ResponseCallback)(bool handled); diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap.mm index 21dacd7af8..e09fc433fc 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap.mm +++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap.mm @@ -7,145 +7,99 @@ #include "./KeyCodeMap_Internal.h" // DO NOT EDIT -- DO NOT EDIT -- DO NOT EDIT -// This file is generated by flutter/flutter@dev/tools/gen_keycodes/bin/gen_keycodes.dart and -// should not be edited directly. +// This file is generated by +// flutter/flutter:dev/tools/gen_keycodes/bin/gen_keycodes.dart and should not +// be edited directly. // -// Edit the template dev/tools/gen_keycodes/data/keyboard_map_macos_cc.tmpl instead. -// See dev/tools/gen_keycodes/README.md for more information. +// Edit the template +// flutter/flutter:dev/tools/gen_keycodes/data/keyboard_map_macos_cc.tmpl +// instead. +// +// See flutter/flutter:dev/tools/gen_keycodes/README.md for more information. -/** - * Mask for the 32-bit value portion of the key code. - * - * This is used by platform-specific code to generate Flutter key codes. - */ -const uint64_t kValueMask = 0x000FFFFFFFF; - -/** - * Mask for the platform prefix portion of the key code. - * - * This is used by platform-specific code to generate Flutter key codes. - */ -const uint64_t kPlatformMask = 0x0FF00000000; - -/** - * The code prefix for keys which have a Unicode representation. - * - * This is used by platform-specific code to generate Flutter key codes. - */ +const uint64_t kValueMask = 0x000ffffffff; const uint64_t kUnicodePlane = 0x00000000000; - -/** - * Mask for the auto-generated bit portion of the key code. - * - * This is used by platform-specific code to generate new Flutter key codes for - * keys which are not recognized. - */ -const uint64_t kAutogeneratedMask = 0x10000000000; - -/** - * Mask for the synonym pseudo-keys generated for keys which appear in more than - * one place on the keyboard. - * - * IDs in this range are used to represent keys which appear in multiple places - * on the keyboard, such as the SHIFT, ALT, CTRL, and numeric keypad keys. These - * key codes will never be generated by the key event system, but may be used in - * key maps to represent the union of all the keys of each type in order to - * match them. - * - * To look up the synonyms that are defined, look in the [synonyms] map. - */ -const uint64_t kSynonymMask = 0x20000000000; - -/** - * The code prefix for keys which do not have a Unicode representation. - * - * This is used by platform-specific code to generate Flutter key codes using - * HID Usage codes. - */ -const uint64_t kHidPlane = 0x00100000000; +const uint64_t kMacosPlane = 0x01400000000; const NSDictionary* keyCodeToPhysicalKey = @{ @0x00000000 : @0x00070004, // keyA - @0x0000000b : @0x00070005, // keyB - @0x00000008 : @0x00070006, // keyC - @0x00000002 : @0x00070007, // keyD - @0x0000000e : @0x00070008, // keyE - @0x00000003 : @0x00070009, // keyF - @0x00000005 : @0x0007000a, // keyG - @0x00000004 : @0x0007000b, // keyH - @0x00000022 : @0x0007000c, // keyI - @0x00000026 : @0x0007000d, // keyJ - @0x00000028 : @0x0007000e, // keyK - @0x00000025 : @0x0007000f, // keyL - @0x0000002e : @0x00070010, // keyM - @0x0000002d : @0x00070011, // keyN - @0x0000001f : @0x00070012, // keyO - @0x00000023 : @0x00070013, // keyP - @0x0000000c : @0x00070014, // keyQ - @0x0000000f : @0x00070015, // keyR @0x00000001 : @0x00070016, // keyS - @0x00000011 : @0x00070017, // keyT - @0x00000020 : @0x00070018, // keyU - @0x00000009 : @0x00070019, // keyV - @0x0000000d : @0x0007001a, // keyW - @0x00000007 : @0x0007001b, // keyX - @0x00000010 : @0x0007001c, // keyY + @0x00000002 : @0x00070007, // keyD + @0x00000003 : @0x00070009, // keyF + @0x00000004 : @0x0007000b, // keyH + @0x00000005 : @0x0007000a, // keyG @0x00000006 : @0x0007001d, // keyZ + @0x00000007 : @0x0007001b, // keyX + @0x00000008 : @0x00070006, // keyC + @0x00000009 : @0x00070019, // keyV + @0x0000000a : @0x00070064, // intlBackslash + @0x0000000b : @0x00070005, // keyB + @0x0000000c : @0x00070014, // keyQ + @0x0000000d : @0x0007001a, // keyW + @0x0000000e : @0x00070008, // keyE + @0x0000000f : @0x00070015, // keyR + @0x00000010 : @0x0007001c, // keyY + @0x00000011 : @0x00070017, // keyT @0x00000012 : @0x0007001e, // digit1 @0x00000013 : @0x0007001f, // digit2 @0x00000014 : @0x00070020, // digit3 @0x00000015 : @0x00070021, // digit4 - @0x00000017 : @0x00070022, // digit5 @0x00000016 : @0x00070023, // digit6 - @0x0000001a : @0x00070024, // digit7 - @0x0000001c : @0x00070025, // digit8 + @0x00000017 : @0x00070022, // digit5 + @0x00000018 : @0x0007002e, // equal @0x00000019 : @0x00070026, // digit9 + @0x0000001a : @0x00070024, // digit7 + @0x0000001b : @0x0007002d, // minus + @0x0000001c : @0x00070025, // digit8 @0x0000001d : @0x00070027, // digit0 + @0x0000001e : @0x00070030, // bracketRight + @0x0000001f : @0x00070012, // keyO + @0x00000020 : @0x00070018, // keyU + @0x00000021 : @0x0007002f, // bracketLeft + @0x00000022 : @0x0007000c, // keyI + @0x00000023 : @0x00070013, // keyP @0x00000024 : @0x00070028, // enter - @0x00000035 : @0x00070029, // escape - @0x00000033 : @0x0007002a, // backspace + @0x00000025 : @0x0007000f, // keyL + @0x00000026 : @0x0007000d, // keyJ + @0x00000027 : @0x00070034, // quote + @0x00000028 : @0x0007000e, // keyK + @0x00000029 : @0x00070033, // semicolon + @0x0000002a : @0x00070031, // backslash + @0x0000002b : @0x00070036, // comma + @0x0000002c : @0x00070038, // slash + @0x0000002d : @0x00070011, // keyN + @0x0000002e : @0x00070010, // keyM + @0x0000002f : @0x00070037, // period @0x00000030 : @0x0007002b, // tab @0x00000031 : @0x0007002c, // space - @0x0000001b : @0x0007002d, // minus - @0x00000018 : @0x0007002e, // equal - @0x00000021 : @0x0007002f, // bracketLeft - @0x0000001e : @0x00070030, // bracketRight - @0x0000002a : @0x00070031, // backslash - @0x00000029 : @0x00070033, // semicolon - @0x00000027 : @0x00070034, // quote @0x00000032 : @0x00070035, // backquote - @0x0000002b : @0x00070036, // comma - @0x0000002f : @0x00070037, // period - @0x0000002c : @0x00070038, // slash + @0x00000033 : @0x0007002a, // backspace + @0x00000035 : @0x00070029, // escape + @0x00000036 : @0x000700e7, // metaRight + @0x00000037 : @0x000700e3, // metaLeft + @0x00000038 : @0x000700e1, // shiftLeft @0x00000039 : @0x00070039, // capsLock - @0x0000007a : @0x0007003a, // f1 - @0x00000078 : @0x0007003b, // f2 - @0x00000063 : @0x0007003c, // f3 - @0x00000076 : @0x0007003d, // f4 - @0x00000060 : @0x0007003e, // f5 - @0x00000061 : @0x0007003f, // f6 - @0x00000062 : @0x00070040, // f7 - @0x00000064 : @0x00070041, // f8 - @0x00000065 : @0x00070042, // f9 - @0x0000006d : @0x00070043, // f10 - @0x00000067 : @0x00070044, // f11 - @0x0000006f : @0x00070045, // f12 - @0x00000072 : @0x00070049, // insert - @0x00000073 : @0x0007004a, // home - @0x00000074 : @0x0007004b, // pageUp - @0x00000075 : @0x0007004c, // delete - @0x00000077 : @0x0007004d, // end - @0x00000079 : @0x0007004e, // pageDown - @0x0000007c : @0x0007004f, // arrowRight - @0x0000007b : @0x00070050, // arrowLeft - @0x0000007d : @0x00070051, // arrowDown - @0x0000007e : @0x00070052, // arrowUp - @0x00000047 : @0x00070053, // numLock - @0x0000004b : @0x00070054, // numpadDivide + @0x0000003a : @0x000700e2, // altLeft + @0x0000003b : @0x000700e0, // controlLeft + @0x0000003c : @0x000700e5, // shiftRight + @0x0000003d : @0x000700e6, // altRight + @0x0000003e : @0x000700e4, // controlRight + @0x0000003f : @0x00000012, // fn + @0x00000040 : @0x0007006c, // f17 + @0x00000041 : @0x00070063, // numpadDecimal @0x00000043 : @0x00070055, // numpadMultiply - @0x0000004e : @0x00070056, // numpadSubtract @0x00000045 : @0x00070057, // numpadAdd + @0x00000047 : @0x00070053, // numLock + @0x00000048 : @0x00070080, // audioVolumeUp + @0x00000049 : @0x00070081, // audioVolumeDown + @0x0000004a : @0x0007007f, // audioVolumeMute + @0x0000004b : @0x00070054, // numpadDivide @0x0000004c : @0x00070058, // numpadEnter + @0x0000004e : @0x00070056, // numpadSubtract + @0x0000004f : @0x0007006d, // f18 + @0x00000050 : @0x0007006e, // f19 + @0x00000051 : @0x00070067, // numpadEqual + @0x00000052 : @0x00070062, // numpad0 @0x00000053 : @0x00070059, // numpad1 @0x00000054 : @0x0007005a, // numpad2 @0x00000055 : @0x0007005b, // numpad3 @@ -153,110 +107,115 @@ const NSDictionary* keyCodeToPhysicalKey = @{ @0x00000057 : @0x0007005d, // numpad5 @0x00000058 : @0x0007005e, // numpad6 @0x00000059 : @0x0007005f, // numpad7 + @0x0000005a : @0x0007006f, // f20 @0x0000005b : @0x00070060, // numpad8 @0x0000005c : @0x00070061, // numpad9 - @0x00000052 : @0x00070062, // numpad0 - @0x00000041 : @0x00070063, // numpadDecimal - @0x0000000a : @0x00070064, // intlBackslash - @0x0000006e : @0x00070065, // contextMenu - @0x00000051 : @0x00070067, // numpadEqual - @0x00000069 : @0x00070068, // f13 - @0x0000006b : @0x00070069, // f14 - @0x00000071 : @0x0007006a, // f15 - @0x0000006a : @0x0007006b, // f16 - @0x00000040 : @0x0007006c, // f17 - @0x0000004f : @0x0007006d, // f18 - @0x00000050 : @0x0007006e, // f19 - @0x0000005a : @0x0007006f, // f20 - @0x0000004a : @0x0007007f, // audioVolumeMute - @0x00000048 : @0x00070080, // audioVolumeUp - @0x00000049 : @0x00070081, // audioVolumeDown - @0x0000005f : @0x00070085, // numpadComma - @0x0000005e : @0x00070087, // intlRo @0x0000005d : @0x00070089, // intlYen - @0x00000068 : @0x00070090, // lang1 + @0x0000005e : @0x00070087, // intlRo + @0x0000005f : @0x00070085, // numpadComma + @0x00000060 : @0x0007003e, // f5 + @0x00000061 : @0x0007003f, // f6 + @0x00000062 : @0x00070040, // f7 + @0x00000063 : @0x0007003c, // f3 + @0x00000064 : @0x00070041, // f8 + @0x00000065 : @0x00070042, // f9 @0x00000066 : @0x00070091, // lang2 - @0x0000003b : @0x000700e0, // controlLeft - @0x00000038 : @0x000700e1, // shiftLeft - @0x0000003a : @0x000700e2, // altLeft - @0x00000037 : @0x000700e3, // metaLeft - @0x0000003e : @0x000700e4, // controlRight - @0x0000003c : @0x000700e5, // shiftRight - @0x0000003d : @0x000700e6, // altRight - @0x00000036 : @0x000700e7, // metaRight - @0x0000003f : @0x00000012, // fn + @0x00000067 : @0x00070044, // f11 + @0x00000068 : @0x00070090, // lang1 + @0x00000069 : @0x00070068, // f13 + @0x0000006a : @0x0007006b, // f16 + @0x0000006b : @0x00070069, // f14 + @0x0000006d : @0x00070043, // f10 + @0x0000006e : @0x00070065, // contextMenu + @0x0000006f : @0x00070045, // f12 + @0x00000071 : @0x0007006a, // f15 + @0x00000072 : @0x00070049, // insert + @0x00000073 : @0x0007004a, // home + @0x00000074 : @0x0007004b, // pageUp + @0x00000075 : @0x0007004c, // delete + @0x00000076 : @0x0007003d, // f4 + @0x00000077 : @0x0007004d, // end + @0x00000078 : @0x0007003b, // f2 + @0x00000079 : @0x0007004e, // pageDown + @0x0000007a : @0x0007003a, // f1 + @0x0000007b : @0x00070050, // arrowLeft + @0x0000007c : @0x0007004f, // arrowRight + @0x0000007d : @0x00070051, // arrowDown + @0x0000007e : @0x00070052, // arrowUp }; const NSDictionary* keyCodeToLogicalKey = @{ - @0x00000033 : @0x0000000008, // Backspace - @0x00000035 : @0x000000001b, // Escape - @0x00000075 : @0x000000007f, // Delete - @0x00000039 : @0x0000000104, // CapsLock - @0x0000003f : @0x0000000106, // Fn - @0x00000047 : @0x000000010a, // NumLock - @0x0000007d : @0x0000000301, // ArrowDown - @0x0000007b : @0x0000000302, // ArrowLeft - @0x0000007c : @0x0000000303, // ArrowRight - @0x0000007e : @0x0000000304, // ArrowUp - @0x00000077 : @0x0000000305, // End - @0x00000073 : @0x0000000306, // Home - @0x00000079 : @0x0000000307, // PageDown - @0x00000074 : @0x0000000308, // PageUp - @0x00000072 : @0x0000000407, // Insert - @0x0000006e : @0x0000000505, // ContextMenu - @0x0000007a : @0x0000000801, // F1 - @0x00000078 : @0x0000000802, // F2 - @0x00000063 : @0x0000000803, // F3 - @0x00000076 : @0x0000000804, // F4 - @0x00000060 : @0x0000000805, // F5 - @0x00000061 : @0x0000000806, // F6 - @0x00000062 : @0x0000000807, // F7 - @0x00000064 : @0x0000000808, // F8 - @0x00000065 : @0x0000000809, // F9 - @0x0000006d : @0x000000080a, // F10 - @0x00000067 : @0x000000080b, // F11 - @0x0000006f : @0x000000080c, // F12 - @0x00000069 : @0x000000080d, // F13 - @0x0000006b : @0x000000080e, // F14 - @0x00000071 : @0x000000080f, // F15 - @0x0000006a : @0x0000000810, // F16 - @0x00000040 : @0x0000000811, // F17 - @0x0000004f : @0x0000000812, // F18 - @0x00000050 : @0x0000000813, // F19 - @0x0000005a : @0x0000000814, // F20 - @0x00000049 : @0x0000000a0f, // AudioVolumeDown - @0x00000048 : @0x0000000a10, // AudioVolumeUp - @0x0000004a : @0x0000000a11, // AudioVolumeMute - @0x0000005e : @0x0100070087, // IntlRo - @0x0000005d : @0x0100070089, // IntlYen - @0x00000068 : @0x0100070090, // Lang1 - @0x00000066 : @0x0100070091, // Lang2 - @0x0000004c : @0x020000000d, // NumpadEnter - @0x00000043 : @0x020000002a, // NumpadMultiply - @0x00000045 : @0x020000002b, // NumpadAdd - @0x0000005f : @0x020000002c, // NumpadComma - @0x0000004e : @0x020000002d, // NumpadSubtract - @0x00000041 : @0x020000002e, // NumpadDecimal - @0x0000004b : @0x020000002f, // NumpadDivide - @0x00000052 : @0x0200000030, // Numpad0 - @0x00000053 : @0x0200000031, // Numpad1 - @0x00000054 : @0x0200000032, // Numpad2 - @0x00000055 : @0x0200000033, // Numpad3 - @0x00000056 : @0x0200000034, // Numpad4 - @0x00000057 : @0x0200000035, // Numpad5 - @0x00000058 : @0x0200000036, // Numpad6 - @0x00000059 : @0x0200000037, // Numpad7 - @0x0000005b : @0x0200000038, // Numpad8 - @0x0000005c : @0x0200000039, // Numpad9 - @0x00000051 : @0x020000003d, // NumpadEqual - @0x0000003a : @0x0300000102, // AltLeft - @0x0000003b : @0x0300000105, // ControlLeft - @0x00000037 : @0x0300000109, // MetaLeft - @0x00000038 : @0x030000010d, // ShiftLeft - @0x0000003d : @0x0400000102, // AltRight - @0x0000003e : @0x0400000105, // ControlRight - @0x00000036 : @0x0400000109, // MetaRight - @0x0000003c : @0x040000010d, // ShiftRight + @0x00000024 : @0x0010000000d, // Enter -> enter + @0x00000030 : @0x00100000009, // Tab -> tab + @0x00000033 : @0x00100000008, // Backspace -> backspace + @0x00000035 : @0x0010000001b, // Escape -> escape + @0x00000036 : @0x00200000107, // MetaRight -> metaRight + @0x00000037 : @0x00200000106, // MetaLeft -> metaLeft + @0x00000038 : @0x00200000102, // ShiftLeft -> shiftLeft + @0x00000039 : @0x00100000104, // CapsLock -> capsLock + @0x0000003a : @0x00200000104, // AltLeft -> altLeft + @0x0000003b : @0x00200000100, // ControlLeft -> controlLeft + @0x0000003c : @0x00200000103, // ShiftRight -> shiftRight + @0x0000003d : @0x00200000105, // AltRight -> altRight + @0x0000003e : @0x00200000101, // ControlRight -> controlRight + @0x0000003f : @0x00100000106, // Fn -> fn + @0x00000040 : @0x00100000811, // F17 -> f17 + @0x00000041 : @0x0020000022e, // NumpadDecimal -> numpadDecimal + @0x00000043 : @0x0020000022a, // NumpadMultiply -> numpadMultiply + @0x00000045 : @0x0020000022b, // NumpadAdd -> numpadAdd + @0x00000047 : @0x0010000010a, // NumLock -> numLock + @0x00000048 : @0x00100000a10, // AudioVolumeUp -> audioVolumeUp + @0x00000049 : @0x00100000a0f, // AudioVolumeDown -> audioVolumeDown + @0x0000004a : @0x00100000a11, // AudioVolumeMute -> audioVolumeMute + @0x0000004b : @0x0020000022f, // NumpadDivide -> numpadDivide + @0x0000004c : @0x0020000020d, // NumpadEnter -> numpadEnter + @0x0000004e : @0x0020000022d, // NumpadSubtract -> numpadSubtract + @0x0000004f : @0x00100000812, // F18 -> f18 + @0x00000050 : @0x00100000813, // F19 -> f19 + @0x00000051 : @0x0020000023d, // NumpadEqual -> numpadEqual + @0x00000052 : @0x00200000230, // Numpad0 -> numpad0 + @0x00000053 : @0x00200000231, // Numpad1 -> numpad1 + @0x00000054 : @0x00200000232, // Numpad2 -> numpad2 + @0x00000055 : @0x00200000233, // Numpad3 -> numpad3 + @0x00000056 : @0x00200000234, // Numpad4 -> numpad4 + @0x00000057 : @0x00200000235, // Numpad5 -> numpad5 + @0x00000058 : @0x00200000236, // Numpad6 -> numpad6 + @0x00000059 : @0x00200000237, // Numpad7 -> numpad7 + @0x0000005a : @0x00100000814, // F20 -> f20 + @0x0000005b : @0x00200000238, // Numpad8 -> numpad8 + @0x0000005c : @0x00200000239, // Numpad9 -> numpad9 + @0x0000005d : @0x00200000022, // IntlYen -> intlYen + @0x0000005e : @0x00200000021, // IntlRo -> intlRo + @0x0000005f : @0x0020000022c, // NumpadComma -> numpadComma + @0x00000060 : @0x00100000805, // F5 -> f5 + @0x00000061 : @0x00100000806, // F6 -> f6 + @0x00000062 : @0x00100000807, // F7 -> f7 + @0x00000063 : @0x00100000803, // F3 -> f3 + @0x00000064 : @0x00100000808, // F8 -> f8 + @0x00000065 : @0x00100000809, // F9 -> f9 + @0x00000066 : @0x00200000011, // Lang2 -> lang2 + @0x00000067 : @0x0010000080b, // F11 -> f11 + @0x00000068 : @0x00200000010, // Lang1 -> lang1 + @0x00000069 : @0x0010000080d, // F13 -> f13 + @0x0000006a : @0x00100000810, // F16 -> f16 + @0x0000006b : @0x0010000080e, // F14 -> f14 + @0x0000006d : @0x0010000080a, // F10 -> f10 + @0x0000006e : @0x00100000505, // ContextMenu -> contextMenu + @0x0000006f : @0x0010000080c, // F12 -> f12 + @0x00000071 : @0x0010000080f, // F15 -> f15 + @0x00000072 : @0x00100000407, // Insert -> insert + @0x00000073 : @0x00100000306, // Home -> home + @0x00000074 : @0x00100000308, // PageUp -> pageUp + @0x00000075 : @0x0010000007f, // Delete -> delete + @0x00000076 : @0x00100000804, // F4 -> f4 + @0x00000077 : @0x00100000305, // End -> end + @0x00000078 : @0x00100000802, // F2 -> f2 + @0x00000079 : @0x00100000307, // PageDown -> pageDown + @0x0000007a : @0x00100000801, // F1 -> f1 + @0x0000007b : @0x00100000302, // ArrowLeft -> arrowLeft + @0x0000007c : @0x00100000303, // ArrowRight -> arrowRight + @0x0000007d : @0x00100000301, // ArrowDown -> arrowDown + @0x0000007e : @0x00100000304, // ArrowUp -> arrowUp }; const NSDictionary* keyCodeToModifierFlag = @{ @@ -282,4 +241,4 @@ const NSDictionary* modifierFlagToKeyCode = @{ }; const uint64_t kCapsLockPhysicalKey = 0x00070039; -const uint64_t kCapsLockLogicalKey = 0x00000104; +const uint64_t kCapsLockLogicalKey = 0x100000104; diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap_Internal.h b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap_Internal.h index 0e52315555..34ea5b8658 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap_Internal.h +++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap_Internal.h @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#import +#include + /** * Maps macOS-specific key code values representing |PhysicalKeyboardKey|. * @@ -19,18 +22,20 @@ extern const NSDictionary* keyCodeToLogicalKey; // Several mask constants. See KeyCodeMap.mm for their descriptions. +/** + * Mask for the 32-bit value portion of the key code. + */ extern const uint64_t kValueMask; -extern const uint64_t kPlatformMask; -extern const uint64_t kUnicodePlane; -extern const uint64_t kHidPlane; -extern const uint64_t kAutogeneratedMask; -extern const uint64_t kSynonymMask; /** - * The code prefix for keys from macOS which do not have a Unicode - * representation. + * The plane value for keys which have a Unicode representation. */ -static const uint64_t kMacosPlane = 0x00500000000; +extern const uint64_t kUnicodePlane; + +/** + * The plane value for the private keys defined by the macOS embedding. + */ +extern const uint64_t kMacosPlane; /** * Map |NSEvent.keyCode| to its corresponding bitmask of NSEventModifierFlags. diff --git a/engine/src/flutter/shell/platform/embedder/BUILD.gn b/engine/src/flutter/shell/platform/embedder/BUILD.gn index b6d93bc60a..3d4db00dd1 100644 --- a/engine/src/flutter/shell/platform/embedder/BUILD.gn +++ b/engine/src/flutter/shell/platform/embedder/BUILD.gn @@ -128,7 +128,10 @@ source_set("embedder_headers") { } source_set("embedder_test_utils") { - public = [ "test_utils/proc_table_replacement.h" ] + public = [ + "test_utils/key_codes.h", + "test_utils/proc_table_replacement.h", + ] deps = [ ":embedder_headers" ] diff --git a/engine/src/flutter/shell/platform/embedder/test_utils/key_codes.h b/engine/src/flutter/shell/platform/embedder/test_utils/key_codes.h new file mode 100644 index 0000000000..45f1f913be --- /dev/null +++ b/engine/src/flutter/shell/platform/embedder/test_utils/key_codes.h @@ -0,0 +1,750 @@ +// Copyright 2013 The Flutter 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 FLUTTER_SHELL_PLATFORM_COMMON_TESTING_KEY_CODES_H_ +#define FLUTTER_SHELL_PLATFORM_COMMON_TESTING_KEY_CODES_H_ + +#include + +// DO NOT EDIT -- DO NOT EDIT -- DO NOT EDIT +// This file is generated by +// flutter/flutter:dev/tools/gen_keycodes/bin/gen_keycodes.dart and should not +// be edited directly. +// +// Edit the template +// flutter/flutter:dev/tools/gen_keycodes/data/key_codes_cc.tmpl +// instead. +// +// See flutter/flutter:dev/tools/gen_keycodes/README.md for more information. + +// This file contains keyboard constants to be used in unit tests. They should +// not be used in production code. + +namespace flutter { + +namespace testing { + +namespace keycodes { + +constexpr uint64_t kPhysicalHyper = 0x00000010; +constexpr uint64_t kPhysicalSuperKey = 0x00000011; +constexpr uint64_t kPhysicalFn = 0x00000012; +constexpr uint64_t kPhysicalFnLock = 0x00000013; +constexpr uint64_t kPhysicalSuspend = 0x00000014; +constexpr uint64_t kPhysicalResume = 0x00000015; +constexpr uint64_t kPhysicalTurbo = 0x00000016; +constexpr uint64_t kPhysicalPrivacyScreenToggle = 0x00000017; +constexpr uint64_t kPhysicalSleep = 0x00010082; +constexpr uint64_t kPhysicalWakeUp = 0x00010083; +constexpr uint64_t kPhysicalDisplayToggleIntExt = 0x000100b5; +constexpr uint64_t kPhysicalGameButton1 = 0x0005ff01; +constexpr uint64_t kPhysicalGameButton2 = 0x0005ff02; +constexpr uint64_t kPhysicalGameButton3 = 0x0005ff03; +constexpr uint64_t kPhysicalGameButton4 = 0x0005ff04; +constexpr uint64_t kPhysicalGameButton5 = 0x0005ff05; +constexpr uint64_t kPhysicalGameButton6 = 0x0005ff06; +constexpr uint64_t kPhysicalGameButton7 = 0x0005ff07; +constexpr uint64_t kPhysicalGameButton8 = 0x0005ff08; +constexpr uint64_t kPhysicalGameButton9 = 0x0005ff09; +constexpr uint64_t kPhysicalGameButton10 = 0x0005ff0a; +constexpr uint64_t kPhysicalGameButton11 = 0x0005ff0b; +constexpr uint64_t kPhysicalGameButton12 = 0x0005ff0c; +constexpr uint64_t kPhysicalGameButton13 = 0x0005ff0d; +constexpr uint64_t kPhysicalGameButton14 = 0x0005ff0e; +constexpr uint64_t kPhysicalGameButton15 = 0x0005ff0f; +constexpr uint64_t kPhysicalGameButton16 = 0x0005ff10; +constexpr uint64_t kPhysicalGameButtonA = 0x0005ff11; +constexpr uint64_t kPhysicalGameButtonB = 0x0005ff12; +constexpr uint64_t kPhysicalGameButtonC = 0x0005ff13; +constexpr uint64_t kPhysicalGameButtonLeft1 = 0x0005ff14; +constexpr uint64_t kPhysicalGameButtonLeft2 = 0x0005ff15; +constexpr uint64_t kPhysicalGameButtonMode = 0x0005ff16; +constexpr uint64_t kPhysicalGameButtonRight1 = 0x0005ff17; +constexpr uint64_t kPhysicalGameButtonRight2 = 0x0005ff18; +constexpr uint64_t kPhysicalGameButtonSelect = 0x0005ff19; +constexpr uint64_t kPhysicalGameButtonStart = 0x0005ff1a; +constexpr uint64_t kPhysicalGameButtonThumbLeft = 0x0005ff1b; +constexpr uint64_t kPhysicalGameButtonThumbRight = 0x0005ff1c; +constexpr uint64_t kPhysicalGameButtonX = 0x0005ff1d; +constexpr uint64_t kPhysicalGameButtonY = 0x0005ff1e; +constexpr uint64_t kPhysicalGameButtonZ = 0x0005ff1f; +constexpr uint64_t kPhysicalUsbReserved = 0x00070000; +constexpr uint64_t kPhysicalUsbErrorRollOver = 0x00070001; +constexpr uint64_t kPhysicalUsbPostFail = 0x00070002; +constexpr uint64_t kPhysicalUsbErrorUndefined = 0x00070003; +constexpr uint64_t kPhysicalKeyA = 0x00070004; +constexpr uint64_t kPhysicalKeyB = 0x00070005; +constexpr uint64_t kPhysicalKeyC = 0x00070006; +constexpr uint64_t kPhysicalKeyD = 0x00070007; +constexpr uint64_t kPhysicalKeyE = 0x00070008; +constexpr uint64_t kPhysicalKeyF = 0x00070009; +constexpr uint64_t kPhysicalKeyG = 0x0007000a; +constexpr uint64_t kPhysicalKeyH = 0x0007000b; +constexpr uint64_t kPhysicalKeyI = 0x0007000c; +constexpr uint64_t kPhysicalKeyJ = 0x0007000d; +constexpr uint64_t kPhysicalKeyK = 0x0007000e; +constexpr uint64_t kPhysicalKeyL = 0x0007000f; +constexpr uint64_t kPhysicalKeyM = 0x00070010; +constexpr uint64_t kPhysicalKeyN = 0x00070011; +constexpr uint64_t kPhysicalKeyO = 0x00070012; +constexpr uint64_t kPhysicalKeyP = 0x00070013; +constexpr uint64_t kPhysicalKeyQ = 0x00070014; +constexpr uint64_t kPhysicalKeyR = 0x00070015; +constexpr uint64_t kPhysicalKeyS = 0x00070016; +constexpr uint64_t kPhysicalKeyT = 0x00070017; +constexpr uint64_t kPhysicalKeyU = 0x00070018; +constexpr uint64_t kPhysicalKeyV = 0x00070019; +constexpr uint64_t kPhysicalKeyW = 0x0007001a; +constexpr uint64_t kPhysicalKeyX = 0x0007001b; +constexpr uint64_t kPhysicalKeyY = 0x0007001c; +constexpr uint64_t kPhysicalKeyZ = 0x0007001d; +constexpr uint64_t kPhysicalDigit1 = 0x0007001e; +constexpr uint64_t kPhysicalDigit2 = 0x0007001f; +constexpr uint64_t kPhysicalDigit3 = 0x00070020; +constexpr uint64_t kPhysicalDigit4 = 0x00070021; +constexpr uint64_t kPhysicalDigit5 = 0x00070022; +constexpr uint64_t kPhysicalDigit6 = 0x00070023; +constexpr uint64_t kPhysicalDigit7 = 0x00070024; +constexpr uint64_t kPhysicalDigit8 = 0x00070025; +constexpr uint64_t kPhysicalDigit9 = 0x00070026; +constexpr uint64_t kPhysicalDigit0 = 0x00070027; +constexpr uint64_t kPhysicalEnter = 0x00070028; +constexpr uint64_t kPhysicalEscape = 0x00070029; +constexpr uint64_t kPhysicalBackspace = 0x0007002a; +constexpr uint64_t kPhysicalTab = 0x0007002b; +constexpr uint64_t kPhysicalSpace = 0x0007002c; +constexpr uint64_t kPhysicalMinus = 0x0007002d; +constexpr uint64_t kPhysicalEqual = 0x0007002e; +constexpr uint64_t kPhysicalBracketLeft = 0x0007002f; +constexpr uint64_t kPhysicalBracketRight = 0x00070030; +constexpr uint64_t kPhysicalBackslash = 0x00070031; +constexpr uint64_t kPhysicalSemicolon = 0x00070033; +constexpr uint64_t kPhysicalQuote = 0x00070034; +constexpr uint64_t kPhysicalBackquote = 0x00070035; +constexpr uint64_t kPhysicalComma = 0x00070036; +constexpr uint64_t kPhysicalPeriod = 0x00070037; +constexpr uint64_t kPhysicalSlash = 0x00070038; +constexpr uint64_t kPhysicalCapsLock = 0x00070039; +constexpr uint64_t kPhysicalF1 = 0x0007003a; +constexpr uint64_t kPhysicalF2 = 0x0007003b; +constexpr uint64_t kPhysicalF3 = 0x0007003c; +constexpr uint64_t kPhysicalF4 = 0x0007003d; +constexpr uint64_t kPhysicalF5 = 0x0007003e; +constexpr uint64_t kPhysicalF6 = 0x0007003f; +constexpr uint64_t kPhysicalF7 = 0x00070040; +constexpr uint64_t kPhysicalF8 = 0x00070041; +constexpr uint64_t kPhysicalF9 = 0x00070042; +constexpr uint64_t kPhysicalF10 = 0x00070043; +constexpr uint64_t kPhysicalF11 = 0x00070044; +constexpr uint64_t kPhysicalF12 = 0x00070045; +constexpr uint64_t kPhysicalPrintScreen = 0x00070046; +constexpr uint64_t kPhysicalScrollLock = 0x00070047; +constexpr uint64_t kPhysicalPause = 0x00070048; +constexpr uint64_t kPhysicalInsert = 0x00070049; +constexpr uint64_t kPhysicalHome = 0x0007004a; +constexpr uint64_t kPhysicalPageUp = 0x0007004b; +constexpr uint64_t kPhysicalDelete = 0x0007004c; +constexpr uint64_t kPhysicalEnd = 0x0007004d; +constexpr uint64_t kPhysicalPageDown = 0x0007004e; +constexpr uint64_t kPhysicalArrowRight = 0x0007004f; +constexpr uint64_t kPhysicalArrowLeft = 0x00070050; +constexpr uint64_t kPhysicalArrowDown = 0x00070051; +constexpr uint64_t kPhysicalArrowUp = 0x00070052; +constexpr uint64_t kPhysicalNumLock = 0x00070053; +constexpr uint64_t kPhysicalNumpadDivide = 0x00070054; +constexpr uint64_t kPhysicalNumpadMultiply = 0x00070055; +constexpr uint64_t kPhysicalNumpadSubtract = 0x00070056; +constexpr uint64_t kPhysicalNumpadAdd = 0x00070057; +constexpr uint64_t kPhysicalNumpadEnter = 0x00070058; +constexpr uint64_t kPhysicalNumpad1 = 0x00070059; +constexpr uint64_t kPhysicalNumpad2 = 0x0007005a; +constexpr uint64_t kPhysicalNumpad3 = 0x0007005b; +constexpr uint64_t kPhysicalNumpad4 = 0x0007005c; +constexpr uint64_t kPhysicalNumpad5 = 0x0007005d; +constexpr uint64_t kPhysicalNumpad6 = 0x0007005e; +constexpr uint64_t kPhysicalNumpad7 = 0x0007005f; +constexpr uint64_t kPhysicalNumpad8 = 0x00070060; +constexpr uint64_t kPhysicalNumpad9 = 0x00070061; +constexpr uint64_t kPhysicalNumpad0 = 0x00070062; +constexpr uint64_t kPhysicalNumpadDecimal = 0x00070063; +constexpr uint64_t kPhysicalIntlBackslash = 0x00070064; +constexpr uint64_t kPhysicalContextMenu = 0x00070065; +constexpr uint64_t kPhysicalPower = 0x00070066; +constexpr uint64_t kPhysicalNumpadEqual = 0x00070067; +constexpr uint64_t kPhysicalF13 = 0x00070068; +constexpr uint64_t kPhysicalF14 = 0x00070069; +constexpr uint64_t kPhysicalF15 = 0x0007006a; +constexpr uint64_t kPhysicalF16 = 0x0007006b; +constexpr uint64_t kPhysicalF17 = 0x0007006c; +constexpr uint64_t kPhysicalF18 = 0x0007006d; +constexpr uint64_t kPhysicalF19 = 0x0007006e; +constexpr uint64_t kPhysicalF20 = 0x0007006f; +constexpr uint64_t kPhysicalF21 = 0x00070070; +constexpr uint64_t kPhysicalF22 = 0x00070071; +constexpr uint64_t kPhysicalF23 = 0x00070072; +constexpr uint64_t kPhysicalF24 = 0x00070073; +constexpr uint64_t kPhysicalOpen = 0x00070074; +constexpr uint64_t kPhysicalHelp = 0x00070075; +constexpr uint64_t kPhysicalSelect = 0x00070077; +constexpr uint64_t kPhysicalAgain = 0x00070079; +constexpr uint64_t kPhysicalUndo = 0x0007007a; +constexpr uint64_t kPhysicalCut = 0x0007007b; +constexpr uint64_t kPhysicalCopy = 0x0007007c; +constexpr uint64_t kPhysicalPaste = 0x0007007d; +constexpr uint64_t kPhysicalFind = 0x0007007e; +constexpr uint64_t kPhysicalAudioVolumeMute = 0x0007007f; +constexpr uint64_t kPhysicalAudioVolumeUp = 0x00070080; +constexpr uint64_t kPhysicalAudioVolumeDown = 0x00070081; +constexpr uint64_t kPhysicalNumpadComma = 0x00070085; +constexpr uint64_t kPhysicalIntlRo = 0x00070087; +constexpr uint64_t kPhysicalKanaMode = 0x00070088; +constexpr uint64_t kPhysicalIntlYen = 0x00070089; +constexpr uint64_t kPhysicalConvert = 0x0007008a; +constexpr uint64_t kPhysicalNonConvert = 0x0007008b; +constexpr uint64_t kPhysicalLang1 = 0x00070090; +constexpr uint64_t kPhysicalLang2 = 0x00070091; +constexpr uint64_t kPhysicalLang3 = 0x00070092; +constexpr uint64_t kPhysicalLang4 = 0x00070093; +constexpr uint64_t kPhysicalLang5 = 0x00070094; +constexpr uint64_t kPhysicalAbort = 0x0007009b; +constexpr uint64_t kPhysicalProps = 0x000700a3; +constexpr uint64_t kPhysicalNumpadParenLeft = 0x000700b6; +constexpr uint64_t kPhysicalNumpadParenRight = 0x000700b7; +constexpr uint64_t kPhysicalNumpadBackspace = 0x000700bb; +constexpr uint64_t kPhysicalNumpadMemoryStore = 0x000700d0; +constexpr uint64_t kPhysicalNumpadMemoryRecall = 0x000700d1; +constexpr uint64_t kPhysicalNumpadMemoryClear = 0x000700d2; +constexpr uint64_t kPhysicalNumpadMemoryAdd = 0x000700d3; +constexpr uint64_t kPhysicalNumpadMemorySubtract = 0x000700d4; +constexpr uint64_t kPhysicalNumpadSignChange = 0x000700d7; +constexpr uint64_t kPhysicalNumpadClear = 0x000700d8; +constexpr uint64_t kPhysicalNumpadClearEntry = 0x000700d9; +constexpr uint64_t kPhysicalControlLeft = 0x000700e0; +constexpr uint64_t kPhysicalShiftLeft = 0x000700e1; +constexpr uint64_t kPhysicalAltLeft = 0x000700e2; +constexpr uint64_t kPhysicalMetaLeft = 0x000700e3; +constexpr uint64_t kPhysicalControlRight = 0x000700e4; +constexpr uint64_t kPhysicalShiftRight = 0x000700e5; +constexpr uint64_t kPhysicalAltRight = 0x000700e6; +constexpr uint64_t kPhysicalMetaRight = 0x000700e7; +constexpr uint64_t kPhysicalInfo = 0x000c0060; +constexpr uint64_t kPhysicalClosedCaptionToggle = 0x000c0061; +constexpr uint64_t kPhysicalBrightnessUp = 0x000c006f; +constexpr uint64_t kPhysicalBrightnessDown = 0x000c0070; +constexpr uint64_t kPhysicalBrightnessToggle = 0x000c0072; +constexpr uint64_t kPhysicalBrightnessMinimum = 0x000c0073; +constexpr uint64_t kPhysicalBrightnessMaximum = 0x000c0074; +constexpr uint64_t kPhysicalBrightnessAuto = 0x000c0075; +constexpr uint64_t kPhysicalKbdIllumUp = 0x000c0079; +constexpr uint64_t kPhysicalKbdIllumDown = 0x000c007a; +constexpr uint64_t kPhysicalMediaLast = 0x000c0083; +constexpr uint64_t kPhysicalLaunchPhone = 0x000c008c; +constexpr uint64_t kPhysicalProgramGuide = 0x000c008d; +constexpr uint64_t kPhysicalExit = 0x000c0094; +constexpr uint64_t kPhysicalChannelUp = 0x000c009c; +constexpr uint64_t kPhysicalChannelDown = 0x000c009d; +constexpr uint64_t kPhysicalMediaPlay = 0x000c00b0; +constexpr uint64_t kPhysicalMediaPause = 0x000c00b1; +constexpr uint64_t kPhysicalMediaRecord = 0x000c00b2; +constexpr uint64_t kPhysicalMediaFastForward = 0x000c00b3; +constexpr uint64_t kPhysicalMediaRewind = 0x000c00b4; +constexpr uint64_t kPhysicalMediaTrackNext = 0x000c00b5; +constexpr uint64_t kPhysicalMediaTrackPrevious = 0x000c00b6; +constexpr uint64_t kPhysicalMediaStop = 0x000c00b7; +constexpr uint64_t kPhysicalEject = 0x000c00b8; +constexpr uint64_t kPhysicalMediaPlayPause = 0x000c00cd; +constexpr uint64_t kPhysicalSpeechInputToggle = 0x000c00cf; +constexpr uint64_t kPhysicalBassBoost = 0x000c00e5; +constexpr uint64_t kPhysicalMediaSelect = 0x000c0183; +constexpr uint64_t kPhysicalLaunchWordProcessor = 0x000c0184; +constexpr uint64_t kPhysicalLaunchSpreadsheet = 0x000c0186; +constexpr uint64_t kPhysicalLaunchMail = 0x000c018a; +constexpr uint64_t kPhysicalLaunchContacts = 0x000c018d; +constexpr uint64_t kPhysicalLaunchCalendar = 0x000c018e; +constexpr uint64_t kPhysicalLaunchApp2 = 0x000c0192; +constexpr uint64_t kPhysicalLaunchApp1 = 0x000c0194; +constexpr uint64_t kPhysicalLaunchInternetBrowser = 0x000c0196; +constexpr uint64_t kPhysicalLogOff = 0x000c019c; +constexpr uint64_t kPhysicalLockScreen = 0x000c019e; +constexpr uint64_t kPhysicalLaunchControlPanel = 0x000c019f; +constexpr uint64_t kPhysicalSelectTask = 0x000c01a2; +constexpr uint64_t kPhysicalLaunchDocuments = 0x000c01a7; +constexpr uint64_t kPhysicalSpellCheck = 0x000c01ab; +constexpr uint64_t kPhysicalLaunchKeyboardLayout = 0x000c01ae; +constexpr uint64_t kPhysicalLaunchScreenSaver = 0x000c01b1; +constexpr uint64_t kPhysicalLaunchAudioBrowser = 0x000c01b7; +constexpr uint64_t kPhysicalLaunchAssistant = 0x000c01cb; +constexpr uint64_t kPhysicalNewKey = 0x000c0201; +constexpr uint64_t kPhysicalClose = 0x000c0203; +constexpr uint64_t kPhysicalSave = 0x000c0207; +constexpr uint64_t kPhysicalPrint = 0x000c0208; +constexpr uint64_t kPhysicalBrowserSearch = 0x000c0221; +constexpr uint64_t kPhysicalBrowserHome = 0x000c0223; +constexpr uint64_t kPhysicalBrowserBack = 0x000c0224; +constexpr uint64_t kPhysicalBrowserForward = 0x000c0225; +constexpr uint64_t kPhysicalBrowserStop = 0x000c0226; +constexpr uint64_t kPhysicalBrowserRefresh = 0x000c0227; +constexpr uint64_t kPhysicalBrowserFavorites = 0x000c022a; +constexpr uint64_t kPhysicalZoomIn = 0x000c022d; +constexpr uint64_t kPhysicalZoomOut = 0x000c022e; +constexpr uint64_t kPhysicalZoomToggle = 0x000c0232; +constexpr uint64_t kPhysicalRedo = 0x000c0279; +constexpr uint64_t kPhysicalMailReply = 0x000c0289; +constexpr uint64_t kPhysicalMailForward = 0x000c028b; +constexpr uint64_t kPhysicalMailSend = 0x000c028c; +constexpr uint64_t kPhysicalKeyboardLayoutSelect = 0x000c029d; +constexpr uint64_t kPhysicalShowAllWindows = 0x000c029f; + +constexpr uint64_t kLogicalSpace = 0x00000000020; +constexpr uint64_t kLogicalExclamation = 0x00000000021; +constexpr uint64_t kLogicalQuote = 0x00000000022; +constexpr uint64_t kLogicalNumberSign = 0x00000000023; +constexpr uint64_t kLogicalDollar = 0x00000000024; +constexpr uint64_t kLogicalPercent = 0x00000000025; +constexpr uint64_t kLogicalAmpersand = 0x00000000026; +constexpr uint64_t kLogicalQuoteSingle = 0x00000000027; +constexpr uint64_t kLogicalParenthesisLeft = 0x00000000028; +constexpr uint64_t kLogicalParenthesisRight = 0x00000000029; +constexpr uint64_t kLogicalAsterisk = 0x0000000002a; +constexpr uint64_t kLogicalAdd = 0x0000000002b; +constexpr uint64_t kLogicalComma = 0x0000000002c; +constexpr uint64_t kLogicalMinus = 0x0000000002d; +constexpr uint64_t kLogicalPeriod = 0x0000000002e; +constexpr uint64_t kLogicalSlash = 0x0000000002f; +constexpr uint64_t kLogicalDigit0 = 0x00000000030; +constexpr uint64_t kLogicalDigit1 = 0x00000000031; +constexpr uint64_t kLogicalDigit2 = 0x00000000032; +constexpr uint64_t kLogicalDigit3 = 0x00000000033; +constexpr uint64_t kLogicalDigit4 = 0x00000000034; +constexpr uint64_t kLogicalDigit5 = 0x00000000035; +constexpr uint64_t kLogicalDigit6 = 0x00000000036; +constexpr uint64_t kLogicalDigit7 = 0x00000000037; +constexpr uint64_t kLogicalDigit8 = 0x00000000038; +constexpr uint64_t kLogicalDigit9 = 0x00000000039; +constexpr uint64_t kLogicalColon = 0x0000000003a; +constexpr uint64_t kLogicalSemicolon = 0x0000000003b; +constexpr uint64_t kLogicalLess = 0x0000000003c; +constexpr uint64_t kLogicalEqual = 0x0000000003d; +constexpr uint64_t kLogicalGreater = 0x0000000003e; +constexpr uint64_t kLogicalQuestion = 0x0000000003f; +constexpr uint64_t kLogicalAt = 0x00000000040; +constexpr uint64_t kLogicalBracketLeft = 0x0000000005b; +constexpr uint64_t kLogicalBackslash = 0x0000000005c; +constexpr uint64_t kLogicalBracketRight = 0x0000000005d; +constexpr uint64_t kLogicalCaret = 0x0000000005e; +constexpr uint64_t kLogicalUnderscore = 0x0000000005f; +constexpr uint64_t kLogicalBackquote = 0x00000000060; +constexpr uint64_t kLogicalKeyA = 0x00000000061; +constexpr uint64_t kLogicalKeyB = 0x00000000062; +constexpr uint64_t kLogicalKeyC = 0x00000000063; +constexpr uint64_t kLogicalKeyD = 0x00000000064; +constexpr uint64_t kLogicalKeyE = 0x00000000065; +constexpr uint64_t kLogicalKeyF = 0x00000000066; +constexpr uint64_t kLogicalKeyG = 0x00000000067; +constexpr uint64_t kLogicalKeyH = 0x00000000068; +constexpr uint64_t kLogicalKeyI = 0x00000000069; +constexpr uint64_t kLogicalKeyJ = 0x0000000006a; +constexpr uint64_t kLogicalKeyK = 0x0000000006b; +constexpr uint64_t kLogicalKeyL = 0x0000000006c; +constexpr uint64_t kLogicalKeyM = 0x0000000006d; +constexpr uint64_t kLogicalKeyN = 0x0000000006e; +constexpr uint64_t kLogicalKeyO = 0x0000000006f; +constexpr uint64_t kLogicalKeyP = 0x00000000070; +constexpr uint64_t kLogicalKeyQ = 0x00000000071; +constexpr uint64_t kLogicalKeyR = 0x00000000072; +constexpr uint64_t kLogicalKeyS = 0x00000000073; +constexpr uint64_t kLogicalKeyT = 0x00000000074; +constexpr uint64_t kLogicalKeyU = 0x00000000075; +constexpr uint64_t kLogicalKeyV = 0x00000000076; +constexpr uint64_t kLogicalKeyW = 0x00000000077; +constexpr uint64_t kLogicalKeyX = 0x00000000078; +constexpr uint64_t kLogicalKeyY = 0x00000000079; +constexpr uint64_t kLogicalKeyZ = 0x0000000007a; +constexpr uint64_t kLogicalBraceLeft = 0x0000000007b; +constexpr uint64_t kLogicalBar = 0x0000000007c; +constexpr uint64_t kLogicalBraceRight = 0x0000000007d; +constexpr uint64_t kLogicalTilde = 0x0000000007e; +constexpr uint64_t kLogicalUnidentified = 0x00100000001; +constexpr uint64_t kLogicalBackspace = 0x00100000008; +constexpr uint64_t kLogicalTab = 0x00100000009; +constexpr uint64_t kLogicalEnter = 0x0010000000d; +constexpr uint64_t kLogicalEscape = 0x0010000001b; +constexpr uint64_t kLogicalDelete = 0x0010000007f; +constexpr uint64_t kLogicalAccel = 0x00100000101; +constexpr uint64_t kLogicalAltGraph = 0x00100000103; +constexpr uint64_t kLogicalCapsLock = 0x00100000104; +constexpr uint64_t kLogicalFn = 0x00100000106; +constexpr uint64_t kLogicalFnLock = 0x00100000107; +constexpr uint64_t kLogicalHyper = 0x00100000108; +constexpr uint64_t kLogicalNumLock = 0x0010000010a; +constexpr uint64_t kLogicalScrollLock = 0x0010000010c; +constexpr uint64_t kLogicalSuperKey = 0x0010000010e; +constexpr uint64_t kLogicalSymbol = 0x0010000010f; +constexpr uint64_t kLogicalSymbolLock = 0x00100000110; +constexpr uint64_t kLogicalShiftLevel5 = 0x00100000111; +constexpr uint64_t kLogicalArrowDown = 0x00100000301; +constexpr uint64_t kLogicalArrowLeft = 0x00100000302; +constexpr uint64_t kLogicalArrowRight = 0x00100000303; +constexpr uint64_t kLogicalArrowUp = 0x00100000304; +constexpr uint64_t kLogicalEnd = 0x00100000305; +constexpr uint64_t kLogicalHome = 0x00100000306; +constexpr uint64_t kLogicalPageDown = 0x00100000307; +constexpr uint64_t kLogicalPageUp = 0x00100000308; +constexpr uint64_t kLogicalClear = 0x00100000401; +constexpr uint64_t kLogicalCopy = 0x00100000402; +constexpr uint64_t kLogicalCrSel = 0x00100000403; +constexpr uint64_t kLogicalCut = 0x00100000404; +constexpr uint64_t kLogicalEraseEof = 0x00100000405; +constexpr uint64_t kLogicalExSel = 0x00100000406; +constexpr uint64_t kLogicalInsert = 0x00100000407; +constexpr uint64_t kLogicalPaste = 0x00100000408; +constexpr uint64_t kLogicalRedo = 0x00100000409; +constexpr uint64_t kLogicalUndo = 0x0010000040a; +constexpr uint64_t kLogicalAccept = 0x00100000501; +constexpr uint64_t kLogicalAgain = 0x00100000502; +constexpr uint64_t kLogicalAttn = 0x00100000503; +constexpr uint64_t kLogicalCancel = 0x00100000504; +constexpr uint64_t kLogicalContextMenu = 0x00100000505; +constexpr uint64_t kLogicalExecute = 0x00100000506; +constexpr uint64_t kLogicalFind = 0x00100000507; +constexpr uint64_t kLogicalHelp = 0x00100000508; +constexpr uint64_t kLogicalPause = 0x00100000509; +constexpr uint64_t kLogicalPlay = 0x0010000050a; +constexpr uint64_t kLogicalProps = 0x0010000050b; +constexpr uint64_t kLogicalSelect = 0x0010000050c; +constexpr uint64_t kLogicalZoomIn = 0x0010000050d; +constexpr uint64_t kLogicalZoomOut = 0x0010000050e; +constexpr uint64_t kLogicalBrightnessDown = 0x00100000601; +constexpr uint64_t kLogicalBrightnessUp = 0x00100000602; +constexpr uint64_t kLogicalCamera = 0x00100000603; +constexpr uint64_t kLogicalEject = 0x00100000604; +constexpr uint64_t kLogicalLogOff = 0x00100000605; +constexpr uint64_t kLogicalPower = 0x00100000606; +constexpr uint64_t kLogicalPowerOff = 0x00100000607; +constexpr uint64_t kLogicalPrintScreen = 0x00100000608; +constexpr uint64_t kLogicalHibernate = 0x00100000609; +constexpr uint64_t kLogicalStandby = 0x0010000060a; +constexpr uint64_t kLogicalWakeUp = 0x0010000060b; +constexpr uint64_t kLogicalAllCandidates = 0x00100000701; +constexpr uint64_t kLogicalAlphanumeric = 0x00100000702; +constexpr uint64_t kLogicalCodeInput = 0x00100000703; +constexpr uint64_t kLogicalCompose = 0x00100000704; +constexpr uint64_t kLogicalConvert = 0x00100000705; +constexpr uint64_t kLogicalFinalMode = 0x00100000706; +constexpr uint64_t kLogicalGroupFirst = 0x00100000707; +constexpr uint64_t kLogicalGroupLast = 0x00100000708; +constexpr uint64_t kLogicalGroupNext = 0x00100000709; +constexpr uint64_t kLogicalGroupPrevious = 0x0010000070a; +constexpr uint64_t kLogicalModeChange = 0x0010000070b; +constexpr uint64_t kLogicalNextCandidate = 0x0010000070c; +constexpr uint64_t kLogicalNonConvert = 0x0010000070d; +constexpr uint64_t kLogicalPreviousCandidate = 0x0010000070e; +constexpr uint64_t kLogicalProcess = 0x0010000070f; +constexpr uint64_t kLogicalSingleCandidate = 0x00100000710; +constexpr uint64_t kLogicalHangulMode = 0x00100000711; +constexpr uint64_t kLogicalHanjaMode = 0x00100000712; +constexpr uint64_t kLogicalJunjaMode = 0x00100000713; +constexpr uint64_t kLogicalEisu = 0x00100000714; +constexpr uint64_t kLogicalHankaku = 0x00100000715; +constexpr uint64_t kLogicalHiragana = 0x00100000716; +constexpr uint64_t kLogicalHiraganaKatakana = 0x00100000717; +constexpr uint64_t kLogicalKanaMode = 0x00100000718; +constexpr uint64_t kLogicalKanjiMode = 0x00100000719; +constexpr uint64_t kLogicalKatakana = 0x0010000071a; +constexpr uint64_t kLogicalRomaji = 0x0010000071b; +constexpr uint64_t kLogicalZenkaku = 0x0010000071c; +constexpr uint64_t kLogicalZenkakuHankaku = 0x0010000071d; +constexpr uint64_t kLogicalF1 = 0x00100000801; +constexpr uint64_t kLogicalF2 = 0x00100000802; +constexpr uint64_t kLogicalF3 = 0x00100000803; +constexpr uint64_t kLogicalF4 = 0x00100000804; +constexpr uint64_t kLogicalF5 = 0x00100000805; +constexpr uint64_t kLogicalF6 = 0x00100000806; +constexpr uint64_t kLogicalF7 = 0x00100000807; +constexpr uint64_t kLogicalF8 = 0x00100000808; +constexpr uint64_t kLogicalF9 = 0x00100000809; +constexpr uint64_t kLogicalF10 = 0x0010000080a; +constexpr uint64_t kLogicalF11 = 0x0010000080b; +constexpr uint64_t kLogicalF12 = 0x0010000080c; +constexpr uint64_t kLogicalF13 = 0x0010000080d; +constexpr uint64_t kLogicalF14 = 0x0010000080e; +constexpr uint64_t kLogicalF15 = 0x0010000080f; +constexpr uint64_t kLogicalF16 = 0x00100000810; +constexpr uint64_t kLogicalF17 = 0x00100000811; +constexpr uint64_t kLogicalF18 = 0x00100000812; +constexpr uint64_t kLogicalF19 = 0x00100000813; +constexpr uint64_t kLogicalF20 = 0x00100000814; +constexpr uint64_t kLogicalF21 = 0x00100000815; +constexpr uint64_t kLogicalF22 = 0x00100000816; +constexpr uint64_t kLogicalF23 = 0x00100000817; +constexpr uint64_t kLogicalF24 = 0x00100000818; +constexpr uint64_t kLogicalSoft1 = 0x00100000901; +constexpr uint64_t kLogicalSoft2 = 0x00100000902; +constexpr uint64_t kLogicalSoft3 = 0x00100000903; +constexpr uint64_t kLogicalSoft4 = 0x00100000904; +constexpr uint64_t kLogicalSoft5 = 0x00100000905; +constexpr uint64_t kLogicalSoft6 = 0x00100000906; +constexpr uint64_t kLogicalSoft7 = 0x00100000907; +constexpr uint64_t kLogicalSoft8 = 0x00100000908; +constexpr uint64_t kLogicalClose = 0x00100000a01; +constexpr uint64_t kLogicalMailForward = 0x00100000a02; +constexpr uint64_t kLogicalMailReply = 0x00100000a03; +constexpr uint64_t kLogicalMailSend = 0x00100000a04; +constexpr uint64_t kLogicalMediaPlayPause = 0x00100000a05; +constexpr uint64_t kLogicalMediaStop = 0x00100000a07; +constexpr uint64_t kLogicalMediaTrackNext = 0x00100000a08; +constexpr uint64_t kLogicalMediaTrackPrevious = 0x00100000a09; +constexpr uint64_t kLogicalNewKey = 0x00100000a0a; +constexpr uint64_t kLogicalOpen = 0x00100000a0b; +constexpr uint64_t kLogicalPrint = 0x00100000a0c; +constexpr uint64_t kLogicalSave = 0x00100000a0d; +constexpr uint64_t kLogicalSpellCheck = 0x00100000a0e; +constexpr uint64_t kLogicalAudioVolumeDown = 0x00100000a0f; +constexpr uint64_t kLogicalAudioVolumeUp = 0x00100000a10; +constexpr uint64_t kLogicalAudioVolumeMute = 0x00100000a11; +constexpr uint64_t kLogicalLaunchApplication2 = 0x00100000b01; +constexpr uint64_t kLogicalLaunchCalendar = 0x00100000b02; +constexpr uint64_t kLogicalLaunchMail = 0x00100000b03; +constexpr uint64_t kLogicalLaunchMediaPlayer = 0x00100000b04; +constexpr uint64_t kLogicalLaunchMusicPlayer = 0x00100000b05; +constexpr uint64_t kLogicalLaunchApplication1 = 0x00100000b06; +constexpr uint64_t kLogicalLaunchScreenSaver = 0x00100000b07; +constexpr uint64_t kLogicalLaunchSpreadsheet = 0x00100000b08; +constexpr uint64_t kLogicalLaunchWebBrowser = 0x00100000b09; +constexpr uint64_t kLogicalLaunchWebCam = 0x00100000b0a; +constexpr uint64_t kLogicalLaunchWordProcessor = 0x00100000b0b; +constexpr uint64_t kLogicalLaunchContacts = 0x00100000b0c; +constexpr uint64_t kLogicalLaunchPhone = 0x00100000b0d; +constexpr uint64_t kLogicalLaunchAssistant = 0x00100000b0e; +constexpr uint64_t kLogicalLaunchControlPanel = 0x00100000b0f; +constexpr uint64_t kLogicalBrowserBack = 0x00100000c01; +constexpr uint64_t kLogicalBrowserFavorites = 0x00100000c02; +constexpr uint64_t kLogicalBrowserForward = 0x00100000c03; +constexpr uint64_t kLogicalBrowserHome = 0x00100000c04; +constexpr uint64_t kLogicalBrowserRefresh = 0x00100000c05; +constexpr uint64_t kLogicalBrowserSearch = 0x00100000c06; +constexpr uint64_t kLogicalBrowserStop = 0x00100000c07; +constexpr uint64_t kLogicalAudioBalanceLeft = 0x00100000d01; +constexpr uint64_t kLogicalAudioBalanceRight = 0x00100000d02; +constexpr uint64_t kLogicalAudioBassBoostDown = 0x00100000d03; +constexpr uint64_t kLogicalAudioBassBoostUp = 0x00100000d04; +constexpr uint64_t kLogicalAudioFaderFront = 0x00100000d05; +constexpr uint64_t kLogicalAudioFaderRear = 0x00100000d06; +constexpr uint64_t kLogicalAudioSurroundModeNext = 0x00100000d07; +constexpr uint64_t kLogicalAvrInput = 0x00100000d08; +constexpr uint64_t kLogicalAvrPower = 0x00100000d09; +constexpr uint64_t kLogicalChannelDown = 0x00100000d0a; +constexpr uint64_t kLogicalChannelUp = 0x00100000d0b; +constexpr uint64_t kLogicalColorF0Red = 0x00100000d0c; +constexpr uint64_t kLogicalColorF1Green = 0x00100000d0d; +constexpr uint64_t kLogicalColorF2Yellow = 0x00100000d0e; +constexpr uint64_t kLogicalColorF3Blue = 0x00100000d0f; +constexpr uint64_t kLogicalColorF4Grey = 0x00100000d10; +constexpr uint64_t kLogicalColorF5Brown = 0x00100000d11; +constexpr uint64_t kLogicalClosedCaptionToggle = 0x00100000d12; +constexpr uint64_t kLogicalDimmer = 0x00100000d13; +constexpr uint64_t kLogicalDisplaySwap = 0x00100000d14; +constexpr uint64_t kLogicalExit = 0x00100000d15; +constexpr uint64_t kLogicalFavoriteClear0 = 0x00100000d16; +constexpr uint64_t kLogicalFavoriteClear1 = 0x00100000d17; +constexpr uint64_t kLogicalFavoriteClear2 = 0x00100000d18; +constexpr uint64_t kLogicalFavoriteClear3 = 0x00100000d19; +constexpr uint64_t kLogicalFavoriteRecall0 = 0x00100000d1a; +constexpr uint64_t kLogicalFavoriteRecall1 = 0x00100000d1b; +constexpr uint64_t kLogicalFavoriteRecall2 = 0x00100000d1c; +constexpr uint64_t kLogicalFavoriteRecall3 = 0x00100000d1d; +constexpr uint64_t kLogicalFavoriteStore0 = 0x00100000d1e; +constexpr uint64_t kLogicalFavoriteStore1 = 0x00100000d1f; +constexpr uint64_t kLogicalFavoriteStore2 = 0x00100000d20; +constexpr uint64_t kLogicalFavoriteStore3 = 0x00100000d21; +constexpr uint64_t kLogicalGuide = 0x00100000d22; +constexpr uint64_t kLogicalGuideNextDay = 0x00100000d23; +constexpr uint64_t kLogicalGuidePreviousDay = 0x00100000d24; +constexpr uint64_t kLogicalInfo = 0x00100000d25; +constexpr uint64_t kLogicalInstantReplay = 0x00100000d26; +constexpr uint64_t kLogicalLink = 0x00100000d27; +constexpr uint64_t kLogicalListProgram = 0x00100000d28; +constexpr uint64_t kLogicalLiveContent = 0x00100000d29; +constexpr uint64_t kLogicalLock = 0x00100000d2a; +constexpr uint64_t kLogicalMediaApps = 0x00100000d2b; +constexpr uint64_t kLogicalMediaFastForward = 0x00100000d2c; +constexpr uint64_t kLogicalMediaLast = 0x00100000d2d; +constexpr uint64_t kLogicalMediaPause = 0x00100000d2e; +constexpr uint64_t kLogicalMediaPlay = 0x00100000d2f; +constexpr uint64_t kLogicalMediaRecord = 0x00100000d30; +constexpr uint64_t kLogicalMediaRewind = 0x00100000d31; +constexpr uint64_t kLogicalMediaSkip = 0x00100000d32; +constexpr uint64_t kLogicalNextFavoriteChannel = 0x00100000d33; +constexpr uint64_t kLogicalNextUserProfile = 0x00100000d34; +constexpr uint64_t kLogicalOnDemand = 0x00100000d35; +constexpr uint64_t kLogicalPInPDown = 0x00100000d36; +constexpr uint64_t kLogicalPInPMove = 0x00100000d37; +constexpr uint64_t kLogicalPInPToggle = 0x00100000d38; +constexpr uint64_t kLogicalPInPUp = 0x00100000d39; +constexpr uint64_t kLogicalPlaySpeedDown = 0x00100000d3a; +constexpr uint64_t kLogicalPlaySpeedReset = 0x00100000d3b; +constexpr uint64_t kLogicalPlaySpeedUp = 0x00100000d3c; +constexpr uint64_t kLogicalRandomToggle = 0x00100000d3d; +constexpr uint64_t kLogicalRcLowBattery = 0x00100000d3e; +constexpr uint64_t kLogicalRecordSpeedNext = 0x00100000d3f; +constexpr uint64_t kLogicalRfBypass = 0x00100000d40; +constexpr uint64_t kLogicalScanChannelsToggle = 0x00100000d41; +constexpr uint64_t kLogicalScreenModeNext = 0x00100000d42; +constexpr uint64_t kLogicalSettings = 0x00100000d43; +constexpr uint64_t kLogicalSplitScreenToggle = 0x00100000d44; +constexpr uint64_t kLogicalStbInput = 0x00100000d45; +constexpr uint64_t kLogicalStbPower = 0x00100000d46; +constexpr uint64_t kLogicalSubtitle = 0x00100000d47; +constexpr uint64_t kLogicalTeletext = 0x00100000d48; +constexpr uint64_t kLogicalTv = 0x00100000d49; +constexpr uint64_t kLogicalTvInput = 0x00100000d4a; +constexpr uint64_t kLogicalTvPower = 0x00100000d4b; +constexpr uint64_t kLogicalVideoModeNext = 0x00100000d4c; +constexpr uint64_t kLogicalWink = 0x00100000d4d; +constexpr uint64_t kLogicalZoomToggle = 0x00100000d4e; +constexpr uint64_t kLogicalDvr = 0x00100000d4f; +constexpr uint64_t kLogicalMediaAudioTrack = 0x00100000d50; +constexpr uint64_t kLogicalMediaSkipBackward = 0x00100000d51; +constexpr uint64_t kLogicalMediaSkipForward = 0x00100000d52; +constexpr uint64_t kLogicalMediaStepBackward = 0x00100000d53; +constexpr uint64_t kLogicalMediaStepForward = 0x00100000d54; +constexpr uint64_t kLogicalMediaTopMenu = 0x00100000d55; +constexpr uint64_t kLogicalNavigateIn = 0x00100000d56; +constexpr uint64_t kLogicalNavigateNext = 0x00100000d57; +constexpr uint64_t kLogicalNavigateOut = 0x00100000d58; +constexpr uint64_t kLogicalNavigatePrevious = 0x00100000d59; +constexpr uint64_t kLogicalPairing = 0x00100000d5a; +constexpr uint64_t kLogicalMediaClose = 0x00100000d5b; +constexpr uint64_t kLogicalAudioBassBoostToggle = 0x00100000e02; +constexpr uint64_t kLogicalAudioTrebleDown = 0x00100000e04; +constexpr uint64_t kLogicalAudioTrebleUp = 0x00100000e05; +constexpr uint64_t kLogicalMicrophoneToggle = 0x00100000e06; +constexpr uint64_t kLogicalMicrophoneVolumeDown = 0x00100000e07; +constexpr uint64_t kLogicalMicrophoneVolumeUp = 0x00100000e08; +constexpr uint64_t kLogicalMicrophoneVolumeMute = 0x00100000e09; +constexpr uint64_t kLogicalSpeechCorrectionList = 0x00100000f01; +constexpr uint64_t kLogicalSpeechInputToggle = 0x00100000f02; +constexpr uint64_t kLogicalAppSwitch = 0x00100001001; +constexpr uint64_t kLogicalCall = 0x00100001002; +constexpr uint64_t kLogicalCameraFocus = 0x00100001003; +constexpr uint64_t kLogicalEndCall = 0x00100001004; +constexpr uint64_t kLogicalGoBack = 0x00100001005; +constexpr uint64_t kLogicalGoHome = 0x00100001006; +constexpr uint64_t kLogicalHeadsetHook = 0x00100001007; +constexpr uint64_t kLogicalLastNumberRedial = 0x00100001008; +constexpr uint64_t kLogicalNotification = 0x00100001009; +constexpr uint64_t kLogicalMannerMode = 0x0010000100a; +constexpr uint64_t kLogicalVoiceDial = 0x0010000100b; +constexpr uint64_t kLogicalTv3DMode = 0x00100001101; +constexpr uint64_t kLogicalTvAntennaCable = 0x00100001102; +constexpr uint64_t kLogicalTvAudioDescription = 0x00100001103; +constexpr uint64_t kLogicalTvAudioDescriptionMixDown = 0x00100001104; +constexpr uint64_t kLogicalTvAudioDescriptionMixUp = 0x00100001105; +constexpr uint64_t kLogicalTvContentsMenu = 0x00100001106; +constexpr uint64_t kLogicalTvDataService = 0x00100001107; +constexpr uint64_t kLogicalTvInputComponent1 = 0x00100001108; +constexpr uint64_t kLogicalTvInputComponent2 = 0x00100001109; +constexpr uint64_t kLogicalTvInputComposite1 = 0x0010000110a; +constexpr uint64_t kLogicalTvInputComposite2 = 0x0010000110b; +constexpr uint64_t kLogicalTvInputHDMI1 = 0x0010000110c; +constexpr uint64_t kLogicalTvInputHDMI2 = 0x0010000110d; +constexpr uint64_t kLogicalTvInputHDMI3 = 0x0010000110e; +constexpr uint64_t kLogicalTvInputHDMI4 = 0x0010000110f; +constexpr uint64_t kLogicalTvInputVGA1 = 0x00100001110; +constexpr uint64_t kLogicalTvMediaContext = 0x00100001111; +constexpr uint64_t kLogicalTvNetwork = 0x00100001112; +constexpr uint64_t kLogicalTvNumberEntry = 0x00100001113; +constexpr uint64_t kLogicalTvRadioService = 0x00100001114; +constexpr uint64_t kLogicalTvSatellite = 0x00100001115; +constexpr uint64_t kLogicalTvSatelliteBS = 0x00100001116; +constexpr uint64_t kLogicalTvSatelliteCS = 0x00100001117; +constexpr uint64_t kLogicalTvSatelliteToggle = 0x00100001118; +constexpr uint64_t kLogicalTvTerrestrialAnalog = 0x00100001119; +constexpr uint64_t kLogicalTvTerrestrialDigital = 0x0010000111a; +constexpr uint64_t kLogicalTvTimer = 0x0010000111b; +constexpr uint64_t kLogicalKey11 = 0x00100001201; +constexpr uint64_t kLogicalKey12 = 0x00100001202; +constexpr uint64_t kLogicalSuspend = 0x00200000000; +constexpr uint64_t kLogicalResume = 0x00200000001; +constexpr uint64_t kLogicalSleep = 0x00200000002; +constexpr uint64_t kLogicalAbort = 0x00200000003; +constexpr uint64_t kLogicalLang1 = 0x00200000010; +constexpr uint64_t kLogicalLang2 = 0x00200000011; +constexpr uint64_t kLogicalLang3 = 0x00200000012; +constexpr uint64_t kLogicalLang4 = 0x00200000013; +constexpr uint64_t kLogicalLang5 = 0x00200000014; +constexpr uint64_t kLogicalIntlBackslash = 0x00200000020; +constexpr uint64_t kLogicalIntlRo = 0x00200000021; +constexpr uint64_t kLogicalIntlYen = 0x00200000022; +constexpr uint64_t kLogicalControlLeft = 0x00200000100; +constexpr uint64_t kLogicalControlRight = 0x00200000101; +constexpr uint64_t kLogicalShiftLeft = 0x00200000102; +constexpr uint64_t kLogicalShiftRight = 0x00200000103; +constexpr uint64_t kLogicalAltLeft = 0x00200000104; +constexpr uint64_t kLogicalAltRight = 0x00200000105; +constexpr uint64_t kLogicalMetaLeft = 0x00200000106; +constexpr uint64_t kLogicalMetaRight = 0x00200000107; +constexpr uint64_t kLogicalControl = 0x002000001f0; +constexpr uint64_t kLogicalShift = 0x002000001f2; +constexpr uint64_t kLogicalAlt = 0x002000001f4; +constexpr uint64_t kLogicalMeta = 0x002000001f6; +constexpr uint64_t kLogicalNumpadEnter = 0x0020000020d; +constexpr uint64_t kLogicalNumpadParenLeft = 0x00200000228; +constexpr uint64_t kLogicalNumpadParenRight = 0x00200000229; +constexpr uint64_t kLogicalNumpadMultiply = 0x0020000022a; +constexpr uint64_t kLogicalNumpadAdd = 0x0020000022b; +constexpr uint64_t kLogicalNumpadComma = 0x0020000022c; +constexpr uint64_t kLogicalNumpadSubtract = 0x0020000022d; +constexpr uint64_t kLogicalNumpadDecimal = 0x0020000022e; +constexpr uint64_t kLogicalNumpadDivide = 0x0020000022f; +constexpr uint64_t kLogicalNumpad0 = 0x00200000230; +constexpr uint64_t kLogicalNumpad1 = 0x00200000231; +constexpr uint64_t kLogicalNumpad2 = 0x00200000232; +constexpr uint64_t kLogicalNumpad3 = 0x00200000233; +constexpr uint64_t kLogicalNumpad4 = 0x00200000234; +constexpr uint64_t kLogicalNumpad5 = 0x00200000235; +constexpr uint64_t kLogicalNumpad6 = 0x00200000236; +constexpr uint64_t kLogicalNumpad7 = 0x00200000237; +constexpr uint64_t kLogicalNumpad8 = 0x00200000238; +constexpr uint64_t kLogicalNumpad9 = 0x00200000239; +constexpr uint64_t kLogicalNumpadEqual = 0x0020000023d; +constexpr uint64_t kLogicalGameButton1 = 0x00200000301; +constexpr uint64_t kLogicalGameButton2 = 0x00200000302; +constexpr uint64_t kLogicalGameButton3 = 0x00200000303; +constexpr uint64_t kLogicalGameButton4 = 0x00200000304; +constexpr uint64_t kLogicalGameButton5 = 0x00200000305; +constexpr uint64_t kLogicalGameButton6 = 0x00200000306; +constexpr uint64_t kLogicalGameButton7 = 0x00200000307; +constexpr uint64_t kLogicalGameButton8 = 0x00200000308; +constexpr uint64_t kLogicalGameButton9 = 0x00200000309; +constexpr uint64_t kLogicalGameButton10 = 0x0020000030a; +constexpr uint64_t kLogicalGameButton11 = 0x0020000030b; +constexpr uint64_t kLogicalGameButton12 = 0x0020000030c; +constexpr uint64_t kLogicalGameButton13 = 0x0020000030d; +constexpr uint64_t kLogicalGameButton14 = 0x0020000030e; +constexpr uint64_t kLogicalGameButton15 = 0x0020000030f; +constexpr uint64_t kLogicalGameButton16 = 0x00200000310; +constexpr uint64_t kLogicalGameButtonA = 0x00200000311; +constexpr uint64_t kLogicalGameButtonB = 0x00200000312; +constexpr uint64_t kLogicalGameButtonC = 0x00200000313; +constexpr uint64_t kLogicalGameButtonLeft1 = 0x00200000314; +constexpr uint64_t kLogicalGameButtonLeft2 = 0x00200000315; +constexpr uint64_t kLogicalGameButtonMode = 0x00200000316; +constexpr uint64_t kLogicalGameButtonRight1 = 0x00200000317; +constexpr uint64_t kLogicalGameButtonRight2 = 0x00200000318; +constexpr uint64_t kLogicalGameButtonSelect = 0x00200000319; +constexpr uint64_t kLogicalGameButtonStart = 0x0020000031a; +constexpr uint64_t kLogicalGameButtonThumbLeft = 0x0020000031b; +constexpr uint64_t kLogicalGameButtonThumbRight = 0x0020000031c; +constexpr uint64_t kLogicalGameButtonX = 0x0020000031d; +constexpr uint64_t kLogicalGameButtonY = 0x0020000031e; +constexpr uint64_t kLogicalGameButtonZ = 0x0020000031f; + +} // namespace keycodes + +} // namespace testing + +} // namespace flutter + +#endif // FLUTTER_SHELL_PLATFORM_COMMON_TESTING_KEY_CODES_H_ diff --git a/engine/src/flutter/shell/platform/linux/fl_key_embedder_responder.cc b/engine/src/flutter/shell/platform/linux/fl_key_embedder_responder.cc index a8cb78aa09..a464f325dc 100644 --- a/engine/src/flutter/shell/platform/linux/fl_key_embedder_responder.cc +++ b/engine/src/flutter/shell/platform/linux/fl_key_embedder_responder.cc @@ -12,10 +12,6 @@ #include "flutter/shell/platform/linux/fl_key_embedder_responder_private.h" #include "flutter/shell/platform/linux/key_mapping.h" -// The code prefix for unrecognized keys that are unique to Gtk, generated from -// platform-specific codes. -constexpr uint64_t kGtkKeyIdPlane = 0x00600000000; - constexpr uint64_t kMicrosecondsPerMillisecond = 1000; // Look up a hash table that maps a uint64_t to a uint64_t. @@ -269,12 +265,16 @@ FlKeyEmbedderResponder* fl_key_embedder_responder_new(FlEngine* engine) { /* Implement FlKeyEmbedderUserData */ +static uint64_t apply_id_plane(uint64_t logical_id, uint64_t plane) { + return (logical_id & kValueMask) | plane; +} + static uint64_t event_to_physical_key(const FlKeyEvent* event) { auto found = xkb_to_physical_key_map.find(event->keycode); if (found != xkb_to_physical_key_map.end()) { return found->second; } - return kGtkKeyIdPlane | event->keycode; + return apply_id_plane(event->keycode, kGtkPlane); } static uint64_t event_to_logical_key(const FlKeyEvent* event) { @@ -285,10 +285,10 @@ static uint64_t event_to_logical_key(const FlKeyEvent* event) { } // EASCII range if (keyval < 256) { - return to_lower(keyval); + return apply_id_plane(to_lower(keyval), kUnicodePlane); } // Auto-generate key - return kGtkKeyIdPlane | keyval; + return apply_id_plane(keyval, kGtkPlane); } static uint64_t event_to_timestamp(const FlKeyEvent* event) { diff --git a/engine/src/flutter/shell/platform/linux/fl_key_embedder_responder_test.cc b/engine/src/flutter/shell/platform/linux/fl_key_embedder_responder_test.cc index 740980d5a6..8aee6a9203 100644 --- a/engine/src/flutter/shell/platform/linux/fl_key_embedder_responder_test.cc +++ b/engine/src/flutter/shell/platform/linux/fl_key_embedder_responder_test.cc @@ -6,6 +6,7 @@ #include "gtest/gtest.h" +#include "flutter/shell/platform/embedder/test_utils/key_codes.h" #include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h" #include "flutter/shell/platform/linux/fl_binary_messenger_private.h" #include "flutter/shell/platform/linux/fl_engine_private.h" @@ -26,20 +27,7 @@ constexpr guint16 kKeyCodeCapsLock = 0x42u; constexpr guint16 kKeyCodeControlLeft = 0x25u; constexpr guint16 kKeyCodeControlRight = 0x69u; -constexpr uint64_t kPhysicalKeyA = 0x00070004; -constexpr uint64_t kPhysicalControlLeft = 0x000700e0; -constexpr uint64_t kPhysicalShiftRight = 0x000700E5; -constexpr uint64_t kPhysicalNumpad1 = 0x00070059; -constexpr uint64_t kPhysicalNumLock = 0x00070053; -constexpr uint64_t kPhysicalCapsLock = 0x00070039; - -constexpr uint64_t kLogicalKeyA = 0x00000061; -constexpr uint64_t kLogicalKeyQ = 0x00000071; -constexpr uint64_t kLogicalControlLeft = 0x30000000105; -constexpr uint64_t kLogicalShiftRight = 0x4000000010D; -constexpr uint64_t kLogicalNumpad1 = 0x50000000031; -constexpr uint64_t kLogicalNumLock = 0x100000010A; -constexpr uint64_t kLogicalCapsLock = 0x1000000104; +using namespace ::flutter::testing::keycodes; } // namespace static void g_ptr_array_clear(GPtrArray* array) { diff --git a/engine/src/flutter/shell/platform/linux/key_mapping.cc b/engine/src/flutter/shell/platform/linux/key_mapping.cc index c43249705e..014ba4a7c9 100644 --- a/engine/src/flutter/shell/platform/linux/key_mapping.cc +++ b/engine/src/flutter/shell/platform/linux/key_mapping.cc @@ -237,177 +237,177 @@ std::map xkb_to_physical_key_map = { }; std::map gtk_keyval_to_logical_key_map = { - {0x000000a5, 0x01100070089}, // yen - {0x0000fd06, 0x01000000405}, // 3270_EraseEOF - {0x0000fd0e, 0x01000000503}, // 3270_Attn - {0x0000fd15, 0x01000000402}, // 3270_Copy - {0x0000fd16, 0x01000000d2f}, // 3270_Play - {0x0000fd1b, 0x01000000406}, // 3270_ExSelect - {0x0000fd1d, 0x01000000608}, // 3270_PrintScreen - {0x0000fd1e, 0x0100000000d}, // 3270_Enter - {0x0000fe03, 0x40000000102}, // ISO_Level3_Shift - {0x0000fe08, 0x01000000709}, // ISO_Next_Group - {0x0000fe0a, 0x0100000070a}, // ISO_Prev_Group - {0x0000fe0c, 0x01000000707}, // ISO_First_Group - {0x0000fe0e, 0x01000000708}, // ISO_Last_Group - {0x0000fe20, 0x01000000009}, // ISO_Left_Tab - {0x0000fe34, 0x0100000000d}, // ISO_Enter - {0x0000ff08, 0x01000000008}, // BackSpace - {0x0000ff09, 0x01000000009}, // Tab - {0x0000ff0b, 0x01000000401}, // Clear - {0x0000ff0d, 0x0100000000d}, // Return - {0x0000ff13, 0x01000000509}, // Pause - {0x0000ff14, 0x0100000010c}, // Scroll_Lock - {0x0000ff1b, 0x0100000001b}, // Escape - {0x0000ff21, 0x01000000719}, // Kanji - {0x0000ff24, 0x0100000071b}, // Romaji - {0x0000ff25, 0x01000000716}, // Hiragana - {0x0000ff26, 0x0100000071a}, // Katakana - {0x0000ff27, 0x01000000717}, // Hiragana_Katakana - {0x0000ff28, 0x0100000071c}, // Zenkaku - {0x0000ff29, 0x01000000715}, // Hankaku - {0x0000ff2a, 0x0100000071d}, // Zenkaku_Hankaku - {0x0000ff2f, 0x01000000714}, // Eisu_Shift - {0x0000ff31, 0x01000000711}, // Hangul - {0x0000ff34, 0x01000000712}, // Hangul_Hanja - {0x0000ff37, 0x01000000703}, // Codeinput - {0x0000ff3c, 0x01000000710}, // SingleCandidate - {0x0000ff3e, 0x0100000070e}, // PreviousCandidate - {0x0000ff50, 0x01000000306}, // Home - {0x0000ff51, 0x01000000302}, // Left - {0x0000ff52, 0x01000000304}, // Up - {0x0000ff53, 0x01000000303}, // Right - {0x0000ff54, 0x01000000301}, // Down - {0x0000ff55, 0x01000000308}, // Page_Up - {0x0000ff56, 0x01000000307}, // Page_Down - {0x0000ff57, 0x01000000305}, // End - {0x0000ff60, 0x0100000050c}, // Select - {0x0000ff61, 0x01000000a0c}, // Print - {0x0000ff62, 0x01000000506}, // Execute - {0x0000ff63, 0x01000000407}, // Insert - {0x0000ff65, 0x0100000040a}, // Undo - {0x0000ff66, 0x01000000409}, // Redo - {0x0000ff67, 0x01000000505}, // Menu - {0x0000ff68, 0x01000000507}, // Find - {0x0000ff69, 0x01000000504}, // Cancel - {0x0000ff6a, 0x01000000508}, // Help - {0x0000ff7e, 0x0100000070b}, // Mode_switch - {0x0000ff7f, 0x0100000010a}, // Num_Lock + {0x000000a5, 0x00200000022}, // yen + {0x0000fd06, 0x00100000405}, // 3270_EraseEOF + {0x0000fd0e, 0x00100000503}, // 3270_Attn + {0x0000fd15, 0x00100000402}, // 3270_Copy + {0x0000fd16, 0x00100000d2f}, // 3270_Play + {0x0000fd1b, 0x00100000406}, // 3270_ExSelect + {0x0000fd1d, 0x00100000608}, // 3270_PrintScreen + {0x0000fd1e, 0x0010000000d}, // 3270_Enter + {0x0000fe03, 0x00200000105}, // ISO_Level3_Shift + {0x0000fe08, 0x00100000709}, // ISO_Next_Group + {0x0000fe0a, 0x0010000070a}, // ISO_Prev_Group + {0x0000fe0c, 0x00100000707}, // ISO_First_Group + {0x0000fe0e, 0x00100000708}, // ISO_Last_Group + {0x0000fe20, 0x00100000009}, // ISO_Left_Tab + {0x0000fe34, 0x0010000000d}, // ISO_Enter + {0x0000ff08, 0x00100000008}, // BackSpace + {0x0000ff09, 0x00100000009}, // Tab + {0x0000ff0b, 0x00100000401}, // Clear + {0x0000ff0d, 0x0010000000d}, // Return + {0x0000ff13, 0x00100000509}, // Pause + {0x0000ff14, 0x0010000010c}, // Scroll_Lock + {0x0000ff1b, 0x0010000001b}, // Escape + {0x0000ff21, 0x00100000719}, // Kanji + {0x0000ff24, 0x0010000071b}, // Romaji + {0x0000ff25, 0x00100000716}, // Hiragana + {0x0000ff26, 0x0010000071a}, // Katakana + {0x0000ff27, 0x00100000717}, // Hiragana_Katakana + {0x0000ff28, 0x0010000071c}, // Zenkaku + {0x0000ff29, 0x00100000715}, // Hankaku + {0x0000ff2a, 0x0010000071d}, // Zenkaku_Hankaku + {0x0000ff2f, 0x00100000714}, // Eisu_Shift + {0x0000ff31, 0x00100000711}, // Hangul + {0x0000ff34, 0x00100000712}, // Hangul_Hanja + {0x0000ff37, 0x00100000703}, // Codeinput + {0x0000ff3c, 0x00100000710}, // SingleCandidate + {0x0000ff3e, 0x0010000070e}, // PreviousCandidate + {0x0000ff50, 0x00100000306}, // Home + {0x0000ff51, 0x00100000302}, // Left + {0x0000ff52, 0x00100000304}, // Up + {0x0000ff53, 0x00100000303}, // Right + {0x0000ff54, 0x00100000301}, // Down + {0x0000ff55, 0x00100000308}, // Page_Up + {0x0000ff56, 0x00100000307}, // Page_Down + {0x0000ff57, 0x00100000305}, // End + {0x0000ff60, 0x0010000050c}, // Select + {0x0000ff61, 0x00100000a0c}, // Print + {0x0000ff62, 0x00100000506}, // Execute + {0x0000ff63, 0x00100000407}, // Insert + {0x0000ff65, 0x0010000040a}, // Undo + {0x0000ff66, 0x00100000409}, // Redo + {0x0000ff67, 0x00100000505}, // Menu + {0x0000ff68, 0x00100000507}, // Find + {0x0000ff69, 0x00100000504}, // Cancel + {0x0000ff6a, 0x00100000508}, // Help + {0x0000ff7e, 0x0010000070b}, // Mode_switch + {0x0000ff7f, 0x0010000010a}, // Num_Lock {0x0000ff80, 0x00000000020}, // KP_Space - {0x0000ff89, 0x01000000009}, // KP_Tab - {0x0000ff8d, 0x5000000000d}, // KP_Enter - {0x0000ff91, 0x01000000801}, // KP_F1 - {0x0000ff92, 0x01000000802}, // KP_F2 - {0x0000ff93, 0x01000000803}, // KP_F3 - {0x0000ff94, 0x01000000804}, // KP_F4 - {0x0000ff95, 0x50000000037}, // KP_Home - {0x0000ff96, 0x50000000034}, // KP_Left - {0x0000ff97, 0x50000000038}, // KP_Up - {0x0000ff98, 0x50000000036}, // KP_Right - {0x0000ff99, 0x50000000032}, // KP_Down - {0x0000ff9a, 0x50000000039}, // KP_Page_Up - {0x0000ff9b, 0x50000000033}, // KP_Page_Down - {0x0000ff9c, 0x50000000031}, // KP_End - {0x0000ff9e, 0x50000000030}, // KP_Insert - {0x0000ff9f, 0x5000000002e}, // KP_Delete - {0x0000ffaa, 0x5000000002a}, // KP_Multiply - {0x0000ffab, 0x5000000002b}, // KP_Add - {0x0000ffad, 0x5000000002d}, // KP_Subtract + {0x0000ff89, 0x00100000009}, // KP_Tab + {0x0000ff8d, 0x0020000020d}, // KP_Enter + {0x0000ff91, 0x00100000801}, // KP_F1 + {0x0000ff92, 0x00100000802}, // KP_F2 + {0x0000ff93, 0x00100000803}, // KP_F3 + {0x0000ff94, 0x00100000804}, // KP_F4 + {0x0000ff95, 0x00200000237}, // KP_Home + {0x0000ff96, 0x00200000234}, // KP_Left + {0x0000ff97, 0x00200000238}, // KP_Up + {0x0000ff98, 0x00200000236}, // KP_Right + {0x0000ff99, 0x00200000232}, // KP_Down + {0x0000ff9a, 0x00200000239}, // KP_Page_Up + {0x0000ff9b, 0x00200000233}, // KP_Page_Down + {0x0000ff9c, 0x00200000231}, // KP_End + {0x0000ff9e, 0x00200000230}, // KP_Insert + {0x0000ff9f, 0x0020000022e}, // KP_Delete + {0x0000ffaa, 0x0020000022a}, // KP_Multiply + {0x0000ffab, 0x0020000022b}, // KP_Add + {0x0000ffad, 0x0020000022d}, // KP_Subtract {0x0000ffae, 0x0000000002e}, // KP_Decimal - {0x0000ffaf, 0x5000000002f}, // KP_Divide - {0x0000ffb0, 0x50000000030}, // KP_0 - {0x0000ffb1, 0x50000000031}, // KP_1 - {0x0000ffb2, 0x50000000032}, // KP_2 - {0x0000ffb3, 0x50000000033}, // KP_3 - {0x0000ffb4, 0x50000000034}, // KP_4 - {0x0000ffb5, 0x50000000035}, // KP_5 - {0x0000ffb6, 0x50000000036}, // KP_6 - {0x0000ffb7, 0x50000000037}, // KP_7 - {0x0000ffb8, 0x50000000038}, // KP_8 - {0x0000ffb9, 0x50000000039}, // KP_9 - {0x0000ffbd, 0x5000000003d}, // KP_Equal - {0x0000ffbe, 0x01000000801}, // F1 - {0x0000ffbf, 0x01000000802}, // F2 - {0x0000ffc0, 0x01000000803}, // F3 - {0x0000ffc1, 0x01000000804}, // F4 - {0x0000ffc2, 0x01000000805}, // F5 - {0x0000ffc3, 0x01000000806}, // F6 - {0x0000ffc4, 0x01000000807}, // F7 - {0x0000ffc5, 0x01000000808}, // F8 - {0x0000ffc6, 0x01000000809}, // F9 - {0x0000ffc7, 0x0100000080a}, // F10 - {0x0000ffc8, 0x0100000080b}, // F11 - {0x0000ffc9, 0x0100000080c}, // F12 - {0x0000ffca, 0x0100000080d}, // F13 - {0x0000ffcb, 0x0100000080e}, // F14 - {0x0000ffcc, 0x0100000080f}, // F15 - {0x0000ffcd, 0x01000000810}, // F16 - {0x0000ffce, 0x01000000811}, // F17 - {0x0000ffcf, 0x01000000812}, // F18 - {0x0000ffd0, 0x01000000813}, // F19 - {0x0000ffd1, 0x01000000814}, // F20 - {0x0000ffd2, 0x01000000815}, // F21 - {0x0000ffd3, 0x01000000816}, // F22 - {0x0000ffd4, 0x01000000817}, // F23 - {0x0000ffd5, 0x01000000818}, // F24 - {0x0000ffe1, 0x3000000010d}, // Shift_L - {0x0000ffe2, 0x4000000010d}, // Shift_R - {0x0000ffe3, 0x30000000105}, // Control_L - {0x0000ffe4, 0x40000000105}, // Control_R - {0x0000ffe5, 0x01000000104}, // Caps_Lock - {0x0000ffe7, 0x30000000109}, // Meta_L - {0x0000ffe8, 0x40000000109}, // Meta_R - {0x0000ffe9, 0x30000000102}, // Alt_L - {0x0000ffea, 0x40000000102}, // Alt_R - {0x0000ffeb, 0x0100000010e}, // Super_L - {0x0000ffec, 0x0100000010e}, // Super_R - {0x0000ffed, 0x01000000108}, // Hyper_L - {0x0000ffee, 0x01000000108}, // Hyper_R - {0x0000ffff, 0x0100000007f}, // Delete - {0x1008ff02, 0x01000000602}, // MonBrightnessUp - {0x1008ff03, 0x01000000601}, // MonBrightnessDown - {0x1008ff10, 0x0100000060a}, // Standby - {0x1008ff11, 0x01000000a0f}, // AudioLowerVolume - {0x1008ff12, 0x01000000a11}, // AudioMute - {0x1008ff13, 0x01000000a10}, // AudioRaiseVolume - {0x1008ff14, 0x01000000d2f}, // AudioPlay - {0x1008ff15, 0x01000000a07}, // AudioStop - {0x1008ff16, 0x01000000a09}, // AudioPrev - {0x1008ff17, 0x01000000a08}, // AudioNext - {0x1008ff18, 0x01000000c04}, // HomePage - {0x1008ff19, 0x01000000b03}, // Mail - {0x1008ff1b, 0x01000000c06}, // Search - {0x1008ff1c, 0x01000000d30}, // AudioRecord - {0x1008ff20, 0x01000000b02}, // Calendar - {0x1008ff26, 0x01000000c01}, // Back - {0x1008ff27, 0x01000000c03}, // Forward - {0x1008ff28, 0x01000000c07}, // Stop - {0x1008ff29, 0x01000000c05}, // Refresh - {0x1008ff2a, 0x01000000607}, // PowerOff - {0x1008ff2b, 0x0100000060b}, // WakeUp - {0x1008ff2c, 0x01000000604}, // Eject - {0x1008ff2d, 0x01000000b07}, // ScreenSaver - {0x1008ff2f, 0x01100010082}, // Sleep - {0x1008ff30, 0x01000000c02}, // Favorites - {0x1008ff31, 0x01000000d2e}, // AudioPause - {0x1008ff3e, 0x01000000d31}, // AudioRewind - {0x1008ff56, 0x01000000a01}, // Close - {0x1008ff57, 0x01000000402}, // Copy - {0x1008ff58, 0x01000000404}, // Cut - {0x1008ff61, 0x01000000605}, // LogOff - {0x1008ff68, 0x01000000a0a}, // New - {0x1008ff6b, 0x01000000a0b}, // Open - {0x1008ff6d, 0x01000000408}, // Paste - {0x1008ff6e, 0x01000000b0d}, // Phone - {0x1008ff72, 0x01000000a03}, // Reply - {0x1008ff77, 0x01000000a0d}, // Save - {0x1008ff7b, 0x01000000a04}, // Send - {0x1008ff7c, 0x01000000a0e}, // Spell - {0x1008ff8b, 0x0100000050d}, // ZoomIn - {0x1008ff8c, 0x0100000050e}, // ZoomOut - {0x1008ff90, 0x01000000a02}, // MailForward - {0x1008ff97, 0x01000000d2c}, // AudioForward - {0x1008ffa7, 0x01100000014}, // Suspend + {0x0000ffaf, 0x0020000022f}, // KP_Divide + {0x0000ffb0, 0x00200000230}, // KP_0 + {0x0000ffb1, 0x00200000231}, // KP_1 + {0x0000ffb2, 0x00200000232}, // KP_2 + {0x0000ffb3, 0x00200000233}, // KP_3 + {0x0000ffb4, 0x00200000234}, // KP_4 + {0x0000ffb5, 0x00200000235}, // KP_5 + {0x0000ffb6, 0x00200000236}, // KP_6 + {0x0000ffb7, 0x00200000237}, // KP_7 + {0x0000ffb8, 0x00200000238}, // KP_8 + {0x0000ffb9, 0x00200000239}, // KP_9 + {0x0000ffbd, 0x0020000023d}, // KP_Equal + {0x0000ffbe, 0x00100000801}, // F1 + {0x0000ffbf, 0x00100000802}, // F2 + {0x0000ffc0, 0x00100000803}, // F3 + {0x0000ffc1, 0x00100000804}, // F4 + {0x0000ffc2, 0x00100000805}, // F5 + {0x0000ffc3, 0x00100000806}, // F6 + {0x0000ffc4, 0x00100000807}, // F7 + {0x0000ffc5, 0x00100000808}, // F8 + {0x0000ffc6, 0x00100000809}, // F9 + {0x0000ffc7, 0x0010000080a}, // F10 + {0x0000ffc8, 0x0010000080b}, // F11 + {0x0000ffc9, 0x0010000080c}, // F12 + {0x0000ffca, 0x0010000080d}, // F13 + {0x0000ffcb, 0x0010000080e}, // F14 + {0x0000ffcc, 0x0010000080f}, // F15 + {0x0000ffcd, 0x00100000810}, // F16 + {0x0000ffce, 0x00100000811}, // F17 + {0x0000ffcf, 0x00100000812}, // F18 + {0x0000ffd0, 0x00100000813}, // F19 + {0x0000ffd1, 0x00100000814}, // F20 + {0x0000ffd2, 0x00100000815}, // F21 + {0x0000ffd3, 0x00100000816}, // F22 + {0x0000ffd4, 0x00100000817}, // F23 + {0x0000ffd5, 0x00100000818}, // F24 + {0x0000ffe1, 0x00200000102}, // Shift_L + {0x0000ffe2, 0x00200000103}, // Shift_R + {0x0000ffe3, 0x00200000100}, // Control_L + {0x0000ffe4, 0x00200000101}, // Control_R + {0x0000ffe5, 0x00100000104}, // Caps_Lock + {0x0000ffe7, 0x00200000106}, // Meta_L + {0x0000ffe8, 0x00200000107}, // Meta_R + {0x0000ffe9, 0x00200000104}, // Alt_L + {0x0000ffea, 0x00200000105}, // Alt_R + {0x0000ffeb, 0x0010000010e}, // Super_L + {0x0000ffec, 0x0010000010e}, // Super_R + {0x0000ffed, 0x00100000108}, // Hyper_L + {0x0000ffee, 0x00100000108}, // Hyper_R + {0x0000ffff, 0x0010000007f}, // Delete + {0x1008ff02, 0x00100000602}, // MonBrightnessUp + {0x1008ff03, 0x00100000601}, // MonBrightnessDown + {0x1008ff10, 0x0010000060a}, // Standby + {0x1008ff11, 0x00100000a0f}, // AudioLowerVolume + {0x1008ff12, 0x00100000a11}, // AudioMute + {0x1008ff13, 0x00100000a10}, // AudioRaiseVolume + {0x1008ff14, 0x00100000d2f}, // AudioPlay + {0x1008ff15, 0x00100000a07}, // AudioStop + {0x1008ff16, 0x00100000a09}, // AudioPrev + {0x1008ff17, 0x00100000a08}, // AudioNext + {0x1008ff18, 0x00100000c04}, // HomePage + {0x1008ff19, 0x00100000b03}, // Mail + {0x1008ff1b, 0x00100000c06}, // Search + {0x1008ff1c, 0x00100000d30}, // AudioRecord + {0x1008ff20, 0x00100000b02}, // Calendar + {0x1008ff26, 0x00100000c01}, // Back + {0x1008ff27, 0x00100000c03}, // Forward + {0x1008ff28, 0x00100000c07}, // Stop + {0x1008ff29, 0x00100000c05}, // Refresh + {0x1008ff2a, 0x00100000607}, // PowerOff + {0x1008ff2b, 0x0010000060b}, // WakeUp + {0x1008ff2c, 0x00100000604}, // Eject + {0x1008ff2d, 0x00100000b07}, // ScreenSaver + {0x1008ff2f, 0x00200000002}, // Sleep + {0x1008ff30, 0x00100000c02}, // Favorites + {0x1008ff31, 0x00100000d2e}, // AudioPause + {0x1008ff3e, 0x00100000d31}, // AudioRewind + {0x1008ff56, 0x00100000a01}, // Close + {0x1008ff57, 0x00100000402}, // Copy + {0x1008ff58, 0x00100000404}, // Cut + {0x1008ff61, 0x00100000605}, // LogOff + {0x1008ff68, 0x00100000a0a}, // New + {0x1008ff6b, 0x00100000a0b}, // Open + {0x1008ff6d, 0x00100000408}, // Paste + {0x1008ff6e, 0x00100000b0d}, // Phone + {0x1008ff72, 0x00100000a03}, // Reply + {0x1008ff77, 0x00100000a0d}, // Save + {0x1008ff7b, 0x00100000a04}, // Send + {0x1008ff7c, 0x00100000a0e}, // Spell + {0x1008ff8b, 0x0010000050d}, // ZoomIn + {0x1008ff8c, 0x0010000050e}, // ZoomOut + {0x1008ff90, 0x00100000a02}, // MailForward + {0x1008ff97, 0x00100000d2c}, // AudioForward + {0x1008ffa7, 0x00200000000}, // Suspend }; void initialize_modifier_bit_to_checked_keys(GHashTable* table) { @@ -417,29 +417,29 @@ void initialize_modifier_bit_to_checked_keys(GHashTable* table) { g_hash_table_insert(table, GUINT_TO_POINTER(GDK_SHIFT_MASK), data); data->is_caps_lock = false; data->primary_physical_key = 0x0000700e1; // shiftLeft - data->primary_logical_key = 0x3000000010d; // shiftLeft - data->secondary_logical_key = 0x4000000010d; // shiftRight + data->primary_logical_key = 0x00200000102; // shiftLeft + data->secondary_logical_key = 0x00200000103; // shiftRight data = g_new(FlKeyEmbedderCheckedKey, 1); g_hash_table_insert(table, GUINT_TO_POINTER(GDK_CONTROL_MASK), data); data->is_caps_lock = false; data->primary_physical_key = 0x0000700e0; // controlLeft - data->primary_logical_key = 0x30000000105; // controlLeft - data->secondary_logical_key = 0x40000000105; // controlRight + data->primary_logical_key = 0x00200000100; // controlLeft + data->secondary_logical_key = 0x00200000101; // controlRight data = g_new(FlKeyEmbedderCheckedKey, 1); g_hash_table_insert(table, GUINT_TO_POINTER(GDK_MOD1_MASK), data); data->is_caps_lock = false; data->primary_physical_key = 0x0000700e2; // altLeft - data->primary_logical_key = 0x30000000102; // altLeft - data->secondary_logical_key = 0x40000000102; // altRight + data->primary_logical_key = 0x00200000104; // altLeft + data->secondary_logical_key = 0x00200000105; // altRight data = g_new(FlKeyEmbedderCheckedKey, 1); g_hash_table_insert(table, GUINT_TO_POINTER(GDK_META_MASK), data); data->is_caps_lock = false; data->primary_physical_key = 0x0000700e3; // metaLeft - data->primary_logical_key = 0x30000000109; // metaLeft - data->secondary_logical_key = 0x40000000109; // metaRight + data->primary_logical_key = 0x00200000106; // metaLeft + data->secondary_logical_key = 0x00200000107; // metaRight } void initialize_lock_bit_to_checked_keys(GHashTable* table) { @@ -449,11 +449,15 @@ void initialize_lock_bit_to_checked_keys(GHashTable* table) { g_hash_table_insert(table, GUINT_TO_POINTER(GDK_LOCK_MASK), data); data->is_caps_lock = true; data->primary_physical_key = 0x000070039; // capsLock - data->primary_logical_key = 0x01000000104; // capsLock + data->primary_logical_key = 0x00100000104; // capsLock data = g_new(FlKeyEmbedderCheckedKey, 1); g_hash_table_insert(table, GUINT_TO_POINTER(GDK_MOD2_MASK), data); data->is_caps_lock = false; data->primary_physical_key = 0x000070053; // numLock - data->primary_logical_key = 0x0100000010a; // numLock + data->primary_logical_key = 0x0010000010a; // numLock } + +const uint64_t kValueMask = 0x000ffffffff; +const uint64_t kUnicodePlane = 0x00000000000; +const uint64_t kGtkPlane = 0x01500000000; diff --git a/engine/src/flutter/shell/platform/linux/key_mapping.h b/engine/src/flutter/shell/platform/linux/key_mapping.h index c537102e04..44fa39290c 100644 --- a/engine/src/flutter/shell/platform/linux/key_mapping.h +++ b/engine/src/flutter/shell/platform/linux/key_mapping.h @@ -27,4 +27,13 @@ void initialize_modifier_bit_to_checked_keys(GHashTable* table); void initialize_lock_bit_to_checked_keys(GHashTable* table); +// Mask for the 32-bit value portion of the key code. +extern const uint64_t kValueMask; + +// The plane value for keys which have a Unicode representation. +extern const uint64_t kUnicodePlane; + +// The plane value for the private keys defined by the GTK embedding. +extern const uint64_t kGtkPlane; + #endif // KEYBOARD_MAP_H_ diff --git a/engine/src/flutter/shell/platform/windows/flutter_key_map.cc b/engine/src/flutter/shell/platform/windows/flutter_key_map.cc index 69256a78f2..a06f7c2776 100644 --- a/engine/src/flutter/shell/platform/windows/flutter_key_map.cc +++ b/engine/src/flutter/shell/platform/windows/flutter_key_map.cc @@ -11,46 +11,20 @@ // DO NOT EDIT -- DO NOT EDIT -- DO NOT EDIT // This file is generated by -// flutter/flutter@dev/tools/gen_keycodes/bin/gen_keycodes.dart and should not +// flutter/flutter:dev/tools/gen_keycodes/bin/gen_keycodes.dart and should not // be edited directly. // -// Edit the template dev/tools/gen_keycodes/data/windows_flutter_key_map_cc.tmpl -// instead. See dev/tools/gen_keycodes/README.md for more information. +// Edit the template +// flutter/flutter:dev/tools/gen_keycodes/data/windows_flutter_key_map_cc.tmpl +// instead. +// +// See flutter/flutter:dev/tools/gen_keycodes/README.md for more information. namespace flutter { std::map KeyboardKeyEmbedderHandler::windowsToPhysicalMap_ = { - {0x0000e05f, 0x00010082}, // sleep - {0x0000e063, 0x00010083}, // wakeUp - {0x000000ff, 0x00070001}, // usbErrorRollOver - {0x000000fc, 0x00070002}, // usbPostFail - {0x0000001e, 0x00070004}, // keyA - {0x00000030, 0x00070005}, // keyB - {0x0000002e, 0x00070006}, // keyC - {0x00000020, 0x00070007}, // keyD - {0x00000012, 0x00070008}, // keyE - {0x00000021, 0x00070009}, // keyF - {0x00000022, 0x0007000a}, // keyG - {0x00000023, 0x0007000b}, // keyH - {0x00000017, 0x0007000c}, // keyI - {0x00000024, 0x0007000d}, // keyJ - {0x00000025, 0x0007000e}, // keyK - {0x00000026, 0x0007000f}, // keyL - {0x00000032, 0x00070010}, // keyM - {0x00000031, 0x00070011}, // keyN - {0x00000018, 0x00070012}, // keyO - {0x00000019, 0x00070013}, // keyP - {0x00000010, 0x00070014}, // keyQ - {0x00000013, 0x00070015}, // keyR - {0x0000001f, 0x00070016}, // keyS - {0x00000014, 0x00070017}, // keyT - {0x00000016, 0x00070018}, // keyU - {0x0000002f, 0x00070019}, // keyV - {0x00000011, 0x0007001a}, // keyW - {0x0000002d, 0x0007001b}, // keyX - {0x00000015, 0x0007001c}, // keyY - {0x0000002c, 0x0007001d}, // keyZ + {0x00000001, 0x00070029}, // escape {0x00000002, 0x0007001e}, // digit1 {0x00000003, 0x0007001f}, // digit2 {0x00000004, 0x00070020}, // digit3 @@ -61,22 +35,52 @@ std::map KeyboardKeyEmbedderHandler::windowsToPhysicalMap_ = {0x00000009, 0x00070025}, // digit8 {0x0000000a, 0x00070026}, // digit9 {0x0000000b, 0x00070027}, // digit0 - {0x0000001c, 0x00070028}, // enter - {0x00000001, 0x00070029}, // escape - {0x0000000e, 0x0007002a}, // backspace - {0x0000000f, 0x0007002b}, // tab - {0x00000039, 0x0007002c}, // space {0x0000000c, 0x0007002d}, // minus {0x0000000d, 0x0007002e}, // equal + {0x0000000e, 0x0007002a}, // backspace + {0x0000000f, 0x0007002b}, // tab + {0x00000010, 0x00070014}, // keyQ + {0x00000011, 0x0007001a}, // keyW + {0x00000012, 0x00070008}, // keyE + {0x00000013, 0x00070015}, // keyR + {0x00000014, 0x00070017}, // keyT + {0x00000015, 0x0007001c}, // keyY + {0x00000016, 0x00070018}, // keyU + {0x00000017, 0x0007000c}, // keyI + {0x00000018, 0x00070012}, // keyO + {0x00000019, 0x00070013}, // keyP {0x0000001a, 0x0007002f}, // bracketLeft {0x0000001b, 0x00070030}, // bracketRight - {0x0000002b, 0x00070031}, // backslash + {0x0000001c, 0x00070028}, // enter + {0x0000001d, 0x000700e0}, // controlLeft + {0x0000001e, 0x00070004}, // keyA + {0x0000001f, 0x00070016}, // keyS + {0x00000020, 0x00070007}, // keyD + {0x00000021, 0x00070009}, // keyF + {0x00000022, 0x0007000a}, // keyG + {0x00000023, 0x0007000b}, // keyH + {0x00000024, 0x0007000d}, // keyJ + {0x00000025, 0x0007000e}, // keyK + {0x00000026, 0x0007000f}, // keyL {0x00000027, 0x00070033}, // semicolon {0x00000028, 0x00070034}, // quote {0x00000029, 0x00070035}, // backquote + {0x0000002a, 0x000700e1}, // shiftLeft + {0x0000002b, 0x00070031}, // backslash + {0x0000002c, 0x0007001d}, // keyZ + {0x0000002d, 0x0007001b}, // keyX + {0x0000002e, 0x00070006}, // keyC + {0x0000002f, 0x00070019}, // keyV + {0x00000030, 0x00070005}, // keyB + {0x00000031, 0x00070011}, // keyN + {0x00000032, 0x00070010}, // keyM {0x00000033, 0x00070036}, // comma {0x00000034, 0x00070037}, // period {0x00000035, 0x00070038}, // slash + {0x00000036, 0x000700e5}, // shiftRight + {0x00000037, 0x00070055}, // numpadMultiply + {0x00000038, 0x000700e2}, // altLeft + {0x00000039, 0x0007002c}, // space {0x0000003a, 0x00070039}, // capsLock {0x0000003b, 0x0007003a}, // f1 {0x0000003c, 0x0007003b}, // f2 @@ -88,41 +92,24 @@ std::map KeyboardKeyEmbedderHandler::windowsToPhysicalMap_ = {0x00000042, 0x00070041}, // f8 {0x00000043, 0x00070042}, // f9 {0x00000044, 0x00070043}, // f10 - {0x00000057, 0x00070044}, // f11 - {0x00000058, 0x00070045}, // f12 - {0x0000e037, 0x00070046}, // printScreen - {0x00000046, 0x00070047}, // scrollLock {0x00000045, 0x00070048}, // pause - {0x0000e052, 0x00070049}, // insert - {0x0000e047, 0x0007004a}, // home - {0x0000e049, 0x0007004b}, // pageUp - {0x0000e053, 0x0007004c}, // delete - {0x0000e04f, 0x0007004d}, // end - {0x0000e051, 0x0007004e}, // pageDown - {0x0000e04d, 0x0007004f}, // arrowRight - {0x0000e04b, 0x00070050}, // arrowLeft - {0x0000e050, 0x00070051}, // arrowDown - {0x0000e048, 0x00070052}, // arrowUp - {0x0000e045, 0x00070053}, // numLock - {0x0000e035, 0x00070054}, // numpadDivide - {0x00000037, 0x00070055}, // numpadMultiply - {0x0000004a, 0x00070056}, // numpadSubtract - {0x0000004e, 0x00070057}, // numpadAdd - {0x0000e01c, 0x00070058}, // numpadEnter - {0x0000004f, 0x00070059}, // numpad1 - {0x00000050, 0x0007005a}, // numpad2 - {0x00000051, 0x0007005b}, // numpad3 - {0x0000004b, 0x0007005c}, // numpad4 - {0x0000004c, 0x0007005d}, // numpad5 - {0x0000004d, 0x0007005e}, // numpad6 + {0x00000046, 0x00070047}, // scrollLock {0x00000047, 0x0007005f}, // numpad7 {0x00000048, 0x00070060}, // numpad8 {0x00000049, 0x00070061}, // numpad9 + {0x0000004a, 0x00070056}, // numpadSubtract + {0x0000004b, 0x0007005c}, // numpad4 + {0x0000004c, 0x0007005d}, // numpad5 + {0x0000004d, 0x0007005e}, // numpad6 + {0x0000004e, 0x00070057}, // numpadAdd + {0x0000004f, 0x00070059}, // numpad1 + {0x00000050, 0x0007005a}, // numpad2 + {0x00000051, 0x0007005b}, // numpad3 {0x00000052, 0x00070062}, // numpad0 {0x00000053, 0x00070063}, // numpadDecimal {0x00000056, 0x00070064}, // intlBackslash - {0x0000e05d, 0x00070065}, // contextMenu - {0x0000e05e, 0x00070066}, // power + {0x00000057, 0x00070044}, // f11 + {0x00000058, 0x00070045}, // f12 {0x00000059, 0x00070067}, // numpadEqual {0x00000064, 0x00070068}, // f13 {0x00000065, 0x00070069}, // f14 @@ -135,195 +122,217 @@ std::map KeyboardKeyEmbedderHandler::windowsToPhysicalMap_ = {0x0000006c, 0x00070070}, // f21 {0x0000006d, 0x00070071}, // f22 {0x0000006e, 0x00070072}, // f23 - {0x00000076, 0x00070073}, // f24 - {0x0000e03b, 0x00070075}, // help - {0x0000e008, 0x0007007a}, // undo - {0x0000e017, 0x0007007b}, // cut - {0x0000e018, 0x0007007c}, // copy - {0x0000e00a, 0x0007007d}, // paste - {0x0000e020, 0x0007007f}, // audioVolumeMute - {0x0000e030, 0x00070080}, // audioVolumeUp - {0x0000e02e, 0x00070081}, // audioVolumeDown - {0x0000007e, 0x00070085}, // numpadComma - {0x00000073, 0x00070087}, // intlRo {0x00000070, 0x00070088}, // kanaMode - {0x0000007d, 0x00070089}, // intlYen + {0x00000071, 0x00070091}, // lang2 + {0x00000072, 0x00070090}, // lang1 + {0x00000073, 0x00070087}, // intlRo + {0x00000076, 0x00070073}, // f24 + {0x00000077, 0x00070093}, // lang4 + {0x00000078, 0x00070092}, // lang3 {0x00000079, 0x0007008a}, // convert {0x0000007b, 0x0007008b}, // nonConvert - {0x00000072, 0x00070090}, // lang1 - {0x00000071, 0x00070091}, // lang2 - {0x00000078, 0x00070092}, // lang3 - {0x00000077, 0x00070093}, // lang4 - {0x0000001d, 0x000700e0}, // controlLeft - {0x0000002a, 0x000700e1}, // shiftLeft - {0x00000038, 0x000700e2}, // altLeft - {0x0000e05b, 0x000700e3}, // metaLeft - {0x0000e01d, 0x000700e4}, // controlRight - {0x00000036, 0x000700e5}, // shiftRight - {0x0000e038, 0x000700e6}, // altRight - {0x0000e05c, 0x000700e7}, // metaRight - {0x0000e019, 0x000c00b5}, // mediaTrackNext + {0x0000007d, 0x00070089}, // intlYen + {0x0000007e, 0x00070085}, // numpadComma + {0x000000fc, 0x00070002}, // usbPostFail + {0x000000ff, 0x00070001}, // usbErrorRollOver + {0x0000e008, 0x0007007a}, // undo + {0x0000e00a, 0x0007007d}, // paste {0x0000e010, 0x000c00b6}, // mediaTrackPrevious + {0x0000e017, 0x0007007b}, // cut + {0x0000e018, 0x0007007c}, // copy + {0x0000e019, 0x000c00b5}, // mediaTrackNext + {0x0000e01c, 0x00070058}, // numpadEnter + {0x0000e01d, 0x000700e4}, // controlRight + {0x0000e020, 0x0007007f}, // audioVolumeMute + {0x0000e021, 0x000c0192}, // launchApp2 + {0x0000e022, 0x000c00cd}, // mediaPlayPause {0x0000e024, 0x000c00b7}, // mediaStop {0x0000e02c, 0x000c00b8}, // eject - {0x0000e022, 0x000c00cd}, // mediaPlayPause - {0x0000e06d, 0x000c0183}, // mediaSelect - {0x0000e06c, 0x000c018a}, // launchMail - {0x0000e021, 0x000c0192}, // launchApp2 - {0x0000e06b, 0x000c0194}, // launchApp1 - {0x0000e065, 0x000c0221}, // browserSearch + {0x0000e02e, 0x00070081}, // audioVolumeDown + {0x0000e030, 0x00070080}, // audioVolumeUp {0x0000e032, 0x000c0223}, // browserHome - {0x0000e06a, 0x000c0224}, // browserBack - {0x0000e069, 0x000c0225}, // browserForward - {0x0000e068, 0x000c0226}, // browserStop - {0x0000e067, 0x000c0227}, // browserRefresh + {0x0000e035, 0x00070054}, // numpadDivide + {0x0000e037, 0x00070046}, // printScreen + {0x0000e038, 0x000700e6}, // altRight + {0x0000e03b, 0x00070075}, // help + {0x0000e045, 0x00070053}, // numLock + {0x0000e047, 0x0007004a}, // home + {0x0000e048, 0x00070052}, // arrowUp + {0x0000e049, 0x0007004b}, // pageUp + {0x0000e04b, 0x00070050}, // arrowLeft + {0x0000e04d, 0x0007004f}, // arrowRight + {0x0000e04f, 0x0007004d}, // end + {0x0000e050, 0x00070051}, // arrowDown + {0x0000e051, 0x0007004e}, // pageDown + {0x0000e052, 0x00070049}, // insert + {0x0000e053, 0x0007004c}, // delete + {0x0000e05b, 0x000700e3}, // metaLeft + {0x0000e05c, 0x000700e7}, // metaRight + {0x0000e05d, 0x00070065}, // contextMenu + {0x0000e05e, 0x00070066}, // power + {0x0000e05f, 0x00010082}, // sleep + {0x0000e063, 0x00010083}, // wakeUp + {0x0000e065, 0x000c0221}, // browserSearch {0x0000e066, 0x000c022a}, // browserFavorites + {0x0000e067, 0x000c0227}, // browserRefresh + {0x0000e068, 0x000c0226}, // browserStop + {0x0000e069, 0x000c0225}, // browserForward + {0x0000e06a, 0x000c0224}, // browserBack + {0x0000e06b, 0x000c0194}, // launchApp1 + {0x0000e06c, 0x000c018a}, // launchMail + {0x0000e06d, 0x000c0183}, // mediaSelect }; std::map KeyboardKeyEmbedderHandler::windowsToLogicalMap_ = { - {0x00000008, 0x00000000008}, // BACK - {0x00000009, 0x00000000009}, // TAB - {0x0000000d, 0x0000000000d}, // RETURN - {0x0000001b, 0x0000000001b}, // ESCAPE - {0x00000020, 0x00000000020}, // SPACE - {0x000000de, 0x00000000022}, // OEM_7 - {0x000000bc, 0x0000000002c}, // OEM_COMMA - {0x000000bd, 0x0000000002d}, // OEM_MINUS - {0x000000be, 0x0000000002e}, // OEM_PERIOD - {0x000000bf, 0x0000000002f}, // OEM_2 - {0x000000ba, 0x0000000003b}, // OEM_1 - {0x000000bb, 0x0000000003d}, // OEM_PLUS - {0x000000db, 0x0000000005b}, // OEM_4 - {0x000000dc, 0x0000000005c}, // OEM_5 - {0x000000dd, 0x0000000005d}, // OEM_6 - {0x000000c0, 0x00000000060}, // OEM_3 - {0x0000002e, 0x0000000007f}, // DELETE - {0x00000014, 0x00000000104}, // CAPITAL - {0x00000090, 0x0000000010a}, // NUMLOCK - {0x00000091, 0x0000000010c}, // SCROLL - {0x00000028, 0x00000000301}, // DOWN - {0x00000025, 0x00000000302}, // LEFT - {0x00000027, 0x00000000303}, // RIGHT - {0x00000026, 0x00000000304}, // UP - {0x00000023, 0x00000000305}, // END - {0x00000024, 0x00000000306}, // HOME - {0x00000022, 0x00000000307}, // NEXT - {0x00000021, 0x00000000308}, // PRIOR - {0x0000000c, 0x00000000401}, // CLEAR - {0x0000002d, 0x00000000407}, // INSERT - {0x0000001e, 0x00000000501}, // ACCEPT - {0x000000f6, 0x00000000503}, // ATTN - {0x00000003, 0x00000000504}, // CANCEL - {0x0000005d, 0x00000000505}, // APPS - {0x0000002b, 0x00000000506}, // EXECUTE - {0x0000002f, 0x00000000508}, // HELP - {0x00000013, 0x00000000509}, // PAUSE - {0x000000fa, 0x0000000050a}, // PLAY - {0x00000029, 0x0000000050c}, // SELECT - {0x0000001c, 0x00000000705}, // CONVERT - {0x0000001f, 0x0000000070b}, // MODECHANGE - {0x00000070, 0x00000000801}, // F1 - {0x00000071, 0x00000000802}, // F2 - {0x00000072, 0x00000000803}, // F3 - {0x00000073, 0x00000000804}, // F4 - {0x00000074, 0x00000000805}, // F5 - {0x00000075, 0x00000000806}, // F6 - {0x00000076, 0x00000000807}, // F7 - {0x00000077, 0x00000000808}, // F8 - {0x00000078, 0x00000000809}, // F9 - {0x00000079, 0x0000000080a}, // F10 - {0x0000007a, 0x0000000080b}, // F11 - {0x0000007b, 0x0000000080c}, // F12 - {0x0000007c, 0x0000000080d}, // F13 - {0x0000007d, 0x0000000080e}, // F14 - {0x0000007e, 0x0000000080f}, // F15 - {0x0000007f, 0x00000000810}, // F16 - {0x00000080, 0x00000000811}, // F17 - {0x00000081, 0x00000000812}, // F18 - {0x00000082, 0x00000000813}, // F19 - {0x00000083, 0x00000000814}, // F20 - {0x00000084, 0x00000000815}, // F21 - {0x00000085, 0x00000000816}, // F22 - {0x00000086, 0x00000000817}, // F23 - {0x00000087, 0x00000000818}, // F24 - {0x000000b3, 0x00000000a05}, // MEDIA_PLAY_PAUSE - {0x000000b2, 0x00000000a07}, // MEDIA_STOP - {0x0000002a, 0x00000000a0c}, // PRINT - {0x000000ae, 0x00000000a0f}, // VOLUME_DOWN - {0x000000af, 0x00000000a10}, // VOLUME_UP - {0x000000ad, 0x00000000a11}, // VOLUME_MUTE - {0x000000b4, 0x00000000b03}, // LAUNCH_MAIL - {0x000000a6, 0x00000000c01}, // BROWSER_BACK - {0x000000ab, 0x00000000c02}, // BROWSER_FAVORITES - {0x000000a7, 0x00000000c03}, // BROWSER_FORWARD - {0x000000ac, 0x00000000c04}, // BROWSER_HOME - {0x000000a8, 0x00000000c05}, // BROWSER_REFRESH - {0x000000aa, 0x00000000c06}, // BROWSER_SEARCH - {0x000000a9, 0x00000000c07}, // BROWSER_STOP - {0x000000c3, 0x0000005ff08}, // GAMEPAD_A - {0x000000c4, 0x0000005ff09}, // GAMEPAD_B - {0x000000c5, 0x0000005ff0a}, // GAMEPAD_X - {0x000000c6, 0x0000005ff0b}, // GAMEPAD_Y - {0x000000c7, 0x0000005ff0c}, // GAMEPAD_RIGHT_SHOULDER - {0x000000c8, 0x0000005ff0d}, // GAMEPAD_LEFT_SHOULDER - {0x000000c9, 0x0000005ff0e}, // GAMEPAD_LEFT_TRIGGER - {0x000000ca, 0x0000005ff0f}, // GAMEPAD_RIGHT_TRIGGER - {0x000000cb, 0x0000005ff10}, // GAMEPAD_DPAD_UP - {0x0000005f, 0x00100010082}, // SLEEP - {0x00000015, 0x00100070090}, // KANA - {0x00000015, 0x00100070090}, // HANGEUL - {0x00000015, 0x00100070090}, // HANGUL - {0x0000006a, 0x0020000002a}, // MULTIPLY - {0x0000006b, 0x0020000002b}, // ADD - {0x0000006d, 0x0020000002d}, // SUBTRACT - {0x0000006e, 0x0020000002e}, // DECIMAL - {0x0000006f, 0x0020000002f}, // DIVIDE - {0x00000060, 0x00200000030}, // NUMPAD0 - {0x00000061, 0x00200000031}, // NUMPAD1 - {0x00000062, 0x00200000032}, // NUMPAD2 - {0x00000063, 0x00200000033}, // NUMPAD3 - {0x00000064, 0x00200000034}, // NUMPAD4 - {0x00000065, 0x00200000035}, // NUMPAD5 - {0x00000066, 0x00200000036}, // NUMPAD6 - {0x00000067, 0x00200000037}, // NUMPAD7 - {0x00000068, 0x00200000038}, // NUMPAD8 - {0x00000069, 0x00200000039}, // NUMPAD9 - {0x00000092, 0x0020000003d}, // OEM_NEC_EQUAL - {0x000000a4, 0x00300000102}, // LMENU - {0x00000011, 0x00300000105}, // CONTROL - {0x000000a2, 0x00300000105}, // LCONTROL - {0x0000005b, 0x00300000109}, // LWIN - {0x00000010, 0x0030000010d}, // SHIFT - {0x000000a0, 0x0030000010d}, // LSHIFT - {0x000000a5, 0x00400000102}, // RMENU - {0x000000a3, 0x00400000105}, // RCONTROL - {0x0000005c, 0x00400000109}, // RWIN - {0x000000a1, 0x0040000010d}, // RSHIFT + {0x00000003, 0x00100000504}, // CANCEL -> cancel + {0x00000008, 0x00100000008}, // BACK -> backspace + {0x00000009, 0x00100000009}, // TAB -> tab + {0x0000000c, 0x00100000401}, // CLEAR -> clear + {0x0000000d, 0x0010000000d}, // RETURN -> enter + {0x00000010, 0x00200000102}, // SHIFT -> shiftLeft + {0x00000011, 0x00200000100}, // CONTROL -> controlLeft + {0x00000013, 0x00100000509}, // PAUSE -> pause + {0x00000014, 0x00100000104}, // CAPITAL -> capsLock + {0x00000015, 0x00200000010}, // KANA, HANGEUL, HANGUL -> lang1 + {0x00000017, 0x00100000713}, // JUNJA -> junjaMode + {0x00000018, 0x00100000706}, // FINAL -> finalMode + {0x00000019, 0x00100000719}, // HANJA, KANJI -> kanjiMode + {0x0000001b, 0x0010000001b}, // ESCAPE -> escape + {0x0000001c, 0x00100000705}, // CONVERT -> convert + {0x0000001e, 0x00100000501}, // ACCEPT -> accept + {0x0000001f, 0x0010000070b}, // MODECHANGE -> modeChange + {0x00000020, 0x00000000020}, // SPACE -> space + {0x00000021, 0x00100000308}, // PRIOR -> pageUp + {0x00000022, 0x00100000307}, // NEXT -> pageDown + {0x00000023, 0x00100000305}, // END -> end + {0x00000024, 0x00100000306}, // HOME -> home + {0x00000025, 0x00100000302}, // LEFT -> arrowLeft + {0x00000026, 0x00100000304}, // UP -> arrowUp + {0x00000027, 0x00100000303}, // RIGHT -> arrowRight + {0x00000028, 0x00100000301}, // DOWN -> arrowDown + {0x00000029, 0x0010000050c}, // SELECT -> select + {0x0000002a, 0x00100000a0c}, // PRINT -> print + {0x0000002b, 0x00100000506}, // EXECUTE -> execute + {0x0000002d, 0x00100000407}, // INSERT -> insert + {0x0000002e, 0x0010000007f}, // DELETE -> delete + {0x0000002f, 0x00100000508}, // HELP -> help + {0x0000005b, 0x00200000106}, // LWIN -> metaLeft + {0x0000005c, 0x00200000107}, // RWIN -> metaRight + {0x0000005d, 0x00100000505}, // APPS -> contextMenu + {0x0000005f, 0x00200000002}, // SLEEP -> sleep + {0x00000060, 0x00200000230}, // NUMPAD0 -> numpad0 + {0x00000061, 0x00200000231}, // NUMPAD1 -> numpad1 + {0x00000062, 0x00200000232}, // NUMPAD2 -> numpad2 + {0x00000063, 0x00200000233}, // NUMPAD3 -> numpad3 + {0x00000064, 0x00200000234}, // NUMPAD4 -> numpad4 + {0x00000065, 0x00200000235}, // NUMPAD5 -> numpad5 + {0x00000066, 0x00200000236}, // NUMPAD6 -> numpad6 + {0x00000067, 0x00200000237}, // NUMPAD7 -> numpad7 + {0x00000068, 0x00200000238}, // NUMPAD8 -> numpad8 + {0x00000069, 0x00200000239}, // NUMPAD9 -> numpad9 + {0x0000006a, 0x0020000022a}, // MULTIPLY -> numpadMultiply + {0x0000006b, 0x0020000022b}, // ADD -> numpadAdd + {0x0000006c, 0x0020000022c}, // SEPARATOR -> numpadComma + {0x0000006d, 0x0020000022d}, // SUBTRACT -> numpadSubtract + {0x0000006e, 0x0020000022e}, // DECIMAL -> numpadDecimal + {0x0000006f, 0x0020000022f}, // DIVIDE -> numpadDivide + {0x00000070, 0x00100000801}, // F1 -> f1 + {0x00000071, 0x00100000802}, // F2 -> f2 + {0x00000072, 0x00100000803}, // F3 -> f3 + {0x00000073, 0x00100000804}, // F4 -> f4 + {0x00000074, 0x00100000805}, // F5 -> f5 + {0x00000075, 0x00100000806}, // F6 -> f6 + {0x00000076, 0x00100000807}, // F7 -> f7 + {0x00000077, 0x00100000808}, // F8 -> f8 + {0x00000078, 0x00100000809}, // F9 -> f9 + {0x00000079, 0x0010000080a}, // F10 -> f10 + {0x0000007a, 0x0010000080b}, // F11 -> f11 + {0x0000007b, 0x0010000080c}, // F12 -> f12 + {0x0000007c, 0x0010000080d}, // F13 -> f13 + {0x0000007d, 0x0010000080e}, // F14 -> f14 + {0x0000007e, 0x0010000080f}, // F15 -> f15 + {0x0000007f, 0x00100000810}, // F16 -> f16 + {0x00000080, 0x00100000811}, // F17 -> f17 + {0x00000081, 0x00100000812}, // F18 -> f18 + {0x00000082, 0x00100000813}, // F19 -> f19 + {0x00000083, 0x00100000814}, // F20 -> f20 + {0x00000084, 0x00100000815}, // F21 -> f21 + {0x00000085, 0x00100000816}, // F22 -> f22 + {0x00000086, 0x00100000817}, // F23 -> f23 + {0x00000087, 0x00100000818}, // F24 -> f24 + {0x00000090, 0x0010000010a}, // NUMLOCK -> numLock + {0x00000091, 0x0010000010c}, // SCROLL -> scrollLock + {0x00000092, 0x0020000023d}, // OEM_NEC_EQUAL -> numpadEqual + {0x000000a0, 0x00200000102}, // LSHIFT -> shiftLeft + {0x000000a1, 0x00200000103}, // RSHIFT -> shiftRight + {0x000000a2, 0x00200000100}, // LCONTROL -> controlLeft + {0x000000a3, 0x00200000101}, // RCONTROL -> controlRight + {0x000000a4, 0x00200000104}, // LMENU -> altLeft + {0x000000a5, 0x00200000105}, // RMENU -> altRight + {0x000000a6, 0x00100000c01}, // BROWSER_BACK -> browserBack + {0x000000a7, 0x00100000c03}, // BROWSER_FORWARD -> browserForward + {0x000000a8, 0x00100000c05}, // BROWSER_REFRESH -> browserRefresh + {0x000000a9, 0x00100000c07}, // BROWSER_STOP -> browserStop + {0x000000aa, 0x00100000c06}, // BROWSER_SEARCH -> browserSearch + {0x000000ab, 0x00100000c02}, // BROWSER_FAVORITES -> browserFavorites + {0x000000ac, 0x00100000c04}, // BROWSER_HOME -> browserHome + {0x000000ad, 0x00100000a11}, // VOLUME_MUTE -> audioVolumeMute + {0x000000ae, 0x00100000a0f}, // VOLUME_DOWN -> audioVolumeDown + {0x000000af, 0x00100000a10}, // VOLUME_UP -> audioVolumeUp + {0x000000b2, 0x00100000a07}, // MEDIA_STOP -> mediaStop + {0x000000b3, 0x00100000a05}, // MEDIA_PLAY_PAUSE -> mediaPlayPause + {0x000000b4, 0x00100000b03}, // LAUNCH_MAIL -> launchMail + {0x000000ba, 0x0000000003b}, // OEM_1 -> semicolon + {0x000000bb, 0x0000000003d}, // OEM_PLUS -> equal + {0x000000bc, 0x0000000002c}, // OEM_COMMA -> comma + {0x000000bd, 0x0000000002d}, // OEM_MINUS -> minus + {0x000000be, 0x0000000002e}, // OEM_PERIOD -> period + {0x000000bf, 0x0000000002f}, // OEM_2 -> slash + {0x000000c0, 0x00000000060}, // OEM_3 -> backquote + {0x000000c3, 0x00200000308}, // GAMEPAD_A -> gameButton8 + {0x000000c4, 0x00200000309}, // GAMEPAD_B -> gameButton9 + {0x000000c5, 0x0020000030a}, // GAMEPAD_X -> gameButton10 + {0x000000c6, 0x0020000030b}, // GAMEPAD_Y -> gameButton11 + {0x000000c7, 0x0020000030c}, // GAMEPAD_RIGHT_SHOULDER -> gameButton12 + {0x000000c8, 0x0020000030d}, // GAMEPAD_LEFT_SHOULDER -> gameButton13 + {0x000000c9, 0x0020000030e}, // GAMEPAD_LEFT_TRIGGER -> gameButton14 + {0x000000ca, 0x0020000030f}, // GAMEPAD_RIGHT_TRIGGER -> gameButton15 + {0x000000cb, 0x00200000310}, // GAMEPAD_DPAD_UP -> gameButton16 + {0x000000db, 0x0000000005b}, // OEM_4 -> bracketLeft + {0x000000dc, 0x0000000005c}, // OEM_5 -> backslash + {0x000000dd, 0x0000000005d}, // OEM_6 -> bracketRight + {0x000000de, 0x00000000022}, // OEM_7 -> quote + {0x000000f6, 0x00100000503}, // ATTN -> attn + {0x000000fa, 0x0010000050a}, // PLAY -> play }; std::map KeyboardKeyEmbedderHandler::scanCodeToLogicalMap_ = { - {0x0000e01d, 0x0400000105}, // ControlRight - {0x0000e038, 0x0400000102}, // AltRight - {0x0000004f, 0x0200000031}, // Numpad1 - {0x00000050, 0x0200000032}, // Numpad2 - {0x00000051, 0x0200000033}, // Numpad3 - {0x0000004b, 0x0200000034}, // Numpad4 - {0x0000004c, 0x0200000035}, // Numpad5 - {0x0000004d, 0x0200000036}, // Numpad6 - {0x00000047, 0x0200000037}, // Numpad7 - {0x00000048, 0x0200000038}, // Numpad8 - {0x00000049, 0x0200000039}, // Numpad9 - {0x00000052, 0x0200000030}, // Numpad0 - {0x0000004e, 0x020000002b}, // NumpadAdd - {0x00000053, 0x020000002e}, // NumpadDecimal - {0x0000e035, 0x020000002f}, // NumpadDivide - {0x00000059, 0x020000003d}, // NumpadEqual - {0x00000037, 0x020000002a}, // NumpadMultiply - {0x0000004a, 0x020000002d}, // NumpadSubtract + {0x00000037, 0x0020000022a}, // numpadMultiply -> numpadMultiply + {0x00000047, 0x00200000237}, // numpad7 -> numpad7 + {0x00000048, 0x00200000238}, // numpad8 -> numpad8 + {0x00000049, 0x00200000239}, // numpad9 -> numpad9 + {0x0000004a, 0x0020000022d}, // numpadSubtract -> numpadSubtract + {0x0000004b, 0x00200000234}, // numpad4 -> numpad4 + {0x0000004c, 0x00200000235}, // numpad5 -> numpad5 + {0x0000004d, 0x00200000236}, // numpad6 -> numpad6 + {0x0000004e, 0x0020000022b}, // numpadAdd -> numpadAdd + {0x0000004f, 0x00200000231}, // numpad1 -> numpad1 + {0x00000050, 0x00200000232}, // numpad2 -> numpad2 + {0x00000051, 0x00200000233}, // numpad3 -> numpad3 + {0x00000052, 0x00200000230}, // numpad0 -> numpad0 + {0x00000053, 0x0020000022e}, // numpadDecimal -> numpadDecimal + {0x00000059, 0x0020000023d}, // numpadEqual -> numpadEqual + {0x0000e01d, 0x00200000101}, // controlRight -> controlRight + {0x0000e035, 0x0020000022f}, // numpadDivide -> numpadDivide + {0x0000e038, 0x00200000105}, // altRight -> altRight }; +const uint64_t KeyboardKeyEmbedderHandler::valueMask = 0x000ffffffff; +const uint64_t KeyboardKeyEmbedderHandler::unicodePlane = 0x00000000000; +const uint64_t KeyboardKeyEmbedderHandler::windowsPlane = 0x01600000000; + } // namespace flutter #endif diff --git a/engine/src/flutter/shell/platform/windows/keyboard_key_embedder_handler.cc b/engine/src/flutter/shell/platform/windows/keyboard_key_embedder_handler.cc index ec1c5402ad..66595efcb9 100644 --- a/engine/src/flutter/shell/platform/windows/keyboard_key_embedder_handler.cc +++ b/engine/src/flutter/shell/platform/windows/keyboard_key_embedder_handler.cc @@ -23,35 +23,6 @@ namespace { // '\0'. constexpr size_t kCharacterCacheSize = 8; -/** - * The code prefix for keys which do not have a Unicode representation. - * - * This is used by platform-specific code to generate Flutter key codes using - * HID Usage codes. - */ -constexpr uint64_t kHidPlane = 0x00100000000; - -/** - * The code prefix for keys which have a Unicode representation. - * - * This is used by platform-specific code to generate Flutter key codes. - */ -constexpr uint64_t kUnicodePlane = 0x00000000000; - -/** - * The code prefix for keys from Windows which do not have a Unicode - * representation. - */ -constexpr uint64_t kWindowsKeyIdPlane = 0x00700000000; - -/** - * Mask for the auto-generated bit portion of the key code. - * - * This is used by platform-specific code to generate new Flutter key codes - * for keys which are not recognized. - */ -constexpr uint64_t kAutogeneratedMask = 0x10000000000; - constexpr SHORT kStateMaskToggled = 0x01; constexpr SHORT kStateMaskPressed = 0x80; @@ -66,13 +37,36 @@ KeyboardKeyEmbedderHandler::KeyboardKeyEmbedderHandler( KeyboardKeyEmbedderHandler::~KeyboardKeyEmbedderHandler() = default; -static bool isAsciiPrintable(int codeUnit) { - return codeUnit <= 0x7f && codeUnit >= 0x20; +static bool isEasciiPrintable(int codeUnit) { + return (codeUnit <= 0x7f && codeUnit >= 0x20) || + (codeUnit <= 0xff && codeUnit >= 0x80); } -static bool isControlCharacter(int codeUnit) { - return (codeUnit <= 0x1f && codeUnit >= 0x00) || - (codeUnit >= 0x7f && codeUnit <= 0x9f); +// Converts upper letters to lower letters in ASCII and extended ASCII, and +// returns as-is otherwise. +// +// Independent of locale. +static uint64_t toLower(uint64_t n) { + constexpr uint64_t lower_a = 0x61; + constexpr uint64_t upper_a = 0x41; + constexpr uint64_t upper_z = 0x5a; + + constexpr uint64_t lower_a_grave = 0xe0; + constexpr uint64_t upper_a_grave = 0xc0; + constexpr uint64_t upper_thorn = 0xde; + constexpr uint64_t division = 0xf7; + + // ASCII range. + if (n >= upper_a && n <= upper_z) { + return n - upper_a + lower_a; + } + + // EASCII range. + if (n >= upper_a_grave && n <= upper_thorn && n != division) { + return n - upper_a_grave + lower_a_grave; + } + + return n; } // Transform scancodes sent by windows to scancodes written in Chromium spec. @@ -82,16 +76,21 @@ static uint16_t normalizeScancode(int windowsScanCode, bool extended) { return (windowsScanCode & 0xff) | (extended ? 0xe000 : 0); } -uint64_t KeyboardKeyEmbedderHandler::getPhysicalKey(int scancode, +uint64_t KeyboardKeyEmbedderHandler::ApplyPlaneToId(uint64_t id, + uint64_t plane) { + return (id & valueMask) | plane; +} + +uint64_t KeyboardKeyEmbedderHandler::GetPhysicalKey(int scancode, bool extended) { int chromiumScancode = normalizeScancode(scancode, extended); auto resultIt = windowsToPhysicalMap_.find(chromiumScancode); if (resultIt != windowsToPhysicalMap_.end()) return resultIt->second; - return scancode | kHidPlane; + return ApplyPlaneToId(scancode, windowsPlane); } -uint64_t KeyboardKeyEmbedderHandler::getLogicalKey(int key, +uint64_t KeyboardKeyEmbedderHandler::GetLogicalKey(int key, bool extended, int scancode) { // Normally logical keys should only be derived from key codes, but since some @@ -108,24 +107,11 @@ uint64_t KeyboardKeyEmbedderHandler::getLogicalKey(int key, return logicalIt->second; // Upper case letters should be normalized into lower case letters. - if (isAsciiPrintable(key)) { - if (isupper(key)) { - return tolower(key); - } - return key; + if (isEasciiPrintable(key)) { + return ApplyPlaneToId(toLower(key), unicodePlane); } - // For keys that do not exist in the map, if it has a non-control-character - // label, then construct a new Unicode-based key from it. Don't mark it as - // autogenerated, since the label uniquely identifies an ID from the Unicode - // plane. - if (!isControlCharacter(key)) { - return key | kUnicodePlane; - } else { - // This is a non-printable key that we don't know about, so we mint a new - // code with the autogenerated bit set. - return key | kWindowsKeyIdPlane | kAutogeneratedMask; - } + return ApplyPlaneToId(toLower(key), windowsPlane); } void KeyboardKeyEmbedderHandler::KeyboardHook( @@ -136,8 +122,8 @@ void KeyboardKeyEmbedderHandler::KeyboardHook( bool extended, bool was_down, std::function callback) { - const uint64_t physical_key = getPhysicalKey(scancode, extended); - const uint64_t logical_key = getLogicalKey(key, extended, scancode); + const uint64_t physical_key = GetPhysicalKey(scancode, extended); + const uint64_t logical_key = GetLogicalKey(key, extended, scancode); assert(action == WM_KEYDOWN || action == WM_KEYUP); const bool is_physical_down = action == WM_KEYDOWN; @@ -364,8 +350,8 @@ void KeyboardKeyEmbedderHandler::InitCriticalKeys() { bool check_toggled) -> CriticalKey { UINT scan_code = MapVirtualKey(virtual_key, MAPVK_VK_TO_VSC); return CriticalKey{ - .physical_key = getPhysicalKey(scan_code, extended), - .logical_key = getLogicalKey(virtual_key, extended, scan_code), + .physical_key = GetPhysicalKey(scan_code, extended), + .logical_key = GetLogicalKey(virtual_key, extended, scan_code), .check_pressed = check_pressed || check_toggled, .check_toggled = check_toggled, .toggled_on = check_toggled diff --git a/engine/src/flutter/shell/platform/windows/keyboard_key_embedder_handler.h b/engine/src/flutter/shell/platform/windows/keyboard_key_embedder_handler.h index 0f557d7b3f..e0132bf2b4 100644 --- a/engine/src/flutter/shell/platform/windows/keyboard_key_embedder_handler.h +++ b/engine/src/flutter/shell/platform/windows/keyboard_key_embedder_handler.h @@ -113,18 +113,28 @@ class KeyboardKeyEmbedderHandler // key they're last seen. std::map critical_keys_; - static uint64_t getPhysicalKey(int scancode, bool extended); - static uint64_t getLogicalKey(int key, bool extended, int scancode); + static uint64_t GetPhysicalKey(int scancode, bool extended); + static uint64_t GetLogicalKey(int key, bool extended, int scancode); static void HandleResponse(bool handled, void* user_data); static void ConvertUtf32ToUtf8_(char* out, char32_t ch); static FlutterKeyEvent SynthesizeSimpleEvent(FlutterKeyEventType type, uint64_t physical, uint64_t logical, const char* character); + static uint64_t ApplyPlaneToId(uint64_t id, uint64_t plane); static std::map windowsToPhysicalMap_; static std::map windowsToLogicalMap_; static std::map scanCodeToLogicalMap_; + + // Mask for the 32-bit value portion of the key code. + static const uint64_t valueMask; + + // The plane value for keys which have a Unicode representation. + static const uint64_t unicodePlane; + + // The plane value for the private keys defined by the GTK embedding. + static const uint64_t windowsPlane; }; } // namespace flutter diff --git a/engine/src/flutter/shell/platform/windows/keyboard_key_embedder_handler_unittests.cc b/engine/src/flutter/shell/platform/windows/keyboard_key_embedder_handler_unittests.cc index 7fdcaece37..ddae527ec9 100644 --- a/engine/src/flutter/shell/platform/windows/keyboard_key_embedder_handler_unittests.cc +++ b/engine/src/flutter/shell/platform/windows/keyboard_key_embedder_handler_unittests.cc @@ -8,6 +8,7 @@ #include #include "flutter/shell/platform/embedder/embedder.h" +#include "flutter/shell/platform/embedder/test_utils/key_codes.h" #include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h" #include "flutter/shell/platform/windows/testing/engine_modifier.h" #include "gtest/gtest.h" @@ -79,19 +80,7 @@ constexpr uint64_t kScanCodeShiftRight = 0x36; constexpr uint64_t kVirtualKeyA = 0x41; -constexpr uint64_t kPhysicalKeyA = 0x00070004; -constexpr uint64_t kPhysicalControlLeft = 0x000700e0; -constexpr uint64_t kPhysicalControlRight = 0x000700e4; -constexpr uint64_t kPhysicalShiftLeft = 0x000700e1; -constexpr uint64_t kPhysicalShiftRight = 0x000700e5; -constexpr uint64_t kPhysicalKeyNumLock = 0x00070053; - -constexpr uint64_t kLogicalKeyA = 0x00000061; -constexpr uint64_t kLogicalControlLeft = 0x00300000105; -constexpr uint64_t kLogicalControlRight = 0x00400000105; -constexpr uint64_t kLogicalShiftLeft = 0x0030000010d; -constexpr uint64_t kLogicalShiftRight = 0x0040000010d; -constexpr uint64_t kLogicalKeyNumLock = 0x0000000010a; +using namespace ::flutter::testing::keycodes; } // namespace // Test the most basic key events. @@ -187,8 +176,8 @@ TEST(KeyboardKeyEmbedderHandlerTest, ToggleNumLockDuringNumpadPress) { EXPECT_EQ(results.size(), 1); event = &results[0]; EXPECT_EQ(event->type, kFlutterKeyEventTypeDown); - EXPECT_EQ(event->physical, 0x00070059); - EXPECT_EQ(event->logical, 0x00200000031); + EXPECT_EQ(event->physical, kPhysicalNumpad1); + EXPECT_EQ(event->logical, kLogicalNumpad1); // EXPECT_STREQ(event->character, "1"); // TODO EXPECT_EQ(event->synthesized, false); results.clear(); @@ -201,8 +190,8 @@ TEST(KeyboardKeyEmbedderHandlerTest, ToggleNumLockDuringNumpadPress) { EXPECT_EQ(results.size(), 1); event = &results[0]; EXPECT_EQ(event->type, kFlutterKeyEventTypeDown); - EXPECT_EQ(event->physical, 0x00070053); - EXPECT_EQ(event->logical, 0x0000010a); + EXPECT_EQ(event->physical, kPhysicalNumLock); + EXPECT_EQ(event->logical, kLogicalNumLock); EXPECT_STREQ(event->character, ""); EXPECT_EQ(event->synthesized, false); results.clear(); @@ -215,8 +204,8 @@ TEST(KeyboardKeyEmbedderHandlerTest, ToggleNumLockDuringNumpadPress) { EXPECT_EQ(results.size(), 1); event = &results[0]; EXPECT_EQ(event->type, kFlutterKeyEventTypeUp); - EXPECT_EQ(event->physical, 0x00070053); - EXPECT_EQ(event->logical, 0x0000010a); + EXPECT_EQ(event->physical, kPhysicalNumLock); + EXPECT_EQ(event->logical, kLogicalNumLock); EXPECT_STREQ(event->character, ""); EXPECT_EQ(event->synthesized, false); results.clear(); @@ -228,8 +217,8 @@ TEST(KeyboardKeyEmbedderHandlerTest, ToggleNumLockDuringNumpadPress) { EXPECT_EQ(results.size(), 1); event = &results[0]; EXPECT_EQ(event->type, kFlutterKeyEventTypeUp); - EXPECT_EQ(event->physical, 0x00070059); - EXPECT_EQ(event->logical, 0x00200000031); + EXPECT_EQ(event->physical, kPhysicalNumpad1); + EXPECT_EQ(event->logical, kLogicalNumpad1); EXPECT_STREQ(event->character, ""); EXPECT_EQ(event->synthesized, false); results.clear(); @@ -648,15 +637,15 @@ TEST(KeyboardKeyEmbedderHandlerTest, SynthesizeForDesyncToggledState) { EXPECT_EQ(results.size(), 3); event = &results[0]; EXPECT_EQ(event->type, kFlutterKeyEventTypeDown); - EXPECT_EQ(event->physical, kPhysicalKeyNumLock); - EXPECT_EQ(event->logical, kLogicalKeyNumLock); + EXPECT_EQ(event->physical, kPhysicalNumLock); + EXPECT_EQ(event->logical, kLogicalNumLock); EXPECT_STREQ(event->character, ""); EXPECT_EQ(event->synthesized, true); event = &results[1]; EXPECT_EQ(event->type, kFlutterKeyEventTypeUp); - EXPECT_EQ(event->physical, kPhysicalKeyNumLock); - EXPECT_EQ(event->logical, kLogicalKeyNumLock); + EXPECT_EQ(event->physical, kPhysicalNumLock); + EXPECT_EQ(event->logical, kLogicalNumLock); EXPECT_STREQ(event->character, ""); EXPECT_EQ(event->synthesized, true); @@ -682,8 +671,8 @@ TEST(KeyboardKeyEmbedderHandlerTest, SynthesizeForDesyncToggledState) { EXPECT_EQ(results.size(), 2); event = &results[0]; EXPECT_EQ(event->type, kFlutterKeyEventTypeDown); - EXPECT_EQ(event->physical, kPhysicalKeyNumLock); - EXPECT_EQ(event->logical, kLogicalKeyNumLock); + EXPECT_EQ(event->physical, kPhysicalNumLock); + EXPECT_EQ(event->logical, kLogicalNumLock); EXPECT_STREQ(event->character, ""); EXPECT_EQ(event->synthesized, true); @@ -711,24 +700,24 @@ TEST(KeyboardKeyEmbedderHandlerTest, SynthesizeForDesyncToggledState) { EXPECT_EQ(results.size(), 4); event = &results[0]; EXPECT_EQ(event->type, kFlutterKeyEventTypeUp); - EXPECT_EQ(event->physical, kPhysicalKeyNumLock); - EXPECT_EQ(event->logical, kLogicalKeyNumLock); + EXPECT_EQ(event->physical, kPhysicalNumLock); + EXPECT_EQ(event->logical, kLogicalNumLock); EXPECT_STREQ(event->character, ""); EXPECT_EQ(event->synthesized, true); EXPECT_EQ(event->callback, nullptr); event = &results[1]; EXPECT_EQ(event->type, kFlutterKeyEventTypeDown); - EXPECT_EQ(event->physical, kPhysicalKeyNumLock); - EXPECT_EQ(event->logical, kLogicalKeyNumLock); + EXPECT_EQ(event->physical, kPhysicalNumLock); + EXPECT_EQ(event->logical, kLogicalNumLock); EXPECT_STREQ(event->character, ""); EXPECT_EQ(event->synthesized, true); EXPECT_EQ(event->callback, nullptr); event = &results[2]; EXPECT_EQ(event->type, kFlutterKeyEventTypeUp); - EXPECT_EQ(event->physical, kPhysicalKeyNumLock); - EXPECT_EQ(event->logical, kLogicalKeyNumLock); + EXPECT_EQ(event->physical, kPhysicalNumLock); + EXPECT_EQ(event->logical, kLogicalNumLock); EXPECT_STREQ(event->character, ""); EXPECT_EQ(event->synthesized, true); EXPECT_EQ(event->callback, nullptr); @@ -775,24 +764,24 @@ TEST(KeyboardKeyEmbedderHandlerTest, SynthesizeForDesyncToggledStateByItself) { EXPECT_EQ(results.size(), 3); event = &results[0]; EXPECT_EQ(event->type, kFlutterKeyEventTypeUp); - EXPECT_EQ(event->physical, kPhysicalKeyNumLock); - EXPECT_EQ(event->logical, kLogicalKeyNumLock); + EXPECT_EQ(event->physical, kPhysicalNumLock); + EXPECT_EQ(event->logical, kLogicalNumLock); EXPECT_STREQ(event->character, ""); EXPECT_EQ(event->synthesized, true); EXPECT_EQ(event->callback, nullptr); event = &results[1]; EXPECT_EQ(event->type, kFlutterKeyEventTypeDown); - EXPECT_EQ(event->physical, kPhysicalKeyNumLock); - EXPECT_EQ(event->logical, kLogicalKeyNumLock); + EXPECT_EQ(event->physical, kPhysicalNumLock); + EXPECT_EQ(event->logical, kLogicalNumLock); EXPECT_STREQ(event->character, ""); EXPECT_EQ(event->synthesized, true); EXPECT_EQ(event->callback, nullptr); event = &results[2]; EXPECT_EQ(event->type, kFlutterKeyEventTypeUp); - EXPECT_EQ(event->physical, kPhysicalKeyNumLock); - EXPECT_EQ(event->logical, kLogicalKeyNumLock); + EXPECT_EQ(event->physical, kPhysicalNumLock); + EXPECT_EQ(event->logical, kLogicalNumLock); EXPECT_STREQ(event->character, ""); EXPECT_EQ(event->synthesized, false); @@ -827,8 +816,8 @@ TEST(KeyboardKeyEmbedderHandlerTest, SynthesizeWithInitialTogglingState) { EXPECT_EQ(results.size(), 1); event = &results[0]; EXPECT_EQ(event->type, kFlutterKeyEventTypeDown); - EXPECT_EQ(event->physical, kPhysicalKeyNumLock); - EXPECT_EQ(event->logical, kLogicalKeyNumLock); + EXPECT_EQ(event->physical, kPhysicalNumLock); + EXPECT_EQ(event->logical, kLogicalNumLock); EXPECT_STREQ(event->character, ""); EXPECT_EQ(event->synthesized, false);