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

Unified Diff: ui/events/keycodes/keyboard_code_conversion.cc

Issue 796003005: Located vs non-located ui::KeyboardCode functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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/keyboard_code_conversion.cc
diff --git a/ui/events/keycodes/keyboard_code_conversion.cc b/ui/events/keycodes/keyboard_code_conversion.cc
index 2d7e2a5a4f03ab2d9ad746835a448fb57c6ab581..0f85c3ecfeaf56b42dafab1703e83cc06ac4004f 100644
--- a/ui/events/keycodes/keyboard_code_conversion.cc
+++ b/ui/events/keycodes/keyboard_code_conversion.cc
@@ -5,6 +5,7 @@
#include "ui/events/keycodes/keyboard_code_conversion.h"
#include "ui/events/event_constants.h"
+#include "ui/events/keycodes/dom3/dom_code.h"
#include "ui/events/keycodes/dom3/dom_key.h"
namespace ui {
@@ -124,6 +125,11 @@ const struct KeyboardCodeToMeaning {
#endif
};
+bool IsRightSideDomCode(DomCode code) {
Wez 2015/01/10 02:06:28 Why are you treating the modifiers to an IsRightSi
kpschoedel 2015/01/12 16:34:06 IsRightSideDomCode() exists because |code| doesn't
Wez 2015/01/13 03:08:36 Acknowledged.
+ return (code == DomCode::SHIFT_RIGHT) || (code == DomCode::CONTROL_RIGHT) ||
+ (code == DomCode::ALT_RIGHT) || (code == DomCode::OS_RIGHT);
+}
+
} // anonymous namespace
base::char16 GetCharacterFromKeyCode(KeyboardCode key_code, int flags) {
@@ -261,4 +267,60 @@ bool GetMeaningFromKeyCode(KeyboardCode key_code,
return false;
}
+// Determine the non-located VKEY corresponding to a located VKEY.
kpschoedel 2015/01/09 20:25:40 This functionality, used by Ozone keyboard layout,
Wez 2015/01/13 03:08:36 Acknowledged.
+KeyboardCode LocatedToNonLocatedKeyboardCode(KeyboardCode key_code) {
Wez 2015/01/10 02:06:28 nit: Could/should this method output the Location
Wez 2015/01/10 02:06:28 Since you handle numeric pad keys in the reverse m
kpschoedel 2015/01/12 16:34:06 There is not currently a ui::Event-level analogue
kpschoedel 2015/01/12 16:34:06 I'll do that in a follow-up CL, since it's a behav
Wez 2015/01/13 03:08:36 Arguably not worth it unless we actually need it.
Wez 2015/01/13 03:08:36 Acknowledged.
kpschoedel 2015/01/13 16:21:08 This is mostly implemented and should trickle in t
+ switch (key_code) {
+ case VKEY_RWIN:
+ return VKEY_LWIN;
+ case VKEY_LSHIFT:
+ case VKEY_RSHIFT:
+ return VKEY_SHIFT;
+ case VKEY_LCONTROL:
+ case VKEY_RCONTROL:
+ return VKEY_CONTROL;
+ case VKEY_LMENU:
+ case VKEY_RMENU:
+ return VKEY_MENU;
+ default:
+ return key_code;
+ }
+}
+
+// Determine the located VKEY corresponding to a non-located VKEY.
+KeyboardCode NonLocatedToLocatedKeyboardCode(KeyboardCode key_code,
+ DomCode dom_code) {
+ switch (key_code) {
+ case VKEY_SHIFT:
+ return IsRightSideDomCode(dom_code) ? VKEY_RSHIFT : VKEY_LSHIFT;
+ case VKEY_CONTROL:
+ return IsRightSideDomCode(dom_code) ? VKEY_RCONTROL : VKEY_LCONTROL;
+ case VKEY_MENU:
+ return IsRightSideDomCode(dom_code) ? VKEY_RMENU : VKEY_LMENU;
+ case VKEY_LWIN:
+ return IsRightSideDomCode(dom_code) ? VKEY_RWIN : VKEY_LWIN;
+ case VKEY_0:
+ return (dom_code == DomCode::NUMPAD0) ? VKEY_NUMPAD0 : VKEY_0;
+ case VKEY_1:
+ return (dom_code == DomCode::NUMPAD1) ? VKEY_NUMPAD1 : VKEY_1;
+ case VKEY_2:
+ return (dom_code == DomCode::NUMPAD2) ? VKEY_NUMPAD2 : VKEY_2;
+ case VKEY_3:
+ return (dom_code == DomCode::NUMPAD3) ? VKEY_NUMPAD3 : VKEY_3;
+ case VKEY_4:
+ return (dom_code == DomCode::NUMPAD4) ? VKEY_NUMPAD4 : VKEY_4;
+ case VKEY_5:
+ return (dom_code == DomCode::NUMPAD5) ? VKEY_NUMPAD5 : VKEY_5;
+ case VKEY_6:
+ return (dom_code == DomCode::NUMPAD6) ? VKEY_NUMPAD6 : VKEY_6;
+ case VKEY_7:
+ return (dom_code == DomCode::NUMPAD7) ? VKEY_NUMPAD7 : VKEY_7;
+ case VKEY_8:
+ return (dom_code == DomCode::NUMPAD8) ? VKEY_NUMPAD8 : VKEY_8;
+ case VKEY_9:
+ return (dom_code == DomCode::NUMPAD9) ? VKEY_NUMPAD9 : VKEY_9;
+ default:
+ return key_code;
+ }
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698