diff --git a/.gitattributes b/.gitattributes index ab6ca853b1..e869fc8fa7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,11 +3,10 @@ *.h text eol=lf *.inc text eol=lf *.java text eol=lf +*.jinja text eol=lf *.json text eol=lf *.md text eol=lf *.xml text eol=lf # Generated files -hal/src/generated/** linguist-generated -ntcore/src/generated/** linguist-generated -wpimath/src/generated/** linguist-generated +*/src/generated/** linguist-generated diff --git a/.github/workflows/pregenerate.yml b/.github/workflows/pregenerate.yml index 025f1b6a73..8dc74bc448 100644 --- a/.github/workflows/pregenerate.yml +++ b/.github/workflows/pregenerate.yml @@ -32,6 +32,8 @@ jobs: run: ./ntcore/generate_topics.py - 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 && ./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 f67c100e08..de0e89797c 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/styleguide/checkstyle-suppressions.xml b/styleguide/checkstyle-suppressions.xml index f42b176a63..7644ea0563 100644 --- a/styleguide/checkstyle-suppressions.xml +++ b/styleguide/checkstyle-suppressions.xml @@ -12,4 +12,6 @@ suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN" checks="(EmptyLineSeparator|LineLength|MissingJavadocMethod|ParameterName)" /> + diff --git a/wpilibNewCommands/.styleguide b/wpilibNewCommands/.styleguide index 7c8d7a70fb..feafd15406 100644 --- a/wpilibNewCommands/.styleguide +++ b/wpilibNewCommands/.styleguide @@ -12,6 +12,10 @@ repoRootNameOverride { wpilib } +generatedFileExclude { + wpilibNewCommands/src/generated/ +} + includeOtherLibs { ^cameraserver/ ^cscore diff --git a/wpilibNewCommands/CMakeLists.txt b/wpilibNewCommands/CMakeLists.txt index cf17bd1427..5b82b2f5ff 100644 --- a/wpilibNewCommands/CMakeLists.txt +++ b/wpilibNewCommands/CMakeLists.txt @@ -8,7 +8,7 @@ if(WITH_JAVA) find_package(Java REQUIRED) include(UseJava) - file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java) + file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java src/generated/main/java/*.java) add_jar( wpilibNewCommands_jar ${JAVA_SOURCES} @@ -39,7 +39,8 @@ if(WITH_JAVA_SOURCE) file(GLOB WPILIBNEWCOMMANDS_SOURCES src/main/java/edu/wpi/first/wpilibj2/command/*.java) file( GLOB WPILIBNEWCOMMANDS_BUTTON_SOURCES - src/main/java/edu/wpi/first/wpilibj2/command/button*.java + src/main/java/edu/wpi/first/wpilibj2/command/button/*.java + src/generated/main/java/edu/wpi/first/wpilibj2/command/button/*.java ) add_jar( wpilibNewCommands_src_jar @@ -55,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") @@ -68,6 +73,7 @@ target_include_directories( wpilibNewCommands PUBLIC $ + $ $ ) diff --git a/wpilibNewCommands/build.gradle b/wpilibNewCommands/build.gradle index d60fcde1e4..89ada857bf 100644 --- a/wpilibNewCommands/build.gradle +++ b/wpilibNewCommands/build.gradle @@ -24,6 +24,8 @@ dependencies { testImplementation 'org.mockito:mockito-core:4.1.0' } +sourceSets.main.java.srcDir "${projectDir}/src/generated/main/java" + nativeUtils.exportsConfigs { wpilibNewCommands { x64ExcludeSymbols = [ @@ -43,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 new file mode 100755 index 0000000000..8836253e5b --- /dev/null +++ b/wpilibNewCommands/generate_hids.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python3 + +# 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. +import json +import os + +from jinja2 import Environment, FileSystemLoader + + +def write_controller_file(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) + + # Java files + env = Environment( + loader=FileSystemLoader( + f"{dirname}/src/generate/main/java/edu/wpi/first/wpilibj2/command/button" + ), + autoescape=False, + keep_trailing_newline=True, + ) + rootPath = ( + f"{dirname}/src/generated/main/java/edu/wpi/first/wpilibj2/command/button" + ) + template = env.get_template("commandhid.java.jinja") + for controller in controllers: + controllerName = os.path.basename( + f"Command{controller['ConsoleName']}Controller.java" + ) + output = template.render(controller) + write_controller_file(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) + write_controller_file(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) + write_controller_file(rootPath, controllerName, output) + + +if __name__ == "__main__": + main() diff --git a/wpilibNewCommands/src/generate/main/java/edu/wpi/first/wpilibj2/command/button/commandhid.java.jinja b/wpilibNewCommands/src/generate/main/java/edu/wpi/first/wpilibj2/command/button/commandhid.java.jinja new file mode 100644 index 0000000000..a13d673afd --- /dev/null +++ b/wpilibNewCommands/src/generate/main/java/edu/wpi/first/wpilibj2/command/button/commandhid.java.jinja @@ -0,0 +1,129 @@ +// 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 +{% macro capitalize_first(string) -%} +{{ string[0]|capitalize + string[1:] }} +{%- endmacro %} +package edu.wpi.first.wpilibj2.command.button; + +import edu.wpi.first.wpilibj.{{ ConsoleName }}Controller; +import edu.wpi.first.wpilibj.event.EventLoop; +import edu.wpi.first.wpilibj2.command.CommandScheduler; + +/** + * A version of {@link {{ ConsoleName }}Controller} with {@link Trigger} factories for command-based. + * + * @see {{ ConsoleName }}Controller + */ +@SuppressWarnings("MethodName") +public class Command{{ ConsoleName }}Controller extends CommandGenericHID { + private final {{ ConsoleName }}Controller m_hid; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public Command{{ ConsoleName }}Controller(int port) { + super(port); + m_hid = new {{ ConsoleName }}Controller(port); + } + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + @Override + public {{ ConsoleName }}Controller getHID() { + return m_hid; + } +{% for button in buttons %} + /** + * Constructs a Trigger instance around the {{ button.DocName|default(button.name) }} button's digital signal. + * + * @return a Trigger instance representing the {{ button.DocName|default(button.name) }} button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #{{ button.name }}(EventLoop) + */ + public Trigger {{ button.name }}() { + return {{ button.name }}(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the {{ button.DocName|default(button.name) }} button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the {{ button.DocName|default(button.name) }} button's digital signal attached + * to the given loop. + */ + public Trigger {{ button.name }}(EventLoop loop) { + return m_hid.{{ button.name }}(loop).castTo(Trigger::new); + } +{% endfor -%} +{% for trigger in triggers -%} +{% 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 {@link Trigger} 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 Trigger to. + * @return a Trigger instance that is true when the {{ trigger.DocName }}'s axis exceeds the provided + * threshold, attached to the given event loop + */ + public Trigger {{ trigger.name }}(double threshold, EventLoop loop) { + return m_hid.{{ trigger.name }}(threshold, loop).castTo(Trigger::new); + } + + /** + * 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 {@link Trigger} to be true. This value + * should be in the range [0, 1] where 0 is the unpressed state of the axis. + * @return a Trigger instance that is true when the {{ trigger.DocName }}'s axis exceeds the provided + * threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler + * button loop}. + */ + public Trigger {{ trigger.name }}(double threshold) { + return {{ trigger.name }}(threshold, CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * 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 0.5. + * + * @return a Trigger instance that is true when the {{ trigger.DocName }}'s axis exceeds 0.5, attached to + * the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + */ + public Trigger {{ trigger.name }}() { + return {{ trigger.name }}(0.5); + } +{% endif -%} +{% endfor -%} +{% for stick in sticks %} + /** + * Get the {{ stick.NameParts[1] }} axis value of {{ stick.NameParts[0] }} side of the controller. + * + * @return The axis value. + */ + public double get{{ stick.NameParts|map("capitalize")|join }}() { + return m_hid.get{{ stick.NameParts|map("capitalize")|join }}(); + } +{% endfor -%} +{% for trigger in triggers %} + /** + * 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. + */ + public double get{{ capitalize_first(trigger.name) }}Axis() { + return m_hid.get{{ capitalize_first(trigger.name) }}Axis(); + } +{% endfor -%} +} 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 0000000000..b6e5058598 --- /dev/null +++ b/wpilibNewCommands/src/generate/main/native/cpp/frc2/command/button/commandhid.cpp.jinja @@ -0,0 +1,41 @@ +// 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 +{% macro capitalize_first(string) -%} +{{ string[0]|capitalize + string[1:] }} +{%- endmacro %} +#include "frc2/command/button/Command{{ ConsoleName }}Controller.h" + +using namespace frc2; + +Command{{ ConsoleName }}Controller::Command{{ ConsoleName }}Controller(int port) + : CommandGenericHID(port), m_hid{frc::{{ ConsoleName }}Controller(port)} {} + +frc::{{ ConsoleName }}Controller& Command{{ ConsoleName }}Controller::GetHID() { + return m_hid; +} +{% for button in buttons %} +Trigger Command{{ ConsoleName }}Controller::{{ capitalize_first(button.name) }}(frc::EventLoop* loop) const { + return m_hid.{{ capitalize_first(button.name) }}(loop).CastTo(); +} +{% endfor -%} +{% for trigger in triggers -%} +{% if trigger.UseThresholdMethods %} +Trigger Command{{ ConsoleName }}Controller::{{ capitalize_first(trigger.name) }}(double threshold, + frc::EventLoop* loop) const { + return m_hid.{{ capitalize_first(trigger.name) }}(threshold, loop).CastTo(); +} +{% endif -%} +{% endfor -%} +{% for stick in sticks %} +double Command{{ ConsoleName }}Controller::Get{{ stick.NameParts|map("capitalize")|join }}() const { + return m_hid.Get{{ stick.NameParts|map("capitalize")|join }}(); +} +{% endfor -%} +{% for trigger in triggers %} +double Command{{ ConsoleName }}Controller::Get{{ capitalize_first(trigger.name) }}Axis() const { + return m_hid.Get{{ capitalize_first(trigger.name) }}Axis(); +} +{% 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 0000000000..8e1d54074d --- /dev/null +++ b/wpilibNewCommands/src/generate/main/native/include/frc2/command/button/commandhid.h.jinja @@ -0,0 +1,92 @@ +// 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 +{% macro capitalize_first(string) -%} +{{ string[0]|capitalize + string[1:] }} +{%- endmacro %} +#pragma once +#include + +#include "frc2/command/button/Trigger.h" +#include "frc2/command/CommandScheduler.h" +#include "frc2/command/button/CommandGenericHID.h" + +namespace frc2 { +/** + * A version of {@link frc::{{ ConsoleName }}Controller} with {@link Trigger} factories for + * command-based. + * + * @see frc::{{ ConsoleName }}Controller + */ +class Command{{ ConsoleName }}Controller : public CommandGenericHID { + public: + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is + * plugged into. + */ + explicit Command{{ ConsoleName }}Controller(int port); + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + frc::{{ ConsoleName }}Controller& GetHID(); +{% for button in buttons %} + /** + * Constructs a Trigger instance around the {{ button.DocName|default(button.name) }} button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the {{ button.DocName|default(button.name) }} button's + * digital signal attached to the given loop. + */ + Trigger {{ capitalize_first(button.name) }}(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; +{% endfor -%} +{% for trigger in triggers -%} +{% 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 {{ capitalize_first(trigger.name) }}(double threshold = 0.5, + frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; +{% endif -%} +{% endfor -%} +{% for stick in sticks %} + /** + * 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 triggers %} + /** + * 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{{ capitalize_first(trigger.name) }}Axis() const; +{% endfor %} + private: + frc::{{ ConsoleName }}Controller m_hid; +}; +} // namespace frc2 diff --git a/wpilibNewCommands/src/generated/main/java/edu/wpi/first/wpilibj2/command/button/CommandPS4Controller.java b/wpilibNewCommands/src/generated/main/java/edu/wpi/first/wpilibj2/command/button/CommandPS4Controller.java new file mode 100644 index 0000000000..150d124228 --- /dev/null +++ b/wpilibNewCommands/src/generated/main/java/edu/wpi/first/wpilibj2/command/button/CommandPS4Controller.java @@ -0,0 +1,405 @@ +// 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 + +package edu.wpi.first.wpilibj2.command.button; + +import edu.wpi.first.wpilibj.PS4Controller; +import edu.wpi.first.wpilibj.event.EventLoop; +import edu.wpi.first.wpilibj2.command.CommandScheduler; + +/** + * A version of {@link PS4Controller} with {@link Trigger} factories for command-based. + * + * @see PS4Controller + */ +@SuppressWarnings("MethodName") +public class CommandPS4Controller extends CommandGenericHID { + private final PS4Controller m_hid; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandPS4Controller(int port) { + super(port); + m_hid = new PS4Controller(port); + } + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + @Override + public PS4Controller getHID() { + return m_hid; + } + + /** + * Constructs a Trigger instance around the square button's digital signal. + * + * @return a Trigger instance representing the square button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #square(EventLoop) + */ + public Trigger square() { + return square(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the square button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the square button's digital signal attached + * to the given loop. + */ + public Trigger square(EventLoop loop) { + return m_hid.square(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the cross button's digital signal. + * + * @return a Trigger instance representing the cross button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #cross(EventLoop) + */ + public Trigger cross() { + return cross(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the cross button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the cross button's digital signal attached + * to the given loop. + */ + public Trigger cross(EventLoop loop) { + return m_hid.cross(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the circle button's digital signal. + * + * @return a Trigger instance representing the circle button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #circle(EventLoop) + */ + public Trigger circle() { + return circle(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the circle button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the circle button's digital signal attached + * to the given loop. + */ + public Trigger circle(EventLoop loop) { + return m_hid.circle(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the triangle button's digital signal. + * + * @return a Trigger instance representing the triangle button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #triangle(EventLoop) + */ + public Trigger triangle() { + return triangle(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the triangle button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the triangle button's digital signal attached + * to the given loop. + */ + public Trigger triangle(EventLoop loop) { + return m_hid.triangle(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the left trigger 1 button's digital signal. + * + * @return a Trigger instance representing the left trigger 1 button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #L1(EventLoop) + */ + public Trigger L1() { + return L1(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the left trigger 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the left trigger 1 button's digital signal attached + * to the given loop. + */ + public Trigger L1(EventLoop loop) { + return m_hid.L1(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the right trigger 1 button's digital signal. + * + * @return a Trigger instance representing the right trigger 1 button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #R1(EventLoop) + */ + public Trigger R1() { + return R1(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the right trigger 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the right trigger 1 button's digital signal attached + * to the given loop. + */ + public Trigger R1(EventLoop loop) { + return m_hid.R1(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the left trigger 2 button's digital signal. + * + * @return a Trigger instance representing the left trigger 2 button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #L2(EventLoop) + */ + public Trigger L2() { + return L2(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the left trigger 2 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the left trigger 2 button's digital signal attached + * to the given loop. + */ + public Trigger L2(EventLoop loop) { + return m_hid.L2(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the right trigger 2 button's digital signal. + * + * @return a Trigger instance representing the right trigger 2 button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #R2(EventLoop) + */ + public Trigger R2() { + return R2(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the right trigger 2 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the right trigger 2 button's digital signal attached + * to the given loop. + */ + public Trigger R2(EventLoop loop) { + return m_hid.R2(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the share button's digital signal. + * + * @return a Trigger instance representing the share button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #share(EventLoop) + */ + public Trigger share() { + return share(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the share button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the share button's digital signal attached + * to the given loop. + */ + public Trigger share(EventLoop loop) { + return m_hid.share(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the options button's digital signal. + * + * @return a Trigger instance representing the options button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #options(EventLoop) + */ + public Trigger options() { + return options(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the options button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the options button's digital signal attached + * to the given loop. + */ + public Trigger options(EventLoop loop) { + return m_hid.options(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the L3 (left stick) button's digital signal. + * + * @return a Trigger instance representing the L3 (left stick) button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #L3(EventLoop) + */ + public Trigger L3() { + return L3(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the L3 (left stick) button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L3 (left stick) button's digital signal attached + * to the given loop. + */ + public Trigger L3(EventLoop loop) { + return m_hid.L3(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the R3 (right stick) button's digital signal. + * + * @return a Trigger instance representing the R3 (right stick) button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #R3(EventLoop) + */ + public Trigger R3() { + return R3(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the R3 (right stick) button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R3 (right stick) button's digital signal attached + * to the given loop. + */ + public Trigger R3(EventLoop loop) { + return m_hid.R3(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the PlayStation button's digital signal. + * + * @return a Trigger instance representing the PlayStation button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #PS(EventLoop) + */ + public Trigger PS() { + return PS(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the PlayStation button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the PlayStation button's digital signal attached + * to the given loop. + */ + public Trigger PS(EventLoop loop) { + return m_hid.PS(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the touchpad button's digital signal. + * + * @return a Trigger instance representing the touchpad button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #touchpad(EventLoop) + */ + public Trigger touchpad() { + return touchpad(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the touchpad button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the touchpad button's digital signal attached + * to the given loop. + */ + public Trigger touchpad(EventLoop loop) { + return m_hid.touchpad(loop).castTo(Trigger::new); + } + + /** + * Get the X axis value of left side of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_hid.getLeftX(); + } + + /** + * Get the Y axis value of left side of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_hid.getLeftY(); + } + + /** + * Get the X axis value of right side of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return m_hid.getRightX(); + } + + /** + * Get the Y axis value of right side of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return m_hid.getRightY(); + } + + /** + * 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. + */ + public double getL2Axis() { + return m_hid.getL2Axis(); + } + + /** + * 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. + */ + public double getR2Axis() { + return m_hid.getR2Axis(); + } +} diff --git a/wpilibNewCommands/src/generated/main/java/edu/wpi/first/wpilibj2/command/button/CommandPS5Controller.java b/wpilibNewCommands/src/generated/main/java/edu/wpi/first/wpilibj2/command/button/CommandPS5Controller.java new file mode 100644 index 0000000000..2f3d271837 --- /dev/null +++ b/wpilibNewCommands/src/generated/main/java/edu/wpi/first/wpilibj2/command/button/CommandPS5Controller.java @@ -0,0 +1,405 @@ +// 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 + +package edu.wpi.first.wpilibj2.command.button; + +import edu.wpi.first.wpilibj.PS5Controller; +import edu.wpi.first.wpilibj.event.EventLoop; +import edu.wpi.first.wpilibj2.command.CommandScheduler; + +/** + * A version of {@link PS5Controller} with {@link Trigger} factories for command-based. + * + * @see PS5Controller + */ +@SuppressWarnings("MethodName") +public class CommandPS5Controller extends CommandGenericHID { + private final PS5Controller m_hid; + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into. + */ + public CommandPS5Controller(int port) { + super(port); + m_hid = new PS5Controller(port); + } + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + @Override + public PS5Controller getHID() { + return m_hid; + } + + /** + * Constructs a Trigger instance around the square button's digital signal. + * + * @return a Trigger instance representing the square button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #square(EventLoop) + */ + public Trigger square() { + return square(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the square button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the square button's digital signal attached + * to the given loop. + */ + public Trigger square(EventLoop loop) { + return m_hid.square(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the cross button's digital signal. + * + * @return a Trigger instance representing the cross button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #cross(EventLoop) + */ + public Trigger cross() { + return cross(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the cross button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the cross button's digital signal attached + * to the given loop. + */ + public Trigger cross(EventLoop loop) { + return m_hid.cross(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the circle button's digital signal. + * + * @return a Trigger instance representing the circle button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #circle(EventLoop) + */ + public Trigger circle() { + return circle(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the circle button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the circle button's digital signal attached + * to the given loop. + */ + public Trigger circle(EventLoop loop) { + return m_hid.circle(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the triangle button's digital signal. + * + * @return a Trigger instance representing the triangle button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #triangle(EventLoop) + */ + public Trigger triangle() { + return triangle(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the triangle button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the triangle button's digital signal attached + * to the given loop. + */ + public Trigger triangle(EventLoop loop) { + return m_hid.triangle(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the left trigger 1 button's digital signal. + * + * @return a Trigger instance representing the left trigger 1 button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #L1(EventLoop) + */ + public Trigger L1() { + return L1(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the left trigger 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the left trigger 1 button's digital signal attached + * to the given loop. + */ + public Trigger L1(EventLoop loop) { + return m_hid.L1(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the right trigger 1 button's digital signal. + * + * @return a Trigger instance representing the right trigger 1 button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #R1(EventLoop) + */ + public Trigger R1() { + return R1(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the right trigger 1 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the right trigger 1 button's digital signal attached + * to the given loop. + */ + public Trigger R1(EventLoop loop) { + return m_hid.R1(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the left trigger 2 button's digital signal. + * + * @return a Trigger instance representing the left trigger 2 button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #L2(EventLoop) + */ + public Trigger L2() { + return L2(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the left trigger 2 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the left trigger 2 button's digital signal attached + * to the given loop. + */ + public Trigger L2(EventLoop loop) { + return m_hid.L2(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the right trigger 2 button's digital signal. + * + * @return a Trigger instance representing the right trigger 2 button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #R2(EventLoop) + */ + public Trigger R2() { + return R2(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the right trigger 2 button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the right trigger 2 button's digital signal attached + * to the given loop. + */ + public Trigger R2(EventLoop loop) { + return m_hid.R2(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the create button's digital signal. + * + * @return a Trigger instance representing the create button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #create(EventLoop) + */ + public Trigger create() { + return create(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the create button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the create button's digital signal attached + * to the given loop. + */ + public Trigger create(EventLoop loop) { + return m_hid.create(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the options button's digital signal. + * + * @return a Trigger instance representing the options button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #options(EventLoop) + */ + public Trigger options() { + return options(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the options button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the options button's digital signal attached + * to the given loop. + */ + public Trigger options(EventLoop loop) { + return m_hid.options(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the L3 (left stick) button's digital signal. + * + * @return a Trigger instance representing the L3 (left stick) button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #L3(EventLoop) + */ + public Trigger L3() { + return L3(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the L3 (left stick) button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the L3 (left stick) button's digital signal attached + * to the given loop. + */ + public Trigger L3(EventLoop loop) { + return m_hid.L3(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the R3 (right stick) button's digital signal. + * + * @return a Trigger instance representing the R3 (right stick) button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #R3(EventLoop) + */ + public Trigger R3() { + return R3(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the R3 (right stick) button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the R3 (right stick) button's digital signal attached + * to the given loop. + */ + public Trigger R3(EventLoop loop) { + return m_hid.R3(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the PlayStation button's digital signal. + * + * @return a Trigger instance representing the PlayStation button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #PS(EventLoop) + */ + public Trigger PS() { + return PS(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the PlayStation button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the PlayStation button's digital signal attached + * to the given loop. + */ + public Trigger PS(EventLoop loop) { + return m_hid.PS(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the touchpad button's digital signal. + * + * @return a Trigger instance representing the touchpad button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #touchpad(EventLoop) + */ + public Trigger touchpad() { + return touchpad(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the touchpad button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the touchpad button's digital signal attached + * to the given loop. + */ + public Trigger touchpad(EventLoop loop) { + return m_hid.touchpad(loop).castTo(Trigger::new); + } + + /** + * Get the X axis value of left side of the controller. + * + * @return The axis value. + */ + public double getLeftX() { + return m_hid.getLeftX(); + } + + /** + * Get the Y axis value of left side of the controller. + * + * @return The axis value. + */ + public double getLeftY() { + return m_hid.getLeftY(); + } + + /** + * Get the X axis value of right side of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return m_hid.getRightX(); + } + + /** + * Get the Y axis value of right side of the controller. + * + * @return The axis value. + */ + public double getRightY() { + return m_hid.getRightY(); + } + + /** + * 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. + */ + public double getL2Axis() { + return m_hid.getL2Axis(); + } + + /** + * 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. + */ + public double getR2Axis() { + return m_hid.getR2Axis(); + } +} diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandStadiaController.java b/wpilibNewCommands/src/generated/main/java/edu/wpi/first/wpilibj2/command/button/CommandStadiaController.java similarity index 50% rename from wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandStadiaController.java rename to wpilibNewCommands/src/generated/main/java/edu/wpi/first/wpilibj2/command/button/CommandStadiaController.java index 0d919e5caa..90bc5d0178 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandStadiaController.java +++ b/wpilibNewCommands/src/generated/main/java/edu/wpi/first/wpilibj2/command/button/CommandStadiaController.java @@ -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 + package edu.wpi.first.wpilibj2.command.button; import edu.wpi.first.wpilibj.StadiaController; @@ -38,142 +40,10 @@ public class CommandStadiaController extends CommandGenericHID { } /** - * Constructs an event instance around the left bumper's digital signal. + * Constructs a Trigger instance around the A button's digital signal. * - * @return an event instance representing the left bumper's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - * @see #leftBumper(EventLoop) - */ - public Trigger leftBumper() { - return leftBumper(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the left bumper'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. - */ - public Trigger leftBumper(EventLoop loop) { - return m_hid.leftBumper(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the right bumper's digital signal. - * - * @return an event instance representing the right bumper's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - * @see #rightBumper(EventLoop) - */ - public Trigger rightBumper() { - return rightBumper(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the right bumper's digital signal. - * - * @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. - */ - public Trigger rightBumper(EventLoop loop) { - return m_hid.rightBumper(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the left stick button's digital signal. - * - * @return an event instance representing the left stick button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - * @see #leftStick(EventLoop) - */ - public Trigger leftStick() { - return leftStick(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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 left stick button's digital signal attached to the - * given loop. - */ - public Trigger leftStick(EventLoop loop) { - return m_hid.leftStick(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the right stick button's digital signal. - * - * @return an event instance representing the right stick button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - * @see #rightStick(EventLoop) - */ - public Trigger rightStick() { - return rightStick(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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 right stick button's digital signal attached to the - * given loop. - */ - public Trigger rightStick(EventLoop loop) { - return m_hid.rightStick(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the right trigger button's digital signal. - * - * @return an event instance representing the right trigger button's digital signal attached to - * the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - * @see #rightTrigger(EventLoop) - */ - public Trigger rightTrigger() { - return rightTrigger(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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 right trigger button's digital signal attached to - * the given loop. - */ - public Trigger rightTrigger(EventLoop loop) { - return m_hid.rightTrigger(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the left trigger button's digital signal. - * - * @return an event instance representing the left trigger button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - * @see #leftTrigger(EventLoop) - */ - public Trigger leftTrigger() { - return leftTrigger(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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 left trigger button's digital signal attached to the - * given loop. - */ - public Trigger leftTrigger(EventLoop loop) { - return m_hid.leftTrigger(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the A button's digital signal. - * - * @return an event instance representing the A button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @return a Trigger instance representing the A button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. * @see #a(EventLoop) */ public Trigger a() { @@ -181,21 +51,21 @@ public class CommandStadiaController extends CommandGenericHID { } /** - * Constructs an event instance around the A button's digital signal. + * Constructs a Trigger instance around the A 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 a Trigger instance representing the A button's digital signal attached + * to the given loop. */ public Trigger a(EventLoop loop) { return m_hid.a(loop).castTo(Trigger::new); } /** - * Constructs an event instance around the B button's digital signal. + * Constructs a Trigger instance around the B button's digital signal. * - * @return an event instance representing the B button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @return a Trigger instance representing the B button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. * @see #b(EventLoop) */ public Trigger b() { @@ -203,21 +73,21 @@ public class CommandStadiaController extends CommandGenericHID { } /** - * Constructs an event instance around the B button's digital signal. + * Constructs a Trigger 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 B button's digital signal attached to the given - * loop. + * @return a Trigger instance representing the B button's digital signal attached + * to the given loop. */ public Trigger b(EventLoop loop) { return m_hid.b(loop).castTo(Trigger::new); } /** - * Constructs an event instance around the X button's digital signal. + * Constructs a Trigger instance around the X button's digital signal. * - * @return an event instance representing the X button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @return a Trigger instance representing the X button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. * @see #x(EventLoop) */ public Trigger x() { @@ -225,21 +95,21 @@ public class CommandStadiaController extends CommandGenericHID { } /** - * Constructs an event instance around the X button's digital signal. + * Constructs a Trigger instance around the X 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 a Trigger instance representing the X button's digital signal attached + * to the given loop. */ public Trigger x(EventLoop loop) { return m_hid.x(loop).castTo(Trigger::new); } /** - * Constructs an event instance around the Y button's digital signal. + * Constructs a Trigger instance around the Y button's digital signal. * - * @return an event instance representing the Y button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @return a Trigger instance representing the Y button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. * @see #y(EventLoop) */ public Trigger y() { @@ -247,21 +117,109 @@ public class CommandStadiaController extends CommandGenericHID { } /** - * Constructs an event instance around the Y button's digital signal. + * Constructs a Trigger 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 Y button's digital signal attached to the given - * loop. + * @return a Trigger instance representing the Y button's digital signal attached + * to the given loop. */ public Trigger y(EventLoop loop) { return m_hid.y(loop).castTo(Trigger::new); } /** - * Constructs an event instance around the ellipses button's digital signal. + * Constructs a Trigger instance around the left bumper button's digital signal. * - * @return an event instance representing the ellipses button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @return a Trigger instance representing the left bumper button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #leftBumper(EventLoop) + */ + public Trigger leftBumper() { + return leftBumper(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the left bumper button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the left bumper button's digital signal attached + * to the given loop. + */ + public Trigger leftBumper(EventLoop loop) { + return m_hid.leftBumper(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the right bumper button's digital signal. + * + * @return a Trigger instance representing the right bumper button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #rightBumper(EventLoop) + */ + public Trigger rightBumper() { + return rightBumper(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the right bumper button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the right bumper button's digital signal attached + * to the given loop. + */ + public Trigger rightBumper(EventLoop loop) { + return m_hid.rightBumper(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the left stick button's digital signal. + * + * @return a Trigger instance representing the left stick button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #leftStick(EventLoop) + */ + public Trigger leftStick() { + return leftStick(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the left stick button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the left stick button's digital signal attached + * to the given loop. + */ + public Trigger leftStick(EventLoop loop) { + return m_hid.leftStick(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the right stick button's digital signal. + * + * @return a Trigger instance representing the right stick button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #rightStick(EventLoop) + */ + public Trigger rightStick() { + return rightStick(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the right stick button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the right stick button's digital signal attached + * to the given loop. + */ + public Trigger rightStick(EventLoop loop) { + return m_hid.rightStick(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the ellipses button's digital signal. + * + * @return a Trigger instance representing the ellipses button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. * @see #ellipses(EventLoop) */ public Trigger ellipses() { @@ -269,87 +227,21 @@ public class CommandStadiaController extends CommandGenericHID { } /** - * Constructs an event instance around the ellipses button's digital signal. + * Constructs a Trigger 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 a Trigger instance representing the ellipses button's digital signal attached + * to the given loop. */ public Trigger ellipses(EventLoop loop) { return m_hid.ellipses(loop).castTo(Trigger::new); } /** - * Constructs an event instance around the stadia button's digital signal. + * Constructs a Trigger instance around the hamburger button's digital signal. * - * @return an event instance representing the stadia button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - * @see #stadia(EventLoop) - */ - public Trigger stadia() { - return stadia(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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. - */ - public Trigger stadia(EventLoop loop) { - return m_hid.stadia(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the google button's digital signal. - * - * @return an event instance representing the google button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - * @see #google(EventLoop) - */ - public Trigger google() { - return google(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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 google button's digital signal attached to the given - * loop. - */ - public Trigger google(EventLoop loop) { - return m_hid.google(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the frame button's digital signal. - * - * @return an event instance representing the frame button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - * @see #frame(EventLoop) - */ - public Trigger frame() { - return frame(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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 frame button's digital signal attached to the given - * loop. - */ - public Trigger frame(EventLoop loop) { - return m_hid.frame(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the hamburger button's digital signal. - * - * @return an event instance representing the hamburger button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @return a Trigger instance representing the hamburger button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. * @see #hamburger(EventLoop) */ public Trigger hamburger() { @@ -357,16 +249,126 @@ public class CommandStadiaController extends CommandGenericHID { } /** - * Constructs an event instance around the hamburger button's digital signal. + * Constructs a Trigger 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 a Trigger instance representing the hamburger button's digital signal attached + * to the given loop. */ public Trigger hamburger(EventLoop loop) { return m_hid.hamburger(loop).castTo(Trigger::new); } + /** + * Constructs a Trigger instance around the stadia button's digital signal. + * + * @return a Trigger instance representing the stadia button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #stadia(EventLoop) + */ + public Trigger stadia() { + return stadia(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the stadia button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the stadia button's digital signal attached + * to the given loop. + */ + public Trigger stadia(EventLoop loop) { + return m_hid.stadia(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the right trigger button's digital signal. + * + * @return a Trigger instance representing the right trigger button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #rightTrigger(EventLoop) + */ + public Trigger rightTrigger() { + return rightTrigger(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the right trigger button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the right trigger button's digital signal attached + * to the given loop. + */ + public Trigger rightTrigger(EventLoop loop) { + return m_hid.rightTrigger(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the left trigger button's digital signal. + * + * @return a Trigger instance representing the left trigger button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #leftTrigger(EventLoop) + */ + public Trigger leftTrigger() { + return leftTrigger(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the left trigger button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the left trigger button's digital signal attached + * to the given loop. + */ + public Trigger leftTrigger(EventLoop loop) { + return m_hid.leftTrigger(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the google button's digital signal. + * + * @return a Trigger instance representing the google button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #google(EventLoop) + */ + public Trigger google() { + return google(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the google button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the google button's digital signal attached + * to the given loop. + */ + public Trigger google(EventLoop loop) { + return m_hid.google(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the frame button's digital signal. + * + * @return a Trigger instance representing the frame button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #frame(EventLoop) + */ + public Trigger frame() { + return frame(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the frame button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the frame button's digital signal attached + * to the given loop. + */ + public Trigger frame(EventLoop loop) { + return m_hid.frame(loop).castTo(Trigger::new); + } + /** * Get the X axis value of left side of the controller. * diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandXboxController.java b/wpilibNewCommands/src/generated/main/java/edu/wpi/first/wpilibj2/command/button/CommandXboxController.java similarity index 62% rename from wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandXboxController.java rename to wpilibNewCommands/src/generated/main/java/edu/wpi/first/wpilibj2/command/button/CommandXboxController.java index 6969c98468..0f6417674e 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandXboxController.java +++ b/wpilibNewCommands/src/generated/main/java/edu/wpi/first/wpilibj2/command/button/CommandXboxController.java @@ -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 + package edu.wpi.first.wpilibj2.command.button; import edu.wpi.first.wpilibj.XboxController; @@ -38,98 +40,10 @@ public class CommandXboxController extends CommandGenericHID { } /** - * Constructs an event instance around the left bumper's digital signal. + * Constructs a Trigger instance around the A button's digital signal. * - * @return an event instance representing the left bumper's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - * @see #leftBumper(EventLoop) - */ - public Trigger leftBumper() { - return leftBumper(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the left bumper'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. - */ - public Trigger leftBumper(EventLoop loop) { - return m_hid.leftBumper(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the right bumper's digital signal. - * - * @return an event instance representing the right bumper's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - * @see #rightBumper(EventLoop) - */ - public Trigger rightBumper() { - return rightBumper(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the right bumper's digital signal. - * - * @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. - */ - public Trigger rightBumper(EventLoop loop) { - return m_hid.rightBumper(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the left stick button's digital signal. - * - * @return an event instance representing the left stick button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - * @see #leftStick(EventLoop) - */ - public Trigger leftStick() { - return leftStick(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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 left stick button's digital signal attached to the - * given loop. - */ - public Trigger leftStick(EventLoop loop) { - return m_hid.leftStick(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the right stick button's digital signal. - * - * @return an event instance representing the right stick button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - * @see #rightStick(EventLoop) - */ - public Trigger rightStick() { - return rightStick(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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 right stick button's digital signal attached to the - * given loop. - */ - public Trigger rightStick(EventLoop loop) { - return m_hid.rightStick(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the A button's digital signal. - * - * @return an event instance representing the A button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @return a Trigger instance representing the A button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. * @see #a(EventLoop) */ public Trigger a() { @@ -137,21 +51,21 @@ public class CommandXboxController extends CommandGenericHID { } /** - * Constructs an event instance around the A button's digital signal. + * Constructs a Trigger instance around the A 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 a Trigger instance representing the A button's digital signal attached + * to the given loop. */ public Trigger a(EventLoop loop) { return m_hid.a(loop).castTo(Trigger::new); } /** - * Constructs an event instance around the B button's digital signal. + * Constructs a Trigger instance around the B button's digital signal. * - * @return an event instance representing the B button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @return a Trigger instance representing the B button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. * @see #b(EventLoop) */ public Trigger b() { @@ -159,21 +73,21 @@ public class CommandXboxController extends CommandGenericHID { } /** - * Constructs an event instance around the B button's digital signal. + * Constructs a Trigger 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 B button's digital signal attached to the given - * loop. + * @return a Trigger instance representing the B button's digital signal attached + * to the given loop. */ public Trigger b(EventLoop loop) { return m_hid.b(loop).castTo(Trigger::new); } /** - * Constructs an event instance around the X button's digital signal. + * Constructs a Trigger instance around the X button's digital signal. * - * @return an event instance representing the X button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @return a Trigger instance representing the X button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. * @see #x(EventLoop) */ public Trigger x() { @@ -181,21 +95,21 @@ public class CommandXboxController extends CommandGenericHID { } /** - * Constructs an event instance around the X button's digital signal. + * Constructs a Trigger instance around the X 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 a Trigger instance representing the X button's digital signal attached + * to the given loop. */ public Trigger x(EventLoop loop) { return m_hid.x(loop).castTo(Trigger::new); } /** - * Constructs an event instance around the Y button's digital signal. + * Constructs a Trigger instance around the Y button's digital signal. * - * @return an event instance representing the Y button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @return a Trigger instance representing the Y button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. * @see #y(EventLoop) */ public Trigger y() { @@ -203,43 +117,65 @@ public class CommandXboxController extends CommandGenericHID { } /** - * Constructs an event instance around the Y button's digital signal. + * Constructs a Trigger 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 Y button's digital signal attached to the given - * loop. + * @return a Trigger instance representing the Y button's digital signal attached + * to the given loop. */ public Trigger y(EventLoop loop) { return m_hid.y(loop).castTo(Trigger::new); } /** - * Constructs an event instance around the start button's digital signal. + * Constructs a Trigger instance around the left bumper button's digital signal. * - * @return an event instance representing the start button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - * @see #start(EventLoop) + * @return a Trigger instance representing the left bumper button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #leftBumper(EventLoop) */ - public Trigger start() { - return start(CommandScheduler.getInstance().getDefaultButtonLoop()); + public Trigger leftBumper() { + return leftBumper(CommandScheduler.getInstance().getDefaultButtonLoop()); } /** - * Constructs an event instance around the start button's digital signal. + * Constructs a Trigger 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 start button's digital signal attached to the given - * loop. + * @return a Trigger instance representing the left bumper button's digital signal attached + * to the given loop. */ - public Trigger start(EventLoop loop) { - return m_hid.start(loop).castTo(Trigger::new); + public Trigger leftBumper(EventLoop loop) { + return m_hid.leftBumper(loop).castTo(Trigger::new); } /** - * Constructs an event instance around the back button's digital signal. + * Constructs a Trigger instance around the right bumper button's digital signal. * - * @return an event instance representing the back button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @return a Trigger instance representing the right bumper button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #rightBumper(EventLoop) + */ + public Trigger rightBumper() { + return rightBumper(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the right bumper button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the right bumper button's digital signal attached + * to the given loop. + */ + public Trigger rightBumper(EventLoop loop) { + return m_hid.rightBumper(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the back button's digital signal. + * + * @return a Trigger instance representing the back button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. * @see #back(EventLoop) */ public Trigger back() { @@ -247,19 +183,85 @@ public class CommandXboxController extends CommandGenericHID { } /** - * Constructs an event instance around the back button's digital signal. + * Constructs a Trigger 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 back button's digital signal attached to the given - * loop. + * @return a Trigger instance representing the back button's digital signal attached + * to the given loop. */ public Trigger back(EventLoop loop) { return m_hid.back(loop).castTo(Trigger::new); } /** - * Constructs a Trigger instance around the axis value of the left trigger. The returned trigger - * will be true when the axis value is greater than {@code threshold}. + * Constructs a Trigger instance around the start button's digital signal. + * + * @return a Trigger instance representing the start button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #start(EventLoop) + */ + public Trigger start() { + return start(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the start button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the start button's digital signal attached + * to the given loop. + */ + public Trigger start(EventLoop loop) { + return m_hid.start(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the left stick button's digital signal. + * + * @return a Trigger instance representing the left stick button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #leftStick(EventLoop) + */ + public Trigger leftStick() { + return leftStick(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the left stick button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the left stick button's digital signal attached + * to the given loop. + */ + public Trigger leftStick(EventLoop loop) { + return m_hid.leftStick(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger instance around the right stick button's digital signal. + * + * @return a Trigger instance representing the right stick button's digital signal attached + * to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. + * @see #rightStick(EventLoop) + */ + public Trigger rightStick() { + return rightStick(CommandScheduler.getInstance().getDefaultButtonLoop()); + } + + /** + * Constructs a Trigger instance around the right stick button's digital signal. + * + * @param loop the event loop instance to attach the event to. + * @return a Trigger instance representing the right stick button's digital signal attached + * to the given loop. + */ + public Trigger rightStick(EventLoop loop) { + return m_hid.rightStick(loop).castTo(Trigger::new); + } + + /** + * Constructs a Trigger 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 {@link Trigger} to be true. This value * should be in the range [0, 1] where 0 is the unpressed state of the axis. @@ -272,8 +274,8 @@ public class CommandXboxController extends CommandGenericHID { } /** - * Constructs a Trigger instance around the axis value of the left trigger. The returned trigger - * will be true when the axis value is greater than {@code threshold}. + * Constructs a Trigger 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 {@link Trigger} to be true. This value * should be in the range [0, 1] where 0 is the unpressed state of the axis. @@ -297,8 +299,8 @@ public class CommandXboxController extends CommandGenericHID { } /** - * Constructs a Trigger instance around the axis value of the right trigger. The returned trigger - * will be true when the axis value is greater than {@code threshold}. + * Constructs a Trigger 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 {@link Trigger} to be true. This value * should be in the range [0, 1] where 0 is the unpressed state of the axis. @@ -311,8 +313,8 @@ public class CommandXboxController extends CommandGenericHID { } /** - * Constructs a Trigger instance around the axis value of the right trigger. The returned trigger - * will be true when the axis value is greater than {@code threshold}. + * Constructs a Trigger 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 {@link Trigger} to be true. This value * should be in the range [0, 1] where 0 is the unpressed state of the axis. @@ -372,7 +374,7 @@ public class CommandXboxController extends CommandGenericHID { } /** - * Get the left trigger (LT) axis value of the controller. Note that this axis is bound to the + * 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. @@ -382,7 +384,7 @@ public class CommandXboxController extends CommandGenericHID { } /** - * Get the right trigger (RT) axis value of the controller. Note that this axis is bound to the + * 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. 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 81% 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 8388682f8b..e5418f845a 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; @@ -45,6 +47,10 @@ Trigger CommandPS4Controller::R2(frc::EventLoop* loop) const { return m_hid.R2(loop).CastTo(); } +Trigger CommandPS4Controller::Share(frc::EventLoop* loop) const { + return m_hid.Share(loop).CastTo(); +} + Trigger CommandPS4Controller::Options(frc::EventLoop* loop) const { return m_hid.Options(loop).CastTo(); } @@ -65,26 +71,26 @@ Trigger CommandPS4Controller::Touchpad(frc::EventLoop* loop) const { return m_hid.Touchpad(loop).CastTo(); } -double CommandPS4Controller::GetR2Axis() { - return m_hid.GetR2Axis(); +double CommandPS4Controller::GetLeftX() const { + return m_hid.GetLeftX(); } -double CommandPS4Controller::GetL2Axis() { - return m_hid.GetL2Axis(); -} - -double CommandPS4Controller::GetRightY() { - return m_hid.GetRightY(); -} - -double CommandPS4Controller::GetLeftY() { +double CommandPS4Controller::GetLeftY() const { return m_hid.GetLeftY(); } -double CommandPS4Controller::GetRightX() { +double CommandPS4Controller::GetRightX() const { return m_hid.GetRightX(); } -double CommandPS4Controller::GetLeftX() { - return m_hid.GetLeftX(); +double CommandPS4Controller::GetRightY() const { + return m_hid.GetRightY(); +} + +double CommandPS4Controller::GetL2Axis() const { + return m_hid.GetL2Axis(); +} + +double CommandPS4Controller::GetR2Axis() const { + return m_hid.GetR2Axis(); } 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 81% 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 d98cc23780..bb0c5b8e5b 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; @@ -45,6 +47,10 @@ Trigger CommandPS5Controller::R2(frc::EventLoop* loop) const { return m_hid.R2(loop).CastTo(); } +Trigger CommandPS5Controller::Create(frc::EventLoop* loop) const { + return m_hid.Create(loop).CastTo(); +} + Trigger CommandPS5Controller::Options(frc::EventLoop* loop) const { return m_hid.Options(loop).CastTo(); } @@ -65,26 +71,26 @@ Trigger CommandPS5Controller::Touchpad(frc::EventLoop* loop) const { return m_hid.Touchpad(loop).CastTo(); } -double CommandPS5Controller::GetR2Axis() { - return m_hid.GetR2Axis(); +double CommandPS5Controller::GetLeftX() const { + return m_hid.GetLeftX(); } -double CommandPS5Controller::GetL2Axis() { - return m_hid.GetL2Axis(); -} - -double CommandPS5Controller::GetRightY() { - return m_hid.GetRightY(); -} - -double CommandPS5Controller::GetLeftY() { +double CommandPS5Controller::GetLeftY() const { return m_hid.GetLeftY(); } -double CommandPS5Controller::GetRightX() { +double CommandPS5Controller::GetRightX() const { return m_hid.GetRightX(); } -double CommandPS5Controller::GetLeftX() { - return m_hid.GetLeftX(); +double CommandPS5Controller::GetRightY() const { + return m_hid.GetRightY(); +} + +double CommandPS5Controller::GetL2Axis() const { + return m_hid.GetL2Axis(); +} + +double CommandPS5Controller::GetR2Axis() const { + return m_hid.GetR2Axis(); } 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 96% 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 6568b8253f..ee032b1926 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,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/CommandStadiaController.h" using namespace frc2; @@ -13,22 +15,6 @@ frc::StadiaController& CommandStadiaController::GetHID() { return m_hid; } -Trigger CommandStadiaController::LeftBumper(frc::EventLoop* loop) const { - return m_hid.LeftBumper(loop).CastTo(); -} - -Trigger CommandStadiaController::RightBumper(frc::EventLoop* loop) const { - return m_hid.RightBumper(loop).CastTo(); -} - -Trigger CommandStadiaController::LeftStick(frc::EventLoop* loop) const { - return m_hid.LeftStick(loop).CastTo(); -} - -Trigger CommandStadiaController::RightStick(frc::EventLoop* loop) const { - return m_hid.RightStick(loop).CastTo(); -} - Trigger CommandStadiaController::A(frc::EventLoop* loop) const { return m_hid.A(loop).CastTo(); } @@ -45,6 +31,22 @@ Trigger CommandStadiaController::Y(frc::EventLoop* loop) const { return m_hid.Y(loop).CastTo(); } +Trigger CommandStadiaController::LeftBumper(frc::EventLoop* loop) const { + return m_hid.LeftBumper(loop).CastTo(); +} + +Trigger CommandStadiaController::RightBumper(frc::EventLoop* loop) const { + return m_hid.RightBumper(loop).CastTo(); +} + +Trigger CommandStadiaController::LeftStick(frc::EventLoop* loop) const { + return m_hid.LeftStick(loop).CastTo(); +} + +Trigger CommandStadiaController::RightStick(frc::EventLoop* loop) const { + return m_hid.RightStick(loop).CastTo(); +} + Trigger CommandStadiaController::Ellipses(frc::EventLoop* loop) const { return m_hid.Ellipses(loop).CastTo(); } @@ -57,20 +59,20 @@ Trigger CommandStadiaController::Stadia(frc::EventLoop* loop) const { return m_hid.Stadia(loop).CastTo(); } -Trigger CommandStadiaController::Google(frc::EventLoop* loop) const { - return m_hid.Google(loop).CastTo(); -} - -Trigger CommandStadiaController::Frame(frc::EventLoop* loop) const { - return m_hid.Frame(loop).CastTo(); +Trigger CommandStadiaController::RightTrigger(frc::EventLoop* loop) const { + return m_hid.RightTrigger(loop).CastTo(); } Trigger CommandStadiaController::LeftTrigger(frc::EventLoop* loop) const { return m_hid.LeftTrigger(loop).CastTo(); } -Trigger CommandStadiaController::RightTrigger(frc::EventLoop* loop) const { - return m_hid.RightTrigger(loop).CastTo(); +Trigger CommandStadiaController::Google(frc::EventLoop* loop) const { + return m_hid.Google(loop).CastTo(); +} + +Trigger CommandStadiaController::Frame(frc::EventLoop* loop) const { + return m_hid.Frame(loop).CastTo(); } double CommandStadiaController::GetLeftX() const { 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 81% 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 2e366d27e2..39fa015454 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; @@ -13,22 +15,6 @@ frc::XboxController& CommandXboxController::GetHID() { return m_hid; } -Trigger CommandXboxController::LeftBumper(frc::EventLoop* loop) const { - return m_hid.LeftBumper(loop).CastTo(); -} - -Trigger CommandXboxController::RightBumper(frc::EventLoop* loop) const { - return m_hid.RightBumper(loop).CastTo(); -} - -Trigger CommandXboxController::LeftStick(frc::EventLoop* loop) const { - return m_hid.LeftStick(loop).CastTo(); -} - -Trigger CommandXboxController::RightStick(frc::EventLoop* loop) const { - return m_hid.RightStick(loop).CastTo(); -} - Trigger CommandXboxController::A(frc::EventLoop* loop) const { return m_hid.A(loop).CastTo(); } @@ -45,6 +31,14 @@ Trigger CommandXboxController::Y(frc::EventLoop* loop) const { return m_hid.Y(loop).CastTo(); } +Trigger CommandXboxController::LeftBumper(frc::EventLoop* loop) const { + return m_hid.LeftBumper(loop).CastTo(); +} + +Trigger CommandXboxController::RightBumper(frc::EventLoop* loop) const { + return m_hid.RightBumper(loop).CastTo(); +} + Trigger CommandXboxController::Back(frc::EventLoop* loop) const { return m_hid.Back(loop).CastTo(); } @@ -53,36 +47,44 @@ Trigger CommandXboxController::Start(frc::EventLoop* loop) const { return m_hid.Start(loop).CastTo(); } +Trigger CommandXboxController::LeftStick(frc::EventLoop* loop) const { + return m_hid.LeftStick(loop).CastTo(); +} + +Trigger CommandXboxController::RightStick(frc::EventLoop* loop) const { + return m_hid.RightStick(loop).CastTo(); +} + Trigger CommandXboxController::LeftTrigger(double threshold, frc::EventLoop* loop) const { return m_hid.LeftTrigger(threshold, loop).CastTo(); } Trigger CommandXboxController::RightTrigger(double threshold, - frc::EventLoop* loop) const { + frc::EventLoop* loop) const { return m_hid.RightTrigger(threshold, loop).CastTo(); } -double CommandXboxController::GetRightTriggerAxis() { - return m_hid.GetRightTriggerAxis(); +double CommandXboxController::GetLeftX() const { + return m_hid.GetLeftX(); } -double CommandXboxController::GetLeftTriggerAxis() { - return m_hid.GetLeftTriggerAxis(); -} - -double CommandXboxController::GetRightY() { - return m_hid.GetRightY(); -} - -double CommandXboxController::GetLeftY() { - return m_hid.GetLeftY(); -} - -double CommandXboxController::GetRightX() { +double CommandXboxController::GetRightX() const { return m_hid.GetRightX(); } -double CommandXboxController::GetLeftX() { - return m_hid.GetLeftX(); +double CommandXboxController::GetLeftY() const { + return m_hid.GetLeftY(); +} + +double CommandXboxController::GetRightY() const { + return m_hid.GetRightY(); +} + +double CommandXboxController::GetLeftTriggerAxis() const { + return m_hid.GetLeftTriggerAxis(); +} + +double CommandXboxController::GetRightTriggerAxis() const { + return m_hid.GetRightTriggerAxis(); } diff --git a/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandPS4Controller.h b/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandPS4Controller.h new file mode 100644 index 0000000000..ac0920f1a5 --- /dev/null +++ b/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandPS4Controller.h @@ -0,0 +1,253 @@ +// 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/button/Trigger.h" +#include "frc2/command/CommandScheduler.h" +#include "frc2/command/button/CommandGenericHID.h" + +namespace frc2 { +/** + * A version of {@link frc::PS4Controller} with {@link Trigger} factories for + * command-based. + * + * @see frc::PS4Controller + */ +class CommandPS4Controller : public CommandGenericHID { + public: + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is + * plugged into. + */ + explicit CommandPS4Controller(int port); + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + frc::PS4Controller& GetHID(); + + /** + * Constructs a Trigger instance around the square button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the square button's + * digital signal attached to the given loop. + */ + Trigger Square(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the cross button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the cross button's + * digital signal attached to the given loop. + */ + Trigger Cross(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the circle button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the circle button's + * digital signal attached to the given loop. + */ + Trigger Circle(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the triangle button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the triangle button's + * digital signal attached to the given loop. + */ + Trigger Triangle(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the left trigger 1 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the left trigger 1 button's + * digital signal attached to the given loop. + */ + Trigger L1(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the right trigger 1 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the right trigger 1 button's + * digital signal attached to the given loop. + */ + Trigger R1(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the left trigger 2 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the left trigger 2 button's + * digital signal attached to the given loop. + */ + Trigger L2(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the right trigger 2 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the right trigger 2 button's + * digital signal attached to the given loop. + */ + Trigger R2(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the share button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the share button's + * digital signal attached to the given loop. + */ + Trigger Share(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the options button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the options button's + * digital signal attached to the given loop. + */ + Trigger Options(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the L3 (left stick) button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the L3 (left stick) button's + * digital signal attached to the given loop. + */ + Trigger L3(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the R3 (right stick) button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the R3 (right stick) button's + * digital signal attached to the given loop. + */ + Trigger R3(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the PlayStation button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the PlayStation button's + * digital signal attached to the given loop. + */ + Trigger PS(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the touchpad button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the touchpad button's + * digital signal attached to the given loop. + */ + Trigger Touchpad(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Get the X axis value of left side of the controller. + * + * @return The axis value. + */ + double GetLeftX() const; + + /** + * Get the Y axis value of left side of the controller. + * + * @return The axis value. + */ + double GetLeftY() const; + + /** + * Get the X axis value of right side of the controller. + * + * @return The axis value. + */ + double GetRightX() const; + + /** + * Get the Y axis value of right side of the controller. + * + * @return The axis value. + */ + double GetRightY() const; + + /** + * 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 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; + + private: + frc::PS4Controller m_hid; +}; +} // namespace frc2 diff --git a/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandPS5Controller.h b/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandPS5Controller.h new file mode 100644 index 0000000000..a92693ea83 --- /dev/null +++ b/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandPS5Controller.h @@ -0,0 +1,253 @@ +// 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/button/Trigger.h" +#include "frc2/command/CommandScheduler.h" +#include "frc2/command/button/CommandGenericHID.h" + +namespace frc2 { +/** + * A version of {@link frc::PS5Controller} with {@link Trigger} factories for + * command-based. + * + * @see frc::PS5Controller + */ +class CommandPS5Controller : public CommandGenericHID { + public: + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is + * plugged into. + */ + explicit CommandPS5Controller(int port); + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + frc::PS5Controller& GetHID(); + + /** + * Constructs a Trigger instance around the square button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the square button's + * digital signal attached to the given loop. + */ + Trigger Square(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the cross button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the cross button's + * digital signal attached to the given loop. + */ + Trigger Cross(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the circle button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the circle button's + * digital signal attached to the given loop. + */ + Trigger Circle(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the triangle button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the triangle button's + * digital signal attached to the given loop. + */ + Trigger Triangle(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the left trigger 1 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the left trigger 1 button's + * digital signal attached to the given loop. + */ + Trigger L1(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the right trigger 1 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the right trigger 1 button's + * digital signal attached to the given loop. + */ + Trigger R1(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the left trigger 2 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the left trigger 2 button's + * digital signal attached to the given loop. + */ + Trigger L2(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the right trigger 2 button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the right trigger 2 button's + * digital signal attached to the given loop. + */ + Trigger R2(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the create button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the create button's + * digital signal attached to the given loop. + */ + Trigger Create(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the options button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the options button's + * digital signal attached to the given loop. + */ + Trigger Options(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the L3 (left stick) button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the L3 (left stick) button's + * digital signal attached to the given loop. + */ + Trigger L3(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the R3 (right stick) button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the R3 (right stick) button's + * digital signal attached to the given loop. + */ + Trigger R3(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the PlayStation button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the PlayStation button's + * digital signal attached to the given loop. + */ + Trigger PS(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the touchpad button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the touchpad button's + * digital signal attached to the given loop. + */ + Trigger Touchpad(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Get the X axis value of left side of the controller. + * + * @return The axis value. + */ + double GetLeftX() const; + + /** + * Get the Y axis value of left side of the controller. + * + * @return The axis value. + */ + double GetLeftY() const; + + /** + * Get the X axis value of right side of the controller. + * + * @return The axis value. + */ + double GetRightX() const; + + /** + * Get the Y axis value of right side of the controller. + * + * @return The axis value. + */ + double GetRightY() const; + + /** + * 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 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; + + private: + frc::PS5Controller m_hid; +}; +} // namespace frc2 diff --git a/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandStadiaController.h b/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandStadiaController.h new file mode 100644 index 0000000000..cbd89c2ada --- /dev/null +++ b/wpilibNewCommands/src/generated/main/native/include/frc2/command/button/CommandStadiaController.h @@ -0,0 +1,249 @@ +// 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/button/Trigger.h" +#include "frc2/command/CommandScheduler.h" +#include "frc2/command/button/CommandGenericHID.h" + +namespace frc2 { +/** + * A version of {@link frc::StadiaController} with {@link Trigger} factories for + * command-based. + * + * @see frc::StadiaController + */ +class CommandStadiaController : public CommandGenericHID { + public: + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is + * plugged into. + */ + explicit CommandStadiaController(int port); + + /** + * Get the underlying GenericHID object. + * + * @return the wrapped GenericHID object + */ + frc::StadiaController& GetHID(); + + /** + * Constructs a Trigger instance around the A button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the A button's + * digital signal attached to the given loop. + */ + Trigger A(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the B button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the B button's + * digital signal attached to the given loop. + */ + Trigger B(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the X button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the X button's + * digital signal attached to the given loop. + */ + Trigger X(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Y button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the Y button's + * digital signal attached to the given loop. + */ + Trigger Y(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the left bumper button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the left bumper button's + * digital signal attached to the given loop. + */ + Trigger LeftBumper(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the right bumper button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the right bumper button's + * digital signal attached to the given loop. + */ + Trigger RightBumper(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the left stick button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the left stick button's + * digital signal attached to the given loop. + */ + Trigger LeftStick(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the right stick button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the right stick button's + * digital signal attached to the given loop. + */ + Trigger RightStick(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the ellipses button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the ellipses button's + * digital signal attached to the given loop. + */ + Trigger Ellipses(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the hamburger button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the hamburger button's + * digital signal attached to the given loop. + */ + Trigger Hamburger(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the stadia button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the stadia button's + * digital signal attached to the given loop. + */ + Trigger Stadia(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the right trigger button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the right trigger button's + * digital signal attached to the given loop. + */ + Trigger RightTrigger(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the left trigger button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the left trigger button's + * digital signal attached to the given loop. + */ + Trigger LeftTrigger(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the google button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the google button's + * digital signal attached to the given loop. + */ + Trigger Google(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the frame button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the frame button's + * digital signal attached to the given loop. + */ + Trigger Frame(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Get the X axis value of left side of the controller. + * + * @return The axis value. + */ + double GetLeftX() const; + + /** + * Get the X axis value of right side of the controller. + * + * @return The axis value. + */ + double GetRightX() const; + + /** + * Get the Y axis value of left side of the controller. + * + * @return The axis value. + */ + double GetLeftY() const; + + /** + * Get the Y axis value of right side of the controller. + * + * @return The axis value. + */ + double GetRightY() const; + + private: + frc::StadiaController m_hid; +}; +} // 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 58% 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 3b43d97dd6..9fb94f4825 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,10 +2,12 @@ // 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/button/Trigger.h" #include "frc2/command/CommandScheduler.h" #include "frc2/command/button/CommandGenericHID.h" @@ -34,114 +36,124 @@ class CommandXboxController : public CommandGenericHID { frc::XboxController& GetHID(); /** - * Constructs an event instance around the left bumper's digital signal. + * Constructs a Trigger instance around the A button'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 - * attached to the given loop. + * @return a Trigger instance representing the A button's + * digital signal attached to the given loop. + */ + Trigger A(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the B button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the B button's + * digital signal attached to the given loop. + */ + Trigger B(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the X button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the X button's + * digital signal attached to the given loop. + */ + Trigger X(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the Y button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the Y button's + * digital signal attached to the given loop. + */ + Trigger Y(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the left bumper button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the left bumper button's + * digital signal attached to the given loop. */ Trigger LeftBumper(frc::EventLoop* loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the right bumper's digital signal. + * Constructs a Trigger instance around the right bumper button'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 - * attached to the given loop. + * @return a Trigger instance representing the right bumper button's + * digital signal attached to the given loop. */ Trigger RightBumper(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * 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 left stick's digital signal - * attached to the given loop. - */ - Trigger LeftStick(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * 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 right stick's digital signal - * attached to the given loop. - */ - Trigger RightStick(frc::EventLoop* loop = CommandScheduler::GetInstance() .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the A button's digital signal. + * Constructs a Trigger instance around the back button'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 - * attached to the given loop. - */ - Trigger A(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the B button'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 - * attached to the given loop. - */ - Trigger B(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the X button'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 - * attached to the given loop. - */ - Trigger X(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the Y button'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 - * attached to the given loop. - */ - Trigger Y(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the back button'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 - * attached to the given loop. + * @return a Trigger instance representing the back button's + * digital signal attached to the given loop. */ Trigger Back(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; /** - * Constructs an event instance around the start button's digital signal. + * Constructs a Trigger instance around the start button'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 - * attached to the given loop. + * @return a Trigger instance representing the start button's + * digital signal attached to the given loop. */ Trigger Start(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the left stick button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the left stick button's + * digital signal attached to the given loop. + */ + Trigger LeftStick(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; + + /** + * Constructs a Trigger instance around the right stick button's + * digital signal. + * + * @param loop the event loop instance to attach the event to. Defaults to the + * CommandScheduler's default loop. + * @return a Trigger instance representing the right stick button's + * digital signal attached to the given loop. + */ + Trigger RightStick(frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** * Constructs a Trigger instance around the axis value of the left trigger. @@ -173,54 +185,53 @@ class CommandXboxController : public CommandGenericHID { * @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; - - /** - * 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]. - * - * @return The axis value. - */ - double GetRightTriggerAxis(); - - /** - * Get the left trigger (LT) 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 GetLeftTriggerAxis(); - - /** - * Get the Y axis value of right side of the controller. - * - * @return The axis value. - */ - double GetRightY(); - - /** - * Get the Y axis value of left side of the controller. - * - * @return The axis value. - */ - double GetLeftY(); - - /** - * Get the X axis value of right side of the controller. - * - * @return The axis value. - */ - double GetRightX(); + Trigger RightTrigger(double threshold = 0.5, + frc::EventLoop* loop = CommandScheduler::GetInstance() + .GetDefaultButtonLoop()) const; /** * Get the X axis value of left side of the controller. * * @return The axis value. */ - double GetLeftX(); + double GetLeftX() const; + + /** + * Get the X axis value of right side of the controller. + * + * @return The axis value. + */ + double GetRightX() const; + + /** + * Get the Y axis value of left side of the controller. + * + * @return The axis value. + */ + double GetLeftY() const; + + /** + * Get the Y axis value of right side of the controller. + * + * @return The axis value. + */ + double GetRightY() const; + + /** + * 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. + */ + double GetLeftTriggerAxis() 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. + */ + double GetRightTriggerAxis() const; private: frc::XboxController m_hid; diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandPS4Controller.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandPS4Controller.java deleted file mode 100644 index a7c0ac7c21..0000000000 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandPS4Controller.java +++ /dev/null @@ -1,389 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj2.command.button; - -import edu.wpi.first.wpilibj.PS4Controller; -import edu.wpi.first.wpilibj.event.EventLoop; -import edu.wpi.first.wpilibj2.command.CommandScheduler; - -/** - * A version of {@link PS4Controller} with {@link Trigger} factories for command-based. - * - * @see PS4Controller - */ -@SuppressWarnings("MethodName") -public class CommandPS4Controller extends CommandGenericHID { - private final PS4Controller m_hid; - - /** - * Construct an instance of a device. - * - * @param port The port index on the Driver Station that the device is plugged into. - */ - public CommandPS4Controller(int port) { - super(port); - m_hid = new PS4Controller(port); - } - - /** - * Get the underlying GenericHID object. - * - * @return the wrapped GenericHID object - */ - @Override - public PS4Controller getHID() { - return m_hid; - } - - /** - * Constructs an event instance around the L2 button's digital signal. - * - * @return an event instance representing the L2 button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger L2() { - return L2(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the L2 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. - */ - public Trigger L2(EventLoop loop) { - return m_hid.L2(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the R2 button's digital signal. - * - * @return an event instance representing the R2 button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger R2() { - return R2(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the R2 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. - */ - public Trigger R2(EventLoop loop) { - return m_hid.R2(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the L1 button's digital signal. - * - * @return an event instance representing the L1 button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger L1() { - return L1(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the L1 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. - */ - public Trigger L1(EventLoop loop) { - return m_hid.L1(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the R1 button's digital signal. - * - * @return an event instance representing the R1 button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger R1() { - return R1(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the R1 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. - */ - public Trigger R1(EventLoop loop) { - return m_hid.R1(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the L3 button's digital signal. - * - * @return an event instance representing the L3 button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger L3() { - return L3(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the L3 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. - */ - public Trigger L3(EventLoop loop) { - return m_hid.L3(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the R3 button's digital signal. - * - * @return an event instance representing the R3 button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger R3() { - return R3(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the R3 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. - */ - public Trigger R3(EventLoop loop) { - return m_hid.R3(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the square button's digital signal. - * - * @return an event instance representing the square button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger square() { - return square(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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. - */ - public Trigger square(EventLoop loop) { - return m_hid.square(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the cross button's digital signal. - * - * @return an event instance representing the cross button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger cross() { - return cross(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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. - */ - public Trigger cross(EventLoop loop) { - return m_hid.cross(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the triangle button's digital signal. - * - * @return an event instance representing the triangle button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger triangle() { - return triangle(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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. - */ - public Trigger triangle(EventLoop loop) { - return m_hid.triangle(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the circle button's digital signal. - * - * @return an event instance representing the circle button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger circle() { - return circle(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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. - */ - public Trigger circle(EventLoop loop) { - return m_hid.circle(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the share button's digital signal. - * - * @return an event instance representing the share button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger share() { - return share(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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. - */ - public Trigger share(EventLoop loop) { - return m_hid.share(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the PS button's digital signal. - * - * @return an event instance representing the PS button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger PS() { - return PS(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the PS 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. - */ - public Trigger PS(EventLoop loop) { - return m_hid.PS(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the options button's digital signal. - * - * @return an event instance representing the options button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger options() { - return options(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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. - */ - public Trigger options(EventLoop loop) { - return m_hid.options(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the touchpad's digital signal. - * - * @return an event instance representing the touchpad's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger touchpad() { - return touchpad(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the touchpad'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. - */ - public Trigger touchpad(EventLoop loop) { - return m_hid.touchpad(loop).castTo(Trigger::new); - } - - /** - * Get the X axis value of left side of the controller. - * - * @return the axis value. - */ - public double getLeftX() { - return m_hid.getLeftX(); - } - - /** - * Get the X axis value of right side of the controller. - * - * @return the axis value. - */ - public double getRightX() { - return m_hid.getRightX(); - } - - /** - * Get the Y axis value of left side of the controller. - * - * @return the axis value. - */ - public double getLeftY() { - return m_hid.getLeftY(); - } - - /** - * Get the Y axis value of right side of the controller. - * - * @return the axis value. - */ - public double getRightY() { - return m_hid.getRightY(); - } - - /** - * 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]. - * - * @return the axis value. - */ - public double getL2Axis() { - return m_hid.getL2Axis(); - } - - /** - * 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]. - * - * @return the axis value. - */ - public double getR2Axis() { - return m_hid.getR2Axis(); - } -} diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandPS5Controller.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandPS5Controller.java deleted file mode 100644 index 6b149d62b4..0000000000 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandPS5Controller.java +++ /dev/null @@ -1,389 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj2.command.button; - -import edu.wpi.first.wpilibj.PS5Controller; -import edu.wpi.first.wpilibj.event.EventLoop; -import edu.wpi.first.wpilibj2.command.CommandScheduler; - -/** - * A version of {@link PS5Controller} with {@link Trigger} factories for command-based. - * - * @see PS5Controller - */ -@SuppressWarnings("MethodName") -public class CommandPS5Controller extends CommandGenericHID { - private final PS5Controller m_hid; - - /** - * Construct an instance of a device. - * - * @param port The port index on the Driver Station that the device is plugged into. - */ - public CommandPS5Controller(int port) { - super(port); - m_hid = new PS5Controller(port); - } - - /** - * Get the underlying GenericHID object. - * - * @return the wrapped GenericHID object - */ - @Override - public PS5Controller getHID() { - return m_hid; - } - - /** - * Constructs an event instance around the L2 button's digital signal. - * - * @return an event instance representing the L2 button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger L2() { - return L2(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the L2 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. - */ - public Trigger L2(EventLoop loop) { - return m_hid.L2(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the R2 button's digital signal. - * - * @return an event instance representing the R2 button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger R2() { - return R2(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the R2 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. - */ - public Trigger R2(EventLoop loop) { - return m_hid.R2(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the L1 button's digital signal. - * - * @return an event instance representing the L1 button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger L1() { - return L1(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the L1 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. - */ - public Trigger L1(EventLoop loop) { - return m_hid.L1(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the R1 button's digital signal. - * - * @return an event instance representing the R1 button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger R1() { - return R1(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the R1 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. - */ - public Trigger R1(EventLoop loop) { - return m_hid.R1(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the L3 button's digital signal. - * - * @return an event instance representing the L3 button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger L3() { - return L3(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the L3 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. - */ - public Trigger L3(EventLoop loop) { - return m_hid.L3(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the R3 button's digital signal. - * - * @return an event instance representing the R3 button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger R3() { - return R3(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the R3 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. - */ - public Trigger R3(EventLoop loop) { - return m_hid.R3(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the square button's digital signal. - * - * @return an event instance representing the square button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger square() { - return square(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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. - */ - public Trigger square(EventLoop loop) { - return m_hid.square(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the cross button's digital signal. - * - * @return an event instance representing the cross button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger cross() { - return cross(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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. - */ - public Trigger cross(EventLoop loop) { - return m_hid.cross(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the triangle button's digital signal. - * - * @return an event instance representing the triangle button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger triangle() { - return triangle(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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. - */ - public Trigger triangle(EventLoop loop) { - return m_hid.triangle(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the circle button's digital signal. - * - * @return an event instance representing the circle button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger circle() { - return circle(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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. - */ - public Trigger circle(EventLoop loop) { - return m_hid.circle(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the create button's digital signal. - * - * @return an event instance representing the create button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger create() { - return create(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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. - */ - public Trigger create(EventLoop loop) { - return m_hid.create(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the PS button's digital signal. - * - * @return an event instance representing the PS button's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger PS() { - return PS(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the PS 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. - */ - public Trigger PS(EventLoop loop) { - return m_hid.PS(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the options button's digital signal. - * - * @return an event instance representing the options button's digital signal attached to the - * {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger options() { - return options(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * 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. - */ - public Trigger options(EventLoop loop) { - return m_hid.options(loop).castTo(Trigger::new); - } - - /** - * Constructs an event instance around the touchpad's digital signal. - * - * @return an event instance representing the touchpad's digital signal attached to the {@link - * CommandScheduler#getDefaultButtonLoop() default scheduler button loop}. - */ - public Trigger touchpad() { - return touchpad(CommandScheduler.getInstance().getDefaultButtonLoop()); - } - - /** - * Constructs an event instance around the touchpad'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. - */ - public Trigger touchpad(EventLoop loop) { - return m_hid.touchpad(loop).castTo(Trigger::new); - } - - /** - * Get the X axis value of left side of the controller. - * - * @return the axis value. - */ - public double getLeftX() { - return m_hid.getLeftX(); - } - - /** - * Get the X axis value of right side of the controller. - * - * @return the axis value. - */ - public double getRightX() { - return m_hid.getRightX(); - } - - /** - * Get the Y axis value of left side of the controller. - * - * @return the axis value. - */ - public double getLeftY() { - return m_hid.getLeftY(); - } - - /** - * Get the Y axis value of right side of the controller. - * - * @return the axis value. - */ - public double getRightY() { - return m_hid.getRightY(); - } - - /** - * 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]. - * - * @return the axis value. - */ - public double getL2Axis() { - return m_hid.getL2Axis(); - } - - /** - * 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]. - * - * @return the axis value. - */ - public double getR2Axis() { - return m_hid.getR2Axis(); - } -} diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandPS4Controller.h b/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandPS4Controller.h deleted file mode 100644 index 476828d26f..0000000000 --- a/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandPS4Controller.h +++ /dev/null @@ -1,239 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once -#include - -#include "Trigger.h" -#include "frc2/command/CommandScheduler.h" -#include "frc2/command/button/CommandGenericHID.h" - -namespace frc2 { -/** - * A version of {@link frc::PS4Controller} with {@link Trigger} factories for - * command-based. - * - * @see frc::PS4Controller - */ -class CommandPS4Controller : public frc2::CommandGenericHID { - public: - /** - * Construct an instance of a device. - * - * @param port The port index on the Driver Station that the device is plugged - * into. - */ - explicit CommandPS4Controller(int port); - - /** - * Get the underlying GenericHID object. - * - * @return the wrapped GenericHID object - */ - frc::PS4Controller& GetHID(); - - /** - * 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; - - /** - * Constructs an event instance around the square button'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 - * attached to the given loop. - */ - Trigger Square(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the cross button'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 - * attached to the given loop. - */ - Trigger Cross(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the circle button'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 - * attached to the given loop. - */ - Trigger Circle(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the triangle button'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 - * attached to the given loop. - */ - Trigger Triangle(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the L1 button'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 - * attached to the given loop. - */ - Trigger L1(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the R1 button'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 - * attached to the given loop. - */ - Trigger R1(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the L2 button'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 - * attached to the given loop. - */ - Trigger L2(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the R2 button'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 - * attached to the given loop. - */ - Trigger R2(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the options button'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 - * attached to the given loop. - */ - Trigger Options(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the L3 button'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 - * attached to the given loop. - */ - Trigger L3(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the R3 button'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 - * attached to the given loop. - */ - Trigger R3(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the PS button'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 - * attached to the given loop. - */ - Trigger PS(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the touchpad'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 touchpad's digital signal - * attached to the given loop. - */ - Trigger Touchpad(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) 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]. - * - * @return the axis value. - */ - double GetR2Axis(); - - /** - * 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]. - * - * @return the axis value. - */ - double GetL2Axis(); - - /** - * Get the Y axis value of right side of the controller. - * - * @return the axis value. - */ - double GetRightY(); - - /** - * Get the Y axis value of left side of the controller. - * - * @return the axis value. - */ - double GetLeftY(); - - /** - * Get the X axis value of right side of the controller. - * - * @return the axis value. - */ - double GetRightX(); - - /** - * Get the X axis value of left side of the controller. - * - * @return the axis value. - */ - double GetLeftX(); - - private: - frc::PS4Controller m_hid; -}; -} // namespace frc2 diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandPS5Controller.h b/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandPS5Controller.h deleted file mode 100644 index badf55cd50..0000000000 --- a/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandPS5Controller.h +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once -#include - -#include "Trigger.h" -#include "frc2/command/CommandScheduler.h" -#include "frc2/command/button/CommandGenericHID.h" - -namespace frc2 { -/** - * A version of {@link frc::PS5Controller} with {@link Trigger} factories for - * command-based. - * - * @see frc::PS5Controller - */ -class CommandPS5Controller : public CommandGenericHID { - public: - /** - * Construct an instance of a device. - * - * @param port The port index on the Driver Station that the device is plugged - * into. - */ - explicit CommandPS5Controller(int port); - - /** - * Get the underlying GenericHID object. - * - * @return the wrapped GenericHID object - */ - frc::PS5Controller& GetHID(); - - /** - * Constructs an event instance around the square button'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 - * attached to the given loop. - */ - Trigger Square(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the cross button'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 - * attached to the given loop. - */ - Trigger Cross(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the circle button'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 - * attached to the given loop. - */ - Trigger Circle(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the triangle button'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 - * attached to the given loop. - */ - Trigger Triangle(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the L1 button'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 - * attached to the given loop. - */ - Trigger L1(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the R1 button'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 - * attached to the given loop. - */ - Trigger R1(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the L2 button'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 - * attached to the given loop. - */ - Trigger L2(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the R2 button'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 - * attached to the given loop. - */ - Trigger R2(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the options button'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 - * attached to the given loop. - */ - Trigger Options(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the L3 button'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 - * attached to the given loop. - */ - Trigger L3(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the R3 button'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 - * attached to the given loop. - */ - Trigger R3(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the PS button'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 - * attached to the given loop. - */ - Trigger PS(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the touchpad'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 touchpad's digital signal - * attached to the given loop. - */ - Trigger Touchpad(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) 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]. - * - * @return the axis value. - */ - double GetR2Axis(); - - /** - * 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]. - * - * @return the axis value. - */ - double GetL2Axis(); - - /** - * Get the Y axis value of right side of the controller. - * - * @return the axis value. - */ - double GetRightY(); - - /** - * Get the Y axis value of left side of the controller. - * - * @return the axis value. - */ - double GetLeftY(); - - /** - * Get the X axis value of right side of the controller. - * - * @return the axis value. - */ - double GetRightX(); - - /** - * Get the X axis value of left side of the controller. - * - * @return the axis value. - */ - double GetLeftX(); - - private: - frc::PS5Controller m_hid; -}; -} // namespace frc2 diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandStadiaController.h b/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandStadiaController.h deleted file mode 100644 index 17e57a2dc2..0000000000 --- a/wpilibNewCommands/src/main/native/include/frc2/command/button/CommandStadiaController.h +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -#pragma once -#include - -#include "Trigger.h" -#include "frc2/command/CommandScheduler.h" -#include "frc2/command/button/CommandGenericHID.h" - -namespace frc2 { -/** - * A version of {@link frc::StadiaController} with {@link Trigger} factories for - * command-based. - * - * @see frc::StadiaController - */ -class CommandStadiaController : public CommandGenericHID { - public: - /** - * Construct an instance of a controller. - * - * @param port The port index on the Driver Station that the controller is - * plugged into. - */ - explicit CommandStadiaController(int port); - - /** - * Get the underlying GenericHID object. - * - * @return the wrapped GenericHID object - */ - frc::StadiaController& GetHID(); - - /** - * 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 left bumper's digital signal - * attached to the given loop. - */ - Trigger LeftBumper(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * 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 right bumper's digital signal - * attached to the given loop. - */ - Trigger RightBumper(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * 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 left stick's digital signal - * attached to the given loop. - */ - Trigger LeftStick(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * 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 right stick's digital signal - * attached to the given loop. - */ - Trigger RightStick(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the A button'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 - * attached to the given loop. - */ - Trigger A(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the B button'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 - * attached to the given loop. - */ - Trigger B(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the X button'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 - * attached to the given loop. - */ - Trigger X(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the Y button'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 - * attached to the given loop. - */ - Trigger Y(frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the ellipses button'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 - * attached to the given loop. - */ - Trigger Ellipses(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the hamburger button'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. - */ - Trigger Hamburger(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the stadia button'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 - * attached to the given loop. - */ - Trigger Stadia(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the google button'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 - * attached to the given loop. - */ - Trigger Google(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * Constructs an event instance around the frame button'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 - * attached to the given loop. - */ - Trigger Frame(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * 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 left trigger's digital signal - * attached to the given loop. - */ - Trigger LeftTrigger(frc::EventLoop* loop = CommandScheduler::GetInstance() - .GetDefaultButtonLoop()) const; - - /** - * 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 right trigger's digital signal - * attached to the given loop. - */ - Trigger RightTrigger( - frc::EventLoop* loop = - CommandScheduler::GetInstance().GetDefaultButtonLoop()) const; - - /** - * Get the X axis value of left side of the controller. - * - * @return the axis value - */ - double GetLeftX() const; - - /** - * Get the X axis value of right side of the controller. - * - * @return the axis value - */ - double GetRightX() const; - - /** - * Get the Y axis value of left side of the controller. - * - * @return the axis value - */ - double GetLeftY() const; - - /** - * Get the Y axis value of right side of the controller. - * - * @return the axis value - */ - double GetRightY() const; - - private: - frc::StadiaController m_hid; -}; -} // namespace frc2 diff --git a/wpilibc/CMakeLists.txt b/wpilibc/CMakeLists.txt index 17e7c991ad..186c9794b1 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 507ec445ad..3c9e8af704 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 0000000000..cfe54f7dee --- /dev/null +++ b/wpilibc/generate_hids.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python3 + +# 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. +import json +import os + +from jinja2 import Environment, FileSystemLoader + + +def write_controller_file(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) + write_controller_file(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) + write_controller_file(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) + write_controller_file(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) + write_controller_file(rootPath, controllerName, output) + + +if __name__ == "__main__": + main() diff --git a/wpilibc/publish.gradle b/wpilibc/publish.gradle index a565ba5f3b..aff50caa69 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 0000000000..05b5572453 --- /dev/null +++ b/wpilibc/src/generate/main/native/cpp/hid.cpp.jinja @@ -0,0 +1,92 @@ +// 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 +{% macro capitalize_first(string) -%} +{{ string[0]|capitalize + string[1:] }} +{%- endmacro %} +#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 sticks %} +double {{ ConsoleName }}Controller::Get{{ stick.NameParts|map("capitalize")|join }}() const { + return GetRawAxis(Axis::k{{ stick.NameParts|map("capitalize")|join }}); +} +{% endfor -%} +{% for trigger in triggers %} +double {{ ConsoleName }}Controller::Get{{ capitalize_first(trigger.name) }}Axis() const { + return GetRawAxis(Axis::k{{ capitalize_first(trigger.name) }}); +} +{% if trigger.UseThresholdMethods %} +BooleanEvent {{ ConsoleName }}Controller::{{ capitalize_first(trigger.name) }}(double threshold, EventLoop* loop) const { + return BooleanEvent(loop, [this, threshold] { return this->Get{{ capitalize_first(trigger.name) }}Axis() > threshold; }); +} + +BooleanEvent {{ ConsoleName }}Controller::{{ capitalize_first(trigger.name) }}(EventLoop* loop) const { + return this->{{ capitalize_first(trigger.name) }}(0.5, loop); +} +{% endif -%} +{% endfor -%} +{% for button in buttons %} +bool {{ ConsoleName }}Controller::Get{{ capitalize_first(button.name) }}Button() const { + return GetRawButton(Button::k{{ capitalize_first(button.name) }}); +} + +bool {{ ConsoleName }}Controller::Get{{ capitalize_first(button.name) }}ButtonPressed() { + return GetRawButtonPressed(Button::k{{ capitalize_first(button.name) }}); +} + +bool {{ ConsoleName }}Controller::Get{{ capitalize_first(button.name) }}ButtonReleased() { + return GetRawButtonReleased(Button::k{{ capitalize_first(button.name) }}); +} + +BooleanEvent {{ ConsoleName }}Controller::{{ capitalize_first(button.name) }}(EventLoop* loop) const { + return BooleanEvent(loop, [this]() { return this->Get{{ capitalize_first(button.name) }}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 0000000000..89ffd0cd3e --- /dev/null +++ b/wpilibc/src/generate/main/native/cpp/simulation/hidsim.cpp.jinja @@ -0,0 +1,42 @@ +// 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 +{% macro capitalize_first(string) -%} +{{ string[0]|capitalize + string[1:] }} +{%- endmacro %} +#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({{ sticks|length + triggers|length }}); + SetButtonCount({{ buttons|length }}); + SetPOVCount(1); +} + +{{ ConsoleName }}ControllerSim::{{ ConsoleName }}ControllerSim(int port) : GenericHIDSim{port} { + SetAxisCount({{ sticks|length + triggers|length }}); + SetButtonCount({{ buttons|length }}); + SetPOVCount(1); +} +{% for stick in sticks %} +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 triggers %} +void {{ ConsoleName }}ControllerSim::Set{{ capitalize_first(trigger.name) }}Axis(double value) { + SetRawAxis({{ ConsoleName }}Controller::Axis::k{{ capitalize_first(trigger.name) }}, value); +} +{% endfor -%} +{% for button in buttons %} +void {{ ConsoleName }}ControllerSim::Set{{ capitalize_first(button.name) }}Button(bool value) { + SetRawButton({{ ConsoleName }}Controller::Button::k{{ capitalize_first(button.name) }}, 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 0000000000..1d2ef67335 --- /dev/null +++ b/wpilibc/src/generate/main/native/include/frc/hid.h.jinja @@ -0,0 +1,208 @@ +// 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 +{% macro capitalize_first(string) -%} +{{ string[0]|capitalize + string[1:] }} +{%- endmacro %} +#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 sticks %} + /** + * 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 triggers %} + /** + * 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{{ capitalize_first(trigger.name) }}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 {{ capitalize_first(trigger.name) }}(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 {{ capitalize_first(trigger.name) }}(EventLoop* loop) const; +{% endif -%} +{% endfor -%} +{% for button in buttons %} + /** + * Read the value of the {{ button.DocName|default(button.name) }} button on the controller. + * + * @return The state of the button. + */ + bool Get{{ capitalize_first(button.name) }}Button() const; + + /** + * Whether the {{ button.DocName|default(button.name) }} button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool Get{{ capitalize_first(button.name) }}ButtonPressed(); + + /** + * Whether the {{ button.DocName|default(button.name) }} button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool Get{{ capitalize_first(button.name) }}ButtonReleased(); + + /** + * Constructs an event instance around the {{ button.DocName|default(button.name) }} 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.name) }} button's + * digital signal attached to the given loop. + */ + BooleanEvent {{ capitalize_first(button.name) }}(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 GetLeftBumperButton instead")]] + bool GetLeftBumper() const; + + /** + * Read the value of the right bumper (RB) button on the controller. + * + * @return the state of the button + */ + [[deprecated("Use GetRightBumperButton 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 GetLeftBumperButtonPressed 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 GetRightBumperButtonPressed 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 GetLeftBumperButtonReleased 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 GetRightBumperButtonReleased 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 %} + /// {{ capitalize_first(button.DocName|default(button.name)) }} button. + static constexpr int k{{ capitalize_first(button.name) }} = {{ button.value }}; +{%- endfor %} + }; + + /** Represents an axis on an {{ ConsoleName }}Controller. */ + struct Axis { +{%- for stick in sticks %} + /// {{ stick.NameParts|map("capitalize")|join(" ") }} axis. + static constexpr int k{{ stick.NameParts|map("capitalize")|join }} = {{ stick.value }}; +{%- endfor %} +{%- for trigger in triggers %} + /// {{ trigger.DocName|capitalize }}. + static constexpr int k{{ capitalize_first(trigger.name) }} = {{ trigger.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 0000000000..6d1ad27f31 --- /dev/null +++ b/wpilibc/src/generate/main/native/include/frc/simulation/hidsim.h.jinja @@ -0,0 +1,89 @@ +// 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 +{% macro capitalize_first(string) -%} +{{ string[0]|capitalize + string[1:] }} +{%- endmacro %} +#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 sticks %} + /** + * 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 triggers %} + /** + * Change the value of the {{ trigger.DocName }} axis on the controller. + * + * @param value the new value + */ + void Set{{ capitalize_first(trigger.name) }}Axis(double value); +{% endfor -%} +{% for button in buttons %} + /** + * Change the value of the {{ button.DocName|default(button.name) }} button on the controller. + * + * @param value the new value + */ + void Set{{ capitalize_first(button.name) }}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 e59e18cd3b..3e4b991d8c 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,6 +248,22 @@ BooleanEvent PS4Controller::PS(EventLoop* loop) const { return BooleanEvent(loop, [this]() { return this->GetPSButton(); }); } +bool PS4Controller::GetTouchpadButton() const { + return GetRawButton(Button::kTouchpad); +} + +bool PS4Controller::GetTouchpadButtonPressed() { + return GetRawButtonPressed(Button::kTouchpad); +} + +bool PS4Controller::GetTouchpadButtonReleased() { + return GetRawButtonReleased(Button::kTouchpad); +} + +BooleanEvent PS4Controller::Touchpad(EventLoop* loop) const { + return BooleanEvent(loop, [this]() { return this->GetTouchpadButton(); }); +} + bool PS4Controller::GetTouchpad() const { return GetRawButton(Button::kTouchpad); } @@ -257,7 +275,3 @@ bool PS4Controller::GetTouchpadPressed() { bool PS4Controller::GetTouchpadReleased() { return GetRawButtonReleased(Button::kTouchpad); } - -BooleanEvent PS4Controller::Touchpad(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetTouchpad(); }); -} 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 95685d677b..34df999abd 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,6 +248,22 @@ BooleanEvent PS5Controller::PS(EventLoop* loop) const { return BooleanEvent(loop, [this]() { return this->GetPSButton(); }); } +bool PS5Controller::GetTouchpadButton() const { + return GetRawButton(Button::kTouchpad); +} + +bool PS5Controller::GetTouchpadButtonPressed() { + return GetRawButtonPressed(Button::kTouchpad); +} + +bool PS5Controller::GetTouchpadButtonReleased() { + return GetRawButtonReleased(Button::kTouchpad); +} + +BooleanEvent PS5Controller::Touchpad(EventLoop* loop) const { + return BooleanEvent(loop, [this]() { return this->GetTouchpadButton(); }); +} + bool PS5Controller::GetTouchpad() const { return GetRawButton(Button::kTouchpad); } @@ -257,7 +275,3 @@ bool PS5Controller::GetTouchpadPressed() { bool PS5Controller::GetTouchpadReleased() { return GetRawButtonReleased(Button::kTouchpad); } - -BooleanEvent PS5Controller::Touchpad(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetTouchpad(); }); -} 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 4f8d666c54..54192f2071 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::GetLeftBumper() const { + return GetRawButton(Button::kLeftBumper); } -bool StadiaController::GetLeftTriggerButtonPressed() { - return GetRawButtonPressed(Button::kLeftTrigger); +bool StadiaController::GetRightBumper() const { + return GetRawButton(Button::kRightBumper); } -bool StadiaController::GetLeftTriggerButtonReleased() { - return GetRawButtonReleased(Button::kLeftTrigger); +bool StadiaController::GetLeftBumperPressed() { + return GetRawButtonPressed(Button::kLeftBumper); } -BooleanEvent StadiaController::LeftTrigger(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetLeftTriggerButton(); }); +bool StadiaController::GetRightBumperPressed() { + return GetRawButtonPressed(Button::kRightBumper); } -bool StadiaController::GetRightTriggerButton() const { - return GetRawButton(Button::kRightTrigger); +bool StadiaController::GetLeftBumperReleased() { + return GetRawButtonReleased(Button::kLeftBumper); } -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::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 f10419f400..a924ba21ef 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); } +BooleanEvent XboxController::LeftTrigger(double threshold, EventLoop* loop) const { + return BooleanEvent(loop, [this, threshold] { return this->GetLeftTriggerAxis() > threshold; }); +} + +BooleanEvent XboxController::LeftTrigger(EventLoop* loop) const { + return this->LeftTrigger(0.5, loop); +} + double XboxController::GetRightTriggerAxis() const { return GetRawAxis(Axis::kRightTrigger); } -bool XboxController::GetLeftBumper() const { - return GetRawButton(Button::kLeftBumper); +BooleanEvent XboxController::RightTrigger(double threshold, EventLoop* loop) const { + return BooleanEvent(loop, [this, threshold] { return this->GetRightTriggerAxis() > threshold; }); } -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); -} - -bool XboxController::GetLeftStickButtonReleased() { - return GetRawButtonReleased(Button::kLeftStick); -} - -bool XboxController::GetRightStickButtonReleased() { - return GetRawButtonReleased(Button::kRightStick); -} - -BooleanEvent XboxController::LeftStick(EventLoop* loop) const { - return BooleanEvent(loop, [this]() { return this->GetLeftStickButton(); }); -} - -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 fecac9dc36..9fb4f3fc99 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 e20105c4b3..4e3a095d8e 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 0000000000..73f4a504e0 --- /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 daf48b78ef..441058982e 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 881f8564f2..3614cc3fdf 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. * @@ -44,13 +46,6 @@ class PS4Controller : public GenericHID { */ double GetLeftX() const; - /** - * Get the X axis value of right side of the controller. - * - * @return the axis value. - */ - double GetRightX() const; - /** * Get the Y axis value of left side of the controller. * @@ -58,6 +53,13 @@ class PS4Controller : public GenericHID { */ double GetLeftY() const; + /** + * Get the X axis value of right side of the controller. + * + * @return the axis value. + */ + 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,13 +491,45 @@ class PS4Controller : public GenericHID { * * @return The state of the button. */ - bool GetTouchpad() const; + bool GetTouchpadButton() const; + /** + * Whether the touchpad button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetTouchpadButtonPressed(); + + /** + * Whether the touchpad button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetTouchpadButtonReleased(); + + /** + * 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 button's + * digital signal attached to the given loop. + */ + BooleanEvent Touchpad(EventLoop* loop) const; + + /** + * 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(); /** @@ -492,54 +537,42 @@ class PS4Controller : public GenericHID { * * @return Whether the touchpad was released since the last check. */ + [[deprecated("Use GetTouchpadButtonReleased instead")]] bool GetTouchpadReleased(); - /** - * Constructs an event instance around the touchpad'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. - */ - BooleanEvent Touchpad(EventLoop* loop) const; - - /** - * Represents a digital button on a PS4Controller. - */ + /** 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. 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 +582,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 e9d5235230..461a853a98 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. * @@ -44,13 +46,6 @@ class PS5Controller : public GenericHID { */ double GetLeftX() const; - /** - * Get the X axis value of right side of the controller. - * - * @return the axis value. - */ - double GetRightX() const; - /** * Get the Y axis value of left side of the controller. * @@ -58,6 +53,13 @@ class PS5Controller : public GenericHID { */ double GetLeftY() const; + /** + * Get the X axis value of right side of the controller. + * + * @return the axis value. + */ + 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,13 +491,45 @@ class PS5Controller : public GenericHID { * * @return The state of the button. */ - bool GetTouchpad() const; + bool GetTouchpadButton() const; + /** + * Whether the touchpad button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetTouchpadButtonPressed(); + + /** + * Whether the touchpad button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetTouchpadButtonReleased(); + + /** + * 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 button's + * digital signal attached to the given loop. + */ + BooleanEvent Touchpad(EventLoop* loop) const; + + /** + * 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(); /** @@ -492,24 +537,14 @@ class PS5Controller : public GenericHID { * * @return Whether the touchpad was released since the last check. */ + [[deprecated("Use GetTouchpadButtonReleased instead")]] bool GetTouchpadReleased(); - /** - * Constructs an event instance around the touchpad'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. - */ - BooleanEvent Touchpad(EventLoop* loop) const; - - /** - * Represents a digital button on a PS5Controller. - */ + /** 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 +562,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. 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 +582,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 68% rename from wpilibc/src/main/native/include/frc/StadiaController.h rename to wpilibc/src/generated/main/native/include/frc/StadiaController.h index cc9dbae981..6a10aa213b 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,151 +42,31 @@ 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. - * - * @return the state of the button - */ - bool GetLeftBumper() const; - - /** - * Read the value of the right bumper (RB) button on the controller. - * - * @return the state of the button - */ - bool GetRightBumper() const; - - /** - * Whether the left bumper (LB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check - */ - bool GetLeftBumperPressed(); - - /** - * Whether the right bumper (RB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check - */ - bool GetRightBumperPressed(); - - /** - * Whether the left bumper (LB) was released since the last check. - * - * @return Whether the button was released since the last check. - */ - bool GetLeftBumperReleased(); - - /** - * Whether the right bumper (RB) was released since the last check. - * - * @return Whether the button was released since the last check. - */ - bool GetRightBumperReleased(); - - /** - * Constructs an event instance around the left bumper's digital signal. - * - * @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. - */ - BooleanEvent LeftBumper(EventLoop* loop) const; - - /** - * Constructs an event instance around the right bumper'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. - */ - BooleanEvent RightBumper(EventLoop* loop) const; - - /** - * Read the value of the left stick button (LSB) on the controller. - * - * @return the state of the button - */ - bool GetLeftStickButton() const; - - /** - * Read the value of the right stick button (RSB) on the controller. - * - * @return the state of the button - */ - bool GetRightStickButton() const; - - /** - * Whether the left stick button (LSB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - bool GetLeftStickButtonPressed(); - - /** - * Whether the right stick button (RSB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check - */ - bool GetRightStickButtonPressed(); - - /** - * Whether the left stick button (LSB) was released since the last check. - * - * @return Whether the button was released since the last check. - */ - bool GetLeftStickButtonReleased(); - - /** - * Whether the right stick button (RSB) was released since the last check. - * - * @return Whether the button was released since the last check. - */ - bool GetRightStickButtonReleased(); - - /** - * Constructs an event instance around the left stick's digital signal. - * - * @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. - */ - BooleanEvent LeftStick(EventLoop* loop) const; - - /** - * Constructs an event instance around the right stick'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. - */ - BooleanEvent RightStick(EventLoop* loop) const; - /** * Read the value of the A button on the controller. * @@ -204,11 +89,12 @@ class StadiaController : public GenericHID { bool GetAButtonReleased(); /** - * Constructs an event instance around the A button's digital signal. + * Constructs an event instance around the A 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 A button's + * digital signal attached to the given loop. */ BooleanEvent A(EventLoop* loop) const; @@ -234,11 +120,12 @@ class StadiaController : public GenericHID { bool GetBButtonReleased(); /** - * Constructs an event instance around the B button'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 B button'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 B(EventLoop* loop) const; @@ -264,11 +151,12 @@ class StadiaController : public GenericHID { bool GetXButtonReleased(); /** - * Constructs an event instance around the X button's digital signal. + * Constructs an event instance around the X 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 X button's + * digital signal attached to the given loop. */ BooleanEvent X(EventLoop* loop) const; @@ -294,14 +182,139 @@ class StadiaController : public GenericHID { bool GetYButtonReleased(); /** - * Constructs an event instance around the Y button'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 Y button'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 Y(EventLoop* loop) const; + /** + * Read the value of the left bumper button on the controller. + * + * @return The state of the button. + */ + bool GetLeftBumperButton() const; + + /** + * Whether the left bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftBumperButtonPressed(); + + /** + * Whether the left bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftBumperButtonReleased(); + + /** + * 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 left bumper button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftBumper(EventLoop* loop) const; + + /** + * Read the value of the right bumper button on the controller. + * + * @return The state of the button. + */ + bool GetRightBumperButton() const; + + /** + * Whether the right bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightBumperButtonPressed(); + + /** + * Whether the right bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightBumperButtonReleased(); + + /** + * 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 right bumper button's + * digital signal attached to the given loop. + */ + BooleanEvent RightBumper(EventLoop* loop) const; + + /** + * Read the value of the left stick button on the controller. + * + * @return The state of the button. + */ + bool GetLeftStickButton() const; + + /** + * Whether the left stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftStickButtonPressed(); + + /** + * Whether the left stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftStickButtonReleased(); + + /** + * 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 left stick button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftStick(EventLoop* loop) const; + + /** + * Read the value of the right stick button on the controller. + * + * @return The state of the button. + */ + bool GetRightStickButton() const; + + /** + * Whether the right stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightStickButtonPressed(); + + /** + * Whether the right stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightStickButtonReleased(); + + /** + * 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 right stick button's + * digital signal attached to the given loop. + */ + 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,14 +399,77 @@ 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 right trigger button on the controller. + * + * @return The state of the button. + */ + bool GetRightTriggerButton() const; + + /** + * Whether the right trigger button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightTriggerButtonPressed(); + + /** + * Whether the right trigger button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightTriggerButtonReleased(); + + /** + * 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 right trigger button's + * digital signal attached to the given loop. + */ + BooleanEvent RightTrigger(EventLoop* loop) const; + + /** + * Read the value of the left trigger button on the controller. + * + * @return The state of the button. + */ + bool GetLeftTriggerButton() const; + + /** + * Whether the left trigger button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftTriggerButtonPressed(); + + /** + * Whether the left trigger button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftTriggerButtonReleased(); + + /** + * 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 left trigger button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftTrigger(EventLoop* loop) const; + /** * Read the value of the google button on the controller. * @@ -414,11 +492,12 @@ class StadiaController : public GenericHID { bool GetGoogleButtonReleased(); /** - * Constructs an event instance around the google 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 google 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 Google(EventLoop* loop) const; @@ -444,79 +523,64 @@ class StadiaController : public GenericHID { bool GetFrameButtonReleased(); /** - * Constructs an event instance around the frame 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 frame 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 Frame(EventLoop* loop) const; /** - * Read the value of the left trigger button on the controller. + * Read the value of the left bumper (LB) button on the controller. * - * @return The state of the button. + * @return the state of the button */ - bool GetLeftTriggerButton() const; + [[deprecated("Use GetLeftBumperButton instead")]] + bool GetLeftBumper() const; /** - * Whether the left trigger button was pressed since the last check. + * Read the value of the right bumper (RB) button on the controller. * - * @return Whether the button was pressed since the last check. + * @return the state of the button */ - bool GetLeftTriggerButtonPressed(); + [[deprecated("Use GetRightBumperButton instead")]] + bool GetRightBumper() const; /** - * Whether the left trigger button was released since the last check. + * Whether the left bumper (LB) was pressed since the last check. + * + * @return Whether the button was pressed since the last check + */ + [[deprecated("Use GetLeftBumperButtonPressed 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 GetRightBumperButtonPressed instead")]] + bool GetRightBumperPressed(); + + /** + * Whether the left bumper (LB) was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetLeftTriggerButtonReleased(); + [[deprecated("Use GetLeftBumperButtonReleased instead")]] + bool GetLeftBumperReleased(); /** - * 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 left trigger button's digital - * signal attached to the given loop. - */ - BooleanEvent LeftTrigger(EventLoop* loop) const; - - /** - * Read the value of the right trigger button on the controller. - * - * @return The state of the button. - */ - bool GetRightTriggerButton() const; - - /** - * Whether the right trigger button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - bool GetRightTriggerButtonPressed(); - - /** - * Whether the right trigger button was released since the last check. + * Whether the right bumper (RB) was released since the last check. * * @return Whether the button was released since the last check. */ - bool GetRightTriggerButtonReleased(); + [[deprecated("Use GetRightBumperButtonReleased instead")]] + bool GetRightBumperReleased(); - /** - * 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 right trigger button's digital - * signal attached to the given loop. - */ - BooleanEvent RightTrigger(EventLoop* loop) const; - - /** - * Represents a digital button on a StadiaController. - */ + /** Represents a digital button on an StadiaController. */ struct Button { /// A button. static constexpr int kA = 1; @@ -550,18 +614,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 4b720c1fc7..0a8357df16 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,166 +42,90 @@ 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. - * - * @return the state of the button - */ - bool GetLeftBumper() const; - - /** - * Read the value of the right bumper (RB) button on the controller. - * - * @return the state of the button - */ - bool GetRightBumper() const; - - /** - * Whether the left bumper (LB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check - */ - bool GetLeftBumperPressed(); - - /** - * Whether the right bumper (RB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check - */ - bool GetRightBumperPressed(); - - /** - * Whether the left bumper (LB) was released since the last check. - * - * @return Whether the button was released since the last check. - */ - bool GetLeftBumperReleased(); - - /** - * Whether the right bumper (RB) was released since the last check. - * - * @return Whether the button was released since the last check. - */ - bool GetRightBumperReleased(); - - /** - * Constructs an event instance around the left bumper's digital signal. - * + * 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 representing the left bumper's digital signal - * attached to the given loop. + * @return an event instance that is true when the right trigger's axis + * exceeds the provided threshold, attached to the given event loop */ - BooleanEvent LeftBumper(EventLoop* loop) const; + BooleanEvent RightTrigger(double threshold, EventLoop* loop) const; /** - * Constructs an event instance around the right bumper's digital signal. - * + * 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 representing the right bumper's digital signal - * attached to the given loop. + * @return an event instance that is true when the right trigger's axis + * exceeds 0.5, attached to the given event loop */ - BooleanEvent RightBumper(EventLoop* loop) const; - - /** - * Read the value of the left stick button (LSB) on the controller. - * - * @return the state of the button - */ - bool GetLeftStickButton() const; - - /** - * Read the value of the right stick button (RSB) on the controller. - * - * @return the state of the button - */ - bool GetRightStickButton() const; - - /** - * Whether the left stick button (LSB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - bool GetLeftStickButtonPressed(); - - /** - * Whether the right stick button (RSB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check - */ - bool GetRightStickButtonPressed(); - - /** - * Whether the left stick button (LSB) was released since the last check. - * - * @return Whether the button was released since the last check. - */ - bool GetLeftStickButtonReleased(); - - /** - * Whether the right stick button (RSB) was released since the last check. - * - * @return Whether the button was released since the last check. - */ - bool GetRightStickButtonReleased(); - - /** - * Constructs an event instance around the left stick's digital signal. - * - * @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. - */ - BooleanEvent LeftStick(EventLoop* loop) const; - - /** - * Constructs an event instance around the right stick'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. - */ - BooleanEvent RightStick(EventLoop* loop) const; + BooleanEvent RightTrigger(EventLoop* loop) const; /** * Read the value of the A button on the controller. @@ -224,11 +149,12 @@ class XboxController : public GenericHID { bool GetAButtonReleased(); /** - * Constructs an event instance around the A button's digital signal. + * Constructs an event instance around the A 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 A button's + * digital signal attached to the given loop. */ BooleanEvent A(EventLoop* loop) const; @@ -254,11 +180,12 @@ class XboxController : public GenericHID { bool GetBButtonReleased(); /** - * Constructs an event instance around the B button'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 B button'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 B(EventLoop* loop) const; @@ -284,11 +211,12 @@ class XboxController : public GenericHID { bool GetXButtonReleased(); /** - * Constructs an event instance around the X button's digital signal. + * Constructs an event instance around the X 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 X button's + * digital signal attached to the given loop. */ BooleanEvent X(EventLoop* loop) const; @@ -314,14 +242,77 @@ class XboxController : public GenericHID { bool GetYButtonReleased(); /** - * Constructs an event instance around the Y button'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 Y button'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 Y(EventLoop* loop) const; + /** + * Read the value of the left bumper button on the controller. + * + * @return The state of the button. + */ + bool GetLeftBumperButton() const; + + /** + * Whether the left bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetLeftBumperButtonPressed(); + + /** + * Whether the left bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetLeftBumperButtonReleased(); + + /** + * 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 left bumper button's + * digital signal attached to the given loop. + */ + BooleanEvent LeftBumper(EventLoop* loop) const; + + /** + * Read the value of the right bumper button on the controller. + * + * @return The state of the button. + */ + bool GetRightBumperButton() const; + + /** + * Whether the right bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightBumperButtonPressed(); + + /** + * Whether the right bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightBumperButtonReleased(); + + /** + * 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 right bumper button's + * digital signal attached to the given loop. + */ + BooleanEvent RightBumper(EventLoop* loop) const; + /** * Read the value of the back button on the controller. * @@ -344,11 +335,12 @@ class XboxController : public GenericHID { bool GetBackButtonReleased(); /** - * Constructs an event instance around the back 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 back 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 Back(EventLoop* loop) const; @@ -374,91 +366,158 @@ class XboxController : public GenericHID { bool GetStartButtonReleased(); /** - * Constructs an event instance around the start 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 start 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 Start(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 stick button on the controller. + * + * @return The state of the button. */ - BooleanEvent LeftTrigger(double threshold, EventLoop* loop) const; + bool GetLeftStickButton() 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 + * Whether the left stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. */ - BooleanEvent LeftTrigger(EventLoop* loop) const; + bool GetLeftStickButtonPressed(); /** - * 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 stick button was released since the last check. + * + * @return Whether the button was released since the last check. */ - BooleanEvent RightTrigger(double threshold, EventLoop* loop) const; + bool GetLeftStickButtonReleased(); /** - * 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. + * 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 that is true when the right trigger's axis - * exceeds 0.5, attached to the given event loop + * @return an event instance representing the left stick button's + * digital signal attached to the given loop. */ - BooleanEvent RightTrigger(EventLoop* loop) const; + BooleanEvent LeftStick(EventLoop* loop) const; + + /** + * Read the value of the right stick button on the controller. + * + * @return The state of the button. + */ + bool GetRightStickButton() const; + + /** + * Whether the right stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + bool GetRightStickButtonPressed(); + + /** + * Whether the right stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + bool GetRightStickButtonReleased(); + + /** + * 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 right stick button's + * digital signal attached to the given loop. + */ + BooleanEvent RightStick(EventLoop* loop) const; + + /** + * Read the value of the left bumper (LB) button on the controller. + * + * @return the state of the button + */ + [[deprecated("Use GetLeftBumperButton instead")]] + bool GetLeftBumper() const; + + /** + * Read the value of the right bumper (RB) button on the controller. + * + * @return the state of the button + */ + [[deprecated("Use GetRightBumperButton 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 GetLeftBumperButtonPressed 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 GetRightBumperButtonPressed 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 GetLeftBumperButtonReleased 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 GetRightBumperButtonReleased 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 a599ad98d6..79dd5ecec7 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. - * - * @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 X value of the controller's joystick. + * + * @param value the new value + */ + void SetRightX(double value); + + /** + * 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 6b9e2c7b2b..e3762bbf20 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. - * - * @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 X value of the controller's joystick. + * + * @param value the new value + */ + void SetRightX(double value); + + /** + * 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 0000000000..532328ab62 --- /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 e609ff04ab..06d6ad6d6e 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,52 +34,123 @@ 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 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 back button on the controller. + * + * @param value the new value + */ + void SetBackButton(bool value); + + /** + * Change the value of the start button on the controller. + * + * @param value the new value + */ + void SetStartButton(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 left bumper value of the joystick. * * @param value the new value */ + [[deprecated("Use SetLeftBumperButton instead")]] void SetLeftBumper(bool value); /** @@ -85,63 +158,9 @@ class XboxControllerSim : public GenericHIDSim { * * @param value the new value */ + [[deprecated("Use SetRightBumperButton instead")]] void SetRightBumper(bool value); - /** - * Change the left button value of the joystick. - * - * @param value the new value - */ - void SetLeftStickButton(bool value); - - /** - * Change the right button value of the joystick. - * - * @param value the new value - */ - void SetRightStickButton(bool value); - - /** - * Change the value of the A button. - * - * @param value the new value - */ - void SetAButton(bool value); - - /** - * Change the value of the B button. - * - * @param value the new value - */ - void SetBButton(bool value); - - /** - * Change the value of the X button. - * - * @param value the new value - */ - void SetXButton(bool value); - - /** - * Change the value of the Y button. - * - * @param value the new value - */ - void SetYButton(bool value); - - /** - * Change the value of the Back button. - * - * @param value the new value - */ - void SetBackButton(bool value); - - /** - * Change the value of the Start button. - * - * @param value the new value - */ - void SetStartButton(bool value); }; } // namespace sim diff --git a/wpilibc/src/test/native/cpp/PS4ControllerTest.cpp b/wpilibc/src/test/native/cpp/PS4ControllerTest.cpp index 4284aed36c..42d2b9dd52 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 67dd0caa98..13ae7709ef 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 3798fde51c..fdc9866d72 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 9b91e205c6..01d3db6abe 100644 --- a/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp @@ -110,7 +110,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 7b982b581b..08074f8cf1 100644 --- a/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp @@ -110,7 +110,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 5d413ab26b..b0a9ed3a92 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 d3bab6e795..2be14fd49f 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/CMakeLists.txt b/wpilibj/CMakeLists.txt index 684c26062b..2418b6d3ed 100644 --- a/wpilibj/CMakeLists.txt +++ b/wpilibj/CMakeLists.txt @@ -17,7 +17,7 @@ if(WITH_JAVA) configure_file(src/generate/WPILibVersion.java.in WPILibVersion.java) - file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java) + file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java src/generated/main/java/*.java) file(GLOB EJML_JARS "${WPILIB_BINARY_DIR}/wpimath/thirdparty/ejml/*.jar") file(GLOB JACKSON_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/jackson/*.jar") @@ -49,14 +49,22 @@ endif() if(WITH_JAVA_SOURCE) find_package(Java REQUIRED) include(UseJava) - file(GLOB WPILIBJ_SOURCES src/main/java/edu/wpi/first/wpilibj/*.java) + file( + GLOB WPILIBJ_SOURCES + src/main/java/edu/wpi/first/wpilibj/*.java + src/generated/main/java/edu/wpi/first/wpilibj/*.java + ) file(GLOB WPILIBJ_COUNTER_SOURCES src/main/java/edu/wpi/first/wpilibj/counter/*.java) file(GLOB WPILIBJ_DRIVE_SOURCES src/main/java/edu/wpi/first/wpilibj/drive/*.java) file(GLOB WPILIBJ_EVENT_SOURCES src/main/java/edu/wpi/first/wpilibj/event/*.java) file(GLOB WPILIBJ_INTERFACES_SOURCES src/main/java/edu/wpi/first/wpilibj/interfaces/*.java) file(GLOB WPILIBJ_MOTORCONTROL_SOURCES src/main/java/edu/wpi/first/wpilibj/motorcontrol*.java) file(GLOB WPILIBJ_SHUFFLEBOARD_SOURCES src/main/java/edu/wpi/first/wpilibj/shuffleboard*.java) - file(GLOB WPILIBJ_SIMULATION_SOURCES src/main/java/edu/wpi/first/wpilibj/simulation*.java) + file( + GLOB WPILIBJ_SIMULATION_SOURCES + src/main/java/edu/wpi/first/wpilibj/simulation/*.java + src/generated/main/java/edu/wpi/first/wpilibj/simulation/*.java + ) file(GLOB WPILIBJ_SMARTDASHBOARD_SOURCES src/main/java/edu/wpi/first/wpilibj/*.java) file( GLOB WPILIBJ_UTIL_SOURCES diff --git a/wpilibj/build.gradle b/wpilibj/build.gradle index 5105f3e4e4..d397f93480 100644 --- a/wpilibj/build.gradle +++ b/wpilibj/build.gradle @@ -50,6 +50,7 @@ gradle.taskGraph.addTaskExecutionGraphListener { graph -> } sourceSets.main.java.srcDir "${buildDir}/generated/java/" +sourceSets.main.java.srcDir "${projectDir}/src/generated/main/java" compileJava { dependsOn generateJavaVersion diff --git a/wpilibj/generate_hids.py b/wpilibj/generate_hids.py new file mode 100755 index 0000000000..98f97dd6c0 --- /dev/null +++ b/wpilibj/generate_hids.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 + +# 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. +import json +import os + +from jinja2 import Environment, FileSystemLoader + + +def write_controller_file(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(f"{dirname}/src/generate/hids.json") as f: + controllers = json.load(f) + + # Java files + env = Environment( + loader=FileSystemLoader(f"{dirname}/src/generate/"), + autoescape=False, + keep_trailing_newline=True, + ) + rootPath = f"{dirname}/src/generated/main/java/edu/wpi/first/wpilibj" + template = env.get_template("hid.java.jinja") + for controller in controllers: + controllerName = os.path.basename(f"{controller['ConsoleName']}Controller.java") + output = template.render(controller) + write_controller_file(rootPath, controllerName, output) + + # Java simulation files + rootPath = f"{dirname}/src/generated/main/java/edu/wpi/first/wpilibj/simulation" + template = env.get_template("hidsim.java.jinja") + for controller in controllers: + controllerName = os.path.basename( + f"{controller['ConsoleName']}ControllerSim.java" + ) + output = template.render(controller) + write_controller_file(rootPath, controllerName, output) + + +if __name__ == "__main__": + main() diff --git a/wpilibj/src/generate/hid.java.jinja b/wpilibj/src/generate/hid.java.jinja new file mode 100644 index 0000000000..84dbd8c3e8 --- /dev/null +++ b/wpilibj/src/generate/hid.java.jinja @@ -0,0 +1,289 @@ +// 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 ./wpilibj/generate_hids.py. DO NOT MODIFY +{% macro capitalize_first(string) -%} +{{ string[0]|capitalize + string[1:] }} +{%- endmacro %} +package edu.wpi.first.wpilibj; + +{{ "// " if SkipReporting }}import edu.wpi.first.hal.FRCNetComm.tResourceType; +{{ "// " if SkipReporting }}import edu.wpi.first.hal.HAL; +import edu.wpi.first.wpilibj.event.BooleanEvent; +import edu.wpi.first.wpilibj.event.EventLoop; + +/** + * 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. + */ +public class {{ ConsoleName }}Controller extends GenericHID { + /** Represents a digital button on a {{ ConsoleName }}Controller. */ + public enum Button { +{%- for button in buttons %} + /** {{ capitalize_first(button.DocName|default(button.name)) }} button. */ + k{{ capitalize_first(button.name) }}({{ button.value }}){{ ";" if loop.last else ","}} +{%- endfor %} + + /** Button value. */ + public final int value; + + Button(int value) { + this.value = value; + } + + /** + * Get the human-friendly name of the button, matching the relevant methods. This is done by + * stripping the leading `k`, and appending `Button`. + * + *

