| Index: webkit/plugins/ppapi/usb_key_code_conversion_linux.cc
|
| diff --git a/webkit/plugins/ppapi/usb_key_code_conversion_linux.cc b/webkit/plugins/ppapi/usb_key_code_conversion_linux.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f10238d2d3fb56546cb3a9a22aa93213117b0e17
|
| --- /dev/null
|
| +++ b/webkit/plugins/ppapi/usb_key_code_conversion_linux.cc
|
| @@ -0,0 +1,89 @@
|
| +// Copyright (c) 2012 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.
|
| +
|
| +#include "webkit/plugins/ppapi/usb_key_code_conversion.h"
|
| +
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
|
| +
|
| +using WebKit::WebKeyboardEvent;
|
| +
|
| +namespace webkit {
|
| +namespace ppapi {
|
| +
|
| +namespace {
|
| +
|
| +// TODO(garykac): This table covers only USB HID Boot Protocol. It should be
|
| +// extended (e.g. with "media keys"), or derived automatically from the
|
| +// evdev USB-to-linux keycode mapping.
|
| +uint16_t linux_evdev_key_code_to_usb[256] = {
|
| + // 0x00-0x0f
|
| + 0x0000, 0x0029, 0x001e, 0x001f, 0x0020, 0x0021, 0x0022, 0x0023,
|
| + 0x0024, 0x0025, 0x0026, 0x0027, 0x002d, 0x002e, 0x002a, 0x002b,
|
| + // 0x10-0x1f
|
| + 0x0014, 0x001a, 0x0008, 0x0015, 0x0017, 0x001c, 0x0018, 0x000c,
|
| + 0x0012, 0x0013, 0x002f, 0x0030, 0x0028, 0x00e0, 0x0004, 0x0016,
|
| + // 0x20-0x2f
|
| + 0x0007, 0x0009, 0x000a, 0x000b, 0x000d, 0x000e, 0x000f, 0x0033,
|
| + 0x0034, 0x0035, 0x00e1, 0x0032, 0x001d, 0x001b, 0x0006, 0x0019,
|
| + // 0x30-0x3f
|
| + 0x0005, 0x0011, 0x0010, 0x0036, 0x0037, 0x0038, 0x00e5, 0x0055,
|
| + 0x00e2, 0x002c, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e,
|
| + // 0x40-0x4f
|
| + 0x003f, 0x0040, 0x0041, 0x0042, 0x0043, 0x0053, 0x0047, 0x005f,
|
| + 0x0060, 0x0061, 0x0056, 0x005c, 0x005d, 0x005e, 0x0057, 0x0059,
|
| + // 0x50-0x5f
|
| + 0x005a, 0x005b, 0x0062, 0x0063, 0x0000, 0x0094, 0x0064, 0x0044,
|
| + 0x0045, 0x0087, 0x0092, 0x0093, 0x008a, 0x0088, 0x008b, 0x008c,
|
| + // 0x60-0x6f
|
| + 0x0058, 0x00e4, 0x0054, 0x0046, 0x00e6, 0x0000, 0x004a, 0x0052,
|
| + 0x004b, 0x0050, 0x004f, 0x004d, 0x0051, 0x004e, 0x0049, 0x004c,
|
| + // 0x70-0x7f
|
| + 0x0000, 0x00ef, 0x00ee, 0x00ed, 0x0066, 0x0067, 0x0000, 0x0048,
|
| + 0x0000, 0x0085, 0x0090, 0x0091, 0x0089, 0x00e3, 0x00e7, 0x0065,
|
| + // 0x80-0x8f
|
| + 0x00f3, 0x0079, 0x0076, 0x007a, 0x0077, 0x007c, 0x0074, 0x007d,
|
| + 0x00f4, 0x007b, 0x0075, 0x0000, 0x00fb, 0x0000, 0x00f8, 0x0000,
|
| + // 0x90-0x9f
|
| + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00f0, 0x0000,
|
| + 0x00f9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00f1, 0x00f2,
|
| + // 0xa0-0xaf
|
| + 0x0000, 0x00ec, 0x0000, 0x00eb, 0x00e8, 0x00ea, 0x00e9, 0x0000,
|
| + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00fa, 0x0000, 0x0000,
|
| + // 0xb0-0xbf
|
| + 0x00f7, 0x00f5, 0x00f6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0068,
|
| + 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, 0x0070,
|
| + // 0xc0-0xcf
|
| + 0x0071, 0x0072, 0x0073, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
| + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
| + // 0xd0-0xdf
|
| + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
| + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
| + // 0xe0-0xef
|
| + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
| + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
| + // 0xf0-0xff
|
| + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
| + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
| +};
|
| +
|
| +} // anonymous namespace
|
| +
|
| +uint32_t UsbKeyCodeForKeyboardEvent(const WebKeyboardEvent& key_event) {
|
| + // TODO(garykac): This code assumes that on Linux we're receiving events via
|
| + // the Xorg "evdev" driver. We should detect "XKB" or "kbd" at run-time and
|
| + // re-map accordingly, but that's not possible here, inside the sandbox.
|
| + if (key_event.nativeKeyCode < 0 || key_event.nativeKeyCode > 255)
|
| + return 0;
|
| +
|
| + uint32_t usbkeycode = 0;
|
| + uint16_t code = linux_evdev_key_code_to_usb[key_event.nativeKeyCode];
|
| + if (code != 0) {
|
| + // Set complete scancode to be the USB keyboard page (7) and key scancode.
|
| + usbkeycode = 0x070000 | code;
|
| + }
|
| + return usbkeycode;
|
| +}
|
| +
|
| +} // namespace ppapi
|
| +} // namespace webkit
|
|
|