| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef UI_EVENTS_DEVICES_MOJO_INPUT_DEVICE_STRUCT_TRAITS_H_ | 5 #ifndef UI_EVENTS_DEVICES_MOJO_INPUT_DEVICE_STRUCT_TRAITS_H_ |
| 6 #define UI_EVENTS_DEVICES_MOJO_INPUT_DEVICE_STRUCT_TRAITS_H_ | 6 #define UI_EVENTS_DEVICES_MOJO_INPUT_DEVICE_STRUCT_TRAITS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/strings/string_piece.h" | |
| 11 #include "ui/events/devices/input_device.h" | 10 #include "ui/events/devices/input_device.h" |
| 12 #include "ui/events/devices/mojo/input_devices.mojom.h" | 11 #include "ui/events/devices/mojo/input_devices.mojom.h" |
| 13 #include "ui/events/devices/touchscreen_device.h" | 12 #include "ui/events/devices/touchscreen_device.h" |
| 14 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
| 15 | 14 |
| 16 namespace mojo { | 15 namespace mojo { |
| 17 | 16 |
| 18 template <> | 17 template <> |
| 19 struct EnumTraits<ui::mojom::InputDeviceType, ui::InputDeviceType> { | 18 struct EnumTraits<ui::mojom::InputDeviceType, ui::InputDeviceType> { |
| 20 static ui::mojom::InputDeviceType ToMojom(ui::InputDeviceType type); | 19 static ui::mojom::InputDeviceType ToMojom(ui::InputDeviceType type); |
| 21 static bool FromMojom(ui::mojom::InputDeviceType type, | 20 static bool FromMojom(ui::mojom::InputDeviceType type, |
| 22 ui::InputDeviceType* output); | 21 ui::InputDeviceType* output); |
| 23 }; | 22 }; |
| 24 | 23 |
| 25 template <> | 24 template <> |
| 26 struct StructTraits<ui::mojom::InputDevice, ui::InputDevice> { | 25 struct StructTraits<ui::mojom::InputDevice, ui::InputDevice> { |
| 27 static int32_t id(const ui::InputDevice& device) { return device.id; } | 26 static int32_t id(const ui::InputDevice& device) { return device.id; } |
| 28 | 27 |
| 29 static ui::InputDeviceType type(const ui::InputDevice& device) { | 28 static ui::InputDeviceType type(const ui::InputDevice& device) { |
| 30 return device.type; | 29 return device.type; |
| 31 } | 30 } |
| 32 | 31 |
| 33 static const std::string& name(const ui::InputDevice& device) { | 32 static const std::string& name(const ui::InputDevice& device) { |
| 34 return device.name; | 33 return device.name; |
| 35 } | 34 } |
| 36 | 35 |
| 37 static base::StringPiece sys_path(const ui::InputDevice& device) { | 36 static std::string sys_path(const ui::InputDevice& device) { |
| 38 return device.sys_path.AsUTF8Unsafe(); | 37 return device.sys_path.AsUTF8Unsafe(); |
| 39 } | 38 } |
| 40 | 39 |
| 41 static uint32_t vendor_id(const ui::InputDevice& device) { | 40 static uint32_t vendor_id(const ui::InputDevice& device) { |
| 42 return device.vendor_id; | 41 return device.vendor_id; |
| 43 } | 42 } |
| 44 | 43 |
| 45 static uint32_t product_id(const ui::InputDevice& device) { | 44 static uint32_t product_id(const ui::InputDevice& device) { |
| 46 return device.product_id; | 45 return device.product_id; |
| 47 } | 46 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 64 return device.touch_points; | 63 return device.touch_points; |
| 65 } | 64 } |
| 66 | 65 |
| 67 static bool Read(ui::mojom::TouchscreenDeviceDataView data, | 66 static bool Read(ui::mojom::TouchscreenDeviceDataView data, |
| 68 ui::TouchscreenDevice* out); | 67 ui::TouchscreenDevice* out); |
| 69 }; | 68 }; |
| 70 | 69 |
| 71 } // namespace mojo | 70 } // namespace mojo |
| 72 | 71 |
| 73 #endif // UI_EVENTS_DEVICES_MOJO_INPUT_DEVICE_STRUCT_TRAITS_H_ | 72 #endif // UI_EVENTS_DEVICES_MOJO_INPUT_DEVICE_STRUCT_TRAITS_H_ |
| OLD | NEW |