nicholss | 1e49b618 | 2017-05-22 20:30:47 | [diff] [blame] | 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" |
nicholss | 7666a28 | 2017-05-24 15:48:02 | [diff] [blame] | 8 | #include "remoting/client/input/native_device_keymap.h" |
nicholss | 1e49b618 | 2017-05-22 20:30:47 | [diff] [blame] | 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 | |
Chris Watkins | 6fe52aa | 2017-11-28 03:24:05 | [diff] [blame^] | 17 | TextKeyboardInputStrategy::~TextKeyboardInputStrategy() = default; |
nicholss | 1e49b618 | 2017-05-22 20:30:47 | [diff] [blame] | 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 | |
Brett Wilson | b02c0a2 | 2017-09-25 22:34:42 | [diff] [blame] | 27 | void TextKeyboardInputStrategy::HandleKeysEvent(base::queue<KeyEvent> keys) { |
nicholss | 1e49b618 | 2017-05-22 20:30:47 | [diff] [blame] | 28 | while (!keys.empty()) { |
| 29 | KeyEvent key = keys.front(); |
| 30 | input_injector_->SendKeyEvent(0, key.keycode, key.keydown); |
| 31 | keys.pop(); |
| 32 | } |
| 33 | } |
| 34 | |
nicholss | 1e49b618 | 2017-05-22 20:30:47 | [diff] [blame] | 35 | } // namespace remoting |