Hardware keyboard: codegen (#73440)

Rewrites tools/gen_keycodes, the script that generates key mappings across the framework and the engine.
This commit is contained in:
Tong Mu
2021-04-30 21:06:03 -07:00
committed by GitHub
parent 0cb0767bd7
commit 9956a35a5a
65 changed files with 23391 additions and 14836 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -107,6 +107,14 @@ class RawKeyEventDataIos extends RawKeyEventData {
if (newKey != null) {
return newKey;
}
// Keys that can't be derived with characterIgnoringModifiers will be
// derived from their key codes using this map.
final LogicalKeyboardKey? knownKey = kIosToLogicalKey[keyCode];
if (knownKey != null) {
return knownKey;
}
// If this key is printable, generate the LogicalKeyboardKey from its
// Unicode value. Control keys such as ESC, CRTL, and SHIFT are not
// printable. HOME, DEL, arrow keys, and function keys are considered

View File

@@ -76,6 +76,14 @@ class RawKeyEventDataMacOs extends RawKeyEventData {
if (numPadKey != null) {
return numPadKey;
}
// Keys that can't be derived with characterIgnoringModifiers will be
// derived from their key codes using this map.
final LogicalKeyboardKey? knownKey = kMacOsToLogicalKey[keyCode];
if (knownKey != null) {
return knownKey;
}
// If this key is printable, generate the LogicalKeyboardKey from its
// Unicode value. Control keys such as ESC, CRTL, and SHIFT are not
// printable. HOME, DEL, arrow keys, and function keys are considered

View File

@@ -29,11 +29,11 @@ void main() {
group(LogicalKeyboardKey, () {
test('Various classes of keys can be looked up by code', () async {
// Check a letter key
expect(LogicalKeyboardKey.findKeyByKeyId(0x0000000061), equals(LogicalKeyboardKey.keyA));
expect(LogicalKeyboardKey.findKeyByKeyId(LogicalKeyboardKey.keyA.keyId), equals(LogicalKeyboardKey.keyA));
// Check a control key
expect(LogicalKeyboardKey.findKeyByKeyId(0x0100070029), equals(LogicalKeyboardKey.escape));
expect(LogicalKeyboardKey.findKeyByKeyId(LogicalKeyboardKey.escape.keyId), equals(LogicalKeyboardKey.escape));
// Check a modifier key
expect(LogicalKeyboardKey.findKeyByKeyId(0x01000700e1), equals(LogicalKeyboardKey.shiftLeft));
expect(LogicalKeyboardKey.findKeyByKeyId(LogicalKeyboardKey.shiftLeft.keyId), equals(LogicalKeyboardKey.shiftLeft));
});
test('Control characters are recognized as such', () async {
// Check some common control characters