@@ -38,6 +38,11 @@ Future<String> getAndroidScanCodes() async {
38
38
return utf8.decode (base64.decode (await http.read (scanCodesUri)));
39
39
}
40
40
41
+ Future <String > getGlfwKeyCodes () async {
42
+ final Uri keyCodesUri = Uri .parse ('https://raw.githubusercontent.com/glfw/glfw/master/include/GLFW/glfw3.h' );
43
+ return await http.read (keyCodesUri);
44
+ }
45
+
41
46
Future <void > main (List <String > rawArguments) async {
42
47
final ArgParser argParser = ArgParser ();
43
48
argParser.addOption (
@@ -66,6 +71,19 @@ Future<void> main(List<String> rawArguments) async {
66
71
defaultsTo: path.join (flutterRoot.path, 'dev' , 'tools' , 'gen_keycodes' , 'data' , 'key_name_to_android_name.json' ),
67
72
help: 'The path to where the Android keycode to DomKey mapping is.' ,
68
73
);
74
+ argParser.addOption (
75
+ 'glfw-keycodes' ,
76
+ defaultsTo: null ,
77
+ help: 'The path to where the GLFW keycodes header file should be read. '
78
+ 'If --glfw-keycodes is not specified, the input will be read from the '
79
+ 'correct file in the GLFW github repository.' ,
80
+ );
81
+ argParser.addOption (
82
+ 'glfw-domkey' ,
83
+ defaultsTo: path.join (flutterRoot.path, 'dev' , 'tools' , 'gen_keycodes' , 'data' , 'key_name_to_glfw_name.json' ),
84
+ help: 'The path to where the GLFW keycode to DomKey mapping is.' ,
85
+ );
86
+
69
87
argParser.addOption (
70
88
'data' ,
71
89
defaultsTo: path.join (flutterRoot.path, 'dev' , 'tools' , 'gen_keycodes' , 'data' , 'key_data.json' ),
@@ -136,8 +154,17 @@ Future<void> main(List<String> rawArguments) async {
136
154
androidScanCodes = File (parsedArguments['android-scancodes' ]).readAsStringSync ();
137
155
}
138
156
157
+ String glfwKeyCodes;
158
+ if (parsedArguments['glfw-keycodes' ] == null ) {
159
+ glfwKeyCodes = await getGlfwKeyCodes ();
160
+ } else {
161
+ glfwKeyCodes = File (parsedArguments['glfw-keycodes' ]).readAsStringSync ();
162
+ }
163
+
164
+ final String glfwToDomKey = File (parsedArguments['glfw-domkey' ]).readAsStringSync ();
139
165
final String androidToDomKey = File (parsedArguments['android-domkey' ]).readAsStringSync ();
140
- data = KeyData (hidCodes, androidScanCodes, androidKeyCodes, androidToDomKey);
166
+
167
+ data = KeyData (hidCodes, androidScanCodes, androidKeyCodes, androidToDomKey, glfwKeyCodes, glfwToDomKey);
141
168
142
169
const JsonEncoder encoder = JsonEncoder .withIndent (' ' );
143
170
File (parsedArguments['data' ]).writeAsStringSync (encoder.convert (data.toJson ()));
0 commit comments