| Flutter Windows Embedder |

keyboard_utils.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_KEYBOARD_WIN32_COMMON_H_
6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_KEYBOARD_WIN32_COMMON_H_
7
8 #include <stdint.h>
9
10 #include <string>
11
12 namespace flutter {
13
14 constexpr int kShift = 1 << 0;
15 constexpr int kControl = 1 << 3;
16 constexpr int kScanCodeShiftLeft = 0x2a;
17 constexpr int kScanCodeShiftRight = 0x36;
18 constexpr int kKeyCodeShiftLeft = 0xa0;
19 constexpr int kScanCodeControlLeft = 0x1d;
20 constexpr int kScanCodeControlRight = 0xe01d;
21 constexpr int kKeyCodeControlLeft = 0xa2;
22
23 // The bit of a mapped character in a WM_KEYDOWN message that indicates the
24 // character is a dead key.
25 //
26 // When a dead key is pressed, the WM_KEYDOWN's lParam is mapped to a special
27 // value: the "normal character" | 0x80000000. For example, when pressing
28 // "dead key caret" (one that makes the following e into ê), its mapped
29 // character is 0x8000005E. "Reverting" it gives 0x5E, which is character '^'.
30 constexpr int kDeadKeyCharMask = 0x80000000;
31
32 // Revert the "character" for a dead key to its normal value, or the argument
33 // unchanged otherwise.
34 inline uint32_t UndeadChar(uint32_t ch) {
35 return ch & ~kDeadKeyCharMask;
36 }
37
38 // Encode a Unicode codepoint into a UTF-16 string.
39 //
40 // If the codepoint is invalid, this function throws an assertion error, and
41 // returns an empty string.
42 std::u16string EncodeUtf16(char32_t character);
43
44 } // namespace flutter
45
46 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_KEYBOARD_WIN32_COMMON_H_
flutter::kKeyCodeShiftLeft
constexpr int kKeyCodeShiftLeft
Definition: keyboard_utils.h:18
character
char32_t character
Definition: keyboard_key_handler_unittests.cc:117
flutter::EncodeUtf16
std::u16string EncodeUtf16(char32_t character)
Definition: keyboard_utils.cc:11
flutter::kScanCodeShiftLeft
constexpr int kScanCodeShiftLeft
Definition: keyboard_utils.h:16
flutter::UndeadChar
uint32_t UndeadChar(uint32_t ch)
Definition: keyboard_utils.h:34
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::kShift
constexpr int kShift
Definition: keyboard_utils.h:14
flutter::kScanCodeControlLeft
constexpr int kScanCodeControlLeft
Definition: keyboard_utils.h:19
flutter::kKeyCodeControlLeft
constexpr int kKeyCodeControlLeft
Definition: keyboard_utils.h:21
flutter::kDeadKeyCharMask
constexpr int kDeadKeyCharMask
Definition: keyboard_utils.h:30
flutter::kScanCodeControlRight
constexpr int kScanCodeControlRight
Definition: keyboard_utils.h:20
flutter::kControl
constexpr int kControl
Definition: keyboard_utils.h:15
flutter::kScanCodeShiftRight
constexpr int kScanCodeShiftRight
Definition: keyboard_utils.h:17