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 org.wpilib.command3.button;
006
007import static org.wpilib.util.ErrorMessages.requireNonNullParam;
008
009import org.wpilib.command3.Trigger;
010import org.wpilib.driverstation.GenericHID;
011
012/** A {@link Trigger} that gets its state from a {@link GenericHID}. */
013public class JoystickButton extends Trigger {
014  /**
015   * Creates a joystick button for triggering commands.
016   *
017   * @param joystick The GenericHID object that has the button (e.g. Joystick, KinectStick, etc)
018   * @param buttonNumber The button number (see {@link GenericHID#getRawButton(int) }
019   */
020  public JoystickButton(GenericHID joystick, int buttonNumber) {
021    super(() -> joystick.getRawButton(buttonNumber));
022    requireNonNullParam(joystick, "joystick", "JoystickButton");
023  }
024}