| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/WebGamepads.
h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 20 #include "webkit/plugins/ppapi/common.h" | 21 #include "webkit/plugins/ppapi/common.h" |
| 21 #include "webkit/plugins/ppapi/usb_key_code_conversion.h" | 22 #include "webkit/plugins/ppapi/usb_key_code_conversion.h" |
| 22 | 23 |
| 23 using ppapi::EventTimeToPPTimeTicks; | 24 using ppapi::EventTimeToPPTimeTicks; |
| 24 using ppapi::InputEventData; | 25 using ppapi::InputEventData; |
| 25 using ppapi::PPTimeTicksToEventTime; | 26 using ppapi::PPTimeTicksToEventTime; |
| 26 using WebKit::WebInputEvent; | 27 using WebKit::WebInputEvent; |
| 27 using WebKit::WebKeyboardEvent; | 28 using WebKit::WebKeyboardEvent; |
| 28 using WebKit::WebMouseEvent; | 29 using WebKit::WebMouseEvent; |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 case WebInputEvent::KeyUp: | 516 case WebInputEvent::KeyUp: |
| 516 case WebInputEvent::Char: | 517 case WebInputEvent::Char: |
| 517 return PP_INPUTEVENT_CLASS_KEYBOARD; | 518 return PP_INPUTEVENT_CLASS_KEYBOARD; |
| 518 case WebInputEvent::Undefined: | 519 case WebInputEvent::Undefined: |
| 519 default: | 520 default: |
| 520 NOTREACHED(); | 521 NOTREACHED(); |
| 521 return PP_InputEvent_Class(0); | 522 return PP_InputEvent_Class(0); |
| 522 } | 523 } |
| 523 } | 524 } |
| 524 | 525 |
| 526 void ConvertWebKitGamepadData(WebKit::WebGamepads& webkit_data, |
| 527 PP_GamepadsSampleData_Dev* output_data) { |
| 528 output_data->length = webkit_data.length; |
| 529 for (unsigned i = 0; i < webkit_data.length; ++i) { |
| 530 PP_GamepadSampleData_Dev& output_pad = output_data->items[i]; |
| 531 const WebKit::WebGamepad& webkit_pad = webkit_data.items[i]; |
| 532 output_pad.connected = webkit_pad.connected ? PP_TRUE : PP_FALSE; |
| 533 if (webkit_pad.connected) { |
| 534 COMPILE_ASSERT(sizeof(output_pad.id) == sizeof(webkit_pad.id), |
| 535 id_size_does_not_match); |
| 536 COMPILE_ASSERT(sizeof(output_pad.axes) == sizeof(webkit_pad.axes), |
| 537 axes_size_does_not_match); |
| 538 COMPILE_ASSERT(sizeof(output_pad.buttons) == sizeof(webkit_pad.buttons), |
| 539 buttons_size_does_not_match); |
| 540 memcpy(output_pad.id, webkit_pad.id, sizeof(output_pad.id)); |
| 541 output_pad.timestamp = webkit_pad.timestamp; |
| 542 output_pad.axes_length = webkit_pad.axesLength; |
| 543 memcpy(output_pad.axes, webkit_pad.axes, sizeof(output_pad.axes)); |
| 544 output_pad.buttons_length = webkit_pad.buttonsLength; |
| 545 memcpy(output_pad.buttons, |
| 546 webkit_pad.buttons, |
| 547 sizeof(output_pad.buttons)); |
| 548 } |
| 549 } |
| 550 } |
| 551 |
| 525 } // namespace ppapi | 552 } // namespace ppapi |
| 526 } // namespace webkit | 553 } // namespace webkit |
| OLD | NEW |