Game controller button support (#33868)
This adds support for game controller buttons. It adds some supplemental USB HID codes that aren't available from the Chromium source code, and maps those on Android to the game pad buttons that Android supports. Other platforms are not supported yet.
This commit is contained in:
@@ -36,10 +36,11 @@ class _HardwareKeyDemoState extends State<RawKeyboardDemo> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _handleKeyEvent(RawKeyEvent event) {
|
||||
bool _handleKeyEvent(FocusNode node, RawKeyEvent event) {
|
||||
setState(() {
|
||||
_event = event;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
String _asHex(int value) => value != null ? '0x${value.toRadixString(16)}' : 'null';
|
||||
@@ -53,9 +54,10 @@ class _HardwareKeyDemoState extends State<RawKeyboardDemo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final TextTheme textTheme = Theme.of(context).textTheme;
|
||||
return RawKeyboardListener(
|
||||
return Focus(
|
||||
focusNode: _focusNode,
|
||||
onKey: _handleKeyEvent,
|
||||
autofocus: true,
|
||||
child: AnimatedBuilder(
|
||||
animation: _focusNode,
|
||||
builder: (BuildContext context, Widget child) {
|
||||
@@ -87,6 +89,9 @@ class _HardwareKeyDemoState extends State<RawKeyboardDemo> {
|
||||
dataText.add(Text('keyCode: ${data.keyCode} (${_asHex(data.keyCode)})'));
|
||||
dataText.add(Text('scanCode: ${data.scanCode} (${_asHex(data.scanCode)})'));
|
||||
dataText.add(Text('metaState: ${data.metaState} (${_asHex(data.metaState)})'));
|
||||
dataText.add(Text('source: ${data.eventSource} (${_asHex(data.eventSource)})'));
|
||||
dataText.add(Text('vendorId: ${data.vendorId} (${_asHex(data.vendorId)})'));
|
||||
dataText.add(Text('productId: ${data.productId} (${_asHex(data.productId)})'));
|
||||
dataText.add(Text('flags: ${data.flags} (${_asHex(data.flags)})'));
|
||||
} else if (data is RawKeyEventDataFuchsia) {
|
||||
dataText.add(Text('codePoint: ${data.codePoint} (${_asHex(data.codePoint)})'));
|
||||
@@ -118,7 +123,7 @@ class _HardwareKeyDemoState extends State<RawKeyboardDemo> {
|
||||
}
|
||||
}
|
||||
return DefaultTextStyle(
|
||||
style: textTheme.headline,
|
||||
style: textTheme.subhead,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: dataText,
|
||||
|
||||
@@ -52,6 +52,12 @@ Future<void> main(List<String> rawArguments) async {
|
||||
'read. If --chromium-hid-codes is not specified, the input will be read '
|
||||
'from the correct file in the Chromium repository.',
|
||||
);
|
||||
argParser.addOption(
|
||||
'supplemental-hid-codes',
|
||||
defaultsTo: path.join(flutterRoot.path, 'dev', 'tools', 'gen_keycodes', 'data', 'supplemental_hid_codes.inc'),
|
||||
help: "The path to where the supplemental HID codes that don't appear in the "
|
||||
'Chromium map should be read.',
|
||||
);
|
||||
argParser.addOption(
|
||||
'android-keycodes',
|
||||
defaultsTo: null,
|
||||
@@ -140,6 +146,9 @@ Future<void> main(List<String> rawArguments) async {
|
||||
hidCodes = File(parsedArguments['chromium-hid-codes']).readAsStringSync();
|
||||
}
|
||||
|
||||
final String supplementalHidCodes = File(parsedArguments['supplemental-hid-codes']).readAsStringSync();
|
||||
hidCodes = '$hidCodes\n$supplementalHidCodes';
|
||||
|
||||
String androidKeyCodes;
|
||||
if (parsedArguments['android-keycodes'] == null) {
|
||||
androidKeyCodes = await getAndroidKeyCodes();
|
||||
|
||||
@@ -3794,13 +3794,17 @@
|
||||
"select": {
|
||||
"names": {
|
||||
"domkey": "Select",
|
||||
"android": null,
|
||||
"android": [
|
||||
"DPAD_CENTER"
|
||||
],
|
||||
"english": "Select",
|
||||
"chromium": "select",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": null,
|
||||
"android": [
|
||||
353
|
||||
],
|
||||
"usb": 458871,
|
||||
"linux": 132,
|
||||
"xkb": 140,
|
||||
@@ -3808,7 +3812,9 @@
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": null,
|
||||
"android": [
|
||||
23
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
@@ -6355,5 +6361,858 @@
|
||||
"android": null,
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton1": {
|
||||
"names": {
|
||||
"domkey": "GameButton1",
|
||||
"android": [
|
||||
"BUTTON_1"
|
||||
],
|
||||
"english": "Game Button 1",
|
||||
"chromium": "button1",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
256,
|
||||
288
|
||||
],
|
||||
"usb": 341761,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
188
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton2": {
|
||||
"names": {
|
||||
"domkey": "GameButton2",
|
||||
"android": [
|
||||
"BUTTON_2"
|
||||
],
|
||||
"english": "Game Button 2",
|
||||
"chromium": "button2",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
257,
|
||||
289
|
||||
],
|
||||
"usb": 341762,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
189
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton3": {
|
||||
"names": {
|
||||
"domkey": "GameButton3",
|
||||
"android": [
|
||||
"BUTTON_3"
|
||||
],
|
||||
"english": "Game Button 3",
|
||||
"chromium": "button3",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
258,
|
||||
290
|
||||
],
|
||||
"usb": 341763,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
190
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton4": {
|
||||
"names": {
|
||||
"domkey": "GameButton4",
|
||||
"android": [
|
||||
"BUTTON_4"
|
||||
],
|
||||
"english": "Game Button 4",
|
||||
"chromium": "button4",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
259,
|
||||
291
|
||||
],
|
||||
"usb": 341764,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
191
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton5": {
|
||||
"names": {
|
||||
"domkey": "GameButton5",
|
||||
"android": [
|
||||
"BUTTON_5"
|
||||
],
|
||||
"english": "Game Button 5",
|
||||
"chromium": "button5",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
260,
|
||||
292
|
||||
],
|
||||
"usb": 341765,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
192
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton6": {
|
||||
"names": {
|
||||
"domkey": "GameButton6",
|
||||
"android": [
|
||||
"BUTTON_6"
|
||||
],
|
||||
"english": "Game Button 6",
|
||||
"chromium": "button6",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
261,
|
||||
293
|
||||
],
|
||||
"usb": 341766,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
193
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton7": {
|
||||
"names": {
|
||||
"domkey": "GameButton7",
|
||||
"android": [
|
||||
"BUTTON_7"
|
||||
],
|
||||
"english": "Game Button 7",
|
||||
"chromium": "button7",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
262,
|
||||
294
|
||||
],
|
||||
"usb": 341767,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
194
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton8": {
|
||||
"names": {
|
||||
"domkey": "GameButton8",
|
||||
"android": [
|
||||
"BUTTON_8"
|
||||
],
|
||||
"english": "Game Button 8",
|
||||
"chromium": "button8",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
263,
|
||||
295
|
||||
],
|
||||
"usb": 341768,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
195
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton9": {
|
||||
"names": {
|
||||
"domkey": "GameButton9",
|
||||
"android": [
|
||||
"BUTTON_9"
|
||||
],
|
||||
"english": "Game Button 9",
|
||||
"chromium": "button9",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
264,
|
||||
296
|
||||
],
|
||||
"usb": 341769,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
196
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton10": {
|
||||
"names": {
|
||||
"domkey": "GameButton10",
|
||||
"android": [
|
||||
"BUTTON_10"
|
||||
],
|
||||
"english": "Game Button 10",
|
||||
"chromium": "button10",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
265,
|
||||
297
|
||||
],
|
||||
"usb": 341770,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
197
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton11": {
|
||||
"names": {
|
||||
"domkey": "GameButton11",
|
||||
"android": [
|
||||
"BUTTON_11"
|
||||
],
|
||||
"english": "Game Button 11",
|
||||
"chromium": "button11",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
266,
|
||||
298
|
||||
],
|
||||
"usb": 341771,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
198
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton12": {
|
||||
"names": {
|
||||
"domkey": "GameButton12",
|
||||
"android": [
|
||||
"BUTTON_12"
|
||||
],
|
||||
"english": "Game Button 12",
|
||||
"chromium": "button12",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
267,
|
||||
299
|
||||
],
|
||||
"usb": 341772,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
199
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton13": {
|
||||
"names": {
|
||||
"domkey": "GameButton13",
|
||||
"android": [
|
||||
"BUTTON_13"
|
||||
],
|
||||
"english": "Game Button 13",
|
||||
"chromium": "button13",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
268,
|
||||
300
|
||||
],
|
||||
"usb": 341773,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
200
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton14": {
|
||||
"names": {
|
||||
"domkey": "GameButton14",
|
||||
"android": [
|
||||
"BUTTON_14"
|
||||
],
|
||||
"english": "Game Button 14",
|
||||
"chromium": "button14",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
269,
|
||||
301
|
||||
],
|
||||
"usb": 341774,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
201
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton15": {
|
||||
"names": {
|
||||
"domkey": "GameButton15",
|
||||
"android": [
|
||||
"BUTTON_15"
|
||||
],
|
||||
"english": "Game Button 15",
|
||||
"chromium": "button15",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
270,
|
||||
302
|
||||
],
|
||||
"usb": 341775,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
202
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButton16": {
|
||||
"names": {
|
||||
"domkey": "GameButton16",
|
||||
"android": [
|
||||
"BUTTON_16"
|
||||
],
|
||||
"english": "Game Button 16",
|
||||
"chromium": "button16",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
271,
|
||||
303
|
||||
],
|
||||
"usb": 341776,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
203
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButtonA": {
|
||||
"names": {
|
||||
"domkey": "GameButtonA",
|
||||
"android": [
|
||||
"BUTTON_A"
|
||||
],
|
||||
"english": "Game Button A",
|
||||
"chromium": "buttonA",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
304
|
||||
],
|
||||
"usb": 341777,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
96
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButtonB": {
|
||||
"names": {
|
||||
"domkey": "GameButtonB",
|
||||
"android": [
|
||||
"BUTTON_B"
|
||||
],
|
||||
"english": "Game Button B",
|
||||
"chromium": "buttonB",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
305
|
||||
],
|
||||
"usb": 341778,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
97
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButtonC": {
|
||||
"names": {
|
||||
"domkey": "GameButtonC",
|
||||
"android": [
|
||||
"BUTTON_C"
|
||||
],
|
||||
"english": "Game Button C",
|
||||
"chromium": "buttonC",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
306
|
||||
],
|
||||
"usb": 341779,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
98
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButtonLeft1": {
|
||||
"names": {
|
||||
"domkey": "GameButtonLeft1",
|
||||
"android": [
|
||||
"BUTTON_L1"
|
||||
],
|
||||
"english": "Game Button Left 1",
|
||||
"chromium": "buttonL1",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
310
|
||||
],
|
||||
"usb": 341780,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
102
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButtonLeft2": {
|
||||
"names": {
|
||||
"domkey": "GameButtonLeft2",
|
||||
"android": [
|
||||
"BUTTON_L2"
|
||||
],
|
||||
"english": "Game Button Left 2",
|
||||
"chromium": "buttonL2",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
312
|
||||
],
|
||||
"usb": 341781,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
104
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButtonMode": {
|
||||
"names": {
|
||||
"domkey": "GameButtonMode",
|
||||
"android": [
|
||||
"BUTTON_MODE"
|
||||
],
|
||||
"english": "Game Button Mode",
|
||||
"chromium": "buttonMode",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
316
|
||||
],
|
||||
"usb": 341782,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
110
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButtonRight1": {
|
||||
"names": {
|
||||
"domkey": "GameButtonRight1",
|
||||
"android": [
|
||||
"BUTTON_R1"
|
||||
],
|
||||
"english": "Game Button Right 1",
|
||||
"chromium": "buttonR1",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
311
|
||||
],
|
||||
"usb": 341783,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
103
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButtonRight2": {
|
||||
"names": {
|
||||
"domkey": "GameButtonRight2",
|
||||
"android": [
|
||||
"BUTTON_R2"
|
||||
],
|
||||
"english": "Game Button Right 2",
|
||||
"chromium": "buttonR2",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
313
|
||||
],
|
||||
"usb": 341784,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
105
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButtonSelect": {
|
||||
"names": {
|
||||
"domkey": "GameButtonSelect",
|
||||
"android": [
|
||||
"BUTTON_SELECT"
|
||||
],
|
||||
"english": "Game Button Select",
|
||||
"chromium": "buttonSelect",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
314
|
||||
],
|
||||
"usb": 341785,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
109
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButtonStart": {
|
||||
"names": {
|
||||
"domkey": "GameButtonStart",
|
||||
"android": [
|
||||
"BUTTON_START"
|
||||
],
|
||||
"english": "Game Button Start",
|
||||
"chromium": "buttonStart",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
315
|
||||
],
|
||||
"usb": 341786,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
108
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButtonThumbLeft": {
|
||||
"names": {
|
||||
"domkey": "GameButtonThumbLeft",
|
||||
"android": [
|
||||
"BUTTON_THUMBL"
|
||||
],
|
||||
"english": "Game Button Thumb Left",
|
||||
"chromium": "buttonThumbl",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
317
|
||||
],
|
||||
"usb": 341787,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
106
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButtonThumbRight": {
|
||||
"names": {
|
||||
"domkey": "GameButtonThumbRight",
|
||||
"android": [
|
||||
"BUTTON_THUMBR"
|
||||
],
|
||||
"english": "Game Button Thumb Right",
|
||||
"chromium": "buttonThumbr",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
318
|
||||
],
|
||||
"usb": 341788,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
107
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButtonX": {
|
||||
"names": {
|
||||
"domkey": "GameButtonX",
|
||||
"android": [
|
||||
"BUTTON_X"
|
||||
],
|
||||
"english": "Game Button X",
|
||||
"chromium": "buttonX",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
307
|
||||
],
|
||||
"usb": 341789,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
99
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButtonY": {
|
||||
"names": {
|
||||
"domkey": "GameButtonY",
|
||||
"android": [
|
||||
"BUTTON_Y"
|
||||
],
|
||||
"english": "Game Button Y",
|
||||
"chromium": "buttonY",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
308
|
||||
],
|
||||
"usb": 341790,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
100
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
},
|
||||
"gameButtonZ": {
|
||||
"names": {
|
||||
"domkey": "GameButtonZ",
|
||||
"android": [
|
||||
"BUTTON_Z"
|
||||
],
|
||||
"english": "Game Button Z",
|
||||
"chromium": "buttonZ",
|
||||
"glfw": null
|
||||
},
|
||||
"scanCodes": {
|
||||
"android": [
|
||||
309
|
||||
],
|
||||
"usb": 341791,
|
||||
"linux": null,
|
||||
"xkb": null,
|
||||
"windows": null,
|
||||
"macos": null
|
||||
},
|
||||
"keyCodes": {
|
||||
"android": [
|
||||
101
|
||||
],
|
||||
"glfw": null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,37 @@
|
||||
"f24": ["F24"],
|
||||
"find": ["FIND"],
|
||||
"fn": ["FUNCTION"],
|
||||
"gameButton1": ["BUTTON_1"],
|
||||
"gameButton2": ["BUTTON_2"],
|
||||
"gameButton3": ["BUTTON_3"],
|
||||
"gameButton4": ["BUTTON_4"],
|
||||
"gameButton5": ["BUTTON_5"],
|
||||
"gameButton6": ["BUTTON_6"],
|
||||
"gameButton7": ["BUTTON_7"],
|
||||
"gameButton8": ["BUTTON_8"],
|
||||
"gameButton9": ["BUTTON_9"],
|
||||
"gameButton10": ["BUTTON_10"],
|
||||
"gameButton11": ["BUTTON_11"],
|
||||
"gameButton12": ["BUTTON_12"],
|
||||
"gameButton13": ["BUTTON_13"],
|
||||
"gameButton14": ["BUTTON_14"],
|
||||
"gameButton15": ["BUTTON_15"],
|
||||
"gameButton16": ["BUTTON_16"],
|
||||
"gameButtonA": ["BUTTON_A"],
|
||||
"gameButtonB": ["BUTTON_B"],
|
||||
"gameButtonC": ["BUTTON_C"],
|
||||
"gameButtonLeft1": ["BUTTON_L1"],
|
||||
"gameButtonLeft2": ["BUTTON_L2"],
|
||||
"gameButtonMode": ["BUTTON_MODE"],
|
||||
"gameButtonRight1": ["BUTTON_R1"],
|
||||
"gameButtonRight2": ["BUTTON_R2"],
|
||||
"gameButtonSelect": ["BUTTON_SELECT"],
|
||||
"gameButtonStart": ["BUTTON_START"],
|
||||
"gameButtonThumbLeft": ["BUTTON_THUMBL"],
|
||||
"gameButtonThumbRight": ["BUTTON_THUMBR"],
|
||||
"gameButtonX": ["BUTTON_X"],
|
||||
"gameButtonY": ["BUTTON_Y"],
|
||||
"gameButtonZ": ["BUTTON_Z"],
|
||||
"goBack": ["BACK"],
|
||||
"goHome": ["HOME"],
|
||||
"groupNext": ["LANGUAGE_SWITCH"],
|
||||
@@ -200,6 +231,7 @@
|
||||
"quote": ["APOSTROPHE"],
|
||||
"redo": ["REDO"],
|
||||
"scrollLock": ["SCROLL_LOCK"],
|
||||
"select": ["DPAD_CENTER"],
|
||||
"semicolon": ["SEMICOLON"],
|
||||
"settings": ["SETTINGS"],
|
||||
"shiftLeft": ["SHIFT_LEFT"],
|
||||
|
||||
45
dev/tools/gen_keycodes/data/supplemental_hid_codes.inc
Normal file
45
dev/tools/gen_keycodes/data/supplemental_hid_codes.inc
Normal file
@@ -0,0 +1,45 @@
|
||||
// These are supplemental key codes to be added to those that Chromium
|
||||
// defines. Since the web doesn't have game controller buttons defined in the
|
||||
// same way, these map USB HID codes for game controller buttons to
|
||||
// Android/Linux button names.
|
||||
//
|
||||
// The HID codes here are not real USB HID codes, because the USB HID standard
|
||||
// doesn't define game controller buttons in this way. It defines only two
|
||||
// button "collections" (fire/jump and trigger), with the button number for
|
||||
// each collection sent as extra data. Since we're just using USB HID as a
|
||||
// convenient namespace, and not using these HID codes for interfacing with a
|
||||
// USB protocol, we can define new ones to enumerate the buttons. These don't
|
||||
// collide with any currently defined HID codes.
|
||||
//
|
||||
// USB HID evdev XKB Win Mac DOMKey Code
|
||||
USB_KEYMAP(0x05ff01, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton1", BUTTON_1),
|
||||
USB_KEYMAP(0x05ff02, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton2", BUTTON_2),
|
||||
USB_KEYMAP(0x05ff03, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton3", BUTTON_3),
|
||||
USB_KEYMAP(0x05ff04, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton4", BUTTON_4),
|
||||
USB_KEYMAP(0x05ff05, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton5", BUTTON_5),
|
||||
USB_KEYMAP(0x05ff06, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton6", BUTTON_6),
|
||||
USB_KEYMAP(0x05ff07, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton7", BUTTON_7),
|
||||
USB_KEYMAP(0x05ff08, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton8", BUTTON_8),
|
||||
USB_KEYMAP(0x05ff09, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton9", BUTTON_9),
|
||||
USB_KEYMAP(0x05ff0a, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton10", BUTTON_10),
|
||||
USB_KEYMAP(0x05ff0b, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton11", BUTTON_11),
|
||||
USB_KEYMAP(0x05ff0c, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton12", BUTTON_12),
|
||||
USB_KEYMAP(0x05ff0d, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton13", BUTTON_13),
|
||||
USB_KEYMAP(0x05ff0e, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton14", BUTTON_14),
|
||||
USB_KEYMAP(0x05ff0f, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton15", BUTTON_15),
|
||||
USB_KEYMAP(0x05ff10, 0x0000, 0x0000, 0x0000, 0xffff, "GameButton16", BUTTON_16),
|
||||
USB_KEYMAP(0x05ff11, 0x0000, 0x0000, 0x0000, 0xffff, "GameButtonA", BUTTON_A),
|
||||
USB_KEYMAP(0x05ff12, 0x0000, 0x0000, 0x0000, 0xffff, "GameButtonB", BUTTON_B),
|
||||
USB_KEYMAP(0x05ff13, 0x0000, 0x0000, 0x0000, 0xffff, "GameButtonC", BUTTON_C),
|
||||
USB_KEYMAP(0x05ff14, 0x0000, 0x0000, 0x0000, 0xffff, "GameButtonLeft1", BUTTON_L1),
|
||||
USB_KEYMAP(0x05ff15, 0x0000, 0x0000, 0x0000, 0xffff, "GameButtonLeft2", BUTTON_L2),
|
||||
USB_KEYMAP(0x05ff16, 0x0000, 0x0000, 0x0000, 0xffff, "GameButtonMode", BUTTON_MODE),
|
||||
USB_KEYMAP(0x05ff17, 0x0000, 0x0000, 0x0000, 0xffff, "GameButtonRight1", BUTTON_R1),
|
||||
USB_KEYMAP(0x05ff18, 0x0000, 0x0000, 0x0000, 0xffff, "GameButtonRight2", BUTTON_R2),
|
||||
USB_KEYMAP(0x05ff19, 0x0000, 0x0000, 0x0000, 0xffff, "GameButtonSelect", BUTTON_SELECT),
|
||||
USB_KEYMAP(0x05ff1a, 0x0000, 0x0000, 0x0000, 0xffff, "GameButtonStart", BUTTON_START),
|
||||
USB_KEYMAP(0x05ff1b, 0x0000, 0x0000, 0x0000, 0xffff, "GameButtonThumbLeft", BUTTON_THUMBL),
|
||||
USB_KEYMAP(0x05ff1c, 0x0000, 0x0000, 0x0000, 0xffff, "GameButtonThumbRight", BUTTON_THUMBR),
|
||||
USB_KEYMAP(0x05ff1d, 0x0000, 0x0000, 0x0000, 0xffff, "GameButtonX", BUTTON_X),
|
||||
USB_KEYMAP(0x05ff1e, 0x0000, 0x0000, 0x0000, 0xffff, "GameButtonY", BUTTON_Y),
|
||||
USB_KEYMAP(0x05ff1f, 0x0000, 0x0000, 0x0000, 0xffff, "GameButtonZ", BUTTON_Z),
|
||||
@@ -375,7 +375,7 @@ class Key {
|
||||
|
||||
static String getCommentName(String constantName) {
|
||||
String upperCamel = lowerCamelToUpperCamel(constantName);
|
||||
upperCamel = upperCamel.replaceAllMapped(RegExp(r'(Digit|Numpad|Lang)([0-9]+)'), (Match match) => '${match.group(1)} ${match.group(2)}');
|
||||
upperCamel = upperCamel.replaceAllMapped(RegExp(r'(Digit|Numpad|Lang|Button|Left|Right)([0-9]+)'), (Match match) => '${match.group(1)} ${match.group(2)}');
|
||||
return upperCamel.replaceAllMapped(RegExp(r'([A-Z])'), (Match match) => ' ${match.group(1)}').trim();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user