OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/event_executor_win.h" | 5 #include "remoting/host/event_executor_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 void EventExecutorWin::HandleKey(const KeyEvent* event) { | 55 void EventExecutorWin::HandleKey(const KeyEvent* event) { |
56 int key = event->keycode(); | 56 int key = event->keycode(); |
57 bool down = event->pressed(); | 57 bool down = event->pressed(); |
58 | 58 |
59 // Calculate scan code from virtual key. | 59 // Calculate scan code from virtual key. |
60 HKL hkl = GetKeyboardLayout(0); | 60 HKL hkl = GetKeyboardLayout(0); |
61 int scan_code = MapVirtualKeyEx(key, MAPVK_VK_TO_VSC_EX, hkl); | 61 int scan_code = MapVirtualKeyEx(key, MAPVK_VK_TO_VSC_EX, hkl); |
62 | 62 |
63 INPUT input; | 63 INPUT input; |
| 64 memset(&input, 0, sizeof(input)); |
| 65 |
64 input.type = INPUT_KEYBOARD; | 66 input.type = INPUT_KEYBOARD; |
65 input.ki.time = 0; | 67 input.ki.time = 0; |
66 input.ki.wVk = key; | 68 input.ki.wVk = key; |
67 input.ki.wScan = scan_code; | 69 input.ki.wScan = scan_code; |
68 | 70 |
69 // Flag to mark extended 'e0' key scancodes. Without this, the left and | 71 // Flag to mark extended 'e0' key scancodes. Without this, the left and |
70 // right windows keys will not be handled properly (on US keyboard). | 72 // right windows keys will not be handled properly (on US keyboard). |
71 if ((scan_code & 0xFF00) == 0xE000) { | 73 if ((scan_code & 0xFF00) == 0xE000) { |
72 input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY; | 74 input.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY; |
73 } | 75 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } else { | 144 } else { |
143 button_event.mi.dwFlags = | 145 button_event.mi.dwFlags = |
144 down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP; | 146 down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP; |
145 } | 147 } |
146 | 148 |
147 SendInput(1, &button_event, sizeof(INPUT)); | 149 SendInput(1, &button_event, sizeof(INPUT)); |
148 } | 150 } |
149 } | 151 } |
150 | 152 |
151 } // namespace remoting | 153 } // namespace remoting |
OLD | NEW |