Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
ddeb0b99
Unverified
Commit
ddeb0b99
authored
Jun 16, 2022
by
Tong Mu
Committed by
GitHub
Jun 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[gen_keycodes] Remove invalid Web code maps (#106074)
* Impl * Test
parent
96813e93
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
41 additions
and
54 deletions
+41
-54
gen_keycodes.dart
dev/tools/gen_keycodes/bin/gen_keycodes.dart
+1
-1
android_key_name_to_name.json
dev/tools/gen_keycodes/data/android_key_name_to_name.json
+0
-1
gtk_logical_name_mapping.json
dev/tools/gen_keycodes/data/gtk_logical_name_mapping.json
+0
-2
keyboard_key.tmpl
dev/tools/gen_keycodes/data/keyboard_key.tmpl
+8
-4
keyboard_maps_code_gen.dart
dev/tools/gen_keycodes/lib/keyboard_maps_code_gen.dart
+2
-2
logical_key_data.dart
dev/tools/gen_keycodes/lib/logical_key_data.dart
+3
-0
physical_key_data.dart
dev/tools/gen_keycodes/lib/physical_key_data.dart
+6
-0
testing_key_codes_java_gen.dart
dev/tools/gen_keycodes/lib/testing_key_codes_java_gen.dart
+2
-2
web_code_gen.dart
dev/tools/gen_keycodes/lib/web_code_gen.dart
+3
-3
keyboard_maps.dart
packages/flutter/lib/src/services/keyboard_maps.dart
+0
-39
keyboard_maps_test.dart
packages/flutter/test/services/keyboard_maps_test.dart
+16
-0
No files found.
dev/tools/gen_keycodes/bin/gen_keycodes.dart
View file @
ddeb0b99
...
...
@@ -65,7 +65,7 @@ Future<String> getGlfwKeyCodes() async {
}
Future
<
String
>
getGtkKeyCodes
()
async
{
final
Uri
keyCodesUri
=
Uri
.
parse
(
'https://gitlab.gnome.org/GNOME/gtk/-/raw/
master
/gdk/gdkkeysyms.h'
);
final
Uri
keyCodesUri
=
Uri
.
parse
(
'https://gitlab.gnome.org/GNOME/gtk/-/raw/
gtk-3-24
/gdk/gdkkeysyms.h'
);
return
http
.
read
(
keyCodesUri
);
}
...
...
dev/tools/gen_keycodes/data/android_key_name_to_name.json
View file @
ddeb0b99
...
...
@@ -201,7 +201,6 @@
"NavigatePrevious"
:
[
"NAVIGATE_PREVIOUS"
],
"NewKey"
:
[
"NEW"
],
"NonConvert"
:
[
"MUHENKAN"
],
"None"
:
[
"UNKNOWN"
],
"Notification"
:
[
"NOTIFICATION"
],
"NumLock"
:
[
"NUM_LOCK"
],
"NumberSign"
:
[
"POUND"
],
...
...
dev/tools/gen_keycodes/data/gtk_logical_name_mapping.json
View file @
ddeb0b99
...
...
@@ -101,8 +101,6 @@
"IntlYen"
:
[
"yen"
],
"KanjiMode"
:
[
"Kanji"
],
"Katakana"
:
[
"Katakana"
],
"KbdIllumDown"
:
[
"KbdBrightnessDown"
],
"KbdIllumUp"
:
[
"KbdBrightnessUp"
],
"LaunchAudioBrowser"
:
[
"Music"
],
"LaunchCalendar"
:
[
"Calendar"
],
"LaunchDocuments"
:
[
"Document"
],
...
...
dev/tools/gen_keycodes/data/keyboard_key.tmpl
View file @
ddeb0b99
...
...
@@ -166,10 +166,12 @@ class LogicalKeyboardKey extends KeyboardKey {
@override
bool operator ==(Object other) {
if (identical(this, other))
if (identical(this, other))
{
return true;
if (other.runtimeType != runtimeType)
}
if (other.runtimeType != runtimeType) {
return false;
}
return other is LogicalKeyboardKey
&& other.keyId == keyId;
}
...
...
@@ -348,10 +350,12 @@ class PhysicalKeyboardKey extends KeyboardKey {
@override
bool operator ==(Object other) {
if (identical(this, other))
if (identical(this, other))
{
return true;
if (other.runtimeType != runtimeType)
}
if (other.runtimeType != runtimeType) {
return false;
}
return other is PhysicalKeyboardKey
&& other.usbHidUsage == usbHidUsage;
}
...
...
dev/tools/gen_keycodes/lib/keyboard_maps_code_gen.dart
View file @
ddeb0b99
...
...
@@ -305,8 +305,8 @@ class KeyboardMapsCodeGenerator extends BaseCodeGenerator {
String
get
_webPhysicalKeyMap
{
final
OutputLines
<
String
>
lines
=
OutputLines
<
String
>(
'Web physical key map'
);
for
(
final
PhysicalKeyEntry
entry
in
keyData
.
entries
)
{
if
(
entry
.
name
!=
null
)
{
lines
.
add
(
entry
.
name
,
" '
$
{entry.name}
': PhysicalKeyboardKey.
${entry.constantName}
,"
);
for
(
final
String
webCodes
in
entry
.
webCodes
()
)
{
lines
.
add
(
entry
.
name
,
" '
$
webCodes
': PhysicalKeyboardKey.
${entry.constantName}
,"
);
}
}
return
lines
.
sortedJoin
().
trimRight
();
...
...
dev/tools/gen_keycodes/lib/logical_key_data.dart
View file @
ddeb0b99
...
...
@@ -372,6 +372,9 @@ class LogicalKeyData {
glfwNameToKeyCode
.
forEach
((
String
glfwName
,
int
value
)
{
final
String
?
name
=
nameToFlutterName
[
glfwName
];
if
(
name
==
null
)
{
return
;
}
final
LogicalKeyEntry
?
entry
=
data
[
nameToFlutterName
[
glfwName
]];
if
(
entry
==
null
)
{
print
(
'Invalid logical entry by name
$name
(from GLFW
$glfwName
)'
);
...
...
dev/tools/gen_keycodes/lib/physical_key_data.dart
View file @
ddeb0b99
...
...
@@ -259,6 +259,12 @@ class PhysicalKeyEntry {
/// The Chromium event code for the key.
final
String
?
chromiumCode
;
Iterable
<
String
>
webCodes
()
sync
*
{
if
(
chromiumCode
!=
null
)
{
yield
chromiumCode
!;
}
}
/// Creates a JSON map from the key data.
Map
<
String
,
dynamic
>
toJson
()
{
return
removeEmptyValues
(<
String
,
dynamic
>{
...
...
dev/tools/gen_keycodes/lib/testing_key_codes_java_gen.dart
View file @
ddeb0b99
...
...
@@ -35,7 +35,7 @@ class KeyCodesJavaGenerator extends BaseCodeGenerator {
final
OutputLines
<
int
>
lines
=
OutputLines
<
int
>(
'Physical Key list'
);
for
(
final
PhysicalKeyEntry
entry
in
keyData
.
entries
)
{
lines
.
add
(
entry
.
usbHidCode
,
'''
public static final long PHYSICAL_
${_toUpperSnake(entry.constantName)}
=
${toHex(entry.usbHidCode)}
l
;'''
);
public static final long PHYSICAL_
${_toUpperSnake(entry.constantName)}
=
${toHex(entry.usbHidCode)}
L
;'''
);
}
return
lines
.
sortedJoin
().
trimRight
();
}
...
...
@@ -45,7 +45,7 @@ class KeyCodesJavaGenerator extends BaseCodeGenerator {
final
OutputLines
<
int
>
lines
=
OutputLines
<
int
>(
'Logical Key list'
);
for
(
final
LogicalKeyEntry
entry
in
logicalData
.
entries
)
{
lines
.
add
(
entry
.
value
,
'''
public static final long LOGICAL_
${_toUpperSnake(entry.constantName)}
=
${toHex(entry.value, digits: 11)}
l
;'''
);
public static final long LOGICAL_
${_toUpperSnake(entry.constantName)}
=
${toHex(entry.value, digits: 11)}
L
;'''
);
}
return
lines
.
sortedJoin
().
trimRight
();
}
...
...
dev/tools/gen_keycodes/lib/web_code_gen.dart
View file @
ddeb0b99
...
...
@@ -37,9 +37,9 @@ class WebCodeGenerator extends PlatformCodeGenerator {
String
get
_webPhysicalKeyCodeMap
{
final
OutputLines
<
String
>
lines
=
OutputLines
<
String
>(
'Web physical map'
);
for
(
final
PhysicalKeyEntry
entry
in
keyData
.
entries
)
{
if
(
entry
.
name
!=
null
)
{
lines
.
add
(
entry
.
nam
e
,
" '
$
{entry.name}
':
${toHex(entry.usbHidCode)}
, //
${entry.constantName}
"
);
for
(
final
String
webCode
in
entry
.
webCodes
()
)
{
lines
.
add
(
webCod
e
,
" '
$
webCode
':
${toHex(entry.usbHidCode)}
, //
${entry.constantName}
"
);
}
}
return
lines
.
sortedJoin
().
trimRight
();
...
...
packages/flutter/lib/src/services/keyboard_maps.dart
View file @
ddeb0b99
...
...
@@ -2459,14 +2459,9 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
'Backquote'
:
PhysicalKeyboardKey
.
backquote
,
'Backslash'
:
PhysicalKeyboardKey
.
backslash
,
'Backspace'
:
PhysicalKeyboardKey
.
backspace
,
'BassBoost'
:
PhysicalKeyboardKey
.
bassBoost
,
'BracketLeft'
:
PhysicalKeyboardKey
.
bracketLeft
,
'BracketRight'
:
PhysicalKeyboardKey
.
bracketRight
,
'BrightnessAuto'
:
PhysicalKeyboardKey
.
brightnessAuto
,
'BrightnessDown'
:
PhysicalKeyboardKey
.
brightnessDown
,
'BrightnessMaximum'
:
PhysicalKeyboardKey
.
brightnessMaximum
,
'BrightnessMinimum'
:
PhysicalKeyboardKey
.
brightnessMinimum
,
'BrightnessToggle'
:
PhysicalKeyboardKey
.
brightnessToggle
,
'BrightnessUp'
:
PhysicalKeyboardKey
.
brightnessUp
,
'BrowserBack'
:
PhysicalKeyboardKey
.
browserBack
,
'BrowserFavorites'
:
PhysicalKeyboardKey
.
browserFavorites
,
...
...
@@ -2476,10 +2471,6 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
'BrowserSearch'
:
PhysicalKeyboardKey
.
browserSearch
,
'BrowserStop'
:
PhysicalKeyboardKey
.
browserStop
,
'CapsLock'
:
PhysicalKeyboardKey
.
capsLock
,
'ChannelDown'
:
PhysicalKeyboardKey
.
channelDown
,
'ChannelUp'
:
PhysicalKeyboardKey
.
channelUp
,
'Close'
:
PhysicalKeyboardKey
.
close
,
'ClosedCaptionToggle'
:
PhysicalKeyboardKey
.
closedCaptionToggle
,
'Comma'
:
PhysicalKeyboardKey
.
comma
,
'ContextMenu'
:
PhysicalKeyboardKey
.
contextMenu
,
'ControlLeft'
:
PhysicalKeyboardKey
.
controlLeft
,
...
...
@@ -2504,7 +2495,6 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
'Enter'
:
PhysicalKeyboardKey
.
enter
,
'Equal'
:
PhysicalKeyboardKey
.
equal
,
'Escape'
:
PhysicalKeyboardKey
.
escape
,
'Exit'
:
PhysicalKeyboardKey
.
exit
,
'F1'
:
PhysicalKeyboardKey
.
f1
,
'F10'
:
PhysicalKeyboardKey
.
f10
,
'F11'
:
PhysicalKeyboardKey
.
f11
,
...
...
@@ -2566,14 +2556,11 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
'Help'
:
PhysicalKeyboardKey
.
help
,
'Home'
:
PhysicalKeyboardKey
.
home
,
'Hyper'
:
PhysicalKeyboardKey
.
hyper
,
'Info'
:
PhysicalKeyboardKey
.
info
,
'Insert'
:
PhysicalKeyboardKey
.
insert
,
'IntlBackslash'
:
PhysicalKeyboardKey
.
intlBackslash
,
'IntlRo'
:
PhysicalKeyboardKey
.
intlRo
,
'IntlYen'
:
PhysicalKeyboardKey
.
intlYen
,
'KanaMode'
:
PhysicalKeyboardKey
.
kanaMode
,
'KbdIllumDown'
:
PhysicalKeyboardKey
.
kbdIllumDown
,
'KbdIllumUp'
:
PhysicalKeyboardKey
.
kbdIllumUp
,
'KeyA'
:
PhysicalKeyboardKey
.
keyA
,
'KeyB'
:
PhysicalKeyboardKey
.
keyB
,
'KeyC'
:
PhysicalKeyboardKey
.
keyC
,
...
...
@@ -2609,25 +2596,13 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
'LaunchApp1'
:
PhysicalKeyboardKey
.
launchApp1
,
'LaunchApp2'
:
PhysicalKeyboardKey
.
launchApp2
,
'LaunchAssistant'
:
PhysicalKeyboardKey
.
launchAssistant
,
'LaunchAudioBrowser'
:
PhysicalKeyboardKey
.
launchAudioBrowser
,
'LaunchCalendar'
:
PhysicalKeyboardKey
.
launchCalendar
,
'LaunchContacts'
:
PhysicalKeyboardKey
.
launchContacts
,
'LaunchControlPanel'
:
PhysicalKeyboardKey
.
launchControlPanel
,
'LaunchDocuments'
:
PhysicalKeyboardKey
.
launchDocuments
,
'LaunchInternetBrowser'
:
PhysicalKeyboardKey
.
launchInternetBrowser
,
'LaunchKeyboardLayout'
:
PhysicalKeyboardKey
.
launchKeyboardLayout
,
'LaunchMail'
:
PhysicalKeyboardKey
.
launchMail
,
'LaunchPhone'
:
PhysicalKeyboardKey
.
launchPhone
,
'LaunchScreenSaver'
:
PhysicalKeyboardKey
.
launchScreenSaver
,
'LaunchSpreadsheet'
:
PhysicalKeyboardKey
.
launchSpreadsheet
,
'LaunchWordProcessor'
:
PhysicalKeyboardKey
.
launchWordProcessor
,
'LockScreen'
:
PhysicalKeyboardKey
.
lockScreen
,
'LogOff'
:
PhysicalKeyboardKey
.
logOff
,
'MailForward'
:
PhysicalKeyboardKey
.
mailForward
,
'MailReply'
:
PhysicalKeyboardKey
.
mailReply
,
'MailSend'
:
PhysicalKeyboardKey
.
mailSend
,
'MediaFastForward'
:
PhysicalKeyboardKey
.
mediaFastForward
,
'MediaLast'
:
PhysicalKeyboardKey
.
mediaLast
,
'MediaPause'
:
PhysicalKeyboardKey
.
mediaPause
,
'MediaPlay'
:
PhysicalKeyboardKey
.
mediaPlay
,
'MediaPlayPause'
:
PhysicalKeyboardKey
.
mediaPlayPause
,
...
...
@@ -2641,7 +2616,6 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
'MetaRight'
:
PhysicalKeyboardKey
.
metaRight
,
'MicrophoneMuteToggle'
:
PhysicalKeyboardKey
.
microphoneMuteToggle
,
'Minus'
:
PhysicalKeyboardKey
.
minus
,
'New'
:
PhysicalKeyboardKey
.
newKey
,
'NonConvert'
:
PhysicalKeyboardKey
.
nonConvert
,
'NumLock'
:
PhysicalKeyboardKey
.
numLock
,
'Numpad0'
:
PhysicalKeyboardKey
.
numpad0
,
...
...
@@ -2671,7 +2645,6 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
'NumpadMultiply'
:
PhysicalKeyboardKey
.
numpadMultiply
,
'NumpadParenLeft'
:
PhysicalKeyboardKey
.
numpadParenLeft
,
'NumpadParenRight'
:
PhysicalKeyboardKey
.
numpadParenRight
,
'NumpadSignChange'
:
PhysicalKeyboardKey
.
numpadSignChange
,
'NumpadSubtract'
:
PhysicalKeyboardKey
.
numpadSubtract
,
'Open'
:
PhysicalKeyboardKey
.
open
,
'PageDown'
:
PhysicalKeyboardKey
.
pageDown
,
...
...
@@ -2680,15 +2653,11 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
'Pause'
:
PhysicalKeyboardKey
.
pause
,
'Period'
:
PhysicalKeyboardKey
.
period
,
'Power'
:
PhysicalKeyboardKey
.
power
,
'Print'
:
PhysicalKeyboardKey
.
print
,
'PrintScreen'
:
PhysicalKeyboardKey
.
printScreen
,
'PrivacyScreenToggle'
:
PhysicalKeyboardKey
.
privacyScreenToggle
,
'ProgramGuide'
:
PhysicalKeyboardKey
.
programGuide
,
'Props'
:
PhysicalKeyboardKey
.
props
,
'Quote'
:
PhysicalKeyboardKey
.
quote
,
'Redo'
:
PhysicalKeyboardKey
.
redo
,
'Resume'
:
PhysicalKeyboardKey
.
resume
,
'Save'
:
PhysicalKeyboardKey
.
save
,
'ScrollLock'
:
PhysicalKeyboardKey
.
scrollLock
,
'Select'
:
PhysicalKeyboardKey
.
select
,
'SelectTask'
:
PhysicalKeyboardKey
.
selectTask
,
...
...
@@ -2699,20 +2668,12 @@ const Map<String, PhysicalKeyboardKey> kWebToPhysicalKey = <String, PhysicalKeyb
'Slash'
:
PhysicalKeyboardKey
.
slash
,
'Sleep'
:
PhysicalKeyboardKey
.
sleep
,
'Space'
:
PhysicalKeyboardKey
.
space
,
'SpeechInputToggle'
:
PhysicalKeyboardKey
.
speechInputToggle
,
'SpellCheck'
:
PhysicalKeyboardKey
.
spellCheck
,
'Super'
:
PhysicalKeyboardKey
.
superKey
,
'Suspend'
:
PhysicalKeyboardKey
.
suspend
,
'Tab'
:
PhysicalKeyboardKey
.
tab
,
'Turbo'
:
PhysicalKeyboardKey
.
turbo
,
'Undo'
:
PhysicalKeyboardKey
.
undo
,
'UsbErrorRollOver'
:
PhysicalKeyboardKey
.
usbErrorRollOver
,
'UsbErrorUndefined'
:
PhysicalKeyboardKey
.
usbErrorUndefined
,
'UsbPostFail'
:
PhysicalKeyboardKey
.
usbPostFail
,
'UsbReserved'
:
PhysicalKeyboardKey
.
usbReserved
,
'WakeUp'
:
PhysicalKeyboardKey
.
wakeUp
,
'ZoomIn'
:
PhysicalKeyboardKey
.
zoomIn
,
'ZoomOut'
:
PhysicalKeyboardKey
.
zoomOut
,
'ZoomToggle'
:
PhysicalKeyboardKey
.
zoomToggle
,
};
...
...
packages/flutter/test/services/keyboard_maps_test.dart
0 → 100644
View file @
ddeb0b99
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
test
(
'The Web physical key mapping do not have entries without a Chrome code.'
,
()
{
// Regression test for https://github.com/flutter/flutter/pull/106074.
// There is an entry called KBD_ILLUM_DOWN in dom_code_data.inc, but it
// has an empty "Code" column. This entry should not be present in the
// web mapping.
expect
(
kWebToPhysicalKey
[
'KbdIllumDown'
],
isNull
);
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment