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/native_device_keymap.h" | |
8 #include "ui/events/keycodes/dom/dom_code.h" | |
9 | |
10 namespace remoting { | |
11 | |
12 TextKeyboardInputStrategy::TextKeyboardInputStrategy( | |
13 ChromotingSession* input_stub) | |
14 : input_stub_(input_stub) {} | |
15 | |
16 TextKeyboardInputStrategy::~TextKeyboardInputStrategy() {} | |
17 | |
18 // KeyboardInputStrategy | |
19 | |
20 void TextKeyboardInputStrategy::HandleTextEvent(const std::string& text, | |
21 uint8_t modifiers) { | |
22 // TODO(nicholss): Handle modifers. | |
23 input_stub_->SendTextEvent(text); | |
24 } | |
25 | |
26 void TextKeyboardInputStrategy::HandleDeleteEvent(uint8_t modifiers) { | |
27 std::queue<KeyEvent> keys = ConvertDeleteEvent(modifiers); | |
28 while (!keys.empty()) { | |
29 KeyEvent key = keys.front(); | |
30 input_stub_->SendKeyEvent(0, key.keycode, key.keydown); | |
31 keys.pop(); | |
32 } | |
33 } | |
34 | |
35 std::queue<KeyEvent> TextKeyboardInputStrategy::ConvertDeleteEvent( | |
36 uint8_t modifiers) { | |
37 std::queue<KeyEvent> keys; | |
Yuwei
2017/05/16 00:47:30
I'm not sure whether we still need KeyEvent... In
nicholss
2017/05/16 17:13:39
perhaps, It might refactor out after I figure out
| |
38 // TODO(nicholss): Handle modifers. | |
39 // Key press. | |
40 keys.push({static_cast<uint32_t>(ui::DomCode::BACKSPACE), true}); | |
41 | |
42 // Key release. | |
43 keys.push({static_cast<uint32_t>(ui::DomCode::BACKSPACE), false}); | |
44 | |
45 return keys; | |
46 } | |
47 | |
48 } // namespace remoting | |
OLD | NEW |