001// Copyright (c) FIRST and other WPILib contributors. 002// Open Source Software; you can modify and/or share it under the terms of 003// the WPILib BSD license file in the root directory of this project. 004 005package edu.wpi.first.wpilibj2.command.button; 006 007import static edu.wpi.first.util.ErrorMessages.requireNonNullParam; 008 009import edu.wpi.first.wpilibj.GenericHID; 010 011/** 012 * A {@link Button} that gets its state from a {@link GenericHID}. 013 * 014 * <p>This class is provided by the NewCommands VendorDep 015 */ 016@SuppressWarnings("deprecation") 017public class JoystickButton extends Button { 018 /** 019 * Creates a joystick button for triggering commands. 020 * 021 * @param joystick The GenericHID object that has the button (e.g. Joystick, KinectStick, etc) 022 * @param buttonNumber The button number (see {@link GenericHID#getRawButton(int) } 023 */ 024 public JoystickButton(GenericHID joystick, int buttonNumber) { 025 super(() -> joystick.getRawButton(buttonNumber)); 026 requireNonNullParam(joystick, "joystick", "JoystickButton"); 027 } 028}