![]() |
WPILibC++ 2027.0.0-alpha-5
|
Handle input from NiDsXbox controllers connected to the Driver Station. More...
#include <wpi/driverstation/NiDsXboxController.hpp>
Classes | |
| struct | Button |
| Represents a digital button on an NiDsXboxController. More... | |
| struct | Axis |
| Represents an axis on an NiDsXboxController. More... | |
Public Member Functions | |
| NiDsXboxController (int port) | |
| Construct an instance of a controller. | |
| ~NiDsXboxController () override=default | |
| NiDsXboxController (NiDsXboxController &&)=default | |
| NiDsXboxController & | operator= (NiDsXboxController &&)=default |
| double | GetLeftX () const |
| Get the X axis value of left side of the controller. | |
| double | GetRightX () const |
| Get the X axis value of right side of the controller. | |
| double | GetLeftY () const |
| Get the Y axis value of left side of the controller. | |
| double | GetRightY () const |
| Get the Y axis value of right side of the controller. | |
| double | GetLeftTriggerAxis () const |
| Get the left trigger axis value of the controller. | |
| BooleanEvent | LeftTrigger (double threshold, EventLoop *loop) const |
| Constructs an event instance around the axis value of the left trigger. | |
| BooleanEvent | LeftTrigger (EventLoop *loop) const |
| Constructs an event instance around the axis value of the left trigger. | |
| double | GetRightTriggerAxis () const |
| Get the right trigger axis value of the controller. | |
| BooleanEvent | RightTrigger (double threshold, EventLoop *loop) const |
| Constructs an event instance around the axis value of the right trigger. | |
| BooleanEvent | RightTrigger (EventLoop *loop) const |
| Constructs an event instance around the axis value of the right trigger. | |
| bool | GetAButton () const |
| Read the value of the A button on the controller. | |
| bool | GetAButtonPressed () |
| Whether the A button was pressed since the last check. | |
| bool | GetAButtonReleased () |
| Whether the A button was released since the last check. | |
| BooleanEvent | A (EventLoop *loop) const |
| Constructs an event instance around the A button's digital signal. | |
| bool | GetBButton () const |
| Read the value of the B button on the controller. | |
| bool | GetBButtonPressed () |
| Whether the B button was pressed since the last check. | |
| bool | GetBButtonReleased () |
| Whether the B button was released since the last check. | |
| BooleanEvent | B (EventLoop *loop) const |
| Constructs an event instance around the B button's digital signal. | |
| bool | GetXButton () const |
| Read the value of the X button on the controller. | |
| bool | GetXButtonPressed () |
| Whether the X button was pressed since the last check. | |
| bool | GetXButtonReleased () |
| Whether the X button was released since the last check. | |
| BooleanEvent | X (EventLoop *loop) const |
| Constructs an event instance around the X button's digital signal. | |
| bool | GetYButton () const |
| Read the value of the Y button on the controller. | |
| bool | GetYButtonPressed () |
| Whether the Y button was pressed since the last check. | |
| bool | GetYButtonReleased () |
| Whether the Y button was released since the last check. | |
| BooleanEvent | Y (EventLoop *loop) const |
| Constructs an event instance around the Y button's digital signal. | |
| bool | GetLeftBumperButton () const |
| Read the value of the left bumper button on the controller. | |
| bool | GetLeftBumperButtonPressed () |
| Whether the left bumper button was pressed since the last check. | |
| bool | GetLeftBumperButtonReleased () |
| Whether the left bumper button was released since the last check. | |
| BooleanEvent | LeftBumper (EventLoop *loop) const |
| Constructs an event instance around the left bumper button's digital signal. | |
| bool | GetRightBumperButton () const |
| Read the value of the right bumper button on the controller. | |
| bool | GetRightBumperButtonPressed () |
| Whether the right bumper button was pressed since the last check. | |
| bool | GetRightBumperButtonReleased () |
| Whether the right bumper button was released since the last check. | |
| BooleanEvent | RightBumper (EventLoop *loop) const |
| Constructs an event instance around the right bumper button's digital signal. | |
| bool | GetBackButton () const |
| Read the value of the back button on the controller. | |
| bool | GetBackButtonPressed () |
| Whether the back button was pressed since the last check. | |
| bool | GetBackButtonReleased () |
| Whether the back button was released since the last check. | |
| BooleanEvent | Back (EventLoop *loop) const |
| Constructs an event instance around the back button's digital signal. | |
| bool | GetStartButton () const |
| Read the value of the start button on the controller. | |
| bool | GetStartButtonPressed () |
| Whether the start button was pressed since the last check. | |
| bool | GetStartButtonReleased () |
| Whether the start button was released since the last check. | |
| BooleanEvent | Start (EventLoop *loop) const |
| Constructs an event instance around the start button's digital signal. | |
| bool | GetLeftStickButton () const |
| Read the value of the left stick button on the controller. | |
| bool | GetLeftStickButtonPressed () |
| Whether the left stick button was pressed since the last check. | |
| bool | GetLeftStickButtonReleased () |
| Whether the left stick button was released since the last check. | |
| BooleanEvent | LeftStick (EventLoop *loop) const |
| Constructs an event instance around the left stick button's digital signal. | |
| bool | GetRightStickButton () const |
| Read the value of the right stick button on the controller. | |
| bool | GetRightStickButtonPressed () |
| Whether the right stick button was pressed since the last check. | |
| bool | GetRightStickButtonReleased () |
| Whether the right stick button was released since the last check. | |
| BooleanEvent | RightStick (EventLoop *loop) const |
| Constructs an event instance around the right stick button's digital signal. | |
| void | InitSendable (wpi::util::SendableBuilder &builder) override |
| Initializes this Sendable object. | |
| Public Member Functions inherited from wpi::GenericHID | |
| GenericHID (int port) | |
| virtual | ~GenericHID ()=default |
| GenericHID (GenericHID &&)=default | |
| GenericHID & | operator= (GenericHID &&)=default |
| bool | GetRawButton (int button) const |
| Get the button value (starting at button 1). | |
| bool | GetRawButtonPressed (int button) |
| Whether the button was pressed since the last check. | |
| bool | GetRawButtonReleased (int button) |
| Whether the button was released since the last check. | |
| BooleanEvent | Button (int button, EventLoop *loop) const |
| Constructs an event instance around this button's digital signal. | |
| double | GetRawAxis (int axis) const |
| Get the value of the axis. | |
| POVDirection | GetPOV (int pov=0) const |
| Get the angle of a POV on the HID. | |
| BooleanEvent | POV (POVDirection angle, EventLoop *loop) const |
| Constructs a BooleanEvent instance based around this angle of a POV on the HID. | |
| BooleanEvent | POV (int pov, POVDirection angle, EventLoop *loop) const |
| Constructs a BooleanEvent instance based around this angle of a POV on the HID. | |
| BooleanEvent | POVUp (EventLoop *loop) const |
| Constructs a BooleanEvent instance based around the up direction of the default (index 0) POV on the HID. | |
| BooleanEvent | POVUpRight (EventLoop *loop) const |
| Constructs a BooleanEvent instance based around the up right direction of the default (index 0) POV on the HID. | |
| BooleanEvent | POVRight (EventLoop *loop) const |
| Constructs a BooleanEvent instance based around the right direction of the default (index 0) POV on the HID. | |
| BooleanEvent | POVDownRight (EventLoop *loop) const |
| Constructs a BooleanEvent instance based around the down right direction of the default (index 0) POV on the HID. | |
| BooleanEvent | POVDown (EventLoop *loop) const |
| Constructs a BooleanEvent instance based around the down direction of the default (index 0) POV on the HID. | |
| BooleanEvent | POVDownLeft (EventLoop *loop) const |
| Constructs a BooleanEvent instance based around the down left direction of the default (index 0) POV on the HID. | |
| BooleanEvent | POVLeft (EventLoop *loop) const |
| Constructs a BooleanEvent instance based around the left direction of the default (index 0) POV on the HID. | |
| BooleanEvent | POVUpLeft (EventLoop *loop) const |
| Constructs a BooleanEvent instance based around the up left direction of the default (index 0) POV on the HID. | |
| BooleanEvent | POVCenter (EventLoop *loop) const |
| Constructs a BooleanEvent instance based around the center (not pressed) of the default (index 0) POV on the HID. | |
| BooleanEvent | AxisLessThan (int axis, double threshold, EventLoop *loop) const |
| Constructs an event instance that is true when the axis value is less than threshold. | |
| BooleanEvent | AxisGreaterThan (int axis, double threshold, EventLoop *loop) const |
| Constructs an event instance that is true when the axis value is greater than threshold. | |
| int | GetAxesMaximumIndex () const |
| int | GetAxesAvailable () const |
| Get the number of axes for the HID. | |
| int | GetPOVsMaximumIndex () const |
| int | GetPOVsAvailable () const |
| Get the number of POVs for the HID. | |
| int | GetButtonsMaximumIndex () const |
| uint64_t | GetButtonsAvailable () const |
| Get the number of buttons for the HID. | |
| bool | IsConnected () const |
| Get if the HID is connected. | |
| GenericHID::HIDType | GetGamepadType () const |
| Get the type of the HID. | |
| SupportedOutputs | GetSupportedOutputs () const |
| Get the supported outputs of the HID. | |
| std::string | GetName () const |
| Get the name of the HID. | |
| int | GetPort () const |
| Get the port number of the HID. | |
| void | SetLeds (int r, int g, int b) |
| Set leds on the controller. | |
| void | SetRumble (RumbleType type, double value) |
| Set the rumble output for the HID. | |
| bool | GetTouchpadFingerAvailable (int touchpad, int finger) const |
| Check if a touchpad finger is available. | |
| TouchpadFinger | GetTouchpadFinger (int touchpad, int finger) const |
| Get the touchpad finger data. | |
| Public Member Functions inherited from wpi::util::Sendable | |
| virtual constexpr | ~Sendable ()=default |
| Public Member Functions inherited from wpi::util::SendableHelper< NiDsXboxController > | |
| constexpr | SendableHelper (const SendableHelper &rhs)=default |
| constexpr SendableHelper & | operator= (const SendableHelper &rhs)=default |
Additional Inherited Members | |
| Public Types inherited from wpi::GenericHID | |
| enum class | RumbleType { LEFT_RUMBLE , RIGHT_RUMBLE , LEFT_TRIGGER_RUMBLE , RIGHT_TRIGGER_RUMBLE } |
| Represents a rumble output on the Joystick. More... | |
| enum class | SupportedOutputs : int { NONE = 0x0 , MONO_LED = 0x1 , RGB_LED = 0x2 , PLAYER_LED = 0x4 , RUMBLE = 0x8 , TRIGGER_RUMBLE = 0x10 } |
| Represents the various outputs that a HID may support. More... | |
| enum class | HIDType { UNKNOWN = 0 , STANDARD , XBOX_360 , XBOX_ONE , PS3 , PS4 , PS5 , SWITCH_PRO , SWITCH_JOYCON_LEFT , SWITCH_JOYCON_RIGHT , SWITCH_JOYCON_PAIR } |
| USB HID interface type. More... | |
| Protected Member Functions inherited from wpi::util::SendableHelper< NiDsXboxController > | |
| constexpr | ~SendableHelper () |
Handle input from NiDsXbox controllers connected to the Driver Station.
This class handles NiDsXbox input that comes from the Driver Station. Each time a value is requested the most recent value is returned. There is a single class instance for each controller and the mapping of ports to hardware buttons depends on the code in the Driver Station.
Only first party controllers from Microsoft are guaranteed to have the correct mapping, and only through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any 3rd party controllers.
|
explicit |
Construct an instance of a controller.
The controller index is the USB port on the Driver Station.
| port | The port on the Driver Station that the controller is plugged into (0-5). |
|
overridedefault |
|
default |
| BooleanEvent wpi::NiDsXboxController::A | ( | EventLoop * | loop | ) | const |
Constructs an event instance around the A button's digital signal.
| loop | the event loop instance to attach the event to. |
| BooleanEvent wpi::NiDsXboxController::B | ( | EventLoop * | loop | ) | const |
Constructs an event instance around the B button's digital signal.
| loop | the event loop instance to attach the event to. |
| BooleanEvent wpi::NiDsXboxController::Back | ( | EventLoop * | loop | ) | const |
Constructs an event instance around the back button's digital signal.
| loop | the event loop instance to attach the event to. |
| bool wpi::NiDsXboxController::GetAButton | ( | ) | const |
Read the value of the A button on the controller.
| bool wpi::NiDsXboxController::GetAButtonPressed | ( | ) |
Whether the A button was pressed since the last check.
| bool wpi::NiDsXboxController::GetAButtonReleased | ( | ) |
Whether the A button was released since the last check.
| bool wpi::NiDsXboxController::GetBackButton | ( | ) | const |
Read the value of the back button on the controller.
| bool wpi::NiDsXboxController::GetBackButtonPressed | ( | ) |
Whether the back button was pressed since the last check.
| bool wpi::NiDsXboxController::GetBackButtonReleased | ( | ) |
Whether the back button was released since the last check.
| bool wpi::NiDsXboxController::GetBButton | ( | ) | const |
Read the value of the B button on the controller.
| bool wpi::NiDsXboxController::GetBButtonPressed | ( | ) |
Whether the B button was pressed since the last check.
| bool wpi::NiDsXboxController::GetBButtonReleased | ( | ) |
Whether the B button was released since the last check.
| bool wpi::NiDsXboxController::GetLeftBumperButton | ( | ) | const |
Read the value of the left bumper button on the controller.
| bool wpi::NiDsXboxController::GetLeftBumperButtonPressed | ( | ) |
Whether the left bumper button was pressed since the last check.
| bool wpi::NiDsXboxController::GetLeftBumperButtonReleased | ( | ) |
Whether the left bumper button was released since the last check.
| bool wpi::NiDsXboxController::GetLeftStickButton | ( | ) | const |
Read the value of the left stick button on the controller.
| bool wpi::NiDsXboxController::GetLeftStickButtonPressed | ( | ) |
Whether the left stick button was pressed since the last check.
| bool wpi::NiDsXboxController::GetLeftStickButtonReleased | ( | ) |
Whether the left stick button was released since the last check.
| double wpi::NiDsXboxController::GetLeftTriggerAxis | ( | ) | const |
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].
| double wpi::NiDsXboxController::GetLeftX | ( | ) | const |
Get the X axis value of left side of the controller.
Right is positive.
| double wpi::NiDsXboxController::GetLeftY | ( | ) | const |
Get the Y axis value of left side of the controller.
Back is positive.
| bool wpi::NiDsXboxController::GetRightBumperButton | ( | ) | const |
Read the value of the right bumper button on the controller.
| bool wpi::NiDsXboxController::GetRightBumperButtonPressed | ( | ) |
Whether the right bumper button was pressed since the last check.
| bool wpi::NiDsXboxController::GetRightBumperButtonReleased | ( | ) |
Whether the right bumper button was released since the last check.
| bool wpi::NiDsXboxController::GetRightStickButton | ( | ) | const |
Read the value of the right stick button on the controller.
| bool wpi::NiDsXboxController::GetRightStickButtonPressed | ( | ) |
Whether the right stick button was pressed since the last check.
| bool wpi::NiDsXboxController::GetRightStickButtonReleased | ( | ) |
Whether the right stick button was released since the last check.
| double wpi::NiDsXboxController::GetRightTriggerAxis | ( | ) | const |
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].
| double wpi::NiDsXboxController::GetRightX | ( | ) | const |
Get the X axis value of right side of the controller.
Right is positive.
| double wpi::NiDsXboxController::GetRightY | ( | ) | const |
Get the Y axis value of right side of the controller.
Back is positive.
| bool wpi::NiDsXboxController::GetStartButton | ( | ) | const |
Read the value of the start button on the controller.
| bool wpi::NiDsXboxController::GetStartButtonPressed | ( | ) |
Whether the start button was pressed since the last check.
| bool wpi::NiDsXboxController::GetStartButtonReleased | ( | ) |
Whether the start button was released since the last check.
| bool wpi::NiDsXboxController::GetXButton | ( | ) | const |
Read the value of the X button on the controller.
| bool wpi::NiDsXboxController::GetXButtonPressed | ( | ) |
Whether the X button was pressed since the last check.
| bool wpi::NiDsXboxController::GetXButtonReleased | ( | ) |
Whether the X button was released since the last check.
| bool wpi::NiDsXboxController::GetYButton | ( | ) | const |
Read the value of the Y button on the controller.
| bool wpi::NiDsXboxController::GetYButtonPressed | ( | ) |
Whether the Y button was pressed since the last check.
| bool wpi::NiDsXboxController::GetYButtonReleased | ( | ) |
Whether the Y button was released since the last check.
|
overridevirtual |
Initializes this Sendable object.
| builder | sendable builder |
Implements wpi::util::Sendable.
| BooleanEvent wpi::NiDsXboxController::LeftBumper | ( | EventLoop * | loop | ) | const |
Constructs an event instance around the left bumper button's digital signal.
| loop | the event loop instance to attach the event to. |
| BooleanEvent wpi::NiDsXboxController::LeftStick | ( | EventLoop * | loop | ) | const |
Constructs an event instance around the left stick button's digital signal.
| loop | the event loop instance to attach the event to. |
| BooleanEvent wpi::NiDsXboxController::LeftTrigger | ( | double | threshold, |
| EventLoop * | loop ) const |
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 threshold.
| threshold | the minimum axis value for the returned event to be true. This value should be in the range [0, 1] where 0 is the unpressed state of the axis. |
| loop | the event loop instance to attach the event to. |
| BooleanEvent wpi::NiDsXboxController::LeftTrigger | ( | EventLoop * | loop | ) | const |
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 0.5.
| loop | the event loop instance to attach the event to. |
|
default |
| BooleanEvent wpi::NiDsXboxController::RightBumper | ( | EventLoop * | loop | ) | const |
Constructs an event instance around the right bumper button's digital signal.
| loop | the event loop instance to attach the event to. |
| BooleanEvent wpi::NiDsXboxController::RightStick | ( | EventLoop * | loop | ) | const |
Constructs an event instance around the right stick button's digital signal.
| loop | the event loop instance to attach the event to. |
| BooleanEvent wpi::NiDsXboxController::RightTrigger | ( | double | threshold, |
| EventLoop * | loop ) const |
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 threshold.
| threshold | the minimum axis value for the returned event to be true. This value should be in the range [0, 1] where 0 is the unpressed state of the axis. |
| loop | the event loop instance to attach the event to. |
| BooleanEvent wpi::NiDsXboxController::RightTrigger | ( | EventLoop * | loop | ) | const |
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 0.5.
| loop | the event loop instance to attach the event to. |
| BooleanEvent wpi::NiDsXboxController::Start | ( | EventLoop * | loop | ) | const |
Constructs an event instance around the start button's digital signal.
| loop | the event loop instance to attach the event to. |
| BooleanEvent wpi::NiDsXboxController::X | ( | EventLoop * | loop | ) | const |
Constructs an event instance around the X button's digital signal.
| loop | the event loop instance to attach the event to. |
| BooleanEvent wpi::NiDsXboxController::Y | ( | EventLoop * | loop | ) | const |
Constructs an event instance around the Y button's digital signal.
| loop | the event loop instance to attach the event to. |