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/keyboard_interpreter.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "remoting/client/chromoting_session.h" |
| 9 #include "remoting/client/input/simple_keyboard_input_strategy.h" |
| 10 |
| 11 namespace remoting { |
| 12 |
| 13 KeyboardInterpreter::KeyboardInterpreter(ChromotingSession* input_stub) |
| 14 : input_stub_(input_stub) { |
| 15 // TODO(nicholss): This should be configurable. |
| 16 input_strategy_.reset(new SimpleKeyboardInputStrategy()); |
| 17 } |
| 18 |
| 19 KeyboardInterpreter::~KeyboardInterpreter() {} |
| 20 |
| 21 void KeyboardInterpreter::HandleTextEvent(const std::string& text, |
| 22 uint8_t modifiers) { |
| 23 std::queue<KeyEvent> keys = |
| 24 input_strategy_->ConvertTextEvent(text, modifiers); |
| 25 while (!keys.empty()) { |
| 26 KeyEvent key = keys.front(); |
| 27 input_stub_->SendKeyEvent(key.keycode, key.keydown); |
| 28 keys.pop(); |
| 29 } |
| 30 } |
| 31 |
| 32 void KeyboardInterpreter::HandleDeleteEvent(uint8_t modifiers) { |
| 33 std::queue<KeyEvent> keys = input_strategy_->ConvertDeleteEvent(modifiers); |
| 34 while (!keys.empty()) { |
| 35 KeyEvent key = keys.front(); |
| 36 input_stub_->SendKeyEvent(0, key.keycode, key.keydown); |
| 37 keys.pop(); |
| 38 } |
| 39 } |
| 40 |
| 41 } // namespace remoting |
OLD | NEW |