// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY

#include "wpi/driverstation/NiDsXboxController.hpp"

#include "wpi/hal/UsageReporting.hpp"
#include "wpi/util/sendable/SendableBuilder.hpp"

#include "wpi/event/BooleanEvent.hpp"

using namespace wpi;

NiDsXboxController::NiDsXboxController(int port) : GenericHID(port) {
  HAL_ReportUsage("HID", port, "NiDsXboxController");
}

double NiDsXboxController::GetLeftX() const {
  return GetRawAxis(Axis::kLeftX);
}

double NiDsXboxController::GetRightX() const {
  return GetRawAxis(Axis::kRightX);
}

double NiDsXboxController::GetLeftY() const {
  return GetRawAxis(Axis::kLeftY);
}

double NiDsXboxController::GetRightY() const {
  return GetRawAxis(Axis::kRightY);
}

double NiDsXboxController::GetLeftTriggerAxis() const {
  return GetRawAxis(Axis::kLeftTrigger);
}

BooleanEvent NiDsXboxController::LeftTrigger(double threshold, EventLoop* loop) const {
  return BooleanEvent(loop, [this, threshold] { return this->GetLeftTriggerAxis() > threshold; });
}

BooleanEvent NiDsXboxController::LeftTrigger(EventLoop* loop) const {
  return this->LeftTrigger(0.5, loop);
}

double NiDsXboxController::GetRightTriggerAxis() const {
  return GetRawAxis(Axis::kRightTrigger);
}

BooleanEvent NiDsXboxController::RightTrigger(double threshold, EventLoop* loop) const {
  return BooleanEvent(loop, [this, threshold] { return this->GetRightTriggerAxis() > threshold; });
}

BooleanEvent NiDsXboxController::RightTrigger(EventLoop* loop) const {
  return this->RightTrigger(0.5, loop);
}

bool NiDsXboxController::GetAButton() const {
  return GetRawButton(Button::kA);
}

bool NiDsXboxController::GetAButtonPressed() {
  return GetRawButtonPressed(Button::kA);
}

bool NiDsXboxController::GetAButtonReleased() {
  return GetRawButtonReleased(Button::kA);
}

BooleanEvent NiDsXboxController::A(EventLoop* loop) const {
  return BooleanEvent(loop, [this]() { return this->GetAButton(); });
}

bool NiDsXboxController::GetBButton() const {
  return GetRawButton(Button::kB);
}

bool NiDsXboxController::GetBButtonPressed() {
  return GetRawButtonPressed(Button::kB);
}

bool NiDsXboxController::GetBButtonReleased() {
  return GetRawButtonReleased(Button::kB);
}

BooleanEvent NiDsXboxController::B(EventLoop* loop) const {
  return BooleanEvent(loop, [this]() { return this->GetBButton(); });
}

bool NiDsXboxController::GetXButton() const {
  return GetRawButton(Button::kX);
}

bool NiDsXboxController::GetXButtonPressed() {
  return GetRawButtonPressed(Button::kX);
}

bool NiDsXboxController::GetXButtonReleased() {
  return GetRawButtonReleased(Button::kX);
}

BooleanEvent NiDsXboxController::X(EventLoop* loop) const {
  return BooleanEvent(loop, [this]() { return this->GetXButton(); });
}

bool NiDsXboxController::GetYButton() const {
  return GetRawButton(Button::kY);
}

bool NiDsXboxController::GetYButtonPressed() {
  return GetRawButtonPressed(Button::kY);
}

bool NiDsXboxController::GetYButtonReleased() {
  return GetRawButtonReleased(Button::kY);
}

BooleanEvent NiDsXboxController::Y(EventLoop* loop) const {
  return BooleanEvent(loop, [this]() { return this->GetYButton(); });
}

bool NiDsXboxController::GetLeftBumperButton() const {
  return GetRawButton(Button::kLeftBumper);
}

bool NiDsXboxController::GetLeftBumperButtonPressed() {
  return GetRawButtonPressed(Button::kLeftBumper);
}

bool NiDsXboxController::GetLeftBumperButtonReleased() {
  return GetRawButtonReleased(Button::kLeftBumper);
}

BooleanEvent NiDsXboxController::LeftBumper(EventLoop* loop) const {
  return BooleanEvent(loop, [this]() { return this->GetLeftBumperButton(); });
}

bool NiDsXboxController::GetRightBumperButton() const {
  return GetRawButton(Button::kRightBumper);
}

