Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Unified Diff: ui/events/keycodes/key_map_win.h

Issue 1585193002: Build key map DomCodeToKey() for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wez's review Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3ddb9cabd1af93a33fca5cc32c1e0bac5bbed6e1
--- /dev/null
+++ b/ui/events/keycodes/key_map_win.h
@@ -0,0 +1,66 @@
+// 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 <map>
+
+#include "base/lazy_instance.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;
+
+struct KeyMapEntry {
+ DomCode code;
dtapuska 2016/02/04 20:31:45 Why is code required here?
+ DomKey key;
+ KeyboardCode legacy_key_code;
dtapuska 2016/02/04 20:31:46 I question storing this field whether it is requir
+ int flags;
+};
+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,
+
+class EVENTS_BASE_EXPORT WindowsKeyMap {
+ public:
+ // Create and load key map table with specified keyboard layout.
+ explicit WindowsKeyMap(HKL layout);
+
+ // 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
+ DomKey DomCodeToKey(DomCode code, int flags) const;
+
+ // Convert a DomCode to a legacy KeyboardCode.
+ KeyboardCode DomCodeToKeyboardCode(DomCode code) const;
Wez 2016/02/09 00:18:57 Don't we need |flags| passing in to this? e.g. the
+
+ // Convert a legacy KeyboardCode to DomCode.
+ DomCode KeyboardCodeToDomCode(KeyboardCode key_code) const;
Wez 2016/02/09 00:18:57 Is this used anywhere other than the test? If it's
+
+ // Convert a DomCode to a DomKey for current system keyboard layout.
+ // Will reload key map table if the system layout has changed.
+ static DomKey DomCodeToSystemLayoutKey(DomCode code, int flags);
+
+ private:
+ friend struct base::DefaultLazyInstanceTraits<WindowsKeyMap>;
+
+ WindowsKeyMap();
+
+ void LoadLayout(HKL layout);
Wez 2016/02/09 00:18:57 nit: Rename this UpdateLayout() and have it check
+ void AddKeyMapEntry(DomCode code,
+ DomKey key,
+ KeyboardCode legacy_key_code,
+ int flags);
+
+ HKL keyboard_layout_;
+ KeyMap key_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowsKeyMap);
+};
+
+} // namespace ui
+
+#endif // UI_EVENTS_KEYCODES_KEY_MAP_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698