Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: webkit/plugins/ppapi/event_conversion.cc

Issue 9353013: Add GetUsbKeyCode dev interface for Pepper key events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Auto-set PP_INPUTEVENT_CLASS_KEYBOARD Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // the event type from the given web event. Event-specific fields will be zero 68 // the event type from the given web event. Event-specific fields will be zero
69 // initialized. 69 // initialized.
70 InputEventData GetEventWithCommonFieldsAndType(const WebInputEvent& web_event) { 70 InputEventData GetEventWithCommonFieldsAndType(const WebInputEvent& web_event) {
71 InputEventData result; 71 InputEventData result;
72 result.event_type = ConvertEventTypes(web_event.type); 72 result.event_type = ConvertEventTypes(web_event.type);
73 result.event_time_stamp = EventTimeToPPTimeTicks(web_event.timeStampSeconds); 73 result.event_time_stamp = EventTimeToPPTimeTicks(web_event.timeStampSeconds);
74 return result; 74 return result;
75 } 75 }
76 76
77 void AppendKeyEvent(const WebInputEvent& event, 77 void AppendKeyEvent(const WebInputEvent& event,
78 bool lowlevel_keyboard_events,
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 if (lowlevel_keyboard_events) {
85 // TODO(garykac) Convert native key code to USB scancodes.
86 result.key_code = key_event.nativeKeyCode;
87 } else {
88 result.key_code = key_event.windowsKeyCode;
89 }
84 result_events->push_back(result); 90 result_events->push_back(result);
85 } 91 }
86 92
87 void AppendCharEvent(const WebInputEvent& event, 93 void AppendCharEvent(const WebInputEvent& event,
88 std::vector<InputEventData>* result_events) { 94 std::vector<InputEventData>* result_events) {
89 const WebKeyboardEvent& key_event = 95 const WebKeyboardEvent& key_event =
90 static_cast<const WebKeyboardEvent&>(event); 96 static_cast<const WebKeyboardEvent&>(event);
91 97
92 // This is a bit complex, the input event will normally just have one 16-bit 98 // This is a bit complex, the input event will normally just have one 16-bit
93 // character in it, but may be zero or more than one. The text array is 99 // character in it, but may be zero or more than one. The text array is
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 } 338 }
333 } 339 }
334 340
335 *code = vk_code; 341 *code = vk_code;
336 *text = vk_text; 342 *text = vk_text;
337 } 343 }
338 344
339 } // namespace 345 } // namespace
340 346
341 void CreateInputEventData(const WebInputEvent& event, 347 void CreateInputEventData(const WebInputEvent& event,
348 bool lowlevel_keyboard_events,
342 std::vector<InputEventData>* result) { 349 std::vector<InputEventData>* result) {
343 result->clear(); 350 result->clear();
344 351
345 switch (event.type) { 352 switch (event.type) {
346 case WebInputEvent::MouseDown: 353 case WebInputEvent::MouseDown:
347 case WebInputEvent::MouseUp: 354 case WebInputEvent::MouseUp:
348 case WebInputEvent::MouseMove: 355 case WebInputEvent::MouseMove:
349 case WebInputEvent::MouseEnter: 356 case WebInputEvent::MouseEnter:
350 case WebInputEvent::MouseLeave: 357 case WebInputEvent::MouseLeave:
351 case WebInputEvent::ContextMenu: 358 case WebInputEvent::ContextMenu:
352 AppendMouseEvent(event, result); 359 AppendMouseEvent(event, result);
353 break; 360 break;
354 case WebInputEvent::MouseWheel: 361 case WebInputEvent::MouseWheel:
355 AppendMouseWheelEvent(event, result); 362 AppendMouseWheelEvent(event, result);
356 break; 363 break;
357 case WebInputEvent::RawKeyDown: 364 case WebInputEvent::RawKeyDown:
358 case WebInputEvent::KeyDown: 365 case WebInputEvent::KeyDown:
359 case WebInputEvent::KeyUp: 366 case WebInputEvent::KeyUp:
360 AppendKeyEvent(event, result); 367 AppendKeyEvent(event, lowlevel_keyboard_events, result);
361 break; 368 break;
362 case WebInputEvent::Char: 369 case WebInputEvent::Char:
363 AppendCharEvent(event, result); 370 AppendCharEvent(event, result);
364 break; 371 break;
365 case WebInputEvent::Undefined: 372 case WebInputEvent::Undefined:
366 default: 373 default:
367 break; 374 break;
368 } 375 }
369 } 376 }
370 377
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 return PP_INPUTEVENT_CLASS_KEYBOARD; 522 return PP_INPUTEVENT_CLASS_KEYBOARD;
516 case WebInputEvent::Undefined: 523 case WebInputEvent::Undefined:
517 default: 524 default:
518 NOTREACHED(); 525 NOTREACHED();
519 return PP_InputEvent_Class(0); 526 return PP_InputEvent_Class(0);
520 } 527 }
521 } 528 }
522 529
523 } // namespace ppapi 530 } // namespace ppapi
524 } // namespace webkit 531 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698