OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_DOM4_KEYCODE_CONVERTER_H_ | 5 #ifndef UI_EVENTS_KEYCODES_DOM4_KEYCODE_CONVERTER_H_ |
6 #define UI_EVENTS_KEYCODES_DOM4_KEYCODE_CONVERTER_H_ | 6 #define UI_EVENTS_KEYCODES_DOM4_KEYCODE_CONVERTER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 | 10 |
11 // For reference, the W3C UI Event spec is located at: | 11 // For reference, the W3C UI Event spec is located at: |
12 // http://www.w3.org/TR/uievents/ | 12 // http://www.w3.org/TR/uievents/ |
13 | 13 |
14 namespace ui { | 14 namespace ui { |
15 | 15 |
16 enum class DomCode; | 16 enum class DomCode; |
17 enum class DomKey; | 17 enum class DomKey; |
18 | 18 |
19 enum class DomKeyLocation { STANDARD, LEFT, RIGHT, NUMPAD }; | |
20 | |
21 // This structure is used to define the keycode mapping table. | 19 // This structure is used to define the keycode mapping table. |
22 // It is defined here because the unittests need access to it. | 20 // It is defined here because the unittests need access to it. |
23 typedef struct { | 21 typedef struct { |
24 // USB keycode: | 22 // USB keycode: |
25 // Upper 16-bits: USB Usage Page. | 23 // Upper 16-bits: USB Usage Page. |
26 // Lower 16-bits: USB Usage Id: Assigned ID within this usage page. | 24 // Lower 16-bits: USB Usage Id: Assigned ID within this usage page. |
27 uint32_t usb_keycode; | 25 uint32_t usb_keycode; |
28 | 26 |
29 // Contains one of the following: | 27 // Contains one of the following: |
30 // On Linux: XKB scancode | 28 // On Linux: XKB scancode |
(...skipping 26 matching lines...) Expand all Loading... |
57 | 55 |
58 // Convert a DomCode into a native keycode. | 56 // Convert a DomCode into a native keycode. |
59 static int DomCodeToNativeKeycode(DomCode code); | 57 static int DomCodeToNativeKeycode(DomCode code); |
60 | 58 |
61 // Convert a UI Events |code| string value into a DomCode. | 59 // Convert a UI Events |code| string value into a DomCode. |
62 static DomCode CodeStringToDomCode(const char* code); | 60 static DomCode CodeStringToDomCode(const char* code); |
63 | 61 |
64 // Convert a DomCode into a UI Events |code| string value. | 62 // Convert a DomCode into a UI Events |code| string value. |
65 static const char* DomCodeToCodeString(DomCode dom_code); | 63 static const char* DomCodeToCodeString(DomCode dom_code); |
66 | 64 |
67 // Return the DomKeyLocation of a DomCode. The DomKeyLocation distinguishes | |
68 // keys with the same meaning, and therefore the same DomKey or KeyboardCode | |
69 // (VKEY), and corresponds to the DOM UI Events |KeyboardEvent.location|. | |
70 static DomKeyLocation DomCodeToLocation(DomCode dom_code); | |
71 | |
72 // Convert a UI Events |key| string value into a DomKey. | 65 // Convert a UI Events |key| string value into a DomKey. |
73 static DomKey KeyStringToDomKey(const char* key); | 66 static DomKey KeyStringToDomKey(const char* key); |
74 | 67 |
75 // Convert a DomKey into a UI Events |key| string value. | 68 // Convert a DomKey into a UI Events |key| string value. |
76 static const char* DomKeyToKeyString(DomKey dom_key); | 69 static const char* DomKeyToKeyString(DomKey dom_key); |
77 | 70 |
78 // The following methods relate to USB keycodes. | 71 // The following methods relate to USB keycodes. |
79 // Note that USB keycodes are not part of any web standard. | 72 // Note that USB keycodes are not part of any web standard. |
80 // Please don't use USB keycodes in new code. | 73 // Please don't use USB keycodes in new code. |
81 | 74 |
(...skipping 21 matching lines...) Expand all Loading... |
103 static const KeycodeMapEntry* GetKeycodeMapForTest(); | 96 static const KeycodeMapEntry* GetKeycodeMapForTest(); |
104 static const char* DomKeyStringForTest(size_t index); | 97 static const char* DomKeyStringForTest(size_t index); |
105 | 98 |
106 private: | 99 private: |
107 DISALLOW_COPY_AND_ASSIGN(KeycodeConverter); | 100 DISALLOW_COPY_AND_ASSIGN(KeycodeConverter); |
108 }; | 101 }; |
109 | 102 |
110 } // namespace ui | 103 } // namespace ui |
111 | 104 |
112 #endif // UI_EVENTS_KEYCODES_DOM4_KEYCODE_CONVERTER_H_ | 105 #endif // UI_EVENTS_KEYCODES_DOM4_KEYCODE_CONVERTER_H_ |
OLD | NEW |