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

Side by Side Diff: chrome/browser/extensions/api/braille_display_private/brlapi_keycode_map.cc

Issue 1136503003: Consolidate ui/events/keycodes/dom[34]/ into .../dom/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/extensions/api/braille_display_private/brlapi_keycode_m ap.h" 5 #include "chrome/browser/extensions/api/braille_display_private/brlapi_keycode_m ap.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversion_utils.h" 8 #include "base/strings/utf_string_conversion_utils.h"
9 9
10 namespace extensions { 10 namespace extensions {
11 namespace api { 11 namespace api {
12 namespace braille_display_private { 12 namespace braille_display_private {
13 13
14 namespace { 14 namespace {
15 // Bitmask for all braille dots in a key command argument, which coincides 15 // Bitmask for all braille dots in a key command argument, which coincides
16 // with the representation in the braille_dots member of the KeyEvent 16 // with the representation in the braille_dots member of the KeyEvent
17 // class. 17 // class.
18 const int kAllDots = BRLAPI_DOT1 | BRLAPI_DOT2 | BRLAPI_DOT3 | BRLAPI_DOT4 | 18 const int kAllDots = BRLAPI_DOT1 | BRLAPI_DOT2 | BRLAPI_DOT3 | BRLAPI_DOT4 |
19 BRLAPI_DOT5 | BRLAPI_DOT6 | BRLAPI_DOT7 | BRLAPI_DOT8; 19 BRLAPI_DOT5 | BRLAPI_DOT6 | BRLAPI_DOT7 | BRLAPI_DOT8;
20 20
21 // Maximum Latin 1 character keyboard symbol. 21 // Maximum Latin 1 character keyboard symbol.
22 const brlapi_keyCode_t kMaxLatin1KeySym = 0xff; 22 const brlapi_keyCode_t kMaxLatin1KeySym = 0xff;
23 23
24 // Range of function keys that we support. 24 // Range of function keys that we support.
25 // See ui/events/keycodes/dom4/keycode_converter_data.h for the list of all 25 // See ui/events/keycodes/dom/keycode_converter_data.inc for the list of all
26 // key codes. 26 // key codes.
27 const brlapi_keyCode_t kMinFunctionKey = BRLAPI_KEY_SYM_FUNCTION; 27 const brlapi_keyCode_t kMinFunctionKey = BRLAPI_KEY_SYM_FUNCTION;
28 const brlapi_keyCode_t kMaxFunctionKey = BRLAPI_KEY_SYM_FUNCTION + 23; 28 const brlapi_keyCode_t kMaxFunctionKey = BRLAPI_KEY_SYM_FUNCTION + 23;
29 29
30 // Maps the keyboard modifier flags to their corresponding flags in a 30 // Maps the keyboard modifier flags to their corresponding flags in a
31 // |KeyEvent|. 31 // |KeyEvent|.
32 void MapModifierFlags(brlapi_keyCode_t code, KeyEvent* event) { 32 void MapModifierFlags(brlapi_keyCode_t code, KeyEvent* event) {
33 if (code & BRLAPI_KEY_FLG_CONTROL) 33 if (code & BRLAPI_KEY_FLG_CONTROL)
34 event->ctrl_key.reset(new bool(true)); 34 event->ctrl_key.reset(new bool(true));
35 if (code & BRLAPI_KEY_FLG_META) 35 if (code & BRLAPI_KEY_FLG_META)
36 event->alt_key.reset(new bool(true)); 36 event->alt_key.reset(new bool(true));
37 if (code & BRLAPI_KEY_FLG_SHIFT) 37 if (code & BRLAPI_KEY_FLG_SHIFT)
38 event->shift_key.reset(new bool(true)); 38 event->shift_key.reset(new bool(true));
39 } 39 }
40 40
41 // Maps a brlapi keysym, which is similar to an X keysym into the 41 // Maps a brlapi keysym, which is similar to an X keysym into the
42 // provided event. 42 // provided event.
43 // See ui/events/keycodes/dom4/keycode_converter_data.cc for the full 43 // See ui/events/keycodes/dom/keycode_converter_data.cc for the full
44 // list of key codes. 44 // list of key codes.
45 void MapKeySym(brlapi_keyCode_t code, KeyEvent* event) { 45 void MapKeySym(brlapi_keyCode_t code, KeyEvent* event) {
46 brlapi_keyCode_t key_sym = code & BRLAPI_KEY_CODE_MASK; 46 brlapi_keyCode_t key_sym = code & BRLAPI_KEY_CODE_MASK;
47 if (key_sym < kMaxLatin1KeySym || 47 if (key_sym < kMaxLatin1KeySym ||
48 (key_sym & BRLAPI_KEY_SYM_UNICODE) != 0) { 48 (key_sym & BRLAPI_KEY_SYM_UNICODE) != 0) {
49 uint32 code_point = key_sym & ~BRLAPI_KEY_SYM_UNICODE; 49 uint32 code_point = key_sym & ~BRLAPI_KEY_SYM_UNICODE;
50 if (!base::IsValidCharacter(code_point)) 50 if (!base::IsValidCharacter(code_point))
51 return; 51 return;
52 event->standard_key_char.reset(new std::string); 52 event->standard_key_char.reset(new std::string);
53 base::WriteUnicodeCharacter(code_point, event->standard_key_char.get()); 53 base::WriteUnicodeCharacter(code_point, event->standard_key_char.get());
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 break; 162 break;
163 } 163 }
164 if (result->command == KEY_COMMAND_NONE) 164 if (result->command == KEY_COMMAND_NONE)
165 result.reset(); 165 result.reset();
166 return result.Pass(); 166 return result.Pass();
167 } 167 }
168 168
169 } // namespace braille_display_private 169 } // namespace braille_display_private
170 } // namespace api 170 } // namespace api
171 } // namespace extensions 171 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698