Index: ui/events/keycodes/key_map_win.h |
diff --git a/ui/events/keycodes/key_map_win.h b/ui/events/keycodes/key_map_win.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4b0442b6d685dd93b25bccc4f722ebad89664665 |
--- /dev/null |
+++ b/ui/events/keycodes/key_map_win.h |
@@ -0,0 +1,54 @@ |
+// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_EVENTS_KEYCODES_KEY_MAP_WIN_H_ |
+#define UI_EVENTS_KEYCODES_KEY_MAP_WIN_H_ |
+ |
+#include <windows.h> |
+ |
+#include <unordered_map> |
+ |
+#include "base/hash.h" |
+#include "ui/events/events_base_export.h" |
+#include "ui/events/keycodes/dom/dom_key.h" |
+#include "ui/events/keycodes/keyboard_codes_win.h" |
+ |
+namespace ui { |
+ |
+enum class DomCode; |
+ |
+typedef std::unordered_map<std::pair<int /*DomCode*/, int /*EventFlags*/>, |
Wez
2016/02/11 23:14:45
Why use an int here rather than DomCode?
Feels li
|
+ DomKey, |
+ base::IntPairHash<std::pair<int, int>>> |
+ KeyMap; |
+ |
+class EVENTS_BASE_EXPORT WindowsKeyMap { |
Wez
2016/02/11 23:14:45
nit: Aside from the explicit HKL constructor, the
|
+ public: |
+ // Create and load key map table with specified keyboard layout. |
+ explicit WindowsKeyMap(HKL layout) : keyboard_layout_(0) { |
Wez
2016/02/11 23:14:45
As per style-guide, don't declare method bodies in
|
+ UpdateLayout(layout); |
+ } |
+ |
+ // Convert a DomCode + flags to a DomKey for layout specified in constructor. |
+ DomKey DomCodeAndFlagsToDomKey(DomCode code, int flags /*EventFlags*/) const; |
+ |
+ // Convert a DomCode + flags to a DomKey using the layout for current thread. |
+ // Will load/update key map table in first call or when layout has changed. |
+ static DomKey DomCodeAndFlagsToDomKeyStatic(DomCode code, |
+ int flags /*EventFlags*/); |
Wez
2016/02/11 23:14:45
I'd suggest renaming flags -> event_flags or even
|
+ |
+ private: |
+ WindowsKeyMap() : keyboard_layout_(0) {} |
Wez
2016/02/11 23:14:45
See above re inlining.
|
+ |
+ void UpdateLayout(HKL layout); |
+ |
+ HKL keyboard_layout_; |
Wez
2016/02/11 23:14:45
This can use C++11 inline initialization:
HKL k
|
+ KeyMap key_map_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WindowsKeyMap); |
+}; |
+ |
+} // namespace ui |
+ |
+#endif // UI_EVENTS_KEYCODES_KEY_MAP_WIN_H_ |