1 // Copyright 2013 The Flutter Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_KEY_EVENT_HANDLER_H_ 6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_KEY_EVENT_HANDLER_H_ 7 8 #include <memory> 9 10 #include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/basic_message_channel.h" 11 #include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/binary_messenger.h" 12 #include "flutter/shell/platform/windows/keyboard_hook_handler.h" 13 #include "flutter/shell/platform/windows/public/flutter_windows.h" 14 #include "rapidjson/document.h" 15 16 namespace flutter { 17 18 class Win32FlutterWindow; 19 20 // Implements a KeyboardHookHandler 21 // 22 // Handles key events and forwards them to the Flutter engine. 23 class KeyEventHandler : public KeyboardHookHandler { 24 public: 25 explicit KeyEventHandler(flutter::BinaryMessenger* messenger); 26 27 virtual ~KeyEventHandler(); 28 29 // |KeyboardHookHandler| 30 void KeyboardHook(Win32FlutterWindow* window, 31 int key, 32 int scancode, 33 int action, 34 int mods) override; 35 36 // |KeyboardHookHandler| 37 void CharHook(Win32FlutterWindow* window, unsigned int code_point) override; 38 39 private: 40 // The Flutter system channel for key event messages. 41 std::unique_ptr<flutter::BasicMessageChannel<rapidjson::Document>> channel_; 42 }; 43 44 } // namespace flutter 45 46 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_KEY_EVENT_HANDLER_H_ 47