[windows] Adds support for keyboard mapping. (#54227)
This commit is contained in:
committed by
GitHub
parent
45bf838014
commit
a0f7f6ca6d
@@ -225,6 +225,43 @@ $otherComments static const LogicalKeyboardKey $constantName = LogicalKeyboardK
|
||||
return androidScanCodeMap.toString().trimRight();
|
||||
}
|
||||
|
||||
/// This generates the map of Windows scan codes to physical keys.
|
||||
String get windowsScanCodeMap {
|
||||
final StringBuffer windowsScanCodeMap = StringBuffer();
|
||||
for (final Key entry in keyData.data) {
|
||||
if (entry.windowsScanCode != null) {
|
||||
windowsScanCodeMap.writeln(' ${toHex(entry.windowsScanCode)}: PhysicalKeyboardKey.${entry.constantName},');
|
||||
}
|
||||
}
|
||||
return windowsScanCodeMap.toString().trimRight();
|
||||
}
|
||||
|
||||
/// This generates the map of Windows number pad key codes to logical keys.
|
||||
String get windowsNumpadMap {
|
||||
final StringBuffer windowsNumPadMap = StringBuffer();
|
||||
for (final Key entry in numpadKeyData) {
|
||||
if (entry.windowsKeyCodes != null){
|
||||
for (final int code in entry.windowsKeyCodes) {
|
||||
windowsNumPadMap.writeln(' $code: LogicalKeyboardKey.${entry.constantName},');
|
||||
}
|
||||
}
|
||||
}
|
||||
return windowsNumPadMap.toString().trimRight();
|
||||
}
|
||||
|
||||
/// This generates the map of Windows key codes to logical keys.
|
||||
String get windowsKeyCodeMap {
|
||||
final StringBuffer windowsKeyCodeMap = StringBuffer();
|
||||
for (final Key entry in keyData.data) {
|
||||
if (entry.windowsKeyCodes != null) {
|
||||
for (final int code in entry.windowsKeyCodes) {
|
||||
windowsKeyCodeMap.writeln(' $code: LogicalKeyboardKey.${entry.constantName},');
|
||||
}
|
||||
}
|
||||
}
|
||||
return windowsKeyCodeMap.toString().trimRight();
|
||||
}
|
||||
|
||||
/// This generates the map of macOS key codes to physical keys.
|
||||
String get macOsScanCodeMap {
|
||||
final StringBuffer macOsScanCodeMap = StringBuffer();
|
||||
@@ -381,6 +418,9 @@ $otherComments static const LogicalKeyboardKey $constantName = LogicalKeyboardK
|
||||
'WEB_LOGICAL_KEY_MAP': webLogicalKeyMap,
|
||||
'WEB_PHYSICAL_KEY_MAP': webPhysicalKeyMap,
|
||||
'WEB_NUMPAD_MAP': webNumpadMap,
|
||||
'WINDOWS_LOGICAL_KEY_MAP': windowsKeyCodeMap,
|
||||
'WINDOWS_PHYSICAL_KEY_MAP': windowsScanCodeMap,
|
||||
'WINDOWS_NUMPAD_MAP': windowsNumpadMap,
|
||||
};
|
||||
|
||||
final String template = File(path.join(flutterRoot.path, 'dev', 'tools', 'gen_keycodes', 'data', 'keyboard_maps.tmpl')).readAsStringSync();
|
||||
|
||||
Reference in New Issue
Block a user