| Flutter Windows Embedder |

Public Member Functions | List of all members
flutter::KeyboardKeyChannelHandler Class Reference

`#include <keyboard_key_channel_handler.h>`

Inheritance diagram for flutter::KeyboardKeyChannelHandler:

## Public Member Functions
| KeyboardKeyChannelHandler (flutter::BinaryMessenger *messenger)
| ~KeyboardKeyChannelHandler ()
void | KeyboardHook (int key, int scancode, int action, char32_t character, bool extended, bool was_down, std::function< void(bool)> callback)
void | SyncModifiersIfNeeded (int modifiers_state)
std::map< uint64_t, uint64_t > | GetPressedState ()
Public Member Functions inherited from flutter::KeyboardKeyHandler::KeyboardKeyHandlerDelegate
virtual | ~KeyboardKeyHandlerDelegate ()

## Detailed Description

Definition at line 24 of file keyboard_key_channel_handler.h.

## Constructor & Destructor Documentation

## ◆ KeyboardKeyChannelHandler()

flutter::KeyboardKeyChannelHandler::KeyboardKeyChannelHandler | ( | flutter::BinaryMessenger * | messenger | ) |
| explicit

Definition at line 102 of file keyboard_key_channel_handler.cc.

104 : channel_(
105 std::make_unique<flutter::BasicMessageChannel<rapidjson::Document>>(
106 messenger,
107 kChannelName,
108 &flutter::JsonMessageCodec::GetInstance())) {}
flutter::BasicMessageChannel
Definition: basic_message_channel.h:56
flutter::JsonMessageCodec::GetInstance
static const JsonMessageCodec & GetInstance()
Definition: json_message_codec.cc:17
kChannelName
static constexpr char kChannelName[]
Definition: cursor_handler.cc:13

## ◆ ~KeyboardKeyChannelHandler()

flutter::KeyboardKeyChannelHandler::~KeyboardKeyChannelHandler | ( |  | ) |
| default

## Member Function Documentation

## ◆ GetPressedState()

std::map< uint64_t, uint64_t > flutter::KeyboardKeyChannelHandler::GetPressedState | ( |  | ) |
| virtual

Implements flutter::KeyboardKeyHandler::KeyboardKeyHandlerDelegate.

Definition at line 116 of file keyboard_key_channel_handler.cc.

116 {
117 // Returns an empty state because it will never be called.
118 // KeyboardKeyEmbedderHandler is the only KeyboardKeyHandlerDelegate to handle
119 // GetPressedState() calls.
120 std::map<uint64_t, uint64_t> empty_state;
121 return empty_state;
122 }

## ◆ KeyboardHook()

void flutter::KeyboardKeyChannelHandler::KeyboardHook | ( | int | key,
|  | int | scancode,
|  | int | action,
|  | char32_t | character,
|  | bool | extended,
|  | bool | was_down,
|  | std::function< void(bool)> | callback
| ) |  |
| virtual

Implements flutter::KeyboardKeyHandler::KeyboardKeyHandlerDelegate.

Definition at line 124 of file keyboard_key_channel_handler.cc.

131 {
132 // TODO: Translate to a cross-platform key code system rather than passing
133 // the native key code.
134 rapidjson::Document event(rapidjson::kObjectType);
135 auto& allocator = event.GetAllocator();
136 event.AddMember(kKeyCodeKey, key, allocator);
137 event.AddMember(kScanCodeKey, scancode | (extended ? kScancodeExtended : 0),
138 allocator);
139 event.AddMember(kCharacterCodePointKey, UndeadChar(character), allocator);
140 event.AddMember(kKeyMapKey, kWindowsKeyMap, allocator);
141 event.AddMember(kModifiersKey, GetModsForKeyState(), allocator);
142
143 switch (action) {
144 case WM_SYSKEYDOWN:
145 case WM_KEYDOWN:
146 event.AddMember(kTypeKey, kKeyDown, allocator);
147 break;
148 case WM_SYSKEYUP:
149 case WM_KEYUP:
150 event.AddMember(kTypeKey, kKeyUp, allocator);
151 break;
152 default:
153 FML_LOG(WARNING) << "Unknown key event action: " << action;
154 callback(false);
155 return;
156 }
157 channel_->Send(event, [callback = std::move(callback)](const uint8_t* reply,
158 size_t reply_size) {
159 auto decoded = flutter::JsonMessageCodec::GetInstance().DecodeMessage(
160 reply, reply_size);
161 bool handled = decoded ? (*decoded)[kHandledKey].GetBool() : false;
162 callback(handled);
163 });
164 }
flutter::MessageCodec::DecodeMessage
std::unique_ptr< T > DecodeMessage(const uint8_t *binary_message, const size_t message_size) const
Definition: message_codec.h:29
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:52
extended
bool extended
Definition: keyboard_key_handler_unittests.cc:118
key
int key
Definition: keyboard_key_handler_unittests.cc:114
character
char32_t character
Definition: keyboard_key_handler_unittests.cc:117
action
int action
Definition: keyboard_key_handler_unittests.cc:116
scancode
int scancode
Definition: keyboard_key_handler_unittests.cc:115
flutter::UndeadChar
uint32_t UndeadChar(uint32_t ch)
Definition: keyboard_utils.h:34

References action, callback, character, flutter::MessageCodec< T >::DecodeMessage(), extended, flutter::JsonMessageCodec::GetInstance(), key, scancode, and flutter::UndeadChar().

## ◆ SyncModifiersIfNeeded()

void flutter::KeyboardKeyChannelHandler::SyncModifiersIfNeeded | ( | int | modifiers_state | ) |
| virtual

Implements flutter::KeyboardKeyHandler::KeyboardKeyHandlerDelegate.

Definition at line 112 of file keyboard_key_channel_handler.cc.

112 {
113 // Do nothing.
114 }

The documentation for this class was generated from the following files:

- shell/platform/windows/keyboard_key_channel_handler.h
- shell/platform/windows/keyboard_key_channel_handler.cc