mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
SCRIPT Generic Renames
This commit is contained in:
committed by
Peter Johnson
parent
c350c5f112
commit
12823a003d
@@ -0,0 +1,92 @@
|
||||
// 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 <frc/{{ ConsoleName }}Controller.h>
|
||||
|
||||
#include "frc2/command/button/Trigger.h"
|
||||
#include "frc2/command/CommandScheduler.h"
|
||||
#include "frc2/command/button/CommandGenericHID.h"
|
||||
|
||||
namespace frc2 {
|
||||
/**
|
||||
* A version of {@link frc::{{ ConsoleName }}Controller} with {@link Trigger} factories for
|
||||
* command-based.
|
||||
*
|
||||
* @see frc::{{ 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
|
||||
*/
|
||||
frc::{{ 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) }}(frc::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,
|
||||
frc::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:
|
||||
frc::{{ ConsoleName }}Controller m_hid;
|
||||
};
|
||||
} // namespace frc2
|
||||
Reference in New Issue
Block a user