chromium/device/gamepad/public/cpp/gamepad_mojom_traits.h

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#ifndef DEVICE_GAMEPAD_PUBLIC_CPP_GAMEPAD_MOJOM_TRAITS_H_
#define DEVICE_GAMEPAD_PUBLIC_CPP_GAMEPAD_MOJOM_TRAITS_H_

#include <stddef.h>

#include "base/component_export.h"
#include "base/containers/span.h"
#include "device/gamepad/public/cpp/gamepad.h"
#include "device/gamepad/public/mojom/gamepad.mojom-shared.h"
#include "mojo/public/cpp/bindings/array_traits_span.h"
#include "mojo/public/cpp/bindings/struct_traits.h"

namespace mojo {

template <>
struct COMPONENT_EXPORT(GAMEPAD_SHARED_TRAITS)
    StructTraits<device::mojom::GamepadQuaternionDataView,
                 device::GamepadQuaternion> {};

template <>
struct COMPONENT_EXPORT(GAMEPAD_SHARED_TRAITS)
    StructTraits<device::mojom::GamepadVectorDataView, device::GamepadVector> {};

template <>
struct COMPONENT_EXPORT(GAMEPAD_SHARED_TRAITS)
    StructTraits<device::mojom::GamepadButtonDataView, device::GamepadButton> {};

template <>
struct COMPONENT_EXPORT(GAMEPAD_SHARED_TRAITS)
    EnumTraits<device::mojom::GamepadHapticActuatorType,
               device::GamepadHapticActuatorType> {};

template <>
struct COMPONENT_EXPORT(GAMEPAD_SHARED_TRAITS)
    StructTraits<device::mojom::GamepadHapticActuatorDataView,
                 device::GamepadHapticActuator> {};

template <>
struct COMPONENT_EXPORT(GAMEPAD_SHARED_TRAITS)
    StructTraits<device::mojom::GamepadPoseDataView, device::GamepadPose> {};

template <>
struct COMPONENT_EXPORT(GAMEPAD_SHARED_TRAITS)
    EnumTraits<device::mojom::GamepadMapping, device::GamepadMapping> {};

template <>
struct COMPONENT_EXPORT(GAMEPAD_SHARED_TRAITS)
    StructTraits<device::mojom::GamepadTouchDataView, device::GamepadTouch> {};

template <>
struct COMPONENT_EXPORT(GAMEPAD_SHARED_TRAITS)
    EnumTraits<device::mojom::GamepadHand, device::GamepadHand> {};

template <>
struct COMPONENT_EXPORT(GAMEPAD_SHARED_TRAITS)
    StructTraits<device::mojom::GamepadDataView, device::Gamepad> {};

}  // namespace mojo

#endif  // DEVICE_GAMEPAD_PUBLIC_CPP_GAMEPAD_MOJOM_TRAITS_H_