| Flutter Windows Embedder |

keyboard_key_channel_handler.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_SHELL_PLATFORM_WINDOWS_KEYBOARD_KEY_CHANNEL_HANDLER_H_
6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_KEYBOARD_KEY_CHANNEL_HANDLER_H_
7
8 #include <deque>
9 #include <memory>
10 #include <string>
11
12 #include "flutter/fml/macros.h"
13 #include "flutter/shell/platform/common/client_wrapper/include/flutter/basic_message_channel.h"
14 #include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h"
15 #include "flutter/shell/platform/windows/keyboard_key_handler.h"
16 #include "rapidjson/document.h"
17
18 namespace flutter {
19
20 // A delegate of |KeyboardKeyHandler| that handles events by sending the
21 // raw information through the method channel.
22 //
23 // This class communicates with the RawKeyboard API in the framework.
24 class KeyboardKeyChannelHandler
25 : public KeyboardKeyHandler::KeyboardKeyHandlerDelegate {
26 public:
27 // Create a |KeyboardKeyChannelHandler| by specifying the messenger
28 // through which the events are sent.
29 explicit KeyboardKeyChannelHandler(flutter::BinaryMessenger* messenger);
30
31 ~KeyboardKeyChannelHandler();
32
33 // |KeyboardKeyHandler::KeyboardKeyHandlerDelegate|
34 void KeyboardHook(int key,
35 int scancode,
36 int action,
37 char32_t character,
38 bool extended,
39 bool was_down,
40 std::function<void(bool)> callback);
41
42 void SyncModifiersIfNeeded(int modifiers_state);
43
44 std::map<uint64_t, uint64_t> GetPressedState();
45
46 private:
47 // The Flutter system channel for key event messages.
48 std::unique_ptr<flutter::BasicMessageChannel<rapidjson::Document>> channel_;
49
50 FML_DISALLOW_COPY_AND_ASSIGN(KeyboardKeyChannelHandler);
51 };
52
53 } // namespace flutter
54
55 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_KEYBOARD_KEY_CHANNEL_HANDLER_H_
flutter::KeyboardKeyChannelHandler::KeyboardHook
void KeyboardHook(int key, int scancode, int action, char32_t character, bool extended, bool was_down, std::function< void(bool)> callback)
Definition: keyboard_key_channel_handler.cc:124
scancode
int scancode
Definition: keyboard_key_handler_unittests.cc:115
was_down
bool was_down
Definition: keyboard_key_handler_unittests.cc:119
extended
bool extended
Definition: keyboard_key_handler_unittests.cc:118
character
char32_t character
Definition: keyboard_key_handler_unittests.cc:117
binary_messenger.h
flutter::KeyboardKeyHandler::KeyboardKeyHandlerDelegate
Definition: keyboard_key_handler.h:39
flutter::KeyboardKeyChannelHandler::GetPressedState
std::map< uint64_t, uint64_t > GetPressedState()
Definition: keyboard_key_channel_handler.cc:116
flutter::BinaryMessenger
Definition: binary_messenger.h:28
flutter::KeyboardKeyChannelHandler::KeyboardKeyChannelHandler
KeyboardKeyChannelHandler(flutter::BinaryMessenger *messenger)
Definition: keyboard_key_channel_handler.cc:102
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::KeyboardKeyChannelHandler
Definition: keyboard_key_channel_handler.h:24
basic_message_channel.h
flutter::KeyboardKeyChannelHandler::SyncModifiersIfNeeded
void SyncModifiersIfNeeded(int modifiers_state)
Definition: keyboard_key_channel_handler.cc:112
keyboard_key_handler.h
flutter::KeyboardKeyChannelHandler::~KeyboardKeyChannelHandler
~KeyboardKeyChannelHandler()
action
int action
Definition: keyboard_key_handler_unittests.cc:116
key
int key
Definition: keyboard_key_handler_unittests.cc:114
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:52