Commit 6ed9953a authored by Mike Wiitala's avatar Mike Wiitala Committed by Commit Bot

Chrome OS: Update event rewriter for Drallion keyboard layout

The Drallion (Wilco 1.5) keyboard has a slightly different layout than
Wilco 1.0:

1. The toggle mirror mode button has moved from F12 to its own key
without a corresponding F key.
2. F12 now shares a key with privacy screen toggle on devices with a
privacy screen.

BUG=b:147241224
TEST=build and deploy chrome to a Drallion DUT:
autoninja -C out_drallion/Release chrome chrome_sandbox nacl_helper;
deploy_chrome --build-dir=out_drallion/Release --to={DUT_IP};

Verify that top row keys map to expected key codes:
Privacy Screen -> VKEY_PRIVACY_SCREEN_TOGGLE
Privacy Screen + Fn -> VKEY_F12
Privacy Screen + Search -> VKEY_F12
Privacy Screen + Fn + Search -> VKEY_PRIVACY_SCREEN_TOGGLE

Mirror toggle key always maps to VKEY_MEDIA_LAUNCH_APP2 with Control
held down, regardless of Fn and Search key states.

Change-Id: I8df3d28d7ea9445d736ec831b4423f2c224dd592
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2008063
Commit-Queue: Mike Wiitala <mwiitala@google.com>
Reviewed-by: default avatarKevin Schoedel <kpschoedel@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734219}
parent 719db867
...@@ -1157,8 +1157,9 @@ void EventRewriterChromeOS::RewriteFunctionKeys(const ui::KeyEvent& key_event, ...@@ -1157,8 +1157,9 @@ void EventRewriterChromeOS::RewriteFunctionKeys(const ui::KeyEvent& key_event,
} }
const bool search_is_pressed = (state->flags & ui::EF_COMMAND_DOWN) != 0; const bool search_is_pressed = (state->flags & ui::EF_COMMAND_DOWN) != 0;
if (layout == kKbdTopRowLayoutWilco) { if (layout == kKbdTopRowLayoutWilco || layout == kKbdTopRowLayoutDrallion) {
if (RewriteTopRowKeysForLayoutWilco(key_event, search_is_pressed, state)) { if (RewriteTopRowKeysForLayoutWilco(key_event, search_is_pressed, state,
layout)) {
return; return;
} }
} else if ((state->key_code >= ui::VKEY_F1) && } else if ((state->key_code >= ui::VKEY_F1) &&
...@@ -1480,7 +1481,8 @@ void EventRewriterChromeOS::RewriteKeyEventInContext( ...@@ -1480,7 +1481,8 @@ void EventRewriterChromeOS::RewriteKeyEventInContext(
bool EventRewriterChromeOS::RewriteTopRowKeysForLayoutWilco( bool EventRewriterChromeOS::RewriteTopRowKeysForLayoutWilco(
const ui::KeyEvent& key_event, const ui::KeyEvent& key_event,
bool search_is_pressed, bool search_is_pressed,
ui::EventRewriterChromeOS::MutableKeyState* state) { ui::EventRewriterChromeOS::MutableKeyState* state,
KeyboardTopRowLayout layout) {
// When the kernel issues an function key (Fn modifier help down) and the // When the kernel issues an function key (Fn modifier help down) and the
// search key is pressed, the function key needs to be mapped to its // search key is pressed, the function key needs to be mapped to its
// corresponding action key. This table defines those function-to-action // corresponding action key. This table defines those function-to-action
...@@ -1556,6 +1558,9 @@ bool EventRewriterChromeOS::RewriteTopRowKeysForLayoutWilco( ...@@ -1556,6 +1558,9 @@ bool EventRewriterChromeOS::RewriteTopRowKeysForLayoutWilco(
{ui::EF_NONE, ui::DomCode::F12, ui::DomKey::F12, ui::VKEY_F12}}, {ui::EF_NONE, ui::DomCode::F12, ui::DomKey::F12, ui::VKEY_F12}},
{{ui::EF_NONE, ui::VKEY_MEDIA_LAUNCH_APP2}, {{ui::EF_NONE, ui::VKEY_MEDIA_LAUNCH_APP2},
{ui::EF_NONE, ui::DomCode::F3, ui::DomKey::F3, ui::VKEY_F3}}, {ui::EF_NONE, ui::DomCode::F3, ui::DomKey::F3, ui::VKEY_F3}},
// VKEY_PRIVACY_SCREEN_TOGGLE shares a key with F12 on Drallion.
{{ui::EF_NONE, ui::VKEY_PRIVACY_SCREEN_TOGGLE},
{ui::EF_NONE, ui::DomCode::F12, ui::DomKey::F12, ui::VKEY_F12}},
}; };
ui::EventRewriterChromeOS::MutableKeyState incoming_without_command = *state; ui::EventRewriterChromeOS::MutableKeyState incoming_without_command = *state;
...@@ -1565,6 +1570,16 @@ bool EventRewriterChromeOS::RewriteTopRowKeysForLayoutWilco( ...@@ -1565,6 +1570,16 @@ bool EventRewriterChromeOS::RewriteTopRowKeysForLayoutWilco(
// Incoming key code is a Fn key. Check if it needs to be mapped back to its // Incoming key code is a Fn key. Check if it needs to be mapped back to its
// corresponding action key. // corresponding action key.
if (search_is_pressed) { if (search_is_pressed) {
// On Drallion, F12 shares a key with privacy screen toggle. Account for
// this before rewriting for Wilco 1.0 layout.
if (layout == kKbdTopRowLayoutDrallion &&
state->key_code == ui::VKEY_F12) {
state->key_code = ui::VKEY_PRIVACY_SCREEN_TOGGLE;
state->code = DomCode::PRIVACY_SCREEN_TOGGLE;
// Clear command flag before returning
state->flags = (state->flags & ~ui::EF_COMMAND_DOWN);
return true;
}
return RewriteWithKeyboardRemappings(kFnkeysToActionKeys, return RewriteWithKeyboardRemappings(kFnkeysToActionKeys,
base::size(kFnkeysToActionKeys), base::size(kFnkeysToActionKeys),
incoming_without_command, state); incoming_without_command, state);
...@@ -1575,11 +1590,18 @@ bool EventRewriterChromeOS::RewriteTopRowKeysForLayoutWilco( ...@@ -1575,11 +1590,18 @@ bool EventRewriterChromeOS::RewriteTopRowKeysForLayoutWilco(
// Incoming key code is an action key. Check if it needs to be mapped back // Incoming key code is an action key. Check if it needs to be mapped back
// to its corresponding function key. // to its corresponding function key.
if (search_is_pressed != ForceTopRowAsFunctionKeys()) { if (search_is_pressed != ForceTopRowAsFunctionKeys()) {
// On Drallion, mirror mode toggle is on its own key so don't remap it.
if (layout == kKbdTopRowLayoutDrallion &&
MatchKeyboardRemapping(
*state, {ui::EF_CONTROL_DOWN, ui::VKEY_MEDIA_LAUNCH_APP2})) {
// Clear command flag before returning
state->flags = (state->flags & ~ui::EF_COMMAND_DOWN);
return true;
}
return RewriteWithKeyboardRemappings(kActionToFnKeys, return RewriteWithKeyboardRemappings(kActionToFnKeys,
base::size(kActionToFnKeys), base::size(kActionToFnKeys),
incoming_without_command, state); incoming_without_command, state);
} }
// At this point we know search_is_pressed == ForceTopRowAsFunctionKeys(). // At this point we know search_is_pressed == ForceTopRowAsFunctionKeys().
// If they're both true, they cancel each other. Thus we can clear the // If they're both true, they cancel each other. Thus we can clear the
// search-key modifier flag. // search-key modifier flag.
......
...@@ -61,10 +61,11 @@ class EventRewriterChromeOS : public ui::EventRewriter { ...@@ -61,10 +61,11 @@ class EventRewriterChromeOS : public ui::EventRewriter {
kKbdTopRowLayout2 = 2, kKbdTopRowLayout2 = 2,
// Keyboard layout and handling for Wilco. // Keyboard layout and handling for Wilco.
kKbdTopRowLayoutWilco = 3, kKbdTopRowLayoutWilco = 3,
kKbdTopRowLayoutDrallion = 4,
kKbdTopRowLayoutDefault = kKbdTopRowLayout1, kKbdTopRowLayoutDefault = kKbdTopRowLayout1,
kKbdTopRowLayoutMin = kKbdTopRowLayout1, kKbdTopRowLayoutMin = kKbdTopRowLayout1,
kKbdTopRowLayoutMax = kKbdTopRowLayoutWilco kKbdTopRowLayoutMax = kKbdTopRowLayoutDrallion
}; };
// Things that keyboard-related rewriter phases can change about an Event. // Things that keyboard-related rewriter phases can change about an Event.
...@@ -248,7 +249,8 @@ class EventRewriterChromeOS : public ui::EventRewriter { ...@@ -248,7 +249,8 @@ class EventRewriterChromeOS : public ui::EventRewriter {
bool RewriteTopRowKeysForLayoutWilco( bool RewriteTopRowKeysForLayoutWilco(
const ui::KeyEvent& key_event, const ui::KeyEvent& key_event,
bool search_is_pressed, bool search_is_pressed,
ui::EventRewriterChromeOS::MutableKeyState* state); ui::EventRewriterChromeOS::MutableKeyState* state,
KeyboardTopRowLayout layout);
// Take the keys being pressed into consideration, in contrast to // Take the keys being pressed into consideration, in contrast to
// RewriteKeyEvent which computes the rewritten event and event rewrite // RewriteKeyEvent which computes the rewritten event and event rewrite
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment