// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
{% macro capitalize_first(string) -%}
{{ string[0]|capitalize + string[1:] }}
{%- endmacro %}
#pragma once

#include "wpi/driverstation/{{ ConsoleName }}Controller.hpp"

#include "wpi/commands2/button/Trigger.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"

namespace wpi::cmd {
/**
 * A version of {@link wpi::{{ ConsoleName }}Controller} with {@link Trigger} factories for
 * command-based.
 *
 * @see wpi::{{ ConsoleName }}Controller
 */
class Command{{ ConsoleName }}Controller : public CommandGenericHID {
 public:
  /**
   * Construct an instance of a controller.
   *
   * @param port The port index on the Driver Station that the controller is
   * plugged into.
   */
  explicit Command{{ ConsoleName }}Controller(int port);

  /**
   * Get the underlying GenericHID object.
   *
   * @return the wrapped GenericHID object
   */
  wpi::{{ ConsoleName }}Controller& GetHID();
{% for button in buttons %}
  /**
   * Constructs a Trigger instance around the {{ button.DocName|default(button.name) }} button's
   * digital signal.
   *
   * @param loop the event loop instance to attach the event to. Defaults to the
   * CommandScheduler's default loop.
   * @return a Trigger instance representing the {{ button.DocName|default(button.name) }} button's
   * digital signal attached to the given loop.
   */
  Trigger {{ capitalize_first(button.name) }}(wpi::EventLoop* loop = CommandScheduler::GetInstance()
                                                .GetDefaultButtonLoop()) const;
{% endfor -%}
{% for trigger in triggers -%}
{% if trigger.UseThresholdMethods %}
  /**
   * Constructs a Trigger instance around the axis value of the {{ trigger.DocName }}.
   * The returned Trigger will be true when the axis value is greater than
   * {@code threshold}.
   *
   * @param threshold the minimum axis value for the returned Trigger to be
   * true. This value should be in the range [0, 1] where 0 is the unpressed
   * state of the axis. Defaults to 0.5.
   * @param loop the event loop instance to attach the Trigger to. Defaults to
   * the CommandScheduler's default loop.
   * @return a Trigger instance that is true when the {{ trigger.DocName }}'s axis
   * exceeds the provided threshold, attached to the given loop
   */
  Trigger {{ capitalize_first(trigger.name) }}(double threshold = 0.5,
                      wpi::EventLoop* loop = CommandScheduler::GetInstance()
                                                 .GetDefaultButtonLoop()) const;
{% endif -%}
{% endfor -%}
{% for stick in sticks %}
  /**
   * Get the {{ stick.NameParts[1] }} axis value of {{ stick.NameParts[0] }} side of the controller. {{ stick.PositiveDirection }} is positive.
   *
   * @return The axis value.
   */
  double Get{{ stick.NameParts|map("capitalize")|join }}() const;
{% endfor -%}
{% for trigger in triggers %}
  /**
   * Get the {{ trigger.DocName }} axis value of the controller. Note that this axis is bound
   * to the range of [0, 1] as opposed to the usual [-1, 1].
   *
   * @return The axis value.
   */
  double Get{{ capitalize_first(trigger.name) }}Axis() const;
{% endfor %}
 private:
  wpi::{{ ConsoleName }}Controller m_hid;
};
}  // namespace wpi::cmd
