Unverified Commit e9905b6a authored by Francisco Magdaleno's avatar Francisco Magdaleno Committed by GitHub

[Keyboard] Collects windows key data (#52265)

parent bc43b41d
......@@ -17,7 +17,7 @@ import 'package:gen_keycodes/utils.dart';
/// Get contents of the file that contains the key code mapping in Chromium
/// source.
Future<String> getChromiumConversions() async {
final Uri keyCodeMapUri = Uri.parse('https://cs.chromium.org/codesearch/f/chromium/src/ui/events/keycodes/dom/keycode_converter_data.inc');
final Uri keyCodeMapUri = Uri.parse('https://cs.chromium.org/codesearch/f/chromium/src/ui/events/keycodes/dom/dom_code_data.inc');
return await http.read(keyCodeMapUri);
}
......@@ -27,6 +27,11 @@ Future<String> getAndroidKeyCodes() async {
return utf8.decode(base64.decode(await http.read(keyCodesUri)));
}
Future<String> getWindowsKeyCodes() async {
final Uri keyCodesUri = Uri.parse('https://raw.githubusercontent.com/tpn/winsdk-10/master/Include/10.0.10240.0/um/WinUser.h');
return await http.read(keyCodesUri);
}
/// Get contents of the file that contains the scan codes in Android source.
/// Yes, this is just the generic keyboard layout file for base Android distro
/// This is because there isn't any facility in Android to get the keyboard
......@@ -84,12 +89,23 @@ Future<void> main(List<String> rawArguments) async {
'If --glfw-keycodes is not specified, the input will be read from the '
'correct file in the GLFW github repository.',
);
argParser.addOption(
argParser.addOption(
'windows-keycodes',
defaultsTo: null,
help: 'The path to where the Windows keycodes header file should be read. '
'If --windows-keycodes is not specified, the input will be read from the '
'correct file in the Windows github repository.',
);
argParser.addOption(
'windows-domkey',
defaultsTo: path.join(flutterRoot.path, 'dev', 'tools', 'gen_keycodes', 'data', 'key_name_to_windows_name.json'),
help: 'The path to where the Windows keycode to DomKey mapping is.',
);
argParser.addOption(
'glfw-domkey',
defaultsTo: path.join(flutterRoot.path, 'dev', 'tools', 'gen_keycodes', 'data', 'key_name_to_glfw_name.json'),
help: 'The path to where the GLFW keycode to DomKey mapping is.',
);
argParser.addOption(
'data',
defaultsTo: path.join(flutterRoot.path, 'dev', 'tools', 'gen_keycodes', 'data', 'key_data.json'),
......@@ -170,10 +186,18 @@ Future<void> main(List<String> rawArguments) async {
glfwKeyCodes = File(parsedArguments['glfw-keycodes'] as String).readAsStringSync();
}
String windowsKeyCodes;
if (parsedArguments['windows-keycodes'] == null) {
windowsKeyCodes = await getWindowsKeyCodes();
} else {
windowsKeyCodes = File(parsedArguments['windows-keycodes'] as String).readAsStringSync();
}
final String windowsToDomKey = File(parsedArguments['windows-domkey'] as String).readAsStringSync();
final String glfwToDomKey = File(parsedArguments['glfw-domkey'] as String).readAsStringSync();
final String androidToDomKey = File(parsedArguments['android-domkey'] as String).readAsStringSync();
data = KeyData(hidCodes, androidScanCodes, androidKeyCodes, androidToDomKey, glfwKeyCodes, glfwToDomKey);
data = KeyData(hidCodes, androidScanCodes, androidKeyCodes, androidToDomKey, glfwKeyCodes, glfwToDomKey, windowsKeyCodes, windowsToDomKey);
const JsonEncoder encoder = JsonEncoder.withIndent(' ');
File(parsedArguments['data'] as String).writeAsStringSync(encoder.convert(data.toJson()));
......
This diff is collapsed.
This diff is collapsed.
......@@ -45,7 +45,7 @@ abstract class KeyboardKey extends Diagnosticable {
/// look at the physical key to make sure that regardless of the character the
/// key produces, you got the key that is in that location on the keyboard.
///
/// {@tool sample --template=stateful_widget_scaffold}
/// {@tool dartpad --template=stateful_widget_scaffold}
/// This example shows how to detect if the user has selected the logical "Q"
/// key.
///
......@@ -331,7 +331,7 @@ class LogicalKeyboardKey extends KeyboardKey {
/// looking for "the key next next to the TAB key", since on a French keyboard,
/// the key next to the TAB key has an "A" on it.
///
/// {@tool sample --template=stateful_widget_scaffold}
/// {@tool dartpad --template=stateful_widget_scaffold}
/// This example shows how to detect if the user has selected the physical key
/// to the right of the CAPS LOCK key.
///
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment