WPILibC++ 2024.3.2
JoystickButton.h
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
6#include <frc/GenericHID.h>
7
8#include "Trigger.h"
9
10namespace frc2 {
11/**
12 * A class used to bind command scheduling to joystick button presses. Can be
13 * composed with other buttons with the operators in Trigger.
14 *
15 * This class is provided by the NewCommands VendorDep
16 *
17 * @see Trigger
18 */
19class JoystickButton : public Trigger {
20 public:
21 /**
22 * Creates a JoystickButton that commands can be bound to.
23 *
24 * @param joystick The joystick on which the button is located.
25 * @param buttonNumber The number of the button on the joystick.
26 */
27 explicit JoystickButton(frc::GenericHID* joystick, int buttonNumber)
28 : Trigger([joystick, buttonNumber] {
29 return joystick->GetRawButton(buttonNumber);
30 }) {}
31};
32} // namespace frc2
A class used to bind command scheduling to joystick button presses.
Definition: JoystickButton.h:19
JoystickButton(frc::GenericHID *joystick, int buttonNumber)
Creates a JoystickButton that commands can be bound to.
Definition: JoystickButton.h:27
This class provides an easy way to link commands to conditions.
Definition: Trigger.h:31
Handle input from standard HID devices connected to the Driver Station.
Definition: GenericHID.h:24
bool GetRawButton(int button) const
Get the button value (starting at button 1).
Definition: TrapezoidProfileSubsystem.h:12