Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1f69391

Browse files
authored
Update keycode output (#47988)
## Description This updates the keycode definitions to match what the keycode generator produces, to keep them in sync.
1 parent 7c2b8d5 commit 1f69391

File tree

8 files changed

+136
-49
lines changed

8 files changed

+136
-49
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4712,6 +4712,7 @@ ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterVie
47124712
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h + ../../../flutter/LICENSE
47134713
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewTest.mm + ../../../flutter/LICENSE
47144714
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap.g.mm + ../../../flutter/LICENSE
4715+
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMapTest.mm + ../../../flutter/LICENSE
47154716
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap_Internal.h + ../../../flutter/LICENSE
47164717
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/NSView+ClipsToBounds.h + ../../../flutter/LICENSE
47174718
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/TestFlutterPlatformView.h + ../../../flutter/LICENSE
@@ -5061,6 +5062,7 @@ ORIGIN: ../../../flutter/shell/platform/linux/fl_view_private.h + ../../../flutt
50615062
ORIGIN: ../../../flutter/shell/platform/linux/fl_view_test.cc + ../../../flutter/LICENSE
50625063
ORIGIN: ../../../flutter/shell/platform/linux/key_mapping.g.cc + ../../../flutter/LICENSE
50635064
ORIGIN: ../../../flutter/shell/platform/linux/key_mapping.h + ../../../flutter/LICENSE
5065+
ORIGIN: ../../../flutter/shell/platform/linux/key_mapping_test.cc + ../../../flutter/LICENSE
50645066
ORIGIN: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_basic_message_channel.h + ../../../flutter/LICENSE
50655067
ORIGIN: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_binary_codec.h + ../../../flutter/LICENSE
50665068
ORIGIN: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h + ../../../flutter/LICENSE
@@ -7494,6 +7496,7 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewE
74947496
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h
74957497
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewTest.mm
74967498
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap.g.mm
7499+
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMapTest.mm
74977500
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap_Internal.h
74987501
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/NSView+ClipsToBounds.h
74997502
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/TestFlutterPlatformView.h
@@ -7849,6 +7852,7 @@ FILE: ../../../flutter/shell/platform/linux/fl_view_private.h
78497852
FILE: ../../../flutter/shell/platform/linux/fl_view_test.cc
78507853
FILE: ../../../flutter/shell/platform/linux/key_mapping.g.cc
78517854
FILE: ../../../flutter/shell/platform/linux/key_mapping.h
7855+
FILE: ../../../flutter/shell/platform/linux/key_mapping_test.cc
78527856
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_basic_message_channel.h
78537857
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_binary_codec.h
78547858
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h

shell/platform/darwin/macos/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ executable("flutter_desktop_darwin_unittests") {
192192
"framework/Source/FlutterViewControllerTestUtils.mm",
193193
"framework/Source/FlutterViewEngineProviderTest.mm",
194194
"framework/Source/FlutterViewTest.mm",
195+
"framework/Source/KeyCodeMapTest.mm",
195196
"framework/Source/TestFlutterPlatformView.h",
196197
"framework/Source/TestFlutterPlatformView.mm",
197198
]

shell/platform/darwin/macos/framework/Source/KeyCodeMap.g.mm

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -246,54 +246,55 @@
246246
const uint64_t kCapsLockLogicalKey = 0x100000104;
247247

248248
const std::vector<LayoutGoal> kLayoutGoals = {
249-
LayoutGoal{0x31, 0x20, false}, // Space
250-
LayoutGoal{0x27, 0x22, false}, // Quote
251-
LayoutGoal{0x2b, 0x2c, false}, // Comma
252-
LayoutGoal{0x1b, 0x2d, false}, // Minus
253-
LayoutGoal{0x2f, 0x2e, false}, // Period
254-
LayoutGoal{0x2c, 0x2f, false}, // Slash
255-
LayoutGoal{0x1d, 0x30, true}, // Digit0
256-
LayoutGoal{0x12, 0x31, true}, // Digit1
257-
LayoutGoal{0x13, 0x32, true}, // Digit2
258-
LayoutGoal{0x14, 0x33, true}, // Digit3
259-
LayoutGoal{0x15, 0x34, true}, // Digit4
260-
LayoutGoal{0x17, 0x35, true}, // Digit5
261-
LayoutGoal{0x16, 0x36, true}, // Digit6
262-
LayoutGoal{0x1a, 0x37, true}, // Digit7
263-
LayoutGoal{0x1c, 0x38, true}, // Digit8
264-
LayoutGoal{0x19, 0x39, true}, // Digit9
265-
LayoutGoal{0x29, 0x3b, false}, // Semicolon
266-
LayoutGoal{0x18, 0x3d, false}, // Equal
267-
LayoutGoal{0x21, 0x5b, false}, // BracketLeft
268-
LayoutGoal{0x2a, 0x5c, false}, // Backslash
269-
LayoutGoal{0x1e, 0x5d, false}, // BracketRight
270-
LayoutGoal{0x32, 0x60, false}, // Backquote
271-
LayoutGoal{0x00, 0x61, true}, // KeyA
272-
LayoutGoal{0x0b, 0x62, true}, // KeyB
273-
LayoutGoal{0x08, 0x63, true}, // KeyC
274-
LayoutGoal{0x02, 0x64, true}, // KeyD
275-
LayoutGoal{0x0e, 0x65, true}, // KeyE
276-
LayoutGoal{0x03, 0x66, true}, // KeyF
277-
LayoutGoal{0x05, 0x67, true}, // KeyG
278-
LayoutGoal{0x04, 0x68, true}, // KeyH
279-
LayoutGoal{0x22, 0x69, true}, // KeyI
280-
LayoutGoal{0x26, 0x6a, true}, // KeyJ
281-
LayoutGoal{0x28, 0x6b, true}, // KeyK
282-
LayoutGoal{0x25, 0x6c, true}, // KeyL
283-
LayoutGoal{0x2e, 0x6d, true}, // KeyM
284-
LayoutGoal{0x2d, 0x6e, true}, // KeyN
285-
LayoutGoal{0x1f, 0x6f, true}, // KeyO
286-
LayoutGoal{0x23, 0x70, true}, // KeyP
287-
LayoutGoal{0x0c, 0x71, true}, // KeyQ
288-
LayoutGoal{0x0f, 0x72, true}, // KeyR
289-
LayoutGoal{0x01, 0x73, true}, // KeyS
290-
LayoutGoal{0x11, 0x74, true}, // KeyT
291-
LayoutGoal{0x20, 0x75, true}, // KeyU
292-
LayoutGoal{0x09, 0x76, true}, // KeyV
293-
LayoutGoal{0x0d, 0x77, true}, // KeyW
294-
LayoutGoal{0x07, 0x78, true}, // KeyX
295-
LayoutGoal{0x10, 0x79, true}, // KeyY
296-
LayoutGoal{0x06, 0x7a, true}, // KeyZ
249+
LayoutGoal{0x31, 0x20, false}, // Space
250+
LayoutGoal{0x27, 0x22, false}, // Quote
251+
LayoutGoal{0x2b, 0x2c, false}, // Comma
252+
LayoutGoal{0x1b, 0x2d, false}, // Minus
253+
LayoutGoal{0x2f, 0x2e, false}, // Period
254+
LayoutGoal{0x2c, 0x2f, false}, // Slash
255+
LayoutGoal{0x1d, 0x30, true}, // Digit0
256+
LayoutGoal{0x12, 0x31, true}, // Digit1
257+
LayoutGoal{0x13, 0x32, true}, // Digit2
258+
LayoutGoal{0x14, 0x33, true}, // Digit3
259+
LayoutGoal{0x15, 0x34, true}, // Digit4
260+
LayoutGoal{0x17, 0x35, true}, // Digit5
261+
LayoutGoal{0x16, 0x36, true}, // Digit6
262+
LayoutGoal{0x1a, 0x37, true}, // Digit7
263+
LayoutGoal{0x1c, 0x38, true}, // Digit8
264+
LayoutGoal{0x19, 0x39, true}, // Digit9
265+
LayoutGoal{0x29, 0x3b, false}, // Semicolon
266+
LayoutGoal{0x18, 0x3d, false}, // Equal
267+
LayoutGoal{0x21, 0x5b, false}, // BracketLeft
268+
LayoutGoal{0x2a, 0x5c, false}, // Backslash
269+
LayoutGoal{0x1e, 0x5d, false}, // BracketRight
270+
LayoutGoal{0x32, 0x60, false}, // Backquote
271+
LayoutGoal{0x00, 0x61, true}, // KeyA
272+
LayoutGoal{0x0b, 0x62, true}, // KeyB
273+
LayoutGoal{0x08, 0x63, true}, // KeyC
274+
LayoutGoal{0x02, 0x64, true}, // KeyD
275+
LayoutGoal{0x0e, 0x65, true}, // KeyE
276+
LayoutGoal{0x03, 0x66, true}, // KeyF
277+
LayoutGoal{0x05, 0x67, true}, // KeyG
278+
LayoutGoal{0x04, 0x68, true}, // KeyH
279+
LayoutGoal{0x22, 0x69, true}, // KeyI
280+
LayoutGoal{0x26, 0x6a, true}, // KeyJ
281+
LayoutGoal{0x28, 0x6b, true}, // KeyK
282+
LayoutGoal{0x25, 0x6c, true}, // KeyL
283+
LayoutGoal{0x2e, 0x6d, true}, // KeyM
284+
LayoutGoal{0x2d, 0x6e, true}, // KeyN
285+
LayoutGoal{0x1f, 0x6f, true}, // KeyO
286+
LayoutGoal{0x23, 0x70, true}, // KeyP
287+
LayoutGoal{0x0c, 0x71, true}, // KeyQ
288+
LayoutGoal{0x0f, 0x72, true}, // KeyR
289+
LayoutGoal{0x01, 0x73, true}, // KeyS
290+
LayoutGoal{0x11, 0x74, true}, // KeyT
291+
LayoutGoal{0x20, 0x75, true}, // KeyU
292+
LayoutGoal{0x09, 0x76, true}, // KeyV
293+
LayoutGoal{0x0d, 0x77, true}, // KeyW
294+
LayoutGoal{0x07, 0x78, true}, // KeyX
295+
LayoutGoal{0x10, 0x79, true}, // KeyY
296+
LayoutGoal{0x06, 0x7a, true}, // KeyZ
297+
LayoutGoal{0x0a, 0x200000020, false}, // IntlBackslash
297298
};
298299

299300
} // namespace flutter
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#import "KeyCodeMap_Internal.h"
6+
7+
#import "flutter/testing/testing.h"
8+
#include "third_party/googletest/googletest/include/gtest/gtest.h"
9+
10+
namespace flutter {
11+
12+
bool operator==(const LayoutGoal& a, const LayoutGoal& b) {
13+
return a.keyCode == b.keyCode && a.keyChar == b.keyChar && a.mandatory == b.mandatory;
14+
}
15+
16+
namespace testing {
17+
18+
// Spot check some expected values so that we know that some classes of key
19+
// aren't excluded.
20+
TEST(KeyMappingTest, HasExpectedValues) {
21+
// Has Space
22+
EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x31, 0x20, false}),
23+
kLayoutGoals.end());
24+
// Has Digit0
25+
EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x1d, 0x30, true}),
26+
kLayoutGoals.end());
27+
// Has KeyA
28+
EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x00, 0x61, true}),
29+
kLayoutGoals.end());
30+
// Has Equal
31+
EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x18, 0x3d, false}),
32+
kLayoutGoals.end());
33+
// Has IntlBackslash
34+
EXPECT_NE(
35+
std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x0a, 0x200000020, false}),
36+
kLayoutGoals.end());
37+
}
38+
} // namespace testing
39+
} // namespace flutter

