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

Side by Side Diff: ui/events/keycodes/keyboard_code_conversion.cc

Issue 660173002: Type conversion fixes, ui/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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
« no previous file with comments | « ui/events/keycodes/dom4/keycode_converter.cc ('k') | ui/events/latency_info.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/events/keycodes/keyboard_code_conversion.h" 5 #include "ui/events/keycodes/keyboard_code_conversion.h"
6 6
7 #include "ui/events/event_constants.h" 7 #include "ui/events/event_constants.h"
8 8
9 namespace ui { 9 namespace ui {
10 10
11 uint16 GetCharacterFromKeyCode(KeyboardCode key_code, int flags) { 11 uint16 GetCharacterFromKeyCode(KeyboardCode key_code, int flags) {
12 const bool ctrl = (flags & EF_CONTROL_DOWN) != 0; 12 const bool ctrl = (flags & EF_CONTROL_DOWN) != 0;
13 const bool shift = (flags & EF_SHIFT_DOWN) != 0; 13 const bool shift = (flags & EF_SHIFT_DOWN) != 0;
14 const bool upper = shift ^ ((flags & EF_CAPS_LOCK_DOWN) != 0); 14 const bool upper = shift ^ ((flags & EF_CAPS_LOCK_DOWN) != 0);
15 15
16 // Following Windows behavior to map ctrl-a ~ ctrl-z to \x01 ~ \x1A. 16 // Following Windows behavior to map ctrl-a ~ ctrl-z to \x01 ~ \x1A.
17 if (key_code >= VKEY_A && key_code <= VKEY_Z) 17 if (key_code >= VKEY_A && key_code <= VKEY_Z) {
18 return key_code - VKEY_A + (ctrl ? 1 : (upper ? 'A' : 'a')); 18 return static_cast<uint16>
19 (key_code - VKEY_A + (ctrl ? 1 : (upper ? 'A' : 'a')));
20 }
19 21
20 // Other ctrl characters 22 // Other ctrl characters
21 if (ctrl) { 23 if (ctrl) {
22 if (shift) { 24 if (shift) {
23 // following graphics chars require shift key to input. 25 // following graphics chars require shift key to input.
24 switch (key_code) { 26 switch (key_code) {
25 // ctrl-@ maps to \x00 (Null byte) 27 // ctrl-@ maps to \x00 (Null byte)
26 case VKEY_2: 28 case VKEY_2:
27 return 0; 29 return 0;
28 // ctrl-^ maps to \x1E (Record separator, Information separator two) 30 // ctrl-^ maps to \x1E (Record separator, Information separator two)
(...skipping 29 matching lines...) Expand all
58 60
59 // For IME support. 61 // For IME support.
60 if (key_code == ui::VKEY_PROCESSKEY) 62 if (key_code == ui::VKEY_PROCESSKEY)
61 return 0xE5; 63 return 0xE5;
62 64
63 // Normal characters 65 // Normal characters
64 if (key_code >= VKEY_0 && key_code <= VKEY_9) { 66 if (key_code >= VKEY_0 && key_code <= VKEY_9) {
65 return shift ? ")!@#$%^&*("[key_code - VKEY_0] : 67 return shift ? ")!@#$%^&*("[key_code - VKEY_0] :
66 static_cast<uint16>(key_code); 68 static_cast<uint16>(key_code);
67 } else if (key_code >= VKEY_NUMPAD0 && key_code <= VKEY_NUMPAD9) { 69 } else if (key_code >= VKEY_NUMPAD0 && key_code <= VKEY_NUMPAD9) {
68 return key_code - VKEY_NUMPAD0 + '0'; 70 return static_cast<uint16>(key_code - VKEY_NUMPAD0 + '0');
69 } 71 }
70 72
71 switch (key_code) { 73 switch (key_code) {
72 case VKEY_TAB: 74 case VKEY_TAB:
73 return '\t'; 75 return '\t';
74 case VKEY_RETURN: 76 case VKEY_RETURN:
75 return '\r'; 77 return '\r';
76 case VKEY_MULTIPLY: 78 case VKEY_MULTIPLY:
77 return '*'; 79 return '*';
78 case VKEY_ADD: 80 case VKEY_ADD:
(...skipping 27 matching lines...) Expand all
106 case VKEY_OEM_6: 108 case VKEY_OEM_6:
107 return shift ? '}' : ']'; 109 return shift ? '}' : ']';
108 case VKEY_OEM_7: 110 case VKEY_OEM_7:
109 return shift ? '"' : '\''; 111 return shift ? '"' : '\'';
110 default: 112 default:
111 return 0; 113 return 0;
112 } 114 }
113 } 115 }
114 116
115 } // namespace ui 117 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/keycodes/dom4/keycode_converter.cc ('k') | ui/events/latency_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698