Valor 6800 1.0
Loading...
Searching...
No Matches
Gamepad.h
1
2#pragma once
3
4#include <frc/XboxController.h>
5#include <frc/filter/LinearFilter.h>
6#include <units/angle.h>
7
8namespace valor {
9
20class Gamepad : public frc::XboxController {
21 public:
27 explicit Gamepad(int id);
28
41 void setDeadbandX(double deadband);
42
55 void setDeadbandY(double deadband);
56
71 double leftStickX(int polynomial = 1);
81 double leftStickXFiltered(int polynomial = 1);
82
90 bool leftStickXActive(int polynomial = 1);
91
105 double leftStickY(int polynomial = 1);
115 double leftStickYFiltered(int polynomial = 1);
116
124 bool leftStickYActive(int polynomial = 1);
125
139 double rightStickX(int polynomial = 1);
149 double rightStickXFiltered(int polynomial = 1);
150
158 bool rightStickXActive(int polynomial = 1);
159
174 double rightStickY(int polynomial = 1);
184 double rightStickYFiltered(int polynomial = 1);
185
193 bool rightStickYActive(int polynomial = 1);
194
200 double rightTrigger();
201
209
215 double leftTrigger();
216
224
231 bool DPadUp();
232
239 bool DPadDown();
240
247 bool DPadLeft();
248
255 bool DPadRight();
256
264
272
279 void setRumble(bool turnOn, double intensity = .25);
280
289 void setJoystickFilterCacheSize(int cacheSize);
290
299 units::angle::radian_t getLeftStickAngle();
308 units::angle::radian_t getRightStickAngle();
309
310 private:
323 double deadband(double input, double deadband, int polynomial);
324
328 double deadbandX;
332 double deadbandY;
333
337 double joystickFilterCacheSize = 5;
338
342 frc::LinearFilter<double> leftJoystickX = frc::LinearFilter<double>::MovingAverage(joystickFilterCacheSize);
346 frc::LinearFilter<double> rightJoystickX = frc::LinearFilter<double>::MovingAverage(joystickFilterCacheSize);
350 frc::LinearFilter<double> leftJoystickY = frc::LinearFilter<double>::MovingAverage(joystickFilterCacheSize);
354 frc::LinearFilter<double> rightJoystickY = frc::LinearFilter<double>::MovingAverage(joystickFilterCacheSize);
355};
356} // namespace valor
Wrapper class for XBox gamepads.
Definition Gamepad.h:20
bool DPadLeft()
Is the gamepad's D-pad left button pressed?
units::angle::radian_t getRightStickAngle()
Gets the angle of the right joystick in a field-relative perspective.
void setJoystickFilterCacheSize(int cacheSize)
Sets the cache size for the joystick filters.
void setDeadbandY(double deadband)
Set the Y deadband value.
double leftTrigger()
Obtain the gamepad's left trigger value.
double leftStickY(int polynomial=1)
Obtain the Y value from the gamepad's left thumb stick.
double rightStickXFiltered(int polynomial=1)
Obtain the X value from the gamepad's right thumb stick, with filtering applied.
Gamepad(int id)
Construct a new Valor Gamepad object.
bool rightStickXActive(int polynomial=1)
Is the gamepad's right X thumb stick active?
bool rightStickYActive(int polynomial=1)
Is the gamepad's right Y thumb stick active?
double rightStickYFiltered(int polynomial=1)
Obtain the Y value from the gamepad's right thumb stick, with filtering applied.
bool DPadRight()
Is the gamepad's D-pad right button pressed?
bool leftStickXActive(int polynomial=1)
Is the gamepad's left X thumb stick active?
bool rightTriggerActive()
Is the gamepad's right trigger active?
bool DPadUp()
Is the gamepad's D-pad up button pressed?
void setDeadbandX(double deadband)
Set the X deadband value.
units::angle::radian_t getLeftStickAngle()
Gets the angle of the left joystick in a field-relative perspective.
bool getLeftStickButton()
Get the state of the left stick button.
double leftStickXFiltered(int polynomial=1)
Obtain the X value from the gamepad's left thumb stick, with filtering applied.
bool leftStickYActive(int polynomial=1)
Is the gamepad's left Y thumb stick active?
double rightStickX(int polynomial=1)
Obtain the X value from the gamepad's right thumb stick.
double rightTrigger()
Obtain the gamepad's right trigger value.
bool leftTriggerActive()
Is the gamepad's left trigger active?
double leftStickYFiltered(int polynomial=1)
Obtain the Y value from the gamepad's left thumb stick, with filtering applied.
double rightStickY(int polynomial=1)
Obtain the Y value from the gamepad's right thumb stick.
bool getRightStickButton()
Get the state of the right stick button.
void setRumble(bool turnOn, double intensity=.25)
Sets the rumble for the gamepad.
double leftStickX(int polynomial=1)
Obtain the X value from the gamepad's left thumb stick.
bool DPadDown()
Is the gamepad's D-pad down button pressed?