Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
flutter::KeyboardKeyChannelHandler Class Reference

#include <keyboard_key_channel_handler.h>

Inheritance diagram for flutter::KeyboardKeyChannelHandler:
flutter::KeyboardKeyHandler::KeyboardKeyHandlerDelegate

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_(
106 messenger,
static NSString *const kChannelName
static const JsonMessageCodec & GetInstance()

◆ ~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) {
160 reply, reply_size);
161 bool handled = decoded ? (*decoded)[kHandledKey].GetBool() : false;
162 callback(handled);
163 });
164}
std::unique_ptr< T > DecodeMessage(const uint8_t *binary_message, const size_t message_size) const
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
FlKeyEvent * event
#define FML_LOG(severity)
Definition logging.h:82
static constexpr char kScanCodeKey[]
static constexpr char kKeyMapKey[]
static constexpr char kKeyDown[]
static constexpr char kKeyUp[]
static constexpr char kModifiersKey[]
static constexpr char kKeyCodeKey[]
constexpr char kTypeKey[]
Definition shell.cc:50
uint32_t UndeadChar(uint32_t ch)

◆ 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: