Chromium Code Reviews| Index: remoting/host/input_injector_win.cc |
| diff --git a/remoting/host/input_injector_win.cc b/remoting/host/input_injector_win.cc |
| index 9354eda63932baf3730db215a64314e34a1fe823..72c92f032bcb707adf2b4ffa8576f29e8792b97a 100644 |
| --- a/remoting/host/input_injector_win.cc |
| +++ b/remoting/host/input_injector_win.cc |
| @@ -199,6 +199,9 @@ class InputInjectorWin : public InputInjector { |
| void HandleMouse(const MouseEvent& event); |
| void HandleTouch(const TouchEvent& event); |
| + // Sets the keyboard lock states to those provided. |
| + void SetLockStates(uint32_t states); |
| + |
| scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
| std::unique_ptr<Clipboard> clipboard_; |
| @@ -348,6 +351,10 @@ void InputInjectorWin::Core::HandleKey(const KeyEvent& event) { |
| if (scancode == ui::KeycodeConverter::InvalidNativeKeycode()) |
| return; |
| + if (event.has_lock_states()) { |
| + SetLockStates(event.lock_states()); |
| + } |
| + |
| uint32_t flags = KEYEVENTF_SCANCODE | (event.pressed() ? 0 : KEYEVENTF_KEYUP); |
| SendKeyboardInput(flags, scancode); |
| } |
| @@ -384,6 +391,28 @@ void InputInjectorWin::Core::HandleTouch(const TouchEvent& event) { |
| touch_injector_->InjectTouchEvent(event); |
| } |
| +void InputInjectorWin::Core::SetLockStates(uint32_t states) { |
| + // Can't use SendKeyboardInput because we need to send virtual key codes, not |
| + // scan codes. |
| + INPUT input[2]; |
| + memset(&input, 0, sizeof(input)); |
| + input[0].type = INPUT_KEYBOARD; |
| + input[1].type = INPUT_KEYBOARD; |
| + input[1].ki.dwFlags = KEYEVENTF_KEYUP; |
| + if (!!(states | protocol::KeyEvent::LOCK_STATES_CAPSLOCK) != |
| + !!(GetKeyState(VK_CAPITAL) & 1)) { |
| + input[0].ki.wVk = VK_CAPITAL; |
| + input[1].ki.wVk = VK_CAPITAL; |
| + SendInput(arraysize(input), input, sizeof(INPUT)); |
| + } |
| + if (!!(states | protocol::KeyEvent::LOCK_STATES_NUMLOCK) != |
| + !!(GetKeyState(VK_NUMLOCK) & 1)) { |
| + input[0].ki.wVk = VK_NUMLOCK; |
| + input[1].ki.wVk = VK_NUMLOCK; |
| + SendInput(arraysize(input), input, sizeof(INPUT)); |
| + } |
| +} |
|
rkjnsn
2017/04/26 23:12:21
This builds, but I'm not able to test it, as I don
|
| + |
| } // namespace |
| // static |