Chromium Code Reviews| Index: remoting/client/input/text_keyboard_input_strategy.cc |
| diff --git a/remoting/client/input/text_keyboard_input_strategy.cc b/remoting/client/input/text_keyboard_input_strategy.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4edb0ed86e2b1d1e273eb045cef9bbd7896082e9 |
| --- /dev/null |
| +++ b/remoting/client/input/text_keyboard_input_strategy.cc |
| @@ -0,0 +1,54 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "remoting/client/input/text_keyboard_input_strategy.h" |
| + |
| +#include "remoting/client/native_device_keymap.h" |
| +#include "ui/events/keycodes/dom/dom_code.h" |
| + |
| +namespace remoting { |
| + |
| +TextKeyboardInputStrategy::TextKeyboardInputStrategy( |
| + ChromotingSession* input_stub) |
| + : input_stub_(input_stub) {} |
| + |
| +TextKeyboardInputStrategy::~TextKeyboardInputStrategy() {} |
| + |
| +// KeyboardInputStrategy |
| + |
| +void TextKeyboardInputStrategy::HandleTextEvent(const std::string& text, |
| + uint8_t modifiers) { |
| + // TODO(nicholss): Handle modifers. |
| + input_stub_->SendTextEvent(text); |
| +} |
| + |
| +void TextKeyboardInputStrategy::HandleDeleteEvent(uint8_t modifiers) { |
| + std::queue<KeyEvent> keys = ConvertDeleteEvent(modifiers); |
| + while (!keys.empty()) { |
| + KeyEvent key = keys.front(); |
| + input_stub_->SendKeyEvent(0, key.keycode, key.keydown); |
| + keys.pop(); |
| + } |
| +} |
| + |
| +std::queue<KeyEvent> TextKeyboardInputStrategy::ConvertDeleteEvent( |
| + uint8_t modifiers) { |
| + std::queue<KeyEvent> keys; |
| + // TODO(nicholss): Handle modifers. |
| + // Key press. |
| + KeyEvent key_down; |
|
Yuwei
2017/05/15 19:38:06
push({...})?
nicholss
2017/05/15 23:06:11
Acknowledged.
Yuwei
2017/05/16 00:47:30
You probably want to use "Done" for things you hav
nicholss
2017/05/16 17:13:39
Acknowledged.
|
| + key_down.keycode = static_cast<uint32_t>(ui::DomCode::BACKSPACE); |
| + key_down.keydown = true; |
| + keys.push(key_down); |
| + |
| + // Key release. |
| + KeyEvent key_up; |
| + key_up.keycode = static_cast<uint32_t>(ui::DomCode::BACKSPACE); |
| + key_up.keydown = false; |
| + keys.push(key_up); |
| + |
| + return keys; |
| +} |
| + |
| +} // namespace remoting |