WPILibC++ 2027.0.0-alpha-5
Loading...
Searching...
No Matches
GamepadButton.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 gamepad button presses. Can be
12 * composed with other buttons with the operators in Trigger.
13 *
14 * This class is provided by the Commands v2 VendorDep
15 *
16 * @see Trigger
17 */
18class GamepadButton : public Trigger {
19 public:
20 /**
21 * Creates a GamepadButton that commands can be bound to.
22 *
23 * @param gamepad The gamepad on which the button is located.
24 * @param button The button
25 */
26 explicit GamepadButton(wpi::Gamepad* gamepad,
27 enum wpi::Gamepad::Button button)
28 : Trigger([gamepad, button] { return gamepad->GetButton(button); }) {}
29};
30} // namespace wpi::cmd
Handle input from Gamepad controllers connected to the Driver Station.
Definition Gamepad.hpp:27
bool GetButton(Button button) const
Get the button value.
Button
Represents a digital button on an Gamepad.
Definition Gamepad.hpp:30
GamepadButton(wpi::Gamepad *gamepad, enum wpi::Gamepad::Button button)
Creates a GamepadButton that commands can be bound to.
Definition GamepadButton.hpp:26
Trigger(std::function< bool()> condition)
Creates a new trigger based on the given condition.
Definition Trigger.hpp:40
Definition CommandNiDsStadiaController.hpp:15