mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
[wpilib] Add a default deadband to all gamepads (#8897)
The FTC DS had a deadband. Additionally, the FRC one had an implicit deadband due to the only 8 bit resolution. We need a deadband by default now with the high resolution gamepads.
This commit is contained in:
@@ -116,39 +116,99 @@ class Gamepad : public GenericHID,
|
||||
/**
|
||||
* Get the X axis value of left side of the controller. Right is positive.
|
||||
*
|
||||
* A deadband of 0.1 is applied by default. Use SetLeftXDeadband() to change
|
||||
* it.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetLeftX() const;
|
||||
|
||||
/**
|
||||
* Set the deadband for the left X axis.
|
||||
*
|
||||
* The deadband is clamped to [0, 1).
|
||||
*
|
||||
* @param deadband The deadband to apply.
|
||||
*/
|
||||
void SetLeftXDeadband(double deadband);
|
||||
|
||||
/**
|
||||
* Get the Y axis value of left side of the controller. Back is positive.
|
||||
*
|
||||
* A deadband of 0.1 is applied by default. Use SetLeftYDeadband() to change
|
||||
* it.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetLeftY() const;
|
||||
|
||||
/**
|
||||
* Set the deadband for the left Y axis.
|
||||
*
|
||||
* The deadband is clamped to [0, 1).
|
||||
*
|
||||
* @param deadband The deadband to apply.
|
||||
*/
|
||||
void SetLeftYDeadband(double deadband);
|
||||
|
||||
/**
|
||||
* Get the X axis value of right side of the controller. Right is positive.
|
||||
*
|
||||
* A deadband of 0.1 is applied by default. Use SetRightXDeadband() to change
|
||||
* it.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetRightX() const;
|
||||
|
||||
/**
|
||||
* Set the deadband for the right X axis.
|
||||
*
|
||||
* The deadband is clamped to [0, 1).
|
||||
*
|
||||
* @param deadband The deadband to apply.
|
||||
*/
|
||||
void SetRightXDeadband(double deadband);
|
||||
|
||||
/**
|
||||
* Get the Y axis value of right side of the controller. Back is positive.
|
||||
*
|
||||
* A deadband of 0.1 is applied by default. Use SetRightYDeadband() to change
|
||||
* it.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetRightY() const;
|
||||
|
||||
/**
|
||||
* Set the deadband for the right Y axis.
|
||||
*
|
||||
* The deadband is clamped to [0, 1).
|
||||
*
|
||||
* @param deadband The deadband to apply.
|
||||
*/
|
||||
void SetRightYDeadband(double deadband);
|
||||
|
||||
/**
|
||||
* Get the left trigger axis value of the controller. Note that this axis
|
||||
* is bound to the range of [0, 1] as opposed to the usual [-1, 1].
|
||||
*
|
||||
* A deadband of 0.01 is applied by default. Use SetLeftTriggerDeadband() to
|
||||
* change it.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetLeftTriggerAxis() const;
|
||||
|
||||
/**
|
||||
* Set the deadband for the left trigger axis.
|
||||
*
|
||||
* The deadband is clamped to [0, 1).
|
||||
*
|
||||
* @param deadband The deadband to apply.
|
||||
*/
|
||||
void SetLeftTriggerDeadband(double deadband);
|
||||
|
||||
/**
|
||||
* Constructs an event instance around the axis value of the left trigger.
|
||||
* The returned trigger will be true when the axis value is greater than
|
||||
@@ -175,10 +235,22 @@ class Gamepad : public GenericHID,
|
||||
* Get the right trigger axis value of the controller. Note that this axis
|
||||
* is bound to the range of [0, 1] as opposed to the usual [-1, 1].
|
||||
*
|
||||
* A deadband of 0.01 is applied by default. Use SetRightTriggerDeadband() to
|
||||
* change it.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetRightTriggerAxis() const;
|
||||
|
||||
/**
|
||||
* Set the deadband for the right trigger axis.
|
||||
*
|
||||
* The deadband is clamped to [0, 1).
|
||||
*
|
||||
* @param deadband The deadband to apply.
|
||||
*/
|
||||
void SetRightTriggerDeadband(double deadband);
|
||||
|
||||
/**
|
||||
* Constructs an event instance around the axis value of the right trigger.
|
||||
* The returned trigger will be true when the axis value is greater than
|
||||
@@ -1090,6 +1162,13 @@ class Gamepad : public GenericHID,
|
||||
private:
|
||||
double GetAxisForSendable(Axis axis) const;
|
||||
bool GetButtonForSendable(Button button) const;
|
||||
|
||||
double m_leftXDeadband = 0.1;
|
||||
double m_leftYDeadband = 0.1;
|
||||
double m_rightXDeadband = 0.1;
|
||||
double m_rightYDeadband = 0.1;
|
||||
double m_leftTriggerDeadband = 0.01;
|
||||
double m_rightTriggerDeadband = 0.01;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
|
||||
Reference in New Issue
Block a user