WPILibC++ 2023.4.3
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#include <wpi/deprecated.h>
8
9#include "Button.h"
10
11namespace frc2 {
12/**
13 * A class used to bind command scheduling to joystick button presses. Can be
14 * composed with other buttons with the operators in Trigger.
15 *
16 * This class is provided by the NewCommands VendorDep
17 *
18 * @see Trigger
19 */
20class JoystickButton : public Button {
21 public:
22 /**
23 * Creates a JoystickButton that commands can be bound to.
24 *
25 * @param joystick The joystick on which the button is located.
26 * @param buttonNumber The number of the button on the joystick.
27 */
28 WPI_IGNORE_DEPRECATED
29 explicit JoystickButton(frc::GenericHID* joystick, int buttonNumber)
30 : Button([joystick, buttonNumber] {
31 return joystick->GetRawButton(buttonNumber);
32 }) {}
33 WPI_UNIGNORE_DEPRECATED
34};
35} // namespace frc2
A class used to bind command scheduling to button presses.
Definition: Button.h:27
A class used to bind command scheduling to joystick button presses.
Definition: JoystickButton.h:20
WPI_IGNORE_DEPRECATED JoystickButton(frc::GenericHID *joystick, int buttonNumber)
Creates a JoystickButton that commands can be bound to.
Definition: JoystickButton.h:29
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: InstantCommand.h:14