mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
[hal,wpilib] Use new DS available API from mrccomm (#8302)
Instead of just having a max count for joystick values, there's an available mask of values. This is because in the future we're expecting there to be holes in the list of available buttons and axes. This updates everything to support that scenario. Also, Joystick buttons, axes, and POVs all now start at 0 instead of 1.
This commit is contained in:
@@ -13,15 +13,15 @@ using namespace frc::sim;
|
||||
|
||||
PS4ControllerSim::PS4ControllerSim(const PS4Controller& joystick)
|
||||
: GenericHIDSim{joystick} {
|
||||
SetAxisCount(6);
|
||||
SetButtonCount(14);
|
||||
SetPOVCount(1);
|
||||
SetAxesMaximumIndex(6);
|
||||
SetButtonsMaximumIndex(14);
|
||||
SetPOVsMaximumIndex(1);
|
||||
}
|
||||
|
||||
PS4ControllerSim::PS4ControllerSim(int port) : GenericHIDSim{port} {
|
||||
SetAxisCount(6);
|
||||
SetButtonCount(14);
|
||||
SetPOVCount(1);
|
||||
SetAxesMaximumIndex(6);
|
||||
SetButtonsMaximumIndex(14);
|
||||
SetPOVsMaximumIndex(1);
|
||||
}
|
||||
|
||||
void PS4ControllerSim::SetLeftX(double value) {
|
||||
|
||||
@@ -13,15 +13,15 @@ using namespace frc::sim;
|
||||
|
||||
PS5ControllerSim::PS5ControllerSim(const PS5Controller& joystick)
|
||||
: GenericHIDSim{joystick} {
|
||||
SetAxisCount(6);
|
||||
SetButtonCount(14);
|
||||
SetPOVCount(1);
|
||||
SetAxesMaximumIndex(6);
|
||||
SetButtonsMaximumIndex(14);
|
||||
SetPOVsMaximumIndex(1);
|
||||
}
|
||||
|
||||
PS5ControllerSim::PS5ControllerSim(int port) : GenericHIDSim{port} {
|
||||
SetAxisCount(6);
|
||||
SetButtonCount(14);
|
||||
SetPOVCount(1);
|
||||
SetAxesMaximumIndex(6);
|
||||
SetButtonsMaximumIndex(14);
|
||||
SetPOVsMaximumIndex(1);
|
||||
}
|
||||
|
||||
void PS5ControllerSim::SetLeftX(double value) {
|
||||
|
||||
@@ -13,15 +13,15 @@ using namespace frc::sim;
|
||||
|
||||
StadiaControllerSim::StadiaControllerSim(const StadiaController& joystick)
|
||||
: GenericHIDSim{joystick} {
|
||||
SetAxisCount(4);
|
||||
SetButtonCount(15);
|
||||
SetPOVCount(1);
|
||||
SetAxesMaximumIndex(4);
|
||||
SetButtonsMaximumIndex(15);
|
||||
SetPOVsMaximumIndex(1);
|
||||
}
|
||||
|
||||
StadiaControllerSim::StadiaControllerSim(int port) : GenericHIDSim{port} {
|
||||
SetAxisCount(4);
|
||||
SetButtonCount(15);
|
||||
SetPOVCount(1);
|
||||
SetAxesMaximumIndex(4);
|
||||
SetButtonsMaximumIndex(15);
|
||||
SetPOVsMaximumIndex(1);
|
||||
}
|
||||
|
||||
void StadiaControllerSim::SetLeftX(double value) {
|
||||
|
||||
@@ -13,15 +13,15 @@ using namespace frc::sim;
|
||||
|
||||
XboxControllerSim::XboxControllerSim(const XboxController& joystick)
|
||||
: GenericHIDSim{joystick} {
|
||||
SetAxisCount(6);
|
||||
SetButtonCount(10);
|
||||
SetPOVCount(1);
|
||||
SetAxesMaximumIndex(6);
|
||||
SetButtonsMaximumIndex(10);
|
||||
SetPOVsMaximumIndex(1);
|
||||
}
|
||||
|
||||
XboxControllerSim::XboxControllerSim(int port) : GenericHIDSim{port} {
|
||||
SetAxisCount(6);
|
||||
SetButtonCount(10);
|
||||
SetPOVCount(1);
|
||||
SetAxesMaximumIndex(6);
|
||||
SetButtonsMaximumIndex(10);
|
||||
SetPOVsMaximumIndex(1);
|
||||
}
|
||||
|
||||
void XboxControllerSim::SetLeftX(double value) {
|
||||
|
||||
@@ -557,33 +557,33 @@ class PS4Controller : public GenericHID,
|
||||
/** Represents a digital button on an PS4Controller. */
|
||||
struct Button {
|
||||
/// Square button.
|
||||
static constexpr int kSquare = 1;
|
||||
static constexpr int kSquare = 0;
|
||||
/// Cross button.
|
||||
static constexpr int kCross = 2;
|
||||
static constexpr int kCross = 1;
|
||||
/// Circle button.
|
||||
static constexpr int kCircle = 3;
|
||||
static constexpr int kCircle = 2;
|
||||
/// Triangle button.
|
||||
static constexpr int kTriangle = 4;
|
||||
static constexpr int kTriangle = 3;
|
||||
/// Left trigger 1 button.
|
||||
static constexpr int kL1 = 5;
|
||||
static constexpr int kL1 = 4;
|
||||
/// Right trigger 1 button.
|
||||
static constexpr int kR1 = 6;
|
||||
static constexpr int kR1 = 5;
|
||||
/// Left trigger 2 button.
|
||||
static constexpr int kL2 = 7;
|
||||
static constexpr int kL2 = 6;
|
||||
/// Right trigger 2 button.
|
||||
static constexpr int kR2 = 8;
|
||||
static constexpr int kR2 = 7;
|
||||
/// Share button.
|
||||
static constexpr int kShare = 9;
|
||||
static constexpr int kShare = 8;
|
||||
/// Options button.
|
||||
static constexpr int kOptions = 10;
|
||||
static constexpr int kOptions = 9;
|
||||
/// L3 (left stick) button.
|
||||
static constexpr int kL3 = 11;
|
||||
static constexpr int kL3 = 10;
|
||||
/// R3 (right stick) button.
|
||||
static constexpr int kR3 = 12;
|
||||
static constexpr int kR3 = 11;
|
||||
/// PlayStation button.
|
||||
static constexpr int kPS = 13;
|
||||
static constexpr int kPS = 12;
|
||||
/// Touchpad button.
|
||||
static constexpr int kTouchpad = 14;
|
||||
static constexpr int kTouchpad = 13;
|
||||
};
|
||||
|
||||
/** Represents an axis on an PS4Controller. */
|
||||
|
||||
@@ -557,33 +557,33 @@ class PS5Controller : public GenericHID,
|
||||
/** Represents a digital button on an PS5Controller. */
|
||||
struct Button {
|
||||
/// Square button.
|
||||
static constexpr int kSquare = 1;
|
||||
static constexpr int kSquare = 0;
|
||||
/// Cross button.
|
||||
static constexpr int kCross = 2;
|
||||
static constexpr int kCross = 1;
|
||||
/// Circle button.
|
||||
static constexpr int kCircle = 3;
|
||||
static constexpr int kCircle = 2;
|
||||
/// Triangle button.
|
||||
static constexpr int kTriangle = 4;
|
||||
static constexpr int kTriangle = 3;
|
||||
/// Left trigger 1 button.
|
||||
static constexpr int kL1 = 5;
|
||||
static constexpr int kL1 = 4;
|
||||
/// Right trigger 1 button.
|
||||
static constexpr int kR1 = 6;
|
||||
static constexpr int kR1 = 5;
|
||||
/// Left trigger 2 button.
|
||||
static constexpr int kL2 = 7;
|
||||
static constexpr int kL2 = 6;
|
||||
/// Right trigger 2 button.
|
||||
static constexpr int kR2 = 8;
|
||||
static constexpr int kR2 = 7;
|
||||
/// Create button.
|
||||
static constexpr int kCreate = 9;
|
||||
static constexpr int kCreate = 8;
|
||||
/// Options button.
|
||||
static constexpr int kOptions = 10;
|
||||
static constexpr int kOptions = 9;
|
||||
/// L3 (left stick) button.
|
||||
static constexpr int kL3 = 11;
|
||||
static constexpr int kL3 = 10;
|
||||
/// R3 (right stick) button.
|
||||
static constexpr int kR3 = 12;
|
||||
static constexpr int kR3 = 11;
|
||||
/// PlayStation button.
|
||||
static constexpr int kPS = 13;
|
||||
static constexpr int kPS = 12;
|
||||
/// Touchpad button.
|
||||
static constexpr int kTouchpad = 14;
|
||||
static constexpr int kTouchpad = 13;
|
||||
};
|
||||
|
||||
/** Represents an axis on an PS5Controller. */
|
||||
|
||||
@@ -606,35 +606,35 @@ class StadiaController : public GenericHID,
|
||||
/** Represents a digital button on an StadiaController. */
|
||||
struct Button {
|
||||
/// A button.
|
||||
static constexpr int kA = 1;
|
||||
static constexpr int kA = 0;
|
||||
/// B button.
|
||||
static constexpr int kB = 2;
|
||||
static constexpr int kB = 1;
|
||||
/// X button.
|
||||
static constexpr int kX = 3;
|
||||
static constexpr int kX = 2;
|
||||
/// Y button.
|
||||
static constexpr int kY = 4;
|
||||
static constexpr int kY = 3;
|
||||
/// Left bumper button.
|
||||
static constexpr int kLeftBumper = 5;
|
||||
static constexpr int kLeftBumper = 4;
|
||||
/// Right bumper button.
|
||||
static constexpr int kRightBumper = 6;
|
||||
static constexpr int kRightBumper = 5;
|
||||
/// Left stick button.
|
||||
static constexpr int kLeftStick = 7;
|
||||
static constexpr int kLeftStick = 6;
|
||||
/// Right stick button.
|
||||
static constexpr int kRightStick = 8;
|
||||
static constexpr int kRightStick = 7;
|
||||
/// Ellipses button.
|
||||
static constexpr int kEllipses = 9;
|
||||
static constexpr int kEllipses = 8;
|
||||
/// Hamburger button.
|
||||
static constexpr int kHamburger = 10;
|
||||
static constexpr int kHamburger = 9;
|
||||
/// Stadia button.
|
||||
static constexpr int kStadia = 11;
|
||||
static constexpr int kStadia = 10;
|
||||
/// Right trigger button.
|
||||
static constexpr int kRightTrigger = 12;
|
||||
static constexpr int kRightTrigger = 11;
|
||||
/// Left trigger button.
|
||||
static constexpr int kLeftTrigger = 13;
|
||||
static constexpr int kLeftTrigger = 12;
|
||||
/// Google button.
|
||||
static constexpr int kGoogle = 14;
|
||||
static constexpr int kGoogle = 13;
|
||||
/// Frame button.
|
||||
static constexpr int kFrame = 15;
|
||||
static constexpr int kFrame = 14;
|
||||
};
|
||||
|
||||
/** Represents an axis on an StadiaController. */
|
||||
|
||||
@@ -511,25 +511,25 @@ class XboxController : public GenericHID,
|
||||
/** Represents a digital button on an XboxController. */
|
||||
struct Button {
|
||||
/// A button.
|
||||
static constexpr int kA = 1;
|
||||
static constexpr int kA = 0;
|
||||
/// B button.
|
||||
static constexpr int kB = 2;
|
||||
static constexpr int kB = 1;
|
||||
/// X button.
|
||||
static constexpr int kX = 3;
|
||||
static constexpr int kX = 2;
|
||||
/// Y button.
|
||||
static constexpr int kY = 4;
|
||||
static constexpr int kY = 3;
|
||||
/// Left bumper button.
|
||||
static constexpr int kLeftBumper = 5;
|
||||
static constexpr int kLeftBumper = 4;
|
||||
/// Right bumper button.
|
||||
static constexpr int kRightBumper = 6;
|
||||
static constexpr int kRightBumper = 5;
|
||||
/// Back button.
|
||||
static constexpr int kBack = 7;
|
||||
static constexpr int kBack = 6;
|
||||
/// Start button.
|
||||
static constexpr int kStart = 8;
|
||||
static constexpr int kStart = 7;
|
||||
/// Left stick button.
|
||||
static constexpr int kLeftStick = 9;
|
||||
static constexpr int kLeftStick = 8;
|
||||
/// Right stick button.
|
||||
static constexpr int kRightStick = 10;
|
||||
static constexpr int kRightStick = 9;
|
||||
};
|
||||
|
||||
/** Represents an axis on an XboxController. */
|
||||
|
||||
Reference in New Issue
Block a user