bool NiDsXboxController::GetRightBumperButtonPressed() {
  return GetRawButtonPressed(Button::kRightBumper);
}

bool NiDsXboxController::GetRightBumperButtonReleased() {
  return GetRawButtonReleased(Button::kRightBumper);
}

BooleanEvent NiDsXboxController::RightBumper(EventLoop* loop) const {
  return BooleanEvent(loop, [this]() { return this->GetRightBumperButton(); });
}

bool NiDsXboxController::GetBackButton() const {
  return GetRawButton(Button::kBack);
}

bool NiDsXboxController::GetBackButtonPressed() {
  return GetRawButtonPressed(Button::kBack);
}

bool NiDsXboxController::GetBackButtonReleased() {
  return GetRawButtonReleased(Button::kBack);
}

BooleanEvent NiDsXboxController::Back(EventLoop* loop) const {
  return BooleanEvent(loop, [this]() { return this->GetBackButton(); });
}

bool NiDsXboxController::GetStartButton() const {
  return GetRawButton(Button::kStart);
}

bool NiDsXboxController::GetStartButtonPressed() {
  return GetRawButtonPressed(Button::kStart);
}

bool NiDsXboxController::GetStartButtonReleased() {
  return GetRawButtonReleased(Button::kStart);
}

BooleanEvent NiDsXboxController::Start(EventLoop* loop) const {
  return BooleanEvent(loop, [this]() { return this->GetStartButton(); });
}

bool NiDsXboxController::GetLeftStickButton() const {
  return GetRawButton(Button::kLeftStick);
}

bool NiDsXboxController::GetLeftStickButtonPressed() {
  return GetRawButtonPressed(Button::kLeftStick);
}

bool NiDsXboxController::GetLeftStickButtonReleased() {
  return GetRawButtonReleased(Button::kLeftStick);
}

BooleanEvent NiDsXboxController::LeftStick(EventLoop* loop) const {
  return BooleanEvent(loop, [this]() { return this->GetLeftStickButton(); });
}

bool NiDsXboxController::GetRightStickButton() const {
  return GetRawButton(Button::kRightStick);
}

bool NiDsXboxController::GetRightStickButtonPressed() {
  return GetRawButtonPressed(Button::kRightStick);
}

bool NiDsXboxController::GetRightStickButtonReleased() {
  return GetRawButtonReleased(Button::kRightStick);
}

BooleanEvent NiDsXboxController::RightStick(EventLoop* loop) const {
  return BooleanEvent(loop, [this]() { return this->GetRightStickButton(); });
}

void NiDsXboxController::InitSendable(wpi::util::SendableBuilder& builder) {
  builder.SetSmartDashboardType("HID");
  builder.PublishConstString("ControllerType", "NiDsXbox");
  builder.AddDoubleProperty("LeftTrigger Axis", [this] { return GetLeftTriggerAxis(); }, nullptr);
  builder.AddDoubleProperty("RightTrigger Axis", [this] { return GetRightTriggerAxis(); }, nullptr);
  builder.AddDoubleProperty("LeftX", [this] { return GetLeftX(); }, nullptr);
  builder.AddDoubleProperty("RightX", [this] { return GetRightX(); }, nullptr);
  builder.AddDoubleProperty("LeftY", [this] { return GetLeftY(); }, nullptr);
  builder.AddDoubleProperty("RightY", [this] { return GetRightY(); }, nullptr);
  builder.AddBooleanProperty("A", [this] { return GetAButton(); }, nullptr);
  builder.AddBooleanProperty("B", [this] { return GetBButton(); }, nullptr);
  builder.AddBooleanProperty("X", [this] { return GetXButton(); }, nullptr);
  builder.AddBooleanProperty("Y", [this] { return GetYButton(); }, nullptr);
  builder.AddBooleanProperty("LeftBumper", [this] { return GetLeftBumperButton(); }, nullptr);
  builder.AddBooleanProperty("RightBumper", [this] { return GetRightBumperButton(); }, nullptr);
  builder.AddBooleanProperty("Back", [this] { return GetBackButton(); }, nullptr);
  builder.AddBooleanProperty("Start", [this] { return GetStartButton(); }, nullptr);
  builder.AddBooleanProperty("LeftStick", [this] { return GetLeftStickButton(); }, nullptr);
  builder.AddBooleanProperty("RightStick", [this] { return GetRightStickButton(); }, nullptr);
}