OLD | NEW |
---|---|
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 #ifndef UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_H_ | 5 #ifndef UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_H_ |
6 #define UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_H_ | 6 #define UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_H_ |
7 | 7 |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "ui/events/events_base_export.h" | 9 #include "ui/events/events_base_export.h" |
10 #include "ui/events/keycodes/keyboard_codes.h" | 10 #include "ui/events/keycodes/keyboard_codes.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 // For example, if a virtual keyboard implementation can only generate key | 21 // For example, if a virtual keyboard implementation can only generate key |
22 // events with key_code and flags information, then there is no way for us to | 22 // events with key_code and flags information, then there is no way for us to |
23 // determine the actual character that should be generate by the key. Because | 23 // determine the actual character that should be generate by the key. Because |
24 // a key_code only represents a physical key on the keyboard, it has nothing | 24 // a key_code only represents a physical key on the keyboard, it has nothing |
25 // to do with the actual character printed on that key. In such case, the only | 25 // to do with the actual character printed on that key. In such case, the only |
26 // thing we can do is to assume that we are using a US keyboard and get the | 26 // thing we can do is to assume that we are using a US keyboard and get the |
27 // character according to US keyboard layout definition. | 27 // character according to US keyboard layout definition. |
28 // If a virtual keyboard implementation wants to support other keyboard | 28 // If a virtual keyboard implementation wants to support other keyboard |
29 // layouts, that may generate different text for a certain key than on a US | 29 // layouts, that may generate different text for a certain key than on a US |
30 // keyboard, a special native event object should be introduced to carry extra | 30 // keyboard, a special native event object should be introduced to carry extra |
31 // information to help determine the correct character. | 31 // information to help determine the correct character. |
Wez
2015/01/17 02:06:47
nit: Skimming this comment block, it's not clear t
kpschoedel
2015/02/18 17:14:01
That dates to the original implementation of GetCh
Wez
2015/02/19 23:16:08
Acknowledged.
| |
32 // Take XKeyEvent as an example, it contains not only keycode and modifier | 32 // Take XKeyEvent as an example, it contains not only keycode and modifier |
33 // flags but also group and other extra XKB information to help determine the | 33 // flags but also group and other extra XKB information to help determine the |
34 // correct character. That's why we can use XLookupString() function to get | 34 // correct character. That's why we can use XLookupString() function to get |
35 // the correct text generated by a X key event (See how is GetCharacter() | 35 // the correct text generated by a X key event (See how is GetCharacter() |
36 // implemented in event_x.cc). | 36 // implemented in event_x.cc). |
kpschoedel
2015/01/14 21:00:32
A subsequent CL will remove the Get…FromKeyCode()
Wez
2015/01/17 02:06:47
+1 to the FooToBar() function names. :)
| |
37 EVENTS_BASE_EXPORT base::char16 GetCharacterFromKeyCode(KeyboardCode key_code, | 37 EVENTS_BASE_EXPORT base::char16 GetCharacterFromKeyCode(KeyboardCode key_code, |
38 int flags); | 38 int flags); |
39 EVENTS_BASE_EXPORT bool GetMeaningFromKeyCode(KeyboardCode key_code, | 39 EVENTS_BASE_EXPORT bool GetMeaningFromKeyCode(KeyboardCode key_code, |
Wez
2015/01/17 02:06:48
Suggest adding a comment to this w/ TODO(...) and
kpschoedel
2015/02/18 17:14:01
Done.
| |
40 int flags, | 40 int flags, |
41 DomKey* dom_key, | 41 DomKey* dom_key, |
42 base::char16* character); | 42 base::char16* character); |
43 EVENTS_BASE_EXPORT bool DomCodeToMeaning(DomCode dom_code, | |
44 int flags, | |
45 DomKey* dom_key, | |
46 base::char16* character, | |
47 KeyboardCode* key_code); | |
Wez
2015/01/17 02:06:47
Provide a brief comment documenting the in & out p
kpschoedel
2015/02/18 17:14:01
Done.
| |
48 | |
49 // Obtains the control character corresponding to a physical key. | |
Wez
2015/01/17 02:06:48
Need to clarify what you mean by "control characte
kpschoedel
2015/02/18 17:14:01
Yes, see below.
| |
50 // In some contexts this is used instead of the key layout. | |
Wez
2015/01/17 02:06:48
Why? What is the layout that this function applies
kpschoedel
2015/02/18 17:14:01
As far as I can tell from searching commits, this
Wez
2015/02/19 23:16:08
:( That sounds like something Gary may know more
| |
51 // Returns true and sets the output parameters if the (dom_code, flags) pair | |
52 // is interpreted as a control character. | |
Wez
2015/01/17 02:06:48
So this parameter _only_ succeeds if the supplied
kpschoedel
2015/02/18 17:14:01
Yes, commented.
| |
53 EVENTS_BASE_EXPORT bool DomCodeToControlCharacter( | |
54 DomCode dom_code, | |
55 int flags, | |
56 DomKey* dom_key, | |
57 base::char16* character, | |
58 KeyboardCode* key_code); | |
59 | |
60 // Returns a Windows-based VKEY for a non-printable DOM Level 3 |key|. | |
61 // The returned VKEY is non-located (e.g. VKEY_SHIFT). | |
62 EVENTS_BASE_EXPORT KeyboardCode | |
63 NonPrintableDomKeyToKeyboardCode(DomKey dom_key); | |
64 | |
65 // Returns the Windows-based VKEY value corresponding to a DOM Level 3 |code|. | |
66 // The returned VKEY is located (e.g. VKEY_LSHIFT). | |
67 EVENTS_BASE_EXPORT KeyboardCode DomCodeToKeyboardCode(DomCode dom_code); | |
Wez
2015/01/17 02:06:48
How does this behave for Numeric Keypad keys, whic
kpschoedel
2015/02/18 17:14:01
Does the modified comment help?
This is currently
| |
68 | |
69 // Returns the Windows-based VKEY value corresponding to a DOM Level 3 |code|. | |
70 // The returned VKEY is non-located (e.g. VKEY_SHIFT). | |
71 EVENTS_BASE_EXPORT KeyboardCode | |
72 DomCodeToNonLocatedKeyboardCode(DomCode dom_code); | |
Wez
2015/01/17 02:06:47
nit: Do you need this or could you just let the ca
kpschoedel
2015/02/18 17:14:01
Right, removed this.
| |
43 | 73 |
44 // Determine the non-located VKEY corresponding to a located VKEY. | 74 // Determine the non-located VKEY corresponding to a located VKEY. |
45 // Most modifier keys have two kinds of KeyboardCode: located (e.g. | 75 // Most modifier keys have two kinds of KeyboardCode: located (e.g. |
46 // VKEY_LSHIFT and VKEY_RSHIFT), that indentify one of two specific | 76 // VKEY_LSHIFT and VKEY_RSHIFT), that indentify one of two specific |
47 // physical keys, and non-located (e.g. VKEY_SHIFT) that identify | 77 // physical keys, and non-located (e.g. VKEY_SHIFT) that identify |
48 // only the operation. | 78 // only the operation. |
49 EVENTS_BASE_EXPORT KeyboardCode | 79 EVENTS_BASE_EXPORT KeyboardCode |
50 LocatedToNonLocatedKeyboardCode(KeyboardCode key_code); | 80 LocatedToNonLocatedKeyboardCode(KeyboardCode key_code); |
51 | 81 |
52 // Determine the located VKEY corresponding to a non-located VKEY. | 82 // Determine the located VKEY corresponding to a non-located VKEY. |
53 EVENTS_BASE_EXPORT KeyboardCode | 83 EVENTS_BASE_EXPORT KeyboardCode |
54 NonLocatedToLocatedKeyboardCode(KeyboardCode key_code, DomCode dom_code); | 84 NonLocatedToLocatedKeyboardCode(KeyboardCode key_code, DomCode dom_code); |
55 | 85 |
86 // Returns a DOM Level 3 |code| from a Windows-based VKEY value. | |
87 // This assumes a US layout and should only be used when |code| cannot be | |
88 // determined from a physical scan code. | |
Wez
2015/01/17 02:06:48
Do you mean "when a key event has no |code| value
kpschoedel
2015/02/18 17:14:01
At the moment this is used for the old constructor
Wez
2015/02/19 23:16:08
OK, cool. Would it cause a lot of churn to rename
kpschoedel
2015/04/10 18:32:33
Done.
| |
89 EVENTS_BASE_EXPORT DomCode KeyboardCodeToDomCode(KeyboardCode key_code); | |
90 | |
56 } // namespace ui | 91 } // namespace ui |
57 | 92 |
58 #endif // UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_H_ | 93 #endif // UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_H_ |
OLD | NEW |