diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/RobotModeTriggers.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/RobotModeTriggers.java index 9bef66abfa3..42984dade56 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/RobotModeTriggers.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/RobotModeTriggers.java @@ -14,39 +14,15 @@ public final class RobotModeTriggers { // Utility class private RobotModeTriggers() {} - /** - * Returns a trigger that is true when the robot is enabled in autonomous mode. - * - * @return A trigger that is true when the robot is enabled in autonomous mode. - */ - public static Trigger autonomous() { - return new Trigger(DriverStation::isAutonomousEnabled); - } + /** A trigger that is true when the robot is enabled in autonomous mode. */ + public static final Trigger autonomous = new Trigger(DriverStation::isAutonomousEnabled); - /** - * Returns a trigger that is true when the robot is enabled in teleop mode. - * - * @return A trigger that is true when the robot is enabled in teleop mode. - */ - public static Trigger teleop() { - return new Trigger(DriverStation::isTeleopEnabled); - } + /** A trigger that is true when the robot is enabled in teleop mode. */ + public static final Trigger teleop = new Trigger(DriverStation::isTeleopEnabled); - /** - * Returns a trigger that is true when the robot is disabled. - * - * @return A trigger that is true when the robot is disabled. - */ - public static Trigger disabled() { - return new Trigger(DriverStation::isDisabled); - } + /** A trigger that is true when the robot is disabled. */ + public static final Trigger disabled = new Trigger(DriverStation::isDisabled); - /** - * Returns a trigger that is true when the robot is enabled in test mode. - * - * @return A trigger that is true when the robot is enabled in test mode. - */ - public static Trigger test() { - return new Trigger(DriverStation::isTestEnabled); - } + /** A trigger that is true when the robot is enabled in test mode. */ + public static final Trigger test = new Trigger(DriverStation::isTestEnabled); } diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/RobotModeTriggers.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/button/RobotModeTriggers.cpp deleted file mode 100644 index ab593d8ff29..00000000000 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/RobotModeTriggers.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#include "frc2/command/button/RobotModeTriggers.h" - -#include - -using namespace frc2; - -Trigger RobotModeTriggers::Autonomous() { - return Trigger{&frc::DriverStation::IsAutonomousEnabled}; -} - -Trigger RobotModeTriggers::Teleop() { - return Trigger{&frc::DriverStation::IsTeleopEnabled}; -} - -Trigger RobotModeTriggers::Disabled() { - return Trigger{&frc::DriverStation::IsDisabled}; -} - -Trigger RobotModeTriggers::Test() { - return Trigger{&frc::DriverStation::IsTestEnabled}; -} diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/button/RobotModeTriggers.h b/wpilibNewCommands/src/main/native/include/frc2/command/button/RobotModeTriggers.h index 2fbcc643851..78e2c59df19 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/button/RobotModeTriggers.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/button/RobotModeTriggers.h @@ -9,7 +9,7 @@ namespace frc2 { /** - * A class containing static Trigger factories for running callbacks when robot + * A class containing static Triggers for running callbacks when robot * mode changes. */ class RobotModeTriggers { @@ -17,34 +17,31 @@ class RobotModeTriggers { RobotModeTriggers() = delete; /** - * Returns a trigger that is true when the robot is enabled in autonomous - * mode. - * - * @return A trigger that is true when the robot is enabled in autonomous + * A trigger that is true when the robot is enabled in autonomous * mode. */ - static Trigger Autonomous(); + static Trigger Autonomous; - /** - * Returns a trigger that is true when the robot is enabled in teleop mode. - * - * @return A trigger that is true when the robot is enabled in teleop mode. + /** A trigger that is true when the robot is enabled in teleop mode. */ - static Trigger Teleop(); + static Trigger Teleop; /** - * Returns a trigger that is true when the robot is disabled. - * - * @return A trigger that is true when the robot is disabled. + * A trigger that is true when the robot is disabled. */ - static Trigger Disabled(); + static Trigger Disabled; /** - * Returns a trigger that is true when the robot is enabled in test mode. - * - * @return A trigger that is true when the robot is enabled in test mode. + * A trigger that is true when the robot is enabled in test mode. */ - static Trigger Test(); + static Trigger Test; }; +Trigger RobotModeTriggers::Autonomous = + Trigger{&frc::DriverStation::IsAutonomousEnabled}; +Trigger RobotModeTriggers::Teleop = + Trigger{&frc::DriverStation::IsTeleopEnabled}; +Trigger RobotModeTriggers::Disabled = Trigger{&frc::DriverStation::IsDisabled}; +Trigger RobotModeTriggers::Test = Trigger{&frc::DriverStation::IsTestEnabled}; + } // namespace frc2 diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/button/RobotModeTriggersTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/button/RobotModeTriggersTest.java index f7df7f0bcb6..2f9cb889753 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/button/RobotModeTriggersTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/button/RobotModeTriggersTest.java @@ -18,8 +18,7 @@ void autonomousTest() { DriverStationSim.setTest(false); DriverStationSim.setEnabled(true); DriverStationSim.notifyNewData(); - Trigger auto = RobotModeTriggers.autonomous(); - assertTrue(auto.getAsBoolean()); + assertTrue(RobotModeTriggers.autonomous.getAsBoolean()); } @Test @@ -29,8 +28,7 @@ void teleopTest() { DriverStationSim.setTest(false); DriverStationSim.setEnabled(true); DriverStationSim.notifyNewData(); - Trigger teleop = RobotModeTriggers.teleop(); - assertTrue(teleop.getAsBoolean()); + assertTrue(RobotModeTriggers.teleop.getAsBoolean()); } @Test @@ -40,8 +38,7 @@ void testModeTest() { DriverStationSim.setTest(true); DriverStationSim.setEnabled(true); DriverStationSim.notifyNewData(); - Trigger test = RobotModeTriggers.test(); - assertTrue(test.getAsBoolean()); + assertTrue(RobotModeTriggers.test.getAsBoolean()); } @Test @@ -51,7 +48,6 @@ void disabledTest() { DriverStationSim.setTest(false); DriverStationSim.setEnabled(false); DriverStationSim.notifyNewData(); - Trigger disabled = RobotModeTriggers.disabled(); - assertTrue(disabled.getAsBoolean()); + assertTrue(RobotModeTriggers.disabled.getAsBoolean()); } } diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/button/RobotModeTriggersTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/button/RobotModeTriggersTest.cpp index adc9ec7732c..cffcdf31863 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/button/RobotModeTriggersTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/button/RobotModeTriggersTest.cpp @@ -19,8 +19,7 @@ TEST(RobotModeTriggersTest, Autonomous) { DriverStationSim::SetTest(false); DriverStationSim::SetEnabled(true); DriverStationSim::NotifyNewData(); - Trigger autonomous = RobotModeTriggers::Autonomous(); - EXPECT_TRUE(autonomous.Get()); + EXPECT_TRUE(RobotModeTriggers::Autonomous.Get()); } TEST(RobotModeTriggersTest, Teleop) { @@ -29,8 +28,7 @@ TEST(RobotModeTriggersTest, Teleop) { DriverStationSim::SetTest(false); DriverStationSim::SetEnabled(true); DriverStationSim::NotifyNewData(); - Trigger teleop = RobotModeTriggers::Teleop(); - EXPECT_TRUE(teleop.Get()); + EXPECT_TRUE(RobotModeTriggers::Teleop.Get()); } TEST(RobotModeTriggersTest, Disabled) { @@ -39,8 +37,7 @@ TEST(RobotModeTriggersTest, Disabled) { DriverStationSim::SetTest(false); DriverStationSim::SetEnabled(false); DriverStationSim::NotifyNewData(); - Trigger disabled = RobotModeTriggers::Disabled(); - EXPECT_TRUE(disabled.Get()); + EXPECT_TRUE(RobotModeTriggers::Disabled.Get()); } TEST(RobotModeTriggersTest, TestMode) { @@ -49,6 +46,5 @@ TEST(RobotModeTriggersTest, TestMode) { DriverStationSim::SetTest(true); DriverStationSim::SetEnabled(true); DriverStationSim::NotifyNewData(); - Trigger test = RobotModeTriggers::Test(); - EXPECT_TRUE(test.Get()); + EXPECT_TRUE(RobotModeTriggers::Test.Get()); }