Unverified Commit 0e251e0a authored by Tong Mu's avatar Tong Mu Committed by GitHub

[key_codegen] Remove webValues (#81678)

Removes webValues from logical_key_data.json. Web's logical mapping should map webNames to logical key values, i.e. entry.value.
parent d28737ee
// Copyright 2014 The Flutter Authors. All rights reserved. // Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
// Edit the template dev/tools/gen_keycodes/data/web_key_map_dart.tmpl instead. // Edit the template dev/tools/gen_keycodes/data/web_key_map_dart.tmpl instead.
// See dev/tools/gen_keycodes/README.md for more information. // See dev/tools/gen_keycodes/README.md for more information.
// @dart = 2.12
part of engine; part of engine;
/// Maps Web KeyboardEvent codes to the matching LogicalKeyboardKey id. /// Maps Web KeyboardEvent codes to the matching LogicalKeyboardKey id.
......
...@@ -158,14 +158,12 @@ class LogicalKeyData { ...@@ -158,14 +158,12 @@ class LogicalKeyData {
value: value + kLeftModifierPlane, value: value + kLeftModifierPlane,
name: pair.left, name: pair.left,
keyLabel: null, // Modifier keys don't have keyLabels keyLabel: null, // Modifier keys don't have keyLabels
)..webNames.add(pair.left) )..webNames.add(pair.left);
..webValues.add(value + kLeftModifierPlane);
data[pair.right] = LogicalKeyEntry.fromName( data[pair.right] = LogicalKeyEntry.fromName(
value: value + kRightModifierPlane, value: value + kRightModifierPlane,
name: pair.right, name: pair.right,
keyLabel: null, // Modifier keys don't have keyLabels keyLabel: null, // Modifier keys don't have keyLabels
)..webNames.add(pair.right) )..webNames.add(pair.right);
..webValues.add(value + kRightModifierPlane);
continue; continue;
} }
...@@ -177,8 +175,7 @@ class LogicalKeyData { ...@@ -177,8 +175,7 @@ class LogicalKeyData {
value: char.codeUnitAt(0) + kNumpadPlane, value: char.codeUnitAt(0) + kNumpadPlane,
name: numpadName, name: numpadName,
keyLabel: null, // Don't add keyLabel for numpad counterparts keyLabel: null, // Don't add keyLabel for numpad counterparts
)..webNames.add(numpadName) )..webNames.add(numpadName);
..webValues.add(char.codeUnitAt(0) + kNumpadPlane);
unusedNumpad.remove(char); unusedNumpad.remove(char);
} }
...@@ -190,8 +187,7 @@ class LogicalKeyData { ...@@ -190,8 +187,7 @@ class LogicalKeyData {
value: value + (isPrintable ? kUnicodePlane : kUnprintablePlane), value: value + (isPrintable ? kUnicodePlane : kUnprintablePlane),
name: name, name: name,
keyLabel: keyLabel, keyLabel: keyLabel,
)..webNames.add(webName) )..webNames.add(webName);
..webValues.add(value);
}); });
} }
...@@ -418,7 +414,6 @@ class LogicalKeyEntry { ...@@ -418,7 +414,6 @@ class LogicalKeyEntry {
required this.name, required this.name,
this.keyLabel, this.keyLabel,
}) : webNames = <String>[], }) : webNames = <String>[],
webValues = <int>[],
macOsKeyCodeNames = <String>[], macOsKeyCodeNames = <String>[],
macOsKeyCodeValues = <int>[], macOsKeyCodeValues = <int>[],
iosKeyCodeNames = <String>[], iosKeyCodeNames = <String>[],
...@@ -446,18 +441,17 @@ class LogicalKeyEntry { ...@@ -446,18 +441,17 @@ class LogicalKeyEntry {
: value = map['value'] as int, : value = map['value'] as int,
name = map['name'] as String, name = map['name'] as String,
webNames = _toNonEmptyArray<String>(map['names']['web']), webNames = _toNonEmptyArray<String>(map['names']['web']),
webValues = _toNonEmptyArray<int>(map['values']['web']),
macOsKeyCodeNames = _toNonEmptyArray<String>(map['names']['macOs']), macOsKeyCodeNames = _toNonEmptyArray<String>(map['names']['macOs']),
macOsKeyCodeValues = _toNonEmptyArray<int>(map['values']['macOs']), macOsKeyCodeValues = _toNonEmptyArray<int>(map['values']?['macOs']),
iosKeyCodeNames = _toNonEmptyArray<String>(map['names']['ios']), iosKeyCodeNames = _toNonEmptyArray<String>(map['names']['ios']),
iosKeyCodeValues = _toNonEmptyArray<int>(map['values']['ios']), iosKeyCodeValues = _toNonEmptyArray<int>(map['values']?['ios']),
gtkNames = _toNonEmptyArray<String>(map['names']['gtk']), gtkNames = _toNonEmptyArray<String>(map['names']['gtk']),
gtkValues = _toNonEmptyArray<int>(map['values']['gtk']), gtkValues = _toNonEmptyArray<int>(map['values']?['gtk']),
windowsNames = _toNonEmptyArray<String>(map['names']['windows']), windowsNames = _toNonEmptyArray<String>(map['names']['windows']),
windowsValues = _toNonEmptyArray<int>(map['values']['windows']), windowsValues = _toNonEmptyArray<int>(map['values']?['windows']),
androidNames = _toNonEmptyArray<String>(map['names']['android']), androidNames = _toNonEmptyArray<String>(map['names']['android']),
androidValues = _toNonEmptyArray<int>(map['values']['android']), androidValues = _toNonEmptyArray<int>(map['values']?['android']),
fuchsiaValues = _toNonEmptyArray<int>(map['values']['fuchsia']), fuchsiaValues = _toNonEmptyArray<int>(map['values']?['fuchsia']),
keyLabel = map['keyLabel'] as String?; keyLabel = map['keyLabel'] as String?;
final int value; final int value;
...@@ -474,9 +468,6 @@ class LogicalKeyEntry { ...@@ -474,9 +468,6 @@ class LogicalKeyEntry {
/// symbol name. /// symbol name.
final List<String> webNames; final List<String> webNames;
/// The value of the key.
final List<int> webValues;
/// The names of the key codes that corresponds to this logical key on macOS, /// The names of the key codes that corresponds to this logical key on macOS,
/// created from the corresponding physical keys. /// created from the corresponding physical keys.
final List<String> macOsKeyCodeNames; final List<String> macOsKeyCodeNames;
...@@ -544,7 +535,6 @@ class LogicalKeyEntry { ...@@ -544,7 +535,6 @@ class LogicalKeyEntry {
'android': androidNames, 'android': androidNames,
}, },
'values': <String, List<int>>{ 'values': <String, List<int>>{
'web': webValues,
'macOs': macOsKeyCodeValues, 'macOs': macOsKeyCodeValues,
'ios': iosKeyCodeValues, 'ios': iosKeyCodeValues,
'gtk': gtkValues, 'gtk': gtkValues,
......
...@@ -50,7 +50,7 @@ class MacOsCodeGenerator extends PlatformCodeGenerator { ...@@ -50,7 +50,7 @@ class MacOsCodeGenerator extends PlatformCodeGenerator {
final StringBuffer result = StringBuffer(); final StringBuffer result = StringBuffer();
for (final LogicalKeyEntry entry in logicalData.entries) { for (final LogicalKeyEntry entry in logicalData.entries) {
zipStrict(entry.macOsKeyCodeValues, entry.macOsKeyCodeNames, (int macOsValue, String macOsName) { zipStrict(entry.macOsKeyCodeValues, entry.macOsKeyCodeNames, (int macOsValue, String macOsName) {
result.writeln(' @${toHex(macOsValue)} : @${toHex(entry.value, digits: 10)}, // $macOsName'); result.writeln(' @${toHex(macOsValue)} : @${toHex(entry.value, digits: 11)}, // $macOsName');
}); });
} }
return result.toString().trimRight(); return result.toString().trimRight();
......
...@@ -21,13 +21,13 @@ class WebCodeGenerator extends PlatformCodeGenerator { ...@@ -21,13 +21,13 @@ class WebCodeGenerator extends PlatformCodeGenerator {
/// This generates the map of Web KeyboardEvent codes to logical key ids. /// This generates the map of Web KeyboardEvent codes to logical key ids.
String get _webLogicalKeyCodeMap { String get _webLogicalKeyCodeMap {
final StringBuffer result = StringBuffer(); final OutputLines<String> lines = OutputLines<String>('Web logical map');
for (final LogicalKeyEntry entry in logicalData.entries) { for (final LogicalKeyEntry entry in logicalData.entries) {
zipStrict(entry.webValues, entry.webNames, (int value, String name) { for (final String name in entry.webNames) {
result.writeln(" '$name': ${toHex(value, digits: 10)},"); lines.add(name, " '$name': ${toHex(entry.value, digits: 11)},");
}); }
} }
return result.toString().trimRight(); return lines.sortedJoin().trimRight();
} }
/// This generates the map of Web KeyboardEvent codes to physical key USB HID codes. /// This generates the map of Web KeyboardEvent codes to physical key USB HID codes.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment