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

Side by Side Diff: remoting/client/key_event_mapper.cc

Issue 1542203002: Switch to standard integer types in remoting/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@int-remoting-host
Patch Set: Created 5 years 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
« no previous file with comments | « remoting/client/key_event_mapper.h ('k') | remoting/client/key_event_mapper_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/client/key_event_mapper.h" 5 #include "remoting/client/key_event_mapper.h"
6 6
7 #include "remoting/proto/event.pb.h" 7 #include "remoting/proto/event.pb.h"
8 8
9 namespace remoting { 9 namespace remoting {
10 10
11 KeyEventMapper::KeyEventMapper() { 11 KeyEventMapper::KeyEventMapper() {
12 } 12 }
13 13
14 KeyEventMapper::KeyEventMapper(InputStub* stub) : protocol::InputFilter(stub) { 14 KeyEventMapper::KeyEventMapper(InputStub* stub) : protocol::InputFilter(stub) {
15 } 15 }
16 16
17 KeyEventMapper::~KeyEventMapper() { 17 KeyEventMapper::~KeyEventMapper() {
18 } 18 }
19 19
20 void KeyEventMapper::SetTrapCallback(KeyTrapCallback callback) { 20 void KeyEventMapper::SetTrapCallback(KeyTrapCallback callback) {
21 trap_callback = callback; 21 trap_callback = callback;
22 } 22 }
23 23
24 void KeyEventMapper::TrapKey(uint32 usb_keycode, bool trap_key) { 24 void KeyEventMapper::TrapKey(uint32_t usb_keycode, bool trap_key) {
25 if (trap_key) { 25 if (trap_key) {
26 trapped_keys.insert(usb_keycode); 26 trapped_keys.insert(usb_keycode);
27 } else { 27 } else {
28 trapped_keys.erase(usb_keycode); 28 trapped_keys.erase(usb_keycode);
29 } 29 }
30 } 30 }
31 31
32 void KeyEventMapper::RemapKey(uint32 in_usb_keycode, uint32 out_usb_keycode) { 32 void KeyEventMapper::RemapKey(uint32_t in_usb_keycode,
33 uint32_t out_usb_keycode) {
33 if (in_usb_keycode == out_usb_keycode) { 34 if (in_usb_keycode == out_usb_keycode) {
34 mapped_keys.erase(in_usb_keycode); 35 mapped_keys.erase(in_usb_keycode);
35 } else { 36 } else {
36 mapped_keys[in_usb_keycode] = out_usb_keycode; 37 mapped_keys[in_usb_keycode] = out_usb_keycode;
37 } 38 }
38 } 39 }
39 40
40 void KeyEventMapper::InjectKeyEvent(const protocol::KeyEvent& event) { 41 void KeyEventMapper::InjectKeyEvent(const protocol::KeyEvent& event) {
41 if (event.has_usb_keycode()) { 42 if (event.has_usb_keycode()) {
42 // Deliver trapped keys to the callback, not the next stub. 43 // Deliver trapped keys to the callback, not the next stub.
43 if (!trap_callback.is_null() && event.has_pressed() && 44 if (!trap_callback.is_null() && event.has_pressed() &&
44 (trapped_keys.find(event.usb_keycode()) != trapped_keys.end())) { 45 (trapped_keys.find(event.usb_keycode()) != trapped_keys.end())) {
45 trap_callback.Run(event); 46 trap_callback.Run(event);
46 return; 47 return;
47 } 48 }
48 49
49 // Re-map mapped keys to the new value before passing them on. 50 // Re-map mapped keys to the new value before passing them on.
50 std::map<uint32,uint32>::iterator mapped = 51 std::map<uint32_t, uint32_t>::iterator mapped =
51 mapped_keys.find(event.usb_keycode()); 52 mapped_keys.find(event.usb_keycode());
52 if (mapped != mapped_keys.end()) { 53 if (mapped != mapped_keys.end()) {
53 protocol::KeyEvent new_event(event); 54 protocol::KeyEvent new_event(event);
54 new_event.set_usb_keycode(mapped->second); 55 new_event.set_usb_keycode(mapped->second);
55 InputFilter::InjectKeyEvent(new_event); 56 InputFilter::InjectKeyEvent(new_event);
56 return; 57 return;
57 } 58 }
58 } 59 }
59 60
60 InputFilter::InjectKeyEvent(event); 61 InputFilter::InjectKeyEvent(event);
61 } 62 }
62 63
63 } // namespace remoting 64 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/key_event_mapper.h ('k') | remoting/client/key_event_mapper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698