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 key data unpacking code in hooks.dart.
13static constexpr int kKeyDataFieldCount = 5;
14static constexpr int kBytesPerKeyField = sizeof(int64_t);
15
16// The change of the key event, used by KeyData.
17//
18// Must match the KeyEventType enum in ui/key.dart.
19enum class KeyEventType : int64_t {
20 kDown = 0,
21 kUp,
22 kRepeat,
23};
24
25// The fixed-length sections of a KeyDataPacket.
26//
27// KeyData does not contain `character`, for variable-length data are stored in
28// a different way in KeyDataPacket.
29//
30// This structure is unpacked by hooks.dart.
31//
32// Changes to this struct must also be made to
33// io/flutter/embedding/android/KeyData.java.
34struct alignas(8) KeyData {
35 // Timestamp in microseconds from an arbitrary and consistent start point
36 uint64_t timestamp;
37 KeyEventType type;
38 uint64_t physical;
39 uint64_t logical;
40 // True if the event does not correspond to a native event.
41 //
42 // The value is 1 for true, and 0 for false.
43 uint64_t synthesized;
44
45 // Sets all contents of `Keydata` to 0.
46 void Clear();
47};
48
49} // namespace flutter
50
51#endif // FLUTTER_LIB_UI_WINDOW_POINTER_DATA_H_
52

source code of flutter_engine/flutter/lib/ui/window/key_data.h