WPILibC++  2020.3.2
JoystickButton.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 #include <frc/GenericHID.h>
10 
11 #include "Button.h"
12 
13 namespace frc2 {
20 class JoystickButton : public Button {
21  public:
28  explicit JoystickButton(frc::GenericHID* joystick, int buttonNumber)
29  : Button([joystick, buttonNumber] {
30  return joystick->GetRawButton(buttonNumber);
31  }) {}
32 };
33 } // namespace frc2
frc2::Button
A class used to bind command scheduling to button presses.
Definition: Button.h:26
frc::GenericHID::GetRawButton
bool GetRawButton(int button) const
Get the button value (starting at button 1).
frc2::JoystickButton::JoystickButton
JoystickButton(frc::GenericHID *joystick, int buttonNumber)
Creates a JoystickButton that commands can be bound to.
Definition: JoystickButton.h:28
frc::GenericHID
GenericHID Interface.
Definition: GenericHID.h:23
frc2::JoystickButton
A class used to bind command scheduling to joystick button presses.
Definition: JoystickButton.h:20