Update raw keyboard example (#6871)
We now center the body correctly and handle Fuchsia key events. Also, add support for modifiers.
This commit is contained in:
@@ -70,6 +70,7 @@ class RawKeyEventDataFuchsia extends RawKeyEventData {
|
||||
const RawKeyEventDataFuchsia({
|
||||
this.hidUsage: 0,
|
||||
this.codePoint: 0,
|
||||
this.modifiers: 0,
|
||||
});
|
||||
|
||||
/// The USB HID usage.
|
||||
@@ -81,6 +82,12 @@ class RawKeyEventDataFuchsia extends RawKeyEventData {
|
||||
///
|
||||
/// If there is no unicode code point, this value is zero.
|
||||
final int codePoint;
|
||||
|
||||
/// The modifiers that we present when the key event occured.
|
||||
///
|
||||
/// See <https://fuchsia.googlesource.com/mozart/+/master/services/input/input_event_constants.fidl>
|
||||
/// for the numerical values of the modifiers.
|
||||
final int modifiers;
|
||||
}
|
||||
|
||||
/// Base class for raw key events.
|
||||
@@ -138,6 +145,7 @@ RawKeyEvent _toRawKeyEvent(Map<String, dynamic> message) {
|
||||
data = new RawKeyEventDataFuchsia(
|
||||
hidUsage: message['hidUsage'] ?? 0,
|
||||
codePoint: message['codePoint'] ?? 0,
|
||||
modifiers: message['modifiers'] ?? 0,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -38,6 +38,7 @@ void main() {
|
||||
'keymap': 'fuchsia',
|
||||
'hidUsage': 0x04,
|
||||
'codePoint': 0x64,
|
||||
'modifiers': 0x08,
|
||||
});
|
||||
|
||||
await tester.idle();
|
||||
@@ -48,5 +49,6 @@ void main() {
|
||||
RawKeyEventDataFuchsia typedData = events[0].data;
|
||||
expect(typedData.hidUsage, 0x04);
|
||||
expect(typedData.codePoint, 0x64);
|
||||
expect(typedData.modifiers, 0x08);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user