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_PLATFORM_KEY_MAP_WIN_H_ | |
6 #define UI_EVENTS_KEYCODES_PLATFORM_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 class EVENTS_BASE_EXPORT PlatformKeyMap { | |
chongz
2016/02/12 16:04:03
Currently other platforms have their own way of ge
| |
22 public: | |
23 // Create and load key map table with specified keyboard layout. | |
24 explicit PlatformKeyMap(HKL layout); | |
25 | |
26 // Returns the DomKey 'meaning' of |code| in the context of specified | |
27 // |ui_event_flags| and stored keyboard layout. | |
28 DomKey DomCodeAndFlagsToDomKey(DomCode code, | |
29 int ui_event_flags /*EventFlags*/) const; | |
Wez
2016/02/12 21:29:38
nit: No need for the EventFlags comment.
| |
30 | |
31 // Returns the DomKey 'meaning' of |code| in the context of specified | |
32 // |ui_event_flags| and the keyboard layout of current thread. | |
33 // Will load/update key map table when: | |
34 // 1. First call to this method. | |
35 // 2. Or keyboard layout of current thread was changed. | |
Wez
2016/02/12 21:29:38
nit: Suggest replacing lines 3-5 with just:
" // U
| |
36 static DomKey DomCodeAndFlagsToDomKeyStatic( | |
37 DomCode code, | |
38 int ui_event_flags /*EventFlags*/); | |
Wez
2016/02/12 21:29:37
nit: No need for the EventFlags comment here, plea
| |
39 | |
40 private: | |
41 PlatformKeyMap(); | |
42 | |
43 void UpdateLayout(HKL layout); | |
44 | |
45 HKL keyboard_layout_ = 0; | |
46 | |
47 typedef std::pair<DomCode, int /*EventFlags*/> DomCodeEventFlagsPair; | |
48 struct DomCodeEventFlagsPairHash { | |
chongz
2016/02/12 16:04:03
Have to do this because we only have PairHash for
Wez
2016/02/12 21:29:38
So ugly! OK... how about using std::pair<int,int>
| |
49 size_t operator()(DomCodeEventFlagsPair code_flags) const { | |
50 return base::HashInts(static_cast<int>(code_flags.first), | |
51 code_flags.second); | |
52 } | |
53 }; | |
54 typedef std::unordered_map<DomCodeEventFlagsPair, | |
55 DomKey, | |
56 DomCodeEventFlagsPairHash> | |
57 DomCodeToKeyMap; | |
58 DomCodeToKeyMap code_key_map_; | |
Wez
2016/02/12 21:29:38
nit: Suggest calling this code_to_key_map_ or just
| |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(PlatformKeyMap); | |
61 }; | |
62 | |
63 } // namespace ui | |
64 | |
65 #endif // UI_EVENTS_KEYCODES_PLATFORM_KEY_MAP_WIN_H_ | |
OLD | NEW |