Flutter Engine
The Flutter Engine
key_data.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_LIB_UI_WINDOW_KEY_DATA_H_
6#define FLUTTER_LIB_UI_WINDOW_KEY_DATA_H_
7
8#include <cstdint>
9
10namespace flutter {
11
12// If this value changes, update the encoding code in the following files:
13//
14// * KeyData.java (KeyData.FIELD_COUNT)
15// * platform_dispatcher.dart (_kKeyDataFieldCount)
16static constexpr int kKeyDataFieldCount = 6;
17static constexpr int kBytesPerKeyField = sizeof(int64_t);
18
19// The change of the key event, used by KeyData.
20//
21// Must match the KeyEventType enum in ui/key.dart.
22enum class KeyEventType : int64_t {
23 kDown = 0,
24 kUp,
25 kRepeat,
26};
27
28// The source device for the key event.
29//
30// Not all platforms supply an accurate source.
31//
32// Defaults to [keyboard].
33// Must match the KeyEventDeviceType enum in ui/key.dart.
34enum class KeyEventDeviceType : int64_t {
35 // The source is a keyboard.
36 kKeyboard = 0,
37
38 // The source is a directional pad on something like a television remote
39 // control or similar.
41
42 // The source is a gamepad button.
44
45 // The source is a joystick button.
47
48 // The source is a device connected to an HDMI bus.
49 kHdmi,
50};
51
52// The fixed-length sections of a KeyDataPacket.
53//
54// KeyData does not contain `character`, for variable-length data are stored in
55// a different way in KeyDataPacket.
56//
57// This structure is unpacked by hooks.dart.
58//
59// Changes to this struct must also be made to
60// io/flutter/embedding/android/KeyData.java.
61struct alignas(8) KeyData {
62 // Timestamp in microseconds from an arbitrary and consistent start point
63 uint64_t timestamp;
65 uint64_t physical;
66 uint64_t logical;
67 // True if the event does not correspond to a native event.
68 //
69 // The value is 1 for true, and 0 for false.
70 uint64_t synthesized;
72
73 // Sets all contents of `Keydata` to 0.
74 void Clear();
75};
76
77} // namespace flutter
78
79#endif // FLUTTER_LIB_UI_WINDOW_KEY_DATA_H_
@ kUp
Definition: embedder.h:973
@ kDown
Definition: embedder.h:980
static constexpr int kBytesPerKeyField
Definition: key_data.h:17
KeyEventType
Definition: key_data.h:22
KeyEventDeviceType
Definition: key_data.h:34
static constexpr int kKeyDataFieldCount
Definition: key_data.h:16
uint64_t synthesized
Definition: key_data.h:70
KeyEventDeviceType device_type
Definition: key_data.h:71
uint64_t logical
Definition: key_data.h:66
uint64_t physical
Definition: key_data.h:65
KeyEventType type
Definition: key_data.h:64
uint64_t timestamp
Definition: key_data.h:63