| Index: mojo/services/public/cpp/input_events/lib/input_events_type_converters.cc
|
| diff --git a/mojo/services/public/cpp/input_events/lib/input_events_type_converters.cc b/mojo/services/public/cpp/input_events/lib/input_events_type_converters.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5b4d0845f3ac1813a44aabf13f482186492b237e
|
| --- /dev/null
|
| +++ b/mojo/services/public/cpp/input_events/lib/input_events_type_converters.cc
|
| @@ -0,0 +1,42 @@
|
| +// Copyright 2014 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 "mojo/services/public/cpp/input_events/input_events_type_converters.h"
|
| +
|
| +#include "mojo/services/public/cpp/geometry/geometry_type_converters.h"
|
| +#include "ui/events/keycodes/keyboard_codes.h"
|
| +
|
| +namespace mojo {
|
| +
|
| +// static
|
| +Event TypeConverter<Event, ui::Event>::ConvertFrom(const ui::Event& input,
|
| + Buffer* buf) {
|
| + Event::Builder event;
|
| + event.set_action(input.type());
|
| + event.set_flags(input.flags());
|
| + event.set_time_stamp(input.time_stamp().ToInternalValue());
|
| +
|
| + if (input.IsMouseEvent() || input.IsTouchEvent()) {
|
| + const ui::LocatedEvent* located_event =
|
| + static_cast<const ui::LocatedEvent*>(&input);
|
| + event.set_location(located_event->location());
|
| + }
|
| +
|
| + if (input.IsTouchEvent()) {
|
| + const ui::TouchEvent* touch_event =
|
| + static_cast<const ui::TouchEvent*>(&input);
|
| + TouchData::Builder touch_data;
|
| + touch_data.set_pointer_id(touch_event->touch_id());
|
| + event.set_touch_data(touch_data.Finish());
|
| + } else if (input.IsKeyEvent()) {
|
| + const ui::KeyEvent* key_event = static_cast<const ui::KeyEvent*>(&input);
|
| + KeyData::Builder key_data;
|
| + key_data.set_key_code(key_event->key_code());
|
| + key_data.set_is_char(key_event->is_char());
|
| + event.set_key_data(key_data.Finish());
|
| + }
|
| + return event.Finish();
|
| +}
|
| +
|
| +} // namespace mojo
|
|
|