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 <unordered_map> | |
11 | |
12 #include "base/hash.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 typedef std::unordered_map<std::pair<int /*DomCode*/, int /*EventFlags*/>, | |
22 DomKey, | |
23 base::IntPairHash<std::pair<int, int>>> | |
24 KeyMap; | |
chongz
2016/02/10 01:25:10
Currently only store DomCode+flags => DomKey, will
| |
25 | |
26 class EVENTS_BASE_EXPORT WindowsKeyMap { | |
27 public: | |
28 // Create and load key map table with specified keyboard layout. | |
29 explicit WindowsKeyMap(HKL layout) : keyboard_layout_(0) { | |
30 UpdateLayout(layout); | |
31 } | |
32 | |
33 // Convert a DomCode + flags to a DomKey for layout specified in constructor. | |
34 DomKey DomCodeAndFlagsToKey(DomCode code, int flags /*EventFlags*/) const; | |
35 | |
36 // Convert a DomCode + flags to a DomKey using the layout for current thread. | |
37 // Will load/update key map table in first call or when layout has changed. | |
38 static DomKey CodeAndFlagsToDomKey(DomCode code, int flags /*EventFlags*/); | |
chongz
2016/02/10 01:25:10
I'm not sure how to name the above two functions..
dtapuska
2016/02/10 21:56:34
Personally I'd name it DomCodeAndFlagsToDomKey
and
| |
39 | |
40 private: | |
41 WindowsKeyMap() : keyboard_layout_(0) {} | |
42 | |
43 void UpdateLayout(HKL layout); | |
44 | |
45 HKL keyboard_layout_; | |
46 KeyMap key_map_; | |
47 | |
48 DISALLOW_COPY_AND_ASSIGN(WindowsKeyMap); | |
49 }; | |
50 | |
51 } // namespace ui | |
52 | |
53 #endif // UI_EVENTS_KEYCODES_KEY_MAP_WIN_H_ | |
OLD | NEW |