Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
key_data_packet.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_PACKET_H_
6#define FLUTTER_LIB_UI_WINDOW_KEY_DATA_PACKET_H_
7
8#include <functional>
9#include <vector>
10
11#include "flutter/fml/macros.h"
12#include "flutter/lib/ui/window/key_data.h"
13
14namespace flutter {
15
16// A byte stream representing a key event, to be sent to the framework.
17//
18// Changes to the marshalling format here must also be made to
19// io/flutter/embedding/android/KeyData.java.
21 public:
22 // Build the key data packet by providing information.
23 //
24 // The `character` is a nullable C-string that ends with a '\0'.
25 KeyDataPacket(const KeyData& event, const char* character);
27
28 // Prevent copying.
29 KeyDataPacket(KeyDataPacket const&) = delete;
31
32 const std::vector<uint8_t>& data() const { return data_; }
33
34 private:
35 // Packet structure:
36 // | CharDataSize | (1 field)
37 // | Key Data | (kKeyDataFieldCount fields)
38 // | CharData | (CharDataSize bits)
39
40 uint8_t* CharacterSizeStart() { return data_.data(); }
41 uint8_t* KeyDataStart() { return CharacterSizeStart() + sizeof(uint64_t); }
42 uint8_t* CharacterStart() { return KeyDataStart() + sizeof(KeyData); }
43
44 std::vector<uint8_t> data_;
45};
46
47} // namespace flutter
48
49#endif // FLUTTER_LIB_UI_WINDOW_KEY_DATA_PACKET_H_
KeyDataPacket & operator=(KeyDataPacket const &)=delete
KeyDataPacket(KeyDataPacket const &)=delete
const std::vector< uint8_t > & data() const
FlKeyEvent * event