OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/input_injector.h" | 5 #include "remoting/host/input_injector.h" |
6 | 6 |
7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
8 #include <Carbon/Carbon.h> | 8 #include <Carbon/Carbon.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 // |clipboard_| will ignore unknown MIME-types, and verify the data's format. | 173 // |clipboard_| will ignore unknown MIME-types, and verify the data's format. |
174 clipboard_->InjectClipboardEvent(event); | 174 clipboard_->InjectClipboardEvent(event); |
175 } | 175 } |
176 | 176 |
177 void InputInjectorMac::Core::InjectKeyEvent(const KeyEvent& event) { | 177 void InputInjectorMac::Core::InjectKeyEvent(const KeyEvent& event) { |
178 // HostEventDispatcher should filter events missing the pressed field. | 178 // HostEventDispatcher should filter events missing the pressed field. |
179 if (!event.has_pressed() || !event.has_usb_keycode()) | 179 if (!event.has_pressed() || !event.has_usb_keycode()) |
180 return; | 180 return; |
181 | 181 |
182 ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance(); | 182 int keycode = |
183 int keycode = key_converter->UsbKeycodeToNativeKeycode(event.usb_keycode()); | 183 ui::KeycodeConverter::UsbKeycodeToNativeKeycode(event.usb_keycode()); |
184 | 184 |
185 VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode() | 185 VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode() |
186 << " to keycode: " << keycode << std::dec; | 186 << " to keycode: " << keycode << std::dec; |
187 | 187 |
188 // If we couldn't determine the Mac virtual key code then ignore the event. | 188 // If we couldn't determine the Mac virtual key code then ignore the event. |
189 if (keycode == key_converter->InvalidNativeKeycode()) | 189 if (keycode == ui::KeycodeConverter::InvalidNativeKeycode()) |
190 return; | 190 return; |
191 | 191 |
192 // If this is a modifier key, remember its new state so that it can be | 192 // If this is a modifier key, remember its new state so that it can be |
193 // correctly applied to subsequent events. | 193 // correctly applied to subsequent events. |
194 if (keycode == kVK_Command) { | 194 if (keycode == kVK_Command) { |
195 SetOrClearBit(left_modifiers_, kCGEventFlagMaskCommand, event.pressed()); | 195 SetOrClearBit(left_modifiers_, kCGEventFlagMaskCommand, event.pressed()); |
196 } else if (keycode == kVK_Shift) { | 196 } else if (keycode == kVK_Shift) { |
197 SetOrClearBit(left_modifiers_, kCGEventFlagMaskShift, event.pressed()); | 197 SetOrClearBit(left_modifiers_, kCGEventFlagMaskShift, event.pressed()); |
198 } else if (keycode == kVK_Control) { | 198 } else if (keycode == kVK_Control) { |
199 SetOrClearBit(left_modifiers_, kCGEventFlagMaskControl, event.pressed()); | 199 SetOrClearBit(left_modifiers_, kCGEventFlagMaskControl, event.pressed()); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 335 |
336 } // namespace | 336 } // namespace |
337 | 337 |
338 scoped_ptr<InputInjector> InputInjector::Create( | 338 scoped_ptr<InputInjector> InputInjector::Create( |
339 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 339 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
340 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 340 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
341 return scoped_ptr<InputInjector>(new InputInjectorMac(main_task_runner)); | 341 return scoped_ptr<InputInjector>(new InputInjectorMac(main_task_runner)); |
342 } | 342 } |
343 | 343 |
344 } // namespace remoting | 344 } // namespace remoting |
OLD | NEW |