| 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..8f2b7fa1e98e40556c243f1cb2433fa50176a81c 100644
|
| --- a/remoting/host/input_injector_win.cc
|
| +++ b/remoting/host/input_injector_win.cc
|
| @@ -199,6 +199,12 @@ class InputInjectorWin : public InputInjector {
|
| void HandleMouse(const MouseEvent& event);
|
| void HandleTouch(const TouchEvent& event);
|
|
|
| + // Check if the given scan code is caps lock or num lock.
|
| + bool IsLockKey(int scancode);
|
| +
|
| + // 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 +354,10 @@ void InputInjectorWin::Core::HandleKey(const KeyEvent& event) {
|
| if (scancode == ui::KeycodeConverter::InvalidNativeKeycode())
|
| return;
|
|
|
| + if (event.has_lock_states() && !IsLockKey(scancode)) {
|
| + SetLockStates(event.lock_states());
|
| + }
|
| +
|
| uint32_t flags = KEYEVENTF_SCANCODE | (event.pressed() ? 0 : KEYEVENTF_KEYUP);
|
| SendKeyboardInput(flags, scancode);
|
| }
|
| @@ -384,6 +394,38 @@ void InputInjectorWin::Core::HandleTouch(const TouchEvent& event) {
|
| touch_injector_->InjectTouchEvent(event);
|
| }
|
|
|
| +bool InputInjectorWin::Core::IsLockKey(int scancode) {
|
| + UINT virtual_key = MapVirtualKey(scancode, MAPVK_VSC_TO_VK);
|
| + return virtual_key == VK_CAPITAL || virtual_key == VK_NUMLOCK;
|
| +}
|
| +
|
| +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] = {};
|
| + input[0].type = INPUT_KEYBOARD;
|
| + input[1].type = INPUT_KEYBOARD;
|
| + input[1].ki.dwFlags = KEYEVENTF_KEYUP;
|
| +
|
| + bool client_capslock_state =
|
| + (states & protocol::KeyEvent::LOCK_STATES_CAPSLOCK) != 0;
|
| + bool host_capslock_state = (GetKeyState(VK_CAPITAL) & 1) != 0;
|
| + if (client_capslock_state != host_capslock_state) {
|
| + input[0].ki.wVk = VK_CAPITAL;
|
| + input[1].ki.wVk = VK_CAPITAL;
|
| + SendInput(arraysize(input), input, sizeof(INPUT));
|
| + }
|
| +
|
| + bool client_numlock_state =
|
| + (states & protocol::KeyEvent::LOCK_STATES_NUMLOCK) != 0;
|
| + bool host_numlock_state = (GetKeyState(VK_NUMLOCK) & 1) != 0;
|
| + if (client_numlock_state != host_numlock_state) {
|
| + input[0].ki.wVk = VK_NUMLOCK;
|
| + input[1].ki.wVk = VK_NUMLOCK;
|
| + SendInput(arraysize(input), input, sizeof(INPUT));
|
| + }
|
| +}
|
| +
|
| } // namespace
|
|
|
| // static
|
|
|