Commit 80a5d0c4 authored by Wez's avatar Wez Committed by Commit Bot

[fuchsia][events] Define DomCode to native_keycode mapping.

- Define non-zero native_keycode values under Fuchsia, derived from the
  USB Usage Code, for keys in the Keyboard Page.
- Migrate the InputEventDispatcher for Fuchsia to use the native-to-
  DomCode conversion API.
- Fix KeycodeConverter preprocessor checks around the DOM_CODE()
  definitions to #error on unsupported platforms.

events_unittests will be enabled under Fuchsia in a follow-up CL.

Bug: 829551
Change-Id: Ia34beec8b0376980e8f599266df233f6c27cc268
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2020771
Commit-Queue: Wez <wez@chromium.org>
Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Auto-Submit: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735955}
parent 380c2759
......@@ -15,8 +15,6 @@
namespace ui {
namespace {
const uint32_t kUsbHidKeyboardPage = 0x07;
int KeyModifiersToFlags(int modifiers) {
int flags = 0;
if (modifiers & fuchsia::ui::input::kModifierShift)
......@@ -167,11 +165,7 @@ bool InputEventDispatcher::ProcessKeyboardEvent(
break;
}
// Currently KeyboardEvent doesn't specify HID Usage page. |hid_usage|
// field always contains values from the Keyboard page. See
// https://fuchsia.atlassian.net/browse/SCN-762 .
DomCode dom_code = KeycodeConverter::UsbKeycodeToDomCode(
(kUsbHidKeyboardPage << 16) | event.hid_usage);
DomCode dom_code = KeycodeConverter::NativeKeycodeToDomCode(event.hid_usage);
DomKey dom_key;
KeyboardCode key_code;
if (!DomCodeToUsLayoutDomKey(dom_code, KeyModifiersToFlags(event.modifiers),
......
......@@ -29,9 +29,20 @@ namespace {
#elif defined(OS_ANDROID)
#define DOM_CODE(usb, evdev, xkb, win, mac, code, id) \
{ usb, evdev, code }
#else
#elif defined(OS_FUCHSIA)
// TODO(https://bugs.fuchsia.com/23982): Fuchsia currently delivers events
// with a USB Code but no Page specified, so only map |native_keycode| for
// Keyboard Usage Page codes, for now.
inline constexpr uint32_t CodeIfOnKeyboardPage(uint32_t usage) {
constexpr uint32_t kUsbHidKeyboardPageBase = 0x070000;
if ((usage & 0xffff0000) == kUsbHidKeyboardPageBase)
return usage & 0xffff;
return 0;
}
#define DOM_CODE(usb, evdev, xkb, win, mac, code, id) \
{ usb, 0, code }
{ usb, CodeIfOnKeyboardPage(usb), code }
#else
#error Unsupported platform
#endif
#define DOM_CODE_DECLARATION const KeycodeMapEntry kDomCodeMappings[] =
#include "ui/events/keycodes/dom/dom_code_data.inc"
......
......@@ -33,6 +33,7 @@ typedef struct {
// On Linux: XKB scancode
// On Windows: Windows OEM scancode
// On Mac: Mac keycode
// On Fuchsia: 16-bit Code from the USB Keyboard Usage Page.
int native_keycode;
// The UIEvents (aka: DOM4Events) |code| value as defined in:
......
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