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:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user