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.commands3.button; 006 007import static edu.wpi.first.util.ErrorMessages.requireNonNullParam; 008 009import edu.wpi.first.wpilibj.DriverStation.POVDirection; 010import edu.wpi.first.wpilibj.GenericHID; 011import org.wpilib.commands3.Trigger; 012 013/** A {@link Trigger} that gets its state from a POV on a {@link GenericHID}. */ 014public class POVButton extends Trigger { 015 /** 016 * Creates a POV button for triggering commands. 017 * 018 * @param joystick The GenericHID object that has the POV 019 * @param angle The desired angle 020 * @param povNumber The POV number (see {@link GenericHID#getPOV(int)}) 021 */ 022 public POVButton(GenericHID joystick, POVDirection angle, int povNumber) { 023 super(() -> joystick.getPOV(povNumber) == angle); 024 requireNonNullParam(joystick, "joystick", "POVButton"); 025 } 026 027 /** 028 * Creates a POV button for triggering commands. By default, acts on POV 0 029 * 030 * @param joystick The GenericHID object that has the POV 031 * @param angle The desired angle 032 */ 033 public POVButton(GenericHID joystick, POVDirection angle) { 034 this(joystick, angle, 0); 035 } 036}