Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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_UTILS_H_
6#define FLUTTER_SHELL_PLATFORM_WINDOWS_KEYBOARD_UTILS_H_
7
8#include <stdint.h>
9
10#include <string>
11
12namespace flutter {
13
14constexpr int kShift = 1 << 0;
15constexpr int kControl = 1 << 3;
16constexpr int kScanCodeShiftLeft = 0x2a;
17constexpr int kScanCodeShiftRight = 0x36;
18constexpr int kKeyCodeShiftLeft = 0xa0;
19constexpr int kScanCodeControlLeft = 0x1d;
20constexpr int kScanCodeControlRight = 0xe01d;
21constexpr 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 '^'.
30constexpr int kDeadKeyCharMask = 0x80000000;
31
32// Revert the "character" for a dead key to its normal value, or the argument
33// unchanged otherwise.
34inline 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.
42std::u16string EncodeUtf16(char32_t character);
43
44} // namespace flutter
45
46#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_KEYBOARD_UTILS_H_
constexpr int kShift
std::u16string EncodeUtf16(char32_t character)
constexpr int kDeadKeyCharMask
constexpr int kKeyCodeShiftLeft
constexpr int kScanCodeShiftRight
constexpr int kScanCodeShiftLeft
constexpr int kScanCodeControlRight
constexpr int kScanCodeControlLeft
constexpr int kKeyCodeControlLeft
constexpr int kControl
uint32_t UndeadChar(uint32_t ch)