Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Side by Side Diff: remoting/host/input_injector_win.cc

Issue 494813002: events: keycodes: Remove the stateless singleton instance of KeycodeConverter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/input_injector_mac.cc ('k') | ui/events/event_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <windows.h> 7 #include <windows.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 InputInjectorWin::Core::~Core() {} 215 InputInjectorWin::Core::~Core() {}
216 216
217 void InputInjectorWin::Core::HandleKey(const KeyEvent& event) { 217 void InputInjectorWin::Core::HandleKey(const KeyEvent& event) {
218 // HostEventDispatcher should filter events missing the pressed field. 218 // HostEventDispatcher should filter events missing the pressed field.
219 DCHECK(event.has_pressed() && event.has_usb_keycode()); 219 DCHECK(event.has_pressed() && event.has_usb_keycode());
220 220
221 // Reset the system idle suspend timeout. 221 // Reset the system idle suspend timeout.
222 SetThreadExecutionState(ES_SYSTEM_REQUIRED); 222 SetThreadExecutionState(ES_SYSTEM_REQUIRED);
223 223
224 ui::KeycodeConverter* key_converter = ui::KeycodeConverter::GetInstance(); 224 int scancode =
225 int scancode = key_converter->UsbKeycodeToNativeKeycode(event.usb_keycode()); 225 ui::KeycodeConverter::UsbKeycodeToNativeKeycode(event.usb_keycode());
226 VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode() 226 VLOG(3) << "Converting USB keycode: " << std::hex << event.usb_keycode()
227 << " to scancode: " << scancode << std::dec; 227 << " to scancode: " << scancode << std::dec;
228 228
229 // Ignore events which can't be mapped. 229 // Ignore events which can't be mapped.
230 if (scancode == key_converter->InvalidNativeKeycode()) 230 if (scancode == ui::KeycodeConverter::InvalidNativeKeycode())
231 return; 231 return;
232 232
233 uint32_t flags = KEYEVENTF_SCANCODE | (event.pressed() ? 0 : KEYEVENTF_KEYUP); 233 uint32_t flags = KEYEVENTF_SCANCODE | (event.pressed() ? 0 : KEYEVENTF_KEYUP);
234 SendKeyboardInput(flags, scancode); 234 SendKeyboardInput(flags, scancode);
235 } 235 }
236 236
237 void InputInjectorWin::Core::HandleText(const TextEvent& event) { 237 void InputInjectorWin::Core::HandleText(const TextEvent& event) {
238 // HostEventDispatcher should filter events missing the pressed field. 238 // HostEventDispatcher should filter events missing the pressed field.
239 DCHECK(event.has_text()); 239 DCHECK(event.has_text());
240 240
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } // namespace 323 } // namespace
324 324
325 scoped_ptr<InputInjector> InputInjector::Create( 325 scoped_ptr<InputInjector> InputInjector::Create(
326 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 326 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
327 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 327 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
328 return scoped_ptr<InputInjector>( 328 return scoped_ptr<InputInjector>(
329 new InputInjectorWin(main_task_runner, ui_task_runner)); 329 new InputInjectorWin(main_task_runner, ui_task_runner));
330 } 330 }
331 331
332 } // namespace remoting 332 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/input_injector_mac.cc ('k') | ui/events/event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698