1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "content/renderer/pepper/usb_key_code_conversion.h" 6 7 #include "base/basictypes.h" 8 #include "third_party/WebKit/public/web/WebInputEvent.h" 9 10 using WebKit::WebKeyboardEvent; 11 12 namespace content { 13 14 namespace { 15 16 #define USB_KEYMAP(usb, xkb, win, mac) {usb, win} 17 #include "ui/base/keycodes/usb_keycode_map.h" 18 #undef USB_KEYMAP 19 20 } // anonymous namespace 21 22 uint32_t UsbKeyCodeForKeyboardEvent(const WebKeyboardEvent& key_event) { 23 // Extract the scancode and extended bit from the native key event's lParam. 24 int scancode = (key_event.nativeKeyCode >> 16) & 0x000000FF; 25 if ((key_event.nativeKeyCode & (1 << 24)) != 0) 26 scancode |= 0xe000; 27 28 return NativeKeycodeToUsbKeycode(scancode); 29 } 30 31 } // namespace content 32