/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

using mozilla::dom::GamepadServiceType from "mozilla/dom/GamepadMessageUtils.h";
using mozilla::dom::GamepadPoseState from "mozilla/dom/GamepadMessageUtils.h";
using mozilla::dom::GamepadMappingType from "mozilla/dom/GamepadMessageUtils.h";
using mozilla::dom::GamepadHand from "mozilla/dom/GamepadMessageUtils.h";


namespace mozilla {
namespace dom {

struct GamepadAdded {
  nsString id;
  GamepadMappingType mapping;
  GamepadHand hand;
  uint32_t display_id;
  uint32_t num_buttons;
  uint32_t num_axes;
  uint32_t num_haptics;
};

struct GamepadRemoved {};

struct GamepadAxisInformation {
  uint32_t axis;
  double value;
};

struct GamepadButtonInformation {
  uint32_t button;
  double value;
  bool pressed;
  bool touched;
};

struct GamepadPoseInformation {
  GamepadPoseState pose_state;
};

struct GamepadHandInformation {
  GamepadHand hand;
};

union GamepadChangeEventBody {
  GamepadAdded;
  GamepadRemoved;
  GamepadAxisInformation;
  GamepadButtonInformation;
  GamepadPoseInformation;
  GamepadHandInformation;
};

struct GamepadChangeEvent {
  uint32_t index;
  GamepadServiceType service_type;
  GamepadChangeEventBody body;
};

} // namespace dom
} // namespace mozilla