WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
JoystickButton.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
8
9namespace wpi::cmd {
10/**
11 * A class used to bind command scheduling to joystick button presses. Can be
12 * composed with other buttons with the operators in Trigger.
13 *
14 * This class is provided by the NewCommands VendorDep
15 *
16 * @see Trigger
17 */
18class JoystickButton : public Trigger {
19 public:
20 /**
21 * Creates a JoystickButton that commands can be bound to.
22 *
23 * @param joystick The joystick on which the button is located.
24 * @param buttonNumber The number of the button on the joystick.
25 */
26 explicit JoystickButton(wpi::GenericHID* joystick, int buttonNumber)
27 : Trigger([joystick, buttonNumber] {
28 return joystick->GetRawButton(buttonNumber);
29 }) {}
30};
31} // namespace wpi::cmd
Handle input from standard HID devices connected to the Driver Station.
Definition GenericHID.hpp:26
bool GetRawButton(int button) const
Get the button value (starting at button 1).
JoystickButton(wpi::GenericHID *joystick, int buttonNumber)
Creates a JoystickButton that commands can be bound to.
Definition JoystickButton.hpp:26
Trigger(std::function< bool()> condition)
Creates a new trigger based on the given condition.
Definition Trigger.hpp:40
Definition CommandNiDsStadiaController.hpp:15