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.command2.button;
006
007import static org.wpilib.util.ErrorMessages.requireNonNullParam;
008
009import org.wpilib.driverstation.Gamepad;
010
011/**
012 * A {@link Trigger} that gets its state from a {@link Gamepad}.
013 *
014 * <p>This class is provided by the Commands v2 VendorDep
015 */
016public class GamepadButton extends Trigger {
017  /**
018   * Creates a gamepad button for triggering commands.
019   *
020   * @param gamepad The gamepad on which the button is located.
021   * @param button The button
022   */
023  public GamepadButton(Gamepad gamepad, Gamepad.Button button) {
024    super(() -> gamepad.getButton(button));
025    requireNonNullParam(gamepad, "gamepad", "GamepadButton");
026  }
027}