Add a keyboard key code generator. (#27620)
This adds a keycode generator that incorporates input from the Chromium and Android source trees, as well as some local tables, to generate static constants for the LogicalKeyboardKey and PhysicalKeyboardKey classes, as well as mappings from each of the platforms we support so far (currently only Android and Fuchsia). This code generator parses the input files, generates an intermediate data structure (`key_data.json`) that is checked in, and then generates the Dart sources for these classes and some static maps that will also be checked in (but are not included in this PR). The idea is that these codes don't change often, and so we don't need to generate them on every build, but we would like to be able to update them easily in the future if new data becomes available. If the existing data disappears or becomes unusable, we can maintain the checked-in data structure by hand if necessary, and still be able to generate the code. This PR only contains the code generator, not the classes themselves. In another follow-on PR, I'll run the generator and check in the output of the generator.
This commit is contained in:
40
dev/tools/gen_keycodes/data/keyboard_maps.tmpl
Normal file
40
dev/tools/gen_keycodes/data/keyboard_maps.tmpl
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright 2019 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// DO NOT EDIT -- DO NOT EDIT -- DO NOT EDIT
|
||||
// This file is generated by dev/tools/gen_keycodes/bin/gen_keycodes.dart and
|
||||
// should not be edited directly.
|
||||
//
|
||||
// Edit dev/tools/gen_keycodes/data/keyboard_maps.tmpl instead.
|
||||
// See dev/tools/gen_keycodes/README.md for more information.
|
||||
|
||||
import 'keyboard_key.dart';
|
||||
|
||||
/// Maps Android-specific key codes to the matching [LogicalKeyboardKey].
|
||||
const Map<int, LogicalKeyboardKey> kAndroidToLogicalKey = <int, LogicalKeyboardKey>{
|
||||
@@@ANDROID_KEY_CODE_MAP@@@
|
||||
};
|
||||
|
||||
/// Maps Android-specific scan codes to the matching [PhysicalKeyboardKey].
|
||||
const Map<int, PhysicalKeyboardKey> kAndroidToPhysicalKey = <int, PhysicalKeyboardKey>{
|
||||
@@@ANDROID_SCAN_CODE_MAP@@@
|
||||
};
|
||||
|
||||
/// A map of Android key codes which have printable representations, but appear
|
||||
/// on the number pad. Used to provide different key objects for keys like
|
||||
/// KEY_EQUALS and NUMPAD_EQUALS.
|
||||
const Map<int, LogicalKeyboardKey> kAndroidNumPadMap = <int, LogicalKeyboardKey>{
|
||||
@@@ANDROID_NUMPAD_MAP@@@
|
||||
};
|
||||
|
||||
/// Maps Fuchsia-specific IDs to the matching [LogicalKeyboardKey].
|
||||
const Map<int, LogicalKeyboardKey> kFuchsiaToLogicalKey = <int, LogicalKeyboardKey>{
|
||||
@@@FUCHSIA_KEY_CODE_MAP@@@
|
||||
};
|
||||
|
||||
/// Maps Fuchsia-specific USB HID Usage IDs to the matching
|
||||
/// [PhysicalKeyboardKey].
|
||||
const Map<int, PhysicalKeyboardKey> kFuchsiaToPhysicalKey = <int, PhysicalKeyboardKey>{
|
||||
@@@FUCHSIA_SCAN_CODE_MAP@@@
|
||||
};
|
||||
Reference in New Issue
Block a user