Update keycode output (flutter/engine#47988)

## Description

This updates the keycode definitions to match what the keycode generator produces, to keep them in sync.
This commit is contained in:
Greg Spencer 2023-11-15 09:29:34 -08:00 committed by GitHub
parent a9c9177d35
commit 28d807f326
8 changed files with 136 additions and 49 deletions

View File

@ -4712,6 +4712,7 @@ ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterVie
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewTest.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap.g.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMapTest.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap_Internal.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/macos/framework/Source/NSView+ClipsToBounds.h + ../../../flutter/LICENSE
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
ORIGIN: ../../../flutter/shell/platform/linux/fl_view_test.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/key_mapping.g.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/key_mapping.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/key_mapping_test.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_basic_message_channel.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_binary_codec.h + ../../../flutter/LICENSE
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
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewTest.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap.g.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMapTest.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap_Internal.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/NSView+ClipsToBounds.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/TestFlutterPlatformView.h
@ -7849,6 +7852,7 @@ FILE: ../../../flutter/shell/platform/linux/fl_view_private.h
FILE: ../../../flutter/shell/platform/linux/fl_view_test.cc
FILE: ../../../flutter/shell/platform/linux/key_mapping.g.cc
FILE: ../../../flutter/shell/platform/linux/key_mapping.h
FILE: ../../../flutter/shell/platform/linux/key_mapping_test.cc
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_basic_message_channel.h
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_binary_codec.h
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h

View File

@ -192,6 +192,7 @@ executable("flutter_desktop_darwin_unittests") {
"framework/Source/FlutterViewControllerTestUtils.mm",
"framework/Source/FlutterViewEngineProviderTest.mm",
"framework/Source/FlutterViewTest.mm",
"framework/Source/KeyCodeMapTest.mm",
"framework/Source/TestFlutterPlatformView.h",
"framework/Source/TestFlutterPlatformView.mm",
]

View File

@ -246,54 +246,55 @@ const uint64_t kCapsLockPhysicalKey = 0x00070039;
const uint64_t kCapsLockLogicalKey = 0x100000104;
const std::vector<LayoutGoal> kLayoutGoals = {
LayoutGoal{0x31, 0x20, false}, // Space
LayoutGoal{0x27, 0x22, false}, // Quote
LayoutGoal{0x2b, 0x2c, false}, // Comma
LayoutGoal{0x1b, 0x2d, false}, // Minus
LayoutGoal{0x2f, 0x2e, false}, // Period
LayoutGoal{0x2c, 0x2f, false}, // Slash
LayoutGoal{0x1d, 0x30, true}, // Digit0
LayoutGoal{0x12, 0x31, true}, // Digit1
LayoutGoal{0x13, 0x32, true}, // Digit2
LayoutGoal{0x14, 0x33, true}, // Digit3
LayoutGoal{0x15, 0x34, true}, // Digit4
LayoutGoal{0x17, 0x35, true}, // Digit5
LayoutGoal{0x16, 0x36, true}, // Digit6
LayoutGoal{0x1a, 0x37, true}, // Digit7
LayoutGoal{0x1c, 0x38, true}, // Digit8
LayoutGoal{0x19, 0x39, true}, // Digit9
LayoutGoal{0x29, 0x3b, false}, // Semicolon
LayoutGoal{0x18, 0x3d, false}, // Equal
LayoutGoal{0x21, 0x5b, false}, // BracketLeft
LayoutGoal{0x2a, 0x5c, false}, // Backslash
LayoutGoal{0x1e, 0x5d, false}, // BracketRight
LayoutGoal{0x32, 0x60, false}, // Backquote
LayoutGoal{0x00, 0x61, true}, // KeyA
LayoutGoal{0x0b, 0x62, true}, // KeyB
LayoutGoal{0x08, 0x63, true}, // KeyC
LayoutGoal{0x02, 0x64, true}, // KeyD
LayoutGoal{0x0e, 0x65, true}, // KeyE
LayoutGoal{0x03, 0x66, true}, // KeyF
LayoutGoal{0x05, 0x67, true}, // KeyG
LayoutGoal{0x04, 0x68, true}, // KeyH
LayoutGoal{0x22, 0x69, true}, // KeyI
LayoutGoal{0x26, 0x6a, true}, // KeyJ
LayoutGoal{0x28, 0x6b, true}, // KeyK
LayoutGoal{0x25, 0x6c, true}, // KeyL
LayoutGoal{0x2e, 0x6d, true}, // KeyM
LayoutGoal{0x2d, 0x6e, true}, // KeyN
LayoutGoal{0x1f, 0x6f, true}, // KeyO
LayoutGoal{0x23, 0x70, true}, // KeyP
LayoutGoal{0x0c, 0x71, true}, // KeyQ
LayoutGoal{0x0f, 0x72, true}, // KeyR
LayoutGoal{0x01, 0x73, true}, // KeyS
LayoutGoal{0x11, 0x74, true}, // KeyT
LayoutGoal{0x20, 0x75, true}, // KeyU
LayoutGoal{0x09, 0x76, true}, // KeyV
LayoutGoal{0x0d, 0x77, true}, // KeyW
LayoutGoal{0x07, 0x78, true}, // KeyX
LayoutGoal{0x10, 0x79, true}, // KeyY
LayoutGoal{0x06, 0x7a, true}, // KeyZ
LayoutGoal{0x31, 0x20, false}, // Space
LayoutGoal{0x27, 0x22, false}, // Quote
LayoutGoal{0x2b, 0x2c, false}, // Comma
LayoutGoal{0x1b, 0x2d, false}, // Minus
LayoutGoal{0x2f, 0x2e, false}, // Period
LayoutGoal{0x2c, 0x2f, false}, // Slash
LayoutGoal{0x1d, 0x30, true}, // Digit0
LayoutGoal{0x12, 0x31, true}, // Digit1
LayoutGoal{0x13, 0x32, true}, // Digit2
LayoutGoal{0x14, 0x33, true}, // Digit3
LayoutGoal{0x15, 0x34, true}, // Digit4
LayoutGoal{0x17, 0x35, true}, // Digit5
LayoutGoal{0x16, 0x36, true}, // Digit6
LayoutGoal{0x1a, 0x37, true}, // Digit7
LayoutGoal{0x1c, 0x38, true}, // Digit8
LayoutGoal{0x19, 0x39, true}, // Digit9
LayoutGoal{0x29, 0x3b, false}, // Semicolon
LayoutGoal{0x18, 0x3d, false}, // Equal
LayoutGoal{0x21, 0x5b, false}, // BracketLeft
LayoutGoal{0x2a, 0x5c, false}, // Backslash
LayoutGoal{0x1e, 0x5d, false}, // BracketRight
LayoutGoal{0x32, 0x60, false}, // Backquote
LayoutGoal{0x00, 0x61, true}, // KeyA
LayoutGoal{0x0b, 0x62, true}, // KeyB
LayoutGoal{0x08, 0x63, true}, // KeyC
LayoutGoal{0x02, 0x64, true}, // KeyD
LayoutGoal{0x0e, 0x65, true}, // KeyE
LayoutGoal{0x03, 0x66, true}, // KeyF
LayoutGoal{0x05, 0x67, true}, // KeyG
LayoutGoal{0x04, 0x68, true}, // KeyH
LayoutGoal{0x22, 0x69, true}, // KeyI
LayoutGoal{0x26, 0x6a, true}, // KeyJ
LayoutGoal{0x28, 0x6b, true}, // KeyK
LayoutGoal{0x25, 0x6c, true}, // KeyL
LayoutGoal{0x2e, 0x6d, true}, // KeyM
LayoutGoal{0x2d, 0x6e, true}, // KeyN
LayoutGoal{0x1f, 0x6f, true}, // KeyO
LayoutGoal{0x23, 0x70, true}, // KeyP
LayoutGoal{0x0c, 0x71, true}, // KeyQ
LayoutGoal{0x0f, 0x72, true}, // KeyR
LayoutGoal{0x01, 0x73, true}, // KeyS
LayoutGoal{0x11, 0x74, true}, // KeyT
LayoutGoal{0x20, 0x75, true}, // KeyU
LayoutGoal{0x09, 0x76, true}, // KeyV
LayoutGoal{0x0d, 0x77, true}, // KeyW
LayoutGoal{0x07, 0x78, true}, // KeyX
LayoutGoal{0x10, 0x79, true}, // KeyY
LayoutGoal{0x06, 0x7a, true}, // KeyZ
LayoutGoal{0x0a, 0x200000020, false}, // IntlBackslash
};
} // namespace flutter