shell/platform/darwin/macos/framework/Source/KeyCodeMap_Internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ typedef struct {
9393
uint16_t keyCode;
9494

9595
// The printable string to derive logical key for.
96-
uint8_t keyChar;
96+
uint64_t keyChar;
9797

9898
// If the goal is mandatory, the keyboard manager will make sure to find a
9999
// logical key for this character, falling back to the US keyboard layout.

shell/platform/linux/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ executable("flutter_linux_unittests") {
228228
"fl_value_test.cc",
229229
"fl_view_accessible_test.cc",
230230
"fl_view_test.cc",
231+
"key_mapping_test.cc",
231232
"testing/fl_test.cc",
232233
"testing/fl_test_gtk_logs.cc",
233234
"testing/fl_test_gtk_logs.h",

shell/platform/linux/key_mapping.g.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ void initialize_lock_bit_to_checked_keys(GHashTable* table) {
460460
}
461461

462462
const std::vector<LayoutGoal> layout_goals = {
463+
LayoutGoal{0x41, 0x20, false}, // Space
463464
LayoutGoal{0x30, 0x22, false}, // Quote
464465
LayoutGoal{0x3b, 0x2c, false}, // Comma
465466
LayoutGoal{0x14, 0x2d, false}, // Minus
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "key_mapping.h"
6+
#include <gmodule.h>
7+
#include <algorithm>
8+
#include <vector>
9+
10+
#include "gtest/gtest.h"
11+
12+
bool operator==(const LayoutGoal& a, const LayoutGoal& b) {
13+
return a.keycode == b.keycode && a.logical_key == b.logical_key &&
14+
a.mandatory == b.mandatory;
15+
}
16+
17+
// Spot check some expected values so that we know that some classes of key
18+
// aren't excluded.
19+
TEST(KeyMappingTest, HasExpectedValues) {
20+
// Has Space
21+
EXPECT_NE(std::find(layout_goals.begin(), layout_goals.end(),
22+
LayoutGoal{0x41, 0x20, false}),
23+
layout_goals.end());
24+
// Has Digit0
25+
EXPECT_NE(std::find(layout_goals.begin(), layout_goals.end(),
26+
LayoutGoal{0x13, 0x30, true}),
27+
layout_goals.end());
28+
// Has KeyA
29+
EXPECT_NE(std::find(layout_goals.begin(), layout_goals.end(),
30+
LayoutGoal{0x26, 0x61, true}),
31+
layout_goals.end());
32+
// Has Equal
33+
EXPECT_NE(std::find(layout_goals.begin(), layout_goals.end(),
34+
LayoutGoal{0x15, 0x3d, false}),
35+
layout_goals.end());
36+
// Has IntlBackslash
37+
EXPECT_NE(std::find(layout_goals.begin(), layout_goals.end(),
38+
LayoutGoal{0x5e, 0x200000020, false}),
39+
layout_goals.end());
40+
}

0 commit comments

Comments
 (0)