[Keyboard, iOS] Generate iOS's special key mapping (#106909)

This commit is contained in:
Tong Mu
2022-07-13 15:40:06 -07:00
committed by GitHub
parent cadb264d26
commit d87faf921d
7 changed files with 99 additions and 29 deletions

View File

@@ -6,6 +6,7 @@ import 'package:path/path.dart' as path;
import 'base_code_gen.dart';
import 'constants.dart';
import 'data.dart';
import 'logical_key_data.dart';
import 'physical_key_data.dart';
import 'utils.dart';
@@ -105,6 +106,15 @@ class IOSCodeGenerator extends PlatformCodeGenerator {
return modifierKeyMap.toString().trimRight();
}
String get _specialKeyMapping {
final OutputLines<int> lines = OutputLines<int>('iOS special key mapping');
kIosSpecialKeyMapping.forEach((String key, String logicalName) {
final int value = logicalData.entryByName(logicalName).value;
lines.add(value, ' @"$key" : @(${toHex(value)}),');
});
return lines.join().trimRight();
}
/// This generates some keys that needs special attention.
String get _specialKeyConstants {
final StringBuffer specialKeyConstants = StringBuffer();
@@ -137,6 +147,7 @@ class IOSCodeGenerator extends PlatformCodeGenerator {
'KEYCODE_TO_MODIFIER_FLAG_MAP': _keyToModifierFlagMap,
'MODIFIER_FLAG_TO_KEYCODE_MAP': _modifierFlagToKeyMap,
'SPECIAL_KEY_CONSTANTS': _specialKeyConstants,
'SPECIAL_KEY_MAPPING': _specialKeyMapping,
};
}
}