OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/plugins/ppapi/event_conversion.h" | 5 #include "webkit/plugins/ppapi/event_conversion.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/i18n/char_iterator.h" | 8 #include "base/i18n/char_iterator.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "base/utf_string_conversion_utils.h" | 14 #include "base/utf_string_conversion_utils.h" |
15 #include "ppapi/c/pp_input_event.h" | 15 #include "ppapi/c/pp_input_event.h" |
16 #include "ppapi/shared_impl/ppb_input_event_shared.h" | 16 #include "ppapi/shared_impl/ppb_input_event_shared.h" |
17 #include "ppapi/shared_impl/time_conversion.h" | 17 #include "ppapi/shared_impl/time_conversion.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
20 #include "webkit/plugins/ppapi/common.h" | 20 #include "webkit/plugins/ppapi/common.h" |
| 21 #include "webkit/plugins/ppapi/usb_scan_code_conversion.h" |
21 | 22 |
22 using ppapi::EventTimeToPPTimeTicks; | 23 using ppapi::EventTimeToPPTimeTicks; |
23 using ppapi::InputEventData; | 24 using ppapi::InputEventData; |
24 using ppapi::PPTimeTicksToEventTime; | 25 using ppapi::PPTimeTicksToEventTime; |
25 using WebKit::WebInputEvent; | 26 using WebKit::WebInputEvent; |
26 using WebKit::WebKeyboardEvent; | 27 using WebKit::WebKeyboardEvent; |
27 using WebKit::WebMouseEvent; | 28 using WebKit::WebMouseEvent; |
28 using WebKit::WebMouseWheelEvent; | 29 using WebKit::WebMouseWheelEvent; |
29 using WebKit::WebString; | 30 using WebKit::WebString; |
30 using WebKit::WebUChar; | 31 using WebKit::WebUChar; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 return result; | 75 return result; |
75 } | 76 } |
76 | 77 |
77 void AppendKeyEvent(const WebInputEvent& event, | 78 void AppendKeyEvent(const WebInputEvent& event, |
78 std::vector<InputEventData>* result_events) { | 79 std::vector<InputEventData>* result_events) { |
79 const WebKeyboardEvent& key_event = | 80 const WebKeyboardEvent& key_event = |
80 static_cast<const WebKeyboardEvent&>(event); | 81 static_cast<const WebKeyboardEvent&>(event); |
81 InputEventData result = GetEventWithCommonFieldsAndType(event); | 82 InputEventData result = GetEventWithCommonFieldsAndType(event); |
82 result.event_modifiers = key_event.modifiers; | 83 result.event_modifiers = key_event.modifiers; |
83 result.key_code = key_event.windowsKeyCode; | 84 result.key_code = key_event.windowsKeyCode; |
84 // TODO(garykac): Platform-specific code to convert from | 85 result.usb_scan_code = UsbScanCodeForKeyboardEvent(key_event); |
85 // |key_event.nativeKeyCode| to USB scan code. | |
86 result.usb_scan_code = 0; | |
87 result_events->push_back(result); | 86 result_events->push_back(result); |
88 } | 87 } |
89 | 88 |
90 void AppendCharEvent(const WebInputEvent& event, | 89 void AppendCharEvent(const WebInputEvent& event, |
91 std::vector<InputEventData>* result_events) { | 90 std::vector<InputEventData>* result_events) { |
92 const WebKeyboardEvent& key_event = | 91 const WebKeyboardEvent& key_event = |
93 static_cast<const WebKeyboardEvent&>(event); | 92 static_cast<const WebKeyboardEvent&>(event); |
94 | 93 |
95 // This is a bit complex, the input event will normally just have one 16-bit | 94 // This is a bit complex, the input event will normally just have one 16-bit |
96 // character in it, but may be zero or more than one. The text array is | 95 // character in it, but may be zero or more than one. The text array is |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 return PP_INPUTEVENT_CLASS_KEYBOARD; | 517 return PP_INPUTEVENT_CLASS_KEYBOARD; |
519 case WebInputEvent::Undefined: | 518 case WebInputEvent::Undefined: |
520 default: | 519 default: |
521 NOTREACHED(); | 520 NOTREACHED(); |
522 return PP_InputEvent_Class(0); | 521 return PP_InputEvent_Class(0); |
523 } | 522 } |
524 } | 523 } |
525 | 524 |
526 } // namespace ppapi | 525 } // namespace ppapi |
527 } // namespace webkit | 526 } // namespace webkit |
OLD | NEW |