Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter::KeyEventHandler Class Reference

#include <key_event_handler.h>

Inheritance diagram for flutter::KeyEventHandler:
flutter::KeyboardHookHandler

Public Member Functions

 KeyEventHandler (flutter::BinaryMessenger *messenger)
 
virtual ~KeyEventHandler ()
 
void KeyboardHook (GLFWwindow *window, int key, int scancode, int action, int mods) override
 
void CharHook (GLFWwindow *window, unsigned int code_point) override
 
- Public Member Functions inherited from flutter::KeyboardHookHandler
virtual ~KeyboardHookHandler ()=default
 
virtual void KeyboardHook (GLFWwindow *window, int key, int scancode, int action, int mods)=0
 
virtual void CharHook (GLFWwindow *window, unsigned int code_point)=0
 

Detailed Description

Definition at line 21 of file key_event_handler.h.

Constructor & Destructor Documentation

◆ KeyEventHandler()

flutter::KeyEventHandler::KeyEventHandler ( flutter::BinaryMessenger messenger)
explicit

Definition at line 104 of file key_event_handler.cc.

105 : channel_(
107 messenger,
static const JsonMessageCodec & GetInstance()
static constexpr char kChannelName[]

◆ ~KeyEventHandler()

flutter::KeyEventHandler::~KeyEventHandler ( )
virtualdefault

Member Function Documentation

◆ CharHook()

void flutter::KeyEventHandler::CharHook ( GLFWwindow *  window,
unsigned int  code_point 
)
overridevirtual

Implements flutter::KeyboardHookHandler.

Definition at line 113 of file key_event_handler.cc.

113{}

◆ KeyboardHook()

void flutter::KeyEventHandler::KeyboardHook ( GLFWwindow *  window,
int  key,
int  scancode,
int  action,
int  mods 
)
overridevirtual

Implements flutter::KeyboardHookHandler.

Definition at line 115 of file key_event_handler.cc.

119 {
120 // TODO(chrome-bot): Translate to a cross-platform key code system rather than
121 // passing the native key code.
122 // NOLINTNEXTLINE(clang-analyzer-core.NullDereference)
123 rapidjson::Document event(rapidjson::kObjectType);
124 auto& allocator = event.GetAllocator();
125 event.AddMember(kKeyCodeKey, key, allocator);
126 event.AddMember(kKeyMapKey, kLinuxKeyMap, allocator);
127 event.AddMember(kScanCodeKey, scancode, allocator);
128 event.AddMember(kModifiersKey, mods, allocator);
129 event.AddMember(kToolkitKey, kGLFWKey, allocator);
130
131 uint32_t unicodeInt;
132 bool result = GetUTF32CodePointFromGLFWKey(key, scancode, &unicodeInt);
133 if (result) {
134 event.AddMember(kUnicodeScalarValues, unicodeInt, allocator);
135 }
136
137 switch (action) {
138 case GLFW_PRESS:
139 case GLFW_REPEAT:
140 event.AddMember(kTypeKey, kKeyDown, allocator);
141 break;
142 case GLFW_RELEASE:
143 event.AddMember(kTypeKey, kKeyUp, allocator);
144 break;
145 default:
146 std::cerr << "Unknown key event action: " << action << std::endl;
147 return;
148 }
149 channel_->Send(event);
150}
FlKeyEvent * event
GAsyncResult * result
static constexpr char kScanCodeKey[]
static constexpr char kKeyMapKey[]
static constexpr char kToolkitKey[]
static constexpr char kGLFWKey[]
static constexpr char kKeyDown[]
static constexpr char kLinuxKeyMap[]
static constexpr char kKeyUp[]
static constexpr char kModifiersKey[]
static constexpr char kUnicodeScalarValues[]
static constexpr char kKeyCodeKey[]
constexpr char kTypeKey[]
Definition: shell.cc:50

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