Skip to content

Commit ddeb0b9

Browse files
authored
[gen_keycodes] Remove invalid Web code maps (#106074)
* Impl * Test
1 parent 96813e9 commit ddeb0b9

File tree

11 files changed

+41
-54
lines changed

11 files changed

+41
-54
lines changed

dev/tools/gen_keycodes/bin/gen_keycodes.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Future<String> getGlfwKeyCodes() async {
6565
}
6666

6767
Future<String> getGtkKeyCodes() async {
68-
final Uri keyCodesUri = Uri.parse('https://gitlab.gnome.org/GNOME/gtk/-/raw/master/gdk/gdkkeysyms.h');
68+
final Uri keyCodesUri = Uri.parse('https://gitlab.gnome.org/GNOME/gtk/-/raw/gtk-3-24/gdk/gdkkeysyms.h');
6969
return http.read(keyCodesUri);
7070
}
7171

dev/tools/gen_keycodes/data/android_key_name_to_name.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@
201201
"NavigatePrevious": ["NAVIGATE_PREVIOUS"],
202202
"NewKey": ["NEW"],
203203
"NonConvert": ["MUHENKAN"],
204-
"None": ["UNKNOWN"],
205204
"Notification": ["NOTIFICATION"],
206205
"NumLock": ["NUM_LOCK"],
207206
"NumberSign": ["POUND"],

dev/tools/gen_keycodes/data/gtk_logical_name_mapping.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@
101101
"IntlYen": ["yen"],
102102
"KanjiMode": ["Kanji"],
103103
"Katakana": ["Katakana"],
104-
"KbdIllumDown": ["KbdBrightnessDown"],
105-
"KbdIllumUp": ["KbdBrightnessUp"],
106104
"LaunchAudioBrowser": ["Music"],
107105
"LaunchCalendar": ["Calendar"],
108106
"LaunchDocuments": ["Document"],

dev/tools/gen_keycodes/data/keyboard_key.tmpl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,12 @@ class LogicalKeyboardKey extends KeyboardKey {
166166

167167
@override
168168
bool operator ==(Object other) {
169-
if (identical(this, other))
169+
if (identical(this, other)) {
170170
return true;
171-
if (other.runtimeType != runtimeType)
171+
}
172+
if (other.runtimeType != runtimeType) {
172173
return false;
174+
}
173175
return other is LogicalKeyboardKey
174176
&& other.keyId == keyId;
175177
}
@@ -348,10 +350,12 @@ class PhysicalKeyboardKey extends KeyboardKey {
348350

349351
@override
350352
bool operator ==(Object other) {
351-
if (identical(this, other))
353+
if (identical(this, other)) {
352354
return true;
353-
if (other.runtimeType != runtimeType)
355+
}
356+
if (other.runtimeType != runtimeType) {
354357
return false;
358+
}
355359
return other is PhysicalKeyboardKey
356360
&& other.usbHidUsage == usbHidUsage;
357361
}

dev/tools/gen_keycodes/lib/keyboard_maps_code_gen.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ class KeyboardMapsCodeGenerator extends BaseCodeGenerator {
305305
String get _webPhysicalKeyMap {
306306
final OutputLines<String> lines = OutputLines<String>('Web physical key map');
307307
for (final PhysicalKeyEntry entry in keyData.entries) {
308-
if (entry.name != null) {
309-
lines.add(entry.name, " '${entry.name}': PhysicalKeyboardKey.${entry.constantName},");
308+
for (final String webCodes in entry.webCodes()) {
309+
lines.add(entry.name, " '$webCodes': PhysicalKeyboardKey.${entry.constantName},");
310310
}
311311
}
312312
return lines.sortedJoin().trimRight();

dev/tools/gen_keycodes/lib/logical_key_data.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ class LogicalKeyData {
372372

373373
glfwNameToKeyCode.forEach((String glfwName, int value) {
374374
final String? name = nameToFlutterName[glfwName];
375+
if (name == null) {
376+
return;
377+
}
375378
final LogicalKeyEntry? entry = data[nameToFlutterName[glfwName]];
376379
if (entry == null) {
377380
print('Invalid logical entry by name $name (from GLFW $glfwName)');

dev/tools/gen_keycodes/lib/physical_key_data.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ class PhysicalKeyEntry {
259259
/// The Chromium event code for the key.
260260
final String? chromiumCode;
261261

262+
Iterable<String> webCodes() sync* {
263+
if (chromiumCode != null) {
264+
yield chromiumCode!;
265+
}
266+
}
267+
262268
/// Creates a JSON map from the key data.
263269
Map<String, dynamic> toJson() {
264270
return removeEmptyValues(<String, dynamic>{

dev/tools/gen_keycodes/lib/testing_key_codes_java_gen.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class KeyCodesJavaGenerator extends BaseCodeGenerator {
3535
final OutputLines<int> lines = OutputLines<int>('Physical Key list');
3636
for (final PhysicalKeyEntry entry in keyData.entries) {
3737
lines.add(entry.usbHidCode, '''
38-
public static final long PHYSICAL_${_toUpperSnake(entry.constantName)} = ${toHex(entry.usbHidCode)}l;''');
38+
public static final long PHYSICAL_${_toUpperSnake(entry.constantName)} = ${toHex(entry.usbHidCode)}L;''');
3939
}
4040
return lines.sortedJoin().trimRight();
4141
}
@@ -45,7 +45,7 @@ class KeyCodesJavaGenerator extends BaseCodeGenerator {
4545
final OutputLines<int> lines = OutputLines<int>('Logical Key list');
4646
for (final LogicalKeyEntry entry in logicalData.entries) {
4747
lines.add(entry.value, '''
48-
public static final long LOGICAL_${_toUpperSnake(entry.constantName)} = ${toHex(entry.value, digits: 11)}l;''');
48+
public static final long LOGICAL_${_toUpperSnake(entry.constantName)} = ${toHex(entry.value, digits: 11)}L;''');
4949
}
5050
return lines.sortedJoin().trimRight();
5151
}

dev/tools/gen_keycodes/lib/web_code_gen.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ class WebCodeGenerator extends PlatformCodeGenerator {
3737
String get _webPhysicalKeyCodeMap {
3838
final OutputLines<String> lines = OutputLines<String>('Web physical map');
3939
for (final PhysicalKeyEntry entry in keyData.entries) {
40-
if (entry.name != null) {
41-
lines.add(entry.name,
42-
" '${entry.name}': ${toHex(entry.usbHidCode)}, // ${entry.constantName}");
40+
for (final String webCode in entry.webCodes()) {
41+
lines.add(webCode,
42+
" '$webCode': ${toHex(entry.usbHidCode)}, // ${entry.constantName}");
4343
}
4444
}
4545
return lines.sortedJoin().trimRight();

packages/flutter/lib/src/services/keyboard_maps.dart

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,14 +2459,9 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
24592459
'Backquote': PhysicalKeyboardKey.backquote,
24602460
'Backslash': PhysicalKeyboardKey.backslash,
24612461
'Backspace': PhysicalKeyboardKey.backspace,
2462-
'BassBoost': PhysicalKeyboardKey.bassBoost,
24632462
'BracketLeft': PhysicalKeyboardKey.bracketLeft,
24642463
'BracketRight': PhysicalKeyboardKey.bracketRight,
2465-
'BrightnessAuto': PhysicalKeyboardKey.brightnessAuto,
24662464
'BrightnessDown': PhysicalKeyboardKey.brightnessDown,
2467-
'BrightnessMaximum': PhysicalKeyboardKey.brightnessMaximum,
2468-
'BrightnessMinimum': PhysicalKeyboardKey.brightnessMinimum,
2469-
'BrightnessToggle': PhysicalKeyboardKey.brightnessToggle,
24702465
'BrightnessUp': PhysicalKeyboardKey.brightnessUp,
24712466
'BrowserBack': PhysicalKeyboardKey.browserBack,
24722467
'BrowserFavorites': PhysicalKeyboardKey.browserFavorites,
@@ -2476,10 +2471,6 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
24762471
'BrowserSearch': PhysicalKeyboardKey.browserSearch,
24772472
'BrowserStop': PhysicalKeyboardKey.browserStop,
24782473
'CapsLock': PhysicalKeyboardKey.capsLock,
2479-
'ChannelDown': PhysicalKeyboardKey.channelDown,
2480-
'ChannelUp': PhysicalKeyboardKey.channelUp,
2481-
'Close': PhysicalKeyboardKey.close,
2482-
'ClosedCaptionToggle': PhysicalKeyboardKey.closedCaptionToggle,
24832474
'Comma': PhysicalKeyboardKey.comma,
24842475
'ContextMenu': PhysicalKeyboardKey.contextMenu,
24852476
'ControlLeft': PhysicalKeyboardKey.controlLeft,
@@ -2504,7 +2495,6 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
25042495
'Enter': PhysicalKeyboardKey.enter,
25052496
'Equal': PhysicalKeyboardKey.equal,
25062497
'Escape': PhysicalKeyboardKey.escape,
2507-
'Exit': PhysicalKeyboardKey.exit,
25082498
'F1': PhysicalKeyboardKey.f1,
25092499
'F10': PhysicalKeyboardKey.f10,
25102500
'F11': PhysicalKeyboardKey.f11,
@@ -2566,14 +2556,11 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
25662556
'Help': PhysicalKeyboardKey.help,
25672557
'Home': PhysicalKeyboardKey.home,
25682558
'Hyper': PhysicalKeyboardKey.hyper,
2569-
'Info': PhysicalKeyboardKey.info,
25702559
'Insert': PhysicalKeyboardKey.insert,
25712560
'IntlBackslash': PhysicalKeyboardKey.intlBackslash,
25722561
'IntlRo': PhysicalKeyboardKey.intlRo,
25732562
'IntlYen': PhysicalKeyboardKey.intlYen,
25742563
'KanaMode': PhysicalKeyboardKey.kanaMode,
2575-
'KbdIllumDown': PhysicalKeyboardKey.kbdIllumDown,
2576-
'KbdIllumUp': PhysicalKeyboardKey.kbdIllumUp,
25772564
'KeyA': PhysicalKeyboardKey.keyA,
25782565
'KeyB': PhysicalKeyboardKey.keyB,
25792566
'KeyC': PhysicalKeyboardKey.keyC,
@@ -2609,25 +2596,13 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
26092596
'LaunchApp1': PhysicalKeyboardKey.launchApp1,
26102597
'LaunchApp2': PhysicalKeyboardKey.launchApp2,
26112598
'LaunchAssistant': PhysicalKeyboardKey.launchAssistant,
2612-
'LaunchAudioBrowser': PhysicalKeyboardKey.launchAudioBrowser,
2613-
'LaunchCalendar': PhysicalKeyboardKey.launchCalendar,
2614-
'LaunchContacts': PhysicalKeyboardKey.launchContacts,
26152599
'LaunchControlPanel': PhysicalKeyboardKey.launchControlPanel,
2616-
'LaunchDocuments': PhysicalKeyboardKey.launchDocuments,
2617-
'LaunchInternetBrowser': PhysicalKeyboardKey.launchInternetBrowser,
2618-
'LaunchKeyboardLayout': PhysicalKeyboardKey.launchKeyboardLayout,
26192600
'LaunchMail': PhysicalKeyboardKey.launchMail,
2620-
'LaunchPhone': PhysicalKeyboardKey.launchPhone,
26212601
'LaunchScreenSaver': PhysicalKeyboardKey.launchScreenSaver,
2622-
'LaunchSpreadsheet': PhysicalKeyboardKey.launchSpreadsheet,
2623-
'LaunchWordProcessor': PhysicalKeyboardKey.launchWordProcessor,
2624-
'LockScreen': PhysicalKeyboardKey.lockScreen,
2625-
'LogOff': PhysicalKeyboardKey.logOff,
26262602
'MailForward': PhysicalKeyboardKey.mailForward,
26272603
'MailReply': PhysicalKeyboardKey.mailReply,
26282604
'MailSend': PhysicalKeyboardKey.mailSend,
26292605
'MediaFastForward': PhysicalKeyboardKey.mediaFastForward,
2630-
'MediaLast': PhysicalKeyboardKey.mediaLast,
26312606
'MediaPause': PhysicalKeyboardKey.mediaPause,
26322607
'MediaPlay': PhysicalKeyboardKey.mediaPlay,
26332608
'MediaPlayPause': PhysicalKeyboardKey.mediaPlayPause,
@@ -2641,7 +2616,6 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
26412616
'MetaRight': PhysicalKeyboardKey.metaRight,
26422617
'MicrophoneMuteToggle': PhysicalKeyboardKey.microphoneMuteToggle,
26432618
'Minus': PhysicalKeyboardKey.minus,
2644-
'New': PhysicalKeyboardKey.newKey,
26452619
'NonConvert': PhysicalKeyboardKey.nonConvert,
26462620
'NumLock': PhysicalKeyboardKey.numLock,
26472621
'Numpad0': PhysicalKeyboardKey.numpad0,
@@ -2671,7 +2645,6 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
26712645
'NumpadMultiply': PhysicalKeyboardKey.numpadMultiply,
26722646
'NumpadParenLeft': PhysicalKeyboardKey.numpadParenLeft,
26732647
'NumpadParenRight': PhysicalKeyboardKey.numpadParenRight,
2674-
'NumpadSignChange': PhysicalKeyboardKey.numpadSignChange,
26752648
'NumpadSubtract': PhysicalKeyboardKey.numpadSubtract,
26762649
'Open': PhysicalKeyboardKey.open,
26772650
'PageDown': PhysicalKeyboardKey.pageDown,
@@ -2680,15 +2653,11 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
26802653
'Pause': PhysicalKeyboardKey.pause,
26812654
'Period': PhysicalKeyboardKey.period,
26822655
'Power': PhysicalKeyboardKey.power,
2683-
'Print': PhysicalKeyboardKey.print,
26842656
'PrintScreen': PhysicalKeyboardKey.printScreen,
26852657
'PrivacyScreenToggle': PhysicalKeyboardKey.privacyScreenToggle,
2686-
'ProgramGuide': PhysicalKeyboardKey.programGuide,
26872658
'Props': PhysicalKeyboardKey.props,
26882659
'Quote': PhysicalKeyboardKey.quote,
2689-
'Redo': PhysicalKeyboardKey.redo,
26902660
'Resume': PhysicalKeyboardKey.resume,
2691-
'Save': PhysicalKeyboardKey.save,
26922661
'ScrollLock': PhysicalKeyboardKey.scrollLock,
26932662
'Select': PhysicalKeyboardKey.select,
26942663
'SelectTask': PhysicalKeyboardKey.selectTask,
@@ -2699,20 +2668,12 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
26992668
'Slash': PhysicalKeyboardKey.slash,
27002669
'Sleep': PhysicalKeyboardKey.sleep,
27012670
'Space': PhysicalKeyboardKey.space,
2702-
'SpeechInputToggle': PhysicalKeyboardKey.speechInputToggle,
2703-
'SpellCheck': PhysicalKeyboardKey.spellCheck,
27042671
'Super': PhysicalKeyboardKey.superKey,
27052672
'Suspend': PhysicalKeyboardKey.suspend,
27062673
'Tab': PhysicalKeyboardKey.tab,
27072674
'Turbo': PhysicalKeyboardKey.turbo,
27082675
'Undo': PhysicalKeyboardKey.undo,
2709-
'UsbErrorRollOver': PhysicalKeyboardKey.usbErrorRollOver,
2710-
'UsbErrorUndefined': PhysicalKeyboardKey.usbErrorUndefined,
2711-
'UsbPostFail': PhysicalKeyboardKey.usbPostFail,
2712-
'UsbReserved': PhysicalKeyboardKey.usbReserved,
27132676
'WakeUp': PhysicalKeyboardKey.wakeUp,
2714-
'ZoomIn': PhysicalKeyboardKey.zoomIn,
2715-
'ZoomOut': PhysicalKeyboardKey.zoomOut,
27162677
'ZoomToggle': PhysicalKeyboardKey.zoomToggle,
27172678
};
27182679

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy