| Index: components/mus/input_devices/touchscreen_device_struct_traits.h
|
| diff --git a/components/mus/input_devices/touchscreen_device_struct_traits.h b/components/mus/input_devices/touchscreen_device_struct_traits.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d2b3916b0bae74fb5881e995358bd621ab766e5f
|
| --- /dev/null
|
| +++ b/components/mus/input_devices/touchscreen_device_struct_traits.h
|
| @@ -0,0 +1,98 @@
|
| +// Copyright 2016 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.
|
| +
|
| +#ifndef COMPONENTS_MUS_INPUT_DEVICES_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_
|
| +#define COMPONENTS_MUS_INPUT_DEVICES_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/strings/string_piece.h"
|
| +#include "components/mus/public/interfaces/input_devices/input_devices.mojom.h"
|
| +#include "ui/events/devices/touchscreen_device.h"
|
| +#include "ui/gfx/geometry/size.h"
|
| +
|
| +namespace mojo {
|
| +
|
| +template <>
|
| +struct StructTraits<input_device::mojom::TouchscreenDevice,
|
| + ui::TouchscreenDevice> {
|
| + static int32_t id(const ui::TouchscreenDevice& device) { return device.id; }
|
| +
|
| + static input_device::mojom::InputDeviceType type(
|
| + const ui::TouchscreenDevice& device) {
|
| + switch (device.type) {
|
| + case ui::INPUT_DEVICE_INTERNAL:
|
| + return input_device::mojom::InputDeviceType::INPUT_DEVICE_INTERNAL;
|
| + case ui::INPUT_DEVICE_EXTERNAL:
|
| + return input_device::mojom::InputDeviceType::INPUT_DEVICE_EXTERNAL;
|
| + case ui::INPUT_DEVICE_UNKNOWN:
|
| + return input_device::mojom::InputDeviceType::INPUT_DEVICE_UNKNOWN;
|
| + }
|
| + }
|
| +
|
| + static std::string name(const ui::TouchscreenDevice& device) {
|
| + return device.name;
|
| + }
|
| +
|
| + static base::StringPiece sys_path(const ui::TouchscreenDevice& device) {
|
| + return device.sys_path.AsUTF8Unsafe();
|
| + }
|
| +
|
| + static uint32_t vendor_id(const ui::TouchscreenDevice& device) {
|
| + return device.vendor_id;
|
| + }
|
| +
|
| + static uint32_t product_id(const ui::TouchscreenDevice& device) {
|
| + return device.product_id;
|
| + }
|
| +
|
| + static gfx::Size size(const ui::TouchscreenDevice& device) {
|
| + return device.size;
|
| + }
|
| +
|
| + static int32_t touch_points(const ui::TouchscreenDevice& device) {
|
| + return device.touch_points;
|
| + }
|
| +
|
| + static bool Read(input_device::mojom::TouchscreenDeviceDataView data,
|
| + ui::TouchscreenDevice* out) {
|
| + out->id = data.id();
|
| +
|
| + switch (data.type()) {
|
| + case input_device::mojom::InputDeviceType::INPUT_DEVICE_INTERNAL:
|
| + out->type = ui::INPUT_DEVICE_INTERNAL;
|
| + break;
|
| + case input_device::mojom::InputDeviceType::INPUT_DEVICE_EXTERNAL:
|
| + out->type = ui::INPUT_DEVICE_EXTERNAL;
|
| + break;
|
| + case input_device::mojom::InputDeviceType::INPUT_DEVICE_UNKNOWN:
|
| + out->type = ui::INPUT_DEVICE_UNKNOWN;
|
| + break;
|
| + default:
|
| + return false;
|
| + }
|
| +
|
| + if (!data.ReadName(&out->name))
|
| + return false;
|
| +
|
| + base::StringPiece sys_path_string;
|
| + if (!data.ReadSysPath(&sys_path_string))
|
| + return false;
|
| + out->sys_path = base::FilePath::FromUTF8Unsafe(sys_path_string);
|
| +
|
| + out->vendor_id = data.vendor_id();
|
| + out->product_id = data.product_id();
|
| +
|
| + if (!data.ReadSize(&out->size))
|
| + return false;
|
| +
|
| + out->touch_points = data.touch_points();
|
| +
|
| + return true;
|
| + }
|
| +};
|
| +
|
| +} // namespace mojo
|
| +
|
| +#endif // COMPONENTS_MUS_INPUT_DEVICES_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_
|
|
|