| 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 355 of file keyboard_key_embedder_handler.cc.

355 {
356 return pressingRecords_;
357 }

## ◆ 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 327 of file keyboard_key_embedder_handler.cc.

334 {
335 sent_any_events = false;
336 KeyboardHookImpl(key, scancode, action, character, extended, was_down,
337 std::move(callback));
338 if (!sent_any_events) {
339 FlutterKeyEvent empty_event{
340 .struct_size = sizeof(FlutterKeyEvent),
341 .timestamp = static_cast<double>(
342 std::chrono::duration_cast<std::chrono::microseconds>(
343 std::chrono::high_resolution_clock::now().time_since_epoch())
344 .count()),
345 .type = kFlutterKeyEventTypeDown,
346 .physical = 0,
347 .logical = 0,
348 .character = empty_character,
349 .synthesized = false,
350 };
351 SendEvent(empty_event, nullptr, nullptr);
352 }
353 }
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::@98::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 502 of file keyboard_key_embedder_handler.cc.

502 {
503 // TODO(bleroux): consider exposing these constants in flutter_key_map.g.cc?
504 const uint64_t physical_shift_left =
505 windowsToPhysicalMap_.at(kScanCodeShiftLeft);
506 const uint64_t physical_shift_right =
507 windowsToPhysicalMap_.at(kScanCodeShiftRight);
508 const uint64_t logical_shift_left =
509 windowsToLogicalMap_.at(kKeyCodeShiftLeft);
510 const uint64_t physical_control_left =
511 windowsToPhysicalMap_.at(kScanCodeControlLeft);
512 const uint64_t physical_control_right =
513 windowsToPhysicalMap_.at(kScanCodeControlRight);
514 const uint64_t logical_control_left =
515 windowsToLogicalMap_.at(kKeyCodeControlLeft);
516
517 bool shift_pressed = (modifiers_state & kShift) != 0;
518 SynthesizeIfNeeded(physical_shift_left, physical_shift_right,
519 logical_shift_left, shift_pressed);
520 bool control_pressed = (modifiers_state & kControl) != 0;
521 SynthesizeIfNeeded(physical_control_left, physical_control_right,
522 logical_control_left, control_pressed);
523 }
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