From d955b0bd2dbdbaab736017e6b13139c6539c4a70 Mon Sep 17 00:00:00 2001 From: Gold856 <117957790+Gold856@users.noreply.github.com> Date: Fri, 2 Feb 2024 23:07:48 -0500 Subject: [PATCH] Use Jinja to generate C++ HID classes --- .github/workflows/pregenerate.yml | 2 +- .styleguide | 1 + wpilibNewCommands/CMakeLists.txt | 7 +- wpilibNewCommands/build.gradle | 19 +- wpilibNewCommands/generate_hids.py | 34 ++ .../frc2/command/button/commandhid.cpp.jinja | 26 ++ .../frc2/command/button/commandhid.h.jinja | 69 +++ .../command/button/CommandPS4Controller.cpp | 6 + .../command/button/CommandPS5Controller.cpp | 6 + .../button/CommandStadiaController.cpp | 53 +-- .../command/button/CommandXboxController.cpp | 36 +- .../command/button/CommandPS4Controller.h | 103 +++-- .../command/button/CommandPS5Controller.h | 103 +++-- .../command/button/CommandStadiaController.h | 117 ++--- .../command/button/CommandXboxController.h | 87 ++-- wpilibc/CMakeLists.txt | 8 +- wpilibc/build.gradle | 10 +- wpilibc/generate_hids.py | 87 ++++ wpilibc/publish.gradle | 3 +- .../generate/main/native/cpp/hid.cpp.jinja | 90 ++++ .../native/cpp/simulation/hidsim.cpp.jinja | 40 ++ .../main/native/include/frc/hid.h.jinja | 202 +++++++++ .../include/frc/simulation/hidsim.h.jinja | 87 ++++ .../main/native/cpp/PS4Controller.cpp | 30 +- .../main/native/cpp/PS5Controller.cpp | 30 +- .../main/native/cpp/StadiaController.cpp | 195 ++++---- .../main/native/cpp/XboxController.cpp | 164 ++++--- .../cpp/simulation/PS4ControllerSim.cpp | 12 +- .../cpp/simulation/PS5ControllerSim.cpp | 12 +- .../cpp/simulation/StadiaControllerSim.cpp | 101 +++++ .../cpp/simulation/XboxControllerSim.cpp | 42 +- .../main/native/include/frc/PS4Controller.h | 271 ++++++----- .../main/native/include/frc/PS5Controller.h | 261 ++++++----- .../native/include/frc/StadiaController.h | 387 +++++++++------- .../main/native/include/frc/XboxController.h | 420 ++++++++++-------- .../include/frc/simulation/PS4ControllerSim.h | 49 +- .../include/frc/simulation/PS5ControllerSim.h | 49 +- .../frc/simulation/StadiaControllerSim.h | 172 +++++++ .../frc/simulation/XboxControllerSim.h | 73 +-- .../src/test/native/cpp/PS4ControllerTest.cpp | 2 +- .../src/test/native/cpp/PS5ControllerTest.cpp | 2 +- .../test/native/cpp/XboxControllerTest.cpp | 4 +- .../cpp/examples/StateSpaceArm/cpp/Robot.cpp | 2 +- .../examples/StateSpaceElevator/cpp/Robot.cpp | 2 +- .../examples/StateSpaceFlywheel/cpp/Robot.cpp | 2 +- .../StateSpaceFlywheelSysId/cpp/Robot.cpp | 2 +- wpilibj/generate_hids.py | 0 47 files changed, 2389 insertions(+), 1091 deletions(-) create mode 100644 wpilibNewCommands/src/generate/main/native/cpp/frc2/command/button/commandhid.cpp.jinja create mode 100644 wpilibNewCommands/src/generate/main/native/include/frc2/command/button/commandhid.h.jinja rename wpilibNewCommands/src/{ => generated}/main/native/cpp/frc2/command/button/CommandPS4Controller.cpp (90%) rename wpilibNewCommands/src/{ => generated}/main/native/cpp/frc2/command/button/CommandPS5Controller.cpp (90%) rename wpilibNewCommands/src/{ => generated}/main/native/cpp/frc2/command/button/CommandStadiaController.cpp (93%) rename wpilibNewCommands/src/{ => generated}/main/native/cpp/frc2/command/button/CommandXboxController.cpp (92%) rename wpilibNewCommands/src/{ => generated}/main/native/include/frc2/command/button/CommandPS4Controller.h (51%) rename wpilibNewCommands/src/{ => generated}/main/native/include/frc2/command/button/CommandPS5Controller.h (51%) rename wpilibNewCommands/src/{ => generated}/main/native/include/frc2/command/button/CommandStadiaController.h (66%) rename wpilibNewCommands/src/{ => generated}/main/native/include/frc2/command/button/CommandXboxController.h (73%) create mode 100755 wpilibc/generate_hids.py create mode 100644 wpilibc/src/generate/main/native/cpp/hid.cpp.jinja create mode 100644 wpilibc/src/generate/main/native/cpp/simulation/hidsim.cpp.jinja create mode 100644 wpilibc/src/generate/main/native/include/frc/hid.h.jinja create mode 100644 wpilibc/src/generate/main/native/include/frc/simulation/hidsim.h.jinja rename wpilibc/src/{ => generated}/main/native/cpp/PS4Controller.cpp (93%) rename wpilibc/src/{ => generated}/main/native/cpp/PS5Controller.cpp (93%) rename wpilibc/src/{ => generated}/main/native/cpp/StadiaController.cpp (90%) rename wpilibc/src/{ => generated}/main/native/cpp/XboxController.cpp (82%) rename wpilibc/src/{ => generated}/main/native/cpp/simulation/PS4ControllerSim.cpp (95%) rename wpilibc/src/{ => generated}/main/native/cpp/simulation/PS5ControllerSim.cpp (95%) create mode 100644 wpilibc/src/generated/main/native/cpp/simulation/StadiaControllerSim.cpp rename wpilibc/src/{ => generated}/main/native/cpp/simulation/XboxControllerSim.cpp (52%) rename wpilibc/src/{ => generated}/main/native/include/frc/PS4Controller.h (57%) rename wpilibc/src/{ => generated}/main/native/include/frc/PS5Controller.h (58%) rename wpilibc/src/{ => generated}/main/native/include/frc/StadiaController.h (69%) rename wpilibc/src/{ => generated}/main/native/include/frc/XboxController.h (66%) rename wpilibc/src/{ => generated}/main/native/include/frc/simulation/PS4ControllerSim.h (65%) rename wpilibc/src/{ => generated}/main/native/include/frc/simulation/PS5ControllerSim.h (65%) create mode 100644 wpilibc/src/generated/main/native/include/frc/simulation/StadiaControllerSim.h rename wpilibc/src/{ => generated}/main/native/include/frc/simulation/XboxControllerSim.h (60%) mode change 100644 => 100755 wpilibj/generate_hids.py diff --git a/.github/workflows/pregenerate.yml b/.github/workflows/pregenerate.yml index b6e6b484d68..8dc74bc4487 100644 --- a/.github/workflows/pregenerate.yml +++ b/.github/workflows/pregenerate.yml @@ -33,7 +33,7 @@ jobs: - name: Run wpimath run: ./wpimath/generate_numbers.py && ./wpimath/generate_quickbuf.py protoc protoc-gen-quickbuf-1.3.3-linux-x86_64.exe - name: Run HIDs - run: ./wpilibj/generate_hids.py && ./wpilibNewCommands/generate_hids.py + run: ./wpilibj/generate_hids.py && ./wpilibc/generate_hids.py && ./wpilibNewCommands/generate_hids.py - name: Add untracked files to index so they count as changes run: git add -A - name: Check output diff --git a/.styleguide b/.styleguide index f67c100e088..de0e89797c7 100644 --- a/.styleguide +++ b/.styleguide @@ -20,6 +20,7 @@ generatedFileExclude { simulation/gz_msgs/src/include/simulation/gz_msgs/msgs\.h$ fieldImages/src/main/native/resources/ apriltag/src/test/resources/ + wpilibc/src/generated/ } repoRootNameOverride { diff --git a/wpilibNewCommands/CMakeLists.txt b/wpilibNewCommands/CMakeLists.txt index 26d08cd7cc2..def2a757aca 100644 --- a/wpilibNewCommands/CMakeLists.txt +++ b/wpilibNewCommands/CMakeLists.txt @@ -56,7 +56,11 @@ if(WITH_JAVA_SOURCE) set_property(TARGET wpilibNewCommands_src_jar PROPERTY FOLDER "java") endif() -file(GLOB_RECURSE wpilibNewCommands_native_src src/main/native/cpp/*.cpp) +file( + GLOB_RECURSE wpilibNewCommands_native_src + src/main/native/cpp/*.cpp + src/generated/main/native/cpp/*.cpp +) add_library(wpilibNewCommands ${wpilibNewCommands_native_src}) set_target_properties(wpilibNewCommands PROPERTIES DEBUG_POSTFIX "d") set_property(TARGET wpilibNewCommands PROPERTY FOLDER "libraries") @@ -69,6 +73,7 @@ target_include_directories( wpilibNewCommands PUBLIC $ + $ $ ) diff --git a/wpilibNewCommands/build.gradle b/wpilibNewCommands/build.gradle index 85147ae6b22..89ada857bfe 100644 --- a/wpilibNewCommands/build.gradle +++ b/wpilibNewCommands/build.gradle @@ -45,7 +45,24 @@ nativeUtils.exportsConfigs { } model { - components {} + components { + "${nativeName}Base" { + it.sources.cpp { + source { + srcDirs 'src/generated/main/native/cpp' + include '**/*.cpp' + } + exportedHeaders { + srcDirs 'src/generated/main/native/include' + } + } + } + "${nativeName}" { + it.sources.cpp.exportedHeaders { + srcDirs 'src/generated/main/native/include' + } + } + } binaries { all { if (!it.buildable || !(it instanceof NativeBinarySpec)) { diff --git a/wpilibNewCommands/generate_hids.py b/wpilibNewCommands/generate_hids.py index d9c51c12cff..32ffb735d80 100755 --- a/wpilibNewCommands/generate_hids.py +++ b/wpilibNewCommands/generate_hids.py @@ -47,5 +47,39 @@ def main(): output = template.render(controller) Output(rootPath, controllerName, output) + # C++ headers + env = Environment( + loader=FileSystemLoader( + f"{dirname}/src/generate/main/native/include/frc2/command/button" + ), + autoescape=False, + keep_trailing_newline=True, + ) + rootPath = f"{dirname}/src/generated/main/native/include/frc2/command/button" + template = env.get_template("commandhid.h.jinja") + for controller in controllers: + controllerName = os.path.basename( + f"Command{controller['ConsoleName']}Controller.h" + ) + output = template.render(controller) + Output(rootPath, controllerName, output) + + # C++ files + env = Environment( + loader=FileSystemLoader( + f"{dirname}/src/generate/main/native/cpp/frc2/command/button" + ), + autoescape=False, + ) + rootPath = f"{dirname}/src/generated/main/native/cpp/frc2/command/button" + template = env.get_template("commandhid.cpp.jinja") + for controller in controllers: + controllerName = os.path.basename( + f"Command{controller['ConsoleName']}Controller.cpp" + ) + output = template.render(controller) + Output(rootPath, controllerName, output) + + if __name__ == "__main__": main() diff --git a/wpilibNewCommands/src/generate/main/native/cpp/frc2/command/button/commandhid.cpp.jinja b/wpilibNewCommands/src/generate/main/native/cpp/frc2/command/button/commandhid.cpp.jinja new file mode 100644 index 00000000000..8869979070f --- /dev/null +++ b/wpilibNewCommands/src/generate/main/native/cpp/frc2/command/button/commandhid.cpp.jinja @@ -0,0 +1,26 @@ +// 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. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY + +#include "frc2/command/button/Command{{ ConsoleName }}Controller.h" + +using namespace frc2; + +Trigger Command{{ ConsoleName }}Controller::Button(int button, frc::EventLoop* loop) const { + return GenericHID::Button(button, loop).CastTo(); +} +{% for button in buttons %} +Trigger Command{{ ConsoleName }}Controller::{{ button.NameParts|map("capitalize")|join }}(frc::EventLoop* loop) const { + return {{ ConsoleName }}Controller::{{ button.NameParts|map("capitalize")|join }}(loop).CastTo(); +} +{% endfor -%} +{% for trigger in axes if trigger.type == "trigger" -%} +{% if trigger.UseThresholdMethods %} +Trigger Command{{ ConsoleName }}Controller::{{ trigger.HumanName }}(double threshold, + frc::EventLoop* loop) const { + return {{ ConsoleName }}Controller::{{ trigger.HumanName }}(threshold, loop).CastTo(); +} +{% endif -%} +{% endfor -%} diff --git a/wpilibNewCommands/src/generate/main/native/include/frc2/command/button/commandhid.h.jinja b/wpilibNewCommands/src/generate/main/native/include/frc2/command/button/commandhid.h.jinja new file mode 100644 index 00000000000..bad3c013a10 --- /dev/null +++ b/wpilibNewCommands/src/generate/main/native/include/frc2/command/button/commandhid.h.jinja @@ -0,0 +1,69 @@ +// 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. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY + +#pragma once +#include + +#include "frc2/command/CommandScheduler.h" +#include "frc2/command/button/Trigger.h" + +namespace frc2 { +/** + * A version of {@link {{ ConsoleName }}Controller} with {@link Trigger} factories for + * command-based. + * + * @see {{ ConsoleName }}Controller + */ +class Command{{ ConsoleName }}Controller : public frc::{{ ConsoleName }}Controller { + public: + using {{ ConsoleName }}Controller::{{ ConsoleName }}Controller; + + /** + * Constructs an event instance around this button's digital signal. + * + * @param button the button index + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return an event instance representing the button's digital signal attached + * to the given loop. + */ + Trigger Button(int button, + frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; +{% for button in buttons %} + /** + * Constructs an event instance around the {{ button.DocName|default(button.NameParts|map("lower")|join(" ")) }}'s digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return an event instance representing the {{ button.DocName|default(button.NameParts|map("lower")|join(" ")) }}'s digital signal + * attached to the given loop. + */ + Trigger {{ button.NameParts|map("capitalize")|join }}(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; +{% endfor -%} +{% for trigger in axes if trigger.type == "trigger" -%} +{% if trigger.UseThresholdMethods %} + /** + * Constructs a Trigger instance around the axis value of the {{ trigger.DocName }}. + * The returned Trigger will be true when the axis value is greater than + * {@code threshold}. + * + * @param threshold the minimum axis value for the returned Trigger to be + * true. This value should be in the range [0, 1] where 0 is the unpressed + * state of the axis. Defaults to 0.5. + * @param loop the event loop instance to attach the Trigger to. Defaults to + * the CommandScheduler's default loop. + * @return a Trigger instance that is true when the {{ trigger.DocName }}'s axis + * exceeds the provided threshold, attached to the given loop + */ + Trigger {{ trigger.HumanName }}(double threshold = 0.5, + frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; +{% endif -%} +{% endfor -%} +}; +} // namespace frc2 diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/CommandPS4Controller.cpp b/wpilibNewCommands/src/generated/main/native/cpp/frc2/command/button/CommandPS4Controller.cpp similarity index 90% rename from wpilibNewCommands/src/main/native/cpp/frc2/command/button/CommandPS4Controller.cpp rename to wpilibNewCommands/src/generated/main/native/cpp/frc2/command/button/CommandPS4Controller.cpp index d04ab66d5ec..ab9a73c27bb 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/CommandPS4Controller.cpp +++ b/wpilibNewCommands/src/generated/main/native/cpp/frc2/command/button/CommandPS4Controller.cpp @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY + #include "frc2/command/button/CommandPS4Controller.h" using namespace frc2; @@ -42,6 +44,10 @@ Trigger CommandPS4Controller::R2(frc::EventLoop* loop) const { return PS4Controller::R2(loop).CastTo(); } +Trigger CommandPS4Controller::Share(frc::EventLoop* loop) const { + return PS4Controller::Share(loop).CastTo(); +} + Trigger CommandPS4Controller::Options(frc::EventLoop* loop) const { return PS4Controller::Options(loop).CastTo(); } diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/CommandPS5Controller.cpp b/wpilibNewCommands/src/generated/main/native/cpp/frc2/command/button/CommandPS5Controller.cpp similarity index 90% rename from wpilibNewCommands/src/main/native/cpp/frc2/command/button/CommandPS5Controller.cpp rename to wpilibNewCommands/src/generated/main/native/cpp/frc2/command/button/CommandPS5Controller.cpp index 399a771ddcd..08bdbcf8a64 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/CommandPS5Controller.cpp +++ b/wpilibNewCommands/src/generated/main/native/cpp/frc2/command/button/CommandPS5Controller.cpp @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY + #include "frc2/command/button/CommandPS5Controller.h" using namespace frc2; @@ -42,6 +44,10 @@ Trigger CommandPS5Controller::R2(frc::EventLoop* loop) const { return PS5Controller::R2(loop).CastTo(); } +Trigger CommandPS5Controller::Create(frc::EventLoop* loop) const { + return PS5Controller::Create(loop).CastTo(); +} + Trigger CommandPS5Controller::Options(frc::EventLoop* loop) const { return PS5Controller::Options(loop).CastTo(); } diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/CommandStadiaController.cpp b/wpilibNewCommands/src/generated/main/native/cpp/frc2/command/button/CommandStadiaController.cpp similarity index 93% rename from wpilibNewCommands/src/main/native/cpp/frc2/command/button/CommandStadiaController.cpp rename to wpilibNewCommands/src/generated/main/native/cpp/frc2/command/button/CommandStadiaController.cpp index 86c34bad219..6efaac72208 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/CommandStadiaController.cpp +++ b/wpilibNewCommands/src/generated/main/native/cpp/frc2/command/button/CommandStadiaController.cpp @@ -2,31 +2,16 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY + #include "frc2/command/button/CommandStadiaController.h" using namespace frc2; -Trigger CommandStadiaController::Button(int button, - frc::EventLoop* loop) const { +Trigger CommandStadiaController::Button(int button, frc::EventLoop* loop) const { return GenericHID::Button(button, loop).CastTo(); } -Trigger CommandStadiaController::LeftBumper(frc::EventLoop* loop) const { - return StadiaController::LeftBumper(loop).CastTo(); -} - -Trigger CommandStadiaController::RightBumper(frc::EventLoop* loop) const { - return StadiaController::RightBumper(loop).CastTo(); -} - -Trigger CommandStadiaController::LeftStick(frc::EventLoop* loop) const { - return StadiaController::LeftStick(loop).CastTo(); -} - -Trigger CommandStadiaController::RightStick(frc::EventLoop* loop) const { - return StadiaController::RightStick(loop).CastTo(); -} - Trigger CommandStadiaController::A(frc::EventLoop* loop) const { return StadiaController::A(loop).CastTo(); } @@ -43,6 +28,22 @@ Trigger CommandStadiaController::Y(frc::EventLoop* loop) const { return StadiaController::Y(loop).CastTo(); } +Trigger CommandStadiaController::LeftBumper(frc::EventLoop* loop) const { + return StadiaController::LeftBumper(loop).CastTo(); +} + +Trigger CommandStadiaController::RightBumper(frc::EventLoop* loop) const { + return StadiaController::RightBumper(loop).CastTo(); +} + +Trigger CommandStadiaController::LeftStick(frc::EventLoop* loop) const { + return StadiaController::LeftStick(loop).CastTo(); +} + +Trigger CommandStadiaController::RightStick(frc::EventLoop* loop) const { + return StadiaController::RightStick(loop).CastTo(); +} + Trigger CommandStadiaController::Ellipses(frc::EventLoop* loop) const { return StadiaController::Ellipses(loop).CastTo(); } @@ -55,18 +56,18 @@ Trigger CommandStadiaController::Stadia(frc::EventLoop* loop) const { return StadiaController::Stadia(loop).CastTo(); } -Trigger CommandStadiaController::Google(frc::EventLoop* loop) const { - return StadiaController::Google(loop).CastTo(); -} - -Trigger CommandStadiaController::Frame(frc::EventLoop* loop) const { - return StadiaController::Frame(loop).CastTo(); +Trigger CommandStadiaController::RightTrigger(frc::EventLoop* loop) const { + return StadiaController::RightTrigger(loop).CastTo(); } Trigger CommandStadiaController::LeftTrigger(frc::EventLoop* loop) const { return StadiaController::LeftTrigger(loop).CastTo(); } -Trigger CommandStadiaController::RightTrigger(frc::EventLoop* loop) const { - return StadiaController::RightTrigger(loop).CastTo(); +Trigger CommandStadiaController::Google(frc::EventLoop* loop) const { + return StadiaController::Google(loop).CastTo(); +} + +Trigger CommandStadiaController::Frame(frc::EventLoop* loop) const { + return StadiaController::Frame(loop).CastTo(); } diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/CommandXboxController.cpp b/wpilibNewCommands/src/generated/main/native/cpp/frc2/command/button/CommandXboxController.cpp similarity index 92% rename from wpilibNewCommands/src/main/native/cpp/frc2/command/button/CommandXboxController.cpp rename to wpilibNewCommands/src/generated/main/native/cpp/frc2/command/button/CommandXboxController.cpp index 8c4eba0fd22..3c5ad4a8cb6 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/CommandXboxController.cpp +++ b/wpilibNewCommands/src/generated/main/native/cpp/frc2/command/button/CommandXboxController.cpp @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY + #include "frc2/command/button/CommandXboxController.h" using namespace frc2; @@ -10,22 +12,6 @@ Trigger CommandXboxController::Button(int button, frc::EventLoop* loop) const { return GenericHID::Button(button, loop).CastTo(); } -Trigger CommandXboxController::LeftBumper(frc::EventLoop* loop) const { - return XboxController::LeftBumper(loop).CastTo(); -} - -Trigger CommandXboxController::RightBumper(frc::EventLoop* loop) const { - return XboxController::RightBumper(loop).CastTo(); -} - -Trigger CommandXboxController::LeftStick(frc::EventLoop* loop) const { - return XboxController::LeftStick(loop).CastTo(); -} - -Trigger CommandXboxController::RightStick(frc::EventLoop* loop) const { - return XboxController::RightStick(loop).CastTo(); -} - Trigger CommandXboxController::A(frc::EventLoop* loop) const { return XboxController::A(loop).CastTo(); } @@ -42,6 +28,14 @@ Trigger CommandXboxController::Y(frc::EventLoop* loop) const { return XboxController::Y(loop).CastTo(); } +Trigger CommandXboxController::LeftBumper(frc::EventLoop* loop) const { + return XboxController::LeftBumper(loop).CastTo(); +} + +Trigger CommandXboxController::RightBumper(frc::EventLoop* loop) const { + return XboxController::RightBumper(loop).CastTo(); +} + Trigger CommandXboxController::Back(frc::EventLoop* loop) const { return XboxController::Back(loop).CastTo(); } @@ -50,12 +44,20 @@ Trigger CommandXboxController::Start(frc::EventLoop* loop) const { return XboxController::Start(loop).CastTo(); } +Trigger CommandXboxController::LeftStick(frc::EventLoop* loop) const { + return XboxController::LeftStick(loop).CastTo(); +} + +Trigger CommandXboxController::RightStick(frc::EventLoop* loop) const { + return XboxController::RightStick(loop).CastTo(); +} + Trigger CommandXboxController::LeftTrigger(double threshold, frc::EventLoop* loop) const { return XboxController::LeftTrigger(threshold, loop).CastTo(); } Trigger CommandXboxController::RightTrigger(double threshold, - frc::EventLoop* loop) const { + frc::EventLoop* loop) const { return XboxController::RightTrigger(threshold, loop).CastTo(); } diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandPS4Controller.h b/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandPS4Controller.h similarity index 51% rename from wpilibNewCommands/src/main/native/include/frc2/command/button/CommandPS4Controller.h rename to wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandPS4Controller.h index 22c54ad22ed..2f691110d73 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandPS4Controller.h +++ b/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandPS4Controller.h @@ -2,11 +2,13 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY + #pragma once #include -#include "Trigger.h" #include "frc2/command/CommandScheduler.h" +#include "frc2/command/button/Trigger.h" namespace frc2 { /** @@ -33,136 +35,147 @@ class CommandPS4Controller : public frc::PS4Controller { .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the square button's digital signal. + * Constructs an event instance around the square's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the square button's digital signal + * @return an event instance representing the square's digital signal * attached to the given loop. */ Trigger Square(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the cross button's digital signal. + * Constructs an event instance around the cross's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the cross button's digital signal + * @return an event instance representing the cross's digital signal * attached to the given loop. */ Trigger Cross(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the circle button's digital signal. + * Constructs an event instance around the circle's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the circle button's digital signal + * @return an event instance representing the circle's digital signal * attached to the given loop. */ Trigger Circle(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the triangle button's digital signal. + * Constructs an event instance around the triangle's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the triangle button's digital signal + * @return an event instance representing the triangle's digital signal * attached to the given loop. */ Trigger Triangle(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; + + /** + * Constructs an event instance around the left trigger 1's digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return an event instance representing the left trigger 1's digital signal + * attached to the given loop. + */ + Trigger L1(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the L1 button's digital signal. + * Constructs an event instance around the right trigger 1's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the L1 button's digital signal + * @return an event instance representing the right trigger 1's digital signal * attached to the given loop. */ - Trigger L1(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger R1(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the R1 button's digital signal. + * Constructs an event instance around the left trigger 2's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the R1 button's digital signal + * @return an event instance representing the left trigger 2's digital signal * attached to the given loop. */ - Trigger R1(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger L2(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the L2 button's digital signal. + * Constructs an event instance around the right trigger 2's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the L2 button's digital signal + * @return an event instance representing the right trigger 2's digital signal * attached to the given loop. */ - Trigger L2(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger R2(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the R2 button's digital signal. + * Constructs an event instance around the share's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the R2 button's digital signal + * @return an event instance representing the share's digital signal * attached to the given loop. */ - Trigger R2(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger Share(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the options button's digital signal. + * Constructs an event instance around the options's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the options button's digital signal + * @return an event instance representing the options's digital signal * attached to the given loop. */ Trigger Options(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the L3 button's digital signal. + * Constructs an event instance around the L3 (left stick)'s digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the L3 button's digital signal + * @return an event instance representing the L3 (left stick)'s digital signal * attached to the given loop. */ - Trigger L3(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger L3(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the R3 button's digital signal. + * Constructs an event instance around the R3 (right stick)'s digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the R3 button's digital signal + * @return an event instance representing the R3 (right stick)'s digital signal * attached to the given loop. */ - Trigger R3(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger R3(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the PS button's digital signal. + * Constructs an event instance around the PlayStation's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the PS button's digital signal + * @return an event instance representing the PlayStation's digital signal * attached to the given loop. */ - Trigger PS(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger PS(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** * Constructs an event instance around the touchpad's digital signal. @@ -173,6 +186,6 @@ class CommandPS4Controller : public frc::PS4Controller { * attached to the given loop. */ Trigger Touchpad(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; }; } // namespace frc2 diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandPS5Controller.h b/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandPS5Controller.h similarity index 51% rename from wpilibNewCommands/src/main/native/include/frc2/command/button/CommandPS5Controller.h rename to wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandPS5Controller.h index d86d38388b5..b50f3169c3f 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandPS5Controller.h +++ b/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandPS5Controller.h @@ -2,11 +2,13 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY + #pragma once #include -#include "Trigger.h" #include "frc2/command/CommandScheduler.h" +#include "frc2/command/button/Trigger.h" namespace frc2 { /** @@ -33,136 +35,147 @@ class CommandPS5Controller : public frc::PS5Controller { .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the square button's digital signal. + * Constructs an event instance around the square's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the square button's digital signal + * @return an event instance representing the square's digital signal * attached to the given loop. */ Trigger Square(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the cross button's digital signal. + * Constructs an event instance around the cross's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the cross button's digital signal + * @return an event instance representing the cross's digital signal * attached to the given loop. */ Trigger Cross(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the circle button's digital signal. + * Constructs an event instance around the circle's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the circle button's digital signal + * @return an event instance representing the circle's digital signal * attached to the given loop. */ Trigger Circle(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the triangle button's digital signal. + * Constructs an event instance around the triangle's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the triangle button's digital signal + * @return an event instance representing the triangle's digital signal * attached to the given loop. */ Trigger Triangle(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; + + /** + * Constructs an event instance around the left trigger 1's digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return an event instance representing the left trigger 1's digital signal + * attached to the given loop. + */ + Trigger L1(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the L1 button's digital signal. + * Constructs an event instance around the right trigger 1's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the L1 button's digital signal + * @return an event instance representing the right trigger 1's digital signal * attached to the given loop. */ - Trigger L1(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger R1(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the R1 button's digital signal. + * Constructs an event instance around the left trigger 2's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the R1 button's digital signal + * @return an event instance representing the left trigger 2's digital signal * attached to the given loop. */ - Trigger R1(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger L2(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the L2 button's digital signal. + * Constructs an event instance around the right trigger 2's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the L2 button's digital signal + * @return an event instance representing the right trigger 2's digital signal * attached to the given loop. */ - Trigger L2(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger R2(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the R2 button's digital signal. + * Constructs an event instance around the create's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the R2 button's digital signal + * @return an event instance representing the create's digital signal * attached to the given loop. */ - Trigger R2(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger Create(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the options button's digital signal. + * Constructs an event instance around the options's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the options button's digital signal + * @return an event instance representing the options's digital signal * attached to the given loop. */ Trigger Options(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the L3 button's digital signal. + * Constructs an event instance around the L3 (left stick)'s digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the L3 button's digital signal + * @return an event instance representing the L3 (left stick)'s digital signal * attached to the given loop. */ - Trigger L3(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger L3(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the R3 button's digital signal. + * Constructs an event instance around the R3 (right stick)'s digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the R3 button's digital signal + * @return an event instance representing the R3 (right stick)'s digital signal * attached to the given loop. */ - Trigger R3(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger R3(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the PS button's digital signal. + * Constructs an event instance around the PlayStation's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the PS button's digital signal + * @return an event instance representing the PlayStation's digital signal * attached to the given loop. */ - Trigger PS(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger PS(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** * Constructs an event instance around the touchpad's digital signal. @@ -173,6 +186,6 @@ class CommandPS5Controller : public frc::PS5Controller { * attached to the given loop. */ Trigger Touchpad(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; }; } // namespace frc2 diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandStadiaController.h b/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandStadiaController.h similarity index 66% rename from wpilibNewCommands/src/main/native/include/frc2/command/button/CommandStadiaController.h rename to wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandStadiaController.h index 7a1b54934cd..cb67bb1a01e 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandStadiaController.h +++ b/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandStadiaController.h @@ -2,11 +2,13 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY + #pragma once #include -#include "Trigger.h" #include "frc2/command/CommandScheduler.h" +#include "frc2/command/button/Trigger.h" namespace frc2 { /** @@ -33,169 +35,168 @@ class CommandStadiaController : public frc::StadiaController { .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the left bumper's digital signal. + * Constructs an event instance around the A's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the left bumper's digital signal + * @return an event instance representing the A's digital signal * attached to the given loop. */ - Trigger LeftBumper(frc::EventLoop* loop = CommandScheduler::GetInstance() + Trigger A(frc::EventLoop* loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the right bumper's digital signal. + * Constructs an event instance around the B's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the right bumper's digital signal + * @return an event instance representing the B's digital signal * attached to the given loop. */ - Trigger RightBumper(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + Trigger B(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the left stick's digital signal. + * Constructs an event instance around the X's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the left stick's digital signal + * @return an event instance representing the X's digital signal * attached to the given loop. */ - Trigger LeftStick(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + Trigger X(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the right stick's digital signal. + * Constructs an event instance around the Y's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the right stick's digital signal + * @return an event instance representing the Y's digital signal * attached to the given loop. */ - Trigger RightStick(frc::EventLoop* loop = CommandScheduler::GetInstance() + Trigger Y(frc::EventLoop* loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the A button's digital signal. + * Constructs an event instance around the left bumper's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the A button's digital signal + * @return an event instance representing the left bumper's digital signal * attached to the given loop. */ - Trigger A(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger LeftBumper(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the B button's digital signal. + * Constructs an event instance around the right bumper's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the B button's digital signal + * @return an event instance representing the right bumper's digital signal * attached to the given loop. */ - Trigger B(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger RightBumper(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the X button's digital signal. + * Constructs an event instance around the left stick's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the X button's digital signal + * @return an event instance representing the left stick's digital signal * attached to the given loop. */ - Trigger X(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger LeftStick(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the Y button's digital signal. + * Constructs an event instance around the right stick's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the Y button's digital signal + * @return an event instance representing the right stick's digital signal * attached to the given loop. */ - Trigger Y(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger RightStick(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the ellipses button's digital signal. + * Constructs an event instance around the ellipses's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the ellipses button's digital signal + * @return an event instance representing the ellipses's digital signal * attached to the given loop. */ Trigger Ellipses(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the hamburger button's digital signal. + * Constructs an event instance around the hamburger's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the hamburger button's digital - * signal attached to the given loop. + * @return an event instance representing the hamburger's digital signal + * attached to the given loop. */ Trigger Hamburger(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the stadia button's digital signal. + * Constructs an event instance around the stadia's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the stadia button's digital signal + * @return an event instance representing the stadia's digital signal * attached to the given loop. */ Trigger Stadia(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the google button's digital signal. + * Constructs an event instance around the right trigger's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the google button's digital signal + * @return an event instance representing the right trigger's digital signal * attached to the given loop. */ - Trigger Google(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + Trigger RightTrigger(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the frame button's digital signal. + * Constructs an event instance around the left trigger's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the frame button's digital signal + * @return an event instance representing the left trigger's digital signal * attached to the given loop. */ - Trigger Frame(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + Trigger LeftTrigger(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the left trigger's digital signal. + * Constructs an event instance around the google's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the left trigger's digital signal + * @return an event instance representing the google's digital signal * attached to the given loop. */ - Trigger LeftTrigger(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + Trigger Google(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the right trigger's digital signal. + * Constructs an event instance around the frame's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the right trigger's digital signal + * @return an event instance representing the frame's digital signal * attached to the given loop. */ - Trigger RightTrigger( - frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger Frame(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; }; } // namespace frc2 diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandXboxController.h b/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandXboxController.h similarity index 73% rename from wpilibNewCommands/src/main/native/include/frc2/command/button/CommandXboxController.h rename to wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandXboxController.h index 94a3c2c505a..80056007bdf 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandXboxController.h +++ b/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandXboxController.h @@ -2,11 +2,13 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibNewCommands/generate_hids.py. DO NOT MODIFY + #pragma once #include -#include "Trigger.h" #include "frc2/command/CommandScheduler.h" +#include "frc2/command/button/Trigger.h" namespace frc2 { /** @@ -33,114 +35,114 @@ class CommandXboxController : public frc::XboxController { .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the left bumper's digital signal. + * Constructs an event instance around the A's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the left bumper's digital signal + * @return an event instance representing the A's digital signal * attached to the given loop. */ - Trigger LeftBumper(frc::EventLoop* loop = CommandScheduler::GetInstance() + Trigger A(frc::EventLoop* loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the right bumper's digital signal. + * Constructs an event instance around the B's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the right bumper's digital signal + * @return an event instance representing the B's digital signal * attached to the given loop. */ - Trigger RightBumper(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + Trigger B(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the left stick's digital signal. + * Constructs an event instance around the X's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the left stick's digital signal + * @return an event instance representing the X's digital signal * attached to the given loop. */ - Trigger LeftStick(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + Trigger X(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the right stick's digital signal. + * Constructs an event instance around the Y's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the right stick's digital signal + * @return an event instance representing the Y's digital signal * attached to the given loop. */ - Trigger RightStick(frc::EventLoop* loop = CommandScheduler::GetInstance() + Trigger Y(frc::EventLoop* loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the A button's digital signal. + * Constructs an event instance around the left bumper's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the A button's digital signal + * @return an event instance representing the left bumper's digital signal * attached to the given loop. */ - Trigger A(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger LeftBumper(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the B button's digital signal. + * Constructs an event instance around the right bumper's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the B button's digital signal + * @return an event instance representing the right bumper's digital signal * attached to the given loop. */ - Trigger B(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger RightBumper(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the X button's digital signal. + * Constructs an event instance around the back's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the X button's digital signal + * @return an event instance representing the back's digital signal * attached to the given loop. */ - Trigger X(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger Back(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the Y button's digital signal. + * Constructs an event instance around the start's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the Y button's digital signal + * @return an event instance representing the start's digital signal * attached to the given loop. */ - Trigger Y(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger Start(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the back button's digital signal. + * Constructs an event instance around the left stick's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the back button's digital signal + * @return an event instance representing the left stick's digital signal * attached to the given loop. */ - Trigger Back(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + Trigger LeftStick(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the start button's digital signal. + * Constructs an event instance around the right stick's digital signal. * * @param loop the event loop instance to attach the event to. Defaults to the * CommandScheduler's default loop. - * @return an event instance representing the start button's digital signal + * @return an event instance representing the right stick's digital signal * attached to the given loop. */ - Trigger Start(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + Trigger RightStick(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** * Constructs a Trigger instance around the axis value of the left trigger. @@ -172,9 +174,8 @@ class CommandXboxController : public frc::XboxController { * @return a Trigger instance that is true when the right trigger's axis * exceeds the provided threshold, attached to the given loop */ - Trigger RightTrigger( - double threshold = 0.5, - frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; + Trigger RightTrigger(double threshold = 0.5, + frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; }; } // namespace frc2 diff --git a/wpilibc/CMakeLists.txt b/wpilibc/CMakeLists.txt index 17e7c991ad2..186c9794b14 100644 --- a/wpilibc/CMakeLists.txt +++ b/wpilibc/CMakeLists.txt @@ -5,7 +5,12 @@ include(AddTest) configure_file(src/generate/WPILibVersion.cpp.in WPILibVersion.cpp) -file(GLOB_RECURSE wpilibc_native_src src/main/native/cpp/*.cpp src/main/native/cppcs/*.cpp) +file( + GLOB_RECURSE wpilibc_native_src + src/main/native/cpp/*.cpp + src/main/native/cppcs/*.cpp + src/generated/main/native/cpp/*.cpp +) add_library(wpilibc ${wpilibc_native_src} ${CMAKE_CURRENT_BINARY_DIR}/WPILibVersion.cpp) set_target_properties(wpilibc PROPERTIES DEBUG_POSTFIX "d") @@ -14,6 +19,7 @@ target_include_directories( wpilibc PUBLIC $ + $ $ ) wpilib_target_warnings(wpilibc) diff --git a/wpilibc/build.gradle b/wpilibc/build.gradle index 507ec445adf..3c9e8af704e 100644 --- a/wpilibc/build.gradle +++ b/wpilibc/build.gradle @@ -85,12 +85,16 @@ model { cpp { source { srcDirs = [ - 'src/main/native/cpp' + 'src/main/native/cpp', + 'src/generated/main/native/cpp' ] include '**/*.cpp' } exportedHeaders { - srcDirs 'src/main/native/include' + srcDirs = [ + 'src/main/native/include', + 'src/generated/main/native/include' + ] } } } @@ -131,7 +135,7 @@ model { include '**/*.cpp' } exportedHeaders { - srcDirs 'src/main/native/include', '../cameraserver/src/main/native/include' + srcDirs 'src/main/native/include', 'src/generated/main/native/include', '../cameraserver/src/main/native/include' } } } diff --git a/wpilibc/generate_hids.py b/wpilibc/generate_hids.py new file mode 100755 index 00000000000..2d24e678abf --- /dev/null +++ b/wpilibc/generate_hids.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 + +import json +import os + +from jinja2 import Environment, FileSystemLoader + + +def Output(outPath, controllerName, contents): + if not os.path.exists(outPath): + os.makedirs(outPath) + + outpathname = f"{outPath}/{controllerName}" + + if os.path.exists(outpathname): + with open(outpathname, "r") as f: + if f.read() == contents: + return + + # File either doesn't exist or has different contents + with open(outpathname, "w", newline="\n") as f: + f.write(contents) + + +def main(): + dirname, _ = os.path.split(os.path.abspath(__file__)) + + with open("wpilibj/src/generate/hids.json") as f: + controllers = json.load(f) + + # C++ headers + env = Environment( + loader=FileSystemLoader(f"{dirname}/src/generate/main/native/include/frc"), + autoescape=False, + keep_trailing_newline=True, + ) + rootPath = f"{dirname}/src/generated/main/native/include/frc" + template = env.get_template("hid.h.jinja") + for controller in controllers: + controllerName = os.path.basename(f"{controller['ConsoleName']}Controller.h") + output = template.render(controller) + Output(rootPath, controllerName, output) + + # C++ files + env = Environment( + loader=FileSystemLoader(f"{dirname}/src/generate/main/native/cpp"), + autoescape=False, + ) + rootPath = f"{dirname}/src/generated/main/native/cpp" + template = env.get_template("hid.cpp.jinja") + for controller in controllers: + controllerName = os.path.basename(f"{controller['ConsoleName']}Controller.cpp") + output = template.render(controller) + Output(rootPath, controllerName, output) + + # C++ simulation headers + env = Environment( + loader=FileSystemLoader( + f"{dirname}/src/generate/main/native/include/frc/simulation" + ), + autoescape=False, + keep_trailing_newline=True, + ) + rootPath = f"{dirname}/src/generated/main/native/include/frc/simulation" + template = env.get_template("hidsim.h.jinja") + for controller in controllers: + controllerName = os.path.basename(f"{controller['ConsoleName']}ControllerSim.h") + output = template.render(controller) + Output(rootPath, controllerName, output) + + # C++ simulation files + env = Environment( + loader=FileSystemLoader(f"{dirname}/src/generate/main/native/cpp/simulation"), + autoescape=False, + ) + rootPath = f"{dirname}/src/generated/main/native/cpp/simulation" + template = env.get_template("hidsim.cpp.jinja") + for controller in controllers: + controllerName = os.path.basename( + f"{controller['ConsoleName']}ControllerSim.cpp" + ) + output = template.render(controller) + Output(rootPath, controllerName, output) + + +if __name__ == "__main__": + main() diff --git a/wpilibc/publish.gradle b/wpilibc/publish.gradle index a565ba5f3b6..aff50caa690 100644 --- a/wpilibc/publish.gradle +++ b/wpilibc/publish.gradle @@ -35,7 +35,8 @@ task cppHeadersZip(type: Zip) { } ext.includeDirs = [ - project.file('src/main/native/include') + project.file('src/main/native/include'), + project.file('src/generated/main/native/include') ] ext.includeDirs.each { diff --git a/wpilibc/src/generate/main/native/cpp/hid.cpp.jinja b/wpilibc/src/generate/main/native/cpp/hid.cpp.jinja new file mode 100644 index 00000000000..c029e1460f8 --- /dev/null +++ b/wpilibc/src/generate/main/native/cpp/hid.cpp.jinja @@ -0,0 +1,90 @@ +// 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. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + +#include "frc/{{ ConsoleName }}Controller.h" + +#include + +#include "frc/event/BooleanEvent.h" + +using namespace frc; + +{{ ConsoleName }}Controller::{{ ConsoleName }}Controller(int port) : GenericHID(port) { + {{ "// " if SkipReporting }}HAL_Report(HALUsageReporting::kResourceType_{{ ConsoleName }}Controller, port + 1); +} +{% for stick in axes if stick.type == "stick" %} +double {{ ConsoleName }}Controller::Get{{ stick.NameParts|map("capitalize")|join }}() const { + return GetRawAxis(Axis::k{{ stick.NameParts|map("capitalize")|join }}); +} +{% endfor -%} +{% for trigger in axes if trigger.type == "trigger" %} +double {{ ConsoleName }}Controller::Get{{ trigger.HumanName }}Axis() const { + return GetRawAxis(Axis::k{{ trigger.HumanName }}); +} +{% if trigger.UseThresholdMethods %} +BooleanEvent {{ ConsoleName }}Controller::{{ trigger.HumanName }}(double threshold, EventLoop* loop) const { + return BooleanEvent(loop, [this, threshold] { return this->Get{{ trigger.HumanName }}Axis() > threshold; }); +} + +BooleanEvent {{ ConsoleName }}Controller::{{ trigger.HumanName }}(EventLoop* loop) const { + return this->{{ trigger.HumanName }}(0.5, loop); +} +{% endif -%} +{% endfor -%} +{% for button in buttons %} +bool {{ ConsoleName }}Controller::Get{{ button.NameParts|map("capitalize")|join }}Button() const { + return GetRawButton(Button::k{{ button.NameParts|map("capitalize")|join }}); +} + +bool {{ ConsoleName }}Controller::Get{{ button.NameParts|map("capitalize")|join }}ButtonPressed() { + return GetRawButtonPressed(Button::k{{ button.NameParts|map("capitalize")|join }}); +} + +bool {{ ConsoleName }}Controller::Get{{ button.NameParts|map("capitalize")|join }}ButtonReleased() { + return GetRawButtonReleased(Button::k{{ button.NameParts|map("capitalize")|join }}); +} + +BooleanEvent {{ ConsoleName }}Controller::{{ button.NameParts|map("capitalize")|join }}(EventLoop* loop) const { + return BooleanEvent(loop, [this]() { return this->Get{{ button.NameParts|map("capitalize")|join }}Button(); }); +} +{% endfor -%} +{% if ConsoleName == "Xbox" or ConsoleName == "Stadia"%} +bool {{ ConsoleName }}Controller::GetLeftBumper() const { + return GetRawButton(Button::kLeftBumper); +} + +bool {{ ConsoleName }}Controller::GetRightBumper() const { + return GetRawButton(Button::kRightBumper); +} + +bool {{ ConsoleName }}Controller::GetLeftBumperPressed() { + return GetRawButtonPressed(Button::kLeftBumper); +} + +bool {{ ConsoleName }}Controller::GetRightBumperPressed() { + return GetRawButtonPressed(Button::kRightBumper); +} + +bool {{ ConsoleName }}Controller::GetLeftBumperReleased() { + return GetRawButtonReleased(Button::kLeftBumper); +} + +bool {{ ConsoleName }}Controller::GetRightBumperReleased() { + return GetRawButtonReleased(Button::kRightBumper); +} +{% elif ConsoleName == "PS4" or ConsoleName == "PS5" %} +bool {{ ConsoleName }}Controller::GetTouchpad() const { + return GetRawButton(Button::kTouchpad); +} + +bool {{ ConsoleName }}Controller::GetTouchpadPressed() { + return GetRawButtonPressed(Button::kTouchpad); +} + +bool {{ ConsoleName }}Controller::GetTouchpadReleased() { + return GetRawButtonReleased(Button::kTouchpad); +} +{% endif %} diff --git a/wpilibc/src/generate/main/native/cpp/simulation/hidsim.cpp.jinja b/wpilibc/src/generate/main/native/cpp/simulation/hidsim.cpp.jinja new file mode 100644 index 00000000000..6df7ba8d8ec --- /dev/null +++ b/wpilibc/src/generate/main/native/cpp/simulation/hidsim.cpp.jinja @@ -0,0 +1,40 @@ +// 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. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + +#include "frc/simulation/{{ ConsoleName }}ControllerSim.h" + +#include "frc/{{ ConsoleName }}Controller.h" + +using namespace frc; +using namespace frc::sim; + +{{ ConsoleName }}ControllerSim::{{ ConsoleName }}ControllerSim(const {{ ConsoleName }}Controller& joystick) + : GenericHIDSim{joystick} { + SetAxisCount({{ axes|length }}); + SetButtonCount({{ buttons|length }}); + SetPOVCount(1); +} + +{{ ConsoleName }}ControllerSim::{{ ConsoleName }}ControllerSim(int port) : GenericHIDSim{port} { + SetAxisCount({{ axes|length }}); + SetButtonCount({{ buttons|length }}); + SetPOVCount(1); +} +{% for stick in axes if stick.type == "stick" %} +void {{ ConsoleName }}ControllerSim::Set{{ stick.NameParts|map("capitalize")|join }}(double value) { + SetRawAxis({{ ConsoleName }}Controller::Axis::k{{ stick.NameParts|map("capitalize")|join }}, value); +} +{% endfor -%} +{% for trigger in axes if trigger.type == "trigger" %} +void {{ ConsoleName }}ControllerSim::Set{{ trigger.HumanName }}Axis(double value) { + SetRawAxis({{ ConsoleName }}Controller::Axis::k{{ trigger.HumanName }}, value); +} +{% endfor -%} +{% for button in buttons %} +void {{ ConsoleName }}ControllerSim::Set{{ button.NameParts|map("capitalize")|join }}Button(bool value) { + SetRawButton({{ ConsoleName }}Controller::Button::k{{ button.NameParts|map("capitalize")|join }}, value); +} +{% endfor %} diff --git a/wpilibc/src/generate/main/native/include/frc/hid.h.jinja b/wpilibc/src/generate/main/native/include/frc/hid.h.jinja new file mode 100644 index 00000000000..3416e81702a --- /dev/null +++ b/wpilibc/src/generate/main/native/include/frc/hid.h.jinja @@ -0,0 +1,202 @@ +// 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. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + +#pragma once + +#include "frc/GenericHID.h" + +namespace frc { + +/** + * Handle input from {{ ConsoleName }} controllers connected to the Driver Station. + * + * This class handles {{ ConsoleName }} input that comes from the Driver Station. Each + * time a value is requested the most recent value is returned. There is a + * single class instance for each controller and the mapping of ports to + * hardware buttons depends on the code in the Driver Station. + * + * Only first party controllers from {{ Manufacturer }} are guaranteed to have the + * correct mapping, and only through the official NI DS. Sim is not guaranteed + * to have the same mapping, as well as any 3rd party controllers. + */ +class {{ ConsoleName }}Controller : public GenericHID { + public: + /** + * Construct an instance of a controller. + * + * The controller index is the USB port on the Driver Station. + * + * @param port The port on the Driver Station that the controller is plugged + * into (0-5). + */ + explicit {{ ConsoleName }}Controller(int port); + + ~{{ ConsoleName }}Controller() override = default; + + {{ ConsoleName }}Controller({{ ConsoleName }}Controller&&) = default; + {{ ConsoleName }}Controller& operator=({{ ConsoleName }}Controller&&) = default; +{% for stick in axes if stick.type == "stick" %} + /** + * Get the {{ stick.NameParts[1] }} axis value of {{ stick.NameParts[0] }} side of the controller. + * + * @return the axis value. + */ + double Get{{ stick.NameParts|map("capitalize")|join }}() const; +{% endfor -%} +{%- for trigger in axes if trigger.type == "trigger" %} + /** + * Get the {{ trigger.DocName }} axis value of the controller. Note that this axis + * is bound to the range of [0, 1] as opposed to the usual [-1, 1]. + * + * @return the axis value. + */ + double Get{{ trigger.HumanName }}Axis() const; +{% if trigger.UseThresholdMethods %} + /** + * Constructs an event instance around the axis value of the {{ trigger.DocName }}. + * The returned trigger will be true when the axis value is greater than + * {@code threshold}. + * @param threshold the minimum axis value for the returned event to be true. + * This value should be in the range [0, 1] where 0 is the unpressed state of + * the axis. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the {{ trigger.DocName }}'s axis + * exceeds the provided threshold, attached to the given event loop + */ + BooleanEvent {{ trigger.HumanName }}(double threshold, EventLoop* loop) const; + + /** + * Constructs an event instance around the axis value of the {{ trigger.DocName }}. + * The returned trigger will be true when the axis value is greater than 0.5. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the {{ trigger.DocName }}'s axis + * exceeds 0.5, attached to the given event loop + */ + BooleanEvent {{ trigger.HumanName }}(EventLoop* loop) const; +{% endif -%} +{% endfor -%} +{% for button in buttons %} + /** + * Read the value of the {{ button.DocName|default(button.NameParts|map("lower")|join(" ")) }} button on the controller. + * + * @return The state of the button. + */ + bool Get{{ button.NameParts|map("capitalize")|join }}Button() const; + + /** + * Whether the {{ button.DocName|default(button.NameParts|map("lower")|join(" ")) }} button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool Get{{ button.NameParts|map("capitalize")|join }}ButtonPressed(); + + /** + * Whether the {{ button.DocName|default(button.NameParts|map("lower")|join(" ")) }} button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool Get{{ button.NameParts|map("capitalize")|join }}ButtonReleased(); + + /** + * Constructs an event instance around the {{ button.DocName|default(button.NameParts|map("lower")|join(" ")) }} button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the {{ button.DocName|default(button.NameParts|map("lower")|join(" ")) }} button's + * digital signal attached to the given loop. + */ + BooleanEvent {{ button.NameParts|map("capitalize")|join }}(EventLoop* loop) const; +{% endfor %} +{% if ConsoleName == "Xbox" or ConsoleName == "Stadia" %} + /** + * Read the value of the left bumper (LB) button on the controller. + * + * @return the state of the button + */ + [[deprecated("Use GetLeftBumper instead")]] + bool GetLeftBumper() const; + + /** + * Read the value of the right bumper (RB) button on the controller. + * + * @return the state of the button + */ + [[deprecated("Use GetRightBumper instead")]] + bool GetRightBumper() const; + + /** + * Whether the left bumper (LB) was pressed since the last check. + * + * @return Whether the button was pressed since the last check + */ + [[deprecated("Use GetLeftBumperPressed instead")]] + bool GetLeftBumperPressed(); + + /** + * Whether the right bumper (RB) was pressed since the last check. + * + * @return Whether the button was pressed since the last check + */ + [[deprecated("Use GetRightBumperPressed instead")]] + bool GetRightBumperPressed(); + + /** + * Whether the left bumper (LB) was released since the last check. + * + * @return Whether the button was released since the last check. + */ + [[deprecated("Use GetLeftBumperReleased instead")]] + bool GetLeftBumperReleased(); + + /** + * Whether the right bumper (RB) was released since the last check. + * + * @return Whether the button was released since the last check. + */ + [[deprecated("Use GetRightBumperReleased instead")]] + bool GetRightBumperReleased(); +{% elif ConsoleName == "PS4" or ConsoleName == "PS5" %} + + /** + * Read the value of the touchpad button on the controller. + * + * @return The state of the button. + */ + [[deprecated("Use GetTouchpadButton instead")]] + bool GetTouchpad() const; + /** + * Whether the touchpad was pressed since the last check. + * + * @return Whether the touchpad was pressed since the last check. + */ + [[deprecated("Use GetTouchpadButtonPressed instead")]] + bool GetTouchpadPressed(); + + /** + * Whether the touchpad was released since the last check. + * + * @return Whether the touchpad was released since the last check. + */ + [[deprecated("Use GetTouchpadButtonReleased instead")]] + bool GetTouchpadReleased(); +{% endif %} + /** Represents a digital button on an {{ ConsoleName }}Controller. */ + struct Button { +{%- for button in buttons %} + /// {{ button.DocName|default(button.NameParts|map("capitalize")|join(" "))|capitalize }} button. + static constexpr int k{{ button.NameParts|map("capitalize")|join }} = {{ button.value }};{% endfor %} + }; + + /** Represents an axis on an {{ ConsoleName }}Controller. */ + struct Axis { +{%- for axis in axes %}{% if axis.type == "stick" %} + /// {{ axis.NameParts|map("capitalize")|join(" ") }} axis.{% else %} + /// {{ axis.DocName|capitalize }}.{% endif %} + static constexpr int k{{ axis.HumanName|default(axis.NameParts|map("capitalize")|join) }} = {{ axis.value }};{% endfor %} + }; +}; + +} // namespace frc diff --git a/wpilibc/src/generate/main/native/include/frc/simulation/hidsim.h.jinja b/wpilibc/src/generate/main/native/include/frc/simulation/hidsim.h.jinja new file mode 100644 index 00000000000..7495b517297 --- /dev/null +++ b/wpilibc/src/generate/main/native/include/frc/simulation/hidsim.h.jinja @@ -0,0 +1,87 @@ +// 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. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + +#pragma once + +#include "frc/simulation/GenericHIDSim.h" + +namespace frc { + +class {{ ConsoleName }}Controller; + +namespace sim { + +/** + * Class to control a simulated {{ ConsoleName }} controller. + */ +class {{ ConsoleName }}ControllerSim : public GenericHIDSim { + public: + /** + * Constructs from a {{ ConsoleName }}Controller object. + * + * @param joystick controller to simulate + */ + explicit {{ ConsoleName }}ControllerSim(const {{ ConsoleName }}Controller& joystick); + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + explicit {{ ConsoleName }}ControllerSim(int port); +{% for stick in axes if stick.type == "stick" %} + /** + * Change the {{ stick.NameParts|join(" ") }} value of the controller's joystick. + * + * @param value the new value + */ + void Set{{ stick.NameParts|map("capitalize")|join }}(double value); +{% endfor -%} +{% for trigger in axes if trigger.type == "trigger" %} + /** + * Change the value of the {{ trigger.DocName }} axis on the controller. + * + * @param value the new value + */ + void Set{{ trigger.HumanName }}Axis(double value); +{% endfor -%} +{% for button in buttons %} + /** + * Change the value of the {{ button.DocName|default(button.NameParts|map("lower")|join(" ")) }} button on the controller. + * + * @param value the new value + */ + void Set{{ button.NameParts|map("capitalize")|join }}Button(bool value); +{% endfor -%} +{% if ConsoleName == "Xbox" %} + /** + * Change the left bumper value of the joystick. + * + * @param value the new value + */ + [[deprecated("Use SetLeftBumperButton instead")]] + void SetLeftBumper(bool value); + + /** + * Change the right bumper value of the joystick. + * + * @param value the new value + */ + [[deprecated("Use SetRightBumperButton instead")]] + void SetRightBumper(bool value); +{% elif ConsoleName == "PS4" or ConsoleName == "PS5" %} + /** + * Change the value of the touchpad button on the controller. + * + * @param value the new value + */ + [[deprecated("Use SetTouchpadButton instead")]] + void SetTouchpad(bool value); +{% endif %} +}; + +} // namespace sim +} // namespace frc diff --git a/wpilibc/src/main/native/cpp/PS4Controller.cpp b/wpilibc/src/generated/main/native/cpp/PS4Controller.cpp similarity index 93% rename from wpilibc/src/main/native/cpp/PS4Controller.cpp rename to wpilibc/src/generated/main/native/cpp/PS4Controller.cpp index e59e18cd3b3..3e4b991d8c7 100644 --- a/wpilibc/src/main/native/cpp/PS4Controller.cpp +++ b/wpilibc/src/generated/main/native/cpp/PS4Controller.cpp @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + #include "frc/PS4Controller.h" #include @@ -18,14 +20,14 @@ double PS4Controller::GetLeftX() const { return GetRawAxis(Axis::kLeftX); } -double PS4Controller::GetRightX() const { - return GetRawAxis(Axis::kRightX); -} - double PS4Controller::GetLeftY() const { return GetRawAxis(Axis::kLeftY); } +double PS4Controller::GetRightX() const { + return GetRawAxis(Axis::kRightX); +} + double PS4Controller::GetRightY() const { return GetRawAxis(Axis::kRightY); } @@ -246,18 +248,30 @@ BooleanEvent PS4Controller::PS(EventLoop* loop) const { return BooleanEvent(loop, [this]() { return this->GetPSButton(); }); } -bool PS4Controller::GetTouchpad() const { +bool PS4Controller::GetTouchpadButton() const { return GetRawButton(Button::kTouchpad); } -bool PS4Controller::GetTouchpadPressed() { +bool PS4Controller::GetTouchpadButtonPressed() { return GetRawButtonPressed(Button::kTouchpad); } -bool PS4Controller::GetTouchpadReleased() { +bool PS4Controller::GetTouchpadButtonReleased() { return GetRawButtonReleased(Button::kTouchpad); } BooleanEvent PS4Controller::Touchpad(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetTouchpad(); }); + return BooleanEvent(loop, [this]() { return this->GetTouchpadButton(); }); +} + +bool PS4Controller::GetTouchpad() const { + return GetRawButton(Button::kTouchpad); +} + +bool PS4Controller::GetTouchpadPressed() { + return GetRawButtonPressed(Button::kTouchpad); +} + +bool PS4Controller::GetTouchpadReleased() { + return GetRawButtonReleased(Button::kTouchpad); } diff --git a/wpilibc/src/main/native/cpp/PS5Controller.cpp b/wpilibc/src/generated/main/native/cpp/PS5Controller.cpp similarity index 93% rename from wpilibc/src/main/native/cpp/PS5Controller.cpp rename to wpilibc/src/generated/main/native/cpp/PS5Controller.cpp index 95685d677b8..34df999abd1 100644 --- a/wpilibc/src/main/native/cpp/PS5Controller.cpp +++ b/wpilibc/src/generated/main/native/cpp/PS5Controller.cpp @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + #include "frc/PS5Controller.h" #include @@ -18,14 +20,14 @@ double PS5Controller::GetLeftX() const { return GetRawAxis(Axis::kLeftX); } -double PS5Controller::GetRightX() const { - return GetRawAxis(Axis::kRightX); -} - double PS5Controller::GetLeftY() const { return GetRawAxis(Axis::kLeftY); } +double PS5Controller::GetRightX() const { + return GetRawAxis(Axis::kRightX); +} + double PS5Controller::GetRightY() const { return GetRawAxis(Axis::kRightY); } @@ -246,18 +248,30 @@ BooleanEvent PS5Controller::PS(EventLoop* loop) const { return BooleanEvent(loop, [this]() { return this->GetPSButton(); }); } -bool PS5Controller::GetTouchpad() const { +bool PS5Controller::GetTouchpadButton() const { return GetRawButton(Button::kTouchpad); } -bool PS5Controller::GetTouchpadPressed() { +bool PS5Controller::GetTouchpadButtonPressed() { return GetRawButtonPressed(Button::kTouchpad); } -bool PS5Controller::GetTouchpadReleased() { +bool PS5Controller::GetTouchpadButtonReleased() { return GetRawButtonReleased(Button::kTouchpad); } BooleanEvent PS5Controller::Touchpad(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetTouchpad(); }); + return BooleanEvent(loop, [this]() { return this->GetTouchpadButton(); }); +} + +bool PS5Controller::GetTouchpad() const { + return GetRawButton(Button::kTouchpad); +} + +bool PS5Controller::GetTouchpadPressed() { + return GetRawButtonPressed(Button::kTouchpad); +} + +bool PS5Controller::GetTouchpadReleased() { + return GetRawButtonReleased(Button::kTouchpad); } diff --git a/wpilibc/src/main/native/cpp/StadiaController.cpp b/wpilibc/src/generated/main/native/cpp/StadiaController.cpp similarity index 90% rename from wpilibc/src/main/native/cpp/StadiaController.cpp rename to wpilibc/src/generated/main/native/cpp/StadiaController.cpp index 4f8d666c54c..54192f2071b 100644 --- a/wpilibc/src/main/native/cpp/StadiaController.cpp +++ b/wpilibc/src/generated/main/native/cpp/StadiaController.cpp @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + #include "frc/StadiaController.h" #include @@ -11,7 +13,6 @@ using namespace frc; StadiaController::StadiaController(int port) : GenericHID(port) { - // re-enable when StadiaController is added to Usage Reporting // HAL_Report(HALUsageReporting::kResourceType_StadiaController, port + 1); } @@ -31,70 +32,6 @@ double StadiaController::GetRightY() const { return GetRawAxis(Axis::kRightY); } -bool StadiaController::GetLeftBumper() const { - return GetRawButton(Button::kLeftBumper); -} - -bool StadiaController::GetRightBumper() const { - return GetRawButton(Button::kRightBumper); -} - -bool StadiaController::GetLeftBumperPressed() { - return GetRawButtonPressed(Button::kLeftBumper); -} - -bool StadiaController::GetRightBumperPressed() { - return GetRawButtonPressed(Button::kRightBumper); -} - -bool StadiaController::GetLeftBumperReleased() { - return GetRawButtonReleased(Button::kLeftBumper); -} - -bool StadiaController::GetRightBumperReleased() { - return GetRawButtonReleased(Button::kRightBumper); -} - -BooleanEvent StadiaController::LeftBumper(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetLeftBumper(); }); -} - -BooleanEvent StadiaController::RightBumper(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetRightBumper(); }); -} - -bool StadiaController::GetLeftStickButton() const { - return GetRawButton(Button::kLeftStick); -} - -bool StadiaController::GetRightStickButton() const { - return GetRawButton(Button::kRightStick); -} - -bool StadiaController::GetLeftStickButtonPressed() { - return GetRawButtonPressed(Button::kLeftStick); -} - -bool StadiaController::GetRightStickButtonPressed() { - return GetRawButtonPressed(Button::kRightStick); -} - -bool StadiaController::GetLeftStickButtonReleased() { - return GetRawButtonReleased(Button::kLeftStick); -} - -bool StadiaController::GetRightStickButtonReleased() { - return GetRawButtonReleased(Button::kRightStick); -} - -BooleanEvent StadiaController::LeftStick(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetLeftStickButton(); }); -} - -BooleanEvent StadiaController::RightStick(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetRightStickButton(); }); -} - bool StadiaController::GetAButton() const { return GetRawButton(Button::kA); } @@ -159,6 +96,70 @@ BooleanEvent StadiaController::Y(EventLoop* loop) const { return BooleanEvent(loop, [this]() { return this->GetYButton(); }); } +bool StadiaController::GetLeftBumperButton() const { + return GetRawButton(Button::kLeftBumper); +} + +bool StadiaController::GetLeftBumperButtonPressed() { + return GetRawButtonPressed(Button::kLeftBumper); +} + +bool StadiaController::GetLeftBumperButtonReleased() { + return GetRawButtonReleased(Button::kLeftBumper); +} + +BooleanEvent StadiaController::LeftBumper(EventLoop* loop) const { + return BooleanEvent(loop, [this]() { return this->GetLeftBumperButton(); }); +} + +bool StadiaController::GetRightBumperButton() const { + return GetRawButton(Button::kRightBumper); +} + +bool StadiaController::GetRightBumperButtonPressed() { + return GetRawButtonPressed(Button::kRightBumper); +} + +bool StadiaController::GetRightBumperButtonReleased() { + return GetRawButtonReleased(Button::kRightBumper); +} + +BooleanEvent StadiaController::RightBumper(EventLoop* loop) const { + return BooleanEvent(loop, [this]() { return this->GetRightBumperButton(); }); +} + +bool StadiaController::GetLeftStickButton() const { + return GetRawButton(Button::kLeftStick); +} + +bool StadiaController::GetLeftStickButtonPressed() { + return GetRawButtonPressed(Button::kLeftStick); +} + +bool StadiaController::GetLeftStickButtonReleased() { + return GetRawButtonReleased(Button::kLeftStick); +} + +BooleanEvent StadiaController::LeftStick(EventLoop* loop) const { + return BooleanEvent(loop, [this]() { return this->GetLeftStickButton(); }); +} + +bool StadiaController::GetRightStickButton() const { + return GetRawButton(Button::kRightStick); +} + +bool StadiaController::GetRightStickButtonPressed() { + return GetRawButtonPressed(Button::kRightStick); +} + +bool StadiaController::GetRightStickButtonReleased() { + return GetRawButtonReleased(Button::kRightStick); +} + +BooleanEvent StadiaController::RightStick(EventLoop* loop) const { + return BooleanEvent(loop, [this]() { return this->GetRightStickButton(); }); +} + bool StadiaController::GetEllipsesButton() const { return GetRawButton(Button::kEllipses); } @@ -207,6 +208,38 @@ BooleanEvent StadiaController::Stadia(EventLoop* loop) const { return BooleanEvent(loop, [this]() { return this->GetStadiaButton(); }); } +bool StadiaController::GetRightTriggerButton() const { + return GetRawButton(Button::kRightTrigger); +} + +bool StadiaController::GetRightTriggerButtonPressed() { + return GetRawButtonPressed(Button::kRightTrigger); +} + +bool StadiaController::GetRightTriggerButtonReleased() { + return GetRawButtonReleased(Button::kRightTrigger); +} + +BooleanEvent StadiaController::RightTrigger(EventLoop* loop) const { + return BooleanEvent(loop, [this]() { return this->GetRightTriggerButton(); }); +} + +bool StadiaController::GetLeftTriggerButton() const { + return GetRawButton(Button::kLeftTrigger); +} + +bool StadiaController::GetLeftTriggerButtonPressed() { + return GetRawButtonPressed(Button::kLeftTrigger); +} + +bool StadiaController::GetLeftTriggerButtonReleased() { + return GetRawButtonReleased(Button::kLeftTrigger); +} + +BooleanEvent StadiaController::LeftTrigger(EventLoop* loop) const { + return BooleanEvent(loop, [this]() { return this->GetLeftTriggerButton(); }); +} + bool StadiaController::GetGoogleButton() const { return GetRawButton(Button::kGoogle); } @@ -239,34 +272,26 @@ BooleanEvent StadiaController::Frame(EventLoop* loop) const { return BooleanEvent(loop, [this]() { return this->GetFrameButton(); }); } -bool StadiaController::GetLeftTriggerButton() const { - return GetRawButton(Button::kLeftTrigger); -} - -bool StadiaController::GetLeftTriggerButtonPressed() { - return GetRawButtonPressed(Button::kLeftTrigger); -} - -bool StadiaController::GetLeftTriggerButtonReleased() { - return GetRawButtonReleased(Button::kLeftTrigger); +bool StadiaController::GetLeftBumper() const { + return GetRawButton(Button::kLeftBumper); } -BooleanEvent StadiaController::LeftTrigger(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetLeftTriggerButton(); }); +bool StadiaController::GetRightBumper() const { + return GetRawButton(Button::kRightBumper); } -bool StadiaController::GetRightTriggerButton() const { - return GetRawButton(Button::kRightTrigger); +bool StadiaController::GetLeftBumperPressed() { + return GetRawButtonPressed(Button::kLeftBumper); } -bool StadiaController::GetRightTriggerButtonPressed() { - return GetRawButtonPressed(Button::kRightTrigger); +bool StadiaController::GetRightBumperPressed() { + return GetRawButtonPressed(Button::kRightBumper); } -bool StadiaController::GetRightTriggerButtonReleased() { - return GetRawButtonReleased(Button::kRightTrigger); +bool StadiaController::GetLeftBumperReleased() { + return GetRawButtonReleased(Button::kLeftBumper); } -BooleanEvent StadiaController::RightTrigger(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetRightTriggerButton(); }); +bool StadiaController::GetRightBumperReleased() { + return GetRawButtonReleased(Button::kRightBumper); } diff --git a/wpilibc/src/main/native/cpp/XboxController.cpp b/wpilibc/src/generated/main/native/cpp/XboxController.cpp similarity index 82% rename from wpilibc/src/main/native/cpp/XboxController.cpp rename to wpilibc/src/generated/main/native/cpp/XboxController.cpp index f10419f4006..a924ba21eff 100644 --- a/wpilibc/src/main/native/cpp/XboxController.cpp +++ b/wpilibc/src/generated/main/native/cpp/XboxController.cpp @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + #include "frc/XboxController.h" #include @@ -34,72 +36,24 @@ double XboxController::GetLeftTriggerAxis() const { return GetRawAxis(Axis::kLeftTrigger); } -double XboxController::GetRightTriggerAxis() const { - return GetRawAxis(Axis::kRightTrigger); -} - -bool XboxController::GetLeftBumper() const { - return GetRawButton(Button::kLeftBumper); -} - -bool XboxController::GetRightBumper() const { - return GetRawButton(Button::kRightBumper); -} - -bool XboxController::GetLeftBumperPressed() { - return GetRawButtonPressed(Button::kLeftBumper); -} - -bool XboxController::GetRightBumperPressed() { - return GetRawButtonPressed(Button::kRightBumper); -} - -bool XboxController::GetLeftBumperReleased() { - return GetRawButtonReleased(Button::kLeftBumper); -} - -bool XboxController::GetRightBumperReleased() { - return GetRawButtonReleased(Button::kRightBumper); -} - -BooleanEvent XboxController::LeftBumper(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetLeftBumper(); }); -} - -BooleanEvent XboxController::RightBumper(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetRightBumper(); }); -} - -bool XboxController::GetLeftStickButton() const { - return GetRawButton(Button::kLeftStick); -} - -bool XboxController::GetRightStickButton() const { - return GetRawButton(Button::kRightStick); -} - -bool XboxController::GetLeftStickButtonPressed() { - return GetRawButtonPressed(Button::kLeftStick); -} - -bool XboxController::GetRightStickButtonPressed() { - return GetRawButtonPressed(Button::kRightStick); +BooleanEvent XboxController::LeftTrigger(double threshold, EventLoop* loop) const { + return BooleanEvent(loop, [this, threshold] { return this->GetLeftTriggerAxis() > threshold; }); } -bool XboxController::GetLeftStickButtonReleased() { - return GetRawButtonReleased(Button::kLeftStick); +BooleanEvent XboxController::LeftTrigger(EventLoop* loop) const { + return this->LeftTrigger(0.5, loop); } -bool XboxController::GetRightStickButtonReleased() { - return GetRawButtonReleased(Button::kRightStick); +double XboxController::GetRightTriggerAxis() const { + return GetRawAxis(Axis::kRightTrigger); } -BooleanEvent XboxController::LeftStick(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetLeftStickButton(); }); +BooleanEvent XboxController::RightTrigger(double threshold, EventLoop* loop) const { + return BooleanEvent(loop, [this, threshold] { return this->GetRightTriggerAxis() > threshold; }); } -BooleanEvent XboxController::RightStick(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetRightStickButton(); }); +BooleanEvent XboxController::RightTrigger(EventLoop* loop) const { + return this->RightTrigger(0.5, loop); } bool XboxController::GetAButton() const { @@ -166,6 +120,38 @@ BooleanEvent XboxController::Y(EventLoop* loop) const { return BooleanEvent(loop, [this]() { return this->GetYButton(); }); } +bool XboxController::GetLeftBumperButton() const { + return GetRawButton(Button::kLeftBumper); +} + +bool XboxController::GetLeftBumperButtonPressed() { + return GetRawButtonPressed(Button::kLeftBumper); +} + +bool XboxController::GetLeftBumperButtonReleased() { + return GetRawButtonReleased(Button::kLeftBumper); +} + +BooleanEvent XboxController::LeftBumper(EventLoop* loop) const { + return BooleanEvent(loop, [this]() { return this->GetLeftBumperButton(); }); +} + +bool XboxController::GetRightBumperButton() const { + return GetRawButton(Button::kRightBumper); +} + +bool XboxController::GetRightBumperButtonPressed() { + return GetRawButtonPressed(Button::kRightBumper); +} + +bool XboxController::GetRightBumperButtonReleased() { + return GetRawButtonReleased(Button::kRightBumper); +} + +BooleanEvent XboxController::RightBumper(EventLoop* loop) const { + return BooleanEvent(loop, [this]() { return this->GetRightBumperButton(); }); +} + bool XboxController::GetBackButton() const { return GetRawButton(Button::kBack); } @@ -198,24 +184,58 @@ BooleanEvent XboxController::Start(EventLoop* loop) const { return BooleanEvent(loop, [this]() { return this->GetStartButton(); }); } -BooleanEvent XboxController::LeftTrigger(double threshold, - EventLoop* loop) const { - return BooleanEvent(loop, [this, threshold]() { - return this->GetLeftTriggerAxis() > threshold; - }); +bool XboxController::GetLeftStickButton() const { + return GetRawButton(Button::kLeftStick); } -BooleanEvent XboxController::LeftTrigger(EventLoop* loop) const { - return this->LeftTrigger(0.5, loop); +bool XboxController::GetLeftStickButtonPressed() { + return GetRawButtonPressed(Button::kLeftStick); } -BooleanEvent XboxController::RightTrigger(double threshold, - EventLoop* loop) const { - return BooleanEvent(loop, [this, threshold]() { - return this->GetRightTriggerAxis() > threshold; - }); +bool XboxController::GetLeftStickButtonReleased() { + return GetRawButtonReleased(Button::kLeftStick); } -BooleanEvent XboxController::RightTrigger(EventLoop* loop) const { - return this->RightTrigger(0.5, loop); +BooleanEvent XboxController::LeftStick(EventLoop* loop) const { + return BooleanEvent(loop, [this]() { return this->GetLeftStickButton(); }); +} + +bool XboxController::GetRightStickButton() const { + return GetRawButton(Button::kRightStick); +} + +bool XboxController::GetRightStickButtonPressed() { + return GetRawButtonPressed(Button::kRightStick); +} + +bool XboxController::GetRightStickButtonReleased() { + return GetRawButtonReleased(Button::kRightStick); +} + +BooleanEvent XboxController::RightStick(EventLoop* loop) const { + return BooleanEvent(loop, [this]() { return this->GetRightStickButton(); }); +} + +bool XboxController::GetLeftBumper() const { + return GetRawButton(Button::kLeftBumper); +} + +bool XboxController::GetRightBumper() const { + return GetRawButton(Button::kRightBumper); +} + +bool XboxController::GetLeftBumperPressed() { + return GetRawButtonPressed(Button::kLeftBumper); +} + +bool XboxController::GetRightBumperPressed() { + return GetRawButtonPressed(Button::kRightBumper); +} + +bool XboxController::GetLeftBumperReleased() { + return GetRawButtonReleased(Button::kLeftBumper); +} + +bool XboxController::GetRightBumperReleased() { + return GetRawButtonReleased(Button::kRightBumper); } diff --git a/wpilibc/src/main/native/cpp/simulation/PS4ControllerSim.cpp b/wpilibc/src/generated/main/native/cpp/simulation/PS4ControllerSim.cpp similarity index 95% rename from wpilibc/src/main/native/cpp/simulation/PS4ControllerSim.cpp rename to wpilibc/src/generated/main/native/cpp/simulation/PS4ControllerSim.cpp index fecac9dc369..9fb4f3fc994 100644 --- a/wpilibc/src/main/native/cpp/simulation/PS4ControllerSim.cpp +++ b/wpilibc/src/generated/main/native/cpp/simulation/PS4ControllerSim.cpp @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + #include "frc/simulation/PS4ControllerSim.h" #include "frc/PS4Controller.h" @@ -26,14 +28,14 @@ void PS4ControllerSim::SetLeftX(double value) { SetRawAxis(PS4Controller::Axis::kLeftX, value); } -void PS4ControllerSim::SetRightX(double value) { - SetRawAxis(PS4Controller::Axis::kRightX, value); -} - void PS4ControllerSim::SetLeftY(double value) { SetRawAxis(PS4Controller::Axis::kLeftY, value); } +void PS4ControllerSim::SetRightX(double value) { + SetRawAxis(PS4Controller::Axis::kRightX, value); +} + void PS4ControllerSim::SetRightY(double value) { SetRawAxis(PS4Controller::Axis::kRightY, value); } @@ -98,6 +100,6 @@ void PS4ControllerSim::SetPSButton(bool value) { SetRawButton(PS4Controller::Button::kPS, value); } -void PS4ControllerSim::SetTouchpad(bool value) { +void PS4ControllerSim::SetTouchpadButton(bool value) { SetRawButton(PS4Controller::Button::kTouchpad, value); } diff --git a/wpilibc/src/main/native/cpp/simulation/PS5ControllerSim.cpp b/wpilibc/src/generated/main/native/cpp/simulation/PS5ControllerSim.cpp similarity index 95% rename from wpilibc/src/main/native/cpp/simulation/PS5ControllerSim.cpp rename to wpilibc/src/generated/main/native/cpp/simulation/PS5ControllerSim.cpp index e20105c4b3d..4e3a095d8e5 100644 --- a/wpilibc/src/main/native/cpp/simulation/PS5ControllerSim.cpp +++ b/wpilibc/src/generated/main/native/cpp/simulation/PS5ControllerSim.cpp @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + #include "frc/simulation/PS5ControllerSim.h" #include "frc/PS5Controller.h" @@ -26,14 +28,14 @@ void PS5ControllerSim::SetLeftX(double value) { SetRawAxis(PS5Controller::Axis::kLeftX, value); } -void PS5ControllerSim::SetRightX(double value) { - SetRawAxis(PS5Controller::Axis::kRightX, value); -} - void PS5ControllerSim::SetLeftY(double value) { SetRawAxis(PS5Controller::Axis::kLeftY, value); } +void PS5ControllerSim::SetRightX(double value) { + SetRawAxis(PS5Controller::Axis::kRightX, value); +} + void PS5ControllerSim::SetRightY(double value) { SetRawAxis(PS5Controller::Axis::kRightY, value); } @@ -98,6 +100,6 @@ void PS5ControllerSim::SetPSButton(bool value) { SetRawButton(PS5Controller::Button::kPS, value); } -void PS5ControllerSim::SetTouchpad(bool value) { +void PS5ControllerSim::SetTouchpadButton(bool value) { SetRawButton(PS5Controller::Button::kTouchpad, value); } diff --git a/wpilibc/src/generated/main/native/cpp/simulation/StadiaControllerSim.cpp b/wpilibc/src/generated/main/native/cpp/simulation/StadiaControllerSim.cpp new file mode 100644 index 00000000000..73f4a504e02 --- /dev/null +++ b/wpilibc/src/generated/main/native/cpp/simulation/StadiaControllerSim.cpp @@ -0,0 +1,101 @@ +// 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. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + +#include "frc/simulation/StadiaControllerSim.h" + +#include "frc/StadiaController.h" + +using namespace frc; +using namespace frc::sim; + +StadiaControllerSim::StadiaControllerSim(const StadiaController& joystick) + : GenericHIDSim{joystick} { + SetAxisCount(4); + SetButtonCount(15); + SetPOVCount(1); +} + +StadiaControllerSim::StadiaControllerSim(int port) : GenericHIDSim{port} { + SetAxisCount(4); + SetButtonCount(15); + SetPOVCount(1); +} + +void StadiaControllerSim::SetLeftX(double value) { + SetRawAxis(StadiaController::Axis::kLeftX, value); +} + +void StadiaControllerSim::SetRightX(double value) { + SetRawAxis(StadiaController::Axis::kRightX, value); +} + +void StadiaControllerSim::SetLeftY(double value) { + SetRawAxis(StadiaController::Axis::kLeftY, value); +} + +void StadiaControllerSim::SetRightY(double value) { + SetRawAxis(StadiaController::Axis::kRightY, value); +} + +void StadiaControllerSim::SetAButton(bool value) { + SetRawButton(StadiaController::Button::kA, value); +} + +void StadiaControllerSim::SetBButton(bool value) { + SetRawButton(StadiaController::Button::kB, value); +} + +void StadiaControllerSim::SetXButton(bool value) { + SetRawButton(StadiaController::Button::kX, value); +} + +void StadiaControllerSim::SetYButton(bool value) { + SetRawButton(StadiaController::Button::kY, value); +} + +void StadiaControllerSim::SetLeftBumperButton(bool value) { + SetRawButton(StadiaController::Button::kLeftBumper, value); +} + +void StadiaControllerSim::SetRightBumperButton(bool value) { + SetRawButton(StadiaController::Button::kRightBumper, value); +} + +void StadiaControllerSim::SetLeftStickButton(bool value) { + SetRawButton(StadiaController::Button::kLeftStick, value); +} + +void StadiaControllerSim::SetRightStickButton(bool value) { + SetRawButton(StadiaController::Button::kRightStick, value); +} + +void StadiaControllerSim::SetEllipsesButton(bool value) { + SetRawButton(StadiaController::Button::kEllipses, value); +} + +void StadiaControllerSim::SetHamburgerButton(bool value) { + SetRawButton(StadiaController::Button::kHamburger, value); +} + +void StadiaControllerSim::SetStadiaButton(bool value) { + SetRawButton(StadiaController::Button::kStadia, value); +} + +void StadiaControllerSim::SetRightTriggerButton(bool value) { + SetRawButton(StadiaController::Button::kRightTrigger, value); +} + +void StadiaControllerSim::SetLeftTriggerButton(bool value) { + SetRawButton(StadiaController::Button::kLeftTrigger, value); +} + +void StadiaControllerSim::SetGoogleButton(bool value) { + SetRawButton(StadiaController::Button::kGoogle, value); +} + +void StadiaControllerSim::SetFrameButton(bool value) { + SetRawButton(StadiaController::Button::kFrame, value); +} diff --git a/wpilibc/src/main/native/cpp/simulation/XboxControllerSim.cpp b/wpilibc/src/generated/main/native/cpp/simulation/XboxControllerSim.cpp similarity index 52% rename from wpilibc/src/main/native/cpp/simulation/XboxControllerSim.cpp rename to wpilibc/src/generated/main/native/cpp/simulation/XboxControllerSim.cpp index daf48b78efe..441058982ed 100644 --- a/wpilibc/src/main/native/cpp/simulation/XboxControllerSim.cpp +++ b/wpilibc/src/generated/main/native/cpp/simulation/XboxControllerSim.cpp @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + #include "frc/simulation/XboxControllerSim.h" #include "frc/XboxController.h" @@ -46,42 +48,42 @@ void XboxControllerSim::SetRightTriggerAxis(double value) { SetRawAxis(XboxController::Axis::kRightTrigger, value); } -void XboxControllerSim::SetLeftBumper(bool state) { - SetRawButton(XboxController::Button::kLeftBumper, state); +void XboxControllerSim::SetAButton(bool value) { + SetRawButton(XboxController::Button::kA, value); } -void XboxControllerSim::SetRightBumper(bool state) { - SetRawButton(XboxController::Button::kRightBumper, state); +void XboxControllerSim::SetBButton(bool value) { + SetRawButton(XboxController::Button::kB, value); } -void XboxControllerSim::SetLeftStickButton(bool state) { - SetRawButton(XboxController::Button::kLeftStick, state); +void XboxControllerSim::SetXButton(bool value) { + SetRawButton(XboxController::Button::kX, value); } -void XboxControllerSim::SetRightStickButton(bool state) { - SetRawButton(XboxController::Button::kRightStick, state); +void XboxControllerSim::SetYButton(bool value) { + SetRawButton(XboxController::Button::kY, value); } -void XboxControllerSim::SetAButton(bool state) { - SetRawButton(XboxController::Button::kA, state); +void XboxControllerSim::SetLeftBumperButton(bool value) { + SetRawButton(XboxController::Button::kLeftBumper, value); } -void XboxControllerSim::SetBButton(bool state) { - SetRawButton(XboxController::Button::kB, state); +void XboxControllerSim::SetRightBumperButton(bool value) { + SetRawButton(XboxController::Button::kRightBumper, value); } -void XboxControllerSim::SetXButton(bool state) { - SetRawButton(XboxController::Button::kX, state); +void XboxControllerSim::SetBackButton(bool value) { + SetRawButton(XboxController::Button::kBack, value); } -void XboxControllerSim::SetYButton(bool state) { - SetRawButton(XboxController::Button::kY, state); +void XboxControllerSim::SetStartButton(bool value) { + SetRawButton(XboxController::Button::kStart, value); } -void XboxControllerSim::SetBackButton(bool state) { - SetRawButton(XboxController::Button::kBack, state); +void XboxControllerSim::SetLeftStickButton(bool value) { + SetRawButton(XboxController::Button::kLeftStick, value); } -void XboxControllerSim::SetStartButton(bool state) { - SetRawButton(XboxController::Button::kStart, state); +void XboxControllerSim::SetRightStickButton(bool value) { + SetRawButton(XboxController::Button::kRightStick, value); } diff --git a/wpilibc/src/main/native/include/frc/PS4Controller.h b/wpilibc/src/generated/main/native/include/frc/PS4Controller.h similarity index 57% rename from wpilibc/src/main/native/include/frc/PS4Controller.h rename to wpilibc/src/generated/main/native/include/frc/PS4Controller.h index 881f8564f25..02b0d206627 100644 --- a/wpilibc/src/main/native/include/frc/PS4Controller.h +++ b/wpilibc/src/generated/main/native/include/frc/PS4Controller.h @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + #pragma once #include "frc/GenericHID.h" @@ -11,19 +13,19 @@ namespace frc { /** * Handle input from PS4 controllers connected to the Driver Station. * - * This class handles PS4 input that comes from the Driver Station. Each time - * a value is requested the most recent value is returned. There is a single - * class instance for each controller and the mapping of ports to hardware - * buttons depends on the code in the Driver Station. + * This class handles PS4 input that comes from the Driver Station. Each + * time a value is requested the most recent value is returned. There is a + * single class instance for each controller and the mapping of ports to + * hardware buttons depends on the code in the Driver Station. * - * Only first party controllers from Sony are guaranteed to have the correct - * mapping, and only through the official NI DS. Sim is not guaranteed to have - * the same mapping, as well as any 3rd party controllers. + * Only first party controllers from Sony are guaranteed to have the + * correct mapping, and only through the official NI DS. Sim is not guaranteed + * to have the same mapping, as well as any 3rd party controllers. */ class PS4Controller : public GenericHID { public: /** - * Construct an instance of an PS4 controller. + * Construct an instance of a controller. * * The controller index is the USB port on the Driver Station. * @@ -45,18 +47,18 @@ class PS4Controller : public GenericHID { double GetLeftX() const; /** - * Get the X axis value of right side of the controller. + * Get the Y axis value of left side of the controller. * * @return the axis value. */ - double GetRightX() const; + double GetLeftY() const; /** - * Get the Y axis value of left side of the controller. + * Get the X axis value of right side of the controller. * * @return the axis value. */ - double GetLeftY() const; + double GetRightX() const; /** * Get the Y axis value of right side of the controller. @@ -66,324 +68,333 @@ class PS4Controller : public GenericHID { double GetRightY() const; /** - * Get the L2 axis value of the controller. Note that this axis is bound to - * the range of [0, 1] as opposed to the usual [-1, 1]. + * Get the left trigger 2 axis value of the controller. Note that this axis + * is bound to the range of [0, 1] as opposed to the usual [-1, 1]. * * @return the axis value. */ double GetL2Axis() const; /** - * Get the R2 axis value of the controller. Note that this axis is bound to - * the range of [0, 1] as opposed to the usual [-1, 1]. + * Get the right trigger 2 axis value of the controller. Note that this axis + * is bound to the range of [0, 1] as opposed to the usual [-1, 1]. * * @return the axis value. */ double GetR2Axis() const; /** - * Read the value of the Square button on the controller. + * Read the value of the square button on the controller. * * @return The state of the button. */ bool GetSquareButton() const; /** - * Whether the Square button was pressed since the last check. + * Whether the square button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetSquareButtonPressed(); /** - * Whether the Square button was released since the last check. + * Whether the square button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetSquareButtonReleased(); /** - * Constructs an event instance around the square button's digital signal. + * Constructs an event instance around the square button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the square button's digital signal - * attached to the given loop. + * @return an event instance representing the square button's + * digital signal attached to the given loop. */ BooleanEvent Square(EventLoop* loop) const; /** - * Read the value of the Cross button on the controller. + * Read the value of the cross button on the controller. * * @return The state of the button. */ bool GetCrossButton() const; /** - * Whether the Cross button was pressed since the last check. + * Whether the cross button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetCrossButtonPressed(); /** - * Whether the Cross button was released since the last check. + * Whether the cross button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetCrossButtonReleased(); /** - * Constructs an event instance around the cross button's digital signal. + * Constructs an event instance around the cross button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the cross button's digital signal - * attached to the given loop. + * @return an event instance representing the cross button's + * digital signal attached to the given loop. */ BooleanEvent Cross(EventLoop* loop) const; /** - * Read the value of the Circle button on the controller. + * Read the value of the circle button on the controller. * * @return The state of the button. */ bool GetCircleButton() const; /** - * Whether the Circle button was pressed since the last check. + * Whether the circle button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetCircleButtonPressed(); /** - * Whether the Circle button was released since the last check. + * Whether the circle button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetCircleButtonReleased(); /** - * Constructs an event instance around the circle button's digital signal. + * Constructs an event instance around the circle button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the circle button's digital signal - * attached to the given loop. + * @return an event instance representing the circle button's + * digital signal attached to the given loop. */ BooleanEvent Circle(EventLoop* loop) const; /** - * Read the value of the Triangle button on the controller. + * Read the value of the triangle button on the controller. * * @return The state of the button. */ bool GetTriangleButton() const; /** - * Whether the Triangle button was pressed since the last check. + * Whether the triangle button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetTriangleButtonPressed(); /** - * Whether the Triangle button was released since the last check. + * Whether the triangle button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetTriangleButtonReleased(); /** - * Constructs an event instance around the triangle button's digital signal. + * Constructs an event instance around the triangle button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the triangle button's digital signal - * attached to the given loop. + * @return an event instance representing the triangle button's + * digital signal attached to the given loop. */ BooleanEvent Triangle(EventLoop* loop) const; /** - * Read the value of the L1 button on the controller. + * Read the value of the left trigger 1 button on the controller. * * @return The state of the button. */ bool GetL1Button() const; /** - * Whether the L1 button was pressed since the last check. + * Whether the left trigger 1 button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetL1ButtonPressed(); /** - * Whether the L1 button was released since the last check. + * Whether the left trigger 1 button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetL1ButtonReleased(); /** - * Constructs an event instance around the L1 button's digital signal. + * Constructs an event instance around the left trigger 1 button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the L1 button's digital signal - * attached to the given loop. + * @return an event instance representing the left trigger 1 button's + * digital signal attached to the given loop. */ BooleanEvent L1(EventLoop* loop) const; /** - * Read the value of the R1 button on the controller. + * Read the value of the right trigger 1 button on the controller. * * @return The state of the button. */ bool GetR1Button() const; /** - * Whether the R1 button was pressed since the last check. + * Whether the right trigger 1 button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetR1ButtonPressed(); /** - * Whether the R1 button was released since the last check. + * Whether the right trigger 1 button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetR1ButtonReleased(); /** - * Constructs an event instance around the R1 button's digital signal. + * Constructs an event instance around the right trigger 1 button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the R1 button's digital signal - * attached to the given loop. + * @return an event instance representing the right trigger 1 button's + * digital signal attached to the given loop. */ BooleanEvent R1(EventLoop* loop) const; /** - * Read the value of the L2 button on the controller. + * Read the value of the left trigger 2 button on the controller. * * @return The state of the button. */ bool GetL2Button() const; /** - * Whether the L2 button was pressed since the last check. + * Whether the left trigger 2 button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetL2ButtonPressed(); /** - * Whether the L2 button was released since the last check. + * Whether the left trigger 2 button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetL2ButtonReleased(); /** - * Constructs an event instance around the L2 button's digital signal. + * Constructs an event instance around the left trigger 2 button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the L2 button's digital signal - * attached to the given loop. + * @return an event instance representing the left trigger 2 button's + * digital signal attached to the given loop. */ BooleanEvent L2(EventLoop* loop) const; /** - * Read the value of the R2 button on the controller. + * Read the value of the right trigger 2 button on the controller. * * @return The state of the button. */ bool GetR2Button() const; /** - * Whether the R2 button was pressed since the last check. + * Whether the right trigger 2 button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetR2ButtonPressed(); /** - * Whether the R2 button was released since the last check. + * Whether the right trigger 2 button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetR2ButtonReleased(); /** - * Constructs an event instance around the R2 button's digital signal. + * Constructs an event instance around the right trigger 2 button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the R2 button's digital signal - * attached to the given loop. + * @return an event instance representing the right trigger 2 button's + * digital signal attached to the given loop. */ BooleanEvent R2(EventLoop* loop) const; /** - * Read the value of the Share button on the controller. + * Read the value of the share button on the controller. * * @return The state of the button. */ bool GetShareButton() const; /** - * Whether the Share button was pressed since the last check. + * Whether the share button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetShareButtonPressed(); /** - * Whether the Share button was released since the last check. + * Whether the share button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetShareButtonReleased(); /** - * Constructs an event instance around the share button's digital signal. + * Constructs an event instance around the share button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the share button's digital signal - * attached to the given loop. + * @return an event instance representing the share button's + * digital signal attached to the given loop. */ BooleanEvent Share(EventLoop* loop) const; /** - * Read the value of the Options button on the controller. + * Read the value of the options button on the controller. * * @return The state of the button. */ bool GetOptionsButton() const; /** - * Whether the Options button was pressed since the last check. + * Whether the options button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetOptionsButtonPressed(); /** - * Whether the Options button was released since the last check. + * Whether the options button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetOptionsButtonReleased(); /** - * Constructs an event instance around the options button's digital signal. + * Constructs an event instance around the options button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the options button's digital signal - * attached to the given loop. + * @return an event instance representing the options button's + * digital signal attached to the given loop. */ BooleanEvent Options(EventLoop* loop) const; /** - * Read the value of the L3 button (pressing the left analog stick) on the - * controller. + * Read the value of the L3 (left stick) button on the controller. * * @return The state of the button. */ @@ -404,17 +415,17 @@ class PS4Controller : public GenericHID { bool GetL3ButtonReleased(); /** - * Constructs an event instance around the L3 button's digital signal. + * Constructs an event instance around the L3 (left stick) button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the L3 button's digital signal - * attached to the given loop. + * @return an event instance representing the L3 (left stick) button's + * digital signal attached to the given loop. */ BooleanEvent L3(EventLoop* loop) const; /** - * Read the value of the R3 button (pressing the right analog stick) on the - * controller. + * Read the value of the R3 (right stick) button on the controller. * * @return The state of the button. */ @@ -435,41 +446,43 @@ class PS4Controller : public GenericHID { bool GetR3ButtonReleased(); /** - * Constructs an event instance around the R3 button's digital signal. + * Constructs an event instance around the R3 (right stick) button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the R3 button's digital signal - * attached to the given loop. + * @return an event instance representing the R3 (right stick) button's + * digital signal attached to the given loop. */ BooleanEvent R3(EventLoop* loop) const; /** - * Read the value of the PS button on the controller. + * Read the value of the PlayStation button on the controller. * * @return The state of the button. */ bool GetPSButton() const; /** - * Whether the PS button was pressed since the last check. + * Whether the PlayStation button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetPSButtonPressed(); /** - * Whether the PS button was released since the last check. + * Whether the PlayStation button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetPSButtonReleased(); /** - * Constructs an event instance around the PS button's digital signal. + * Constructs an event instance around the PlayStation button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the PS button's digital signal - * attached to the given loop. + * @return an event instance representing the PlayStation button's + * digital signal attached to the given loop. */ BooleanEvent PS(EventLoop* loop) const; @@ -478,68 +491,90 @@ class PS4Controller : public GenericHID { * * @return The state of the button. */ - bool GetTouchpad() const; + bool GetTouchpadButton() const; /** - * Whether the touchpad was pressed since the last check. + * Whether the touchpad button was pressed since the last check. * - * @return Whether the touchpad was pressed since the last check. + * @return Whether the button was pressed since the last check. */ - bool GetTouchpadPressed(); + bool GetTouchpadButtonPressed(); /** - * Whether the touchpad was released since the last check. + * Whether the touchpad button was released since the last check. * - * @return Whether the touchpad was released since the last check. + * @return Whether the button was released since the last check. */ - bool GetTouchpadReleased(); + bool GetTouchpadButtonReleased(); /** - * Constructs an event instance around the touchpad's digital signal. + * Constructs an event instance around the touchpad button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the touchpad's digital signal - * attached to the given loop. + * @return an event instance representing the touchpad button's + * digital signal attached to the given loop. */ BooleanEvent Touchpad(EventLoop* loop) const; + + /** - * Represents a digital button on a PS4Controller. + * Read the value of the touchpad button on the controller. + * + * @return The state of the button. + */ + [[deprecated("Use GetTouchpadButton instead")]] + bool GetTouchpad() const; + /** + * Whether the touchpad was pressed since the last check. + * + * @return Whether the touchpad was pressed since the last check. + */ + [[deprecated("Use GetTouchpadButtonPressed instead")]] + bool GetTouchpadPressed(); + + /** + * Whether the touchpad was released since the last check. + * + * @return Whether the touchpad was released since the last check. */ + [[deprecated("Use GetTouchpadButtonReleased instead")]] + bool GetTouchpadReleased(); + + /** Represents a digital button on an PS4Controller. */ struct Button { /// Square button. static constexpr int kSquare = 1; - /// X button. + /// Cross button. static constexpr int kCross = 2; /// Circle button. static constexpr int kCircle = 3; /// Triangle button. static constexpr int kTriangle = 4; - /// Left Trigger 1 button. + /// Left trigger 1 button. static constexpr int kL1 = 5; - /// Right Trigger 1 button. + /// Right trigger 1 button. static constexpr int kR1 = 6; - /// Left Trigger 2 button. + /// Left trigger 2 button. static constexpr int kL2 = 7; - /// Right Trigger 2 button. + /// Right trigger 2 button. static constexpr int kR2 = 8; /// Share button. static constexpr int kShare = 9; - /// Option button. + /// Options button. static constexpr int kOptions = 10; - /// Left stick button. + /// L3 (left stick) button. static constexpr int kL3 = 11; - /// Right stick button. + /// R3 (right stick) button. static constexpr int kR3 = 12; - /// PlayStation button. + /// Playstation button. static constexpr int kPS = 13; - /// Touchpad click button. + /// Touchpad button. static constexpr int kTouchpad = 14; }; - /** - * Represents an axis on a PS4Controller. - */ + /** Represents an axis on an PS4Controller. */ struct Axis { /// Left X axis. static constexpr int kLeftX = 0; @@ -549,9 +584,9 @@ class PS4Controller : public GenericHID { static constexpr int kRightX = 2; /// Right Y axis. static constexpr int kRightY = 5; - /// Left Trigger 2. + /// Left trigger 2. static constexpr int kL2 = 3; - /// Right Trigger 2. + /// Right trigger 2. static constexpr int kR2 = 4; }; }; diff --git a/wpilibc/src/main/native/include/frc/PS5Controller.h b/wpilibc/src/generated/main/native/include/frc/PS5Controller.h similarity index 58% rename from wpilibc/src/main/native/include/frc/PS5Controller.h rename to wpilibc/src/generated/main/native/include/frc/PS5Controller.h index e9d52352304..3181b72114b 100644 --- a/wpilibc/src/main/native/include/frc/PS5Controller.h +++ b/wpilibc/src/generated/main/native/include/frc/PS5Controller.h @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + #pragma once #include "frc/GenericHID.h" @@ -11,19 +13,19 @@ namespace frc { /** * Handle input from PS5 controllers connected to the Driver Station. * - * This class handles PS5 input that comes from the Driver Station. Each time - * a value is requested the most recent value is returned. There is a single - * class instance for each controller and the mapping of ports to hardware - * buttons depends on the code in the Driver Station. + * This class handles PS5 input that comes from the Driver Station. Each + * time a value is requested the most recent value is returned. There is a + * single class instance for each controller and the mapping of ports to + * hardware buttons depends on the code in the Driver Station. * - * Only first party controllers from Sony are guaranteed to have the correct - * mapping, and only through the official NI DS. Sim is not guaranteed to have - * the same mapping, as well as any 3rd party controllers. + * Only first party controllers from Sony are guaranteed to have the + * correct mapping, and only through the official NI DS. Sim is not guaranteed + * to have the same mapping, as well as any 3rd party controllers. */ class PS5Controller : public GenericHID { public: /** - * Construct an instance of an PS5 controller. + * Construct an instance of a controller. * * The controller index is the USB port on the Driver Station. * @@ -45,18 +47,18 @@ class PS5Controller : public GenericHID { double GetLeftX() const; /** - * Get the X axis value of right side of the controller. + * Get the Y axis value of left side of the controller. * * @return the axis value. */ - double GetRightX() const; + double GetLeftY() const; /** - * Get the Y axis value of left side of the controller. + * Get the X axis value of right side of the controller. * * @return the axis value. */ - double GetLeftY() const; + double GetRightX() const; /** * Get the Y axis value of right side of the controller. @@ -66,324 +68,333 @@ class PS5Controller : public GenericHID { double GetRightY() const; /** - * Get the L2 axis value of the controller. Note that this axis is bound to - * the range of [0, 1] as opposed to the usual [-1, 1]. + * Get the left trigger 2 axis value of the controller. Note that this axis + * is bound to the range of [0, 1] as opposed to the usual [-1, 1]. * * @return the axis value. */ double GetL2Axis() const; /** - * Get the R2 axis value of the controller. Note that this axis is bound to - * the range of [0, 1] as opposed to the usual [-1, 1]. + * Get the right trigger 2 axis value of the controller. Note that this axis + * is bound to the range of [0, 1] as opposed to the usual [-1, 1]. * * @return the axis value. */ double GetR2Axis() const; /** - * Read the value of the Square button on the controller. + * Read the value of the square button on the controller. * * @return The state of the button. */ bool GetSquareButton() const; /** - * Whether the Square button was pressed since the last check. + * Whether the square button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetSquareButtonPressed(); /** - * Whether the Square button was released since the last check. + * Whether the square button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetSquareButtonReleased(); /** - * Constructs an event instance around the square button's digital signal. + * Constructs an event instance around the square button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the square button's digital signal - * attached to the given loop. + * @return an event instance representing the square button's + * digital signal attached to the given loop. */ BooleanEvent Square(EventLoop* loop) const; /** - * Read the value of the Cross button on the controller. + * Read the value of the cross button on the controller. * * @return The state of the button. */ bool GetCrossButton() const; /** - * Whether the Cross button was pressed since the last check. + * Whether the cross button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetCrossButtonPressed(); /** - * Whether the Cross button was released since the last check. + * Whether the cross button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetCrossButtonReleased(); /** - * Constructs an event instance around the cross button's digital signal. + * Constructs an event instance around the cross button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the cross button's digital signal - * attached to the given loop. + * @return an event instance representing the cross button's + * digital signal attached to the given loop. */ BooleanEvent Cross(EventLoop* loop) const; /** - * Read the value of the Circle button on the controller. + * Read the value of the circle button on the controller. * * @return The state of the button. */ bool GetCircleButton() const; /** - * Whether the Circle button was pressed since the last check. + * Whether the circle button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetCircleButtonPressed(); /** - * Whether the Circle button was released since the last check. + * Whether the circle button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetCircleButtonReleased(); /** - * Constructs an event instance around the circle button's digital signal. + * Constructs an event instance around the circle button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the circle button's digital signal - * attached to the given loop. + * @return an event instance representing the circle button's + * digital signal attached to the given loop. */ BooleanEvent Circle(EventLoop* loop) const; /** - * Read the value of the Triangle button on the controller. + * Read the value of the triangle button on the controller. * * @return The state of the button. */ bool GetTriangleButton() const; /** - * Whether the Triangle button was pressed since the last check. + * Whether the triangle button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetTriangleButtonPressed(); /** - * Whether the Triangle button was released since the last check. + * Whether the triangle button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetTriangleButtonReleased(); /** - * Constructs an event instance around the triangle button's digital signal. + * Constructs an event instance around the triangle button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the triangle button's digital signal - * attached to the given loop. + * @return an event instance representing the triangle button's + * digital signal attached to the given loop. */ BooleanEvent Triangle(EventLoop* loop) const; /** - * Read the value of the L1 button on the controller. + * Read the value of the left trigger 1 button on the controller. * * @return The state of the button. */ bool GetL1Button() const; /** - * Whether the L1 button was pressed since the last check. + * Whether the left trigger 1 button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetL1ButtonPressed(); /** - * Whether the L1 button was released since the last check. + * Whether the left trigger 1 button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetL1ButtonReleased(); /** - * Constructs an event instance around the L1 button's digital signal. + * Constructs an event instance around the left trigger 1 button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the L1 button's digital signal - * attached to the given loop. + * @return an event instance representing the left trigger 1 button's + * digital signal attached to the given loop. */ BooleanEvent L1(EventLoop* loop) const; /** - * Read the value of the R1 button on the controller. + * Read the value of the right trigger 1 button on the controller. * * @return The state of the button. */ bool GetR1Button() const; /** - * Whether the R1 button was pressed since the last check. + * Whether the right trigger 1 button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetR1ButtonPressed(); /** - * Whether the R1 button was released since the last check. + * Whether the right trigger 1 button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetR1ButtonReleased(); /** - * Constructs an event instance around the R1 button's digital signal. + * Constructs an event instance around the right trigger 1 button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the R1 button's digital signal - * attached to the given loop. + * @return an event instance representing the right trigger 1 button's + * digital signal attached to the given loop. */ BooleanEvent R1(EventLoop* loop) const; /** - * Read the value of the L2 button on the controller. + * Read the value of the left trigger 2 button on the controller. * * @return The state of the button. */ bool GetL2Button() const; /** - * Whether the L2 button was pressed since the last check. + * Whether the left trigger 2 button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetL2ButtonPressed(); /** - * Whether the L2 button was released since the last check. + * Whether the left trigger 2 button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetL2ButtonReleased(); /** - * Constructs an event instance around the L2 button's digital signal. + * Constructs an event instance around the left trigger 2 button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the L2 button's digital signal - * attached to the given loop. + * @return an event instance representing the left trigger 2 button's + * digital signal attached to the given loop. */ BooleanEvent L2(EventLoop* loop) const; /** - * Read the value of the R2 button on the controller. + * Read the value of the right trigger 2 button on the controller. * * @return The state of the button. */ bool GetR2Button() const; /** - * Whether the R2 button was pressed since the last check. + * Whether the right trigger 2 button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetR2ButtonPressed(); /** - * Whether the R2 button was released since the last check. + * Whether the right trigger 2 button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetR2ButtonReleased(); /** - * Constructs an event instance around the R2 button's digital signal. + * Constructs an event instance around the right trigger 2 button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the R2 button's digital signal - * attached to the given loop. + * @return an event instance representing the right trigger 2 button's + * digital signal attached to the given loop. */ BooleanEvent R2(EventLoop* loop) const; /** - * Read the value of the Create button on the controller. + * Read the value of the create button on the controller. * * @return The state of the button. */ bool GetCreateButton() const; /** - * Whether the Create button was pressed since the last check. + * Whether the create button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetCreateButtonPressed(); /** - * Whether the Create button was released since the last check. + * Whether the create button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetCreateButtonReleased(); /** - * Constructs an event instance around the Create button's digital signal. + * Constructs an event instance around the create button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the Create button's digital signal - * attached to the given loop. + * @return an event instance representing the create button's + * digital signal attached to the given loop. */ BooleanEvent Create(EventLoop* loop) const; /** - * Read the value of the Options button on the controller. + * Read the value of the options button on the controller. * * @return The state of the button. */ bool GetOptionsButton() const; /** - * Whether the Options button was pressed since the last check. + * Whether the options button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetOptionsButtonPressed(); /** - * Whether the Options button was released since the last check. + * Whether the options button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetOptionsButtonReleased(); /** - * Constructs an event instance around the options button's digital signal. + * Constructs an event instance around the options button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the options button's digital signal - * attached to the given loop. + * @return an event instance representing the options button's + * digital signal attached to the given loop. */ BooleanEvent Options(EventLoop* loop) const; /** - * Read the value of the L3 button (pressing the left analog stick) on the - * controller. + * Read the value of the L3 (left stick) button on the controller. * * @return The state of the button. */ @@ -404,17 +415,17 @@ class PS5Controller : public GenericHID { bool GetL3ButtonReleased(); /** - * Constructs an event instance around the L3 button's digital signal. + * Constructs an event instance around the L3 (left stick) button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the L3 button's digital signal - * attached to the given loop. + * @return an event instance representing the L3 (left stick) button's + * digital signal attached to the given loop. */ BooleanEvent L3(EventLoop* loop) const; /** - * Read the value of the R3 button (pressing the right analog stick) on the - * controller. + * Read the value of the R3 (right stick) button on the controller. * * @return The state of the button. */ @@ -435,41 +446,43 @@ class PS5Controller : public GenericHID { bool GetR3ButtonReleased(); /** - * Constructs an event instance around the R3 button's digital signal. + * Constructs an event instance around the R3 (right stick) button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the R3 button's digital signal - * attached to the given loop. + * @return an event instance representing the R3 (right stick) button's + * digital signal attached to the given loop. */ BooleanEvent R3(EventLoop* loop) const; /** - * Read the value of the PS button on the controller. + * Read the value of the PlayStation button on the controller. * * @return The state of the button. */ bool GetPSButton() const; /** - * Whether the PS button was pressed since the last check. + * Whether the PlayStation button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ bool GetPSButtonPressed(); /** - * Whether the PS button was released since the last check. + * Whether the PlayStation button was released since the last check. * * @return Whether the button was released since the last check. */ bool GetPSButtonReleased(); /** - * Constructs an event instance around the PS button's digital signal. + * Constructs an event instance around the PlayStation button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the PS button's digital signal - * attached to the given loop. + * @return an event instance representing the PlayStation button's + * digital signal attached to the given loop. */ BooleanEvent PS(EventLoop* loop) const; @@ -478,38 +491,62 @@ class PS5Controller : public GenericHID { * * @return The state of the button. */ - bool GetTouchpad() const; + bool GetTouchpadButton() const; /** - * Whether the touchpad was pressed since the last check. + * Whether the touchpad button was pressed since the last check. * - * @return Whether the touchpad was pressed since the last check. + * @return Whether the button was pressed since the last check. */ - bool GetTouchpadPressed(); + bool GetTouchpadButtonPressed(); /** - * Whether the touchpad was released since the last check. + * Whether the touchpad button was released since the last check. * - * @return Whether the touchpad was released since the last check. + * @return Whether the button was released since the last check. */ - bool GetTouchpadReleased(); + bool GetTouchpadButtonReleased(); /** - * Constructs an event instance around the touchpad's digital signal. + * Constructs an event instance around the touchpad button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the touchpad's digital signal - * attached to the given loop. + * @return an event instance representing the touchpad button's + * digital signal attached to the given loop. */ BooleanEvent Touchpad(EventLoop* loop) const; + + /** - * Represents a digital button on a PS5Controller. + * Read the value of the touchpad button on the controller. + * + * @return The state of the button. + */ + [[deprecated("Use GetTouchpadButton instead")]] + bool GetTouchpad() const; + /** + * Whether the touchpad was pressed since the last check. + * + * @return Whether the touchpad was pressed since the last check. + */ + [[deprecated("Use GetTouchpadButtonPressed instead")]] + bool GetTouchpadPressed(); + + /** + * Whether the touchpad was released since the last check. + * + * @return Whether the touchpad was released since the last check. */ + [[deprecated("Use GetTouchpadButtonReleased instead")]] + bool GetTouchpadReleased(); + + /** Represents a digital button on an PS5Controller. */ struct Button { /// Square button. static constexpr int kSquare = 1; - /// X button. + /// Cross button. static constexpr int kCross = 2; /// Circle button. static constexpr int kCircle = 3; @@ -527,19 +564,17 @@ class PS5Controller : public GenericHID { static constexpr int kCreate = 9; /// Options button. static constexpr int kOptions = 10; - /// Left stick button. + /// L3 (left stick) button. static constexpr int kL3 = 11; - /// Right stick button. + /// R3 (right stick) button. static constexpr int kR3 = 12; - /// PlayStation button. + /// Playstation button. static constexpr int kPS = 13; - /// Touchpad click button. + /// Touchpad button. static constexpr int kTouchpad = 14; }; - /** - * Represents an axis on a PS5Controller. - */ + /** Represents an axis on an PS5Controller. */ struct Axis { /// Left X axis. static constexpr int kLeftX = 0; @@ -549,9 +584,9 @@ class PS5Controller : public GenericHID { static constexpr int kRightX = 2; /// Right Y axis. static constexpr int kRightY = 5; - /// Left Trigger 2. + /// Left trigger 2. static constexpr int kL2 = 3; - /// Right Trigger 2. + /// Right trigger 2. static constexpr int kR2 = 4; }; }; diff --git a/wpilibc/src/main/native/include/frc/StadiaController.h b/wpilibc/src/generated/main/native/include/frc/StadiaController.h similarity index 69% rename from wpilibc/src/main/native/include/frc/StadiaController.h rename to wpilibc/src/generated/main/native/include/frc/StadiaController.h index cc9dbae981c..617be798f7a 100644 --- a/wpilibc/src/main/native/include/frc/StadiaController.h +++ b/wpilibc/src/generated/main/native/include/frc/StadiaController.h @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + #pragma once #include "frc/GenericHID.h" @@ -9,18 +11,21 @@ namespace frc { /** - * Handle input from Stadia controllers connected to the Driver - * Station. + * Handle input from Stadia controllers connected to the Driver Station. + * + * This class handles Stadia input that comes from the Driver Station. Each + * time a value is requested the most recent value is returned. There is a + * single class instance for each controller and the mapping of ports to + * hardware buttons depends on the code in the Driver Station. * - * This class handles Stadia input that comes from the Driver Station. Each time - * a value is requested the most recent value is returned. There is a single - * class instance for each controller and the mapping of ports to hardware - * buttons depends on the code in the Driver Station. + * Only first party controllers from Google are guaranteed to have the + * correct mapping, and only through the official NI DS. Sim is not guaranteed + * to have the same mapping, as well as any 3rd party controllers. */ class StadiaController : public GenericHID { public: /** - * Construct an instance of a Stadia controller. + * Construct an instance of a controller. * * The controller index is the USB port on the Driver Station. * @@ -37,270 +42,278 @@ class StadiaController : public GenericHID { /** * Get the X axis value of left side of the controller. * - * @return the axis value + * @return the axis value. */ double GetLeftX() const; /** * Get the X axis value of right side of the controller. * - * @return the axis value + * @return the axis value. */ double GetRightX() const; /** * Get the Y axis value of left side of the controller. * - * @return the axis value + * @return the axis value. */ double GetLeftY() const; /** * Get the Y axis value of right side of the controller. * - * @return the axis value + * @return the axis value. */ double GetRightY() const; /** - * Read the value of the left bumper (LB) button on the controller. + * Read the value of the A button on the controller. * - * @return the state of the button + * @return The state of the button. */ - bool GetLeftBumper() const; + bool GetAButton() const; /** - * Read the value of the right bumper (RB) button on the controller. + * Whether the A button was pressed since the last check. * - * @return the state of the button + * @return Whether the button was pressed since the last check. */ - bool GetRightBumper() const; + bool GetAButtonPressed(); /** - * Whether the left bumper (LB) was pressed since the last check. + * Whether the A button was released since the last check. * - * @return Whether the button was pressed since the last check + * @return Whether the button was released since the last check. */ - bool GetLeftBumperPressed(); + bool GetAButtonReleased(); /** - * Whether the right bumper (RB) was pressed since the last check. + * Constructs an event instance around the A button's + * digital signal. * - * @return Whether the button was pressed since the last check + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's + * digital signal attached to the given loop. */ - bool GetRightBumperPressed(); + BooleanEvent A(EventLoop* loop) const; /** - * Whether the left bumper (LB) was released since the last check. + * Read the value of the B button on the controller. * - * @return Whether the button was released since the last check. + * @return The state of the button. */ - bool GetLeftBumperReleased(); + bool GetBButton() const; /** - * Whether the right bumper (RB) was released since the last check. + * Whether the B button was pressed since the last check. * - * @return Whether the button was released since the last check. + * @return Whether the button was pressed since the last check. */ - bool GetRightBumperReleased(); + bool GetBButtonPressed(); /** - * Constructs an event instance around the left bumper's digital signal. + * Whether the B button was released since the last check. * - * @param loop the event loop instance to attach the event to. - * @return an event instance representing the left bumper's digital signal - * attached to the given loop. + * @return Whether the button was released since the last check. */ - BooleanEvent LeftBumper(EventLoop* loop) const; + bool GetBButtonReleased(); /** - * Constructs an event instance around the right bumper's digital signal. + * Constructs an event instance around the B button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the right bumper's digital signal - * attached to the given loop. + * @return an event instance representing the B button's + * digital signal attached to the given loop. */ - BooleanEvent RightBumper(EventLoop* loop) const; + BooleanEvent B(EventLoop* loop) const; /** - * Read the value of the left stick button (LSB) on the controller. + * Read the value of the X button on the controller. * - * @return the state of the button + * @return The state of the button. */ - bool GetLeftStickButton() const; + bool GetXButton() const; /** - * Read the value of the right stick button (RSB) on the controller. + * Whether the X button was pressed since the last check. * - * @return the state of the button + * @return Whether the button was pressed since the last check. */ - bool GetRightStickButton() const; + bool GetXButtonPressed(); /** - * Whether the left stick button (LSB) was pressed since the last check. + * Whether the X button was released since the last check. * - * @return Whether the button was pressed since the last check. + * @return Whether the button was released since the last check. */ - bool GetLeftStickButtonPressed(); + bool GetXButtonReleased(); /** - * Whether the right stick button (RSB) was pressed since the last check. + * Constructs an event instance around the X button's + * digital signal. * - * @return Whether the button was pressed since the last check + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the X button's + * digital signal attached to the given loop. */ - bool GetRightStickButtonPressed(); + BooleanEvent X(EventLoop* loop) const; /** - * Whether the left stick button (LSB) was released since the last check. + * Read the value of the Y button on the controller. * - * @return Whether the button was released since the last check. + * @return The state of the button. */ - bool GetLeftStickButtonReleased(); + bool GetYButton() const; /** - * Whether the right stick button (RSB) was released since the last check. + * Whether the Y button was pressed since the last check. * - * @return Whether the button was released since the last check. + * @return Whether the button was pressed since the last check. */ - bool GetRightStickButtonReleased(); + bool GetYButtonPressed(); /** - * Constructs an event instance around the left stick's digital signal. + * Whether the Y button was released since the last check. * - * @param loop the event loop instance to attach the event to. - * @return an event instance representing the left stick's digital signal - * attached to the given loop. + * @return Whether the button was released since the last check. */ - BooleanEvent LeftStick(EventLoop* loop) const; + bool GetYButtonReleased(); /** - * Constructs an event instance around the right stick's digital signal. + * Constructs an event instance around the Y button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the right stick's digital signal - * attached to the given loop. + * @return an event instance representing the Y button's + * digital signal attached to the given loop. */ - BooleanEvent RightStick(EventLoop* loop) const; + BooleanEvent Y(EventLoop* loop) const; /** - * Read the value of the A button on the controller. + * Read the value of the left bumper button on the controller. * * @return The state of the button. */ - bool GetAButton() const; + bool GetLeftBumperButton() const; /** - * Whether the A button was pressed since the last check. + * Whether the left bumper button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ - bool GetAButtonPressed(); + bool GetLeftBumperButtonPressed(); /** - * Whether the A button was released since the last check. + * Whether the left bumper button was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetAButtonReleased(); + bool GetLeftBumperButtonReleased(); /** - * Constructs an event instance around the A button's digital signal. + * Constructs an event instance around the left bumper button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the A button's digital signal - * attached to the given loop. + * @return an event instance representing the left bumper button's + * digital signal attached to the given loop. */ - BooleanEvent A(EventLoop* loop) const; + BooleanEvent LeftBumper(EventLoop* loop) const; /** - * Read the value of the B button on the controller. + * Read the value of the right bumper button on the controller. * * @return The state of the button. */ - bool GetBButton() const; + bool GetRightBumperButton() const; /** - * Whether the B button was pressed since the last check. + * Whether the right bumper button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ - bool GetBButtonPressed(); + bool GetRightBumperButtonPressed(); /** - * Whether the B button was released since the last check. + * Whether the right bumper button was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetBButtonReleased(); + bool GetRightBumperButtonReleased(); /** - * Constructs an event instance around the B button's digital signal. + * Constructs an event instance around the right bumper button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the B button's digital signal - * attached to the given loop. + * @return an event instance representing the right bumper button's + * digital signal attached to the given loop. */ - BooleanEvent B(EventLoop* loop) const; + BooleanEvent RightBumper(EventLoop* loop) const; /** - * Read the value of the X button on the controller. + * Read the value of the left stick button on the controller. * * @return The state of the button. */ - bool GetXButton() const; + bool GetLeftStickButton() const; /** - * Whether the X button was pressed since the last check. + * Whether the left stick button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ - bool GetXButtonPressed(); + bool GetLeftStickButtonPressed(); /** - * Whether the X button was released since the last check. + * Whether the left stick button was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetXButtonReleased(); + bool GetLeftStickButtonReleased(); /** - * Constructs an event instance around the X button's digital signal. + * Constructs an event instance around the left stick button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the X button's digital signal - * attached to the given loop. + * @return an event instance representing the left stick button's + * digital signal attached to the given loop. */ - BooleanEvent X(EventLoop* loop) const; + BooleanEvent LeftStick(EventLoop* loop) const; /** - * Read the value of the Y button on the controller. + * Read the value of the right stick button on the controller. * * @return The state of the button. */ - bool GetYButton() const; + bool GetRightStickButton() const; /** - * Whether the Y button was pressed since the last check. + * Whether the right stick button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ - bool GetYButtonPressed(); + bool GetRightStickButtonPressed(); /** - * Whether the Y button was released since the last check. + * Whether the right stick button was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetYButtonReleased(); + bool GetRightStickButtonReleased(); /** - * Constructs an event instance around the Y button's digital signal. + * Constructs an event instance around the right stick button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the Y button's digital signal - * attached to the given loop. + * @return an event instance representing the right stick button's + * digital signal attached to the given loop. */ - BooleanEvent Y(EventLoop* loop) const; + BooleanEvent RightStick(EventLoop* loop) const; /** * Read the value of the ellipses button on the controller. @@ -324,11 +337,12 @@ class StadiaController : public GenericHID { bool GetEllipsesButtonReleased(); /** - * Constructs an event instance around the ellipses button's digital signal. + * Constructs an event instance around the ellipses button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the ellipses button's digital signal - * attached to the given loop. + * @return an event instance representing the ellipses button's + * digital signal attached to the given loop. */ BooleanEvent Ellipses(EventLoop* loop) const; @@ -354,11 +368,12 @@ class StadiaController : public GenericHID { bool GetHamburgerButtonReleased(); /** - * Constructs an event instance around the hamburger button's digital signal. + * Constructs an event instance around the hamburger button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the hamburger button's digital - * signal attached to the given loop. + * @return an event instance representing the hamburger button's + * digital signal attached to the given loop. */ BooleanEvent Hamburger(EventLoop* loop) const; @@ -384,139 +399,189 @@ class StadiaController : public GenericHID { bool GetStadiaButtonReleased(); /** - * Constructs an event instance around the stadia button's digital signal. + * Constructs an event instance around the stadia button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the stadia button's digital signal - * attached to the given loop. + * @return an event instance representing the stadia button's + * digital signal attached to the given loop. */ BooleanEvent Stadia(EventLoop* loop) const; /** - * Read the value of the google button on the controller. + * Read the value of the right trigger button on the controller. * * @return The state of the button. */ - bool GetGoogleButton() const; + bool GetRightTriggerButton() const; /** - * Whether the google button was pressed since the last check. + * Whether the right trigger button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ - bool GetGoogleButtonPressed(); + bool GetRightTriggerButtonPressed(); /** - * Whether the google button was released since the last check. + * Whether the right trigger button was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetGoogleButtonReleased(); + bool GetRightTriggerButtonReleased(); /** - * Constructs an event instance around the google button's digital signal. + * Constructs an event instance around the right trigger button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the google button's digital signal - * attached to the given loop. + * @return an event instance representing the right trigger button's + * digital signal attached to the given loop. */ - BooleanEvent Google(EventLoop* loop) const; + BooleanEvent RightTrigger(EventLoop* loop) const; /** - * Read the value of the frame button on the controller. + * Read the value of the left trigger button on the controller. * * @return The state of the button. */ - bool GetFrameButton() const; + bool GetLeftTriggerButton() const; /** - * Whether the frame button was pressed since the last check. + * Whether the left trigger button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ - bool GetFrameButtonPressed(); + bool GetLeftTriggerButtonPressed(); /** - * Whether the frame button was released since the last check. + * Whether the left trigger button was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetFrameButtonReleased(); + bool GetLeftTriggerButtonReleased(); /** - * Constructs an event instance around the frame button's digital signal. + * Constructs an event instance around the left trigger button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the frame button's digital signal - * attached to the given loop. + * @return an event instance representing the left trigger button's + * digital signal attached to the given loop. */ - BooleanEvent Frame(EventLoop* loop) const; + BooleanEvent LeftTrigger(EventLoop* loop) const; /** - * Read the value of the left trigger button on the controller. + * Read the value of the google button on the controller. * * @return The state of the button. */ - bool GetLeftTriggerButton() const; + bool GetGoogleButton() const; /** - * Whether the left trigger button was pressed since the last check. + * Whether the google button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ - bool GetLeftTriggerButtonPressed(); + bool GetGoogleButtonPressed(); /** - * Whether the left trigger button was released since the last check. + * Whether the google button was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetLeftTriggerButtonReleased(); + bool GetGoogleButtonReleased(); /** - * Constructs an event instance around the left trigger button's digital - * signal. + * Constructs an event instance around the google button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the left trigger button's digital - * signal attached to the given loop. + * @return an event instance representing the google button's + * digital signal attached to the given loop. */ - BooleanEvent LeftTrigger(EventLoop* loop) const; + BooleanEvent Google(EventLoop* loop) const; /** - * Read the value of the right trigger button on the controller. + * Read the value of the frame button on the controller. * * @return The state of the button. */ - bool GetRightTriggerButton() const; + bool GetFrameButton() const; /** - * Whether the right trigger button was pressed since the last check. + * Whether the frame button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ - bool GetRightTriggerButtonPressed(); + bool GetFrameButtonPressed(); /** - * Whether the right trigger button was released since the last check. + * Whether the frame button was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetRightTriggerButtonReleased(); + bool GetFrameButtonReleased(); /** - * Constructs an event instance around the right trigger button's digital - * signal. + * Constructs an event instance around the frame button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the right trigger button's digital - * signal attached to the given loop. + * @return an event instance representing the frame button's + * digital signal attached to the given loop. */ - BooleanEvent RightTrigger(EventLoop* loop) const; + BooleanEvent Frame(EventLoop* loop) const; + + + /** + * Read the value of the left bumper (LB) button on the controller. + * + * @return the state of the button + */ + [[deprecated("Use GetLeftBumper instead")]] + bool GetLeftBumper() const; + + /** + * Read the value of the right bumper (RB) button on the controller. + * + * @return the state of the button + */ + [[deprecated("Use GetRightBumper instead")]] + bool GetRightBumper() const; + + /** + * Whether the left bumper (LB) was pressed since the last check. + * + * @return Whether the button was pressed since the last check + */ + [[deprecated("Use GetLeftBumperPressed instead")]] + bool GetLeftBumperPressed(); /** - * Represents a digital button on a StadiaController. + * Whether the right bumper (RB) was pressed since the last check. + * + * @return Whether the button was pressed since the last check */ + [[deprecated("Use GetRightBumperPressed instead")]] + bool GetRightBumperPressed(); + + /** + * Whether the left bumper (LB) was released since the last check. + * + * @return Whether the button was released since the last check. + */ + [[deprecated("Use GetLeftBumperReleased instead")]] + bool GetLeftBumperReleased(); + + /** + * Whether the right bumper (RB) was released since the last check. + * + * @return Whether the button was released since the last check. + */ + [[deprecated("Use GetRightBumperReleased instead")]] + bool GetRightBumperReleased(); + + /** Represents a digital button on an StadiaController. */ struct Button { /// A button. static constexpr int kA = 1; @@ -550,18 +615,16 @@ class StadiaController : public GenericHID { static constexpr int kFrame = 15; }; - /** - * Represents an axis on a StadiaController. - */ + /** Represents an axis on an StadiaController. */ struct Axis { /// Left X axis. static constexpr int kLeftX = 0; /// Right X axis. - static constexpr int kRightX = 4; + static constexpr int kRightX = 3; /// Left Y axis. static constexpr int kLeftY = 1; /// Right Y axis. - static constexpr int kRightY = 5; + static constexpr int kRightY = 4; }; }; diff --git a/wpilibc/src/main/native/include/frc/XboxController.h b/wpilibc/src/generated/main/native/include/frc/XboxController.h similarity index 66% rename from wpilibc/src/main/native/include/frc/XboxController.h rename to wpilibc/src/generated/main/native/include/frc/XboxController.h index 4b720c1fc72..9e85ca47499 100644 --- a/wpilibc/src/main/native/include/frc/XboxController.h +++ b/wpilibc/src/generated/main/native/include/frc/XboxController.h @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + #pragma once #include "frc/GenericHID.h" @@ -9,13 +11,12 @@ namespace frc { /** - * Handle input from Xbox 360 or Xbox One controllers connected to the Driver - * Station. + * Handle input from Xbox controllers connected to the Driver Station. * - * This class handles Xbox input that comes from the Driver Station. Each time a - * value is requested the most recent value is returned. There is a single class - * instance for each controller and the mapping of ports to hardware buttons - * depends on the code in the Driver Station. + * This class handles Xbox input that comes from the Driver Station. Each + * time a value is requested the most recent value is returned. There is a + * single class instance for each controller and the mapping of ports to + * hardware buttons depends on the code in the Driver Station. * * Only first party controllers from Microsoft are guaranteed to have the * correct mapping, and only through the official NI DS. Sim is not guaranteed @@ -24,7 +25,7 @@ namespace frc { class XboxController : public GenericHID { public: /** - * Construct an instance of an Xbox controller. + * Construct an instance of a controller. * * The controller index is the USB port on the Driver Station. * @@ -41,424 +42,483 @@ class XboxController : public GenericHID { /** * Get the X axis value of left side of the controller. * - * @return the axis value + * @return the axis value. */ double GetLeftX() const; /** * Get the X axis value of right side of the controller. * - * @return the axis value + * @return the axis value. */ double GetRightX() const; /** * Get the Y axis value of left side of the controller. * - * @return the axis value + * @return the axis value. */ double GetLeftY() const; /** * Get the Y axis value of right side of the controller. * - * @return the axis value + * @return the axis value. */ double GetRightY() const; /** - * Get the left trigger (LT) axis value of the controller. Note that this axis + * Get the left trigger axis value of the controller. Note that this axis * is bound to the range of [0, 1] as opposed to the usual [-1, 1]. * - * @return the axis value + * @return the axis value. */ double GetLeftTriggerAxis() const; /** - * Get the right trigger (RT) axis value of the controller. Note that this - * axis is bound to the range of [0, 1] as opposed to the usual [-1, 1]. + * Constructs an event instance around the axis value of the left trigger. + * The returned trigger will be true when the axis value is greater than + * {@code threshold}. + * @param threshold the minimum axis value for the returned event to be true. + * This value should be in the range [0, 1] where 0 is the unpressed state of + * the axis. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the left trigger's axis + * exceeds the provided threshold, attached to the given event loop + */ + BooleanEvent LeftTrigger(double threshold, EventLoop* loop) const; + + /** + * Constructs an event instance around the axis value of the left trigger. + * The returned trigger will be true when the axis value is greater than 0.5. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the left trigger's axis + * exceeds 0.5, attached to the given event loop + */ + BooleanEvent LeftTrigger(EventLoop* loop) const; + + /** + * Get the right trigger axis value of the controller. Note that this axis + * is bound to the range of [0, 1] as opposed to the usual [-1, 1]. * - * @return the axis value + * @return the axis value. */ double GetRightTriggerAxis() const; /** - * Read the value of the left bumper (LB) button on the controller. + * Constructs an event instance around the axis value of the right trigger. + * The returned trigger will be true when the axis value is greater than + * {@code threshold}. + * @param threshold the minimum axis value for the returned event to be true. + * This value should be in the range [0, 1] where 0 is the unpressed state of + * the axis. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the right trigger's axis + * exceeds the provided threshold, attached to the given event loop + */ + BooleanEvent RightTrigger(double threshold, EventLoop* loop) const; + + /** + * Constructs an event instance around the axis value of the right trigger. + * The returned trigger will be true when the axis value is greater than 0.5. + * @param loop the event loop instance to attach the event to. + * @return an event instance that is true when the right trigger's axis + * exceeds 0.5, attached to the given event loop + */ + BooleanEvent RightTrigger(EventLoop* loop) const; + + /** + * Read the value of the A button on the controller. * - * @return the state of the button + * @return The state of the button. */ - bool GetLeftBumper() const; + bool GetAButton() const; /** - * Read the value of the right bumper (RB) button on the controller. + * Whether the A button was pressed since the last check. * - * @return the state of the button + * @return Whether the button was pressed since the last check. */ - bool GetRightBumper() const; + bool GetAButtonPressed(); /** - * Whether the left bumper (LB) was pressed since the last check. + * Whether the A button was released since the last check. * - * @return Whether the button was pressed since the last check + * @return Whether the button was released since the last check. */ - bool GetLeftBumperPressed(); + bool GetAButtonReleased(); /** - * Whether the right bumper (RB) was pressed since the last check. + * Constructs an event instance around the A button's + * digital signal. * - * @return Whether the button was pressed since the last check + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the A button's + * digital signal attached to the given loop. */ - bool GetRightBumperPressed(); + BooleanEvent A(EventLoop* loop) const; /** - * Whether the left bumper (LB) was released since the last check. + * Read the value of the B button on the controller. * - * @return Whether the button was released since the last check. + * @return The state of the button. */ - bool GetLeftBumperReleased(); + bool GetBButton() const; /** - * Whether the right bumper (RB) was released since the last check. + * Whether the B button was pressed since the last check. * - * @return Whether the button was released since the last check. + * @return Whether the button was pressed since the last check. */ - bool GetRightBumperReleased(); + bool GetBButtonPressed(); /** - * Constructs an event instance around the left bumper's digital signal. + * Whether the B button was released since the last check. * - * @param loop the event loop instance to attach the event to. - * @return an event instance representing the left bumper's digital signal - * attached to the given loop. + * @return Whether the button was released since the last check. */ - BooleanEvent LeftBumper(EventLoop* loop) const; + bool GetBButtonReleased(); /** - * Constructs an event instance around the right bumper's digital signal. + * Constructs an event instance around the B button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the right bumper's digital signal - * attached to the given loop. + * @return an event instance representing the B button's + * digital signal attached to the given loop. */ - BooleanEvent RightBumper(EventLoop* loop) const; + BooleanEvent B(EventLoop* loop) const; /** - * Read the value of the left stick button (LSB) on the controller. + * Read the value of the X button on the controller. * - * @return the state of the button + * @return The state of the button. */ - bool GetLeftStickButton() const; + bool GetXButton() const; /** - * Read the value of the right stick button (RSB) on the controller. + * Whether the X button was pressed since the last check. * - * @return the state of the button + * @return Whether the button was pressed since the last check. */ - bool GetRightStickButton() const; + bool GetXButtonPressed(); /** - * Whether the left stick button (LSB) was pressed since the last check. + * Whether the X button was released since the last check. * - * @return Whether the button was pressed since the last check. + * @return Whether the button was released since the last check. */ - bool GetLeftStickButtonPressed(); + bool GetXButtonReleased(); /** - * Whether the right stick button (RSB) was pressed since the last check. + * Constructs an event instance around the X button's + * digital signal. * - * @return Whether the button was pressed since the last check + * @param loop the event loop instance to attach the event to. + * @return an event instance representing the X button's + * digital signal attached to the given loop. */ - bool GetRightStickButtonPressed(); + BooleanEvent X(EventLoop* loop) const; /** - * Whether the left stick button (LSB) was released since the last check. + * Read the value of the Y button on the controller. * - * @return Whether the button was released since the last check. + * @return The state of the button. */ - bool GetLeftStickButtonReleased(); + bool GetYButton() const; /** - * Whether the right stick button (RSB) was released since the last check. + * Whether the Y button was pressed since the last check. * - * @return Whether the button was released since the last check. + * @return Whether the button was pressed since the last check. */ - bool GetRightStickButtonReleased(); + bool GetYButtonPressed(); /** - * Constructs an event instance around the left stick's digital signal. + * Whether the Y button was released since the last check. * - * @param loop the event loop instance to attach the event to. - * @return an event instance representing the left stick's digital signal - * attached to the given loop. + * @return Whether the button was released since the last check. */ - BooleanEvent LeftStick(EventLoop* loop) const; + bool GetYButtonReleased(); /** - * Constructs an event instance around the right stick's digital signal. + * Constructs an event instance around the Y button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the right stick's digital signal - * attached to the given loop. + * @return an event instance representing the Y button's + * digital signal attached to the given loop. */ - BooleanEvent RightStick(EventLoop* loop) const; + BooleanEvent Y(EventLoop* loop) const; /** - * Read the value of the A button on the controller. + * Read the value of the left bumper button on the controller. * * @return The state of the button. */ - bool GetAButton() const; + bool GetLeftBumperButton() const; /** - * Whether the A button was pressed since the last check. + * Whether the left bumper button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ - bool GetAButtonPressed(); + bool GetLeftBumperButtonPressed(); /** - * Whether the A button was released since the last check. + * Whether the left bumper button was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetAButtonReleased(); + bool GetLeftBumperButtonReleased(); /** - * Constructs an event instance around the A button's digital signal. + * Constructs an event instance around the left bumper button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the A button's digital signal - * attached to the given loop. + * @return an event instance representing the left bumper button's + * digital signal attached to the given loop. */ - BooleanEvent A(EventLoop* loop) const; + BooleanEvent LeftBumper(EventLoop* loop) const; /** - * Read the value of the B button on the controller. + * Read the value of the right bumper button on the controller. * * @return The state of the button. */ - bool GetBButton() const; + bool GetRightBumperButton() const; /** - * Whether the B button was pressed since the last check. + * Whether the right bumper button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ - bool GetBButtonPressed(); + bool GetRightBumperButtonPressed(); /** - * Whether the B button was released since the last check. + * Whether the right bumper button was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetBButtonReleased(); + bool GetRightBumperButtonReleased(); /** - * Constructs an event instance around the B button's digital signal. + * Constructs an event instance around the right bumper button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the B button's digital signal - * attached to the given loop. + * @return an event instance representing the right bumper button's + * digital signal attached to the given loop. */ - BooleanEvent B(EventLoop* loop) const; + BooleanEvent RightBumper(EventLoop* loop) const; /** - * Read the value of the X button on the controller. + * Read the value of the back button on the controller. * * @return The state of the button. */ - bool GetXButton() const; + bool GetBackButton() const; /** - * Whether the X button was pressed since the last check. + * Whether the back button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ - bool GetXButtonPressed(); + bool GetBackButtonPressed(); /** - * Whether the X button was released since the last check. + * Whether the back button was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetXButtonReleased(); + bool GetBackButtonReleased(); /** - * Constructs an event instance around the X button's digital signal. + * Constructs an event instance around the back button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the X button's digital signal - * attached to the given loop. + * @return an event instance representing the back button's + * digital signal attached to the given loop. */ - BooleanEvent X(EventLoop* loop) const; + BooleanEvent Back(EventLoop* loop) const; /** - * Read the value of the Y button on the controller. + * Read the value of the start button on the controller. * * @return The state of the button. */ - bool GetYButton() const; + bool GetStartButton() const; /** - * Whether the Y button was pressed since the last check. + * Whether the start button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ - bool GetYButtonPressed(); + bool GetStartButtonPressed(); /** - * Whether the Y button was released since the last check. + * Whether the start button was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetYButtonReleased(); + bool GetStartButtonReleased(); /** - * Constructs an event instance around the Y button's digital signal. + * Constructs an event instance around the start button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the Y button's digital signal - * attached to the given loop. + * @return an event instance representing the start button's + * digital signal attached to the given loop. */ - BooleanEvent Y(EventLoop* loop) const; + BooleanEvent Start(EventLoop* loop) const; /** - * Read the value of the back button on the controller. + * Read the value of the left stick button on the controller. * * @return The state of the button. */ - bool GetBackButton() const; + bool GetLeftStickButton() const; /** - * Whether the back button was pressed since the last check. + * Whether the left stick button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ - bool GetBackButtonPressed(); + bool GetLeftStickButtonPressed(); /** - * Whether the back button was released since the last check. + * Whether the left stick button was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetBackButtonReleased(); + bool GetLeftStickButtonReleased(); /** - * Constructs an event instance around the back button's digital signal. + * Constructs an event instance around the left stick button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the back button's digital signal - * attached to the given loop. + * @return an event instance representing the left stick button's + * digital signal attached to the given loop. */ - BooleanEvent Back(EventLoop* loop) const; + BooleanEvent LeftStick(EventLoop* loop) const; /** - * Read the value of the start button on the controller. + * Read the value of the right stick button on the controller. * * @return The state of the button. */ - bool GetStartButton() const; + bool GetRightStickButton() const; /** - * Whether the start button was pressed since the last check. + * Whether the right stick button was pressed since the last check. * * @return Whether the button was pressed since the last check. */ - bool GetStartButtonPressed(); + bool GetRightStickButtonPressed(); /** - * Whether the start button was released since the last check. + * Whether the right stick button was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetStartButtonReleased(); + bool GetRightStickButtonReleased(); /** - * Constructs an event instance around the start button's digital signal. + * Constructs an event instance around the right stick button's + * digital signal. * * @param loop the event loop instance to attach the event to. - * @return an event instance representing the start button's digital signal - * attached to the given loop. + * @return an event instance representing the right stick button's + * digital signal attached to the given loop. */ - BooleanEvent Start(EventLoop* loop) const; + BooleanEvent RightStick(EventLoop* loop) const; + /** - * Constructs an event instance around the axis value of the left trigger. The - * returned trigger will be true when the axis value is greater than {@code - * threshold}. - * @param threshold the minimum axis value for the returned event to be true. - * This value should be in the range [0, 1] where 0 is the unpressed state of - * the axis. - * @param loop the event loop instance to attach the event to. - * @return an event instance that is true when the left trigger's axis exceeds - * the provided threshold, attached to the given event loop + * Read the value of the left bumper (LB) button on the controller. + * + * @return the state of the button */ - BooleanEvent LeftTrigger(double threshold, EventLoop* loop) const; + [[deprecated("Use GetLeftBumper instead")]] + bool GetLeftBumper() const; /** - * Constructs an event instance around the axis value of the left trigger. - * The returned trigger will be true when the axis value is greater than 0.5. - * @param loop the event loop instance to attach the event to. - * @return an event instance that is true when the left trigger's axis - * exceeds 0.5, attached to the given event loop + * Read the value of the right bumper (RB) button on the controller. + * + * @return the state of the button */ - BooleanEvent LeftTrigger(EventLoop* loop) const; + [[deprecated("Use GetRightBumper instead")]] + bool GetRightBumper() const; /** - * Constructs an event instance around the axis value of the right trigger. - * The returned trigger will be true when the axis value is greater than - * {@code threshold}. - * @param threshold the minimum axis value for the returned event to be true. - * This value should be in the range [0, 1] where 0 is the unpressed state of - * the axis. - * @param loop the event loop instance to attach the event to. - * @return an event instance that is true when the right trigger's axis - * exceeds the provided threshold, attached to the given event loop + * Whether the left bumper (LB) was pressed since the last check. + * + * @return Whether the button was pressed since the last check */ - BooleanEvent RightTrigger(double threshold, EventLoop* loop) const; + [[deprecated("Use GetLeftBumperPressed instead")]] + bool GetLeftBumperPressed(); /** - * Constructs an event instance around the axis value of the right trigger. - * The returned trigger will be true when the axis value is greater than 0.5. - * @param loop the event loop instance to attach the event to. - * @return an event instance that is true when the right trigger's axis - * exceeds 0.5, attached to the given event loop + * Whether the right bumper (RB) was pressed since the last check. + * + * @return Whether the button was pressed since the last check */ - BooleanEvent RightTrigger(EventLoop* loop) const; + [[deprecated("Use GetRightBumperPressed instead")]] + bool GetRightBumperPressed(); + + /** + * Whether the left bumper (LB) was released since the last check. + * + * @return Whether the button was released since the last check. + */ + [[deprecated("Use GetLeftBumperReleased instead")]] + bool GetLeftBumperReleased(); + + /** + * Whether the right bumper (RB) was released since the last check. + * + * @return Whether the button was released since the last check. + */ + [[deprecated("Use GetRightBumperReleased instead")]] + bool GetRightBumperReleased(); /** Represents a digital button on an XboxController. */ struct Button { - /// Left bumper. - static constexpr int kLeftBumper = 5; - /// Right bumper. - static constexpr int kRightBumper = 6; - /// Left stick. - static constexpr int kLeftStick = 9; - /// Right stick. - static constexpr int kRightStick = 10; - /// A. + /// A button. static constexpr int kA = 1; - /// B. + /// B button. static constexpr int kB = 2; - /// X. + /// X button. static constexpr int kX = 3; - /// Y. + /// Y button. static constexpr int kY = 4; - /// Back. + /// Left bumper button. + static constexpr int kLeftBumper = 5; + /// Right bumper button. + static constexpr int kRightBumper = 6; + /// Back button. static constexpr int kBack = 7; - /// Start. + /// Start button. static constexpr int kStart = 8; + /// Left stick button. + static constexpr int kLeftStick = 9; + /// Right stick button. + static constexpr int kRightStick = 10; }; /** Represents an axis on an XboxController. */ struct Axis { - /// Left X. + /// Left X axis. static constexpr int kLeftX = 0; - /// Right X. + /// Right X axis. static constexpr int kRightX = 4; - /// Left Y. + /// Left Y axis. static constexpr int kLeftY = 1; - /// Right Y. + /// Right Y axis. static constexpr int kRightY = 5; /// Left trigger. static constexpr int kLeftTrigger = 2; diff --git a/wpilibc/src/main/native/include/frc/simulation/PS4ControllerSim.h b/wpilibc/src/generated/main/native/include/frc/simulation/PS4ControllerSim.h similarity index 65% rename from wpilibc/src/main/native/include/frc/simulation/PS4ControllerSim.h rename to wpilibc/src/generated/main/native/include/frc/simulation/PS4ControllerSim.h index a599ad98d63..79dd5ecec73 100644 --- a/wpilibc/src/main/native/include/frc/simulation/PS4ControllerSim.h +++ b/wpilibc/src/generated/main/native/include/frc/simulation/PS4ControllerSim.h @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + #pragma once #include "frc/simulation/GenericHIDSim.h" @@ -32,112 +34,112 @@ class PS4ControllerSim : public GenericHIDSim { explicit PS4ControllerSim(int port); /** - * Change the X axis value of the controller's left stick. + * Change the left X value of the controller's joystick. * * @param value the new value */ void SetLeftX(double value); /** - * Change the X axis value of the controller's right stick. + * Change the left Y value of the controller's joystick. * * @param value the new value */ - void SetRightX(double value); + void SetLeftY(double value); /** - * Change the Y axis value of the controller's left stick. + * Change the right X value of the controller's joystick. * * @param value the new value */ - void SetLeftY(double value); + void SetRightX(double value); /** - * Change the Y axis value of the controller's right stick. + * Change the right Y value of the controller's joystick. * * @param value the new value */ void SetRightY(double value); /** - * Change the L2 axis axis value of the controller. + * Change the value of the left trigger 2 axis on the controller. * * @param value the new value */ void SetL2Axis(double value); /** - * Change the R2 axis value of the controller. + * Change the value of the right trigger 2 axis on the controller. * * @param value the new value */ void SetR2Axis(double value); /** - * Change the value of the Square button on the controller. + * Change the value of the square button on the controller. * * @param value the new value */ void SetSquareButton(bool value); /** - * Change the value of the Cross button on the controller. + * Change the value of the cross button on the controller. * * @param value the new value */ void SetCrossButton(bool value); /** - * Change the value of the Circle button on the controller. + * Change the value of the circle button on the controller. * * @param value the new value */ void SetCircleButton(bool value); /** - * Change the value of the Triangle button on the controller. + * Change the value of the triangle button on the controller. * * @param value the new value */ void SetTriangleButton(bool value); /** - * Change the value of the L1 button on the controller. + * Change the value of the left trigger 1 button on the controller. * * @param value the new value */ void SetL1Button(bool value); /** - * Change the value of the R1 button on the controller. + * Change the value of the right trigger 1 button on the controller. * * @param value the new value */ void SetR1Button(bool value); /** - * Change the value of the L2 button on the controller. + * Change the value of the left trigger 2 button on the controller. * * @param value the new value */ void SetL2Button(bool value); /** - * Change the value of the R2 button on the controller. + * Change the value of the right trigger 2 button on the controller. * * @param value the new value */ void SetR2Button(bool value); /** - * Change the value of the Share button on the controller. + * Change the value of the share button on the controller. * * @param value the new value */ void SetShareButton(bool value); /** - * Change the value of the Options button on the controller. + * Change the value of the options button on the controller. * * @param value the new value */ @@ -158,7 +160,7 @@ class PS4ControllerSim : public GenericHIDSim { void SetR3Button(bool value); /** - * Change the value of the PS button on the controller. + * Change the value of the PlayStation button on the controller. * * @param value the new value */ @@ -169,7 +171,16 @@ class PS4ControllerSim : public GenericHIDSim { * * @param value the new value */ + void SetTouchpadButton(bool value); + + /** + * Change the value of the touchpad button on the controller. + * + * @param value the new value + */ + [[deprecated("Use SetTouchpadButton instead")]] void SetTouchpad(bool value); + }; } // namespace sim diff --git a/wpilibc/src/main/native/include/frc/simulation/PS5ControllerSim.h b/wpilibc/src/generated/main/native/include/frc/simulation/PS5ControllerSim.h similarity index 65% rename from wpilibc/src/main/native/include/frc/simulation/PS5ControllerSim.h rename to wpilibc/src/generated/main/native/include/frc/simulation/PS5ControllerSim.h index 6b9e2c7b2b3..e3762bbf204 100644 --- a/wpilibc/src/main/native/include/frc/simulation/PS5ControllerSim.h +++ b/wpilibc/src/generated/main/native/include/frc/simulation/PS5ControllerSim.h @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + #pragma once #include "frc/simulation/GenericHIDSim.h" @@ -32,112 +34,112 @@ class PS5ControllerSim : public GenericHIDSim { explicit PS5ControllerSim(int port); /** - * Change the X axis value of the controller's left stick. + * Change the left X value of the controller's joystick. * * @param value the new value */ void SetLeftX(double value); /** - * Change the X axis value of the controller's right stick. + * Change the left Y value of the controller's joystick. * * @param value the new value */ - void SetRightX(double value); + void SetLeftY(double value); /** - * Change the Y axis value of the controller's left stick. + * Change the right X value of the controller's joystick. * * @param value the new value */ - void SetLeftY(double value); + void SetRightX(double value); /** - * Change the Y axis value of the controller's right stick. + * Change the right Y value of the controller's joystick. * * @param value the new value */ void SetRightY(double value); /** - * Change the L2 axis axis value of the controller. + * Change the value of the left trigger 2 axis on the controller. * * @param value the new value */ void SetL2Axis(double value); /** - * Change the R2 axis value of the controller. + * Change the value of the right trigger 2 axis on the controller. * * @param value the new value */ void SetR2Axis(double value); /** - * Change the value of the Square button on the controller. + * Change the value of the square button on the controller. * * @param value the new value */ void SetSquareButton(bool value); /** - * Change the value of the Cross button on the controller. + * Change the value of the cross button on the controller. * * @param value the new value */ void SetCrossButton(bool value); /** - * Change the value of the Circle button on the controller. + * Change the value of the circle button on the controller. * * @param value the new value */ void SetCircleButton(bool value); /** - * Change the value of the Triangle button on the controller. + * Change the value of the triangle button on the controller. * * @param value the new value */ void SetTriangleButton(bool value); /** - * Change the value of the L1 button on the controller. + * Change the value of the left trigger 1 button on the controller. * * @param value the new value */ void SetL1Button(bool value); /** - * Change the value of the R1 button on the controller. + * Change the value of the right trigger 1 button on the controller. * * @param value the new value */ void SetR1Button(bool value); /** - * Change the value of the L2 button on the controller. + * Change the value of the left trigger 2 button on the controller. * * @param value the new value */ void SetL2Button(bool value); /** - * Change the value of the R2 button on the controller. + * Change the value of the right trigger 2 button on the controller. * * @param value the new value */ void SetR2Button(bool value); /** - * Change the value of the Create button on the controller. + * Change the value of the create button on the controller. * * @param value the new value */ void SetCreateButton(bool value); /** - * Change the value of the Options button on the controller. + * Change the value of the options button on the controller. * * @param value the new value */ @@ -158,7 +160,7 @@ class PS5ControllerSim : public GenericHIDSim { void SetR3Button(bool value); /** - * Change the value of the PS button on the controller. + * Change the value of the PlayStation button on the controller. * * @param value the new value */ @@ -169,7 +171,16 @@ class PS5ControllerSim : public GenericHIDSim { * * @param value the new value */ + void SetTouchpadButton(bool value); + + /** + * Change the value of the touchpad button on the controller. + * + * @param value the new value + */ + [[deprecated("Use SetTouchpadButton instead")]] void SetTouchpad(bool value); + }; } // namespace sim diff --git a/wpilibc/src/generated/main/native/include/frc/simulation/StadiaControllerSim.h b/wpilibc/src/generated/main/native/include/frc/simulation/StadiaControllerSim.h new file mode 100644 index 00000000000..532328ab629 --- /dev/null +++ b/wpilibc/src/generated/main/native/include/frc/simulation/StadiaControllerSim.h @@ -0,0 +1,172 @@ +// 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. + +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + +#pragma once + +#include "frc/simulation/GenericHIDSim.h" + +namespace frc { + +class StadiaController; + +namespace sim { + +/** + * Class to control a simulated Stadia controller. + */ +class StadiaControllerSim : public GenericHIDSim { + public: + /** + * Constructs from a StadiaController object. + * + * @param joystick controller to simulate + */ + explicit StadiaControllerSim(const StadiaController& joystick); + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + explicit StadiaControllerSim(int port); + + /** + * Change the left X value of the controller's joystick. + * + * @param value the new value + */ + void SetLeftX(double value); + + /** + * Change the right X value of the controller's joystick. + * + * @param value the new value + */ + void SetRightX(double value); + + /** + * Change the left Y value of the controller's joystick. + * + * @param value the new value + */ + void SetLeftY(double value); + + /** + * Change the right Y value of the controller's joystick. + * + * @param value the new value + */ + void SetRightY(double value); + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + void SetAButton(bool value); + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + void SetBButton(bool value); + + /** + * Change the value of the X button on the controller. + * + * @param value the new value + */ + void SetXButton(bool value); + + /** + * Change the value of the Y button on the controller. + * + * @param value the new value + */ + void SetYButton(bool value); + + /** + * Change the value of the left bumper button on the controller. + * + * @param value the new value + */ + void SetLeftBumperButton(bool value); + + /** + * Change the value of the right bumper button on the controller. + * + * @param value the new value + */ + void SetRightBumperButton(bool value); + + /** + * Change the value of the left stick button on the controller. + * + * @param value the new value + */ + void SetLeftStickButton(bool value); + + /** + * Change the value of the right stick button on the controller. + * + * @param value the new value + */ + void SetRightStickButton(bool value); + + /** + * Change the value of the ellipses button on the controller. + * + * @param value the new value + */ + void SetEllipsesButton(bool value); + + /** + * Change the value of the hamburger button on the controller. + * + * @param value the new value + */ + void SetHamburgerButton(bool value); + + /** + * Change the value of the stadia button on the controller. + * + * @param value the new value + */ + void SetStadiaButton(bool value); + + /** + * Change the value of the right trigger button on the controller. + * + * @param value the new value + */ + void SetRightTriggerButton(bool value); + + /** + * Change the value of the left trigger button on the controller. + * + * @param value the new value + */ + void SetLeftTriggerButton(bool value); + + /** + * Change the value of the google button on the controller. + * + * @param value the new value + */ + void SetGoogleButton(bool value); + + /** + * Change the value of the frame button on the controller. + * + * @param value the new value + */ + void SetFrameButton(bool value); + +}; + +} // namespace sim +} // namespace frc diff --git a/wpilibc/src/main/native/include/frc/simulation/XboxControllerSim.h b/wpilibc/src/generated/main/native/include/frc/simulation/XboxControllerSim.h similarity index 60% rename from wpilibc/src/main/native/include/frc/simulation/XboxControllerSim.h rename to wpilibc/src/generated/main/native/include/frc/simulation/XboxControllerSim.h index e609ff04ab3..06d6ad6d6e3 100644 --- a/wpilibc/src/main/native/include/frc/simulation/XboxControllerSim.h +++ b/wpilibc/src/generated/main/native/include/frc/simulation/XboxControllerSim.h @@ -2,6 +2,8 @@ // 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. +// THIS FILE WAS AUTO-GENERATED BY ./wpilibc/generate_hids.py. DO NOT MODIFY + #pragma once #include "frc/simulation/GenericHIDSim.h" @@ -13,7 +15,7 @@ class XboxController; namespace sim { /** - * Class to control a simulated Xbox 360 or Xbox One controller. + * Class to control a simulated Xbox controller. */ class XboxControllerSim : public GenericHIDSim { public: @@ -32,116 +34,133 @@ class XboxControllerSim : public GenericHIDSim { explicit XboxControllerSim(int port); /** - * Change the X axis value of the controller's left stick. + * Change the left X value of the controller's joystick. * * @param value the new value */ void SetLeftX(double value); /** - * Change the X axis value of the controller's right stick. + * Change the right X value of the controller's joystick. * * @param value the new value */ void SetRightX(double value); /** - * Change the Y axis value of the controller's left stick. + * Change the left Y value of the controller's joystick. * * @param value the new value */ void SetLeftY(double value); /** - * Change the Y axis value of the controller's right stick. + * Change the right Y value of the controller's joystick. * * @param value the new value */ void SetRightY(double value); /** - * Change the left trigger axis value of the joystick. + * Change the value of the left trigger axis on the controller. * * @param value the new value */ void SetLeftTriggerAxis(double value); /** - * Change the right trigger axis value of the joystick. + * Change the value of the right trigger axis on the controller. * * @param value the new value */ void SetRightTriggerAxis(double value); /** - * Change the left bumper value of the joystick. + * Change the value of the A button on the controller. * * @param value the new value */ - void SetLeftBumper(bool value); + void SetAButton(bool value); /** - * Change the right bumper value of the joystick. + * Change the value of the B button on the controller. * * @param value the new value */ - void SetRightBumper(bool value); + void SetBButton(bool value); /** - * Change the left button value of the joystick. + * Change the value of the X button on the controller. * * @param value the new value */ - void SetLeftStickButton(bool value); + void SetXButton(bool value); /** - * Change the right button value of the joystick. + * Change the value of the Y button on the controller. * * @param value the new value */ - void SetRightStickButton(bool value); + void SetYButton(bool value); /** - * Change the value of the A button. + * Change the value of the left bumper button on the controller. * * @param value the new value */ - void SetAButton(bool value); + void SetLeftBumperButton(bool value); /** - * Change the value of the B button. + * Change the value of the right bumper button on the controller. * * @param value the new value */ - void SetBButton(bool value); + void SetRightBumperButton(bool value); /** - * Change the value of the X button. + * Change the value of the back button on the controller. * * @param value the new value */ - void SetXButton(bool value); + void SetBackButton(bool value); /** - * Change the value of the Y button. + * Change the value of the start button on the controller. * * @param value the new value */ - void SetYButton(bool value); + void SetStartButton(bool value); /** - * Change the value of the Back button. + * Change the value of the left stick button on the controller. * * @param value the new value */ - void SetBackButton(bool value); + void SetLeftStickButton(bool value); /** - * Change the value of the Start button. + * Change the value of the right stick button on the controller. * * @param value the new value */ - void SetStartButton(bool value); + void SetRightStickButton(bool value); + + /** + * Change the left bumper value of the joystick. + * + * @param value the new value + */ + [[deprecated("Use SetLeftBumperButton instead")]] + void SetLeftBumper(bool value); + + /** + * Change the right bumper value of the joystick. + * + * @param value the new value + */ + [[deprecated("Use SetRightBumperButton instead")]] + void SetRightBumper(bool value); + }; } // namespace sim diff --git a/wpilibc/src/test/native/cpp/PS4ControllerTest.cpp b/wpilibc/src/test/native/cpp/PS4ControllerTest.cpp index 4284aed36cd..42d2b9dd526 100644 --- a/wpilibc/src/test/native/cpp/PS4ControllerTest.cpp +++ b/wpilibc/src/test/native/cpp/PS4ControllerTest.cpp @@ -28,7 +28,7 @@ BUTTON_TEST(PS4Controller, L3Button) BUTTON_TEST(PS4Controller, R3Button) BUTTON_TEST(PS4Controller, PSButton) -BUTTON_TEST(PS4Controller, Touchpad) +BUTTON_TEST(PS4Controller, TouchpadButton) AXIS_TEST(PS4Controller, LeftX) AXIS_TEST(PS4Controller, RightX) diff --git a/wpilibc/src/test/native/cpp/PS5ControllerTest.cpp b/wpilibc/src/test/native/cpp/PS5ControllerTest.cpp index 67dd0caa98e..13ae7709efe 100644 --- a/wpilibc/src/test/native/cpp/PS5ControllerTest.cpp +++ b/wpilibc/src/test/native/cpp/PS5ControllerTest.cpp @@ -28,7 +28,7 @@ BUTTON_TEST(PS5Controller, L3Button) BUTTON_TEST(PS5Controller, R3Button) BUTTON_TEST(PS5Controller, PSButton) -BUTTON_TEST(PS5Controller, Touchpad) +BUTTON_TEST(PS5Controller, TouchpadButton) AXIS_TEST(PS5Controller, LeftX) AXIS_TEST(PS5Controller, RightX) diff --git a/wpilibc/src/test/native/cpp/XboxControllerTest.cpp b/wpilibc/src/test/native/cpp/XboxControllerTest.cpp index 3798fde51c3..fdc9866d72b 100644 --- a/wpilibc/src/test/native/cpp/XboxControllerTest.cpp +++ b/wpilibc/src/test/native/cpp/XboxControllerTest.cpp @@ -11,8 +11,8 @@ using namespace frc; -BUTTON_TEST(XboxController, LeftBumper) -BUTTON_TEST(XboxController, RightBumper) +BUTTON_TEST(XboxController, LeftBumperButton) +BUTTON_TEST(XboxController, RightBumperButton) BUTTON_TEST(XboxController, LeftStickButton) BUTTON_TEST(XboxController, RightStickButton) diff --git a/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp index 38e9262613f..e1a51e61ecc 100644 --- a/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp @@ -109,7 +109,7 @@ class Robot : public frc::TimedRobot { // Sets the target position of our arm. This is similar to setting the // setpoint of a PID controller. frc::TrapezoidProfile::State goal; - if (m_joystick.GetRightBumper()) { + if (m_joystick.GetRightBumperButton()) { // We pressed the bumper, so let's set our next reference goal = {kRaisedPosition, 0_rad_per_s}; } else { diff --git a/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp index ceadd8392bf..620f9568baa 100644 --- a/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp @@ -109,7 +109,7 @@ class Robot : public frc::TimedRobot { // Sets the target height of our elevator. This is similar to setting the // setpoint of a PID controller. frc::TrapezoidProfile::State goal; - if (m_joystick.GetRightBumper()) { + if (m_joystick.GetRightBumperButton()) { // We pressed the bumper, so let's set our next reference goal = {kRaisedPosition, 0_fps}; } else { diff --git a/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp index 5d413ab26b0..b0a9ed3a92f 100644 --- a/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp @@ -92,7 +92,7 @@ class Robot : public frc::TimedRobot { void TeleopPeriodic() override { // Sets the target speed of our flywheel. This is similar to setting the // setpoint of a PID controller. - if (m_joystick.GetRightBumper()) { + if (m_joystick.GetRightBumperButton()) { // We pressed the bumper, so let's set our next reference m_loop.SetNextR(frc::Vectord<1>{kSpinup.value()}); } else { diff --git a/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp index d3bab6e7954..2be14fd49f0 100644 --- a/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp @@ -92,7 +92,7 @@ class Robot : public frc::TimedRobot { void TeleopPeriodic() override { // Sets the target speed of our flywheel. This is similar to setting the // setpoint of a PID controller. - if (m_joystick.GetRightBumper()) { + if (m_joystick.GetRightBumperButton()) { // We pressed the bumper, so let's set our next reference m_loop.SetNextR(frc::Vectord<1>{kSpinup.value()}); } else { diff --git a/wpilibj/generate_hids.py b/wpilibj/generate_hids.py old mode 100644 new mode 100755