OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium 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 #include "remoting/client/input/text_keyboard_input_strategy.h" |
| 6 |
| 7 #include "remoting/client/input/client_input_injector.h" |
| 8 #include "remoting/client/native_device_keymap.h" |
| 9 #include "ui/events/keycodes/dom/dom_code.h" |
| 10 |
| 11 namespace remoting { |
| 12 |
| 13 TextKeyboardInputStrategy::TextKeyboardInputStrategy( |
| 14 ClientInputInjector* input_injector) |
| 15 : input_injector_(input_injector) {} |
| 16 |
| 17 TextKeyboardInputStrategy::~TextKeyboardInputStrategy() {} |
| 18 |
| 19 // KeyboardInputStrategy |
| 20 |
| 21 void TextKeyboardInputStrategy::HandleTextEvent(const std::string& text, |
| 22 uint8_t modifiers) { |
| 23 // TODO(nicholss): Handle modifers. |
| 24 input_injector_->SendTextEvent(text); |
| 25 } |
| 26 |
| 27 void TextKeyboardInputStrategy::HandleDeleteEvent(uint8_t modifiers) { |
| 28 std::queue<KeyEvent> keys = ConvertDeleteEvent(modifiers); |
| 29 while (!keys.empty()) { |
| 30 KeyEvent key = keys.front(); |
| 31 input_injector_->SendKeyEvent(0, key.keycode, key.keydown); |
| 32 keys.pop(); |
| 33 } |
| 34 } |
| 35 |
| 36 std::queue<KeyEvent> TextKeyboardInputStrategy::ConvertDeleteEvent( |
| 37 uint8_t modifiers) { |
| 38 std::queue<KeyEvent> keys; |
| 39 // TODO(nicholss): Handle modifers. |
| 40 // Key press. |
| 41 keys.push({static_cast<uint32_t>(ui::DomCode::BACKSPACE), true}); |
| 42 |
| 43 // Key release. |
| 44 keys.push({static_cast<uint32_t>(ui::DomCode::BACKSPACE), false}); |
| 45 |
| 46 return keys; |
| 47 } |
| 48 |
| 49 } // namespace remoting |
OLD | NEW |