3#include <frc/XboxController.h>
4#include <frc/filter/LinearFilter.h>
5#include <units/angle.h>
7#include "valkyrie/sensors/BaseSensor.h"
24class Gamepad :
public frc::XboxController {
51 inline void Reset()
override { filter.Reset(); }
72 this->deadband = deadband;
155 filter = frc::LinearFilter<double>::MovingAverage(size);
186 frc::LinearFilter<double> filter = frc::LinearFilter<double>::MovingAverage(1);
202 inline bool DPadUp()
const {
return GetPOV() == 0; }
210 inline bool DPadDown()
const {
return GetPOV() == 180; }
218 inline bool DPadLeft()
const {
return GetPOV() == 270; }
226 inline bool DPadRight()
const {
return GetPOV() == 90; }
322 AnalogValue leftStickX;
325 AnalogValue leftStickY;
328 AnalogValue rightStickX;
331 AnalogValue rightStickY;
334 AnalogValue leftTrigger;
337 AnalogValue rightTrigger;
Represents a processed analog controller input.
Definition Gamepad.h:37
void Reset() override
Resets the internal filter state.
Definition Gamepad.h:51
bool Active() const
Checks whether the analog input is currently active.
Definition Gamepad.h:61
AnalogValue & SetFilterTime(units::second_t time)
Sets the moving-average filter duration.
Definition Gamepad.h:166
int GetPolynomial() const
Gets the configured polynomial exponent.
Definition Gamepad.h:133
AnalogValue & SetPolynomial(int poly)
Sets the polynomial response curve exponent.
Definition Gamepad.h:123
double GetFiltered() const
Gets the filtered analog value.
Definition Gamepad.h:147
void Calculate() override
Updates the internal filter with the current processed value.
Definition Gamepad.h:140
AnalogValue & SetFilterSize(int size)
Sets the moving-average filter window size.
Definition Gamepad.h:154
double GetMaxValue() const
Gets the configured maximum output value.
Definition Gamepad.h:104
void SetGetter(std::function< double()> getter)
Sets the function used to retrieve the raw input value.
double GetDeadband() const
Gets the configured deadband threshold.
Definition Gamepad.h:97
AnalogValue & SetRange(double min, double max=1)
Sets the output range of the processed analog input.
Definition Gamepad.h:86
AnalogValue & SetDeadband(double deadband)
Sets the deadband applied to the input.
Definition Gamepad.h:71
double GetMinValue() const
Gets the configured minimum output value.
Definition Gamepad.h:111
bool DPadUp() const
Is the gamepad's D-pad up button pressed?
Definition Gamepad.h:202
constexpr AnalogValue & LeftTrigger()
Gets the processed left trigger input.
Definition Gamepad.h:297
constexpr const AnalogValue & LeftTrigger() const
Gets the processed left trigger input.
Definition Gamepad.h:304
void SetRumble(bool turnOn, double intensity=.25)
Sets the rumble for the gamepad.
Gamepad(int id)
Construct a new Valor Gamepad object.
constexpr AnalogValue & LeftStickX()
Gets the processed left stick X-axis input.
Definition Gamepad.h:241
constexpr const AnalogValue & RightTrigger() const
Gets the processed right trigger input.
Definition Gamepad.h:318
bool DPadRight() const
Is the gamepad's D-pad right button pressed?
Definition Gamepad.h:226
constexpr AnalogValue & RightStickY()
Gets the processed right stick Y-axis input.
Definition Gamepad.h:283
constexpr const AnalogValue & LeftStickY() const
Gets the processed left stick Y-axis input.
Definition Gamepad.h:262
constexpr const AnalogValue & RightStickY() const
Gets the processed right stick Y-axis input.
Definition Gamepad.h:290
constexpr const AnalogValue & RightStickX() const
Gets the processed right stick X-axis input.
Definition Gamepad.h:276
constexpr const AnalogValue & LeftStickX() const
Gets the processed left stick X-axis input.
Definition Gamepad.h:248
constexpr AnalogValue & LeftStickY()
Gets the processed left stick Y-axis input.
Definition Gamepad.h:255
bool DPadDown() const
Is the gamepad's D-pad down button pressed?
Definition Gamepad.h:210
constexpr AnalogValue & RightTrigger()
Gets the processed right trigger input.
Definition Gamepad.h:311
constexpr AnalogValue & RightStickX()
Gets the processed right stick X-axis input.
Definition Gamepad.h:269
bool DPadLeft() const
Is the gamepad's D-pad left button pressed?
Definition Gamepad.h:218
Abstract class that all Valor sensors should implement.
Definition BaseSensor.h:52
double Get() const
Definition BaseSensor.h:91