Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_EVENTS_KEYCODES_KEY_MAP_WIN_H_ | |
| 6 #define UI_EVENTS_KEYCODES_KEY_MAP_WIN_H_ | |
| 7 | |
| 8 #include <windows.h> | |
| 9 | |
| 10 #include <map> | |
| 11 | |
| 12 #include "base/lazy_instance.h" | |
| 13 #include "ui/events/events_base_export.h" | |
| 14 #include "ui/events/keycodes/dom/dom_key.h" | |
| 15 #include "ui/events/keycodes/keyboard_codes_win.h" | |
| 16 | |
| 17 namespace ui { | |
| 18 | |
| 19 enum class DomCode; | |
| 20 | |
| 21 struct KeyMapEntry { | |
| 22 DomCode code; | |
|
dtapuska
2016/02/04 20:31:45
Why is code required here?
| |
| 23 DomKey key; | |
| 24 KeyboardCode legacy_key_code; | |
|
dtapuska
2016/02/04 20:31:46
I question storing this field whether it is requir
| |
| 25 int flags; | |
| 26 }; | |
| 27 typedef std::map<std::pair<DomCode, int /*flags*/>, KeyMapEntry> KeyMap; | |
|
dtapuska
2016/02/04 20:31:46
can we get away with an unordered_map?
chongz
2016/02/04 21:10:25
Not sure which one is better, the map will usually
Wez
2016/02/09 00:18:57
Unless we need ordering, and I don't think we do,
| |
| 28 | |
| 29 class EVENTS_BASE_EXPORT WindowsKeyMap { | |
| 30 public: | |
| 31 // Create and load key map table with specified keyboard layout. | |
| 32 explicit WindowsKeyMap(HKL layout); | |
| 33 | |
| 34 // Convert a DomCode to a DomKey for the layout specified in constructor. | |
|
dtapuska
2016/02/04 20:31:45
We ideally should identify what |flags| are..
chongz
2016/02/04 21:10:25
Ya I will add comment about EventFlags here
| |
| 35 DomKey DomCodeToKey(DomCode code, int flags) const; | |
| 36 | |
| 37 // Convert a DomCode to a legacy KeyboardCode. | |
| 38 KeyboardCode DomCodeToKeyboardCode(DomCode code) const; | |
|
Wez
2016/02/09 00:18:57
Don't we need |flags| passing in to this? e.g. the
| |
| 39 | |
| 40 // Convert a legacy KeyboardCode to DomCode. | |
| 41 DomCode KeyboardCodeToDomCode(KeyboardCode key_code) const; | |
|
Wez
2016/02/09 00:18:57
Is this used anywhere other than the test? If it's
| |
| 42 | |
| 43 // Convert a DomCode to a DomKey for current system keyboard layout. | |
| 44 // Will reload key map table if the system layout has changed. | |
| 45 static DomKey DomCodeToSystemLayoutKey(DomCode code, int flags); | |
| 46 | |
| 47 private: | |
| 48 friend struct base::DefaultLazyInstanceTraits<WindowsKeyMap>; | |
| 49 | |
| 50 WindowsKeyMap(); | |
| 51 | |
| 52 void LoadLayout(HKL layout); | |
|
Wez
2016/02/09 00:18:57
nit: Rename this UpdateLayout() and have it check
| |
| 53 void AddKeyMapEntry(DomCode code, | |
| 54 DomKey key, | |
| 55 KeyboardCode legacy_key_code, | |
| 56 int flags); | |
| 57 | |
| 58 HKL keyboard_layout_; | |
| 59 KeyMap key_map_; | |
| 60 | |
| 61 DISALLOW_COPY_AND_ASSIGN(WindowsKeyMap); | |
| 62 }; | |
| 63 | |
| 64 } // namespace ui | |
| 65 | |
| 66 #endif // UI_EVENTS_KEYCODES_KEY_MAP_WIN_H_ | |
| OLD | NEW |