Index: ui/events/keycodes/keyboard_lookup_win.h |
diff --git a/ui/events/keycodes/keyboard_lookup_win.h b/ui/events/keycodes/keyboard_lookup_win.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7e689fe809995c5883ca840f9c0b033f6f592e22 |
--- /dev/null |
+++ b/ui/events/keycodes/keyboard_lookup_win.h |
@@ -0,0 +1,41 @@ |
+// 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_KEYBOARD_LOOKUP_WIN_H_ |
+#define UI_EVENTS_KEYCODES_KEYBOARD_LOOKUP_WIN_H_ |
+ |
+#include <windows.h> |
+ |
+#include "ui/events/event_constants.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 { |
+ |
+class EVENTS_BASE_EXPORT WindowsKeyboardLookup { |
Wez
2016/01/29 00:22:24
This class encapsulates the key-map, in effect - c
chongz
2016/01/29 20:25:49
Acknowledged.
|
+ public: |
+ WindowsKeyboardLookup(HKL alayout); |
Wez
2016/01/29 00:22:24
explicit
chongz
2016/01/29 20:25:49
Acknowledged.
|
+ |
+ static DomKey VirtualKeyToCurrentLayoutDomKey(KeyboardCode vkcode, |
+ int event_flags); |
+ DomKey VirtualKeyToDomKey(KeyboardCode vkcode, int event_flags) const; |
Wez
2016/01/29 00:22:24
nit: Please add brief comments to explain why we h
dtapuska
2016/01/29 17:05:48
Ok I do see how we can make this as an API that ma
chongz
2016/01/29 20:25:50
The static function VirtualKeyToCurrentLayoutDomKe
chongz
2016/02/02 21:14:04
Changed it to DomCodeToKey(), also added DomCodeTo
|
+ |
+ static WindowsKeyboardLookup s_instance; |
dtapuska
2016/01/28 15:27:55
I'd define this static inside the VirtualKeyToCurr
chongz
2016/01/29 20:25:49
Acknowledged.
|
+ |
+ private: |
+ WindowsKeyboardLookup(); |
+ |
+ void CheckOrLoadLayout(HKL alayout); |
Wez
2016/01/29 00:22:24
nit: Why |alayout| rather than |layout|?
Why is t
chongz
2016/01/29 20:25:50
It will load layout only when it's different from
|
+ |
+ static const size_t kMaxVirtualKeyCode = 256; |
Wez
2016/01/29 00:22:24
nit: This isn't the maximum virtual key code value
chongz
2016/01/29 20:25:50
Acknowledged.
|
+ static const size_t kMaxKeyboardModifier = 1 << 8; |
Wez
2016/01/29 00:22:24
nit: This isn't the maximum modifier, it's the num
chongz
2016/01/29 20:25:50
Acknowledged.
|
+ |
+ HKL keyboard_layout_; |
+ DomKey lookup_table_[kMaxVirtualKeyCode][kMaxKeyboardModifier]; |
Wez
2016/01/29 00:22:24
This means we're creating a table with 256*256 ent
chongz
2016/01/29 20:25:50
Yes it's too large. I guess for each DomCode I can
chongz
2016/02/02 21:14:04
Switched to the sparse map and ignored EF_COMMAND_
|
+}; |
Wez
2016/01/29 00:22:24
DISALLOW_COPY_AND_ASSIGN() on this class.
chongz
2016/01/29 20:25:50
Acknowledged.
|
+ |
+} // namespace ui |
+ |
+#endif // UI_EVENTS_KEYCODES_KEYBOARD_LOOKUP_WIN_H_ |