| 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 |
| 19 // This structure is used to define the keycode mapping table. | 21 // This structure is used to define the keycode mapping table. |
| 20 // It is defined here because the unittests need access to it. | 22 // It is defined here because the unittests need access to it. |
| 21 typedef struct { | 23 typedef struct { |
| 22 // USB keycode: | 24 // USB keycode: |
| 23 // Upper 16-bits: USB Usage Page. | 25 // Upper 16-bits: USB Usage Page. |
| 24 // Lower 16-bits: USB Usage Id: Assigned ID within this usage page. | 26 // Lower 16-bits: USB Usage Id: Assigned ID within this usage page. |
| 25 uint32_t usb_keycode; | 27 uint32_t usb_keycode; |
| 26 | 28 |
| 27 // Contains one of the following: | 29 // Contains one of the following: |
| 28 // On Linux: XKB scancode | 30 // On Linux: XKB scancode |
| (...skipping 26 matching lines...) Expand all Loading... |
| 55 | 57 |
| 56 // Convert a DomCode into a native keycode. | 58 // Convert a DomCode into a native keycode. |
| 57 static int DomCodeToNativeKeycode(DomCode code); | 59 static int DomCodeToNativeKeycode(DomCode code); |
| 58 | 60 |
| 59 // Convert a UI Events |code| string value into a DomCode. | 61 // Convert a UI Events |code| string value into a DomCode. |
| 60 static DomCode CodeStringToDomCode(const char* code); | 62 static DomCode CodeStringToDomCode(const char* code); |
| 61 | 63 |
| 62 // Convert a DomCode into a UI Events |code| string value. | 64 // Convert a DomCode into a UI Events |code| string value. |
| 63 static const char* DomCodeToCodeString(DomCode dom_code); | 65 static const char* DomCodeToCodeString(DomCode dom_code); |
| 64 | 66 |
| 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 |
| 65 // Convert a UI Events |key| string value into a DomKey. | 72 // Convert a UI Events |key| string value into a DomKey. |
| 66 static DomKey KeyStringToDomKey(const char* key); | 73 static DomKey KeyStringToDomKey(const char* key); |
| 67 | 74 |
| 68 // Convert a DomKey into a UI Events |key| string value. | 75 // Convert a DomKey into a UI Events |key| string value. |
| 69 static const char* DomKeyToKeyString(DomKey dom_key); | 76 static const char* DomKeyToKeyString(DomKey dom_key); |
| 70 | 77 |
| 71 // The following methods relate to USB keycodes. | 78 // The following methods relate to USB keycodes. |
| 72 // Note that USB keycodes are not part of any web standard. | 79 // Note that USB keycodes are not part of any web standard. |
| 73 // Please don't use USB keycodes in new code. | 80 // Please don't use USB keycodes in new code. |
| 74 | 81 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 96 static const KeycodeMapEntry* GetKeycodeMapForTest(); | 103 static const KeycodeMapEntry* GetKeycodeMapForTest(); |
| 97 static const char* DomKeyStringForTest(size_t index); | 104 static const char* DomKeyStringForTest(size_t index); |
| 98 | 105 |
| 99 private: | 106 private: |
| 100 DISALLOW_COPY_AND_ASSIGN(KeycodeConverter); | 107 DISALLOW_COPY_AND_ASSIGN(KeycodeConverter); |
| 101 }; | 108 }; |
| 102 | 109 |
| 103 } // namespace ui | 110 } // namespace ui |
| 104 | 111 |
| 105 #endif // UI_EVENTS_KEYCODES_DOM4_KEYCODE_CONVERTER_H_ | 112 #endif // UI_EVENTS_KEYCODES_DOM4_KEYCODE_CONVERTER_H_ |
| OLD | NEW |