| Flutter Windows Embedder |

Classes | Public Types | Public Member Functions | List of all members
flutter::KeyboardKeyEmbedderHandler Class Reference

`#include <keyboard_key_embedder_handler.h>`

Inheritance diagram for flutter::KeyboardKeyEmbedderHandler:

## Public Types
using | SendEventHandler = std::function< void(const FlutterKeyEvent &, FlutterKeyEventCallback, void *)>
using | GetKeyStateHandler = std::function< SHORT(int)>
using | MapVirtualKeyToScanCode = std::function< SHORT(UINT, bool)>

## Public Member Functions
| KeyboardKeyEmbedderHandler (SendEventHandler send_event, GetKeyStateHandler get_key_state, MapVirtualKeyToScanCode map_vk_to_scan)
virtual | ~KeyboardKeyEmbedderHandler ()
void | KeyboardHook (int key, int scancode, int action, char32_t character, bool extended, bool was_down, std::function< void(bool)> callback) override
void | SyncModifiersIfNeeded (int modifiers_state) override
std::map< uint64_t, uint64_t > | GetPressedState () override
Public Member Functions inherited from flutter::KeyboardKeyHandler::KeyboardKeyHandlerDelegate
virtual | ~KeyboardKeyHandlerDelegate ()

## Detailed Description

Definition at line 34 of file keyboard_key_embedder_handler.h.

## Member Typedef Documentation

## ◆ GetKeyStateHandler

using flutter::KeyboardKeyEmbedderHandler::GetKeyStateHandler = std::function<SHORT(int )>

Definition at line 41 of file keyboard_key_embedder_handler.h.

## ◆ MapVirtualKeyToScanCode

using flutter::KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode = std::function<SHORT(UINT , bool )>

Definition at line 42 of file keyboard_key_embedder_handler.h.

## ◆ SendEventHandler

using flutter::KeyboardKeyEmbedderHandler::SendEventHandler = std::function<void(const FlutterKeyEvent& , FlutterKeyEventCallback , void* )>

Definition at line 37 of file keyboard_key_embedder_handler.h.

## Constructor & Destructor Documentation

## ◆ KeyboardKeyEmbedderHandler()

flutter::KeyboardKeyEmbedderHandler::KeyboardKeyEmbedderHandler | ( | SendEventHandler | send_event,
|  | GetKeyStateHandler | get_key_state,
|  | MapVirtualKeyToScanCode | map_vk_to_scan
| ) |  |
| explicit

Definition at line 59 of file keyboard_key_embedder_handler.cc.

63 : perform_send_event_(send_event),
64 get_key_state_(get_key_state),
65 response_id_(1) {
66 InitCriticalKeys(map_virtual_key_to_scan_code);
67 }

## ◆ ~KeyboardKeyEmbedderHandler()

flutter::KeyboardKeyEmbedderHandler::~KeyboardKeyEmbedderHandler | ( |  | ) |
| virtual default

## Member Function Documentation

## ◆ GetPressedState()

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

Implements flutter::KeyboardKeyHandler::KeyboardKeyHandlerDelegate.

Definition at line 353 of file keyboard_key_embedder_handler.cc.

353 {
354 return pressingRecords_;
355 }

## ◆ KeyboardHook()

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

Implements flutter::KeyboardKeyHandler::KeyboardKeyHandlerDelegate.

Definition at line 325 of file keyboard_key_embedder_handler.cc.

332 {
333 sent_any_events = false;
334 KeyboardHookImpl(key, scancode, action, character, extended, was_down,
335 std::move(callback));
336 if (!sent_any_events) {
337 FlutterKeyEvent empty_event{
338 .struct_size = sizeof(FlutterKeyEvent),
339 .timestamp = static_cast<double>(
340 std::chrono::duration_cast<std::chrono::microseconds>(
341 std::chrono::high_resolution_clock::now().time_since_epoch())
342 .count()),
343 .type = kFlutterKeyEventTypeDown,
344 .physical = 0,
345 .logical = 0,
346 .character = empty_character,
347 .synthesized = false,
348 };
349 SendEvent(empty_event, nullptr, nullptr);
350 }
351 }
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
was_down
bool was_down
Definition: keyboard_key_handler_unittests.cc:119
type
enum flutter::testing::@88::KeyboardChange::Type type

References action, callback, character, extended, key, scancode, type, and was_down.

## ◆ SyncModifiersIfNeeded()

void flutter::KeyboardKeyEmbedderHandler::SyncModifiersIfNeeded | ( | int | modifiers_state | ) |
| override virtual

Implements flutter::KeyboardKeyHandler::KeyboardKeyHandlerDelegate.

Definition at line 500 of file keyboard_key_embedder_handler.cc.

500 {
501 // TODO(bleroux): consider exposing these constants in flutter_key_map.g.cc?
502 const uint64_t physical_shift_left =
503 windowsToPhysicalMap_.at(kScanCodeShiftLeft);
504 const uint64_t physical_shift_right =
505 windowsToPhysicalMap_.at(kScanCodeShiftRight);
506 const uint64_t logical_shift_left =
507 windowsToLogicalMap_.at(kKeyCodeShiftLeft);
508 const uint64_t physical_control_left =
509 windowsToPhysicalMap_.at(kScanCodeControlLeft);
510 const uint64_t physical_control_right =
511 windowsToPhysicalMap_.at(kScanCodeControlRight);
512 const uint64_t logical_control_left =
513 windowsToLogicalMap_.at(kKeyCodeControlLeft);
514
515 bool shift_pressed = (modifiers_state & kShift) != 0;
516 SynthesizeIfNeeded(physical_shift_left, physical_shift_right,
517 logical_shift_left, shift_pressed);
518 bool control_pressed = (modifiers_state & kControl) != 0;
519 SynthesizeIfNeeded(physical_control_left, physical_control_right,
520 logical_control_left, control_pressed);
521 }
flutter::kShift
constexpr int kShift
Definition: keyboard_utils.h:14
flutter::kKeyCodeShiftLeft
constexpr int kKeyCodeShiftLeft
Definition: keyboard_utils.h:18
flutter::kScanCodeShiftRight
constexpr int kScanCodeShiftRight
Definition: keyboard_utils.h:17
flutter::kScanCodeShiftLeft
constexpr int kScanCodeShiftLeft
Definition: keyboard_utils.h:16
flutter::kScanCodeControlRight
constexpr int kScanCodeControlRight
Definition: keyboard_utils.h:20
flutter::kScanCodeControlLeft
constexpr int kScanCodeControlLeft
Definition: keyboard_utils.h:19
flutter::kKeyCodeControlLeft
constexpr int kKeyCodeControlLeft
Definition: keyboard_utils.h:21
flutter::kControl
constexpr int kControl
Definition: keyboard_utils.h:15

References flutter::kControl, flutter::kKeyCodeControlLeft, flutter::kKeyCodeShiftLeft, flutter::kScanCodeControlLeft, flutter::kScanCodeControlRight, flutter::kScanCodeShiftLeft, flutter::kScanCodeShiftRight, and flutter::kShift.

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

- shell/platform/windows/keyboard_key_embedder_handler.h
- shell/platform/windows/flutter_key_map.g.cc
- shell/platform/windows/keyboard_key_embedder_handler.cc