View File

@ -0,0 +1,39 @@
// Copyright 2013 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 "KeyCodeMap_Internal.h"
#import "flutter/testing/testing.h"
#include "third_party/googletest/googletest/include/gtest/gtest.h"
namespace flutter {
bool operator==(const LayoutGoal& a, const LayoutGoal& b) {
return a.keyCode == b.keyCode && a.keyChar == b.keyChar && a.mandatory == b.mandatory;
}
namespace testing {
// Spot check some expected values so that we know that some classes of key
// aren't excluded.
TEST(KeyMappingTest, HasExpectedValues) {
// Has Space
EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x31, 0x20, false}),
kLayoutGoals.end());
// Has Digit0
EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x1d, 0x30, true}),
kLayoutGoals.end());
// Has KeyA
EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x00, 0x61, true}),
kLayoutGoals.end());
// Has Equal
EXPECT_NE(std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x18, 0x3d, false}),
kLayoutGoals.end());
// Has IntlBackslash
EXPECT_NE(
std::find(kLayoutGoals.begin(), kLayoutGoals.end(), LayoutGoal{0x0a, 0x200000020, false}),
kLayoutGoals.end());
}
} // namespace testing
} // namespace flutter

View File

@ -93,7 +93,7 @@ typedef struct {
uint16_t keyCode;
// The printable string to derive logical key for.
uint8_t keyChar;
uint64_t keyChar;
// If the goal is mandatory, the keyboard manager will make sure to find a
// logical key for this character, falling back to the US keyboard layout.

View File

@ -228,6 +228,7 @@ executable("flutter_linux_unittests") {
"fl_value_test.cc",
"fl_view_accessible_test.cc",
"fl_view_test.cc",
"key_mapping_test.cc",
"testing/fl_test.cc",
"testing/fl_test_gtk_logs.cc",
"testing/fl_test_gtk_logs.h",

View File

@ -460,6 +460,7 @@ void initialize_lock_bit_to_checked_keys(GHashTable* table) {
}
const std::vector<LayoutGoal> layout_goals = {
LayoutGoal{0x41, 0x20, false}, // Space
LayoutGoal{0x30, 0x22, false}, // Quote
LayoutGoal{0x3b, 0x2c, false}, // Comma
LayoutGoal{0x14, 0x2d, false}, // Minus

View File

@ -0,0 +1,40 @@
// Copyright 2013 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.
#include "key_mapping.h"
#include <gmodule.h>
#include <algorithm>
#include <vector>
#include "gtest/gtest.h"
bool operator==(const LayoutGoal& a, const LayoutGoal& b) {
return a.keycode == b.keycode && a.logical_key == b.logical_key &&
a.mandatory == b.mandatory;
}
// Spot check some expected values so that we know that some classes of key
// aren't excluded.
TEST(KeyMappingTest, HasExpectedValues) {
// Has Space
EXPECT_NE(std::find(layout_goals.begin(), layout_goals.end(),
LayoutGoal{0x41, 0x20, false}),
layout_goals.end());
// Has Digit0
EXPECT_NE(std::find(layout_goals.begin(), layout_goals.end(),
LayoutGoal{0x13, 0x30, true}),
layout_goals.end());
// Has KeyA
EXPECT_NE(std::find(layout_goals.begin(), layout_goals.end(),
LayoutGoal{0x26, 0x61, true}),
layout_goals.end());
// Has Equal
EXPECT_NE(std::find(layout_goals.begin(), layout_goals.end(),
LayoutGoal{0x15, 0x3d, false}),
layout_goals.end());
// Has IntlBackslash
EXPECT_NE(std::find(layout_goals.begin(), layout_goals.end(),
LayoutGoal{0x5e, 0x200000020, false}),
layout_goals.end());
}