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..3abd242b0690407196ea233256a3d8ab1cb5891d |
--- /dev/null |
+++ b/ui/events/keycodes/key_map_win.h |
@@ -0,0 +1,53 @@ |
+// 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*/>, |
+ DomKey, |
+ base::IntPairHash<std::pair<int, int>>> |
+ KeyMap; |
chongz
2016/02/10 01:25:10
Currently only store DomCode+flags => DomKey, will
|
+ |
+class EVENTS_BASE_EXPORT WindowsKeyMap { |
+ public: |
+ // Create and load key map table with specified keyboard layout. |
+ explicit WindowsKeyMap(HKL layout) : keyboard_layout_(0) { |
+ UpdateLayout(layout); |
+ } |
+ |
+ // Convert a DomCode + flags to a DomKey for layout specified in constructor. |
+ DomKey DomCodeAndFlagsToKey(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 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
|
+ |
+ private: |
+ WindowsKeyMap() : keyboard_layout_(0) {} |
+ |
+ void UpdateLayout(HKL layout); |
+ |
+ HKL keyboard_layout_; |
+ KeyMap key_map_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WindowsKeyMap); |
+}; |
+ |
+} // namespace ui |
+ |
+#endif // UI_EVENTS_KEYCODES_KEY_MAP_WIN_H_ |