Primarily used for automated unit tests. + * + * @return the human-friendly name of the button. + */ + @Override + public String toString() { + // Remove leading `k` + return this.name().substring(1) + "Button"; + } + } + + /** Represents an axis on an {{ ConsoleName }}Controller. */ + public enum Axis { +{%- for stick in sticks %} + /** {{ stick.NameParts|map("capitalize")|join(" ") }} axis. */ + k{{ stick.NameParts|map("capitalize")|join }}({{ stick.value }}){{ "," if triggers|length > 0 or not loop.last else ";"}} +{%- endfor %} +{%- for trigger in triggers %} + /** {{ trigger.DocName|capitalize }}. */ + k{{ capitalize_first(trigger.name) }}({{ trigger.value }}){{ ";" if loop.last else ","}} +{%- endfor %} + + /** Axis value. */ + public final int value; + + Axis(int value) { + this.value = value; + } + + /** + * Get the human-friendly name of the axis, matching the relevant methods. This is done by + * stripping the leading `k`, and appending `Axis` if the name ends with `{{ AxisNameSuffix }}`. + * + *

Primarily used for automated unit tests. + * + * @return the human-friendly name of the axis. + */ + @Override + public String toString() { + var name = this.name().substring(1); // Remove leading `k` + if (name.endsWith("{{ AxisNameSuffix }}")) { + return name + "Axis"; + } + return name; + } + } + + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into (0-5). + */ + public {{ ConsoleName }}Controller(final int port) { + super(port); + {{ "// " if SkipReporting }}HAL.report(tResourceType.kResourceType_{{ ConsoleName }}Controller, port + 1); + } +{% for stick in sticks %} + /** + * Get the {{ stick.NameParts[1] }} axis value of {{ stick.NameParts[0] }} side of the controller. + * + * @return The axis value. + */ + public double get{{ stick.NameParts|map("capitalize")|join }}() { + return getRawAxis(Axis.k{{ stick.NameParts|map("capitalize")|join }}.value); + } +{% endfor -%} +{% for trigger in triggers %} + /** + * 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. + */ + public double get{{ capitalize_first(trigger.name) }}Axis() { + return getRawAxis(Axis.k{{ capitalize_first(trigger.name) }}.value); + } +{% 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 {@link BooleanEvent} 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 + */ + public BooleanEvent {{ trigger.name }}(double threshold, EventLoop loop) { + return new BooleanEvent(loop, () -> get{{ capitalize_first(trigger.name) }}Axis() > threshold); + } + + /** + * 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 the provided + * threshold, attached to the given event loop + */ + public BooleanEvent {{ trigger.name }}(EventLoop loop) { + return {{ trigger.name }}(0.5, loop); + } +{% endif -%} +{% endfor -%} +{% for button in buttons %} + /** + * Read the value of the {{ button.DocName|default(button.name) }} button on the controller. + * + * @return The state of the button. + */ + public boolean get{{ capitalize_first(button.name) }}Button() { + return getRawButton(Button.k{{ capitalize_first(button.name) }}.value); + } + + /** + * Whether the {{ button.DocName|default(button.name) }} button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean get{{ capitalize_first(button.name) }}ButtonPressed() { + return getRawButtonPressed(Button.k{{ capitalize_first(button.name) }}.value); + } + + /** + * Whether the {{ button.DocName|default(button.name) }} button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean get{{ capitalize_first(button.name) }}ButtonReleased() { + return getRawButtonReleased(Button.k{{ capitalize_first(button.name) }}.value); + } + + /** + * Constructs an event instance around the {{ button.DocName|default(button.name) }} 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.name) }} button's digital signal + * attached to the given loop. + */ + public BooleanEvent {{ button.name }}(EventLoop loop) { + return new BooleanEvent(loop, this::get{{ capitalize_first(button.name) }}Button); + } +{% 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 {@link getLeftBumperButton} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getLeftBumper() { + return getRawButton(Button.kLeftBumper.value); + } + + /** + * Read the value of the right bumper (RB) button on the controller. + * + * @return The state of the button. + * @deprecated Use {@link getRightBumperButton} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getRightBumper() { + return getRawButton(Button.kRightBumper.value); + } + + /** + * Whether the left bumper (LB) was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + * @deprecated Use {@link getLeftBumperButtonPressed} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getLeftBumperPressed() { + return getRawButtonPressed(Button.kLeftBumper.value); + } + + /** + * Whether the right bumper (RB) was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + * @deprecated Use {@link getRightBumperButtonPressed} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getRightBumperPressed() { + return getRawButtonPressed(Button.kRightBumper.value); + } + + /** + * Whether the left bumper (LB) was released since the last check. + * + * @return Whether the button was released since the last check. + * @deprecated Use {@link getLeftBumperButtonReleased} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getLeftBumperReleased() { + return getRawButtonReleased(Button.kLeftBumper.value); + } + + /** + * Whether the right bumper (RB) was released since the last check. + * + * @return Whether the button was released since the last check. + * @deprecated Use {@link getRightBumperButtonReleased} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getRightBumperReleased() { + return getRawButtonReleased(Button.kRightBumper.value); + } +{% elif ConsoleName == "PS4" or ConsoleName == "PS5" %} + /** + * Read the value of the touchpad on the controller. + * + * @return The state of the touchpad. + * @deprecated Use {@link getTouchpadButton} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getTouchpad() { + return getRawButton(Button.kTouchpad.value); + } + + /** + * Whether the touchpad was pressed since the last check. + * + * @return Whether the touchpad was pressed since the last check. + * @deprecated Use {@link getTouchpadButtonPressed} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getTouchpadPressed() { + return getRawButtonPressed(Button.kTouchpad.value); + } + + /** + * Whether the touchpad was released since the last check. + * + * @return Whether the touchpad was released since the last check. + * @deprecated Use {@link getTouchpadButtonReleased} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getTouchpadReleased() { + return getRawButtonReleased(Button.kTouchpad.value); + } +{% endif -%} +} diff --git a/wpilibj/src/generate/hids.json b/wpilibj/src/generate/hids.json new file mode 100644 index 0000000000..f27806458a --- /dev/null +++ b/wpilibj/src/generate/hids.json @@ -0,0 +1,440 @@ +[ + { + "ConsoleName": "Xbox", + "Manufacturer": "Microsoft", + "SkipReporting": false, + "AxisNameSuffix": "Trigger", + "buttons": [ + { + "name": "a", + "value": 1, + "DocName": "A" + }, + { + "name": "b", + "value": 2, + "DocName": "B" + }, + { + "name": "x", + "value": 3, + "DocName": "X" + }, + { + "name": "y", + "value": 4, + "DocName": "Y" + }, + { + "name": "leftBumper", + "value": 5, + "DocName": "left bumper" + }, + { + "name": "rightBumper", + "value": 6, + "DocName": "right bumper" + }, + { + "name": "back", + "value": 7 + }, + { + "name": "start", + "value": 8 + }, + { + "name": "leftStick", + "value": 9, + "DocName": "left stick" + }, + { + "name": "rightStick", + "value": 10, + "DocName": "right stick" + } + ], + "sticks": [ + { + "NameParts": [ + "left", + "X" + ], + "value": 0 + }, + { + "NameParts": [ + "right", + "X" + ], + "value": 4 + }, + { + "NameParts": [ + "left", + "Y" + ], + "value": 1 + }, + { + "NameParts": [ + "right", + "Y" + ], + "value": 5 + } + ], + "triggers": [ + { + "name": "leftTrigger", + "value": 2, + "DocName": "left trigger", + "UseThresholdMethods": true + }, + { + "name": "rightTrigger", + "value": 3, + "DocName": "right trigger", + "UseThresholdMethods": true + } + ] + }, + { + "ConsoleName": "PS4", + "Manufacturer": "Sony", + "SkipReporting": false, + "AxisNameSuffix": "2", + "buttons": [ + { + "name": "square", + "value": 1 + }, + { + "name": "cross", + "value": 2 + }, + { + "name": "circle", + "value": 3 + }, + { + "name": "triangle", + "value": 4 + }, + { + "name": "L1", + "value": 5, + "DocName": "left trigger 1" + }, + { + "name": "R1", + "value": 6, + "DocName": "right trigger 1" + }, + { + "name": "L2", + "value": 7, + "DocName": "left trigger 2" + }, + { + "name": "R2", + "value": 8, + "DocName": "right trigger 2" + }, + { + "name": "share", + "value": 9 + }, + { + "name": "options", + "value": 10 + }, + { + "name": "L3", + "value": 11, + "DocName": "L3 (left stick)" + }, + { + "name": "R3", + "value": 12, + "DocName": "R3 (right stick)" + }, + { + "name": "PS", + "value": 13, + "DocName": "PlayStation" + }, + { + "name": "touchpad", + "value": 14 + } + ], + "sticks": [ + { + "NameParts": [ + "left", + "X" + ], + "value": 0 + }, + { + "NameParts": [ + "left", + "Y" + ], + "value": 1 + }, + { + "NameParts": [ + "right", + "X" + ], + "value": 2 + }, + { + "NameParts": [ + "right", + "Y" + ], + "value": 5 + } + ], + "triggers": [ + { + "name": "L2", + "value": 3, + "DocName": "left trigger 2", + "UseThresholdMethods": false + }, + { + "name": "R2", + "value": 4, + "DocName": "right trigger 2", + "UseThresholdMethods": false + } + ] + }, + { + "ConsoleName": "PS5", + "Manufacturer": "Sony", + "SkipReporting": true, + "AxisNameSuffix": "2", + "buttons": [ + { + "name": "square", + "value": 1 + }, + { + "name": "cross", + "value": 2 + }, + { + "name": "circle", + "value": 3 + }, + { + "name": "triangle", + "value": 4 + }, + { + "name": "L1", + "value": 5, + "DocName": "left trigger 1" + }, + { + "name": "R1", + "value": 6, + "DocName": "right trigger 1" + }, + { + "name": "L2", + "value": 7, + "DocName": "left trigger 2" + }, + { + "name": "R2", + "value": 8, + "DocName": "right trigger 2" + }, + { + "name": "create", + "value": 9 + }, + { + "name": "options", + "value": 10 + }, + { + "name": "L3", + "value": 11, + "DocName": "L3 (left stick)" + }, + { + "name": "R3", + "value": 12, + "DocName": "R3 (right stick)" + }, + { + "name": "PS", + "value": 13, + "DocName": "PlayStation" + }, + { + "name": "touchpad", + "value": 14 + } + ], + "sticks": [ + { + "NameParts": [ + "left", + "X" + ], + "value": 0 + }, + { + "NameParts": [ + "left", + "Y" + ], + "value": 1 + }, + { + "NameParts": [ + "right", + "X" + ], + "value": 2 + }, + { + "NameParts": [ + "right", + "Y" + ], + "value": 5 + } + ], + "triggers": [ + { + "name": "L2", + "value": 3, + "DocName": "left trigger 2", + "UseThresholdMethods": false + }, + { + "name": "R2", + "value": 4, + "DocName": "right trigger 2", + "UseThresholdMethods": false + } + ] + }, + { + "ConsoleName": "Stadia", + "Manufacturer": "Google", + "SkipReporting": true, + "AxisNameSuffix": "Trigger", + "buttons": [ + { + "name": "a", + "value": 1, + "DocName": "A" + }, + { + "name": "b", + "value": 2, + "DocName": "B" + }, + { + "name": "x", + "value": 3, + "DocName": "X" + }, + { + "name": "y", + "value": 4, + "DocName": "Y" + }, + { + "name": "leftBumper", + "value": 5, + "DocName": "left bumper" + }, + { + "name": "rightBumper", + "value": 6, + "DocName": "right bumper" + }, + { + "name": "leftStick", + "value": 7, + "DocName": "left stick" + }, + { + "name": "rightStick", + "value": 8, + "DocName": "right stick" + }, + { + "name": "ellipses", + "value": 9 + }, + { + "name": "hamburger", + "value": 10 + }, + { + "name": "stadia", + "value": 11 + }, + { + "name": "rightTrigger", + "value": 12, + "DocName": "right trigger" + }, + { + "name": "leftTrigger", + "value": 13, + "DocName": "left trigger" + }, + { + "name": "google", + "value": 14 + }, + { + "name": "frame", + "value": 15 + } + ], + "sticks": [ + { + "NameParts": [ + "left", + "X" + ], + "value": 0 + }, + { + "NameParts": [ + "right", + "X" + ], + "value": 3 + }, + { + "NameParts": [ + "left", + "Y" + ], + "value": 1 + }, + { + "NameParts": [ + "right", + "Y" + ], + "value": 4 + } + ] + } +] diff --git a/wpilibj/src/generate/hids.schema.json b/wpilibj/src/generate/hids.schema.json new file mode 100644 index 0000000000..3b9dca3015 --- /dev/null +++ b/wpilibj/src/generate/hids.schema.json @@ -0,0 +1,120 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://raw.githubusercontent.com/wpilibsuite/allwpilib/main/wpilibj/src/generate/hids.schema.json", + "title": "A schema for defining HIDs with JSON", + "type": "array", + "default": [], + "items": { + "title": "A Schema", + "type": "object", + "required": [ + "ConsoleName", + "Manufacturer", + "SkipReporting", + "AxisNameSuffix", + "buttons", + "sticks" + ], + "properties": { + "ConsoleName": { + "description": "The name of the console this controller is associated with", + "type": "string" + }, + "Manufacturer": { + "description": "The manufacturer of the console", + "type": "string" + }, + "SkipReporting": { + "description": "Whether or not to skip the usage reporting call", + "type": "boolean" + }, + "AxisNameSuffix": { + "description": "The suffix of an axis that shouldn't have Axis appended to its name", + "type": "string" + }, + "buttons": { + "description": "A list of buttons on the controller", + "type": "array", + "items": { + "description": "A description of a button on the controller", + "type": "object", + "required": [ + "name", + "value" + ], + "properties": { + "name": { + "description": "The name in lowerCamelCase", + "type": "string" + }, + "value": { + "description": "The button value", + "type": "integer" + }, + "DocName": { + "description": "The name of the button to use in docs", + "type": "string" + } + } + } + }, + "sticks": { + "description": "A list of joysticks on the controller", + "type": "array", + "items": { + "description": "A description of a joystick", + "type": "object", + "required": [ + "NameParts", + "value" + ], + "properties": { + "NameParts": { + "description": "The parts of the joystick name in lowerCamelCase", + "type": "array", + "items": { + "description": "The different components of a joystick name, direction and axis", + "type": "string" + } + }, + "value": { + "description": "The axis value", + "type": "integer" + } + } + } + }, + "triggers": { + "description": "A list of triggers on the controller", + "type": "array", + "items": { + "description": "A description of a trigger on the controller", + "type": "object", + "required": [ + "name", + "value", + "UseThresholdMethods" + ], + "properties": { + "name": { + "description": "The name of the trigger to use in code", + "type": "string" + }, + "value": { + "description": "The axis value", + "type": "integer" + }, + "DocName": { + "description": "The name of the trigger for use in docs", + "type": "string" + }, + "UseThresholdMethods": { + "description": "Whether or not an method is created where an event fires based on the axis value", + "type": "boolean" + } + } + } + } + } + } +} diff --git a/wpilibj/src/generate/hidsim.java.jinja b/wpilibj/src/generate/hidsim.java.jinja new file mode 100644 index 0000000000..c2f2704bef --- /dev/null +++ b/wpilibj/src/generate/hidsim.java.jinja @@ -0,0 +1,115 @@ +// 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 ./wpilibj/generate_hids.py. DO NOT MODIFY +{% macro capitalize_first(string) -%} +{{ string[0]|capitalize + string[1:] }} +{%- endmacro %} +package edu.wpi.first.wpilibj.simulation; + +import edu.wpi.first.wpilibj.{{ ConsoleName }}Controller; + +/** Class to control a simulated {{ ConsoleName }} controller. */ +public class {{ ConsoleName }}ControllerSim extends GenericHIDSim { + /** + * Constructs from a {{ ConsoleName }}Controller object. + * + * @param joystick controller to simulate + */ + @SuppressWarnings("this-escape") + public {{ ConsoleName }}ControllerSim({{ ConsoleName }}Controller joystick) { + super(joystick); + setAxisCount({{ sticks|length + triggers|length }}); + setButtonCount({{ buttons|length }}); + setPOVCount(1); + } + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + @SuppressWarnings("this-escape") + public {{ ConsoleName }}ControllerSim(int port) { + super(port); + setAxisCount({{ sticks|length + triggers|length }}); + setButtonCount({{ buttons|length }}); + setPOVCount(1); + } +{% for stick in sticks %} + /** + * Change the {{ stick.NameParts|join(" ") }} value of the controller's joystick. + * + * @param value the new value + */ + public void set{{ stick.NameParts|map("capitalize")|join }}(double value) { + setRawAxis({{ ConsoleName }}Controller.Axis.k{{ stick.NameParts|map("capitalize")|join }}.value, value); + } +{% endfor -%} +{% for trigger in triggers %} + /** + * Change the value of the {{ trigger.DocName }} axis on the controller. + * + * @param value the new value + */ + public void set{{ capitalize_first(trigger.name) }}Axis(double value) { + setRawAxis({{ ConsoleName }}Controller.Axis.k{{ capitalize_first(trigger.name) }}.value, value); + } +{% endfor -%} +{% for button in buttons %} + /** + * Change the value of the {{ button.DocName|default(button.name) }} button on the controller. + * + * @param value the new value + */ + public void set{{ capitalize_first(button.name) }}Button(boolean value) { + setRawButton({{ ConsoleName }}Controller.Button.k{{ capitalize_first(button.name) }}.value, value); + } +{% endfor -%} +{% if ConsoleName == "Xbox" %} + /** + * Change the value of the left bumper on the joystick. + * + * @param state the new value + * @deprecated Use {@link setLeftBumperButton} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public void setLeftBumper(boolean state) { + setRawButton(XboxController.Button.kLeftBumper.value, state); + } + + /** + * Change the value of the right bumper on the joystick. + * + * @param state the new value + * @deprecated Use {@link setRightBumperButton} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public void setRightBumper(boolean state) { + setRawButton(XboxController.Button.kRightBumper.value, state); + } +{% elif ConsoleName == "PS4" %} + /** + * Change the value of the touchpad button on the controller. + * + * @param value the new value + * @deprecated Use {@link setTouchpadButton} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public void setTouchpad(boolean value) { + setRawButton(PS4Controller.Button.kTouchpad.value, value); + } +{% elif ConsoleName == "PS5" %} + /** + * Change the value of the touchpad button on the controller. + * + * @param value the new value + * @deprecated Use {@link setTouchpadButton} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public void setTouchpad(boolean value) { + setRawButton(PS5Controller.Button.kTouchpad.value, value); + } +{% endif -%} +} diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PS4Controller.java b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/PS4Controller.java similarity index 68% rename from wpilibj/src/main/java/edu/wpi/first/wpilibj/PS4Controller.java rename to wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/PS4Controller.java index e000c6f51d..3195c5122b 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PS4Controller.java +++ b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/PS4Controller.java @@ -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 ./wpilibj/generate_hids.py. DO NOT MODIFY + package edu.wpi.first.wpilibj; import edu.wpi.first.hal.FRCNetComm.tResourceType; @@ -16,63 +18,52 @@ import edu.wpi.first.wpilibj.event.EventLoop; * 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. */ public class PS4Controller extends GenericHID { - /** - * Construct an instance of a device. - * - * @param port The port index on the Driver Station that the device is plugged into. - */ - public PS4Controller(int port) { - super(port); - - HAL.report(tResourceType.kResourceType_PS4Controller, port + 1); - } - /** Represents a digital button on a PS4Controller. */ public enum Button { /** Square button. */ kSquare(1), - /** X button. */ + /** Cross button. */ kCross(2), /** Circle button. */ kCircle(3), /** Triangle button. */ kTriangle(4), - /** Left Trigger 1 button. */ + /** Left trigger 1 button. */ kL1(5), - /** Right Trigger 1 button. */ + /** Right trigger 1 button. */ kR1(6), - /** Left Trigger 2 button. */ + /** Left trigger 2 button. */ kL2(7), - /** Right Trigger 2 button. */ + /** Right trigger 2 button. */ kR2(8), /** Share button. */ kShare(9), - /** Option button. */ + /** Options button. */ kOptions(10), - /** Left stick button. */ + /** L3 (left stick) button. */ kL3(11), - /** Right stick button. */ + /** R3 (right stick) button. */ kR3(12), /** PlayStation button. */ kPS(13), - /** Touchpad click button. */ + /** Touchpad button. */ kTouchpad(14); /** Button value. */ public final int value; - Button(int index) { - this.value = index; + Button(int value) { + this.value = value; } /** * Get the human-friendly name of the button, matching the relevant methods. This is done by - * stripping the leading `k`, and if not the touchpad append `Button`. + * stripping the leading `k`, and appending `Button`. * *

Primarily used for automated unit tests. * @@ -80,15 +71,12 @@ public class PS4Controller extends GenericHID { */ @Override public String toString() { - var name = this.name().substring(1); // Remove leading `k` - if (this == kTouchpad) { - return name; - } - return name + "Button"; + // Remove leading `k` + return this.name().substring(1) + "Button"; } } - /** Represents an axis on a PS4Controller. */ + /** Represents an axis on an PS4Controller. */ public enum Axis { /** Left X axis. */ kLeftX(0), @@ -98,21 +86,21 @@ public class PS4Controller extends GenericHID { kRightX(2), /** Right Y axis. */ kRightY(5), - /** Left Trigger 2. */ + /** Left trigger 2. */ kL2(3), - /** Right Trigger 2. */ + /** Right trigger 2. */ kR2(4); /** Axis value. */ public final int value; - Axis(int index) { - value = index; + Axis(int value) { + this.value = value; } /** * Get the human-friendly name of the axis, matching the relevant methods. This is done by - * stripping the leading `k`, and if one of L2/R2 append `Axis`. + * stripping the leading `k`, and appending `Axis` if the name ends with `2`. * *

Primarily used for automated unit tests. * @@ -128,298 +116,74 @@ public class PS4Controller extends GenericHID { } } + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into (0-5). + */ + public PS4Controller(final int port) { + super(port); + HAL.report(tResourceType.kResourceType_PS4Controller, port + 1); + } + /** * Get the X axis value of left side of the controller. * - * @return the axis value. + * @return The axis value. */ public double getLeftX() { return getRawAxis(Axis.kLeftX.value); } - /** - * Get the X axis value of right side of the controller. - * - * @return the axis value. - */ - public double getRightX() { - return getRawAxis(Axis.kRightX.value); - } - /** * Get the Y axis value of left side of the controller. * - * @return the axis value. + * @return The axis value. */ public double getLeftY() { return getRawAxis(Axis.kLeftY.value); } + /** + * Get the X axis value of right side of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return getRawAxis(Axis.kRightX.value); + } + /** * Get the Y axis value of right side of the controller. * - * @return the axis value. + * @return The axis value. */ public double getRightY() { return getRawAxis(Axis.kRightY.value); } /** - * 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. + * @return The axis value. */ public double getL2Axis() { return getRawAxis(Axis.kL2.value); } /** - * 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. + * @return The axis value. */ public double getR2Axis() { return getRawAxis(Axis.kR2.value); } /** - * Read the value of the left trigger button on the controller. - * - * @return The state of the button. - */ - public boolean getL2Button() { - return getRawButton(Button.kL2.value); - } - - /** - * Read the value of the right trigger button on the controller. - * - * @return The state of the button. - */ - public boolean getR2Button() { - return getRawButton(Button.kR2.value); - } - - /** - * Whether the L2 button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getL2ButtonPressed() { - return getRawButtonPressed(Button.kL2.value); - } - - /** - * Whether the R2 button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getR2ButtonPressed() { - return getRawButtonPressed(Button.kR2.value); - } - - /** - * Whether the L2 button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getL2ButtonReleased() { - return getRawButtonReleased(Button.kL2.value); - } - - /** - * Whether the R2 button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getR2ButtonReleased() { - return getRawButtonReleased(Button.kR2.value); - } - - /** - * Constructs an event instance around the L2 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. - */ - @SuppressWarnings("MethodName") - public BooleanEvent L2(EventLoop loop) { - return new BooleanEvent(loop, this::getL2Button); - } - - /** - * Constructs an event instance around the R2 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. - */ - @SuppressWarnings("MethodName") - public BooleanEvent R2(EventLoop loop) { - return new BooleanEvent(loop, this::getR2Button); - } - - /** - * Read the value of the L1 button on the controller. - * - * @return The state of the button. - */ - public boolean getL1Button() { - return getRawButton(Button.kL1.value); - } - - /** - * Read the value of the R1 button on the controller. - * - * @return The state of the button. - */ - public boolean getR1Button() { - return getRawButton(Button.kR1.value); - } - - /** - * Whether the L1 button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getL1ButtonPressed() { - return getRawButtonPressed(Button.kL1.value); - } - - /** - * Whether the R1 button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getR1ButtonPressed() { - return getRawButtonPressed(Button.kR1.value); - } - - /** - * Whether the L1 button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getL1ButtonReleased() { - return getRawButtonReleased(Button.kL1.value); - } - - /** - * Whether the R1 button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getR1ButtonReleased() { - return getRawButtonReleased(Button.kR1.value); - } - - /** - * Constructs an event instance around the L1 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. - */ - @SuppressWarnings("MethodName") - public BooleanEvent L1(EventLoop loop) { - return new BooleanEvent(loop, this::getL1Button); - } - - /** - * Constructs an event instance around the R1 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. - */ - @SuppressWarnings("MethodName") - public BooleanEvent R1(EventLoop loop) { - return new BooleanEvent(loop, this::getR1Button); - } - - /** - * Read the value of the L3 button (pressing the left analog stick) on the controller. - * - * @return The state of the button. - */ - public boolean getL3Button() { - return getRawButton(Button.kL3.value); - } - - /** - * Read the value of the R3 button (pressing the right analog stick) on the controller. - * - * @return The state of the button. - */ - public boolean getR3Button() { - return getRawButton(Button.kR3.value); - } - - /** - * Whether the L3 (left stick) button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getL3ButtonPressed() { - return getRawButtonPressed(Button.kL3.value); - } - - /** - * Whether the R3 (right stick) button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getR3ButtonPressed() { - return getRawButtonPressed(Button.kR3.value); - } - - /** - * Whether the L3 (left stick) button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getL3ButtonReleased() { - return getRawButtonReleased(Button.kL3.value); - } - - /** - * Whether the R3 (right stick) button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getR3ButtonReleased() { - return getRawButtonReleased(Button.kR3.value); - } - - /** - * Constructs an event instance around the L3 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. - */ - @SuppressWarnings("MethodName") - public BooleanEvent L3(EventLoop loop) { - return new BooleanEvent(loop, this::getL3Button); - } - - /** - * Constructs an event instance around the R3 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. - */ - @SuppressWarnings("MethodName") - public BooleanEvent R3(EventLoop loop) { - return new BooleanEvent(loop, this::getR3Button); - } - - /** - * 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. */ @@ -428,7 +192,7 @@ public class PS4Controller extends GenericHID { } /** - * 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. */ @@ -437,7 +201,7 @@ public class PS4Controller extends GenericHID { } /** - * 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. */ @@ -449,15 +213,15 @@ public class PS4Controller extends GenericHID { * 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. */ public BooleanEvent square(EventLoop loop) { return new BooleanEvent(loop, this::getSquareButton); } /** - * 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. */ @@ -466,7 +230,7 @@ public class PS4Controller extends GenericHID { } /** - * 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. */ @@ -475,7 +239,7 @@ public class PS4Controller extends GenericHID { } /** - * 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. */ @@ -487,53 +251,15 @@ public class PS4Controller extends GenericHID { * 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. */ public BooleanEvent cross(EventLoop loop) { return new BooleanEvent(loop, this::getCrossButton); } /** - * Read the value of the Triangle button on the controller. - * - * @return The state of the button. - */ - public boolean getTriangleButton() { - return getRawButton(Button.kTriangle.value); - } - - /** - * Whether the Triangle button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getTriangleButtonPressed() { - return getRawButtonPressed(Button.kTriangle.value); - } - - /** - * Whether the Triangle button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getTriangleButtonReleased() { - return getRawButtonReleased(Button.kTriangle.value); - } - - /** - * 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. - */ - public BooleanEvent triangle(EventLoop loop) { - return new BooleanEvent(loop, this::getTriangleButton); - } - - /** - * 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. */ @@ -542,7 +268,7 @@ public class PS4Controller extends GenericHID { } /** - * 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. */ @@ -551,7 +277,7 @@ public class PS4Controller extends GenericHID { } /** - * 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. */ @@ -563,13 +289,203 @@ public class PS4Controller extends GenericHID { * 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. */ public BooleanEvent circle(EventLoop loop) { return new BooleanEvent(loop, this::getCircleButton); } + /** + * Read the value of the triangle button on the controller. + * + * @return The state of the button. + */ + public boolean getTriangleButton() { + return getRawButton(Button.kTriangle.value); + } + + /** + * Whether the triangle button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getTriangleButtonPressed() { + return getRawButtonPressed(Button.kTriangle.value); + } + + /** + * Whether the triangle button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getTriangleButtonReleased() { + return getRawButtonReleased(Button.kTriangle.value); + } + + /** + * 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. + */ + public BooleanEvent triangle(EventLoop loop) { + return new BooleanEvent(loop, this::getTriangleButton); + } + + /** + * Read the value of the left trigger 1 button on the controller. + * + * @return The state of the button. + */ + public boolean getL1Button() { + return getRawButton(Button.kL1.value); + } + + /** + * Whether the left trigger 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getL1ButtonPressed() { + return getRawButtonPressed(Button.kL1.value); + } + + /** + * Whether the left trigger 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getL1ButtonReleased() { + return getRawButtonReleased(Button.kL1.value); + } + + /** + * 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 left trigger 1 button's digital signal + * attached to the given loop. + */ + public BooleanEvent L1(EventLoop loop) { + return new BooleanEvent(loop, this::getL1Button); + } + + /** + * Read the value of the right trigger 1 button on the controller. + * + * @return The state of the button. + */ + public boolean getR1Button() { + return getRawButton(Button.kR1.value); + } + + /** + * Whether the right trigger 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getR1ButtonPressed() { + return getRawButtonPressed(Button.kR1.value); + } + + /** + * Whether the right trigger 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getR1ButtonReleased() { + return getRawButtonReleased(Button.kR1.value); + } + + /** + * 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 right trigger 1 button's digital signal + * attached to the given loop. + */ + public BooleanEvent R1(EventLoop loop) { + return new BooleanEvent(loop, this::getR1Button); + } + + /** + * Read the value of the left trigger 2 button on the controller. + * + * @return The state of the button. + */ + public boolean getL2Button() { + return getRawButton(Button.kL2.value); + } + + /** + * Whether the left trigger 2 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getL2ButtonPressed() { + return getRawButtonPressed(Button.kL2.value); + } + + /** + * Whether the left trigger 2 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getL2ButtonReleased() { + return getRawButtonReleased(Button.kL2.value); + } + + /** + * 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 left trigger 2 button's digital signal + * attached to the given loop. + */ + public BooleanEvent L2(EventLoop loop) { + return new BooleanEvent(loop, this::getL2Button); + } + + /** + * Read the value of the right trigger 2 button on the controller. + * + * @return The state of the button. + */ + public boolean getR2Button() { + return getRawButton(Button.kR2.value); + } + + /** + * Whether the right trigger 2 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getR2ButtonPressed() { + return getRawButtonPressed(Button.kR2.value); + } + + /** + * Whether the right trigger 2 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getR2ButtonReleased() { + return getRawButtonReleased(Button.kR2.value); + } + + /** + * 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 right trigger 2 button's digital signal + * attached to the given loop. + */ + public BooleanEvent R2(EventLoop loop) { + return new BooleanEvent(loop, this::getR2Button); + } + /** * Read the value of the share button on the controller. * @@ -601,53 +517,13 @@ public class PS4Controller extends GenericHID { * 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. */ - @SuppressWarnings("MethodName") public BooleanEvent share(EventLoop loop) { return new BooleanEvent(loop, this::getShareButton); } - /** - * Read the value of the PS button on the controller. - * - * @return The state of the button. - */ - public boolean getPSButton() { - return getRawButton(Button.kPS.value); - } - - /** - * Whether the PS button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getPSButtonPressed() { - return getRawButtonPressed(Button.kPS.value); - } - - /** - * Whether the PS button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getPSButtonReleased() { - return getRawButtonReleased(Button.kPS.value); - } - - /** - * Constructs an event instance around the PS 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. - */ - @SuppressWarnings("MethodName") - public BooleanEvent PS(EventLoop loop) { - return new BooleanEvent(loop, this::getPSButton); - } - /** * Read the value of the options button on the controller. * @@ -679,18 +555,172 @@ public class PS4Controller extends GenericHID { * 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. */ public BooleanEvent options(EventLoop loop) { return new BooleanEvent(loop, this::getOptionsButton); } + /** + * Read the value of the L3 (left stick) button on the controller. + * + * @return The state of the button. + */ + public boolean getL3Button() { + return getRawButton(Button.kL3.value); + } + + /** + * Whether the L3 (left stick) button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getL3ButtonPressed() { + return getRawButtonPressed(Button.kL3.value); + } + + /** + * Whether the L3 (left stick) button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getL3ButtonReleased() { + return getRawButtonReleased(Button.kL3.value); + } + + /** + * 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 (left stick) button's digital signal + * attached to the given loop. + */ + public BooleanEvent L3(EventLoop loop) { + return new BooleanEvent(loop, this::getL3Button); + } + + /** + * Read the value of the R3 (right stick) button on the controller. + * + * @return The state of the button. + */ + public boolean getR3Button() { + return getRawButton(Button.kR3.value); + } + + /** + * Whether the R3 (right stick) button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getR3ButtonPressed() { + return getRawButtonPressed(Button.kR3.value); + } + + /** + * Whether the R3 (right stick) button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getR3ButtonReleased() { + return getRawButtonReleased(Button.kR3.value); + } + + /** + * 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 (right stick) button's digital signal + * attached to the given loop. + */ + public BooleanEvent R3(EventLoop loop) { + return new BooleanEvent(loop, this::getR3Button); + } + + /** + * Read the value of the PlayStation button on the controller. + * + * @return The state of the button. + */ + public boolean getPSButton() { + return getRawButton(Button.kPS.value); + } + + /** + * Whether the PlayStation button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getPSButtonPressed() { + return getRawButtonPressed(Button.kPS.value); + } + + /** + * Whether the PlayStation button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getPSButtonReleased() { + return getRawButtonReleased(Button.kPS.value); + } + + /** + * 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 PlayStation button's digital signal + * attached to the given loop. + */ + public BooleanEvent PS(EventLoop loop) { + return new BooleanEvent(loop, this::getPSButton); + } + + /** + * Read the value of the touchpad button on the controller. + * + * @return The state of the button. + */ + public boolean getTouchpadButton() { + return getRawButton(Button.kTouchpad.value); + } + + /** + * Whether the touchpad button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getTouchpadButtonPressed() { + return getRawButtonPressed(Button.kTouchpad.value); + } + + /** + * Whether the touchpad button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getTouchpadButtonReleased() { + return getRawButtonReleased(Button.kTouchpad.value); + } + + /** + * 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 button's digital signal + * attached to the given loop. + */ + public BooleanEvent touchpad(EventLoop loop) { + return new BooleanEvent(loop, this::getTouchpadButton); + } + /** * Read the value of the touchpad on the controller. * * @return The state of the touchpad. + * @deprecated Use {@link getTouchpadButton} instead */ + @Deprecated(since = "2025", forRemoval = true) public boolean getTouchpad() { return getRawButton(Button.kTouchpad.value); } @@ -699,7 +729,9 @@ public class PS4Controller extends GenericHID { * Whether the touchpad was pressed since the last check. * * @return Whether the touchpad was pressed since the last check. + * @deprecated Use {@link getTouchpadButtonPressed} instead */ + @Deprecated(since = "2025", forRemoval = true) public boolean getTouchpadPressed() { return getRawButtonPressed(Button.kTouchpad.value); } @@ -708,19 +740,10 @@ public class PS4Controller extends GenericHID { * Whether the touchpad was released since the last check. * * @return Whether the touchpad was released since the last check. + * @deprecated Use {@link getTouchpadButtonReleased} instead */ + @Deprecated(since = "2025", forRemoval = true) public boolean getTouchpadReleased() { return getRawButtonReleased(Button.kTouchpad.value); } - - /** - * Constructs an event instance around the touchpad'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. - */ - public BooleanEvent touchpad(EventLoop loop) { - return new BooleanEvent(loop, this::getTouchpad); - } } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PS5Controller.java b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/PS5Controller.java similarity index 67% rename from wpilibj/src/main/java/edu/wpi/first/wpilibj/PS5Controller.java rename to wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/PS5Controller.java index 18cb738e88..7b0e3083ab 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/PS5Controller.java +++ b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/PS5Controller.java @@ -2,8 +2,12 @@ // 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 ./wpilibj/generate_hids.py. DO NOT MODIFY + package edu.wpi.first.wpilibj; +// import edu.wpi.first.hal.FRCNetComm.tResourceType; +// import edu.wpi.first.hal.HAL; import edu.wpi.first.wpilibj.event.BooleanEvent; import edu.wpi.first.wpilibj.event.EventLoop; @@ -14,26 +18,16 @@ import edu.wpi.first.wpilibj.event.EventLoop; * 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. */ public class PS5Controller extends GenericHID { - /** - * Construct an instance of a device. - * - * @param port The port index on the Driver Station that the device is plugged into. - */ - public PS5Controller(int port) { - super(port); - // HAL.report(tResourceType.kResourceType_PS5Controller, port + 1); - } - /** Represents a digital button on a PS5Controller. */ public enum Button { /** Square button. */ kSquare(1), - /** X button. */ + /** Cross button. */ kCross(2), /** Circle button. */ kCircle(3), @@ -51,25 +45,25 @@ public class PS5Controller extends GenericHID { kCreate(9), /** Options button. */ kOptions(10), - /** Left stick button. */ + /** L3 (left stick) button. */ kL3(11), - /** Right stick button. */ + /** R3 (right stick) button. */ kR3(12), /** PlayStation button. */ kPS(13), - /** Touchpad click button. */ + /** Touchpad button. */ kTouchpad(14); /** Button value. */ public final int value; - Button(int index) { - this.value = index; + Button(int value) { + this.value = value; } /** * Get the human-friendly name of the button, matching the relevant methods. This is done by - * stripping the leading `k`, and if not the touchpad append `Button`. + * stripping the leading `k`, and appending `Button`. * *

Primarily used for automated unit tests. * @@ -77,15 +71,12 @@ public class PS5Controller extends GenericHID { */ @Override public String toString() { - var name = this.name().substring(1); // Remove leading `k` - if (this == kTouchpad) { - return name; - } - return name + "Button"; + // Remove leading `k` + return this.name().substring(1) + "Button"; } } - /** Represents an axis on a PS5Controller. */ + /** Represents an axis on an PS5Controller. */ public enum Axis { /** Left X axis. */ kLeftX(0), @@ -95,21 +86,21 @@ public class PS5Controller extends GenericHID { kRightX(2), /** Right Y axis. */ kRightY(5), - /** Left Trigger 2. */ + /** Left trigger 2. */ kL2(3), - /** Right Trigger 2. */ + /** Right trigger 2. */ kR2(4); /** Axis value. */ public final int value; - Axis(int index) { - value = index; + Axis(int value) { + this.value = value; } /** * Get the human-friendly name of the axis, matching the relevant methods. This is done by - * stripping the leading `k`, and if one of L2/R2 append `Axis`. + * stripping the leading `k`, and appending `Axis` if the name ends with `2`. * *

Primarily used for automated unit tests. * @@ -125,298 +116,74 @@ public class PS5Controller extends GenericHID { } } + /** + * Construct an instance of a controller. + * + * @param port The port index on the Driver Station that the controller is plugged into (0-5). + */ + public PS5Controller(final int port) { + super(port); + // HAL.report(tResourceType.kResourceType_PS5Controller, port + 1); + } + /** * Get the X axis value of left side of the controller. * - * @return the axis value. + * @return The axis value. */ public double getLeftX() { return getRawAxis(Axis.kLeftX.value); } - /** - * Get the X axis value of right side of the controller. - * - * @return the axis value. - */ - public double getRightX() { - return getRawAxis(Axis.kRightX.value); - } - /** * Get the Y axis value of left side of the controller. * - * @return the axis value. + * @return The axis value. */ public double getLeftY() { return getRawAxis(Axis.kLeftY.value); } + /** + * Get the X axis value of right side of the controller. + * + * @return The axis value. + */ + public double getRightX() { + return getRawAxis(Axis.kRightX.value); + } + /** * Get the Y axis value of right side of the controller. * - * @return the axis value. + * @return The axis value. */ public double getRightY() { return getRawAxis(Axis.kRightY.value); } /** - * 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. + * @return The axis value. */ public double getL2Axis() { return getRawAxis(Axis.kL2.value); } /** - * 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. + * @return The axis value. */ public double getR2Axis() { return getRawAxis(Axis.kR2.value); } /** - * Read the value of the left trigger button on the controller. - * - * @return The state of the button. - */ - public boolean getL2Button() { - return getRawButton(Button.kL2.value); - } - - /** - * Read the value of the right trigger button on the controller. - * - * @return The state of the button. - */ - public boolean getR2Button() { - return getRawButton(Button.kR2.value); - } - - /** - * Whether the L2 button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getL2ButtonPressed() { - return getRawButtonPressed(Button.kL2.value); - } - - /** - * Whether the R2 button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getR2ButtonPressed() { - return getRawButtonPressed(Button.kR2.value); - } - - /** - * Whether the L2 button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getL2ButtonReleased() { - return getRawButtonReleased(Button.kL2.value); - } - - /** - * Whether the R2 button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getR2ButtonReleased() { - return getRawButtonReleased(Button.kR2.value); - } - - /** - * Constructs an event instance around the L2 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. - */ - @SuppressWarnings("MethodName") - public BooleanEvent L2(EventLoop loop) { - return new BooleanEvent(loop, this::getL2Button); - } - - /** - * Constructs an event instance around the R2 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. - */ - @SuppressWarnings("MethodName") - public BooleanEvent R2(EventLoop loop) { - return new BooleanEvent(loop, this::getR2Button); - } - - /** - * Read the value of the L1 button on the controller. - * - * @return The state of the button. - */ - public boolean getL1Button() { - return getRawButton(Button.kL1.value); - } - - /** - * Read the value of the R1 button on the controller. - * - * @return The state of the button. - */ - public boolean getR1Button() { - return getRawButton(Button.kR1.value); - } - - /** - * Whether the L1 button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getL1ButtonPressed() { - return getRawButtonPressed(Button.kL1.value); - } - - /** - * Whether the R1 button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getR1ButtonPressed() { - return getRawButtonPressed(Button.kR1.value); - } - - /** - * Whether the L1 button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getL1ButtonReleased() { - return getRawButtonReleased(Button.kL1.value); - } - - /** - * Whether the R1 button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getR1ButtonReleased() { - return getRawButtonReleased(Button.kR1.value); - } - - /** - * Constructs an event instance around the L1 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. - */ - @SuppressWarnings("MethodName") - public BooleanEvent L1(EventLoop loop) { - return new BooleanEvent(loop, this::getL1Button); - } - - /** - * Constructs an event instance around the R1 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. - */ - @SuppressWarnings("MethodName") - public BooleanEvent R1(EventLoop loop) { - return new BooleanEvent(loop, this::getR1Button); - } - - /** - * Read the value of the L3 button (pressing the left analog stick) on the controller. - * - * @return The state of the button. - */ - public boolean getL3Button() { - return getRawButton(Button.kL3.value); - } - - /** - * Read the value of the R3 button (pressing the right analog stick) on the controller. - * - * @return The state of the button. - */ - public boolean getR3Button() { - return getRawButton(Button.kR3.value); - } - - /** - * Whether the L3 (left stick) button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getL3ButtonPressed() { - return getRawButtonPressed(Button.kL3.value); - } - - /** - * Whether the R3 (right stick) button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getR3ButtonPressed() { - return getRawButtonPressed(Button.kR3.value); - } - - /** - * Whether the L3 (left stick) button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getL3ButtonReleased() { - return getRawButtonReleased(Button.kL3.value); - } - - /** - * Whether the R3 (right stick) button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getR3ButtonReleased() { - return getRawButtonReleased(Button.kR3.value); - } - - /** - * Constructs an event instance around the L3 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. - */ - @SuppressWarnings("MethodName") - public BooleanEvent L3(EventLoop loop) { - return new BooleanEvent(loop, this::getL3Button); - } - - /** - * Constructs an event instance around the R3 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. - */ - @SuppressWarnings("MethodName") - public BooleanEvent R3(EventLoop loop) { - return new BooleanEvent(loop, this::getR3Button); - } - - /** - * 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. */ @@ -425,7 +192,7 @@ public class PS5Controller extends GenericHID { } /** - * 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. */ @@ -434,7 +201,7 @@ public class PS5Controller extends GenericHID { } /** - * 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. */ @@ -446,15 +213,15 @@ public class PS5Controller extends GenericHID { * 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. */ public BooleanEvent square(EventLoop loop) { return new BooleanEvent(loop, this::getSquareButton); } /** - * 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. */ @@ -463,7 +230,7 @@ public class PS5Controller extends GenericHID { } /** - * 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. */ @@ -472,7 +239,7 @@ public class PS5Controller extends GenericHID { } /** - * 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. */ @@ -484,53 +251,15 @@ public class PS5Controller extends GenericHID { * 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. */ public BooleanEvent cross(EventLoop loop) { return new BooleanEvent(loop, this::getCrossButton); } /** - * Read the value of the Triangle button on the controller. - * - * @return The state of the button. - */ - public boolean getTriangleButton() { - return getRawButton(Button.kTriangle.value); - } - - /** - * Whether the Triangle button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getTriangleButtonPressed() { - return getRawButtonPressed(Button.kTriangle.value); - } - - /** - * Whether the Triangle button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getTriangleButtonReleased() { - return getRawButtonReleased(Button.kTriangle.value); - } - - /** - * 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. - */ - public BooleanEvent triangle(EventLoop loop) { - return new BooleanEvent(loop, this::getTriangleButton); - } - - /** - * 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. */ @@ -539,7 +268,7 @@ public class PS5Controller extends GenericHID { } /** - * 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. */ @@ -548,7 +277,7 @@ public class PS5Controller extends GenericHID { } /** - * 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. */ @@ -560,15 +289,205 @@ public class PS5Controller extends GenericHID { * 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. */ public BooleanEvent circle(EventLoop loop) { return new BooleanEvent(loop, this::getCircleButton); } /** - * Read the value of the share button on the controller. + * Read the value of the triangle button on the controller. + * + * @return The state of the button. + */ + public boolean getTriangleButton() { + return getRawButton(Button.kTriangle.value); + } + + /** + * Whether the triangle button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getTriangleButtonPressed() { + return getRawButtonPressed(Button.kTriangle.value); + } + + /** + * Whether the triangle button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getTriangleButtonReleased() { + return getRawButtonReleased(Button.kTriangle.value); + } + + /** + * 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. + */ + public BooleanEvent triangle(EventLoop loop) { + return new BooleanEvent(loop, this::getTriangleButton); + } + + /** + * Read the value of the left trigger 1 button on the controller. + * + * @return The state of the button. + */ + public boolean getL1Button() { + return getRawButton(Button.kL1.value); + } + + /** + * Whether the left trigger 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getL1ButtonPressed() { + return getRawButtonPressed(Button.kL1.value); + } + + /** + * Whether the left trigger 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getL1ButtonReleased() { + return getRawButtonReleased(Button.kL1.value); + } + + /** + * 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 left trigger 1 button's digital signal + * attached to the given loop. + */ + public BooleanEvent L1(EventLoop loop) { + return new BooleanEvent(loop, this::getL1Button); + } + + /** + * Read the value of the right trigger 1 button on the controller. + * + * @return The state of the button. + */ + public boolean getR1Button() { + return getRawButton(Button.kR1.value); + } + + /** + * Whether the right trigger 1 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getR1ButtonPressed() { + return getRawButtonPressed(Button.kR1.value); + } + + /** + * Whether the right trigger 1 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getR1ButtonReleased() { + return getRawButtonReleased(Button.kR1.value); + } + + /** + * 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 right trigger 1 button's digital signal + * attached to the given loop. + */ + public BooleanEvent R1(EventLoop loop) { + return new BooleanEvent(loop, this::getR1Button); + } + + /** + * Read the value of the left trigger 2 button on the controller. + * + * @return The state of the button. + */ + public boolean getL2Button() { + return getRawButton(Button.kL2.value); + } + + /** + * Whether the left trigger 2 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getL2ButtonPressed() { + return getRawButtonPressed(Button.kL2.value); + } + + /** + * Whether the left trigger 2 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getL2ButtonReleased() { + return getRawButtonReleased(Button.kL2.value); + } + + /** + * 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 left trigger 2 button's digital signal + * attached to the given loop. + */ + public BooleanEvent L2(EventLoop loop) { + return new BooleanEvent(loop, this::getL2Button); + } + + /** + * Read the value of the right trigger 2 button on the controller. + * + * @return The state of the button. + */ + public boolean getR2Button() { + return getRawButton(Button.kR2.value); + } + + /** + * Whether the right trigger 2 button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getR2ButtonPressed() { + return getRawButtonPressed(Button.kR2.value); + } + + /** + * Whether the right trigger 2 button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getR2ButtonReleased() { + return getRawButtonReleased(Button.kR2.value); + } + + /** + * 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 right trigger 2 button's digital signal + * attached to the given loop. + */ + public BooleanEvent R2(EventLoop loop) { + return new BooleanEvent(loop, this::getR2Button); + } + + /** + * Read the value of the create button on the controller. * * @return The state of the button. */ @@ -577,7 +496,7 @@ public class PS5Controller extends GenericHID { } /** - * Whether the share 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. */ @@ -586,7 +505,7 @@ public class PS5Controller extends GenericHID { } /** - * Whether the share 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. */ @@ -595,56 +514,16 @@ public class PS5Controller extends GenericHID { } /** - * Constructs an event instance around the share 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 share 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. */ - @SuppressWarnings("MethodName") public BooleanEvent create(EventLoop loop) { return new BooleanEvent(loop, this::getCreateButton); } - /** - * Read the value of the PS button on the controller. - * - * @return The state of the button. - */ - public boolean getPSButton() { - return getRawButton(Button.kPS.value); - } - - /** - * Whether the PS button was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getPSButtonPressed() { - return getRawButtonPressed(Button.kPS.value); - } - - /** - * Whether the PS button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getPSButtonReleased() { - return getRawButtonReleased(Button.kPS.value); - } - - /** - * Constructs an event instance around the PS 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. - */ - @SuppressWarnings("MethodName") - public BooleanEvent PS(EventLoop loop) { - return new BooleanEvent(loop, this::getPSButton); - } - /** * Read the value of the options button on the controller. * @@ -676,18 +555,172 @@ public class PS5Controller extends GenericHID { * 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. */ public BooleanEvent options(EventLoop loop) { return new BooleanEvent(loop, this::getOptionsButton); } + /** + * Read the value of the L3 (left stick) button on the controller. + * + * @return The state of the button. + */ + public boolean getL3Button() { + return getRawButton(Button.kL3.value); + } + + /** + * Whether the L3 (left stick) button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getL3ButtonPressed() { + return getRawButtonPressed(Button.kL3.value); + } + + /** + * Whether the L3 (left stick) button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getL3ButtonReleased() { + return getRawButtonReleased(Button.kL3.value); + } + + /** + * 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 (left stick) button's digital signal + * attached to the given loop. + */ + public BooleanEvent L3(EventLoop loop) { + return new BooleanEvent(loop, this::getL3Button); + } + + /** + * Read the value of the R3 (right stick) button on the controller. + * + * @return The state of the button. + */ + public boolean getR3Button() { + return getRawButton(Button.kR3.value); + } + + /** + * Whether the R3 (right stick) button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getR3ButtonPressed() { + return getRawButtonPressed(Button.kR3.value); + } + + /** + * Whether the R3 (right stick) button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getR3ButtonReleased() { + return getRawButtonReleased(Button.kR3.value); + } + + /** + * 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 (right stick) button's digital signal + * attached to the given loop. + */ + public BooleanEvent R3(EventLoop loop) { + return new BooleanEvent(loop, this::getR3Button); + } + + /** + * Read the value of the PlayStation button on the controller. + * + * @return The state of the button. + */ + public boolean getPSButton() { + return getRawButton(Button.kPS.value); + } + + /** + * Whether the PlayStation button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getPSButtonPressed() { + return getRawButtonPressed(Button.kPS.value); + } + + /** + * Whether the PlayStation button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getPSButtonReleased() { + return getRawButtonReleased(Button.kPS.value); + } + + /** + * 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 PlayStation button's digital signal + * attached to the given loop. + */ + public BooleanEvent PS(EventLoop loop) { + return new BooleanEvent(loop, this::getPSButton); + } + + /** + * Read the value of the touchpad button on the controller. + * + * @return The state of the button. + */ + public boolean getTouchpadButton() { + return getRawButton(Button.kTouchpad.value); + } + + /** + * Whether the touchpad button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getTouchpadButtonPressed() { + return getRawButtonPressed(Button.kTouchpad.value); + } + + /** + * Whether the touchpad button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getTouchpadButtonReleased() { + return getRawButtonReleased(Button.kTouchpad.value); + } + + /** + * 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 button's digital signal + * attached to the given loop. + */ + public BooleanEvent touchpad(EventLoop loop) { + return new BooleanEvent(loop, this::getTouchpadButton); + } + /** * Read the value of the touchpad on the controller. * * @return The state of the touchpad. + * @deprecated Use {@link getTouchpadButton} instead */ + @Deprecated(since = "2025", forRemoval = true) public boolean getTouchpad() { return getRawButton(Button.kTouchpad.value); } @@ -696,7 +729,9 @@ public class PS5Controller extends GenericHID { * Whether the touchpad was pressed since the last check. * * @return Whether the touchpad was pressed since the last check. + * @deprecated Use {@link getTouchpadButtonPressed} instead */ + @Deprecated(since = "2025", forRemoval = true) public boolean getTouchpadPressed() { return getRawButtonPressed(Button.kTouchpad.value); } @@ -705,19 +740,10 @@ public class PS5Controller extends GenericHID { * Whether the touchpad was released since the last check. * * @return Whether the touchpad was released since the last check. + * @deprecated Use {@link getTouchpadButtonReleased} instead */ + @Deprecated(since = "2025", forRemoval = true) public boolean getTouchpadReleased() { return getRawButtonReleased(Button.kTouchpad.value); } - - /** - * Constructs an event instance around the touchpad'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. - */ - public BooleanEvent touchpad(EventLoop loop) { - return new BooleanEvent(loop, this::getTouchpad); - } } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/StadiaController.java b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/StadiaController.java similarity index 78% rename from wpilibj/src/main/java/edu/wpi/first/wpilibj/StadiaController.java rename to wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/StadiaController.java index d092d8b937..916ab3979d 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/StadiaController.java +++ b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/StadiaController.java @@ -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 ./wpilibj/generate_hids.py. DO NOT MODIFY + package edu.wpi.first.wpilibj; // import edu.wpi.first.hal.FRCNetComm.tResourceType; @@ -15,6 +17,10 @@ import edu.wpi.first.wpilibj.event.EventLoop; *

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. */ public class StadiaController extends GenericHID { /** Represents a digital button on a StadiaController. */ @@ -23,9 +29,9 @@ public class StadiaController extends GenericHID { kA(1), /** B button. */ kB(2), - /** X Button. */ + /** X button. */ kX(3), - /** Y Button. */ + /** Y button. */ kY(4), /** Left bumper button. */ kLeftBumper(5), @@ -59,7 +65,7 @@ public class StadiaController extends GenericHID { /** * Get the human-friendly name of the button, matching the relevant methods. This is done by - * stripping the leading `k`, and if not a Bumper button append `Button`. + * stripping the leading `k`, and appending `Button`. * *

Primarily used for automated unit tests. * @@ -67,15 +73,12 @@ public class StadiaController extends GenericHID { */ @Override public String toString() { - var name = this.name().substring(1); // Remove leading `k` - if (name.endsWith("Bumper")) { - return name; - } - return name + "Button"; + // Remove leading `k` + return this.name().substring(1) + "Button"; } } - /** Represents an axis on a StadiaController. */ + /** Represents an axis on an StadiaController. */ public enum Axis { /** Left X axis. */ kLeftX(0), @@ -95,7 +98,7 @@ public class StadiaController extends GenericHID { /** * Get the human-friendly name of the axis, matching the relevant methods. This is done by - * stripping the leading `k`, and if a trigger axis append `Axis`. + * stripping the leading `k`, and appending `Axis` if the name ends with `Trigger`. * *

Primarily used for automated unit tests. * @@ -114,12 +117,11 @@ public class StadiaController extends GenericHID { /** * Construct an instance of a controller. * - * @param port The port index on the Driver Station that the controller is plugged into. + * @param port The port index on the Driver Station that the controller is plugged into (0-5). */ public StadiaController(final int port) { super(port); - // re-enable when StadiaController is added to Usage Reporting - // HAL.report(tResourceType.kResourceType_Joystick, port + 1); + // HAL.report(tResourceType.kResourceType_StadiaController, port + 1); } /** @@ -158,234 +160,6 @@ public class StadiaController extends GenericHID { return getRawAxis(Axis.kRightY.value); } - /** - * Read the value of the left bumper (LB) button on the controller. - * - * @return The state of the button. - */ - public boolean getLeftBumper() { - return getRawButton(Button.kLeftBumper.value); - } - - /** - * Read the value of the right bumper (RB) button on the controller. - * - * @return The state of the button. - */ - public boolean getRightBumper() { - return getRawButton(Button.kRightBumper.value); - } - - /** - * Whether the left bumper (LB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getLeftBumperPressed() { - return getRawButtonPressed(Button.kLeftBumper.value); - } - - /** - * Whether the right bumper (RB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getRightBumperPressed() { - return getRawButtonPressed(Button.kRightBumper.value); - } - - /** - * Whether the left bumper (LB) was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getLeftBumperReleased() { - return getRawButtonReleased(Button.kLeftBumper.value); - } - - /** - * Whether the right bumper (RB) was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getRightBumperReleased() { - return getRawButtonReleased(Button.kRightBumper.value); - } - - /** - * Constructs an event instance around the right bumper'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. - */ - public BooleanEvent leftBumper(EventLoop loop) { - return new BooleanEvent(loop, this::getLeftBumper); - } - - /** - * Constructs an event instance around the left bumper's digital signal. - * - * @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. - */ - public BooleanEvent rightBumper(EventLoop loop) { - return new BooleanEvent(loop, this::getRightBumper); - } - - /** - * Read the value of the left stick button (LSB) on the controller. - * - * @return The state of the button. - */ - public boolean getLeftStickButton() { - return getRawButton(Button.kLeftStick.value); - } - - /** - * Read the value of the right stick button (RSB) on the controller. - * - * @return The state of the button. - */ - public boolean getRightStickButton() { - return getRawButton(Button.kRightStick.value); - } - - /** - * Whether the left stick button (LSB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getLeftStickButtonPressed() { - return getRawButtonPressed(Button.kLeftStick.value); - } - - /** - * Whether the right stick button (RSB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getRightStickButtonPressed() { - return getRawButtonPressed(Button.kRightStick.value); - } - - /** - * Whether the left stick button (LSB) was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getLeftStickButtonReleased() { - return getRawButtonReleased(Button.kLeftStick.value); - } - - /** - * Whether the right stick (RSB) button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getRightStickButtonReleased() { - return getRawButtonReleased(Button.kRightStick.value); - } - - /** - * 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 left stick button's digital signal attached to the - * given loop. - */ - public BooleanEvent leftStick(EventLoop loop) { - return new BooleanEvent(loop, this::getLeftStickButton); - } - - /** - * 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 right stick button's digital signal attached to the - * given loop. - */ - public BooleanEvent rightStick(EventLoop loop) { - return new BooleanEvent(loop, this::getRightStickButton); - } - - /** - * Read the value of the left trigger button (LTB) on the controller. - * - * @return The state of the button. - */ - public boolean getLeftTriggerButton() { - return getRawButton(Button.kLeftTrigger.value); - } - - /** - * Read the value of the right trigger button (RTB) on the controller. - * - * @return The state of the button. - */ - public boolean getRightTriggerButton() { - return getRawButton(Button.kRightTrigger.value); - } - - /** - * Whether the left trigger button (LTB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getLeftTriggerButtonPressed() { - return getRawButtonPressed(Button.kLeftTrigger.value); - } - - /** - * Whether the right trigger button (RTB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getRightTriggerButtonPressed() { - return getRawButtonPressed(Button.kRightTrigger.value); - } - - /** - * Whether the left trigger button (LTB) was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getLeftTriggerButtonReleased() { - return getRawButtonReleased(Button.kLeftTrigger.value); - } - - /** - * Whether the right trigger (RTB) button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getRightTriggerButtonReleased() { - return getRawButtonReleased(Button.kRightTrigger.value); - } - - /** - * 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 left trigger button's digital signal attached to the - * given loop. - */ - public BooleanEvent leftTrigger(EventLoop loop) { - return new BooleanEvent(loop, this::getLeftTriggerButton); - } - - /** - * 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 right trigger button's digital signal attached to - * the given loop. - */ - public BooleanEvent rightTrigger(EventLoop loop) { - return new BooleanEvent(loop, this::getRightTriggerButton); - } - /** * Read the value of the A button on the controller. * @@ -417,10 +191,9 @@ public class StadiaController extends GenericHID { * Constructs an event instance around the A 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 A button's digital signal + * attached to the given loop. */ - @SuppressWarnings("MethodName") public BooleanEvent a(EventLoop loop) { return new BooleanEvent(loop, this::getAButton); } @@ -456,10 +229,9 @@ public class StadiaController extends GenericHID { * 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 B button's digital signal attached to the given - * loop. + * @return an event instance representing the B button's digital signal + * attached to the given loop. */ - @SuppressWarnings("MethodName") public BooleanEvent b(EventLoop loop) { return new BooleanEvent(loop, this::getBButton); } @@ -495,10 +267,9 @@ public class StadiaController extends GenericHID { * Constructs an event instance around the X 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 X button's digital signal + * attached to the given loop. */ - @SuppressWarnings("MethodName") public BooleanEvent x(EventLoop loop) { return new BooleanEvent(loop, this::getXButton); } @@ -534,14 +305,165 @@ public class StadiaController extends GenericHID { * 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 Y button's digital signal attached to the given - * loop. + * @return an event instance representing the Y button's digital signal + * attached to the given loop. */ - @SuppressWarnings("MethodName") public BooleanEvent y(EventLoop loop) { return new BooleanEvent(loop, this::getYButton); } + /** + * Read the value of the left bumper button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftBumperButton() { + return getRawButton(Button.kLeftBumper.value); + } + + /** + * Whether the left bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftBumperButtonPressed() { + return getRawButtonPressed(Button.kLeftBumper.value); + } + + /** + * Whether the left bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftBumperButtonReleased() { + return getRawButtonReleased(Button.kLeftBumper.value); + } + + /** + * 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 left bumper button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftBumper(EventLoop loop) { + return new BooleanEvent(loop, this::getLeftBumperButton); + } + + /** + * Read the value of the right bumper button on the controller. + * + * @return The state of the button. + */ + public boolean getRightBumperButton() { + return getRawButton(Button.kRightBumper.value); + } + + /** + * Whether the right bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightBumperButtonPressed() { + return getRawButtonPressed(Button.kRightBumper.value); + } + + /** + * Whether the right bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightBumperButtonReleased() { + return getRawButtonReleased(Button.kRightBumper.value); + } + + /** + * 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 right bumper button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightBumper(EventLoop loop) { + return new BooleanEvent(loop, this::getRightBumperButton); + } + + /** + * Read the value of the left stick button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftStickButton() { + return getRawButton(Button.kLeftStick.value); + } + + /** + * Whether the left stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftStickButtonPressed() { + return getRawButtonPressed(Button.kLeftStick.value); + } + + /** + * Whether the left stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftStickButtonReleased() { + return getRawButtonReleased(Button.kLeftStick.value); + } + + /** + * 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 left stick button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftStick(EventLoop loop) { + return new BooleanEvent(loop, this::getLeftStickButton); + } + + /** + * Read the value of the right stick button on the controller. + * + * @return The state of the button. + */ + public boolean getRightStickButton() { + return getRawButton(Button.kRightStick.value); + } + + /** + * Whether the right stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightStickButtonPressed() { + return getRawButtonPressed(Button.kRightStick.value); + } + + /** + * Whether the right stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightStickButtonReleased() { + return getRawButtonReleased(Button.kRightStick.value); + } + + /** + * 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 right stick button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightStick(EventLoop loop) { + return new BooleanEvent(loop, this::getRightStickButton); + } + /** * Read the value of the ellipses button on the controller. * @@ -573,8 +495,8 @@ public class StadiaController extends GenericHID { * 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. */ public BooleanEvent ellipses(EventLoop loop) { return new BooleanEvent(loop, this::getEllipsesButton); @@ -611,8 +533,8 @@ public class StadiaController extends GenericHID { * 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. */ public BooleanEvent hamburger(EventLoop loop) { return new BooleanEvent(loop, this::getHamburgerButton); @@ -649,14 +571,89 @@ public class StadiaController extends GenericHID { * 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. */ - @SuppressWarnings("MethodName") public BooleanEvent stadia(EventLoop loop) { return new BooleanEvent(loop, this::getStadiaButton); } + /** + * Read the value of the right trigger button on the controller. + * + * @return The state of the button. + */ + public boolean getRightTriggerButton() { + return getRawButton(Button.kRightTrigger.value); + } + + /** + * Whether the right trigger button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightTriggerButtonPressed() { + return getRawButtonPressed(Button.kRightTrigger.value); + } + + /** + * Whether the right trigger button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightTriggerButtonReleased() { + return getRawButtonReleased(Button.kRightTrigger.value); + } + + /** + * 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 right trigger button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightTrigger(EventLoop loop) { + return new BooleanEvent(loop, this::getRightTriggerButton); + } + + /** + * Read the value of the left trigger button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftTriggerButton() { + return getRawButton(Button.kLeftTrigger.value); + } + + /** + * Whether the left trigger button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftTriggerButtonPressed() { + return getRawButtonPressed(Button.kLeftTrigger.value); + } + + /** + * Whether the left trigger button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftTriggerButtonReleased() { + return getRawButtonReleased(Button.kLeftTrigger.value); + } + + /** + * 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 left trigger button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftTrigger(EventLoop loop) { + return new BooleanEvent(loop, this::getLeftTriggerButton); + } + /** * Read the value of the google button on the controller. * @@ -688,10 +685,9 @@ public class StadiaController extends GenericHID { * 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 google 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. */ - @SuppressWarnings("MethodName") public BooleanEvent google(EventLoop loop) { return new BooleanEvent(loop, this::getGoogleButton); } @@ -727,11 +723,76 @@ public class StadiaController extends GenericHID { * 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 frame 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. */ - @SuppressWarnings("MethodName") public BooleanEvent frame(EventLoop loop) { return new BooleanEvent(loop, this::getFrameButton); } + + /** + * Read the value of the left bumper (LB) button on the controller. + * + * @return The state of the button. + * @deprecated Use {@link getLeftBumperButton} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getLeftBumper() { + return getRawButton(Button.kLeftBumper.value); + } + + /** + * Read the value of the right bumper (RB) button on the controller. + * + * @return The state of the button. + * @deprecated Use {@link getRightBumperButton} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getRightBumper() { + return getRawButton(Button.kRightBumper.value); + } + + /** + * Whether the left bumper (LB) was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + * @deprecated Use {@link getLeftBumperButtonPressed} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getLeftBumperPressed() { + return getRawButtonPressed(Button.kLeftBumper.value); + } + + /** + * Whether the right bumper (RB) was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + * @deprecated Use {@link getRightBumperButtonPressed} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getRightBumperPressed() { + return getRawButtonPressed(Button.kRightBumper.value); + } + + /** + * Whether the left bumper (LB) was released since the last check. + * + * @return Whether the button was released since the last check. + * @deprecated Use {@link getLeftBumperButtonReleased} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getLeftBumperReleased() { + return getRawButtonReleased(Button.kLeftBumper.value); + } + + /** + * Whether the right bumper (RB) was released since the last check. + * + * @return Whether the button was released since the last check. + * @deprecated Use {@link getRightBumperButtonReleased} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getRightBumperReleased() { + return getRawButtonReleased(Button.kRightBumper.value); + } } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/XboxController.java b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/XboxController.java similarity index 77% rename from wpilibj/src/main/java/edu/wpi/first/wpilibj/XboxController.java rename to wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/XboxController.java index 5bd7a01927..3bf77e11f6 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/XboxController.java +++ b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/XboxController.java @@ -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 ./wpilibj/generate_hids.py. DO NOT MODIFY + package edu.wpi.first.wpilibj; import edu.wpi.first.hal.FRCNetComm.tResourceType; @@ -10,7 +12,7 @@ import edu.wpi.first.wpilibj.event.BooleanEvent; import edu.wpi.first.wpilibj.event.EventLoop; /** - * 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 @@ -21,28 +23,28 @@ import edu.wpi.first.wpilibj.event.EventLoop; * 3rd party controllers. */ public class XboxController extends GenericHID { - /** Represents a digital button on an XboxController. */ + /** Represents a digital button on a XboxController. */ public enum Button { - /** Left bumper. */ - kLeftBumper(5), - /** Right bumper. */ - kRightBumper(6), - /** Left stick. */ - kLeftStick(9), - /** Right stick. */ - kRightStick(10), - /** A. */ + /** A button. */ kA(1), - /** B. */ + /** B button. */ kB(2), - /** X. */ + /** X button. */ kX(3), - /** Y. */ + /** Y button. */ kY(4), - /** Back. */ + /** Left bumper button. */ + kLeftBumper(5), + /** Right bumper button. */ + kRightBumper(6), + /** Back button. */ kBack(7), - /** Start. */ - kStart(8); + /** Start button. */ + kStart(8), + /** Left stick button. */ + kLeftStick(9), + /** Right stick button. */ + kRightStick(10); /** Button value. */ public final int value; @@ -53,7 +55,7 @@ public class XboxController extends GenericHID { /** * Get the human-friendly name of the button, matching the relevant methods. This is done by - * stripping the leading `k`, and if not a Bumper button append `Button`. + * stripping the leading `k`, and appending `Button`. * *

Primarily used for automated unit tests. * @@ -61,23 +63,20 @@ public class XboxController extends GenericHID { */ @Override public String toString() { - var name = this.name().substring(1); // Remove leading `k` - if (name.endsWith("Bumper")) { - return name; - } - return name + "Button"; + // Remove leading `k` + return this.name().substring(1) + "Button"; } } /** Represents an axis on an XboxController. */ public enum Axis { - /** Left X. */ + /** Left X axis. */ kLeftX(0), - /** Right X. */ + /** Right X axis. */ kRightX(4), - /** Left Y. */ + /** Left Y axis. */ kLeftY(1), - /** Right Y. */ + /** Right Y axis. */ kRightY(5), /** Left trigger. */ kLeftTrigger(2), @@ -93,7 +92,7 @@ public class XboxController extends GenericHID { /** * Get the human-friendly name of the axis, matching the relevant methods. This is done by - * stripping the leading `k`, and if a trigger axis append `Axis`. + * stripping the leading `k`, and appending `Axis` if the name ends with `Trigger`. * *

Primarily used for automated unit tests. * @@ -112,11 +111,10 @@ public class XboxController extends GenericHID { /** * Construct an instance of a controller. * - * @param port The port index on the Driver Station that the controller is plugged into. + * @param port The port index on the Driver Station that the controller is plugged into (0-5). */ public XboxController(final int port) { super(port); - HAL.report(tResourceType.kResourceType_XboxController, port + 1); } @@ -157,7 +155,7 @@ public class XboxController extends GenericHID { } /** - * Get the left trigger (LT) axis value of the controller. Note that this axis is bound to the + * 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. @@ -167,7 +165,33 @@ public class XboxController extends GenericHID { } /** - * Get the right trigger (RT) axis value of the controller. Note that this axis is bound to the + * 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 {@link BooleanEvent} 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 + */ + public BooleanEvent leftTrigger(double threshold, EventLoop loop) { + return new BooleanEvent(loop, () -> getLeftTriggerAxis() > threshold); + } + + /** + * 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 the provided + * threshold, attached to the given event loop + */ + public BooleanEvent leftTrigger(EventLoop loop) { + return leftTrigger(0.5, loop); + } + + /** + * 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. @@ -177,155 +201,29 @@ public class XboxController extends GenericHID { } /** - * 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}. * - * @return The state of the button. + * @param threshold the minimum axis value for the returned {@link BooleanEvent} 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 */ - public boolean getLeftBumper() { - return getRawButton(Button.kLeftBumper.value); + public BooleanEvent rightTrigger(double threshold, EventLoop loop) { + return new BooleanEvent(loop, () -> getRightTriggerAxis() > threshold); } /** - * Read the value of the right bumper (RB) button on the controller. - * - * @return The state of the button. - */ - public boolean getRightBumper() { - return getRawButton(Button.kRightBumper.value); - } - - /** - * Whether the left bumper (LB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getLeftBumperPressed() { - return getRawButtonPressed(Button.kLeftBumper.value); - } - - /** - * Whether the right bumper (RB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getRightBumperPressed() { - return getRawButtonPressed(Button.kRightBumper.value); - } - - /** - * Whether the left bumper (LB) was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getLeftBumperReleased() { - return getRawButtonReleased(Button.kLeftBumper.value); - } - - /** - * Whether the right bumper (RB) was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getRightBumperReleased() { - return getRawButtonReleased(Button.kRightBumper.value); - } - - /** - * Constructs an event instance around the right bumper's digital signal. + * 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 representing the right bumper's digital signal attached to the given - * loop. + * @return an event instance that is true when the right trigger's axis exceeds the provided + * threshold, attached to the given event loop */ - public BooleanEvent leftBumper(EventLoop loop) { - return new BooleanEvent(loop, this::getLeftBumper); - } - - /** - * Constructs an event instance around the left bumper's digital signal. - * - * @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. - */ - public BooleanEvent rightBumper(EventLoop loop) { - return new BooleanEvent(loop, this::getRightBumper); - } - - /** - * Read the value of the left stick button (LSB) on the controller. - * - * @return The state of the button. - */ - public boolean getLeftStickButton() { - return getRawButton(Button.kLeftStick.value); - } - - /** - * Read the value of the right stick button (RSB) on the controller. - * - * @return The state of the button. - */ - public boolean getRightStickButton() { - return getRawButton(Button.kRightStick.value); - } - - /** - * Whether the left stick button (LSB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getLeftStickButtonPressed() { - return getRawButtonPressed(Button.kLeftStick.value); - } - - /** - * Whether the right stick button (RSB) was pressed since the last check. - * - * @return Whether the button was pressed since the last check. - */ - public boolean getRightStickButtonPressed() { - return getRawButtonPressed(Button.kRightStick.value); - } - - /** - * Whether the left stick button (LSB) was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getLeftStickButtonReleased() { - return getRawButtonReleased(Button.kLeftStick.value); - } - - /** - * Whether the right stick (RSB) button was released since the last check. - * - * @return Whether the button was released since the last check. - */ - public boolean getRightStickButtonReleased() { - return getRawButtonReleased(Button.kRightStick.value); - } - - /** - * 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 left stick button's digital signal attached to the - * given loop. - */ - public BooleanEvent leftStick(EventLoop loop) { - return new BooleanEvent(loop, this::getLeftStickButton); - } - - /** - * 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 right stick button's digital signal attached to the - * given loop. - */ - public BooleanEvent rightStick(EventLoop loop) { - return new BooleanEvent(loop, this::getRightStickButton); + public BooleanEvent rightTrigger(EventLoop loop) { + return rightTrigger(0.5, loop); } /** @@ -359,10 +257,9 @@ public class XboxController extends GenericHID { * Constructs an event instance around the A 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 A button's digital signal + * attached to the given loop. */ - @SuppressWarnings("MethodName") public BooleanEvent a(EventLoop loop) { return new BooleanEvent(loop, this::getAButton); } @@ -398,10 +295,9 @@ public class XboxController extends GenericHID { * 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 B button's digital signal attached to the given - * loop. + * @return an event instance representing the B button's digital signal + * attached to the given loop. */ - @SuppressWarnings("MethodName") public BooleanEvent b(EventLoop loop) { return new BooleanEvent(loop, this::getBButton); } @@ -437,10 +333,9 @@ public class XboxController extends GenericHID { * Constructs an event instance around the X 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 X button's digital signal + * attached to the given loop. */ - @SuppressWarnings("MethodName") public BooleanEvent x(EventLoop loop) { return new BooleanEvent(loop, this::getXButton); } @@ -476,14 +371,89 @@ public class XboxController extends GenericHID { * 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 Y button's digital signal attached to the given - * loop. + * @return an event instance representing the Y button's digital signal + * attached to the given loop. */ - @SuppressWarnings("MethodName") public BooleanEvent y(EventLoop loop) { return new BooleanEvent(loop, this::getYButton); } + /** + * Read the value of the left bumper button on the controller. + * + * @return The state of the button. + */ + public boolean getLeftBumperButton() { + return getRawButton(Button.kLeftBumper.value); + } + + /** + * Whether the left bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getLeftBumperButtonPressed() { + return getRawButtonPressed(Button.kLeftBumper.value); + } + + /** + * Whether the left bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getLeftBumperButtonReleased() { + return getRawButtonReleased(Button.kLeftBumper.value); + } + + /** + * 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 left bumper button's digital signal + * attached to the given loop. + */ + public BooleanEvent leftBumper(EventLoop loop) { + return new BooleanEvent(loop, this::getLeftBumperButton); + } + + /** + * Read the value of the right bumper button on the controller. + * + * @return The state of the button. + */ + public boolean getRightBumperButton() { + return getRawButton(Button.kRightBumper.value); + } + + /** + * Whether the right bumper button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightBumperButtonPressed() { + return getRawButtonPressed(Button.kRightBumper.value); + } + + /** + * Whether the right bumper button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightBumperButtonReleased() { + return getRawButtonReleased(Button.kRightBumper.value); + } + + /** + * 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 right bumper button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightBumper(EventLoop loop) { + return new BooleanEvent(loop, this::getRightBumperButton); + } + /** * Read the value of the back button on the controller. * @@ -515,8 +485,8 @@ public class XboxController extends GenericHID { * 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 back 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. */ public BooleanEvent back(EventLoop loop) { return new BooleanEvent(loop, this::getBackButton); @@ -553,62 +523,152 @@ public class XboxController extends GenericHID { * 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 start 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. */ public BooleanEvent start(EventLoop loop) { return new BooleanEvent(loop, this::getStartButton); } /** - * 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}. + * Read the value of the left stick button on the controller. * - * @param threshold the minimum axis value for the returned {@link BooleanEvent} 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 + * @return The state of the button. */ - public BooleanEvent leftTrigger(double threshold, EventLoop loop) { - return new BooleanEvent(loop, () -> getLeftTriggerAxis() > threshold); + public boolean getLeftStickButton() { + return getRawButton(Button.kLeftStick.value); } /** - * 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. + * Whether the left stick button was pressed since the last check. * - * @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 + * @return Whether the button was pressed since the last check. */ - public BooleanEvent leftTrigger(EventLoop loop) { - return leftTrigger(0.5, loop); + public boolean getLeftStickButtonPressed() { + return getRawButtonPressed(Button.kLeftStick.value); } /** - * 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}. + * Whether the left stick button was released since the last check. * - * @param threshold the minimum axis value for the returned {@link BooleanEvent} 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 + * @return Whether the button was released since the last check. */ - public BooleanEvent rightTrigger(double threshold, EventLoop loop) { - return new BooleanEvent(loop, () -> getRightTriggerAxis() > threshold); + public boolean getLeftStickButtonReleased() { + return getRawButtonReleased(Button.kLeftStick.value); } /** - * 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. + * 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 that is true when the right trigger's axis exceeds the provided - * threshold, attached to the given event loop + * @return an event instance representing the left stick button's digital signal + * attached to the given loop. */ - public BooleanEvent rightTrigger(EventLoop loop) { - return rightTrigger(0.5, loop); + public BooleanEvent leftStick(EventLoop loop) { + return new BooleanEvent(loop, this::getLeftStickButton); + } + + /** + * Read the value of the right stick button on the controller. + * + * @return The state of the button. + */ + public boolean getRightStickButton() { + return getRawButton(Button.kRightStick.value); + } + + /** + * Whether the right stick button was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + */ + public boolean getRightStickButtonPressed() { + return getRawButtonPressed(Button.kRightStick.value); + } + + /** + * Whether the right stick button was released since the last check. + * + * @return Whether the button was released since the last check. + */ + public boolean getRightStickButtonReleased() { + return getRawButtonReleased(Button.kRightStick.value); + } + + /** + * 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 right stick button's digital signal + * attached to the given loop. + */ + public BooleanEvent rightStick(EventLoop loop) { + return new BooleanEvent(loop, this::getRightStickButton); + } + + /** + * Read the value of the left bumper (LB) button on the controller. + * + * @return The state of the button. + * @deprecated Use {@link getLeftBumperButton} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getLeftBumper() { + return getRawButton(Button.kLeftBumper.value); + } + + /** + * Read the value of the right bumper (RB) button on the controller. + * + * @return The state of the button. + * @deprecated Use {@link getRightBumperButton} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getRightBumper() { + return getRawButton(Button.kRightBumper.value); + } + + /** + * Whether the left bumper (LB) was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + * @deprecated Use {@link getLeftBumperButtonPressed} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getLeftBumperPressed() { + return getRawButtonPressed(Button.kLeftBumper.value); + } + + /** + * Whether the right bumper (RB) was pressed since the last check. + * + * @return Whether the button was pressed since the last check. + * @deprecated Use {@link getRightBumperButtonPressed} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getRightBumperPressed() { + return getRawButtonPressed(Button.kRightBumper.value); + } + + /** + * Whether the left bumper (LB) was released since the last check. + * + * @return Whether the button was released since the last check. + * @deprecated Use {@link getLeftBumperButtonReleased} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getLeftBumperReleased() { + return getRawButtonReleased(Button.kLeftBumper.value); + } + + /** + * Whether the right bumper (RB) was released since the last check. + * + * @return Whether the button was released since the last check. + * @deprecated Use {@link getRightBumperButtonReleased} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public boolean getRightBumperReleased() { + return getRawButtonReleased(Button.kRightBumper.value); } } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/PS4ControllerSim.java b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/simulation/PS4ControllerSim.java similarity index 73% rename from wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/PS4ControllerSim.java rename to wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/simulation/PS4ControllerSim.java index 822b1db58f..a2f1141abc 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/PS4ControllerSim.java +++ b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/simulation/PS4ControllerSim.java @@ -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 ./wpilibj/generate_hids.py. DO NOT MODIFY + package edu.wpi.first.wpilibj.simulation; import edu.wpi.first.wpilibj.PS4Controller; @@ -35,7 +37,7 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -44,16 +46,7 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * Change the X axis value of the controller's right stick. - * - * @param value the new value - */ - public void setRightX(double value) { - setRawAxis(PS4Controller.Axis.kRightX.value, 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 */ @@ -62,7 +55,16 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * Change the Y axis value of the controller's right stick. + * Change the right X value of the controller's joystick. + * + * @param value the new value + */ + public void setRightX(double value) { + setRawAxis(PS4Controller.Axis.kRightX.value, value); + } + + /** + * Change the right Y value of the controller's joystick. * * @param value the new value */ @@ -71,7 +73,7 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * Change the L2 axis value of the controller. + * Change the value of the left trigger 2 axis on the controller. * * @param value the new value */ @@ -80,7 +82,7 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -89,7 +91,7 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -98,7 +100,7 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -107,7 +109,7 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -116,7 +118,7 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -125,7 +127,7 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -134,7 +136,7 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -143,7 +145,7 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -152,7 +154,7 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -161,7 +163,7 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -170,7 +172,7 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -197,7 +199,7 @@ public class PS4ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -210,6 +212,17 @@ public class PS4ControllerSim extends GenericHIDSim { * * @param value the new value */ + public void setTouchpadButton(boolean value) { + setRawButton(PS4Controller.Button.kTouchpad.value, value); + } + + /** + * Change the value of the touchpad button on the controller. + * + * @param value the new value + * @deprecated Use {@link setTouchpadButton} instead + */ + @Deprecated(since = "2025", forRemoval = true) public void setTouchpad(boolean value) { setRawButton(PS4Controller.Button.kTouchpad.value, value); } diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/PS5ControllerSim.java b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/simulation/PS5ControllerSim.java similarity index 73% rename from wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/PS5ControllerSim.java rename to wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/simulation/PS5ControllerSim.java index e11cdd084c..090e74435e 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/PS5ControllerSim.java +++ b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/simulation/PS5ControllerSim.java @@ -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 ./wpilibj/generate_hids.py. DO NOT MODIFY + package edu.wpi.first.wpilibj.simulation; import edu.wpi.first.wpilibj.PS5Controller; @@ -35,7 +37,7 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -44,16 +46,7 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * Change the X axis value of the controller's right stick. - * - * @param value the new value - */ - public void setRightX(double value) { - setRawAxis(PS5Controller.Axis.kRightX.value, 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 */ @@ -62,7 +55,16 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * Change the Y axis value of the controller's right stick. + * Change the right X value of the controller's joystick. + * + * @param value the new value + */ + public void setRightX(double value) { + setRawAxis(PS5Controller.Axis.kRightX.value, value); + } + + /** + * Change the right Y value of the controller's joystick. * * @param value the new value */ @@ -71,7 +73,7 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * Change the L2 axis value of the controller. + * Change the value of the left trigger 2 axis on the controller. * * @param value the new value */ @@ -80,7 +82,7 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -89,7 +91,7 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -98,7 +100,7 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -107,7 +109,7 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -116,7 +118,7 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -125,7 +127,7 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -134,7 +136,7 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -143,7 +145,7 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -152,7 +154,7 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -161,7 +163,7 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -170,7 +172,7 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -197,7 +199,7 @@ public class PS5ControllerSim extends GenericHIDSim { } /** - * 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 */ @@ -210,6 +212,17 @@ public class PS5ControllerSim extends GenericHIDSim { * * @param value the new value */ + public void setTouchpadButton(boolean value) { + setRawButton(PS5Controller.Button.kTouchpad.value, value); + } + + /** + * Change the value of the touchpad button on the controller. + * + * @param value the new value + * @deprecated Use {@link setTouchpadButton} instead + */ + @Deprecated(since = "2025", forRemoval = true) public void setTouchpad(boolean value) { setRawButton(PS5Controller.Button.kTouchpad.value, value); } diff --git a/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/simulation/StadiaControllerSim.java b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/simulation/StadiaControllerSim.java new file mode 100644 index 0000000000..4bde45da27 --- /dev/null +++ b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/simulation/StadiaControllerSim.java @@ -0,0 +1,209 @@ +// 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 ./wpilibj/generate_hids.py. DO NOT MODIFY + +package edu.wpi.first.wpilibj.simulation; + +import edu.wpi.first.wpilibj.StadiaController; + +/** Class to control a simulated Stadia controller. */ +public class StadiaControllerSim extends GenericHIDSim { + /** + * Constructs from a StadiaController object. + * + * @param joystick controller to simulate + */ + @SuppressWarnings("this-escape") + public StadiaControllerSim(StadiaController joystick) { + super(joystick); + setAxisCount(4); + setButtonCount(15); + setPOVCount(1); + } + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + @SuppressWarnings("this-escape") + public StadiaControllerSim(int port) { + super(port); + setAxisCount(4); + setButtonCount(15); + setPOVCount(1); + } + + /** + * Change the left X value of the controller's joystick. + * + * @param value the new value + */ + public void setLeftX(double value) { + setRawAxis(StadiaController.Axis.kLeftX.value, value); + } + + /** + * Change the right X value of the controller's joystick. + * + * @param value the new value + */ + public void setRightX(double value) { + setRawAxis(StadiaController.Axis.kRightX.value, value); + } + + /** + * Change the left Y value of the controller's joystick. + * + * @param value the new value + */ + public void setLeftY(double value) { + setRawAxis(StadiaController.Axis.kLeftY.value, value); + } + + /** + * Change the right Y value of the controller's joystick. + * + * @param value the new value + */ + public void setRightY(double value) { + setRawAxis(StadiaController.Axis.kRightY.value, value); + } + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + public void setAButton(boolean value) { + setRawButton(StadiaController.Button.kA.value, value); + } + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + public void setBButton(boolean value) { + setRawButton(StadiaController.Button.kB.value, value); + } + + /** + * Change the value of the X button on the controller. + * + * @param value the new value + */ + public void setXButton(boolean value) { + setRawButton(StadiaController.Button.kX.value, value); + } + + /** + * Change the value of the Y button on the controller. + * + * @param value the new value + */ + public void setYButton(boolean value) { + setRawButton(StadiaController.Button.kY.value, value); + } + + /** + * Change the value of the left bumper button on the controller. + * + * @param value the new value + */ + public void setLeftBumperButton(boolean value) { + setRawButton(StadiaController.Button.kLeftBumper.value, value); + } + + /** + * Change the value of the right bumper button on the controller. + * + * @param value the new value + */ + public void setRightBumperButton(boolean value) { + setRawButton(StadiaController.Button.kRightBumper.value, value); + } + + /** + * Change the value of the left stick button on the controller. + * + * @param value the new value + */ + public void setLeftStickButton(boolean value) { + setRawButton(StadiaController.Button.kLeftStick.value, value); + } + + /** + * Change the value of the right stick button on the controller. + * + * @param value the new value + */ + public void setRightStickButton(boolean value) { + setRawButton(StadiaController.Button.kRightStick.value, value); + } + + /** + * Change the value of the ellipses button on the controller. + * + * @param value the new value + */ + public void setEllipsesButton(boolean value) { + setRawButton(StadiaController.Button.kEllipses.value, value); + } + + /** + * Change the value of the hamburger button on the controller. + * + * @param value the new value + */ + public void setHamburgerButton(boolean value) { + setRawButton(StadiaController.Button.kHamburger.value, value); + } + + /** + * Change the value of the stadia button on the controller. + * + * @param value the new value + */ + public void setStadiaButton(boolean value) { + setRawButton(StadiaController.Button.kStadia.value, value); + } + + /** + * Change the value of the right trigger button on the controller. + * + * @param value the new value + */ + public void setRightTriggerButton(boolean value) { + setRawButton(StadiaController.Button.kRightTrigger.value, value); + } + + /** + * Change the value of the left trigger button on the controller. + * + * @param value the new value + */ + public void setLeftTriggerButton(boolean value) { + setRawButton(StadiaController.Button.kLeftTrigger.value, value); + } + + /** + * Change the value of the google button on the controller. + * + * @param value the new value + */ + public void setGoogleButton(boolean value) { + setRawButton(StadiaController.Button.kGoogle.value, value); + } + + /** + * Change the value of the frame button on the controller. + * + * @param value the new value + */ + public void setFrameButton(boolean value) { + setRawButton(StadiaController.Button.kFrame.value, value); + } +} diff --git a/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/simulation/XboxControllerSim.java b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/simulation/XboxControllerSim.java new file mode 100644 index 0000000000..8417b777f7 --- /dev/null +++ b/wpilibj/src/generated/main/java/edu/wpi/first/wpilibj/simulation/XboxControllerSim.java @@ -0,0 +1,204 @@ +// 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 ./wpilibj/generate_hids.py. DO NOT MODIFY + +package edu.wpi.first.wpilibj.simulation; + +import edu.wpi.first.wpilibj.XboxController; + +/** Class to control a simulated Xbox controller. */ +public class XboxControllerSim extends GenericHIDSim { + /** + * Constructs from a XboxController object. + * + * @param joystick controller to simulate + */ + @SuppressWarnings("this-escape") + public XboxControllerSim(XboxController joystick) { + super(joystick); + setAxisCount(6); + setButtonCount(10); + setPOVCount(1); + } + + /** + * Constructs from a joystick port number. + * + * @param port port number + */ + @SuppressWarnings("this-escape") + public XboxControllerSim(int port) { + super(port); + setAxisCount(6); + setButtonCount(10); + setPOVCount(1); + } + + /** + * Change the left X value of the controller's joystick. + * + * @param value the new value + */ + public void setLeftX(double value) { + setRawAxis(XboxController.Axis.kLeftX.value, value); + } + + /** + * Change the right X value of the controller's joystick. + * + * @param value the new value + */ + public void setRightX(double value) { + setRawAxis(XboxController.Axis.kRightX.value, value); + } + + /** + * Change the left Y value of the controller's joystick. + * + * @param value the new value + */ + public void setLeftY(double value) { + setRawAxis(XboxController.Axis.kLeftY.value, value); + } + + /** + * Change the right Y value of the controller's joystick. + * + * @param value the new value + */ + public void setRightY(double value) { + setRawAxis(XboxController.Axis.kRightY.value, value); + } + + /** + * Change the value of the left trigger axis on the controller. + * + * @param value the new value + */ + public void setLeftTriggerAxis(double value) { + setRawAxis(XboxController.Axis.kLeftTrigger.value, value); + } + + /** + * Change the value of the right trigger axis on the controller. + * + * @param value the new value + */ + public void setRightTriggerAxis(double value) { + setRawAxis(XboxController.Axis.kRightTrigger.value, value); + } + + /** + * Change the value of the A button on the controller. + * + * @param value the new value + */ + public void setAButton(boolean value) { + setRawButton(XboxController.Button.kA.value, value); + } + + /** + * Change the value of the B button on the controller. + * + * @param value the new value + */ + public void setBButton(boolean value) { + setRawButton(XboxController.Button.kB.value, value); + } + + /** + * Change the value of the X button on the controller. + * + * @param value the new value + */ + public void setXButton(boolean value) { + setRawButton(XboxController.Button.kX.value, value); + } + + /** + * Change the value of the Y button on the controller. + * + * @param value the new value + */ + public void setYButton(boolean value) { + setRawButton(XboxController.Button.kY.value, value); + } + + /** + * Change the value of the left bumper button on the controller. + * + * @param value the new value + */ + public void setLeftBumperButton(boolean value) { + setRawButton(XboxController.Button.kLeftBumper.value, value); + } + + /** + * Change the value of the right bumper button on the controller. + * + * @param value the new value + */ + public void setRightBumperButton(boolean value) { + setRawButton(XboxController.Button.kRightBumper.value, value); + } + + /** + * Change the value of the back button on the controller. + * + * @param value the new value + */ + public void setBackButton(boolean value) { + setRawButton(XboxController.Button.kBack.value, value); + } + + /** + * Change the value of the start button on the controller. + * + * @param value the new value + */ + public void setStartButton(boolean value) { + setRawButton(XboxController.Button.kStart.value, value); + } + + /** + * Change the value of the left stick button on the controller. + * + * @param value the new value + */ + public void setLeftStickButton(boolean value) { + setRawButton(XboxController.Button.kLeftStick.value, value); + } + + /** + * Change the value of the right stick button on the controller. + * + * @param value the new value + */ + public void setRightStickButton(boolean value) { + setRawButton(XboxController.Button.kRightStick.value, value); + } + + /** + * Change the value of the left bumper on the joystick. + * + * @param state the new value + * @deprecated Use {@link setLeftBumperButton} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public void setLeftBumper(boolean state) { + setRawButton(XboxController.Button.kLeftBumper.value, state); + } + + /** + * Change the value of the right bumper on the joystick. + * + * @param state the new value + * @deprecated Use {@link setRightBumperButton} instead + */ + @Deprecated(since = "2025", forRemoval = true) + public void setRightBumper(boolean state) { + setRawButton(XboxController.Button.kRightBumper.value, state); + } +} diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/XboxControllerSim.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/XboxControllerSim.java deleted file mode 100644 index 37e0bda32d..0000000000 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/XboxControllerSim.java +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package edu.wpi.first.wpilibj.simulation; - -import edu.wpi.first.wpilibj.XboxController; - -/** Class to control a simulated Xbox 360 or Xbox One controller. */ -public class XboxControllerSim extends GenericHIDSim { - /** - * Constructs from a XboxController object. - * - * @param joystick controller to simulate - */ - @SuppressWarnings("this-escape") - public XboxControllerSim(XboxController joystick) { - super(joystick); - setAxisCount(6); - setButtonCount(10); - setPOVCount(1); - } - - /** - * Constructs from a joystick port number. - * - * @param port port number - */ - @SuppressWarnings("this-escape") - public XboxControllerSim(int port) { - super(port); - setAxisCount(6); - setButtonCount(10); - setPOVCount(1); - } - - /** - * Change the left X value of the joystick. - * - * @param value the new value - */ - public void setLeftX(double value) { - setRawAxis(XboxController.Axis.kLeftX.value, value); - } - - /** - * Change the right X value of the joystick. - * - * @param value the new value - */ - public void setRightX(double value) { - setRawAxis(XboxController.Axis.kRightX.value, value); - } - - /** - * Change the left Y value of the joystick. - * - * @param value the new value - */ - public void setLeftY(double value) { - setRawAxis(XboxController.Axis.kLeftY.value, value); - } - - /** - * Change the right Y value of the joystick. - * - * @param value the new value - */ - public void setRightY(double value) { - setRawAxis(XboxController.Axis.kRightY.value, value); - } - - /** - * Change the value of the left trigger axis on the joystick. - * - * @param value the new value - */ - public void setLeftTriggerAxis(double value) { - setRawAxis(XboxController.Axis.kLeftTrigger.value, value); - } - - /** - * Change the value of the right trigger axis on the joystick. - * - * @param value the new value - */ - public void setRightTriggerAxis(double value) { - setRawAxis(XboxController.Axis.kRightTrigger.value, value); - } - - /** - * Change the value of the left bumper on the joystick. - * - * @param state the new value - */ - public void setLeftBumper(boolean state) { - setRawButton(XboxController.Button.kLeftBumper.value, state); - } - - /** - * Change the value of the right bumper on the joystick. - * - * @param state the new value - */ - public void setRightBumper(boolean state) { - setRawButton(XboxController.Button.kRightBumper.value, state); - } - - /** - * Change the value of the left stick button on the joystick. - * - * @param state the new value - */ - public void setLeftStickButton(boolean state) { - setRawButton(XboxController.Button.kLeftStick.value, state); - } - - /** - * Change the value of the right stick button on the joystick. - * - * @param state the new value - */ - public void setRightStickButton(boolean state) { - setRawButton(XboxController.Button.kRightStick.value, state); - } - - /** - * Change the value of the A button. - * - * @param state the new value - */ - public void setAButton(boolean state) { - setRawButton(XboxController.Button.kA.value, state); - } - - /** - * Change the value of the B button. - * - * @param state the new value - */ - public void setBButton(boolean state) { - setRawButton(XboxController.Button.kB.value, state); - } - - /** - * Change the value of the X button. - * - * @param state the new value - */ - public void setXButton(boolean state) { - setRawButton(XboxController.Button.kX.value, state); - } - - /** - * Change the value of the Y button. - * - * @param state the new value - */ - public void setYButton(boolean state) { - setRawButton(XboxController.Button.kY.value, state); - } - - /** - * Change the value of the Back button. - * - * @param state the new value - */ - public void setBackButton(boolean state) { - setRawButton(XboxController.Button.kBack.value, state); - } - - /** - * Change the value of the Start button. - * - * @param state the new value - */ - public void setStartButton(boolean state) { - setRawButton(XboxController.Button.kStart.value, state); - } -}