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 edu.wpi.first.wpilibj.DriverStation;
008import org.wpilib.commands3.Trigger;
009
010/**
011 * A class containing static {@link Trigger} factories for running callbacks when the robot mode
012 * changes.
013 */
014public final class RobotModeTriggers {
015  // Utility class
016  private RobotModeTriggers() {}
017
018  /**
019   * Returns a trigger that is true when the robot is enabled in autonomous mode.
020   *
021   * @return A trigger that is true when the robot is enabled in autonomous mode.
022   */
023  public static Trigger autonomous() {
024    return new Trigger(DriverStation::isAutonomousEnabled);
025  }
026
027  /**
028   * Returns a trigger that is true when the robot is enabled in teleop mode.
029   *
030   * @return A trigger that is true when the robot is enabled in teleop mode.
031   */
032  public static Trigger teleop() {
033    return new Trigger(DriverStation::isTeleopEnabled);
034  }
035
036  /**
037   * Returns a trigger that is true when the robot is disabled.
038   *
039   * @return A trigger that is true when the robot is disabled.
040   */
041  public static Trigger disabled() {
042    return new Trigger(DriverStation::isDisabled);
043  }
044
045  /**
046   * Returns a trigger that is true when the robot is enabled in test mode.
047   *
048   * @return A trigger that is true when the robot is enabled in test mode.
049   */
050  public static Trigger test() {
051    return new Trigger(DriverStation::isTestEnabled);
052  }
053}