Compare commits

...

98 Commits

Author SHA1 Message Date
Thad House
9ea17c1d53 [glass] Fix ANSI handling at end column (#9011)
Ported from mrccomm
2026-06-22 15:55:48 -07:00
Peter Johnson
aef281f43d [wpilib] Fix DifferentialDrivetrainSimTest (#8934)
- Fix a dependency on other test global state via Vin by calling
ResetData() to ensure consistent state
- Clamp the ground truth voltages to match sim.SetInputs()
- The C++ test was checking the noisy measurement output instead of
using sim.GetState()
- Make GetState() public in C++ and Java
2026-06-21 20:20:21 -07:00
Tyler Veness
be110d0469 [hal] Port last GoogleTest unit test to Catch2 (#9010)
This fixes a linker error I got for gtest.
2026-06-21 20:12:48 -07:00
Sam Carlberg
ffd371cbf8 [cmd3] Add example and template projects for commands v3 and make hatchbot example idiomatic (#8887)
The `command3` example project contains a program that could plausibly
play in the 2026 rebuilt game. It includes nested mechanisms (`Intake`
has an inner `IntakeWrist` and `IntakeRoller` and is similar to the v2
superstructure concept), swerve drive with localization and path
following (albeit stubbed for sake of example), opmodes and
opmode-scoped commands, and command-scoped triggers.

The template projects are basic skeletons. The larger template includes
a basic command that just increments and prints a counter variable every
time it runs.

The hatchbot v3 example has been refactored to be more idiomatic:
- `RobotContainer` removed
- "Subsystem" names in packages, comments, and classes has been replaced
with "Mechanism"
- Some v2-specific comments and structures have been reworded or deleted
- The Drive mechanism now provides commands for arcade drive and driving
a distance, instead of exposing public methods that write directly to
hardware (which broke encapsulation and made it possible to issue
conflicting hardware requests)
2026-06-21 20:10:53 -07:00
Thad House
8444a58640 [wpilib,cmd] Add expanded game controller list (#8959)
Extension of #8957
2026-06-21 19:37:32 -07:00
PJ Reiniger
4a2cd3e5d0 [robotpy] Run wpiformat on non-python robotpy files (#8362)
This turns the styleguide on for the non-python robotpy files.

The overwhelming amount of changes were
related to whitespace, followed by some IWYU for standard library
headers.
2026-06-21 19:36:03 -07:00
PJ Reiniger
6bc7051e23 [robotpy] Port more wpilibc tests to python (#8903)
I tasked Claude with converting the existing C++ tests to python for
wpilib. I gave it a decent review for comparison to the existing tests,
and it seems to have covered everything. I did do some small cleanup in
a couple of places. One notable test that is missing is the LED
patterns, but that is getting handled in
[mostrobotpy](https://github.com/robotpy/mostrobotpy/pull/254) land.
2026-06-21 19:33:50 -07:00
PJ Reiniger
45d4ed5bca [wpilibc] Change DriverStationSim to use a C++ enum for alliance station (#8991) 2026-06-21 19:29:19 -07:00
Peter Johnson
af91ba39f2 [glass,sim] Add sim GUI support for DS display (#8998) 2026-06-21 19:27:02 -07:00
Peter Johnson
c3fe63b2f7 [hal] Translate unit tests to catch2 (#9003) 2026-06-21 19:26:10 -07:00
Peter Johnson
912938b434 [tools] Translate unit tests to catch2 (#9006) 2026-06-21 19:24:30 -07:00
Peter Johnson
edbf2db5a7 [sim] Translate unit tests to catch2 (#9004) 2026-06-21 19:13:33 -07:00
Satchit Kulkarni
678176cd3c [wpimath] Add drivetrain anti-tipping utility (#8787)
Resolves #8587

This PR implements the requested anti-tipping utility and refactors the
math to correctly adhere to the NWU coordinate system.

**Key Changes:**
* Fixed the axis mapping: Positive pitch now correctly maps to a forward
tip (+X), and positive roll maps to a rightward tip (-Y).
* Inverted the proportional control logic: The correction vector now
applies a positive `kP` to drive *into* the direction of the fall to get
the wheels back under the center of gravity, rather than driving away
from it.
* Added a comprehensive JUnit test suite (`AntiTippingTest.java`) to
verify the calculated `ChassisSpeeds` correctly zero out the orthogonal
axis and provide the correct positive/negative velocity across all four
tipping directions.

Tested locally against `testDesktopJava` and passes all style/formatting
guidelines.

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-21 19:11:48 -07:00
Tyler Veness
d4f89c11c3 [wpimath] Use triangular solves to compute UKF Kalman gain (#9009) 2026-06-21 15:09:34 -07:00
Peter Johnson
7298d9eafb [wpinet] Unit tests: use UNSCOPED_INFO in several places (#9007) 2026-06-21 13:52:38 -07:00
Peter Johnson
7dcb70cfcd [datalog] Translate unit tests to catch2 (#9002) 2026-06-21 13:51:49 -07:00
Peter Johnson
3d6df4a50e [apriltag] Translate unit tests to catch2 (#9001) 2026-06-21 13:50:11 -07:00
Peter Johnson
50eab65b07 [cscore] Translate unit tests to catch2 (#8999) 2026-06-21 13:49:07 -07:00
Thad House
f1c9d82d50 [hal,wpilib] Add DS Display API (#8975) 2026-06-20 10:28:24 -07:00
Tyler Veness
481a586009 [upstream_utils] Upgrade to Sleipnir 0.6.2 (#8996) 2026-06-19 20:16:03 -07:00
Peter Johnson
396b553069 [wpinet] Translate unit tests to catch2 (#8954) 2026-06-19 19:49:50 -07:00
PJ Reiniger
cfab47e871 [bazel] Improve vendored deps, make libssh vendored (#8948)
TL;DR: kill https://github.com/wpilibsuite/bzlmodRio-libssh, update
versions, and make things easier for a script to update.

The main motivation behind this was that libssh was out of date with the
gradle version. Using these "external" dependencies can cause agita as
we churn through toolchain updates. Unlike the toolchains and opencv,
which can be used by external users (i.e. a all bazel robot, if a vendor
wanted to use bazel) a C++ wrapper around libssh maven deps almost
certainly wouldn't be pulled in, much like ceres and mrclib.

As a result of vendor'ing libssh, and knowing some potential pitfalls
and annoyances, this PR does the following:
- Vendor libssh, akin to how mrclib is pulled in
- Moves the vendor'd ceres to `shared/bazel/thirdparty`, and refactors
it to better match mrclib. To me it doesn't necessarily belong in its
`thirdparty` location because it is bazel only.
- Due to the refactoring, libssh and ceres can now be pulled into
`MODULE.bazel` instead of the `WORKSPACE.bzlmod` helper. This is good
prep for a potential upgrade to killing `--enable_workspace` / bazel 9
- Write a python script that can deal with the integrity / sha256 of the
http_archives. I suggested this be added to davo's mrclib PR, but this
one is a little bit more robust and will actually edit the files in
place. This makes upgrading versions substantially easier.
- Upgrade libssh version to what gradle is using, and mrclib to the
version in #8858. These changes have been tested against that PR.
2026-06-19 15:25:07 -07:00
Dan Katzuv
637f006f9b [ci] Build Javadoc with JDK 26 for dark theme support (#8842) 2026-06-19 15:24:13 -07:00
Peter Johnson
608f024f82 [ntcore] Add PubSubOption to disable handle signaling (#8972)
This helps reduce lock contention on Synchronization Signal objects if
the user does not intend to use this signaling path.

Use this option on the RobotBase MultiSubscriber to all topics.
2026-06-19 15:17:37 -07:00
Thad House
8d2f3212e7 [wpilib,cmd2] Fix up issues with generated gamepads (#8985)
There were a few issues with the generated classes.

Python had a __getattr__ forwarder that we defintely did not want.
C++ was using a struct with constexpr values, and not an enum class for
button types.
In all 3, the forwarders from gamepad didn't exist on the generated
types.

This fixes all 3.

---------

Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2026-06-19 14:53:41 -07:00
Thad House
0b950ea6d9 [wpilibj] Crash robot program if an exception occurs during opmode construction (#8982)
There's essentially nothing the user can do here, other then switch
opmodes. It will make it clearer that something is very wrong.
2026-06-19 14:51:46 -07:00
Tyler Veness
ad797456f5 [ci] Upgrade to wpiformat 2026.64 (#8993) 2026-06-19 08:40:55 -05:00
Tyler Veness
e92478c212 [upstream_utils] Upgrade to Catch2 3.15.1 (#8994) 2026-06-19 08:40:13 -05:00
Thad House
0662a78892 [sim] GUI: Fix buttons starting at 1 instead of 0 (#8987)
Closes #8986
2026-06-17 14:39:14 -06:00
Benjamin Hall
c35df58a81 [wpilibc] Change DriverStationSim to use wpi::hal::RobotMode (#8988)
The `RobotState::GetRobotMode()` API returns this enum class, but
`DriverStationSim` was using the `HAL_RobotMode` enum instead. This
commonizes the two APIs to return the same `RobotMode` enum class.

This difference in the APIs also affected Python, as the `hal.RobotMode`
and `hal._wpiHal._RobotMode` types are not compatible with each other.
2026-06-17 14:38:13 -06:00
Thad House
5a7d7d50ee [wpilib,cmd] Remove Axis from Gamepad Triggers (#8956)
It's a bit confusing, especially since some controllers will have this be
a 0:1 button rather than axis.
2026-06-12 06:42:06 -07:00
Thad House
d6fb871a26 [ci] Build bazel builds in docker (#8978)
Needed for mrclib, as mrclib is built on a trixie image.
2026-06-12 05:59:21 -07:00
Thad House
489b993e60 [hal,wpilib] Switch CANBusMap to Enum, use it for CAN API (#8977)
Will make it easier to solve
https://github.com/wpilibsuite/SystemcoreTesting/issues/286
2026-06-11 16:14:40 -07:00
Thad House
97381549e6 [wpilib,cmd] Add new generation for gamepads (#8957)
SDL makes these schemas much simpler, so its easier to support more
controllers.
2026-06-11 16:06:45 -07:00
Thad House
025732093f [wpilib] Remove UserControls (#8973)
It was too complex, and we can solve it by figuring out how to make
singleton GenericHID objects, implemented in #8970.
2026-06-11 15:33:51 -07:00
Thad House
c647e67de0 [wpilib,cmd] Cache HID wrappers (#8970)
Store DriverStation-owned GenericHID and Gamepad instances in Java and
C++, and expose the cached objects to Python bindings.

Move hand-written command gamepad and joystick wrappers to compose
cached CommandGenericHID instances plus typed HID wrappers, including a
Python CommandGamepad.

This will let us remove UserControls, while helping ensure that we don't
have state smashing between GenericHID objects.

Another bonus is without inheritance, intellisense will no longer show a
bunch of annoying methods, and instead just what actually exists.

---------

Co-authored-by: Peter Johnson <johnson.peter@gmail.com>
2026-06-11 09:42:39 -07:00
Zach Harel
fe499ede4c [build] Update avaje to 3.14 (#8974)
This fixes inherited and generic fields and getters.

Signed-off-by: Zach Harel <zach@zharel.me>
2026-06-10 23:50:01 -07:00
Gold856
3f966aa7c6 Clean up unused includes (#8950) 2026-06-09 22:16:26 -07:00
Thad House
72d85be0c2 [ntcore] Add API to get and set user data on NT_Topic (#8962)
Theres many uses where we need to attach data to a topic, and doing it
this way can make it really easy and efficient.
2026-06-08 19:24:15 -07:00
PJ Reiniger
111130d8bb [copybara] Sync with robotpy (#8964)
GitOrigin-RevId: 9dff8f977401e78be0bb6f39cea2328320ab2d95
2026-06-08 19:22:48 -07:00
Thad House
0213ecf382 [build] Update native utils, to switch to new compilers (#8966) 2026-06-08 19:21:33 -07:00
Zach Harel
bdd45c7365 [cmd2] Move .cpp files to subproject source root (#8967)
This matches all of the other subprojects.

Signed-off-by: Zach Harel <zach@zharel.me>
2026-06-08 19:20:48 -07:00
David Vo
44501bf5eb [bazel] Update rules_cc with patches (#8969)
@AustinSchuh's `rules_cc` patches have all been merged upstream. This
updates `rules_cc` to include the relevant patches, removing the need to
patch it here.

This also squashes this warning on every build:

> WARNING: For repository 'rules_cc', the root module requires module
version rules_cc@0.2.13, but got rules_cc@0.2.14 in the resolved
dependency graph. Please update the version in your MODULE.bazel or set
--check_direct_dependencies=off
2026-06-08 19:20:03 -07:00
Thad House
1be5da5bde [wpiutil] Fix Handle.hpp not including cstddef (#8965) 2026-06-07 16:08:11 -07:00
Thad House
06fb36ba8e [hal] Switch IMU to mrclib (#8961) 2026-06-06 16:30:08 -07:00
Thad House
71ed28f768 [hal] Switch SmartIO to mrclib (#8960) 2026-06-06 14:54:49 -07:00
Peter Johnson
edf77fa007 [hal,sim] Add notifier generation counter to WaitForProgramStart (#8947)
This fixes simulation WaitForProgramStart(true) potentially advancing
due to a stale or pre-start notifier created before SetProgramStarted()
was called.
2026-06-06 12:17:14 -07:00
Thad House
6e5171cd8f [hal] Use MrcLib to talk to DS (#8858)
Using MrcLib on the robot is going to be the plan for the future, to
make things easier.

MrcLib is how sim is supported going forward. The desktop version of
mrclib can act as a robot server.

This is set up where the mrclib interface is in shared code. On robot,
that is the only backend used. On desktop, a default sim backend is
used. However, the sim plugin can switch that to the real robot backend,
so the robot code will exactly look like a real robot.
2026-06-06 12:15:17 -07:00
Peter Johnson
ddf9306264 [ntcore] Fix a couple of bugs in NetworkOutgoingQueue (#8953)
Fix SetPeriod() valuePos handling when an ID moves between period queues

In SendValue(), don't append older values, and fix the total size
accounting for the underflow case when a smaller value replaces a larger
value.

Add comprehensive unit tests.
2026-06-05 20:35:11 -07:00
Peter Johnson
88d8369751 [upstream_utils] Update catch2 to 3.15.0 (#8955) 2026-06-05 20:34:20 -07:00
Peter Johnson
96fb033deb [build] Remove cmake Java support (#8952)
This is increasingly difficult to maintain, and has very limited
benefit. Modern coprocessors with enough horsepower to run Java
applications can use the Gradle or Bazel build systems instead.
2026-06-05 15:05:09 -07:00
Vasista Vovveti
d941be905e [ntcore] NetworkClient: Add IsLoopClosing() guard in deferred disconnect timer (#8936)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-05 15:01:44 -07:00
Peter Johnson
e085c3e8b3 [examples,cscore] Don't use assertTimeoutPreemptively in tests (#8951)
Particularly with short timeouts, this results in spurious failures
under high CPU load.
2026-06-05 07:28:51 -07:00
Sam Carlberg
98c03baf54 [javac] Add compiler check for integer division in floating-point contexts (#8885)
Useful for catching bad behavior when doing math or configuring ratios
with integers. Errors can be turned off with
`@SuppressWarnings("IntegerDivision")`

```java
double kV = 12 / 6000; // error: integer division in a floating-point context
double kV = 12. / 6000; // OK
double kV = 12 / 6000.; // OK

int kV = 12 / 6000; // OK, but evaluates to 0

double ratio = 42 / 12; // error: integer division in a floating-point context

@SuppressWarnings("IntegerDivision")
double ratio = 42 / 12; // OK, evaluates to 2
```

```
Execution failed for task ':developerRobot:compileJava'.
> Compilation failed; see the compiler output below.
  /Users/sam/code/wpilib/allwpilib/developerRobot/src/main/java/wpilib/robot/Robot.java:10: error: integer division in a floating-point context
    double kV = 12 / 6000;
                   ^
  1 error
```

Also adds the compiler plugin as a dependency to the developerRobot
project for dev testing
2026-06-04 21:56:22 -07:00
sciencewhiz
8353b95507 Add avahi license to ThirdPartyNotices (#8883) 2026-06-04 21:54:00 -07:00
Benjamin Hall
a41679854b [wpimath] Fix C++ Odometry ResetRotation missing a negation (#8949)
The original implementation was `m_gyroOffset + (rotation -
m_pose.Rotation())`, which means the first `RotateBy` should be using
`-m_pose.Rotation()` (see `ResetPose()`). Java is already correct. This
also adds new tests to catch this particular error.
2026-06-04 17:03:22 -07:00
PJ Reiniger
fdc6fd9cb1 [build][bazel] Combine remote setup CI actions (#8893)
When the bazel remote cache was switched from buildbuddy to a self
hosted server in #8342, I asked that the buildbuddy hooks be remain so
that I could still use their caching service for local builds.

The downside of this was that my forks builds aren't leveraging
buildbuddy, so if I'm fiddling with something heavy like a wpimath
robotpy thing, my CI builds never update a cache and never are warm when
I push fixups.


This PR combines the `setup-bazel-remote` and `setup-build-buddy`
actions which set up the bazel remote cache. Rather than having two
different version, the correct one will be choosen in the following
order:
1. Use wpi's server with write access if the `bazel_remote` information
is set (This basically would only happen on main branch in
`wpilibsuite/allwpilib` since secrets aren't accessible from builds
originating in forks)
2. Use buildbuddy if the key it is present (This would work for my fork
builds)
3. Fall back to the readonly version of wpi's server


As seen
[here](https://github.com/bzlmodRio/allwpilib/actions/runs/25777428163/job/75712863120#step:7:28)
the build in my fork will run with buildbuddy, and my PR's build here
should fall back to readonly mode.
2026-06-03 20:16:42 -07:00
PJ Reiniger
dca59147e1 [robotpy][examples] Split examples and snippets (#8944)
This also updates the bazel scripts to behave more like the C++ and Java
examples, and updates the copybara scripts to be able to sync up
`mostrobotpy`
2026-06-03 19:43:16 -07:00
Benjamin Hall
a734275cc5 [wpimath] Add const qualifier to C++ SwerveModuleVelocity Optimize and CosineScale (#8946)
These two functions were changed to return new objects instead of
modifying in-place, so the `const` qualifier should be added. Otherwise,
users with a const reference to a `SwerveModuleVelocity` need to make a
temporary copy first.
2026-06-03 19:42:05 -07:00
Peter Johnson
3f0d7bc2c4 [wpiutil,hal] Move C++ Handle wrapper to wpiutil (#8935)
Also move WPI_Handle typedef to its own header (util/Handle.h).
2026-06-01 14:57:25 -06:00
Vasista Vovveti
3d982f81dd [ntcore] Update period on added or removed, not XOR (#8941)
`added ^ removed` (XOR) is incorrect for the update guard.
Both `added` and `removed` can be true simultaneously (e.g. subscription
options change), and XOR would incorrectly skip the period update. Fixed
to `added || removed`.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-01 14:56:23 -06:00
sciencewhiz
a3c18d24a7 [examples] Add mecanum drive snippets (#8931)
shows both polar, and cartesian
2026-05-29 23:10:42 -07:00
Peter Johnson
c597116f02 [hal] HALSIM_StepTiming: Avoid underflow (#8933)
Don't advance time if the only active timer is in the past; just wake up
any notifiers.
2026-05-29 23:10:02 -07:00
Peter Johnson
9adffd356d [hal] Update waitForProgramStart to optionally wait for first notifier (#8932)
This addresses a race condition caused by TimedRobot and other
frameworks not creating their first notifier alarm until after signaling
program start.

Default this to true because it's the most common desired use case when
combined with TimedRobot.
2026-05-29 23:09:25 -07:00
Thad House
635e971a02 [wpilib] Add a default deadband to all gamepads (#8897)
The FTC DS had a deadband. Additionally, the FRC one had an implicit
deadband due to the only 8 bit resolution. We need a deadband by default
now with the high resolution gamepads.
2026-05-29 16:31:48 -07:00
sciencewhiz
40fdb779d8 [examples] Add differential drive snippets (#8927)
Shows tank, arcade, and curvature for wpilib-docs
2026-05-29 15:00:12 -07:00
Tyler Veness
e728ee27f2 [upstream_utils] Upgrade to Sleipnir 0.6.1 (#8930)
This fixes a memory leak on Windows.
2026-05-29 14:59:39 -07:00
Guinea Wheek
50fd29e697 [ntcore] Fix unbounded memory size tracker (#8929)
If a `ClientMessageQueue` is at a
memory limit, `ClientMessageQueueImpl::ClientSetValue` will still
increment `m_valueSize.size` even though no element has actually been
actually been added.

This quickly results in things like topics completely shutting down
under high load, as no new elements can be added as `m_valueSize.size`
explodes to infinity unless `ClearQueue()` is explicitly called. You can
see this pretty easily with the following code, be it in sim or on a
robot:

```cpp
#include "wpi/framework/TimedRobot.hpp"
#include "wpi/smartdashboard/SmartDashboard.hpp"
class Robot : public wpi::TimedRobot {
  public:
  // ...
  uint64_t value{0};
  /**
   * This function is called periodically during all modes
   */
  void RobotPeriodic() override {
    for (int i = 0; i < 1'000'000; i++) {
      value += 1;
      wpi::SmartDashboard::PutNumber("value", value);
    }
  }
}
```

Connecting via your favorite dashboard quickly reveals that no new
values get added after a while. However, with this patch implemented,
values do still continue to increment as updates gradually get serviced.
2026-05-29 11:01:13 -07:00
Sam Carlberg
4fa5dacfc4 [epilogue] Improve support for robot base classes in epilogue (#8886)
Generate an `update` method for any logged Robot class, not just
TimedRobot

Continue to generate a `bind` method for TimedRobot subclasses

Also removes unnecessary import statements for generated loggers, since
they're using fully-qualified names in the generated Epilogue class now.
2026-05-29 00:14:30 -04:00
sciencewhiz
1e12408a7d [examples] add motor safety and invert to motor snip (#8924) 2026-05-28 20:09:07 -07:00
sciencewhiz
14db070c2c [build] Add guard for missing arm64 msvc runtime (#8922) 2026-05-28 20:08:46 -07:00
sciencewhiz
5c3a474a58 Replace references of frc-docs with wpilib-docs (NFC) (#8926) 2026-05-28 09:01:11 -06:00
Tyler Veness
f1d95ee5f8 [upstream_utils] Upgrade to Sleipnir 0.6.0 (#8923) 2026-05-27 21:26:42 -07:00
Jonah Snider
7ff32d7756 [epilogue,ntcore,wpiunits] Use pattern matching switch expressions where possible (#8925)
Use [pattern matching switch
expressions](https://docs.oracle.com/en/java/javase/17/language/pattern-matching-switch.html)
where possible. This is a JVM 21+ feature which wasn't available until
recently.

If you look at the Java bytecode, this improves performance from an O(n)
runtime check of literally each of the `if (x instanceof y)` checks to
instead be an O(1) tableswitch.

---------

Signed-off-by: Jonah Snider <jonah@jonahsnider.com>
2026-05-27 18:06:15 -07:00
Tyler Veness
aedee56e22 [upstream_utils] Add cbegin()/cend()/crbegin()/crend() to SmallVector (#8918)
std::vector has these.
2026-05-26 21:55:50 -07:00
Peter Johnson
ac7a9524f8 [wpigui] Add stdint.h include to PFD (#8920)
Needed for uint8_t.
2026-05-26 21:55:22 -07:00
Thad House
b100586cab [wpilib] Finish gamepad face button rename (#8921) 2026-05-26 21:55:07 -07:00
Tyler Veness
254ca64106 [upstream_utils] Upgrade to LLVM 22.1.6 (#8919) 2026-05-26 16:25:29 -07:00
Peter Johnson
1392db4529 [romi] Fix Romi motor support (#8915)
Since Servo has been removed from WPILib, add a RomiServo to replace it
(similar to XRPServo).

For Romi, move allocation of PWM channels to OnBoardIO since Motor and
Servo share channels.
2026-05-23 17:38:36 -07:00
Peter Johnson
40f9a87e70 [xrp] Fix motor support (#8916)
The protocol layer got out of sync with the rename to throttle.
2026-05-23 17:37:38 -07:00
Sam Carlberg
94fda36e04 [cmd3] Add trigger multi press and continuous bindings (#8901)
`Trigger.multiPress(N, T)` creates a trigger that fires when there are
at least N rising edges within the last T timespan, eg `multiPress(3,
Seconds.of(1.25))` for 3 rising edges within the last 1.25 seconds.

`Trigger.retryWhileTrue` and `retryWhileFalse` will continuously attempt
to schedule a command while the binding condition is met. This is
similar to `whileTrue` and `whileFalse`, but will reschedule the command
if it ends or is canceled while the binding condition is still met,
rather than requiring a new rising edge to reschedule it.
2026-05-23 16:51:45 -07:00
Sam Carlberg
f217dfe747 [cmd3] Make sideload functions scoped and improve docs (#8900)
Notably, this removes the ability to escape command scoping by using a
sideloaded function to schedule another command
2026-05-23 16:50:46 -07:00
crueter
d86378d353 [wpimath,wpiunits] Add PoundSquareInches MOI unit, and improve KilogramMetersSquaredPerSecond definition (#8838)
As discussed in the discord. lb-in^2 is the common imperial MOI unit,
e.g. Onshape uses it.

Also, improved the Java docstring for `KilogramMetersSquaredPerSecond`
to explain what it represents.

---------

Co-authored-by: Benjamin Hall <bhall@ctr-electronics.com>
2026-05-23 16:41:35 -07:00
Gold856
ac41523eb4 [ci] Run wpilibc through asan (#8868) 2026-05-23 16:40:32 -07:00
David Vo
d48f1cd0e5 [bazel] Add mrclib dependency (#8873)
This pulls in the `mrclib` maven repository as shared libraries, as a
prereq for #8858.

Alternative to #8869, which avoids the unnecessary lockfile entry. This
should be a one-to-one replacement for that PR.

Closes #8869

---------

Co-authored-by: PJ Reiniger <pj.reiniger@gmail.com>
2026-05-23 16:39:47 -07:00
Gold856
e88729c67e [ci] Start avahi-daemon in sentinel builds (#8914)
This fixes the mDNS test failures in the sentinel builds.
2026-05-23 15:39:22 -07:00
Daniel Chen
e35ca772fd [cmd3] Make Mechanism an interface (#8303)
Since there is no longer a requirement for Subsystems/Mechanisms to be
registered to the command scheduler via a register() call, Mechanism can
be changed to an interface instead to allow for more flexible
inheritance structures.

Specifically, this would allow compatibility with CTRE swerve (which
previously required implementing Subsystem so that it could extend
CTRE's base class).
2026-05-18 19:30:12 -05:00
Thad House
fa24446ce3 [wpilib,cmd] Rename gamepad face-button trigger APIs to directional names (faceUp/Down/Left/Right) (#8896)
This updates gamepad trigger naming from cardinal-style face buttons
(`northFace/southFace/eastFace/westFace` and
`NorthFace/SouthFace/EastFace/WestFace`) to directional naming
(`faceUp/faceDown/faceRight/faceLeft` and
`FaceUp/FaceDown/FaceRight/FaceLeft`) to match the requested API shape.
The change is applied across Java and C++ HID/command layers, along with
related examples and binding metadata.

- **API surface updates (Java)**
  - Renamed trigger/event methods in:
    - `wpilibj` `Gamepad`
    - `commandsv2` `CommandGamepad`
    - `commandsv3` `CommandGamepad`
  - Mapping preserved:
    - `southFace` → `faceDown`
    - `eastFace` → `faceRight`
    - `westFace` → `faceLeft`
    - `northFace` → `faceUp`

- **API surface updates (C++)**
  - Renamed trigger/event methods in:
    - `wpilibc` `Gamepad`
    - `commandsv2` `CommandGamepad`
  - Mapping preserved:
    - `SouthFace` → `FaceDown`
    - `EastFace` → `FaceRight`
    - `WestFace` → `FaceLeft`
    - `NorthFace` → `FaceUp`

- **Python semiwrap updates**
- Updated `wpilibc/src/main/python/semiwrap/Gamepad.yml` method mappings
to the renamed C++ method names (`FaceDown/FaceRight/FaceLeft/FaceUp`).

- **Callsite migration**
- Updated Java examples/template code and C++ examples/template code to
use the new method names so samples remain aligned with the API rename.

- **Docs/comments alignment**
- Updated related Javadoc/reference text and example comments to use
directional terminology.

```java
// Before
driverController.southFace().onTrue(command);
driverController.eastFace().onTrue(command);

// After
driverController.faceDown().onTrue(command);
driverController.faceRight().onTrue(command);
```

```cpp
// Before
driverController.SouthFace().OnTrue(command);
driverController.EastFace().OnTrue(command);

// After
driverController.FaceDown().OnTrue(command);
driverController.FaceRight().OnTrue(command);
```

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ThadHouse <7727148+ThadHouse@users.noreply.github.com>
2026-05-15 00:08:57 -05:00
Thad House
67b795057b [build] Add arm64 MSVC Runtime (#8840) 2026-05-15 00:06:18 -05:00
sciencewhiz
e4ae671b49 [ci] Add CI spelling check and fix spelling errors (#8882)
reviewdog/action-misspell is used on frc-docs. It has a dictionary of
commonly misspelled words, so it has less false positives then other
tools.
2026-05-14 21:55:02 -07:00
David Vo
f751ca88eb [bazel] Enforce up-to-date lock file in CI (#8860)
The Bazel lock file was missing a few dependencies. This adds a check in
CI that the lock file is up-to-date.
2026-05-14 21:54:04 -07:00
PJ Reiniger
6ba5734a94 [robotpy] Add wrapper for timestamp functions, like SetNowImpl (#8889)
`SetNowImpl` is used somewhat often in unit tests. It is a little bit
goofier to wrap because it takes a C function, so a little bit more work
has to be done to get that wrapped in pybind.

Claude helped.
2026-05-14 21:53:26 -07:00
PJ Reiniger
68d24bb29e [python] Improve robotpy generation (#8867)
The initial build file generation for robotpy projects was relatively
naive and purpose built to get `allwpilib` compiling, without supporting
all the available features.

This modifies the generation scripts to be able to support multiple
embedded libraries, which will be necessary for #8858, since `mrclib.so`
will need to be bundled along with the hal libraries. In addition some
cleanup was done to get the wheels looking more like what is in pypi.
2026-05-14 21:52:39 -07:00
Thad House
3f1cf3cabe [wpilib] ExHub Follower Fixes (#8892)
A chunk of updates to followers on Expansion Hub

Fixes followers not implicitly enabling.
Allows followers to follow other followers
Throws exceptions on construction if a follower cycle is detected.
Allows reversing followers.

The enable thing will fix
https://github.com/wpilibsuite/SystemcoreTesting/discussions/259#discussioncomment-16886195

Closes #8843

Depends on https://github.com/wpilibsuite/scservices/pull/30
2026-05-14 21:50:38 -07:00
Jade
b91001f504 Add nix files to gitignore (#8894)
Based on discord comments I assume we don't want to support a Nix shell
or flake for use with building allwpilib so we should just ignore these
files so users can have their own
2026-05-14 21:49:01 -07:00
Thad House
ffd36eb091 [developerRobot] Add an OpModeRobot instance to DeveloperRobot (#8891)
You can switch to it just by switching Main.java
2026-05-14 21:48:09 -07:00
crueter
97c0b0c40a [upstream_utils] Patch LLVM SmallSetIterator for AppleClang 21 (#8877)
Signed-off-by: crueter <crueter@eden-emu.dev>
2026-05-08 12:49:47 -07:00
sciencewhiz
16fcf016de [examples] Update command template names with v2 to disambiguate (NFC) (#8875)
Partially addresses wpilibsuite/vscode-wpilib#876
2026-05-08 09:34:52 -07:00
1410 changed files with 93170 additions and 14412 deletions

View File

@@ -68,7 +68,6 @@ build:remote_user --config=remote_cache_readonly
build:remote_user --remote_download_toplevel
common:ci --color=yes
build:ci --config=remote_cache
build:ci --remote_download_minimal
build:ci --progress_report_interval=60 --show_progress_rate_limit=60

View File

@@ -0,0 +1,38 @@
name: 'Setup Bazel Cache'
description: 'Configures the Bazel remote cache. Prefers WPI bazel-remote (R/W), falls back to BuildBuddy, then readonly WPI cache.'
inputs:
bazel_remote_username:
description: 'WPI Bazel remote cache username'
bazel_remote_password:
description: 'WPI Bazel remote cache password'
bazel_remote_url:
description: 'WPI Bazel remote cache base URL (no credentials or protocol, e.g. gitlib-bazel.wpi.edu)'
default: 'gitlib-bazel.wpi.edu'
buildbuddy_token:
description: 'BuildBuddy API token'
runs:
using: "composite"
steps:
- name: Resolve Bazel cache configuration
env:
CACHE_USER: ${{ inputs.bazel_remote_username }}
CACHE_PASS: ${{ inputs.bazel_remote_password }}
REMOTE_URL: ${{ inputs.bazel_remote_url }}
BB_TOKEN: ${{ inputs.buildbuddy_token }}
shell: bash
run: |
if [ -n "${CACHE_USER}" ] && [ -n "${CACHE_PASS}" ]; then
echo "WPI bazel-remote credentials detected; configuring R/W access"
echo "build:remote_cache --remote_cache=grpcs://${CACHE_USER}:${CACHE_PASS}@${REMOTE_URL}" > bazel_auth.rc
echo "build:ci --config=remote_cache" >> bazel_auth.rc
elif [ -n "${BB_TOKEN}" ]; then
echo "BuildBuddy token detected; configuring BuildBuddy cache"
echo "build:build_buddy --remote_header=x-buildbuddy-api-key=${BB_TOKEN}" > bazel_auth.rc
echo "build:ci --config=build_buddy" >> bazel_auth.rc
else
echo "No cache credentials detected; falling back to readonly WPI cache"
echo "build:ci --config=remote_cache" > bazel_auth.rc
echo "build:ci --config=remote_cache_readonly" >> bazel_auth.rc
fi

View File

@@ -1,37 +0,0 @@
name: 'Setup Bazel Remote cache'
description: 'Sets up bazel-remote cache using basic auth from GitHub secrets'
inputs:
username:
description: 'Bazel remote cache username'
password:
description: 'Bazel remote cache password'
remote_url:
description: 'Bazel remote cache base URL (no credentials or protocol, e.g. gitlib-bazel.wpi.edu)'
default: 'gitlib-bazel.wpi.edu'
runs:
using: "composite"
steps:
- name: Setup bazel-remote (skip when no creds)
env:
CACHE_USER: ${{ inputs.username }}
CACHE_PASS: ${{ inputs.password }}
REMOTE_URL: ${{ inputs.remote_url }}
if: ${{ env.CACHE_USER == '' || env.CACHE_PASS == '' }}
shell: bash
run: |
echo "No bazel-remote credentials detected; leaving caching as previously configured"
echo "build:ci --config=remote_cache_readonly" >> bazel_auth.rc
- name: Setup bazel-remote (with creds)
env:
CACHE_USER: ${{ inputs.username }}
CACHE_PASS: ${{ inputs.password }}
REMOTE_URL: ${{ inputs.remote_url }}
if: ${{ env.CACHE_USER != '' && env.CACHE_PASS != '' }}
shell: bash
run: |
echo "Bazel-remote credentials detected; configuring bazel_auth.rc"
URL_WITH_CREDS="grpcs://${CACHE_USER}:${CACHE_PASS}@${REMOTE_URL}"
echo "build:remote_cache --remote_cache=${URL_WITH_CREDS}" >> bazel_auth.rc

View File

@@ -1,38 +0,0 @@
name: 'Setup BuildBuddy acache'
description: 'Sets up the build buddy cache to be readonly / writing based on the presence of environment variables'
inputs:
token:
description: 'Build Buddy API token'
runs:
using: "composite"
steps:
# Sets up build buddy when no secret is found for the API key. This is most likely because this is triggered from an action from a fork instead of the main allwpilib repo.
- name: Setup without key
env:
API_KEY: ${{ inputs.token }}
if: ${{ env.API_KEY == '' }}
shell: bash
run: |
echo "No API key secret detected, will setup readonly cache"
echo "build:ci --config=build_buddy_readonly" > bazel_auth.rc
# Set up the readonly key only if this build is for a pull request. Push builds happen in the forks repository,
# so the user should set their own buildbuddy api keys up there. Only enabling it for PR's should reduce heavy
# and more random load on the cache.
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "Assuming this is a pull request from a fork. Setting up the readonly api key"
echo "build:ci --remote_header=x-buildbuddy-api-key=QIOV65PTW1tVal3AJbe7" >> bazel_auth.rc
else
echo "Not setting up readonly key for trigger ${{ github.event_name }} since this is not a pull request, it is most likely a forks push. See the buildbuddy setup guide in README-Bazel.md to set up caching on your fork"
fi
- name: Set with key
env:
API_KEY: ${{ inputs.token }}
if: ${{ env.API_KEY != '' }}
shell: bash
run: |
echo "API Key detected!"
echo "build:build_buddy --remote_header=x-buildbuddy-api-key=${{ env.API_KEY }}" > bazel_auth.rc

View File

@@ -12,28 +12,29 @@ jobs:
fail-fast: false
matrix:
include:
- { name: "Linux System Core", classifier: "linuxsystemcore", os: ubuntu-24.04, action: "build" }
- { name: "Linux System Core Debug", classifier: "linuxsystemcoredebug", os: ubuntu-24.04, action: "build" }
- { name: "Linux System Core Static", classifier: "linuxsystemcorestatic", os: ubuntu-24.04, action: "build" }
- { name: "Linux System Core Static Debug", classifier: "linuxsystemcorestaticdebug", os: ubuntu-24.04, action: "build" }
- { name: "Linux x86-64", classifier: "linuxx86-64,headers,sources", os: ubuntu-24.04, action: "test" }
- { name: "Linux x86-64 Debug", classifier: "linuxx86-64debug", os: ubuntu-24.04, action: "test" }
- { name: "Linux x86-64 Static", classifier: "linuxx86-64static", os: ubuntu-24.04, action: "test" }
- { name: "Linux x86-64 Static Debug", classifier: "linuxx86-64staticdebug", os: ubuntu-24.04, action: "test" }
- { name: "Linux System Core", classifier: "linuxsystemcore", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "build" }
- { name: "Linux System Core Debug", classifier: "linuxsystemcoredebug", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "build" }
- { name: "Linux System Core Static", classifier: "linuxsystemcorestatic", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "build" }
- { name: "Linux System Core Static Debug", classifier: "linuxsystemcorestaticdebug", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "build" }
- { name: "Linux x86-64", classifier: "linuxx86-64,headers,sources", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "test" }
- { name: "Linux x86-64 Debug", classifier: "linuxx86-64debug", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "test" }
- { name: "Linux x86-64 Static", classifier: "linuxx86-64static", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "test" }
- { name: "Linux x86-64 Static Debug", classifier: "linuxx86-64staticdebug", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "test" }
- { name: "macOS", classifier: "osxuniversal,osxuniversaldebug,headers,sources,osxuniversalstatic,osxuniversalstaticdebug,linuxsystemcore,linuxsystemcoredebug,linuxsystemcorestatic,linuxsystemcorestaticdebug", os: macOS-15, action: "test" }
- { name: "macOS", classifier: "osxuniversal,osxuniversaldebug,headers,sources,osxuniversalstatic,osxuniversalstaticdebug,linuxsystemcore,linuxsystemcoredebug,linuxsystemcorestatic,linuxsystemcorestaticdebug", os: macOS-15, container: "", action: "test" }
- { name: "Windows x86-64", classifier: "windowsx86-64,windowsx86-64static,headers,sources", os: windows-2022, action: "test" }
- { name: "Windows x86-64 Debug", classifier: "windowsx86-64debug,windowsx86-64staticdebug", os: windows-2022, action: "test" }
- { name: "Windows x86-64", classifier: "windowsx86-64,windowsx86-64static,headers,sources", os: windows-2022, container: "", action: "test" }
- { name: "Windows x86-64 Debug", classifier: "windowsx86-64debug,windowsx86-64staticdebug", os: windows-2022, container: "", action: "test" }
- { name: "Windows ARM64", classifier: "windowsarm64,windowsarm64static", os: windows-2022, action: "build" }
- { name: "Windows ARM64 Debug", classifier: "windowsarm64debug,windowsarm64staticdebug", os: windows-2022, action: "build" }
- { name: "Windows ARM64", classifier: "windowsarm64,windowsarm64static", os: windows-2022, container: "", action: "build" }
- { name: "Windows ARM64 Debug", classifier: "windowsarm64debug,windowsarm64staticdebug", os: windows-2022, container: "", action: "build" }
- { name: "Windows System Core", classifier: "linuxsystemcore,linuxsystemcorestatic", os: windows-2022, action: "build" }
- { name: "Windows System Core Debug", classifier: "linuxsystemcoredebug,linuxsystemcorestaticdebug", os: windows-2022, action: "build" }
- { name: "Windows System Core", classifier: "linuxsystemcore,linuxsystemcorestatic", os: windows-2022, container: "", action: "build" }
- { name: "Windows System Core Debug", classifier: "linuxsystemcoredebug,linuxsystemcorestaticdebug", os: windows-2022, container: "", action: "build" }
name: "${{ matrix.action == 'test' && 'Test' || 'Build' }} ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- name: Check disk free space pre-cleanup
run: df -h
@@ -66,16 +67,23 @@ jobs:
- uses: actions/checkout@v6
with: { fetch-depth: 0 }
- id: Setup_bazel_remote
uses: ./.github/actions/setup-bazel-remote
- id: Setup_bazel_cache
uses: ./.github/actions/setup-bazel-cache
with:
username: ${{ secrets.BAZEL_CACHE_USERNAME }}
password: ${{ secrets.BAZEL_CACHE_PASSWORD }}
bazel_remote_username: ${{ secrets.BAZEL_CACHE_USERNAME }}
bazel_remote_password: ${{ secrets.BAZEL_CACHE_PASSWORD }}
buildbuddy_token: ${{ secrets.BUILDBUDDY_API_KEY }}
- name: Install apt dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libgl1-mesa-dev libx11-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev avahi-daemon
- name: Setup avahi-daemon
if: runner.os == 'Linux'
run: |
sudo service dbus start
sudo avahi-daemon -D
- if: runner.os == 'Linux'
uses: bazel-contrib/setup-bazel@0.15.0
with:
@@ -137,6 +145,27 @@ jobs:
path: "*-bazel-lint-fixes.patch"
if: ${{ failure() }}
mod-lock:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Check lockfile
run: bazel mod deps --lockfile_mode=error
- run: bazel mod deps --lockfile_mode=update
if: ${{ failure() }}
- name: Generate diff
run: git diff HEAD > bazel-mod-lock-fixes.patch
if: ${{ failure() }}
- uses: actions/upload-artifact@v7
with:
archive: false
path: "bazel-mod-lock-fixes.patch"
if: ${{ failure() }}
non_robotpy_pregeneration:
name: "Non-RobotPy Pregen"
runs-on: ubuntu-24.04
@@ -144,14 +173,15 @@ jobs:
- uses: actions/checkout@v6
with: { fetch-depth: 0 }
- id: Setup_bazel_remote
uses: ./.github/actions/setup-bazel-remote
- id: Setup_bazel_cache
uses: ./.github/actions/setup-bazel-cache
with:
username: ${{ secrets.BAZEL_CACHE_USERNAME }}
password: ${{ secrets.BAZEL_CACHE_PASSWORD }}
bazel_remote_username: ${{ secrets.BAZEL_CACHE_USERNAME }}
bazel_remote_password: ${{ secrets.BAZEL_CACHE_PASSWORD }}
buildbuddy_token: ${{ secrets.BUILDBUDDY_API_KEY }}
- name: Run Non-RobotPy pregeneration
run: bazel run //:write_pregenerated_files
run: bazel run --config=ci //:write_pregenerated_files
- name: Check Output
run: git --no-pager diff --exit-code HEAD
@@ -173,21 +203,23 @@ jobs:
- uses: actions/checkout@v6
with: { fetch-depth: 0 }
- id: Setup_build_buddy
uses: ./.github/actions/setup-build-buddy
- id: Setup_bazel_cache
uses: ./.github/actions/setup-bazel-cache
with:
token: ${{ secrets.BUILDBUDDY_API_KEY }}
bazel_remote_username: ${{ secrets.BAZEL_CACHE_USERNAME }}
bazel_remote_password: ${{ secrets.BAZEL_CACHE_PASSWORD }}
buildbuddy_token: ${{ secrets.BUILDBUDDY_API_KEY }}
# You should ensure the headers are correct before trying to pregen files
- name: Test Scan Headers
run: bazel test //... -k --test_tag_filters=robotpy_scan_headers --build_tests_only
run: bazel test --config=ci //... -k --test_tag_filters=robotpy_scan_headers --build_tests_only
shell: bash
- name: Run yaml file generation
run: bazel run //:write_robotpy_update_yaml_files
run: bazel run --config=ci //:write_robotpy_update_yaml_files
- name: Run build file generation
run: bazel run //:write_robotpy_generated_pybind_files
run: bazel run --config=ci //:write_robotpy_generated_pybind_files
- name: Check Output
run: git --no-pager diff --exit-code HEAD

View File

@@ -33,11 +33,6 @@ jobs:
ndk-version: r27d
add-to-path: false
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 25
- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.9
@@ -45,7 +40,7 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y ninja-build
- name: configure
run: cmake --preset with-sccache -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_WPILIB=OFF -DWITH_GUI=OFF -DWITH_CSCORE=OFF -DWITH_TESTS=OFF -DWITH_SIMULATION_MODULES=OFF -DWITH_JAVA=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake -DANDROID_ABI="${{ matrix.abi }}" -DANDROID_PLATFORM=android-24
run: cmake --preset with-sccache -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_WPILIB=OFF -DWITH_GUI=OFF -DWITH_CSCORE=OFF -DWITH_TESTS=OFF -DWITH_SIMULATION_MODULES=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake -DANDROID_ABI="${{ matrix.abi }}" -DANDROID_PLATFORM=android-24
env:
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

View File

@@ -18,8 +18,8 @@ jobs:
include:
- os: ubuntu-24.04
name: Linux
container: wpilib/systemcore-cross-ubuntu:2027-24.04
flags: "--preset with-java-and-sccache -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON"
container: wpilib/systemcore-cross-debian:trixie
flags: "--preset with-sccache -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON"
- os: macOS-15
name: macOS
container: ""
@@ -35,7 +35,7 @@ jobs:
steps:
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv-java ninja-build
run: sudo apt-get update && sudo apt-get install -y libopencv-dev ninja-build
- name: Setup avahi-daemon
if: runner.os == 'Linux'

View File

@@ -19,13 +19,13 @@ jobs:
fail-fast: false
matrix:
include:
- container: wpilib/systemcore-cross-ubuntu:2027-24.04
- container: wpilib/systemcore-cross-debian:trixie
artifact-name: Systemcore
build-options: "-Ponlylinuxsystemcore"
- container: wpilib/aarch64-cross-ubuntu:2027-bookworm-24.04
- container: wpilib/aarch64-cross-debian:trixie
artifact-name: Arm64
build-options: "-Ponlylinuxarm64"
- container: wpilib/systemcore-cross-ubuntu:2027-24.04
- container: wpilib/systemcore-cross-debian:trixie
artifact-name: Linux
build-options: "-Ponlylinuxx86-64"
name: "Build - ${{ matrix.artifact-name }}"
@@ -195,7 +195,7 @@ jobs:
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 25
java-version: 26
- name: Set release environment variable
run: echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v')

View File

@@ -36,7 +36,7 @@ jobs:
- name: Install wpiformat
run: |
python -m venv ${{ runner.temp }}/wpiformat
${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2026.57
${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2026.64
- name: Run
run: ${{ runner.temp }}/wpiformat/bin/wpiformat
- name: Check output
@@ -61,7 +61,7 @@ jobs:
name: "clang-tidy"
runs-on: ubuntu-24.04
needs: [validation]
container: wpilib/ubuntu-base:24.04
container: wpilib/debian-base:trixie
steps:
- uses: actions/checkout@v6
with:
@@ -78,7 +78,7 @@ jobs:
- name: Install wpiformat
run: |
python -m venv ${{ runner.temp }}/wpiformat
${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2026.57
${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2026.64
- name: Create compile_commands.json
run: |
./gradlew generateCompileCommands -Ptoolchain-optional-roboRio
@@ -94,7 +94,7 @@ jobs:
name: "Java format"
runs-on: ubuntu-24.04
needs: [validation]
container: wpilib/systemcore-cross-ubuntu:2027-24.04
container: wpilib/debian-base:trixie
steps:
- uses: actions/checkout@v6
with:
@@ -123,3 +123,27 @@ jobs:
echo '' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
if: ${{ failure() }}
check-spelling:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: misspell
uses: reviewdog/action-misspell@v1
with:
reporter: "github-check"
fail_level: "error"
exclude: |
**/*.svg
**/thirdparty/**
**/upstream_utils/**
**/generated/**
./wpigui/src/main/native/cpp/portable-file-dialogs.*
./wpimath/src/main/native/include/wpi/units/base.hpp
./wpinet/src/main/native/linux/AvahiClient.*
./wpinet/src/main/native/cpp/http_parser.cpp
./wpinet/src/main/native/include/wpi/net/http_parser.hpp
./wpiutil/src/main/native/include/wpi/util/FastQueue.hpp
./wpiutil/src/test/native/cpp/json/**
./wpiutil/src/test/native/cpp/llvm/**
./wpiutil/src/test/native/cpp/span/**

View File

@@ -19,7 +19,7 @@ jobs:
- name: asan
cmake-flags: "-DCMAKE_BUILD_TYPE=Asan"
ctest-env: ""
ctest-flags: "-E 'wpilibc'"
ctest-flags: ""
- name: tsan
cmake-flags: "-DCMAKE_BUILD_TYPE=Tsan"
ctest-env: "TSAN_OPTIONS=second_deadlock_stack=1:suppressions=$GITHUB_WORKSPACE/tsan_suppressions.txt"
@@ -30,10 +30,10 @@ jobs:
ctest-flags: ""
name: "${{ matrix.name }}"
runs-on: ubuntu-24.04
container: wpilib/roborio-cross-ubuntu:2025-24.04
container: wpilib/debian-base:trixie
steps:
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv-java clang-18 ninja-build avahi-daemon
run: sudo apt-get update && sudo apt-get install -y libopencv-dev clang-18 ninja-build avahi-daemon
- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.10
@@ -41,7 +41,7 @@ jobs:
- uses: actions/checkout@v6
- name: configure
run: mkdir build && cd build && cmake -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-18 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-18 -DWITH_JAVA=OFF ${{ matrix.cmake-flags }} ..
run: mkdir build && cd build && cmake -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-18 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-18 ${{ matrix.cmake-flags }} ..
env:
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

View File

@@ -23,13 +23,13 @@ jobs:
fail-fast: false
matrix:
include:
- container: wpilib/systemcore-cross-ubuntu:2027-24.04
- container: wpilib/systemcore-cross-debian:trixie
artifact-name: Systemcore
build-options: "-Ponlylinuxsystemcore"
- container: wpilib/aarch64-cross-ubuntu:2027-bookworm-24.04
- container: wpilib/aarch64-cross-debian:trixie
artifact-name: Arm64
build-options: "-Ponlylinuxarm64"
- container: wpilib/systemcore-cross-ubuntu:2027-24.04
- container: wpilib/systemcore-cross-debian:trixie
artifact-name: Linux
build-options: "-Ponlylinuxx86-64"
name: "Build - ${{ matrix.artifact-name }}"
@@ -54,7 +54,11 @@ jobs:
with:
image: ${{ matrix.container }}
options: -v ${{ github.workspace }}:/work -w /work -e GITHUB_REF -e CI
run: ./gradlew build -PbuildServer -PskipJavaFormat ${{ matrix.build-options }}
# Start avahi-daemon and build
run: |
service dbus start
avahi-daemon -D
./gradlew build -PbuildServer -PskipJavaFormat ${{ matrix.build-options }}
- name: Check free disk space
run: df .
- uses: actions/upload-artifact@v7

5
.gitignore vendored
View File

@@ -261,3 +261,8 @@ bazel_auth.rc
# Copybara user config
shared/bazel/copybara/.copybara.json
# Nix files
shell.nix
flake.nix
flake.lock

View File

@@ -13,7 +13,10 @@ generatedFileExclude {
docs/theme\.css$
generated/
hal/src/main/native/systemcore/rev/
python/
src/main/python/.*/type_casters/
src/main/python/.*\.py$
src/test/python/.*\.py$
robotpyExamples/
resources/
thirdparty/
@@ -40,4 +43,8 @@ licenseUpdateExclude {
wpiutil/src/main/native/cpp/Base64\.cpp$
wpiutil/src/main/native/cpp/sha1\.cpp$
wpiutil/src/main/native/include/wpi/util/sha1\.hpp$
wpinet/src/main/native/linux/AvahiClient\.hpp$
src/main/python/
src/test/python/
}

View File

@@ -63,9 +63,7 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Options for building certain parts of the repo. Everything is built by default.
option(BUILD_SHARED_LIBS "Build with shared libs (needed for JNI)" ON)
option(WITH_JAVA "Include Java and JNI in the build" OFF)
option(WITH_JAVA_SOURCE "Build Java source jars" ${WITH_JAVA})
option(BUILD_SHARED_LIBS "Build with shared libs" ON)
option(WITH_DOCS "Build Doxygen docs (needs Git for versioning)" OFF)
cmake_dependent_option(
DOCS_WARNINGS_AS_ERRORS
@@ -78,13 +76,6 @@ option(WITH_CSCORE "Build cscore (needs OpenCV)" ON)
option(WITH_NTCORE "Build ntcore" ON)
option(WITH_WPICAL "Build wpical" OFF)
option(WITH_WPIMATH "Build wpimath" ON)
cmake_dependent_option(
WITH_WPIUNITS
"Build wpiunits"
ON
WITH_JAVA
OFF
)
option(WITH_WPILIB "Build hal, wpilibc/j, and developerRobot (needs OpenCV)" ON)
option(WITH_EXAMPLES "Build examples" OFF)
option(WITH_TESTS "Build unit tests (requires internet connection)" ON)
@@ -98,26 +89,9 @@ option(USE_SYSTEM_LIBUV "Use system libuv" OFF)
option(USE_SYSTEM_EIGEN "Use system eigen" OFF)
option(USE_LINKED_AVAHI "Use directly linked Avahi instead of loading at runtime" OFF)
# Options for location of OpenCV Java.
set(OPENCV_JAVA_INSTALL_DIR "" CACHE PATH "Location to search for the OpenCV jar file")
# Options for compilation flags.
option(NO_WERROR "Disable -Werror flag during compilation" OFF)
if(NOT WITH_JAVA OR NOT WITH_CSCORE)
if(NOT "${OPENCV_JAVA_INSTALL_DIR}" STREQUAL "")
message(
WARNING
"
WARNING: OpenCV Java dir set but java is not enabled!
It will be ignored.
"
)
endif()
endif()
wpilib_config(OPTIONS WITH_JAVA REQUIRES BUILD_SHARED_LIBS)
wpilib_config(OPTIONS WITH_SIMULATION_MODULES REQUIRES BUILD_SHARED_LIBS WITH_WPILIB WITH_NTCORE)
wpilib_config(OPTIONS WITH_CSCORE REQUIRES WITH_NTCORE)
@@ -126,17 +100,7 @@ wpilib_config(OPTIONS WITH_GUI REQUIRES WITH_NTCORE WITH_WPIMATH)
wpilib_config(OPTIONS WITH_WPILIB REQUIRES WITH_NTCORE WITH_WPIMATH)
wpilib_config(OPTIONS WITH_WPIMATH WITH_JAVA REQUIRES WITH_WPIUNITS)
set(include_dest include)
set(java_lib_dest java)
if(WITH_JAVA OR WITH_JAVA_SOURCE)
set(CMAKE_JAVA_COMPILE_FLAGS "-encoding" "UTF8" "-Xlint:unchecked" "-proc:full")
find_package(Java REQUIRED COMPONENTS Development)
if(NOT ANDROID)
find_package(JNI REQUIRED COMPONENTS JVM)
endif()
endif()
if(WITH_DOCS)
find_package(Doxygen REQUIRED)
@@ -283,13 +247,8 @@ endif()
set(FILENAME_DEP_REPLACE "get_filename_component(SELF_DIR \"$\{CMAKE_CURRENT_LIST_FILE\}\" PATH)")
set(SELF_DIR "$\{SELF_DIR\}")
set(WPIUNITS_DEP_REPLACE_IMPL "find_dependency(wpiunits)")
set(WPIANNOTATIONS_DEP_REPLACE_IMPL "find_dependency(wpiannotations)")
set(WPIUTIL_DEP_REPLACE "find_dependency(wpiutil)")
set(DATALOG_DEP_REPLACE "find_dependency(datalog)")
if(WITH_JAVA)
add_subdirectory(wpiannotations)
endif()
add_subdirectory(wpiutil)
@@ -303,20 +262,10 @@ if(WITH_NTCORE)
endif()
if(WITH_WPIMATH)
if(WITH_JAVA)
set(WPIUNITS_DEP_REPLACE ${WPIUNITS_DEP_REPLACE_IMPL})
add_subdirectory(wpiunits)
endif()
set(WPIMATH_DEP_REPLACE "find_dependency(wpimath)")
add_subdirectory(wpimath)
endif()
if(WITH_WPIUNITS AND NOT WITH_WPIMATH)
# In case of building wpiunits standalone
set(WPIUNITS_DEP_REPLACE ${WPIUNITS_DEP_REPLACE_IMPL})
add_subdirectory(wpiunits)
endif()
if(WITH_GUI)
add_subdirectory(fields)
add_subdirectory(thirdparty/imgui_suite)
@@ -347,16 +296,10 @@ endif()
if(WITH_WPILIB)
set(APRILTAG_DEP_REPLACE "find_dependency(apriltag)")
set(COMMANDSV3_DEP_REPLACE "find_dependency(commandsv3)")
set(WPILIBC_DEP_REPLACE "find_dependency(wpilibc)")
if(WITH_JAVA)
set(WPILIBJ_DEP_REPLACE "find_dependency(wpilibj)")
endif()
set(COMMAND_DEP_REPLACE "find_dependency(commandsv2)")
add_subdirectory(apriltag)
add_subdirectory(wpilibj)
add_subdirectory(wpilibc)
add_subdirectory(commandsv3) # must be after wpilibj
add_subdirectory(commandsv2)
add_subdirectory(romiVendordep)
add_subdirectory(xrpVendordep)

View File

@@ -24,27 +24,6 @@
"CMAKE_C_COMPILER_LAUNCHER": "sccache",
"CMAKE_CXX_COMPILER_LAUNCHER": "sccache"
}
},
{
"name": "with-java",
"displayName": "",
"description": "Ninja config with Java",
"generator": "Ninja",
"binaryDir": "build-cmake",
"cacheVariables": {
"WITH_JAVA": "ON"
}
},
{
"name": "with-java-and-sccache",
"displayName": "",
"description": "Ninja config with Java and sccache",
"generator": "Ninja",
"inherits": "with-sccache",
"binaryDir": "build-cmake",
"cacheVariables": {
"WITH_JAVA": "ON"
}
}
]
}

View File

@@ -21,7 +21,7 @@ So you want to contribute your changes back to WPILib. Great! We have a few cont
- Some features, such the addition of C++26 for WPILibC or Functional Interfaces for WPILibJ, are specific to that version of WPILib only. New language features added to C++ must be wrappable in Python for [RobotPy](https://github.com/robotpy).
- Changes should have tests.
- Code should be well documented.
- This involves writing tutorials and/or usage guides for your submitted feature. These articles are then hosted on the [WPILib](https://docs.wpilib.org/) documentation website. See the [frc-docs repository](https://github.com/wpilibsuite/frc-docs) for more information.
- This involves writing tutorials and/or usage guides for your submitted feature. These articles are then hosted on the [WPILib](https://docs.wpilib.org/) documentation website. See the [wpilib-docs repository](https://github.com/wpilibsuite/wpilib-docs) for more information.
## What to Contribute

View File

@@ -5,19 +5,14 @@ module(
include("//docs:doxygen.MODULE.bazel")
include("//shared/bazel/thirdparty/ceres:ceres.MODULE.bazel")
include("//shared/bazel/thirdparty/libssh:libssh.MODULE.bazel")
include("//shared/bazel/thirdparty/mrclib:mrclib.MODULE.bazel")
bazel_dep(name = "apple_support", version = "2.0.0", repo_name = "build_bazel_apple_support")
# TODO(austin): Upgrade when the patches land.
# https://github.com/bazelbuild/rules_cc/pull/430
# https://github.com/bazelbuild/rules_cc/pull/431
# https://github.com/bazelbuild/rules_cc/pull/432
bazel_dep(name = "rules_cc", version = "0.2.13")
single_version_override(
module_name = "rules_cc",
patch_strip = 1,
patches = ["//:shared/bazel/patches/rules_cc_windows.patch"],
)
bazel_dep(name = "rules_cc", version = "0.2.17")
bazel_dep(name = "rules_pkg", version = "1.1.0")
bazel_dep(name = "bazel_features", version = "1.33.0")
bazel_dep(name = "aspect_bazel_lib", version = "2.14.0")
@@ -53,8 +48,8 @@ maven.install(
name = "maven",
artifacts = [
"org.ejml:ejml-simple:0.44.0",
"io.avaje:avaje-jsonb:3.11",
"io.avaje:avaje-jsonb-generator:3.11",
"io.avaje:avaje-jsonb:3.14",
"io.avaje:avaje-jsonb-generator:3.14",
"us.hebi.quickbuf:quickbuf-runtime:1.4",
"com.google.code.gson:gson:2.13.1",
"org.wpilib.thirdparty.opencv:opencv-java:2027-4.13.0-1",

312
MODULE.bazel.lock generated
View File

@@ -117,7 +117,8 @@
"https://bcr.bazel.build/modules/rules_cc/0.2.0/MODULE.bazel": "b5c17f90458caae90d2ccd114c81970062946f49f355610ed89bebf954f5783c",
"https://bcr.bazel.build/modules/rules_cc/0.2.13/MODULE.bazel": "eecdd666eda6be16a8d9dc15e44b5c75133405e820f620a234acc4b1fdc5aa37",
"https://bcr.bazel.build/modules/rules_cc/0.2.14/MODULE.bazel": "353c99ed148887ee89c54a17d4100ae7e7e436593d104b668476019023b58df8",
"https://bcr.bazel.build/modules/rules_cc/0.2.14/source.json": "55d0a4587c5592fad350f6e698530f4faf0e7dd15e69d43f8d87e220c78bea54",
"https://bcr.bazel.build/modules/rules_cc/0.2.17/MODULE.bazel": "1849602c86cb60da8613d2de887f9566a6d354a6df6d7009f9d04a14402f9a84",
"https://bcr.bazel.build/modules/rules_cc/0.2.17/source.json": "3832f45d145354049137c0090df04629d9c2b5493dc5c2bf46f1834040133a07",
"https://bcr.bazel.build/modules/rules_cc/0.2.8/MODULE.bazel": "f1df20f0bf22c28192a794f29b501ee2018fa37a3862a1a2132ae2940a23a642",
"https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6",
"https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/MODULE.bazel": "40c97d1144356f52905566c55811f13b299453a14ac7769dfba2ac38192337a8",
@@ -204,6 +205,156 @@
},
"selectedYankedVersions": {},
"moduleExtensions": {
"@@pybind11_bazel+//:internal_configure.bzl%internal_configure_extension": {
"general": {
"bzlTransitiveDigest": "uxP2cZuW027Q8wpZbeJeuW5MXcNBO8GcOK/LNN2sPvQ=",
"usagesDigest": "D1r3lfzMuUBFxgG8V6o0bQTLMk3GkaGOaPzw53wrwyw=",
"recordedFileInputs": {
"@@pybind11_bazel+//MODULE.bazel": "e6f4c20442eaa7c90d7190d8dc539d0ab422f95c65a57cc59562170c58ae3d34"
},
"recordedDirentsInputs": {},
"envVariables": {},
"generatedRepoSpecs": {
"pybind11": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"build_file": "@@pybind11_bazel+//:pybind11-BUILD.bazel",
"strip_prefix": "pybind11-2.12.0",
"urls": [
"https://github.com/pybind/pybind11/archive/v2.12.0.zip"
]
}
}
},
"recordedRepoMappingEntries": [
[
"pybind11_bazel+",
"bazel_tools",
"bazel_tools"
]
]
}
},
"@@rules_apple+//apple:apple.bzl%provisioning_profile_repository_extension": {
"general": {
"bzlTransitiveDigest": "JNyWptXQtF/Vu+dUIk3wLLXiS47h7sDP2eYWSsD28xU=",
"usagesDigest": "vsJl8Rw5NL+5Ag2wdUDoTeRF/5klkXO8545Iy7U1Q08=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
"envVariables": {},
"generatedRepoSpecs": {
"local_provisioning_profiles": {
"repoRuleId": "@@rules_apple+//apple/internal:local_provisioning_profiles.bzl%provisioning_profile_repository",
"attributes": {}
}
},
"recordedRepoMappingEntries": [
[
"apple_support+",
"bazel_skylib",
"bazel_skylib+"
],
[
"bazel_tools",
"rules_cc",
"rules_cc+"
],
[
"rules_apple+",
"bazel_skylib",
"bazel_skylib+"
],
[
"rules_apple+",
"bazel_tools",
"bazel_tools"
],
[
"rules_apple+",
"build_bazel_apple_support",
"apple_support+"
],
[
"rules_apple+",
"build_bazel_rules_swift",
"rules_swift+"
],
[
"rules_cc+",
"bazel_tools",
"bazel_tools"
],
[
"rules_cc+",
"cc_compatibility_proxy",
"rules_cc++compatibility_proxy+cc_compatibility_proxy"
],
[
"rules_cc+",
"rules_cc",
"rules_cc+"
],
[
"rules_cc++compatibility_proxy+cc_compatibility_proxy",
"rules_cc",
"rules_cc+"
],
[
"rules_swift+",
"bazel_skylib",
"bazel_skylib+"
],
[
"rules_swift+",
"bazel_tools",
"bazel_tools"
],
[
"rules_swift+",
"build_bazel_apple_support",
"apple_support+"
],
[
"rules_swift+",
"build_bazel_rules_swift",
"rules_swift+"
],
[
"rules_swift+",
"build_bazel_rules_swift_local_config",
"rules_swift++non_module_deps+build_bazel_rules_swift_local_config"
]
]
}
},
"@@rules_apple+//apple:extensions.bzl%non_module_deps": {
"general": {
"bzlTransitiveDigest": "UsflLeiazyu2v5pvibcvOeIdDV95S25rT96h4XU1nhY=",
"usagesDigest": "M3VqFpeTCo4qmrNKGZw0dxBHvTYDrfV3cscGzlSAhQ4=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
"envVariables": {},
"generatedRepoSpecs": {
"xctestrunner": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"urls": [
"https://github.com/google/xctestrunner/archive/b7698df3d435b6491b4b4c0f9fc7a63fbed5e3a6.tar.gz"
],
"strip_prefix": "xctestrunner-b7698df3d435b6491b4b4c0f9fc7a63fbed5e3a6",
"sha256": "ae3a063c985a8633cb7eb566db21656f8db8eb9a0edb8c182312c7f0db53730d"
}
}
},
"recordedRepoMappingEntries": [
[
"rules_apple+",
"bazel_tools",
"bazel_tools"
]
]
}
},
"@@rules_bzlmodrio_toolchains+//:extensions.bzl%sh_configure": {
"general": {
"bzlTransitiveDigest": "q+0LgnvjpZ9Y2r2JYzNeYCKGLphbczG73lZ3rBg+XhM=",
@@ -852,6 +1003,165 @@
]
]
}
},
"@@rules_swift+//swift:extensions.bzl%non_module_deps": {
"general": {
"bzlTransitiveDigest": "WQxCEBSXJEaQYe860JXZvAQug2B6+/VbBtRIDMF0pOc=",
"usagesDigest": "mhACFnrdMv9Wi0Mt67bxocJqviRkDSV+Ee5Mqdj5akA=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
"envVariables": {},
"generatedRepoSpecs": {
"com_github_apple_swift_protobuf": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"urls": [
"https://github.com/apple/swift-protobuf/archive/1.20.2.tar.gz"
],
"sha256": "3fb50bd4d293337f202d917b6ada22f9548a0a0aed9d9a4d791e6fbd8a246ebb",
"strip_prefix": "swift-protobuf-1.20.2/",
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_protobuf/BUILD.overlay"
}
},
"com_github_grpc_grpc_swift": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"urls": [
"https://github.com/grpc/grpc-swift/archive/1.16.0.tar.gz"
],
"sha256": "58b60431d0064969f9679411264b82e40a217ae6bd34e17096d92cc4e47556a5",
"strip_prefix": "grpc-swift-1.16.0/",
"build_file": "@@rules_swift+//third_party:com_github_grpc_grpc_swift/BUILD.overlay"
}
},
"com_github_apple_swift_docc_symbolkit": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"urls": [
"https://github.com/apple/swift-docc-symbolkit/archive/refs/tags/swift-5.10-RELEASE.tar.gz"
],
"sha256": "de1d4b6940468ddb53b89df7aa1a81323b9712775b0e33e8254fa0f6f7469a97",
"strip_prefix": "swift-docc-symbolkit-swift-5.10-RELEASE",
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_docc_symbolkit/BUILD.overlay"
}
},
"com_github_apple_swift_nio": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"urls": [
"https://github.com/apple/swift-nio/archive/2.42.0.tar.gz"
],
"sha256": "e3304bc3fb53aea74a3e54bd005ede11f6dc357117d9b1db642d03aea87194a0",
"strip_prefix": "swift-nio-2.42.0/",
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_nio/BUILD.overlay"
}
},
"com_github_apple_swift_nio_http2": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"urls": [
"https://github.com/apple/swift-nio-http2/archive/1.26.0.tar.gz"
],
"sha256": "f0edfc9d6a7be1d587e5b403f2d04264bdfae59aac1d74f7d974a9022c6d2b25",
"strip_prefix": "swift-nio-http2-1.26.0/",
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_nio_http2/BUILD.overlay"
}
},
"com_github_apple_swift_nio_transport_services": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"urls": [
"https://github.com/apple/swift-nio-transport-services/archive/1.15.0.tar.gz"
],
"sha256": "f3498dafa633751a52b9b7f741f7ac30c42bcbeb3b9edca6d447e0da8e693262",
"strip_prefix": "swift-nio-transport-services-1.15.0/",
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_nio_transport_services/BUILD.overlay"
}
},
"com_github_apple_swift_nio_extras": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"urls": [
"https://github.com/apple/swift-nio-extras/archive/1.4.0.tar.gz"
],
"sha256": "4684b52951d9d9937bb3e8ccd6b5daedd777021ef2519ea2f18c4c922843b52b",
"strip_prefix": "swift-nio-extras-1.4.0/",
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_nio_extras/BUILD.overlay"
}
},
"com_github_apple_swift_log": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"urls": [
"https://github.com/apple/swift-log/archive/1.4.4.tar.gz"
],
"sha256": "48fe66426c784c0c20031f15dc17faf9f4c9037c192bfac2f643f65cb2321ba0",
"strip_prefix": "swift-log-1.4.4/",
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_log/BUILD.overlay"
}
},
"com_github_apple_swift_nio_ssl": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"urls": [
"https://github.com/apple/swift-nio-ssl/archive/2.23.0.tar.gz"
],
"sha256": "4787c63f61dd04d99e498adc3d1a628193387e41efddf8de19b8db04544d016d",
"strip_prefix": "swift-nio-ssl-2.23.0/",
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_nio_ssl/BUILD.overlay"
}
},
"com_github_apple_swift_collections": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"urls": [
"https://github.com/apple/swift-collections/archive/1.0.4.tar.gz"
],
"sha256": "d9e4c8a91c60fb9c92a04caccbb10ded42f4cb47b26a212bc6b39cc390a4b096",
"strip_prefix": "swift-collections-1.0.4/",
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_collections/BUILD.overlay"
}
},
"com_github_apple_swift_atomics": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"urls": [
"https://github.com/apple/swift-atomics/archive/1.1.0.tar.gz"
],
"sha256": "1bee7f469f7e8dc49f11cfa4da07182fbc79eab000ec2c17bfdce468c5d276fb",
"strip_prefix": "swift-atomics-1.1.0/",
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_atomics/BUILD.overlay"
}
},
"build_bazel_rules_swift_index_import": {
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
"attributes": {
"build_file": "@@rules_swift+//third_party:build_bazel_rules_swift_index_import/BUILD.overlay",
"canonical_id": "index-import-5.8",
"urls": [
"https://github.com/MobileNativeFoundation/index-import/releases/download/5.8.0.1/index-import.tar.gz"
],
"sha256": "28c1ffa39d99e74ed70623899b207b41f79214c498c603915aef55972a851a15"
}
},
"build_bazel_rules_swift_local_config": {
"repoRuleId": "@@rules_swift+//swift/internal:swift_autoconfiguration.bzl%swift_autoconfiguration",
"attributes": {}
}
},
"recordedRepoMappingEntries": [
[
"rules_swift+",
"bazel_tools",
"bazel_tools"
],
[
"rules_swift+",
"build_bazel_rules_swift",
"rules_swift+"
]
]
}
}
},
"facts": {}

View File

@@ -1,12 +1,11 @@
# WPILib CMake Support
WPILib is normally built with Gradle, however for some systems, such as Linux based coprocessors, Gradle doesn't work correctly, especially if cscore is needed, which requires OpenCV. Furthermore, the CMake build can be used for C++ development because it provides better build caching compared to Gradle. We provide the CMake build for these cases. Although macOS is supported, these docs will only go over Linux and Windows builds, but should mostly work for macOS as well. If you are stuck, you can look at the GitHub workflows for any OS to see how it works.
WPILib is normally built with Gradle, however for some systems, such as Linux based coprocessors, Gradle doesn't work correctly, especially if cscore is needed, which requires OpenCV. Furthermore, the CMake build can be used for C++ development because it provides better build caching compared to Gradle. We provide the CMake build for these cases. Although macOS is supported, these docs will only go over Linux and Windows builds, but should mostly work for macOS as well. If you are stuck, you can look at the GitHub workflows for any OS to see how it works. The CMake build does not build Java or Python, only C++.
## Libraries that get built
* apriltag
* cameraserver
* commandsv2
* commandsv3
* cscore
* datalog
* fields
@@ -18,7 +17,6 @@ WPILib is normally built with Gradle, however for some systems, such as Linux ba
* wpilib (wpilibc, wpilibj, and developerRobot)
* wpimath
* wpinet
* wpiunits
* wpiutil
* xrpVendordep
@@ -30,30 +28,24 @@ WPILib is normally built with Gradle, however for some systems, such as Linux ba
* wpical
* halsim_gui (if simulation extensions are enabled)
By default, all libraries get built with a default CMake setup. The libraries are built as shared libraries, and include the JNI libraries as well as building the Java JARs. Data Log Tool is only built if libssh is available.
By default, all libraries get built with a default CMake setup. The libraries are built as shared libraries. Data Log Tool is only built if libssh is available.
## Prerequisites
OpenCV needs to be findable by CMake. On systems like the Jetson, this is installed by default. Otherwise, you will need to build OpenCV from source and install it.
If you want JNI and Java, you will need a JDK of at least version 25 installed. In addition, you need a `JAVA_HOME` environment variable set properly and set to the JDK directory.
## Build Options
The following build options are available:
* `BUILD_SHARED_LIBS` (ON Default)
* This option will cause CMake to build static libraries instead of shared libraries. If this is off, `WITH_JAVA` must be off. Otherwise CMake will error.
* This option will cause CMake to build static libraries instead of shared libraries.
* `WITH_CSCORE` (ON Default)
* This option will cause cscore to be built. Turning this off will implicitly disable cameraserver. If this is off, the OpenCV build requirement is removed.
* `WITH_EXAMPLES` (OFF Default)
* This option will build C++ examples.
* `WITH_GUI` (ON Default)
* This option will build GUI items. If this is off, and `WITH_SIMULATION_MODULES` is on, the simulation GUI will not be built.
* `WITH_JAVA` (OFF Default)
* This option will enable Java and JNI builds. If this is on, `BUILD_SHARED_LIBS` must be on. Otherwise CMake will error.
* `WITH_JAVA_SOURCE` (`WITH_JAVA` Default)
* This option will build Java source JARs for each enabled Java library. This does not require `WITH_JAVA` to be on, allowing source JARs to be built without the compiled JARs if desired.
* `WITH_NTCORE` (ON Default)
* This option will cause ntcore to be built. Turning this off will implicitly disable wpinet, and will cause an error if `WITH_WPILIB` is enabled.
* `WITH_SIMULATION_MODULES` (ON Default)
@@ -61,13 +53,9 @@ The following build options are available:
* `WITH_TESTS` (ON Default)
* This option will build C++ unit tests. These can be run via `ctest -C <config>`, where `<config>` is the build configuration, e.g. `Debug` or `Release`.
* `WITH_WPILIB` (ON Default)
* This option will build the HAL and wpilibc/j during the build. The HAL is the simulation HAL, unless the external HAL options are used. The CMake build has no capability to build for Systemcore.
* This option will build the HAL and wpilibc during the build. The HAL is the simulation HAL, unless the external HAL options are used. The CMake build has no capability to build for Systemcore.
* `WITH_WPIMATH` (ON Default)
* This option will build the wpimath library. This option must be on to build wpilib.
* `WITH_WPIUNITS` (`WITH_JAVA` Default)
* This option will build the wpiunits library. This option must be on to build the Java wpimath library and requires `WITH_JAVA` to also be on.
* `OPENCV_JAVA_INSTALL_DIR`
* Set this option to the location of the archive of the OpenCV Java bindings (it should be called opencv-xxx.jar, with the x'es being version numbers). NOTE: set it to the LOCATION of the file, not the file itself!
* `NO_WERROR` (OFF Default)
* This option will disable the `-Werror` compilation flag for non-MSVC builds.
* `WPILIB_TARGET_WARNINGS`
@@ -89,7 +77,7 @@ If you want, you can also use `ccmake` in order to visually set these properties
## Presets
The WPILib CMake setup has a variety of presets for common configurations and options used. The default sets the generator to Ninja and build directory to `build-cmake`. The other presets are `with-java` (sets `WITH_JAVA=ON`), `sccache` (sets the C/C++ compiler launcher to sccache), and `with-java-sccache` (a combination of `with-java` and `sccache`).
The WPILib CMake setup has a variety of presets for common configurations and options used. The default sets the generator to Ninja and build directory to `build-cmake`. The other preset is `sccache` (sets the C/C++ compiler launcher to sccache).
## Building
@@ -115,7 +103,7 @@ sudo cmake --build . --target install
On Windows, make sure the directories for the libraries you built are on PATH. For wpilib, the default install location is `C:\Program Files (x86)\allwpilib`. If you built other libraries like OpenCV from source, install them, and add the install directories to PATH. This ensures CMake can locate the libraries.
You will also want to add the directories where the DLLs are located (usually the `bin` subdirectory of the install directory) to PATH so they can be loaded by your program. If you are using OpenCV and Java, the `opencv_java` DLL is located in either the `lib` subdirectory if you built but didn't install OpenCV, or the `java` subdirectory if you did install OpenCV.
You will also want to add the directories where the DLLs are located (usually the `bin` subdirectory of the install directory) to PATH so they can be loaded by your program.
## Using the installed libraries for C++.
@@ -143,40 +131,9 @@ cmake /path/to/folder/containing/CMakeLists
After that, run `cmake --build .`. That will create your executable. Then you should be able to run `./my_vision_app` to run your application.
## Using the installed libraries for Java
Using the built JARs is more involved than using the C++ libraries, but the additional work involves providing the paths to various libraries and JARs when needed.
Create a new folder to contain your project. Add the following code below to a `CMakeLists.txt` file in that directory.
```cmake
cmake_minimum_required(VERSION 3.11)
project(robot)
find_package(Java REQUIRED COMPONENTS Development)
include(UseJava)
find_package(wpilib REQUIRED)
find_jar(opencvJar opencv-xxx PATHS ENV PATH) # Change to OpenCV version
file(GLOB_RECURSE JAVA_SOURCES *.java)
# If you want Gradle compatibility or you are using one of the templates/examples, comment out the above line and uncomment this line instead:
# file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
add_jar(robot ${JAVA_SOURCES}
INCLUDE_JARS apriltag_jar cscore_jar hal_jar ntcore_jar commandsv2_jar wpimath_jar wpinet_jar wpiutil_jar wpiunits_jar wpilibj_jar ${opencvJar})
export_jars(TARGETS robot FILE robot.jar)
```
This includes all the built JARs except for the vendordeps. If you are not using a JAR/library, you may remove it.
Add a `Main.java` file to contain your code, and create a build folder. Move into the build folder, and run
```
cmake /path/to/folder/containing/CMakeLists
```
After that, run `cmake --build .` to create your JAR file. To execute the JAR file, you need to include the wpilib JARs and your JAR in the classpath, and execute your Java program's entry point. If you are using cscore or cameraserver, you also need to include the path to the OpenCV JAR. If you built it from source, it will be in your OpenCV build directory. If it's installed on the system, CMake may find it from PATH, but you will likely need to locate the JAR and manually give CMake the JAR directory. If you are on Linux, you will also need to add the path of the libraries to `LD_LIBRARY_PATH`. This can be done by prepending `LD_LIBRARY_PATH=/path/to/libraries` to the Java command. If you need to add more paths, separate them with colons. The final command should look like `java -cp "robot.jar:/path/to/library_jars/*" main.package.Main`, using a semicolon to separate paths instead of a colon if you are on Windows. If you are on Linux, the final command should look more like `LD_LIBRARY_PATH=/path/to/libraries java -cp robot.jar:/path/to/library_jars/* main.package.Main`.
## Using vendordeps
Vendordeps are not included as part of the `wpilib` CMake package. However, if you want to use a vendordep, you need to use `find_package(VENDORDEP)`, where `VENDORDEP` is the name of the vendordep (case-sensitive), like `xrpVendordep` or `romiVendordep`. Note that commandsv2, while a vendordep in normal robot projects, is not built as a vendordep in CMake, and is instead included as part of the `wpilib` CMake package. After you used `find_package`, you can reference the vendordep library like normal, either by using `target_link_libraries` for C++ or `add_jar` for Java.
Vendordeps are not included as part of the `wpilib` CMake package. However, if you want to use a vendordep, you need to use `find_package(VENDORDEP)`, where `VENDORDEP` is the name of the vendordep (case-sensitive), like `xrpVendordep` or `romiVendordep`. Note that commandsv2, while a vendordep in normal robot projects, is not built as a vendordep in CMake, and is instead included as part of the `wpilib` CMake package. After you used `find_package`, you can reference the vendordep library like normal (using `target_link_libraries`).
## Troubleshooting
Below are some common issues that are run into when building.
@@ -204,32 +161,3 @@ CMake Error at cscore/CMakeLists.txt:3 (find_package):
```
If you get that, you need make sure OpenCV was installed, and then reattempt to configure. If that doesn't work, set the `OpenCV_DIR` variable to the directory where you built OpenCV.
#### Missing Java
If you are missing Java, you will get a message like the following.
```
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE
Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE
Development)
```
If this happens, make sure you have a JDK of at least version 25 installed, and that your JAVA_HOME variable is set properly to point to the JDK.
In addition, if you do not need Java, you can disable it with `-DWITH_JAVA=OFF`.
#### Java: Can't find dependent libraries
If one of the libraries can't be found, you will get an error similar to this one:
```
java.io.IOException: wpiHaljni could not be loaded from path or an embedded resource.
attempted to load for platform windows-x86_64
Last Load Error:
C:\Program Files (x86)\allwpilib\bin\wpiHaljni.dll: Can't find dependent libraries
```
If you get this error, that's usually an indication that not all your libraries are in your PATH. If the error is coming from cscore specifically, it's likely you're missing OpenCV. Otherwise, it's likely the wpilib libraries are not in a directory on PATH.
Note that Linux will not have this specific type of error, as it will usually tell you the dependent library you are missing. In that case, you most likely need to add the library to `LD_LIBRARY_PATH`.

View File

@@ -49,6 +49,7 @@ mrcal tools/wpical/src/main/native/thirdparty/mrcal
libdogleg tools/wpical/src/main/native/thirdparty/libdogleg
Simd hal/src/main/native/systemcore/simd
AdvantageScope fields/src/main/native/resources/org/wpilib/fields/ftc
Avahi wpinet/src/main/native/linux/AvahiClient.hpp
Additionally, glfw and nanopb were modified for use in WPILib.
@@ -1595,3 +1596,509 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============
Avahi License
=============
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Moe Ghoul>, 1 April 1990
Moe Ghoul, President of Vice
That's all there is to it!

View File

@@ -1,9 +1,5 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//thirdparty/ceres:repositories.bzl", "ceres_repositories")
ceres_repositories()
http_archive(
name = "pybind11_bazel",
integrity = "sha256-iwRj1wuX2pDS6t6DqiCfhIXisv4y+7CvxSJtZoSAzGw=",
@@ -29,16 +25,6 @@ load("@bzlmodrio-opencv//:maven_cpp_deps.bzl", "setup_legacy_bzlmodrio_opencv_cp
setup_legacy_bzlmodrio_opencv_cpp_dependencies()
http_archive(
name = "bzlmodrio-libssh",
sha256 = "f8fef627c7b393f7f6ed638e12b80ff90b2cfea11488b15214f25ce1e470723a",
url = "https://github.com/wpilibsuite/bzlmodRio-libssh/releases/download/2024.0.105-1.bcr1/bzlmodrio-libssh-2024.0.105-1.bcr1.tar.gz",
)
load("@bzlmodrio-libssh//:maven_cpp_deps.bzl", "setup_legacy_bzlmodrio_libssh_cpp_dependencies")
setup_legacy_bzlmodrio_libssh_cpp_dependencies()
# Capture the repository environmental variables which specify the filter list for what architectures to build in CI.
load("//shared/bazel/rules:publishing_rule.bzl", "publishing_repo")

View File

@@ -164,13 +164,13 @@ pkg_files(
cc_test(
name = "apriltag-cpp-test",
size = "small",
srcs = glob(["src/test/native/cpp/**"]),
srcs = glob(["src/test/native/cpp/**/*.cpp"]),
tags = [
"no-asan",
],
deps = [
":apriltag",
"//thirdparty/googletest",
"//thirdparty/catch2",
],
)

View File

@@ -31,81 +31,6 @@ else()
)
endif()
file(GLOB apriltag_jni_src src/main/native/cpp/jni/AprilTagJNI.cpp)
if(WITH_JAVA)
include(UseJava)
set(CMAKE_JNI_TARGET true)
file(GLOB EJML_JARS "${WPILIB_BINARY_DIR}/wpimath/thirdparty/ejml/*.jar")
file(GLOB AVAJE_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/avaje/*.jar")
find_file(
OPENCV_JAR_FILE
NAMES opencv-${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.jar
PATHS
${OPENCV_JAVA_INSTALL_DIR}
${OpenCV_INSTALL_PATH}/bin
${OpenCV_INSTALL_PATH}/share/java
${OpenCV_INSTALL_PATH}/share/java/opencv4
${OpenCV_INSTALL_PATH}/share/OpenCV/java
NO_DEFAULT_PATH
)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
file(
GLOB_RECURSE JAVA_RESOURCES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
src/main/native/resources/*.json
)
add_jar(
apriltag_jar
SOURCES ${JAVA_SOURCES}
RESOURCES
NAMESPACE "org/wpilib/vision/apriltag" ${JAVA_RESOURCES}
INCLUDE_JARS
wpimath_jar
wpiunits_jar
wpiutil_jar
${EJML_JARS}
${OPENCV_JAR_FILE}
${AVAJE_JARS}
OUTPUT_NAME apriltag
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
GENERATE_NATIVE_HEADERS apriltag_jni_headers
)
set_property(TARGET apriltag_jar PROPERTY FOLDER "java")
install_jar(apriltag_jar DESTINATION ${java_lib_dest})
install_jar_exports(TARGETS apriltag_jar FILE apriltag_jar.cmake DESTINATION share/apriltag)
add_library(apriltagjni ${apriltag_jni_src} ${apriltaglib_src})
wpilib_target_warnings(apriltagjni)
target_link_libraries(apriltagjni PUBLIC apriltag)
set_property(TARGET apriltagjni PROPERTY FOLDER "libraries")
target_link_libraries(apriltagjni PRIVATE apriltag_jni_headers)
add_dependencies(apriltagjni apriltag_jar)
install(TARGETS apriltagjni EXPORT apriltagjni)
export(TARGETS apriltagjni FILE apriltagjni.cmake NAMESPACE apriltagjni::)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
apriltag_src_jar
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
OUTPUT_NAME apriltag-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET apriltag_src_jar PROPERTY FOLDER "java")
install_jar(apriltag_src_jar DESTINATION ${java_lib_dest})
endif()
generate_resources(
src/main/native/resources/org/wpilib/vision/apriltag
generated/main/cpp
@@ -152,7 +77,7 @@ install(FILES ${WPILIB_BINARY_DIR}/apriltag-config.cmake DESTINATION share/april
install(EXPORT apriltag DESTINATION share/apriltag)
if(WITH_TESTS)
wpilib_add_test(apriltag src/test/native/cpp)
wpilib_add_test_catch2(apriltag src/test/native/cpp)
target_include_directories(apriltag_test PRIVATE src/test/native/include)
target_link_libraries(apriltag_test apriltag googletest)
target_link_libraries(apriltag_test apriltag)
endif()

View File

@@ -5,6 +5,3 @@ include(CMakeFindDependencyMacro)
@FILENAME_DEP_REPLACE@
include(${SELF_DIR}/apriltag.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/apriltag_jar.cmake)
endif()

View File

@@ -5,11 +5,12 @@ apply plugin: 'c'
ext {
nativeName = 'apriltag'
devMain = 'org.wpilib.vision.apriltag.DevMain'
nativeTestSuiteName = "${nativeName}Catch2Test"
useJava = true
useCpp = true
sharedCvConfigs = [
apriltagDev : [],
apriltagTest: []]
(nativeTestSuiteName): []]
staticCvConfigs = []
def generateTask = createGenerateResourcesTask('main', 'APRILTAG', 'wpi::apriltag', project)

View File

@@ -1,9 +1,11 @@
# THIS FILE IS AUTO GENERATED
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "native_wrappery_library")
load("//shared/bazel/rules/robotpy:robotpy_rules.bzl", "copy_native_file", "generate_native_files", "robotpy_library")
def define_native_wrapper(name, pyproject_toml = None):
pyproject_toml = pyproject_toml or "src/main/python/native-pyproject.toml"
copy_to_directory(
name = "{}.copy_headers".format(name),
srcs = native.glob(["src/main/native/include/**"]) + native.glob(["src/generated/main/native/include/**"], allow_empty = True) + native.glob([
@@ -20,25 +22,42 @@ def define_native_wrapper(name, pyproject_toml = None):
visibility = ["//visibility:public"],
)
native_wrappery_library(
libinit_files = ["native/apriltag/_init_robotpy_native_apriltag.py"]
generate_native_files(
name = name,
pyproject_toml = pyproject_toml or "src/main/python/native-pyproject.toml",
libinit_file = "native/apriltag/_init_robotpy_native_apriltag.py",
pc_file = "native/apriltag/robotpy-native-apriltag.pc",
pyproject_toml = pyproject_toml,
pc_deps = [
"//wpimath:native/wpimath/robotpy-native-wpimath.pc",
"//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc",
],
libinit_files = libinit_files,
pc_files = ["native/apriltag/robotpy-native-apriltag.pc"],
)
copy_native_file(
name = "apriltag",
library = "shared/apriltag",
base_path = "native/apriltag/",
)
robotpy_library(
name = name,
distribution = "robotpy-native-apriltag",
srcs = libinit_files,
data = [
name + ".pc_wrapper",
":apriltag.copy_lib",
"{}.copy_headers".format(name),
],
deps = [
"//wpimath:robotpy-native-wpimath",
"//wpiutil:robotpy-native-wpiutil",
],
headers = "{}.copy_headers".format(name),
native_shared_library = "shared/apriltag",
install_path = "native/apriltag/",
strip_path_prefixes = ["apriltag"],
requires = ["robotpy-native-wpiutil==0.0.0", "robotpy-native-wpimath==0.0.0"],
summary = "WPILib AprilTag Library",
requires = ["robotpy-native-wpiutil==0.0.0", "robotpy-native-wpimath==0.0.0"],
python_requires = ">=3.11",
strip_path_prefixes = ["apriltag"],
entry_points = {
"pkg_config": [
"apriltag = native.apriltag",

View File

@@ -1,7 +1,7 @@
# THIS FILE IS AUTO GENERATED
load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file")
load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "create_pybind_library", "robotpy_library")
load("//shared/bazel/rules/robotpy:robotpy_rules.bzl", "create_pybind_library", "robotpy_library")
load("//shared/bazel/rules/robotpy:semiwrap_helpers.bzl", "gen_libinit", "gen_modinit_hpp", "gen_pkgconf", "resolve_casters", "run_header_gen")
load("//shared/bazel/rules/robotpy:semiwrap_tool_helpers.bzl", "scan_headers", "update_yaml_files")
@@ -198,6 +198,7 @@ def define_pybind_library(name, pkgcfgs = []):
robotpy_library(
name = name,
distribution = "robotpy-apriltag",
srcs = native.glob(["src/main/python/robotpy_apriltag/**/*.py"]) + [
"src/main/python/robotpy_apriltag/_init__apriltag.py",
"{}.generate_version".format(name),
@@ -219,6 +220,7 @@ def define_pybind_library(name, pkgcfgs = []):
project_urls = {"Source code": "https://github.com/robotpy/mostrobotpy"},
author_email = "RobotPy Development Team <robotpy@googlegroups.com>",
requires = ["robotpy-native-apriltag==0.0.0", "robotpy-wpiutil==0.0.0", "robotpy-wpimath==0.0.0"],
python_requires = ">=3.11",
entry_points = {
"pkg_config": ["apriltag = robotpy_apriltag"],
},

View File

@@ -4,10 +4,6 @@
#pragma once
#include <string_view>
#include "wpi/util/SymbolExports.hpp"
namespace wpi::apriltag {
/**

View File

@@ -12,6 +12,7 @@ requires = [
name = "robotpy-native-apriltag"
version = "0.0.0"
description = "WPILib AprilTag Library"
requires-python = ">=3.11"
license = "BSD-3-Clause"
dependencies = [

View File

@@ -14,6 +14,7 @@ requires = [
name = "robotpy-apriltag"
version = "0.0.0"
description = "RobotPy bindings for WPILib's AprilTag library"
requires-python = ">=3.11"
authors = [
{name = "RobotPy Development Team", email = "robotpy@googlegroups.com"},
]

View File

@@ -1,4 +1,6 @@
#include "semiwrap_init.robotpy_apriltag._apriltag.hpp"
SEMIWRAP_PYBIND11_MODULE(m) { initWrapper(m); }
SEMIWRAP_PYBIND11_MODULE(m) {
initWrapper(m);
}

View File

@@ -32,7 +32,7 @@ classes:
// We are going to move the detection result into this shared_ptr
// so that python can keep it alive. We don't expose the result directly
// to the user because we'd have to pretend it's a list, and that would
// be annoying.
// be annoying.
std::shared_ptr<AprilTagDetector::Results> c_result;
{
py::gil_scoped_release unlock;

View File

@@ -4,55 +4,55 @@
#include "wpi/apriltag/AprilTagDetector.hpp"
#include <gtest/gtest.h>
#include <catch2/catch_test_macros.hpp>
using namespace wpi::apriltag;
TEST(AprilTagDetectorTest, ConfigDefaults) {
TEST_CASE("AprilTagDetectorTest ConfigDefaults", "[apriltag][detector]") {
AprilTagDetector detector;
auto config = detector.GetConfig();
ASSERT_EQ(config, AprilTagDetector::Config{});
REQUIRE(config == AprilTagDetector::Config{});
}
TEST(AprilTagDetectorTest, QtpDefaults) {
TEST_CASE("AprilTagDetectorTest QtpDefaults", "[apriltag][detector]") {
AprilTagDetector detector;
auto params = detector.GetQuadThresholdParameters();
ASSERT_EQ(params, AprilTagDetector::QuadThresholdParameters{});
REQUIRE(params == AprilTagDetector::QuadThresholdParameters{});
}
TEST(AprilTagDetectorTest, SetConfigNumThreads) {
TEST_CASE("AprilTagDetectorTest SetConfigNumThreads", "[apriltag][detector]") {
AprilTagDetector detector;
detector.SetConfig({.numThreads = 2});
auto config = detector.GetConfig();
ASSERT_EQ(config.numThreads, 2);
REQUIRE(config.numThreads == 2);
}
TEST(AprilTagDetectorTest, QtpMinClusterPixels) {
TEST_CASE("AprilTagDetectorTest QtpMinClusterPixels", "[apriltag][detector]") {
AprilTagDetector detector;
detector.SetQuadThresholdParameters({.minClusterPixels = 8});
auto params = detector.GetQuadThresholdParameters();
ASSERT_EQ(params.minClusterPixels, 8);
REQUIRE(params.minClusterPixels == 8);
}
TEST(AprilTagDetectorTest, Add16h5) {
TEST_CASE("AprilTagDetectorTest Add16h5", "[apriltag][detector]") {
AprilTagDetector detector;
ASSERT_TRUE(detector.AddFamily("tag16h5"));
REQUIRE(detector.AddFamily("tag16h5"));
// duplicate addition is also okay
ASSERT_TRUE(detector.AddFamily("tag16h5"));
REQUIRE(detector.AddFamily("tag16h5"));
}
TEST(AprilTagDetectorTest, Add36h11) {
TEST_CASE("AprilTagDetectorTest Add36h11", "[apriltag][detector]") {
AprilTagDetector detector;
ASSERT_TRUE(detector.AddFamily("tag36h11"));
REQUIRE(detector.AddFamily("tag36h11"));
}
TEST(AprilTagDetectorTest, AddMultiple) {
TEST_CASE("AprilTagDetectorTest AddMultiple", "[apriltag][detector]") {
AprilTagDetector detector;
ASSERT_TRUE(detector.AddFamily("tag16h5"));
ASSERT_TRUE(detector.AddFamily("tag36h11"));
REQUIRE(detector.AddFamily("tag16h5"));
REQUIRE(detector.AddFamily("tag36h11"));
}
TEST(AprilTagDetectorTest, RemoveFamily) {
TEST_CASE("AprilTagDetectorTest RemoveFamily", "[apriltag][detector]") {
AprilTagDetector detector;
// okay to remove non-existent family
detector.RemoveFamily("tag16h5");

View File

@@ -4,7 +4,7 @@
#include <vector>
#include <gtest/gtest.h>
#include <catch2/catch_test_macros.hpp>
#include "wpi/apriltag/AprilTag.hpp"
#include "wpi/apriltag/AprilTagFieldLayout.hpp"
@@ -13,7 +13,7 @@
using namespace wpi::apriltag;
TEST(AprilTagJsonTest, DeserializeMatches) {
TEST_CASE("AprilTagJsonTest DeserializeMatches", "[apriltag][json]") {
auto layout = AprilTagFieldLayout{
std::vector{AprilTag{1, wpi::math::Pose3d{}},
AprilTag{3, wpi::math::Pose3d{0_m, 1_m, 0_m,
@@ -23,6 +23,6 @@ TEST(AprilTagJsonTest, DeserializeMatches) {
AprilTagFieldLayout deserialized;
wpi::util::json json = layout;
EXPECT_NO_THROW(deserialized = json.get<AprilTagFieldLayout>());
EXPECT_EQ(layout, deserialized);
CHECK_NOTHROW(deserialized = json.get<AprilTagFieldLayout>());
CHECK(layout == deserialized);
}

View File

@@ -4,7 +4,7 @@
#include <vector>
#include <gtest/gtest.h>
#include <catch2/catch_test_macros.hpp>
#include "wpi/apriltag/AprilTag.hpp"
#include "wpi/apriltag/AprilTagFieldLayout.hpp"
@@ -13,7 +13,8 @@
using namespace wpi::apriltag;
TEST(AprilTagPoseSetOriginTest, TransformationMatches) {
TEST_CASE("AprilTagPoseSetOriginTest TransformationMatches",
"[apriltag][field-layout][pose]") {
auto layout = AprilTagFieldLayout{
std::vector<AprilTag>{
AprilTag{
@@ -29,8 +30,8 @@ TEST(AprilTagPoseSetOriginTest, TransformationMatches) {
auto mirrorPose = wpi::math::Pose3d{
54_ft, 27_ft, 0_ft, wpi::math::Rotation3d{0_deg, 0_deg, 180_deg}};
EXPECT_EQ(mirrorPose, *layout.GetTagPose(1));
CHECK(mirrorPose == *layout.GetTagPose(1));
mirrorPose = wpi::math::Pose3d{50_ft, 23_ft, 4_ft,
wpi::math::Rotation3d{0_deg, 0_deg, 0_deg}};
EXPECT_EQ(mirrorPose, *layout.GetTagPose(2));
CHECK(mirrorPose == *layout.GetTagPose(2));
}

View File

@@ -4,7 +4,7 @@
#include <vector>
#include <gtest/gtest.h>
#include <catch2/catch_test_macros.hpp>
#include "wpi/apriltag/AprilTagFieldLayout.hpp"
#include "wpi/apriltag/AprilTagFields.hpp"
@@ -21,7 +21,8 @@ std::vector<AprilTagField> GetAllFields() {
return output;
}
TEST(AprilTagFieldsTest, TestLoad2022RapidReact) {
TEST_CASE("AprilTagFieldsTest TestLoad2022RapidReact",
"[apriltag][field-layout]") {
AprilTagFieldLayout layout =
AprilTagFieldLayout::LoadField(AprilTagField::k2022RapidReact);
@@ -30,39 +31,36 @@ TEST(AprilTagFieldsTest, TestLoad2022RapidReact) {
wpi::math::Pose3d{127.272_in, 216.01_in, 67.932_in,
wpi::math::Rotation3d{0_deg, 0_deg, 0_deg}};
auto maybePose = layout.GetTagPose(1);
EXPECT_TRUE(maybePose);
EXPECT_EQ(expectedPose, *maybePose);
REQUIRE(maybePose);
CHECK(expectedPose == *maybePose);
// Blue Terminal Near Station
expectedPose =
wpi::math::Pose3d{4.768_in, 67.631_in, 35.063_in,
wpi::math::Rotation3d{0_deg, 0_deg, 46.25_deg}};
maybePose = layout.GetTagPose(5);
EXPECT_TRUE(maybePose);
EXPECT_EQ(expectedPose, *maybePose);
REQUIRE(maybePose);
CHECK(expectedPose == *maybePose);
// Upper Hub Blue-Near
expectedPose =
wpi::math::Pose3d{332.321_in, 183.676_in, 95.186_in,
wpi::math::Rotation3d{0_deg, 26.75_deg, 69_deg}};
maybePose = layout.GetTagPose(53);
EXPECT_TRUE(maybePose);
EXPECT_EQ(expectedPose, *maybePose);
REQUIRE(maybePose);
CHECK(expectedPose == *maybePose);
// Doesn't exist
maybePose = layout.GetTagPose(54);
EXPECT_FALSE(maybePose);
CHECK_FALSE(maybePose);
}
// Test all of the fields in the enum
class AllFieldsFixtureTest : public ::testing::TestWithParam<AprilTagField> {};
TEST_P(AllFieldsFixtureTest, CheckEntireEnum) {
AprilTagField field = GetParam();
EXPECT_NO_THROW(AprilTagFieldLayout::LoadField(field));
TEST_CASE("AprilTagFieldsTest CheckEntireEnum", "[apriltag][field-layout]") {
for (auto field : GetAllFields()) {
CAPTURE(field);
CHECK_NOTHROW(AprilTagFieldLayout::LoadField(field));
}
}
INSTANTIATE_TEST_SUITE_P(ValuesEnumTestInstTests, AllFieldsFixtureTest,
::testing::ValuesIn(GetAllFields()));
} // namespace wpi::apriltag

View File

@@ -2,10 +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.
#include <gtest/gtest.h>
#include <catch2/catch_session.hpp>
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
int ret = RUN_ALL_TESTS();
return ret;
return Catch::Session().run(argc, argv);
}

View File

@@ -3,57 +3,6 @@ project(cameraserver)
include(CompileWarnings)
include(AddTest)
# Java bindings
if(WITH_JAVA)
include(UseJava)
#find JAR file, copy it locally
set(OPENCV_JAVA_INSTALL_DIR ${OpenCV_INSTALL_PATH}/share/java/opencv4)
find_file(
OPENCV_JAR_FILE
NAMES opencv-${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.jar
PATHS
${OPENCV_JAVA_INSTALL_DIR}
${OpenCV_INSTALL_PATH}/bin
${OpenCV_INSTALL_PATH}/share/java
${OpenCV_INSTALL_PATH}/share/OpenCV/java
NO_DEFAULT_PATH
)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
add_jar(
cameraserver_jar
${JAVA_SOURCES}
INCLUDE_JARS wpiutil_jar cscore_jar ntcore_jar ${OPENCV_JAR_FILE}
OUTPUT_NAME cameraserver
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET cameraserver_jar PROPERTY FOLDER "java")
install_jar(cameraserver_jar DESTINATION ${java_lib_dest})
install_jar_exports(
TARGETS cameraserver_jar
FILE cameraserver_jar.cmake
DESTINATION share/cameraserver
)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
cameraserver_src_jar
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
OUTPUT_NAME cameraserver-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET cameraserver_src_jar PROPERTY FOLDER "java")
install_jar(cameraserver_src_jar DESTINATION ${java_lib_dest})
endif()
file(GLOB_RECURSE cameraserver_native_src src/main/native/cpp/*.cpp)
add_library(cameraserver ${cameraserver_native_src})
set_target_properties(cameraserver PROPERTIES DEBUG_POSTFIX "d")

View File

@@ -8,6 +8,3 @@ find_dependency(OpenCV)
@FILENAME_DEP_REPLACE@
include(${SELF_DIR}/cameraserver.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/cameraserver_jar.cmake)
endif()

View File

@@ -13,3 +13,23 @@ macro(wpilib_add_test name srcdir)
endif()
add_test(NAME ${name} COMMAND ${name}_test)
endmacro()
macro(wpilib_add_test_catch2 name)
set(wpilib_catch2_test_src)
foreach(src ${ARGN})
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
file(GLOB_RECURSE wpilib_catch2_dir_src ${src}/*.cpp)
list(APPEND wpilib_catch2_test_src ${wpilib_catch2_dir_src})
else()
list(APPEND wpilib_catch2_test_src ${src})
endif()
endforeach()
add_executable(${name}_test ${wpilib_catch2_test_src})
set_property(TARGET ${name}_test PROPERTY FOLDER "tests")
wpilib_target_warnings(${name}_test)
target_link_libraries(${name}_test catch2)
catch_discover_tests(${name}_test)
if(MSVC)
target_compile_options(${name}_test PRIVATE /wd4101 /wd4251 /utf-8)
endif()
endmacro()

View File

@@ -1,33 +0,0 @@
macro(add_source_jar target)
set(oneValueArgs OUTPUT_NAME OUTPUT_DIR)
cmake_parse_arguments(SOURCE_JAR "" "${oneValueArgs}" "BASE_DIRECTORIES" ${ARGN})
foreach(base_package_dir ${SOURCE_JAR_BASE_DIRECTORIES})
file(GLOB_RECURSE directories LIST_DIRECTORIES true ${base_package_dir}/*.directoriesonly)
# Find all packages
foreach(directory ${directories})
cmake_path(
RELATIVE_PATH directory
BASE_DIRECTORY ${base_package_dir}
OUTPUT_VARIABLE package_name
)
file(GLOB package_sources ${directory}/*.java)
if(package_sources STREQUAL "")
continue()
endif()
# If package sources are scattered across different places, consolidate them under one package
list(FIND packages ${package_name} index)
if(index EQUAL -1)
list(APPEND packages ${package_name})
endif()
list(APPEND ${package_name} ${package_sources})
endforeach()
endforeach()
set(resources "")
foreach(package ${packages})
string(APPEND resources "NAMESPACE \"${package}\" ${${package}} ")
endforeach()
cmake_language(
EVAL CODE
"add_jar(${target} RESOURCES ${resources} OUTPUT_NAME ${SOURCE_JAR_OUTPUT_NAME} OUTPUT_DIR ${SOURCE_JAR_OUTPUT_DIR})"
)
endmacro()

View File

@@ -2,14 +2,13 @@ load("@allwpilib_pip_deps//:requirements.bzl", "requirement")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")
load("@rules_java//java:defs.bzl", "java_binary")
load("@rules_pycross//pycross:defs.bzl", "pycross_wheel_library")
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
load("@rules_python//python:packaging.bzl", "py_wheel")
load("@rules_python//python:defs.bzl", "py_binary")
load("//commandsv2:generate.bzl", "generate_wpilib_new_commands")
load("//shared/bazel/rules:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_library", "wpilib_cc_shared_library", "wpilib_cc_static_library")
load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test", "wpilib_java_library")
load("//shared/bazel/rules:packaging.bzl", "package_default_cc_project")
load("//shared/bazel/rules/robotpy:pytest_util.bzl", "robotpy_py_test")
load("//shared/bazel/rules/robotpy:robotpy_rules.bzl", "robotpy_library")
filegroup(
name = "doxygen-files",
@@ -188,30 +187,21 @@ package_default_cc_project(
maven_group_id = "org.wpilib.commandsv2",
)
py_library(
name = "commandsv2-py-lib",
srcs = glob(["src/main/python/**/*.py"]),
imports = ["src/main/python"],
deps = [
"//wpilibc:robotpy-wpilib",
requirement("typing-extensions"),
],
)
py_wheel(
name = "commandsv2-wheel",
distribution = "commandsv2",
strip_path_prefixes = ["commandsv2/src/main/python"],
tags = ["robotpy"],
version = "$(ROBOTPY_VERSION)",
deps = [":commandsv2-py-lib"],
)
pycross_wheel_library(
robotpy_library(
name = "commandsv2-py",
tags = ["manual"],
visibility = ["//visibility:public"],
wheel = ":commandsv2-wheel",
srcs = glob(["src/main/python/**/*.py"]),
author_email = "RobotPy Development Team <robotpy@googlegroups.com>",
description_file = "src/main/python/README.md",
distribution = "robotpy-commands-v2",
imports = ["src/main/python"],
project_urls = {"Source code": "https://github.com/robotpy/mostrobotpy"},
python_requires = ">=3.10",
requires = [
"wpilib==0.0.0",
"typing_extensions>=4.1.0,<5",
],
strip_path_prefixes = ["commandsv2/src/main/python"],
summary = "WPILib command framework v2",
deps = [
"//wpilibc:robotpy-wpilib",
requirement("typing-extensions"),

View File

@@ -4,55 +4,6 @@ include(SubDirList)
include(CompileWarnings)
include(AddTest)
if(WITH_JAVA)
include(UseJava)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java src/generated/main/java/*.java)
file(GLOB AVAJE_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/avaje/*.jar")
add_jar(
commandsv2_jar
${JAVA_SOURCES}
INCLUDE_JARS
hal_jar
ntcore_jar
${AVAJE_JARS}
cscore_jar
cameraserver_jar
wpimath_jar
wpiunits_jar
wpiutil_jar
wpilibj_jar
datalog_jar
wpiannotations_jar
OUTPUT_NAME commandsv2
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET commandsv2_jar PROPERTY FOLDER "java")
install_jar(commandsv2_jar DESTINATION ${java_lib_dest})
install_jar_exports(
TARGETS commandsv2_jar
FILE commandsv2_jar.cmake
DESTINATION share/commandsv2
)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
commandsv2_src_jar
BASE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
${CMAKE_CURRENT_SOURCE_DIR}/src/generated/main/java
OUTPUT_NAME commandsv2-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET commandsv2_src_jar PROPERTY FOLDER "java")
install_jar(commandsv2_src_jar DESTINATION ${java_lib_dest})
endif()
file(
GLOB_RECURSE commandsv2_native_src
src/main/native/cpp/*.cpp

View File

@@ -10,6 +10,3 @@ include(CMakeFindDependencyMacro)
@FILENAME_DEP_REPLACE@
include(${SELF_DIR}/commandsv2.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/commandsv2_jar.cmake)
endif()

View File

@@ -7,6 +7,7 @@ def __generate_wpilib_new_commands_impl(ctx):
args = ctx.actions.args()
args.add("--output_directory", output_dir.path)
args.add("--template_root", "commandsv2/src/generate")
args.add("--python_output_directory", "__none__")
ctx.actions.run(
inputs = ctx.attr._templates.files,

View File

@@ -6,6 +6,7 @@
import argparse
import json
import re
from pathlib import Path
from jinja2 import Environment, FileSystemLoader
@@ -63,6 +64,147 @@ def generate_hids(output_directory: Path, template_directory: Path, schema_file:
write_controller_file(root_path, controllerName, output)
def _capitalize_first(name: str) -> str:
return name[0].upper() + name[1:]
def _display_name(name: str) -> str:
name = re.sub(r"([a-z0-9])([A-Z])", r"\1 \2", name)
name = re.sub(r"([A-Z]+)([A-Z][a-z])", r"\1 \2", name)
name = re.sub(r"([A-Za-z])([0-9])", r"\1 \2", name)
return name[0].upper() + name[1:]
def _constant_name(name: str) -> str:
name = re.sub(r"([A-Z]+)([A-Z][a-z])", r"\1_\2", name)
name = re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", name)
name = re.sub(r"([a-z])([0-9])", r"\1_\2", name)
return name.upper()
def _is_trigger_axis(name: str) -> bool:
return name.endswith("Trigger") or name in {
"L2",
"R2",
"ZL",
"ZR",
}
def _normalize_command_mapping(mapping: dict[str, int]):
return [
{
"Name": name,
"MethodName": _capitalize_first(name),
"ConstantName": _constant_name(name),
"DocName": _display_name(name),
"value": value,
}
for name, value in mapping.items()
]
def _normalize_first_ds_command_controller(controller: dict):
buttons = _normalize_command_mapping(controller["buttons"])
axes = _normalize_command_mapping(controller["axes"])
button_names = {button["Name"] for button in buttons}
trigger_axes = []
for axis in axes:
if not _is_trigger_axis(axis["Name"]):
continue
name = axis["Name"]
trigger_name = name
trigger_axes.append(
{
"Name": trigger_name,
"MethodName": _capitalize_first(trigger_name),
"DocName": _display_name(trigger_name),
"AxisName": axis["Name"],
"AxisMethodName": axis["MethodName"],
"AxisConstantName": axis["ConstantName"],
"AxisDocName": axis["DocName"],
"HasDefaultThresholdMethod": trigger_name not in button_names,
}
)
normalized = dict(controller)
normalized["buttons"] = buttons
normalized["axes"] = axes
normalized["triggerAxes"] = trigger_axes
return normalized
def generate_first_ds_hids(
output_directory: Path,
template_directory: Path,
schema_file: Path,
python_output_directory: Path | None = None,
):
with schema_file.open(encoding="utf-8") as f:
controllers = [
_normalize_first_ds_command_controller(controller)
for controller in json.load(f)
]
# Java files
java_subdirectory = "main/java/org/wpilib/command2/button"
env = Environment(
loader=FileSystemLoader(template_directory / "main/java"),
autoescape=False,
keep_trailing_newline=True,
)
root_path = output_directory / java_subdirectory
template = env.get_template("first_ds_commandhid.java.jinja")
for controller in controllers:
controller_name = f"Command{controller['ClassName']}Controller.java"
output = template.render(controller)
write_controller_file(root_path, controller_name, output)
# C++ headers
hdr_subdirectory = "main/native/include/wpi/commands2/button"
env = Environment(
loader=FileSystemLoader(template_directory / hdr_subdirectory),
autoescape=False,
keep_trailing_newline=True,
)
root_path = output_directory / hdr_subdirectory
template = env.get_template("first_ds_commandhid.hpp.jinja")
for controller in controllers:
controller_name = f"Command{controller['ClassName']}Controller.hpp"
output = template.render(controller)
write_controller_file(root_path, controller_name, output)
# C++ files
cpp_subdirectory = "main/native/cpp/wpi/commands2/button"
env = Environment(
loader=FileSystemLoader(template_directory / cpp_subdirectory),
autoescape=False,
keep_trailing_newline=True,
)
root_path = output_directory / cpp_subdirectory
template = env.get_template("first_ds_commandhid.cpp.jinja")
for controller in controllers:
controller_name = f"Command{controller['ClassName']}Controller.cpp"
output = template.render(controller)
write_controller_file(root_path, controller_name, output)
if python_output_directory is not None:
python_subdirectory = "commands2/button"
env = Environment(
loader=FileSystemLoader(template_directory / "main/python"),
autoescape=False,
keep_trailing_newline=True,
)
root_path = python_output_directory / python_subdirectory
template = env.get_template("first_ds_commandhid.py.jinja")
for controller in controllers:
controller_name = f"command{controller['ClassName'].lower()}controller.py"
output = template.render(controller)
write_controller_file(root_path, controller_name, output)
def main():
script_path = Path(__file__).resolve()
dirname = script_path.parent
@@ -86,9 +228,32 @@ def main():
default="wpilibj/src/generate/hids.json",
type=Path,
)
parser.add_argument(
"--first_ds_schema_file",
help="Optional. If set, will use this file for the FIRST Driver Station HID schema",
default="wpilibj/src/generate/first_ds_hids.json",
type=Path,
)
parser.add_argument(
"--python_output_directory",
help="Optional. If set, will output generated Python files to this directory",
default=dirname / "src/main/python",
type=Path,
)
args = parser.parse_args()
generate_hids(args.output_directory, args.template_root, args.schema_file)
python_output_directory = (
None
if args.python_output_directory.name == "__none__"
else args.python_output_directory
)
generate_first_ds_hids(
args.output_directory,
args.template_root,
args.first_ds_schema_file,
python_output_directory,
)
if __name__ == "__main__":

View File

@@ -18,8 +18,9 @@ import org.wpilib.event.EventLoop;
* @see {{ ConsoleName }}Controller
*/
@SuppressWarnings("MethodName")
public class Command{{ ConsoleName }}Controller extends CommandGenericHID {
private final {{ ConsoleName }}Controller m_hid;
public class Command{{ ConsoleName }}Controller {
private final CommandGenericHID m_hid;
private final {{ ConsoleName }}Controller m_controller;
/**
* Construct an instance of a controller.
@@ -27,19 +28,27 @@ public class Command{{ ConsoleName }}Controller extends CommandGenericHID {
* @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);
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new {{ ConsoleName }}Controller(m_hid.getHID());
}
/**
* Get the underlying GenericHID object.
* Get the underlying CommandGenericHID object.
*
* @return the wrapped GenericHID object
* @return the wrapped CommandGenericHID object
*/
@Override
public {{ ConsoleName }}Controller getHID() {
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the underlying {{ ConsoleName }}Controller object.
*
* @return the wrapped {{ ConsoleName }}Controller object
*/
public {{ ConsoleName }}Controller get{{ ConsoleName }}Controller() {
return m_controller;
}
{% for button in buttons %}
/**
* Constructs a Trigger instance around the {{ button.DocName|default(button.name) }} button's digital signal.
@@ -60,7 +69,7 @@ public class Command{{ ConsoleName }}Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger {{ button.name }}(EventLoop loop) {
return button({{ ConsoleName }}Controller.Button.k{{ capitalize_first(button.name) }}.value, loop);
return m_hid.button({{ ConsoleName }}Controller.Button.k{{ capitalize_first(button.name) }}.value, loop);
}
{% endfor -%}
{% for trigger in triggers -%}
@@ -76,7 +85,7 @@ public class Command{{ ConsoleName }}Controller extends CommandGenericHID {
* threshold, attached to the given event loop
*/
public Trigger {{ trigger.name }}(double threshold, EventLoop loop) {
return axisGreaterThan({{ ConsoleName }}Controller.Axis.k{{ capitalize_first(trigger.name) }}.value, threshold, loop);
return m_hid.axisGreaterThan({{ ConsoleName }}Controller.Axis.k{{ capitalize_first(trigger.name) }}.value, threshold, loop);
}
/**
@@ -112,7 +121,7 @@ public class Command{{ ConsoleName }}Controller extends CommandGenericHID {
* @return The axis value.
*/
public double get{{ stick.NameParts|map("capitalize")|join }}() {
return m_hid.get{{ stick.NameParts|map("capitalize")|join }}();
return m_controller.get{{ stick.NameParts|map("capitalize")|join }}();
}
{% endfor -%}
{% for trigger in triggers %}
@@ -123,7 +132,7 @@ public class Command{{ ConsoleName }}Controller extends CommandGenericHID {
* @return The axis value.
*/
public double get{{ capitalize_first(trigger.name) }}Axis() {
return m_hid.get{{ capitalize_first(trigger.name) }}Axis();
return m_controller.get{{ capitalize_first(trigger.name) }}Axis();
}
{% endfor -%}
}

View File

@@ -0,0 +1,258 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
package org.wpilib.command2.button;
import java.util.Objects;
import org.wpilib.command2.CommandScheduler;
import org.wpilib.driverstation.{{ ClassName }}Controller;
import org.wpilib.event.EventLoop;
/**
* A version of {@link {{ ClassName }}Controller} with {@link Trigger} factories for command-based.
*
* @see {{ ClassName }}Controller
*/
@SuppressWarnings("MethodName")
public class Command{{ ClassName }}Controller {
private final CommandGenericHID m_hid;
private final {{ ClassName }}Controller m_controller;
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public Command{{ ClassName }}Controller(int port) {
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new {{ ClassName }}Controller(m_hid.getHID());
}
/**
* Construct an instance of a controller with a {{ ClassName }}Controller object.
*
* @param controller The {{ ClassName }}Controller object to use for this controller.
*/
public Command{{ ClassName }}Controller({{ ClassName }}Controller controller) {
m_controller =
Objects.requireNonNull(controller, "Provided {{ ClassName }}Controller cannot be null");
m_hid = new CommandGenericHID(m_controller.getHID());
}
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
public {{ ClassName }}Controller getController() {
return m_controller;
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @return an event instance representing the button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #button({{ ClassName }}Controller.Button, EventLoop)
*/
public Trigger button({{ ClassName }}Controller.Button button) {
return button(button, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the button's digital signal attached to the given loop.
*/
public Trigger button({{ ClassName }}Controller.Button button, EventLoop loop) {
return m_hid.button(button.value, loop);
}
{% for button in buttons %}
/**
* Constructs a Trigger instance around the {{ button.DocName }} button's digital signal.
*
* @return a Trigger instance representing the {{ button.DocName }} 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 }} button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the {{ button.DocName }} button's digital signal attached
* to the given loop.
*/
public Trigger {{ button.Name }}(EventLoop loop) {
return button({{ ClassName }}Controller.Button.{{ button.ConstantName }}, loop);
}
{% endfor -%}
{% for trigger in triggerAxes %}
/**
* 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 }} axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger {{ trigger.Name }}(double threshold, EventLoop loop) {
return axisGreaterThan(
{{ ClassName }}Controller.Axis.{{ trigger.AxisConstantName }}, threshold, loop);
}
/**
* 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 }} 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());
}
{% if trigger.HasDefaultThresholdMethod %}
/**
* 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 }} 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 %}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan({{ ClassName }}Controller.Axis axis, double threshold) {
return m_hid.axisLessThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the trigger to
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(
{{ ClassName }}Controller.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisLessThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan({{ ClassName }}Controller.Axis axis, double threshold) {
return m_hid.axisGreaterThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(
{{ ClassName }}Controller.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is greater than the
* provided threshold.
*/
public Trigger axisMagnitudeGreaterThan(
{{ ClassName }}Controller.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command
* scheduler button loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
*/
public Trigger axisMagnitudeGreaterThan({{ ClassName }}Controller.Axis axis, double threshold) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
}
/**
* Get the value of the axis.
*
* @param axis The axis to read
* @return The value of the axis.
*/
public double getAxis({{ ClassName }}Controller.Axis axis) {
return m_hid.getRawAxis(axis.value);
}
{% for axis in axes %}
/**
* Get the {{ axis.DocName }} value of the controller.
*
* @return The axis value.
*/
public double get{{ axis.MethodName }}() {
return m_controller.get{{ axis.MethodName }}();
}
{% endfor -%}
}

View File

@@ -11,33 +11,39 @@
using namespace wpi::cmd;
Command{{ ConsoleName }}Controller::Command{{ ConsoleName }}Controller(int port)
: CommandGenericHID(port), m_hid{wpi::{{ ConsoleName }}Controller(port)} {}
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)},
m_controller{m_hid->GetHID()} {}
wpi::{{ ConsoleName }}Controller& Command{{ ConsoleName }}Controller::GetHID() {
return m_hid;
CommandGenericHID& Command{{ ConsoleName }}Controller::GetHID() {
return *m_hid;
}
wpi::{{ ConsoleName }}Controller&
Command{{ ConsoleName }}Controller::Get{{ ConsoleName }}Controller() {
return m_controller;
}
{% for button in buttons %}
Trigger Command{{ ConsoleName }}Controller::{{ capitalize_first(button.name) }}(wpi::EventLoop* loop) const {
return Button(wpi::{{ ConsoleName }}Controller::Button::k{{ capitalize_first(button.name) }}, loop);
return m_hid->Button(
wpi::{{ ConsoleName }}Controller::Button::k{{ capitalize_first(button.name) }}, loop);
}
{% endfor -%}
{% for trigger in triggers -%}
{% if trigger.UseThresholdMethods %}
Trigger Command{{ ConsoleName }}Controller::{{ capitalize_first(trigger.name) }}(double threshold,
wpi::EventLoop* loop) const {
return Trigger(loop, [this, threshold] {
return m_hid.Get{{ capitalize_first(trigger.name) }}Axis() > threshold;
});
return m_hid->AxisGreaterThan(
wpi::{{ ConsoleName }}Controller::Axis::k{{ capitalize_first(trigger.name) }}, threshold, loop);
}
{% 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 }}();
return m_controller.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();
return m_controller.Get{{ capitalize_first(trigger.name) }}Axis();
}
{% endfor -%}

View File

@@ -0,0 +1,81 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#include "wpi/commands2/button/Command{{ ClassName }}Controller.hpp"
using namespace wpi::cmd;
Command{{ ClassName }}Controller::Command{{ ClassName }}Controller(int port)
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)} {
m_ownedController =
std::make_unique<wpi::{{ ClassName }}Controller>(m_hid->GetHID());
m_controller = m_ownedController.get();
}
Command{{ ClassName }}Controller::Command{{ ClassName }}Controller(
wpi::{{ ClassName }}Controller* controller)
: m_ownedHid{std::make_unique<CommandGenericHID>(controller->GetHID())},
m_hid{m_ownedHid.get()},
m_controller{controller} {}
CommandGenericHID& Command{{ ClassName }}Controller::GetHID() {
return *m_hid;
}
wpi::{{ ClassName }}Controller&
Command{{ ClassName }}Controller::GetController() {
return *m_controller;
}
const wpi::{{ ClassName }}Controller&
Command{{ ClassName }}Controller::GetController() const {
return *m_controller;
}
Trigger Command{{ ClassName }}Controller::Button(
enum wpi::{{ ClassName }}Controller::Button button,
wpi::EventLoop* loop) const {
return m_hid->Button(static_cast<int>(button), loop);
}
{% for button in buttons %}
Trigger Command{{ ClassName }}Controller::{{ button.MethodName }}(
wpi::EventLoop* loop) const {
return Button(wpi::{{ ClassName }}Controller::Button::{{ button.ConstantName }},
loop);
}
{% endfor -%}
{% for trigger in triggerAxes %}
Trigger Command{{ ClassName }}Controller::{{ trigger.MethodName }}(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::{{ ClassName }}Controller::Axis::{{ trigger.AxisConstantName }},
threshold, loop);
}
{% endfor %}
Trigger Command{{ ClassName }}Controller::AxisLessThan(
wpi::{{ ClassName }}Controller::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisLessThan(static_cast<int>(axis), threshold, loop);
}
Trigger Command{{ ClassName }}Controller::AxisGreaterThan(
wpi::{{ ClassName }}Controller::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisGreaterThan(static_cast<int>(axis), threshold, loop);
}
Trigger Command{{ ClassName }}Controller::AxisMagnitudeGreaterThan(
wpi::{{ ClassName }}Controller::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisMagnitudeGreaterThan(static_cast<int>(axis), threshold,
loop);
}
{% for axis in axes %}
double Command{{ ClassName }}Controller::Get{{ axis.MethodName }}() const {
return m_controller->Get{{ axis.MethodName }}();
}
{% endfor -%}

View File

@@ -8,11 +8,10 @@
{%- endmacro %}
#pragma once
#include "wpi/driverstation/{{ ConsoleName }}Controller.hpp"
#include "wpi/commands2/button/Trigger.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/Trigger.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/driverstation/{{ ConsoleName }}Controller.hpp"
namespace wpi::cmd {
/**
@@ -21,7 +20,7 @@ namespace wpi::cmd {
*
* @see wpi::{{ ConsoleName }}Controller
*/
class Command{{ ConsoleName }}Controller : public CommandGenericHID {
class Command{{ ConsoleName }}Controller {
public:
/**
* Construct an instance of a controller.
@@ -32,11 +31,18 @@ class Command{{ ConsoleName }}Controller : public CommandGenericHID {
explicit Command{{ ConsoleName }}Controller(int port);
/**
* Get the underlying GenericHID object.
* Get the underlying CommandGenericHID object.
*
* @return the wrapped GenericHID object
* @return the wrapped CommandGenericHID object
*/
wpi::{{ ConsoleName }}Controller& GetHID();
CommandGenericHID& GetHID();
/**
* Get the underlying {{ ConsoleName }}Controller object.
*
* @return the wrapped {{ ConsoleName }}Controller object
*/
wpi::{{ ConsoleName }}Controller& Get{{ ConsoleName }}Controller();
{% for button in buttons %}
/**
* Constructs a Trigger instance around the {{ button.DocName|default(button.name) }} button's
@@ -88,6 +94,7 @@ class Command{{ ConsoleName }}Controller : public CommandGenericHID {
double Get{{ capitalize_first(trigger.name) }}Axis() const;
{% endfor %}
private:
wpi::{{ ConsoleName }}Controller m_hid;
CommandGenericHID* m_hid;
wpi::{{ ConsoleName }}Controller m_controller;
};
} // namespace wpi::cmd

View File

@@ -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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#pragma once
#include <memory>
#include "wpi/driverstation/{{ ClassName }}Controller.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/commands2/button/Trigger.hpp"
namespace wpi::cmd {
/**
* A version of {@link wpi::{{ ClassName }}Controller} with {@link Trigger}
* factories for command-based.
*
* @see wpi::{{ ClassName }}Controller
*/
class Command{{ ClassName }}Controller {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit Command{{ ClassName }}Controller(int port);
/**
* Construct an instance of a controller with a {{ ClassName }}Controller object.
*
* @param controller The {{ ClassName }}Controller object to use for this controller.
*/
explicit Command{{ ClassName }}Controller(wpi::{{ ClassName }}Controller* controller);
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
CommandGenericHID& GetHID();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
wpi::{{ ClassName }}Controller& GetController();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
const wpi::{{ ClassName }}Controller& GetController() const;
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @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(enum wpi::{{ ClassName }}Controller::Button button,
wpi::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
{% for button in buttons %}
/**
* Constructs a Trigger instance around the {{ button.DocName }} 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 }} button's
* digital signal attached to the given loop.
*/
Trigger {{ button.MethodName }}(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
{% endfor -%}
{% for trigger in triggerAxes %}
/**
* 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 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.{% if trigger.HasDefaultThresholdMethod %} Defaults to 0.5.{% endif %}
* @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 }} axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger {{ trigger.MethodName }}(
double threshold{% if trigger.HasDefaultThresholdMethod %} = 0.5{% endif %},
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
{% endfor %}
/**
* Constructs a Trigger instance that is true when the axis value is less than
* {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read, starting at 0.
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is less than
* the provided threshold.
*/
Trigger AxisLessThan(
wpi::{{ ClassName }}Controller::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is greater
* than {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is greater than
* the provided threshold.
*/
Trigger AxisGreaterThan(
wpi::{{ ClassName }}Controller::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis magnitude value is
* greater than {@code threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is
* greater than the provided threshold.
*/
Trigger AxisMagnitudeGreaterThan(
wpi::{{ ClassName }}Controller::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
{% for axis in axes %}
/**
* Get the {{ axis.DocName }} value of the controller.
*
* @return the axis value.
*/
double Get{{ axis.MethodName }}() const;
{% endfor %}
private:
std::unique_ptr<CommandGenericHID> m_ownedHid;
CommandGenericHID* m_hid = nullptr;
std::unique_ptr<wpi::{{ ClassName }}Controller> m_ownedController;
wpi::{{ ClassName }}Controller* m_controller = nullptr;
};
} // namespace wpi::cmd

View File

@@ -0,0 +1,170 @@
# THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY
from typing import Optional, Union
from wpilib import EventLoop, {{ ClassName }}Controller
from .commandgenerichid import CommandGenericHID
from .trigger import Trigger
class Command{{ ClassName }}Controller:
"""
A version of :class:`wpilib.{{ ClassName }}Controller` with :class:`.Trigger` factories for command-based.
"""
_hid: CommandGenericHID
_controller: {{ ClassName }}Controller
def __init__(self, hid: Union[int, {{ ClassName }}Controller]):
"""
Construct an instance of a controller.
:param hid: The port index on the Driver Station that the controller is plugged into,
or the {{ ClassName }}Controller object to use for this controller.
"""
if isinstance(hid, int):
self._hid = CommandGenericHID.getCommandGenericHID(hid)
self._controller = {{ ClassName }}Controller(self._hid.getHID())
else:
self._hid = CommandGenericHID(hid.getHID())
self._controller = hid
def getHID(self) -> CommandGenericHID:
"""
Get the underlying CommandGenericHID object.
:returns: the wrapped CommandGenericHID object
"""
return self._hid
def getController(self) -> {{ ClassName }}Controller:
"""
Get the wrapped controller object.
:returns: the wrapped controller object
"""
return self._controller
def button(
self,
button: {{ ClassName }}Controller.Button,
loop: Optional[EventLoop] = None,
) -> Trigger:
"""
Constructs an event instance around this button's digital signal.
:param button: the :class:`wpilib.{{ ClassName }}Controller.Button` to read
:param loop: the event loop instance to attach the event to
"""
return self._hid.button(button.value, loop)
{% for button in buttons %}
def {{ button.Name }}(self, loop: Optional[EventLoop] = None) -> Trigger:
"""
Constructs a Trigger instance around the {{ button.DocName }} button's digital signal.
:param loop: the event loop instance to attach the Trigger to, defaults
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`
:returns: a Trigger instance representing the {{ button.DocName }} button's digital signal
attached to the given loop.
"""
return self.button({{ ClassName }}Controller.Button.{{ button.ConstantName }}, loop)
{% endfor -%}
{% for trigger in triggerAxes %}
def {{ trigger.Name }}(
self,
threshold: float{% if trigger.HasDefaultThresholdMethod %} = 0.5{% endif %},
loop: Optional[EventLoop] = None,
) -> Trigger:
"""
Constructs a Trigger instance around the {{ trigger.DocName }} axis value. The returned
Trigger will be true when the axis value is greater than ``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.
:param loop: the event loop instance to attach the Trigger to, defaults
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`
:returns: a Trigger instance that is true when the {{ trigger.DocName }} axis exceeds the
provided threshold, attached to the given event loop.
"""
return self.axisGreaterThan(
{{ ClassName }}Controller.Axis.{{ trigger.AxisConstantName }},
threshold,
loop,
)
{% endfor %}
def axisLessThan(
self,
axis: {{ ClassName }}Controller.Axis,
threshold: float,
loop: Optional[EventLoop] = None,
) -> Trigger:
"""
Constructs a Trigger instance that is true when the axis value is less than
``threshold``, attached to the given loop.
:param axis: the :class:`wpilib.{{ ClassName }}Controller.Axis` to read
:param threshold: the value below which this Trigger should return true.
:param loop: the event loop instance to attach the Trigger to
:returns: a Trigger instance that is true when the axis value is less than
the provided threshold.
"""
return self._hid.axisLessThan(axis.value, threshold, loop)
def axisGreaterThan(
self,
axis: {{ ClassName }}Controller.Axis,
threshold: float,
loop: Optional[EventLoop] = None,
) -> Trigger:
"""
Constructs a Trigger instance that is true when the axis value is greater
than ``threshold``, attached to the given loop.
:param axis: the :class:`wpilib.{{ ClassName }}Controller.Axis` to read
:param threshold: the value above which this Trigger should return true.
:param loop: the event loop instance to attach the Trigger to.
:returns: a Trigger instance that is true when the axis value is greater
than the provided threshold.
"""
return self._hid.axisGreaterThan(axis.value, threshold, loop)
def axisMagnitudeGreaterThan(
self,
axis: {{ ClassName }}Controller.Axis,
threshold: float,
loop: Optional[EventLoop] = None,
) -> Trigger:
"""
Constructs a Trigger instance that is true when the axis magnitude is
greater than ``threshold``, attached to the given loop.
:param axis: the :class:`wpilib.{{ ClassName }}Controller.Axis` to read
:param threshold: the value above which this Trigger should return true.
:param loop: the event loop instance to attach the Trigger to.
:returns: a Trigger instance that is true when the axis magnitude is
greater than the provided threshold.
"""
return self._hid.axisMagnitudeGreaterThan(axis.value, threshold, loop)
def getAxis(self, axis: {{ ClassName }}Controller.Axis) -> float:
"""
Get the value of the axis.
:param axis: the :class:`wpilib.{{ ClassName }}Controller.Axis` to read
"""
return self._hid.getRawAxis(axis.value)
{% for axis in axes %}
def get{{ axis.MethodName }}(self) -> float:
"""
Get the {{ axis.DocName }} value of the controller.
:returns: the axis value.
"""
return self._controller.get{{ axis.MethodName }}()
{% endfor -%}

View File

@@ -0,0 +1,696 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
package org.wpilib.command2.button;
import java.util.Objects;
import org.wpilib.command2.CommandScheduler;
import org.wpilib.driverstation.DualSenseController;
import org.wpilib.event.EventLoop;
/**
* A version of {@link DualSenseController} with {@link Trigger} factories for command-based.
*
* @see DualSenseController
*/
@SuppressWarnings("MethodName")
public class CommandDualSenseController {
private final CommandGenericHID m_hid;
private final DualSenseController m_controller;
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandDualSenseController(int port) {
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new DualSenseController(m_hid.getHID());
}
/**
* Construct an instance of a controller with a DualSenseController object.
*
* @param controller The DualSenseController object to use for this controller.
*/
public CommandDualSenseController(DualSenseController controller) {
m_controller =
Objects.requireNonNull(controller, "Provided DualSenseController cannot be null");
m_hid = new CommandGenericHID(m_controller.getHID());
}
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
public DualSenseController getController() {
return m_controller;
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @return an event instance representing the button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #button(DualSenseController.Button, EventLoop)
*/
public Trigger button(DualSenseController.Button button) {
return button(button, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the button's digital signal attached to the given loop.
*/
public Trigger button(DualSenseController.Button button, EventLoop loop) {
return m_hid.button(button.value, loop);
}
/**
* 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 button(DualSenseController.Button.CROSS, loop);
}
/**
* 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 button(DualSenseController.Button.CIRCLE, loop);
}
/**
* 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 button(DualSenseController.Button.SQUARE, loop);
}
/**
* 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 button(DualSenseController.Button.TRIANGLE, loop);
}
/**
* 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 button(DualSenseController.Button.CREATE, loop);
}
/**
* Constructs a Trigger instance around the PS button's digital signal.
*
* @return a Trigger instance representing the PS 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 PS button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the PS button's digital signal attached
* to the given loop.
*/
public Trigger PS(EventLoop loop) {
return button(DualSenseController.Button.PS, loop);
}
/**
* 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 button(DualSenseController.Button.OPTIONS, loop);
}
/**
* Constructs a Trigger instance around the L 3 button's digital signal.
*
* @return a Trigger instance representing the L 3 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 L 3 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the L 3 button's digital signal attached
* to the given loop.
*/
public Trigger L3(EventLoop loop) {
return button(DualSenseController.Button.L3, loop);
}
/**
* Constructs a Trigger instance around the R 3 button's digital signal.
*
* @return a Trigger instance representing the R 3 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 R 3 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the R 3 button's digital signal attached
* to the given loop.
*/
public Trigger R3(EventLoop loop) {
return button(DualSenseController.Button.R3, loop);
}
/**
* Constructs a Trigger instance around the L 1 button's digital signal.
*
* @return a Trigger instance representing the L 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 L 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the L 1 button's digital signal attached
* to the given loop.
*/
public Trigger L1(EventLoop loop) {
return button(DualSenseController.Button.L1, loop);
}
/**
* Constructs a Trigger instance around the R 1 button's digital signal.
*
* @return a Trigger instance representing the R 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 R 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the R 1 button's digital signal attached
* to the given loop.
*/
public Trigger R1(EventLoop loop) {
return button(DualSenseController.Button.R1, loop);
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadUp(EventLoop)
*/
public Trigger dpadUp() {
return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the given loop.
*/
public Trigger dpadUp(EventLoop loop) {
return button(DualSenseController.Button.DPAD_UP, loop);
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadDown(EventLoop)
*/
public Trigger dpadDown() {
return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the given loop.
*/
public Trigger dpadDown(EventLoop loop) {
return button(DualSenseController.Button.DPAD_DOWN, loop);
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadLeft(EventLoop)
*/
public Trigger dpadLeft() {
return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the given loop.
*/
public Trigger dpadLeft(EventLoop loop) {
return button(DualSenseController.Button.DPAD_LEFT, loop);
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadRight(EventLoop)
*/
public Trigger dpadRight() {
return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the given loop.
*/
public Trigger dpadRight(EventLoop loop) {
return button(DualSenseController.Button.DPAD_RIGHT, loop);
}
/**
* Constructs a Trigger instance around the Microphone button's digital signal.
*
* @return a Trigger instance representing the Microphone button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #microphone(EventLoop)
*/
public Trigger microphone() {
return microphone(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Microphone button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Microphone button's digital signal attached
* to the given loop.
*/
public Trigger microphone(EventLoop loop) {
return button(DualSenseController.Button.MICROPHONE, loop);
}
/**
* 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 button(DualSenseController.Button.TOUCHPAD, loop);
}
/**
* Constructs a Trigger instance around the axis value of the L 2. 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 L 2 axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger L2(double threshold, EventLoop loop) {
return axisGreaterThan(
DualSenseController.Axis.L2, threshold, loop);
}
/**
* Constructs a Trigger instance around the axis value of the L 2. 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 L 2 axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger L2(double threshold) {
return L2(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the L 2. The returned
* trigger will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the L 2 axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger L2() {
return L2(0.5);
}
/**
* Constructs a Trigger instance around the axis value of the R 2. 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 R 2 axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger R2(double threshold, EventLoop loop) {
return axisGreaterThan(
DualSenseController.Axis.R2, threshold, loop);
}
/**
* Constructs a Trigger instance around the axis value of the R 2. 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 R 2 axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger R2(double threshold) {
return R2(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the R 2. The returned
* trigger will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the R 2 axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger R2() {
return R2(0.5);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(DualSenseController.Axis axis, double threshold) {
return m_hid.axisLessThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the trigger to
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(
DualSenseController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisLessThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(DualSenseController.Axis axis, double threshold) {
return m_hid.axisGreaterThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(
DualSenseController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is greater than the
* provided threshold.
*/
public Trigger axisMagnitudeGreaterThan(
DualSenseController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command
* scheduler button loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
*/
public Trigger axisMagnitudeGreaterThan(DualSenseController.Axis axis, double threshold) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
}
/**
* Get the value of the axis.
*
* @param axis The axis to read
* @return The value of the axis.
*/
public double getAxis(DualSenseController.Axis axis) {
return m_hid.getRawAxis(axis.value);
}
/**
* Get the Left X value of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return m_controller.getLeftX();
}
/**
* Get the Left Y value of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return m_controller.getLeftY();
}
/**
* Get the Right X value of the controller.
*
* @return The axis value.
*/
public double getRightX() {
return m_controller.getRightX();
}
/**
* Get the Right Y value of the controller.
*
* @return The axis value.
*/
public double getRightY() {
return m_controller.getRightY();
}
/**
* Get the L 2 value of the controller.
*
* @return The axis value.
*/
public double getL2() {
return m_controller.getL2();
}
/**
* Get the R 2 value of the controller.
*
* @return The axis value.
*/
public double getR2() {
return m_controller.getR2();
}
}

View File

@@ -0,0 +1,784 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
package org.wpilib.command2.button;
import java.util.Objects;
import org.wpilib.command2.CommandScheduler;
import org.wpilib.driverstation.DualSenseEdgeController;
import org.wpilib.event.EventLoop;
/**
* A version of {@link DualSenseEdgeController} with {@link Trigger} factories for command-based.
*
* @see DualSenseEdgeController
*/
@SuppressWarnings("MethodName")
public class CommandDualSenseEdgeController {
private final CommandGenericHID m_hid;
private final DualSenseEdgeController m_controller;
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandDualSenseEdgeController(int port) {
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new DualSenseEdgeController(m_hid.getHID());
}
/**
* Construct an instance of a controller with a DualSenseEdgeController object.
*
* @param controller The DualSenseEdgeController object to use for this controller.
*/
public CommandDualSenseEdgeController(DualSenseEdgeController controller) {
m_controller =
Objects.requireNonNull(controller, "Provided DualSenseEdgeController cannot be null");
m_hid = new CommandGenericHID(m_controller.getHID());
}
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
public DualSenseEdgeController getController() {
return m_controller;
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @return an event instance representing the button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #button(DualSenseEdgeController.Button, EventLoop)
*/
public Trigger button(DualSenseEdgeController.Button button) {
return button(button, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the button's digital signal attached to the given loop.
*/
public Trigger button(DualSenseEdgeController.Button button, EventLoop loop) {
return m_hid.button(button.value, loop);
}
/**
* 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 button(DualSenseEdgeController.Button.CROSS, loop);
}
/**
* 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 button(DualSenseEdgeController.Button.CIRCLE, loop);
}
/**
* 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 button(DualSenseEdgeController.Button.SQUARE, loop);
}
/**
* 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 button(DualSenseEdgeController.Button.TRIANGLE, loop);
}
/**
* 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 button(DualSenseEdgeController.Button.CREATE, loop);
}
/**
* Constructs a Trigger instance around the PS button's digital signal.
*
* @return a Trigger instance representing the PS 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 PS button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the PS button's digital signal attached
* to the given loop.
*/
public Trigger PS(EventLoop loop) {
return button(DualSenseEdgeController.Button.PS, loop);
}
/**
* 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 button(DualSenseEdgeController.Button.OPTIONS, loop);
}
/**
* Constructs a Trigger instance around the L 3 button's digital signal.
*
* @return a Trigger instance representing the L 3 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 L 3 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the L 3 button's digital signal attached
* to the given loop.
*/
public Trigger L3(EventLoop loop) {
return button(DualSenseEdgeController.Button.L3, loop);
}
/**
* Constructs a Trigger instance around the R 3 button's digital signal.
*
* @return a Trigger instance representing the R 3 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 R 3 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the R 3 button's digital signal attached
* to the given loop.
*/
public Trigger R3(EventLoop loop) {
return button(DualSenseEdgeController.Button.R3, loop);
}
/**
* Constructs a Trigger instance around the L 1 button's digital signal.
*
* @return a Trigger instance representing the L 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 L 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the L 1 button's digital signal attached
* to the given loop.
*/
public Trigger L1(EventLoop loop) {
return button(DualSenseEdgeController.Button.L1, loop);
}
/**
* Constructs a Trigger instance around the R 1 button's digital signal.
*
* @return a Trigger instance representing the R 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 R 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the R 1 button's digital signal attached
* to the given loop.
*/
public Trigger R1(EventLoop loop) {
return button(DualSenseEdgeController.Button.R1, loop);
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadUp(EventLoop)
*/
public Trigger dpadUp() {
return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the given loop.
*/
public Trigger dpadUp(EventLoop loop) {
return button(DualSenseEdgeController.Button.DPAD_UP, loop);
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadDown(EventLoop)
*/
public Trigger dpadDown() {
return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the given loop.
*/
public Trigger dpadDown(EventLoop loop) {
return button(DualSenseEdgeController.Button.DPAD_DOWN, loop);
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadLeft(EventLoop)
*/
public Trigger dpadLeft() {
return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the given loop.
*/
public Trigger dpadLeft(EventLoop loop) {
return button(DualSenseEdgeController.Button.DPAD_LEFT, loop);
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadRight(EventLoop)
*/
public Trigger dpadRight() {
return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the given loop.
*/
public Trigger dpadRight(EventLoop loop) {
return button(DualSenseEdgeController.Button.DPAD_RIGHT, loop);
}
/**
* Constructs a Trigger instance around the Microphone button's digital signal.
*
* @return a Trigger instance representing the Microphone button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #microphone(EventLoop)
*/
public Trigger microphone() {
return microphone(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Microphone button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Microphone button's digital signal attached
* to the given loop.
*/
public Trigger microphone(EventLoop loop) {
return button(DualSenseEdgeController.Button.MICROPHONE, loop);
}
/**
* Constructs a Trigger instance around the Right Paddle 1 button's digital signal.
*
* @return a Trigger instance representing the Right Paddle 1 button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #rightPaddle1(EventLoop)
*/
public Trigger rightPaddle1() {
return rightPaddle1(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Right Paddle 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Right Paddle 1 button's digital signal attached
* to the given loop.
*/
public Trigger rightPaddle1(EventLoop loop) {
return button(DualSenseEdgeController.Button.RIGHT_PADDLE_1, loop);
}
/**
* Constructs a Trigger instance around the Left Paddle 1 button's digital signal.
*
* @return a Trigger instance representing the Left Paddle 1 button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #leftPaddle1(EventLoop)
*/
public Trigger leftPaddle1() {
return leftPaddle1(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Left Paddle 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Left Paddle 1 button's digital signal attached
* to the given loop.
*/
public Trigger leftPaddle1(EventLoop loop) {
return button(DualSenseEdgeController.Button.LEFT_PADDLE_1, loop);
}
/**
* 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 button(DualSenseEdgeController.Button.TOUCHPAD, loop);
}
/**
* Constructs a Trigger instance around the Left Function button's digital signal.
*
* @return a Trigger instance representing the Left Function button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #leftFunction(EventLoop)
*/
public Trigger leftFunction() {
return leftFunction(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Left Function button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Left Function button's digital signal attached
* to the given loop.
*/
public Trigger leftFunction(EventLoop loop) {
return button(DualSenseEdgeController.Button.LEFT_FUNCTION, loop);
}
/**
* Constructs a Trigger instance around the Right Function button's digital signal.
*
* @return a Trigger instance representing the Right Function button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #rightFunction(EventLoop)
*/
public Trigger rightFunction() {
return rightFunction(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Right Function button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Right Function button's digital signal attached
* to the given loop.
*/
public Trigger rightFunction(EventLoop loop) {
return button(DualSenseEdgeController.Button.RIGHT_FUNCTION, loop);
}
/**
* Constructs a Trigger instance around the axis value of the L 2. 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 L 2 axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger L2(double threshold, EventLoop loop) {
return axisGreaterThan(
DualSenseEdgeController.Axis.L2, threshold, loop);
}
/**
* Constructs a Trigger instance around the axis value of the L 2. 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 L 2 axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger L2(double threshold) {
return L2(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the L 2. The returned
* trigger will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the L 2 axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger L2() {
return L2(0.5);
}
/**
* Constructs a Trigger instance around the axis value of the R 2. 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 R 2 axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger R2(double threshold, EventLoop loop) {
return axisGreaterThan(
DualSenseEdgeController.Axis.R2, threshold, loop);
}
/**
* Constructs a Trigger instance around the axis value of the R 2. 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 R 2 axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger R2(double threshold) {
return R2(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the R 2. The returned
* trigger will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the R 2 axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger R2() {
return R2(0.5);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(DualSenseEdgeController.Axis axis, double threshold) {
return m_hid.axisLessThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the trigger to
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(
DualSenseEdgeController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisLessThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(DualSenseEdgeController.Axis axis, double threshold) {
return m_hid.axisGreaterThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(
DualSenseEdgeController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is greater than the
* provided threshold.
*/
public Trigger axisMagnitudeGreaterThan(
DualSenseEdgeController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command
* scheduler button loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
*/
public Trigger axisMagnitudeGreaterThan(DualSenseEdgeController.Axis axis, double threshold) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
}
/**
* Get the value of the axis.
*
* @param axis The axis to read
* @return The value of the axis.
*/
public double getAxis(DualSenseEdgeController.Axis axis) {
return m_hid.getRawAxis(axis.value);
}
/**
* Get the Left X value of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return m_controller.getLeftX();
}
/**
* Get the Left Y value of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return m_controller.getLeftY();
}
/**
* Get the Right X value of the controller.
*
* @return The axis value.
*/
public double getRightX() {
return m_controller.getRightX();
}
/**
* Get the Right Y value of the controller.
*
* @return The axis value.
*/
public double getRightY() {
return m_controller.getRightY();
}
/**
* Get the L 2 value of the controller.
*
* @return The axis value.
*/
public double getL2() {
return m_controller.getL2();
}
/**
* Get the R 2 value of the controller.
*
* @return The axis value.
*/
public double getR2() {
return m_controller.getR2();
}
}

View File

@@ -0,0 +1,674 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
package org.wpilib.command2.button;
import java.util.Objects;
import org.wpilib.command2.CommandScheduler;
import org.wpilib.driverstation.DualShock4Controller;
import org.wpilib.event.EventLoop;
/**
* A version of {@link DualShock4Controller} with {@link Trigger} factories for command-based.
*
* @see DualShock4Controller
*/
@SuppressWarnings("MethodName")
public class CommandDualShock4Controller {
private final CommandGenericHID m_hid;
private final DualShock4Controller m_controller;
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandDualShock4Controller(int port) {
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new DualShock4Controller(m_hid.getHID());
}
/**
* Construct an instance of a controller with a DualShock4Controller object.
*
* @param controller The DualShock4Controller object to use for this controller.
*/
public CommandDualShock4Controller(DualShock4Controller controller) {
m_controller =
Objects.requireNonNull(controller, "Provided DualShock4Controller cannot be null");
m_hid = new CommandGenericHID(m_controller.getHID());
}
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
public DualShock4Controller getController() {
return m_controller;
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @return an event instance representing the button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #button(DualShock4Controller.Button, EventLoop)
*/
public Trigger button(DualShock4Controller.Button button) {
return button(button, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the button's digital signal attached to the given loop.
*/
public Trigger button(DualShock4Controller.Button button, EventLoop loop) {
return m_hid.button(button.value, loop);
}
/**
* 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 button(DualShock4Controller.Button.CROSS, loop);
}
/**
* 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 button(DualShock4Controller.Button.CIRCLE, loop);
}
/**
* 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 button(DualShock4Controller.Button.SQUARE, loop);
}
/**
* 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 button(DualShock4Controller.Button.TRIANGLE, loop);
}
/**
* 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 button(DualShock4Controller.Button.SHARE, loop);
}
/**
* Constructs a Trigger instance around the PS button's digital signal.
*
* @return a Trigger instance representing the PS 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 PS button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the PS button's digital signal attached
* to the given loop.
*/
public Trigger PS(EventLoop loop) {
return button(DualShock4Controller.Button.PS, loop);
}
/**
* 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 button(DualShock4Controller.Button.OPTIONS, loop);
}
/**
* Constructs a Trigger instance around the L 3 button's digital signal.
*
* @return a Trigger instance representing the L 3 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 L 3 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the L 3 button's digital signal attached
* to the given loop.
*/
public Trigger L3(EventLoop loop) {
return button(DualShock4Controller.Button.L3, loop);
}
/**
* Constructs a Trigger instance around the R 3 button's digital signal.
*
* @return a Trigger instance representing the R 3 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 R 3 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the R 3 button's digital signal attached
* to the given loop.
*/
public Trigger R3(EventLoop loop) {
return button(DualShock4Controller.Button.R3, loop);
}
/**
* Constructs a Trigger instance around the L 1 button's digital signal.
*
* @return a Trigger instance representing the L 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 L 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the L 1 button's digital signal attached
* to the given loop.
*/
public Trigger L1(EventLoop loop) {
return button(DualShock4Controller.Button.L1, loop);
}
/**
* Constructs a Trigger instance around the R 1 button's digital signal.
*
* @return a Trigger instance representing the R 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 R 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the R 1 button's digital signal attached
* to the given loop.
*/
public Trigger R1(EventLoop loop) {
return button(DualShock4Controller.Button.R1, loop);
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadUp(EventLoop)
*/
public Trigger dpadUp() {
return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the given loop.
*/
public Trigger dpadUp(EventLoop loop) {
return button(DualShock4Controller.Button.DPAD_UP, loop);
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadDown(EventLoop)
*/
public Trigger dpadDown() {
return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the given loop.
*/
public Trigger dpadDown(EventLoop loop) {
return button(DualShock4Controller.Button.DPAD_DOWN, loop);
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadLeft(EventLoop)
*/
public Trigger dpadLeft() {
return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the given loop.
*/
public Trigger dpadLeft(EventLoop loop) {
return button(DualShock4Controller.Button.DPAD_LEFT, loop);
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadRight(EventLoop)
*/
public Trigger dpadRight() {
return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the given loop.
*/
public Trigger dpadRight(EventLoop loop) {
return button(DualShock4Controller.Button.DPAD_RIGHT, loop);
}
/**
* 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 button(DualShock4Controller.Button.TOUCHPAD, loop);
}
/**
* Constructs a Trigger instance around the axis value of the L 2. 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 L 2 axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger L2(double threshold, EventLoop loop) {
return axisGreaterThan(
DualShock4Controller.Axis.L2, threshold, loop);
}
/**
* Constructs a Trigger instance around the axis value of the L 2. 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 L 2 axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger L2(double threshold) {
return L2(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the L 2. The returned
* trigger will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the L 2 axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger L2() {
return L2(0.5);
}
/**
* Constructs a Trigger instance around the axis value of the R 2. 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 R 2 axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger R2(double threshold, EventLoop loop) {
return axisGreaterThan(
DualShock4Controller.Axis.R2, threshold, loop);
}
/**
* Constructs a Trigger instance around the axis value of the R 2. 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 R 2 axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger R2(double threshold) {
return R2(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the R 2. The returned
* trigger will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the R 2 axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger R2() {
return R2(0.5);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(DualShock4Controller.Axis axis, double threshold) {
return m_hid.axisLessThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the trigger to
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(
DualShock4Controller.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisLessThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(DualShock4Controller.Axis axis, double threshold) {
return m_hid.axisGreaterThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(
DualShock4Controller.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is greater than the
* provided threshold.
*/
public Trigger axisMagnitudeGreaterThan(
DualShock4Controller.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command
* scheduler button loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
*/
public Trigger axisMagnitudeGreaterThan(DualShock4Controller.Axis axis, double threshold) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
}
/**
* Get the value of the axis.
*
* @param axis The axis to read
* @return The value of the axis.
*/
public double getAxis(DualShock4Controller.Axis axis) {
return m_hid.getRawAxis(axis.value);
}
/**
* Get the Left X value of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return m_controller.getLeftX();
}
/**
* Get the Left Y value of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return m_controller.getLeftY();
}
/**
* Get the Right X value of the controller.
*
* @return The axis value.
*/
public double getRightX() {
return m_controller.getRightX();
}
/**
* Get the Right Y value of the controller.
*
* @return The axis value.
*/
public double getRightY() {
return m_controller.getRightY();
}
/**
* Get the L 2 value of the controller.
*
* @return The axis value.
*/
public double getL2() {
return m_controller.getL2();
}
/**
* Get the R 2 value of the controller.
*
* @return The axis value.
*/
public double getR2() {
return m_controller.getR2();
}
}

View File

@@ -0,0 +1,586 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
package org.wpilib.command2.button;
import java.util.Objects;
import org.wpilib.command2.CommandScheduler;
import org.wpilib.driverstation.GameCubeController;
import org.wpilib.event.EventLoop;
/**
* A version of {@link GameCubeController} with {@link Trigger} factories for command-based.
*
* @see GameCubeController
*/
@SuppressWarnings("MethodName")
public class CommandGameCubeController {
private final CommandGenericHID m_hid;
private final GameCubeController m_controller;
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandGameCubeController(int port) {
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new GameCubeController(m_hid.getHID());
}
/**
* Construct an instance of a controller with a GameCubeController object.
*
* @param controller The GameCubeController object to use for this controller.
*/
public CommandGameCubeController(GameCubeController controller) {
m_controller =
Objects.requireNonNull(controller, "Provided GameCubeController cannot be null");
m_hid = new CommandGenericHID(m_controller.getHID());
}
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
public GameCubeController getController() {
return m_controller;
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @return an event instance representing the button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #button(GameCubeController.Button, EventLoop)
*/
public Trigger button(GameCubeController.Button button) {
return button(button, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the button's digital signal attached to the given loop.
*/
public Trigger button(GameCubeController.Button button, EventLoop loop) {
return m_hid.button(button.value, loop);
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @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() {
return a(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the A button's digital signal attached
* to the given loop.
*/
public Trigger a(EventLoop loop) {
return button(GameCubeController.Button.A, loop);
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @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() {
return x(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the X button's digital signal attached
* to the given loop.
*/
public Trigger x(EventLoop loop) {
return button(GameCubeController.Button.X, loop);
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @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() {
return b(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the B button's digital signal attached
* to the given loop.
*/
public Trigger b(EventLoop loop) {
return button(GameCubeController.Button.B, loop);
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @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() {
return y(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Y button's digital signal attached
* to the given loop.
*/
public Trigger y(EventLoop loop) {
return button(GameCubeController.Button.Y, loop);
}
/**
* 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 button(GameCubeController.Button.START, loop);
}
/**
* Constructs a Trigger instance around the Z button's digital signal.
*
* @return a Trigger instance representing the Z button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #Z(EventLoop)
*/
public Trigger Z() {
return Z(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Z button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Z button's digital signal attached
* to the given loop.
*/
public Trigger Z(EventLoop loop) {
return button(GameCubeController.Button.Z, loop);
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadUp(EventLoop)
*/
public Trigger dpadUp() {
return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the given loop.
*/
public Trigger dpadUp(EventLoop loop) {
return button(GameCubeController.Button.DPAD_UP, loop);
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadDown(EventLoop)
*/
public Trigger dpadDown() {
return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the given loop.
*/
public Trigger dpadDown(EventLoop loop) {
return button(GameCubeController.Button.DPAD_DOWN, loop);
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadLeft(EventLoop)
*/
public Trigger dpadLeft() {
return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the given loop.
*/
public Trigger dpadLeft(EventLoop loop) {
return button(GameCubeController.Button.DPAD_LEFT, loop);
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadRight(EventLoop)
*/
public Trigger dpadRight() {
return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the given loop.
*/
public Trigger dpadRight(EventLoop loop) {
return button(GameCubeController.Button.DPAD_RIGHT, loop);
}
/**
* Constructs a Trigger instance around the L button's digital signal.
*
* @return a Trigger instance representing the L button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #L(EventLoop)
*/
public Trigger L() {
return L(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the L button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the L button's digital signal attached
* to the given loop.
*/
public Trigger L(EventLoop loop) {
return button(GameCubeController.Button.L, loop);
}
/**
* Constructs a Trigger instance around the R button's digital signal.
*
* @return a Trigger instance representing the R button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #R(EventLoop)
*/
public Trigger R() {
return R(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the R button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the R button's digital signal attached
* to the given loop.
*/
public Trigger R(EventLoop loop) {
return button(GameCubeController.Button.R, loop);
}
/**
* Constructs a Trigger instance around the axis value of the L 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.
* @param loop the event loop instance to attach the Trigger to.
* @return a Trigger instance that is true when the L Trigger axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger LTrigger(double threshold, EventLoop loop) {
return axisGreaterThan(
GameCubeController.Axis.L_TRIGGER, threshold, loop);
}
/**
* Constructs a Trigger instance around the axis value of the L 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.
* @return a Trigger instance that is true when the L Trigger axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger LTrigger(double threshold) {
return LTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the L Trigger. The returned
* trigger will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the L Trigger axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger LTrigger() {
return LTrigger(0.5);
}
/**
* Constructs a Trigger instance around the axis value of the R 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.
* @param loop the event loop instance to attach the Trigger to.
* @return a Trigger instance that is true when the R Trigger axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger RTrigger(double threshold, EventLoop loop) {
return axisGreaterThan(
GameCubeController.Axis.R_TRIGGER, threshold, loop);
}
/**
* Constructs a Trigger instance around the axis value of the R 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.
* @return a Trigger instance that is true when the R Trigger axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger RTrigger(double threshold) {
return RTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the R Trigger. The returned
* trigger will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the R Trigger axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger RTrigger() {
return RTrigger(0.5);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(GameCubeController.Axis axis, double threshold) {
return m_hid.axisLessThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the trigger to
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(
GameCubeController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisLessThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(GameCubeController.Axis axis, double threshold) {
return m_hid.axisGreaterThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(
GameCubeController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is greater than the
* provided threshold.
*/
public Trigger axisMagnitudeGreaterThan(
GameCubeController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command
* scheduler button loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
*/
public Trigger axisMagnitudeGreaterThan(GameCubeController.Axis axis, double threshold) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
}
/**
* Get the value of the axis.
*
* @param axis The axis to read
* @return The value of the axis.
*/
public double getAxis(GameCubeController.Axis axis) {
return m_hid.getRawAxis(axis.value);
}
/**
* Get the Left X value of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return m_controller.getLeftX();
}
/**
* Get the Left Y value of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return m_controller.getLeftY();
}
/**
* Get the C Stick X value of the controller.
*
* @return The axis value.
*/
public double getCStickX() {
return m_controller.getCStickX();
}
/**
* Get the C Stick Y value of the controller.
*
* @return The axis value.
*/
public double getCStickY() {
return m_controller.getCStickY();
}
/**
* Get the L Trigger value of the controller.
*
* @return The axis value.
*/
public double getLTrigger() {
return m_controller.getLTrigger();
}
/**
* Get the R Trigger value of the controller.
*
* @return The axis value.
*/
public double getRTrigger() {
return m_controller.getRTrigger();
}
}

View File

@@ -0,0 +1,652 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
package org.wpilib.command2.button;
import java.util.Objects;
import org.wpilib.command2.CommandScheduler;
import org.wpilib.driverstation.LogitechF310Controller;
import org.wpilib.event.EventLoop;
/**
* A version of {@link LogitechF310Controller} with {@link Trigger} factories for command-based.
*
* @see LogitechF310Controller
*/
@SuppressWarnings("MethodName")
public class CommandLogitechF310Controller {
private final CommandGenericHID m_hid;
private final LogitechF310Controller m_controller;
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandLogitechF310Controller(int port) {
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new LogitechF310Controller(m_hid.getHID());
}
/**
* Construct an instance of a controller with a LogitechF310Controller object.
*
* @param controller The LogitechF310Controller object to use for this controller.
*/
public CommandLogitechF310Controller(LogitechF310Controller controller) {
m_controller =
Objects.requireNonNull(controller, "Provided LogitechF310Controller cannot be null");
m_hid = new CommandGenericHID(m_controller.getHID());
}
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
public LogitechF310Controller getController() {
return m_controller;
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @return an event instance representing the button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #button(LogitechF310Controller.Button, EventLoop)
*/
public Trigger button(LogitechF310Controller.Button button) {
return button(button, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the button's digital signal attached to the given loop.
*/
public Trigger button(LogitechF310Controller.Button button, EventLoop loop) {
return m_hid.button(button.value, loop);
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @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() {
return a(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the A button's digital signal attached
* to the given loop.
*/
public Trigger a(EventLoop loop) {
return button(LogitechF310Controller.Button.A, loop);
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @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() {
return b(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the B button's digital signal attached
* to the given loop.
*/
public Trigger b(EventLoop loop) {
return button(LogitechF310Controller.Button.B, loop);
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @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() {
return x(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the X button's digital signal attached
* to the given loop.
*/
public Trigger x(EventLoop loop) {
return button(LogitechF310Controller.Button.X, loop);
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @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() {
return y(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Y button's digital signal attached
* to the given loop.
*/
public Trigger y(EventLoop loop) {
return button(LogitechF310Controller.Button.Y, loop);
}
/**
* 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() {
return back(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Back button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Back button's digital signal attached
* to the given loop.
*/
public Trigger back(EventLoop loop) {
return button(LogitechF310Controller.Button.BACK, loop);
}
/**
* Constructs a Trigger instance around the Logitech button's digital signal.
*
* @return a Trigger instance representing the Logitech button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #logitech(EventLoop)
*/
public Trigger logitech() {
return logitech(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Logitech button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Logitech button's digital signal attached
* to the given loop.
*/
public Trigger logitech(EventLoop loop) {
return button(LogitechF310Controller.Button.LOGITECH, loop);
}
/**
* 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 button(LogitechF310Controller.Button.START, loop);
}
/**
* 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 button(LogitechF310Controller.Button.LEFT_STICK, loop);
}
/**
* 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 button(LogitechF310Controller.Button.RIGHT_STICK, loop);
}
/**
* Constructs a Trigger instance around the Left Bumper button's digital signal.
*
* @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 button(LogitechF310Controller.Button.LEFT_BUMPER, loop);
}
/**
* 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 button(LogitechF310Controller.Button.RIGHT_BUMPER, loop);
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadUp(EventLoop)
*/
public Trigger dpadUp() {
return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the given loop.
*/
public Trigger dpadUp(EventLoop loop) {
return button(LogitechF310Controller.Button.DPAD_UP, loop);
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadDown(EventLoop)
*/
public Trigger dpadDown() {
return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the given loop.
*/
public Trigger dpadDown(EventLoop loop) {
return button(LogitechF310Controller.Button.DPAD_DOWN, loop);
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadLeft(EventLoop)
*/
public Trigger dpadLeft() {
return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the given loop.
*/
public Trigger dpadLeft(EventLoop loop) {
return button(LogitechF310Controller.Button.DPAD_LEFT, loop);
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadRight(EventLoop)
*/
public Trigger dpadRight() {
return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the given loop.
*/
public Trigger dpadRight(EventLoop loop) {
return button(LogitechF310Controller.Button.DPAD_RIGHT, loop);
}
/**
* 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.
* @param loop the event loop instance to attach the Trigger to.
* @return a Trigger instance that is true when the Left Trigger axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger leftTrigger(double threshold, EventLoop loop) {
return axisGreaterThan(
LogitechF310Controller.Axis.LEFT_TRIGGER, threshold, loop);
}
/**
* 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.
* @return a Trigger instance that is true when the Left Trigger axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger leftTrigger(double threshold) {
return leftTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 0.5.
*
* @return a Trigger instance that is true when the Left Trigger axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger leftTrigger() {
return leftTrigger(0.5);
}
/**
* 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.
* @param loop the event loop instance to attach the Trigger to.
* @return a Trigger instance that is true when the Right Trigger axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger rightTrigger(double threshold, EventLoop loop) {
return axisGreaterThan(
LogitechF310Controller.Axis.RIGHT_TRIGGER, threshold, loop);
}
/**
* 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.
* @return a Trigger instance that is true when the Right Trigger axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger rightTrigger(double threshold) {
return rightTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 0.5.
*
* @return a Trigger instance that is true when the Right Trigger axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger rightTrigger() {
return rightTrigger(0.5);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(LogitechF310Controller.Axis axis, double threshold) {
return m_hid.axisLessThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the trigger to
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(
LogitechF310Controller.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisLessThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(LogitechF310Controller.Axis axis, double threshold) {
return m_hid.axisGreaterThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(
LogitechF310Controller.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is greater than the
* provided threshold.
*/
public Trigger axisMagnitudeGreaterThan(
LogitechF310Controller.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command
* scheduler button loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
*/
public Trigger axisMagnitudeGreaterThan(LogitechF310Controller.Axis axis, double threshold) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
}
/**
* Get the value of the axis.
*
* @param axis The axis to read
* @return The value of the axis.
*/
public double getAxis(LogitechF310Controller.Axis axis) {
return m_hid.getRawAxis(axis.value);
}
/**
* Get the Left X value of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return m_controller.getLeftX();
}
/**
* Get the Left Y value of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return m_controller.getLeftY();
}
/**
* Get the Right X value of the controller.
*
* @return The axis value.
*/
public double getRightX() {
return m_controller.getRightX();
}
/**
* Get the Right Y value of the controller.
*
* @return The axis value.
*/
public double getRightY() {
return m_controller.getRightY();
}
/**
* Get the Left Trigger value of the controller.
*
* @return The axis value.
*/
public double getLeftTrigger() {
return m_controller.getLeftTrigger();
}
/**
* Get the Right Trigger value of the controller.
*
* @return The axis value.
*/
public double getRightTrigger() {
return m_controller.getRightTrigger();
}
}

View File

@@ -16,8 +16,9 @@ import org.wpilib.event.EventLoop;
* @see NiDsPS4Controller
*/
@SuppressWarnings("MethodName")
public class CommandNiDsPS4Controller extends CommandGenericHID {
private final NiDsPS4Controller m_hid;
public class CommandNiDsPS4Controller {
private final CommandGenericHID m_hid;
private final NiDsPS4Controller m_controller;
/**
* Construct an instance of a controller.
@@ -25,20 +26,28 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandNiDsPS4Controller(int port) {
super(port);
m_hid = new NiDsPS4Controller(port);
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new NiDsPS4Controller(m_hid.getHID());
}
/**
* Get the underlying GenericHID object.
* Get the underlying CommandGenericHID object.
*
* @return the wrapped GenericHID object
* @return the wrapped CommandGenericHID object
*/
@Override
public NiDsPS4Controller getHID() {
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the underlying NiDsPS4Controller object.
*
* @return the wrapped NiDsPS4Controller object
*/
public NiDsPS4Controller getNiDsPS4Controller() {
return m_controller;
}
/**
* Constructs a Trigger instance around the square button's digital signal.
*
@@ -58,7 +67,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger square(EventLoop loop) {
return button(NiDsPS4Controller.Button.kSquare.value, loop);
return m_hid.button(NiDsPS4Controller.Button.kSquare.value, loop);
}
/**
@@ -80,7 +89,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger cross(EventLoop loop) {
return button(NiDsPS4Controller.Button.kCross.value, loop);
return m_hid.button(NiDsPS4Controller.Button.kCross.value, loop);
}
/**
@@ -102,7 +111,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger circle(EventLoop loop) {
return button(NiDsPS4Controller.Button.kCircle.value, loop);
return m_hid.button(NiDsPS4Controller.Button.kCircle.value, loop);
}
/**
@@ -124,7 +133,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger triangle(EventLoop loop) {
return button(NiDsPS4Controller.Button.kTriangle.value, loop);
return m_hid.button(NiDsPS4Controller.Button.kTriangle.value, loop);
}
/**
@@ -146,7 +155,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger L1(EventLoop loop) {
return button(NiDsPS4Controller.Button.kL1.value, loop);
return m_hid.button(NiDsPS4Controller.Button.kL1.value, loop);
}
/**
@@ -168,7 +177,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger R1(EventLoop loop) {
return button(NiDsPS4Controller.Button.kR1.value, loop);
return m_hid.button(NiDsPS4Controller.Button.kR1.value, loop);
}
/**
@@ -190,7 +199,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger L2(EventLoop loop) {
return button(NiDsPS4Controller.Button.kL2.value, loop);
return m_hid.button(NiDsPS4Controller.Button.kL2.value, loop);
}
/**
@@ -212,7 +221,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger R2(EventLoop loop) {
return button(NiDsPS4Controller.Button.kR2.value, loop);
return m_hid.button(NiDsPS4Controller.Button.kR2.value, loop);
}
/**
@@ -234,7 +243,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger share(EventLoop loop) {
return button(NiDsPS4Controller.Button.kShare.value, loop);
return m_hid.button(NiDsPS4Controller.Button.kShare.value, loop);
}
/**
@@ -256,7 +265,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger options(EventLoop loop) {
return button(NiDsPS4Controller.Button.kOptions.value, loop);
return m_hid.button(NiDsPS4Controller.Button.kOptions.value, loop);
}
/**
@@ -278,7 +287,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger L3(EventLoop loop) {
return button(NiDsPS4Controller.Button.kL3.value, loop);
return m_hid.button(NiDsPS4Controller.Button.kL3.value, loop);
}
/**
@@ -300,7 +309,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger R3(EventLoop loop) {
return button(NiDsPS4Controller.Button.kR3.value, loop);
return m_hid.button(NiDsPS4Controller.Button.kR3.value, loop);
}
/**
@@ -322,7 +331,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger PS(EventLoop loop) {
return button(NiDsPS4Controller.Button.kPS.value, loop);
return m_hid.button(NiDsPS4Controller.Button.kPS.value, loop);
}
/**
@@ -344,7 +353,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger touchpad(EventLoop loop) {
return button(NiDsPS4Controller.Button.kTouchpad.value, loop);
return m_hid.button(NiDsPS4Controller.Button.kTouchpad.value, loop);
}
/**
@@ -353,7 +362,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* @return The axis value.
*/
public double getLeftX() {
return m_hid.getLeftX();
return m_controller.getLeftX();
}
/**
@@ -362,7 +371,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* @return The axis value.
*/
public double getLeftY() {
return m_hid.getLeftY();
return m_controller.getLeftY();
}
/**
@@ -371,7 +380,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* @return The axis value.
*/
public double getRightX() {
return m_hid.getRightX();
return m_controller.getRightX();
}
/**
@@ -380,7 +389,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* @return The axis value.
*/
public double getRightY() {
return m_hid.getRightY();
return m_controller.getRightY();
}
/**
@@ -390,7 +399,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* @return The axis value.
*/
public double getL2Axis() {
return m_hid.getL2Axis();
return m_controller.getL2Axis();
}
/**
@@ -400,6 +409,6 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
* @return The axis value.
*/
public double getR2Axis() {
return m_hid.getR2Axis();
return m_controller.getR2Axis();
}
}

View File

@@ -16,8 +16,9 @@ import org.wpilib.event.EventLoop;
* @see NiDsPS5Controller
*/
@SuppressWarnings("MethodName")
public class CommandNiDsPS5Controller extends CommandGenericHID {
private final NiDsPS5Controller m_hid;
public class CommandNiDsPS5Controller {
private final CommandGenericHID m_hid;
private final NiDsPS5Controller m_controller;
/**
* Construct an instance of a controller.
@@ -25,20 +26,28 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandNiDsPS5Controller(int port) {
super(port);
m_hid = new NiDsPS5Controller(port);
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new NiDsPS5Controller(m_hid.getHID());
}
/**
* Get the underlying GenericHID object.
* Get the underlying CommandGenericHID object.
*
* @return the wrapped GenericHID object
* @return the wrapped CommandGenericHID object
*/
@Override
public NiDsPS5Controller getHID() {
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the underlying NiDsPS5Controller object.
*
* @return the wrapped NiDsPS5Controller object
*/
public NiDsPS5Controller getNiDsPS5Controller() {
return m_controller;
}
/**
* Constructs a Trigger instance around the square button's digital signal.
*
@@ -58,7 +67,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger square(EventLoop loop) {
return button(NiDsPS5Controller.Button.kSquare.value, loop);
return m_hid.button(NiDsPS5Controller.Button.kSquare.value, loop);
}
/**
@@ -80,7 +89,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger cross(EventLoop loop) {
return button(NiDsPS5Controller.Button.kCross.value, loop);
return m_hid.button(NiDsPS5Controller.Button.kCross.value, loop);
}
/**
@@ -102,7 +111,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger circle(EventLoop loop) {
return button(NiDsPS5Controller.Button.kCircle.value, loop);
return m_hid.button(NiDsPS5Controller.Button.kCircle.value, loop);
}
/**
@@ -124,7 +133,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger triangle(EventLoop loop) {
return button(NiDsPS5Controller.Button.kTriangle.value, loop);
return m_hid.button(NiDsPS5Controller.Button.kTriangle.value, loop);
}
/**
@@ -146,7 +155,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger L1(EventLoop loop) {
return button(NiDsPS5Controller.Button.kL1.value, loop);
return m_hid.button(NiDsPS5Controller.Button.kL1.value, loop);
}
/**
@@ -168,7 +177,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger R1(EventLoop loop) {
return button(NiDsPS5Controller.Button.kR1.value, loop);
return m_hid.button(NiDsPS5Controller.Button.kR1.value, loop);
}
/**
@@ -190,7 +199,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger L2(EventLoop loop) {
return button(NiDsPS5Controller.Button.kL2.value, loop);
return m_hid.button(NiDsPS5Controller.Button.kL2.value, loop);
}
/**
@@ -212,7 +221,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger R2(EventLoop loop) {
return button(NiDsPS5Controller.Button.kR2.value, loop);
return m_hid.button(NiDsPS5Controller.Button.kR2.value, loop);
}
/**
@@ -234,7 +243,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger create(EventLoop loop) {
return button(NiDsPS5Controller.Button.kCreate.value, loop);
return m_hid.button(NiDsPS5Controller.Button.kCreate.value, loop);
}
/**
@@ -256,7 +265,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger options(EventLoop loop) {
return button(NiDsPS5Controller.Button.kOptions.value, loop);
return m_hid.button(NiDsPS5Controller.Button.kOptions.value, loop);
}
/**
@@ -278,7 +287,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger L3(EventLoop loop) {
return button(NiDsPS5Controller.Button.kL3.value, loop);
return m_hid.button(NiDsPS5Controller.Button.kL3.value, loop);
}
/**
@@ -300,7 +309,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger R3(EventLoop loop) {
return button(NiDsPS5Controller.Button.kR3.value, loop);
return m_hid.button(NiDsPS5Controller.Button.kR3.value, loop);
}
/**
@@ -322,7 +331,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger PS(EventLoop loop) {
return button(NiDsPS5Controller.Button.kPS.value, loop);
return m_hid.button(NiDsPS5Controller.Button.kPS.value, loop);
}
/**
@@ -344,7 +353,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* to the given loop.
*/
public Trigger touchpad(EventLoop loop) {
return button(NiDsPS5Controller.Button.kTouchpad.value, loop);
return m_hid.button(NiDsPS5Controller.Button.kTouchpad.value, loop);
}
/**
@@ -353,7 +362,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* @return The axis value.
*/
public double getLeftX() {
return m_hid.getLeftX();
return m_controller.getLeftX();
}
/**
@@ -362,7 +371,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* @return The axis value.
*/
public double getLeftY() {
return m_hid.getLeftY();
return m_controller.getLeftY();
}
/**
@@ -371,7 +380,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* @return The axis value.
*/
public double getRightX() {
return m_hid.getRightX();
return m_controller.getRightX();
}
/**
@@ -380,7 +389,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* @return The axis value.
*/
public double getRightY() {
return m_hid.getRightY();
return m_controller.getRightY();
}
/**
@@ -390,7 +399,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* @return The axis value.
*/
public double getL2Axis() {
return m_hid.getL2Axis();
return m_controller.getL2Axis();
}
/**
@@ -400,6 +409,6 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
* @return The axis value.
*/
public double getR2Axis() {
return m_hid.getR2Axis();
return m_controller.getR2Axis();
}
}

View File

@@ -16,8 +16,9 @@ import org.wpilib.event.EventLoop;
* @see NiDsStadiaController
*/
@SuppressWarnings("MethodName")
public class CommandNiDsStadiaController extends CommandGenericHID {
private final NiDsStadiaController m_hid;
public class CommandNiDsStadiaController {
private final CommandGenericHID m_hid;
private final NiDsStadiaController m_controller;
/**
* Construct an instance of a controller.
@@ -25,20 +26,28 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandNiDsStadiaController(int port) {
super(port);
m_hid = new NiDsStadiaController(port);
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new NiDsStadiaController(m_hid.getHID());
}
/**
* Get the underlying GenericHID object.
* Get the underlying CommandGenericHID object.
*
* @return the wrapped GenericHID object
* @return the wrapped CommandGenericHID object
*/
@Override
public NiDsStadiaController getHID() {
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the underlying NiDsStadiaController object.
*
* @return the wrapped NiDsStadiaController object
*/
public NiDsStadiaController getNiDsStadiaController() {
return m_controller;
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
@@ -58,7 +67,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* to the given loop.
*/
public Trigger a(EventLoop loop) {
return button(NiDsStadiaController.Button.kA.value, loop);
return m_hid.button(NiDsStadiaController.Button.kA.value, loop);
}
/**
@@ -80,7 +89,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* to the given loop.
*/
public Trigger b(EventLoop loop) {
return button(NiDsStadiaController.Button.kB.value, loop);
return m_hid.button(NiDsStadiaController.Button.kB.value, loop);
}
/**
@@ -102,7 +111,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* to the given loop.
*/
public Trigger x(EventLoop loop) {
return button(NiDsStadiaController.Button.kX.value, loop);
return m_hid.button(NiDsStadiaController.Button.kX.value, loop);
}
/**
@@ -124,7 +133,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* to the given loop.
*/
public Trigger y(EventLoop loop) {
return button(NiDsStadiaController.Button.kY.value, loop);
return m_hid.button(NiDsStadiaController.Button.kY.value, loop);
}
/**
@@ -146,7 +155,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* to the given loop.
*/
public Trigger leftBumper(EventLoop loop) {
return button(NiDsStadiaController.Button.kLeftBumper.value, loop);
return m_hid.button(NiDsStadiaController.Button.kLeftBumper.value, loop);
}
/**
@@ -168,7 +177,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* to the given loop.
*/
public Trigger rightBumper(EventLoop loop) {
return button(NiDsStadiaController.Button.kRightBumper.value, loop);
return m_hid.button(NiDsStadiaController.Button.kRightBumper.value, loop);
}
/**
@@ -190,7 +199,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* to the given loop.
*/
public Trigger leftStick(EventLoop loop) {
return button(NiDsStadiaController.Button.kLeftStick.value, loop);
return m_hid.button(NiDsStadiaController.Button.kLeftStick.value, loop);
}
/**
@@ -212,7 +221,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* to the given loop.
*/
public Trigger rightStick(EventLoop loop) {
return button(NiDsStadiaController.Button.kRightStick.value, loop);
return m_hid.button(NiDsStadiaController.Button.kRightStick.value, loop);
}
/**
@@ -234,7 +243,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* to the given loop.
*/
public Trigger ellipses(EventLoop loop) {
return button(NiDsStadiaController.Button.kEllipses.value, loop);
return m_hid.button(NiDsStadiaController.Button.kEllipses.value, loop);
}
/**
@@ -256,7 +265,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* to the given loop.
*/
public Trigger hamburger(EventLoop loop) {
return button(NiDsStadiaController.Button.kHamburger.value, loop);
return m_hid.button(NiDsStadiaController.Button.kHamburger.value, loop);
}
/**
@@ -278,7 +287,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* to the given loop.
*/
public Trigger stadia(EventLoop loop) {
return button(NiDsStadiaController.Button.kStadia.value, loop);
return m_hid.button(NiDsStadiaController.Button.kStadia.value, loop);
}
/**
@@ -300,7 +309,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* to the given loop.
*/
public Trigger rightTrigger(EventLoop loop) {
return button(NiDsStadiaController.Button.kRightTrigger.value, loop);
return m_hid.button(NiDsStadiaController.Button.kRightTrigger.value, loop);
}
/**
@@ -322,7 +331,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* to the given loop.
*/
public Trigger leftTrigger(EventLoop loop) {
return button(NiDsStadiaController.Button.kLeftTrigger.value, loop);
return m_hid.button(NiDsStadiaController.Button.kLeftTrigger.value, loop);
}
/**
@@ -344,7 +353,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* to the given loop.
*/
public Trigger google(EventLoop loop) {
return button(NiDsStadiaController.Button.kGoogle.value, loop);
return m_hid.button(NiDsStadiaController.Button.kGoogle.value, loop);
}
/**
@@ -366,7 +375,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* to the given loop.
*/
public Trigger frame(EventLoop loop) {
return button(NiDsStadiaController.Button.kFrame.value, loop);
return m_hid.button(NiDsStadiaController.Button.kFrame.value, loop);
}
/**
@@ -375,7 +384,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* @return The axis value.
*/
public double getLeftX() {
return m_hid.getLeftX();
return m_controller.getLeftX();
}
/**
@@ -384,7 +393,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* @return The axis value.
*/
public double getRightX() {
return m_hid.getRightX();
return m_controller.getRightX();
}
/**
@@ -393,7 +402,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* @return The axis value.
*/
public double getLeftY() {
return m_hid.getLeftY();
return m_controller.getLeftY();
}
/**
@@ -402,6 +411,6 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
* @return The axis value.
*/
public double getRightY() {
return m_hid.getRightY();
return m_controller.getRightY();
}
}

View File

@@ -16,8 +16,9 @@ import org.wpilib.event.EventLoop;
* @see NiDsXboxController
*/
@SuppressWarnings("MethodName")
public class CommandNiDsXboxController extends CommandGenericHID {
private final NiDsXboxController m_hid;
public class CommandNiDsXboxController {
private final CommandGenericHID m_hid;
private final NiDsXboxController m_controller;
/**
* Construct an instance of a controller.
@@ -25,20 +26,28 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandNiDsXboxController(int port) {
super(port);
m_hid = new NiDsXboxController(port);
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new NiDsXboxController(m_hid.getHID());
}
/**
* Get the underlying GenericHID object.
* Get the underlying CommandGenericHID object.
*
* @return the wrapped GenericHID object
* @return the wrapped CommandGenericHID object
*/
@Override
public NiDsXboxController getHID() {
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the underlying NiDsXboxController object.
*
* @return the wrapped NiDsXboxController object
*/
public NiDsXboxController getNiDsXboxController() {
return m_controller;
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
@@ -58,7 +67,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* to the given loop.
*/
public Trigger a(EventLoop loop) {
return button(NiDsXboxController.Button.kA.value, loop);
return m_hid.button(NiDsXboxController.Button.kA.value, loop);
}
/**
@@ -80,7 +89,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* to the given loop.
*/
public Trigger b(EventLoop loop) {
return button(NiDsXboxController.Button.kB.value, loop);
return m_hid.button(NiDsXboxController.Button.kB.value, loop);
}
/**
@@ -102,7 +111,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* to the given loop.
*/
public Trigger x(EventLoop loop) {
return button(NiDsXboxController.Button.kX.value, loop);
return m_hid.button(NiDsXboxController.Button.kX.value, loop);
}
/**
@@ -124,7 +133,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* to the given loop.
*/
public Trigger y(EventLoop loop) {
return button(NiDsXboxController.Button.kY.value, loop);
return m_hid.button(NiDsXboxController.Button.kY.value, loop);
}
/**
@@ -146,7 +155,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* to the given loop.
*/
public Trigger leftBumper(EventLoop loop) {
return button(NiDsXboxController.Button.kLeftBumper.value, loop);
return m_hid.button(NiDsXboxController.Button.kLeftBumper.value, loop);
}
/**
@@ -168,7 +177,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* to the given loop.
*/
public Trigger rightBumper(EventLoop loop) {
return button(NiDsXboxController.Button.kRightBumper.value, loop);
return m_hid.button(NiDsXboxController.Button.kRightBumper.value, loop);
}
/**
@@ -190,7 +199,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* to the given loop.
*/
public Trigger back(EventLoop loop) {
return button(NiDsXboxController.Button.kBack.value, loop);
return m_hid.button(NiDsXboxController.Button.kBack.value, loop);
}
/**
@@ -212,7 +221,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* to the given loop.
*/
public Trigger start(EventLoop loop) {
return button(NiDsXboxController.Button.kStart.value, loop);
return m_hid.button(NiDsXboxController.Button.kStart.value, loop);
}
/**
@@ -234,7 +243,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* to the given loop.
*/
public Trigger leftStick(EventLoop loop) {
return button(NiDsXboxController.Button.kLeftStick.value, loop);
return m_hid.button(NiDsXboxController.Button.kLeftStick.value, loop);
}
/**
@@ -256,7 +265,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* to the given loop.
*/
public Trigger rightStick(EventLoop loop) {
return button(NiDsXboxController.Button.kRightStick.value, loop);
return m_hid.button(NiDsXboxController.Button.kRightStick.value, loop);
}
/**
@@ -270,7 +279,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* threshold, attached to the given event loop
*/
public Trigger leftTrigger(double threshold, EventLoop loop) {
return axisGreaterThan(NiDsXboxController.Axis.kLeftTrigger.value, threshold, loop);
return m_hid.axisGreaterThan(NiDsXboxController.Axis.kLeftTrigger.value, threshold, loop);
}
/**
@@ -309,7 +318,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* threshold, attached to the given event loop
*/
public Trigger rightTrigger(double threshold, EventLoop loop) {
return axisGreaterThan(NiDsXboxController.Axis.kRightTrigger.value, threshold, loop);
return m_hid.axisGreaterThan(NiDsXboxController.Axis.kRightTrigger.value, threshold, loop);
}
/**
@@ -343,7 +352,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* @return The axis value.
*/
public double getLeftX() {
return m_hid.getLeftX();
return m_controller.getLeftX();
}
/**
@@ -352,7 +361,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* @return The axis value.
*/
public double getRightX() {
return m_hid.getRightX();
return m_controller.getRightX();
}
/**
@@ -361,7 +370,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* @return The axis value.
*/
public double getLeftY() {
return m_hid.getLeftY();
return m_controller.getLeftY();
}
/**
@@ -370,7 +379,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* @return The axis value.
*/
public double getRightY() {
return m_hid.getRightY();
return m_controller.getRightY();
}
/**
@@ -380,7 +389,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* @return The axis value.
*/
public double getLeftTriggerAxis() {
return m_hid.getLeftTriggerAxis();
return m_controller.getLeftTriggerAxis();
}
/**
@@ -390,6 +399,6 @@ public class CommandNiDsXboxController extends CommandGenericHID {
* @return The axis value.
*/
public double getRightTriggerAxis() {
return m_hid.getRightTriggerAxis();
return m_controller.getRightTriggerAxis();
}
}

View File

@@ -0,0 +1,894 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
package org.wpilib.command2.button;
import java.util.Objects;
import org.wpilib.command2.CommandScheduler;
import org.wpilib.driverstation.SteamController;
import org.wpilib.event.EventLoop;
/**
* A version of {@link SteamController} with {@link Trigger} factories for command-based.
*
* @see SteamController
*/
@SuppressWarnings("MethodName")
public class CommandSteamController {
private final CommandGenericHID m_hid;
private final SteamController m_controller;
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandSteamController(int port) {
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new SteamController(m_hid.getHID());
}
/**
* Construct an instance of a controller with a SteamController object.
*
* @param controller The SteamController object to use for this controller.
*/
public CommandSteamController(SteamController controller) {
m_controller =
Objects.requireNonNull(controller, "Provided SteamController cannot be null");
m_hid = new CommandGenericHID(m_controller.getHID());
}
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
public SteamController getController() {
return m_controller;
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @return an event instance representing the button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #button(SteamController.Button, EventLoop)
*/
public Trigger button(SteamController.Button button) {
return button(button, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the button's digital signal attached to the given loop.
*/
public Trigger button(SteamController.Button button, EventLoop loop) {
return m_hid.button(button.value, loop);
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @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() {
return a(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the A button's digital signal attached
* to the given loop.
*/
public Trigger a(EventLoop loop) {
return button(SteamController.Button.A, loop);
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @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() {
return b(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the B button's digital signal attached
* to the given loop.
*/
public Trigger b(EventLoop loop) {
return button(SteamController.Button.B, loop);
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @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() {
return x(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the X button's digital signal attached
* to the given loop.
*/
public Trigger x(EventLoop loop) {
return button(SteamController.Button.X, loop);
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @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() {
return y(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Y button's digital signal attached
* to the given loop.
*/
public Trigger y(EventLoop loop) {
return button(SteamController.Button.Y, loop);
}
/**
* Constructs a Trigger instance around the Menu button's digital signal.
*
* @return a Trigger instance representing the Menu button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #menu(EventLoop)
*/
public Trigger menu() {
return menu(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Menu button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Menu button's digital signal attached
* to the given loop.
*/
public Trigger menu(EventLoop loop) {
return button(SteamController.Button.MENU, loop);
}
/**
* Constructs a Trigger instance around the Steam button's digital signal.
*
* @return a Trigger instance representing the Steam button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #steam(EventLoop)
*/
public Trigger steam() {
return steam(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Steam button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Steam button's digital signal attached
* to the given loop.
*/
public Trigger steam(EventLoop loop) {
return button(SteamController.Button.STEAM, loop);
}
/**
* Constructs a Trigger instance around the View button's digital signal.
*
* @return a Trigger instance representing the View button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #view(EventLoop)
*/
public Trigger view() {
return view(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the View button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the View button's digital signal attached
* to the given loop.
*/
public Trigger view(EventLoop loop) {
return button(SteamController.Button.VIEW, loop);
}
/**
* 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 button(SteamController.Button.LEFT_STICK, loop);
}
/**
* 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 button(SteamController.Button.RIGHT_STICK, loop);
}
/**
* Constructs a Trigger instance around the Left Bumper button's digital signal.
*
* @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 button(SteamController.Button.LEFT_BUMPER, loop);
}
/**
* 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 button(SteamController.Button.RIGHT_BUMPER, loop);
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadUp(EventLoop)
*/
public Trigger dpadUp() {
return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the given loop.
*/
public Trigger dpadUp(EventLoop loop) {
return button(SteamController.Button.DPAD_UP, loop);
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadDown(EventLoop)
*/
public Trigger dpadDown() {
return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the given loop.
*/
public Trigger dpadDown(EventLoop loop) {
return button(SteamController.Button.DPAD_DOWN, loop);
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadLeft(EventLoop)
*/
public Trigger dpadLeft() {
return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the given loop.
*/
public Trigger dpadLeft(EventLoop loop) {
return button(SteamController.Button.DPAD_LEFT, loop);
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadRight(EventLoop)
*/
public Trigger dpadRight() {
return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the given loop.
*/
public Trigger dpadRight(EventLoop loop) {
return button(SteamController.Button.DPAD_RIGHT, loop);
}
/**
* Constructs a Trigger instance around the QAM button's digital signal.
*
* @return a Trigger instance representing the QAM button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #QAM(EventLoop)
*/
public Trigger QAM() {
return QAM(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the QAM button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the QAM button's digital signal attached
* to the given loop.
*/
public Trigger QAM(EventLoop loop) {
return button(SteamController.Button.QAM, loop);
}
/**
* Constructs a Trigger instance around the Right Paddle 1 button's digital signal.
*
* @return a Trigger instance representing the Right Paddle 1 button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #rightPaddle1(EventLoop)
*/
public Trigger rightPaddle1() {
return rightPaddle1(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Right Paddle 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Right Paddle 1 button's digital signal attached
* to the given loop.
*/
public Trigger rightPaddle1(EventLoop loop) {
return button(SteamController.Button.RIGHT_PADDLE_1, loop);
}
/**
* Constructs a Trigger instance around the Left Paddle 1 button's digital signal.
*
* @return a Trigger instance representing the Left Paddle 1 button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #leftPaddle1(EventLoop)
*/
public Trigger leftPaddle1() {
return leftPaddle1(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Left Paddle 1 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Left Paddle 1 button's digital signal attached
* to the given loop.
*/
public Trigger leftPaddle1(EventLoop loop) {
return button(SteamController.Button.LEFT_PADDLE_1, loop);
}
/**
* Constructs a Trigger instance around the Right Paddle 2 button's digital signal.
*
* @return a Trigger instance representing the Right Paddle 2 button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #rightPaddle2(EventLoop)
*/
public Trigger rightPaddle2() {
return rightPaddle2(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Right Paddle 2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Right Paddle 2 button's digital signal attached
* to the given loop.
*/
public Trigger rightPaddle2(EventLoop loop) {
return button(SteamController.Button.RIGHT_PADDLE_2, loop);
}
/**
* Constructs a Trigger instance around the Left Paddle 2 button's digital signal.
*
* @return a Trigger instance representing the Left Paddle 2 button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #leftPaddle2(EventLoop)
*/
public Trigger leftPaddle2() {
return leftPaddle2(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Left Paddle 2 button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Left Paddle 2 button's digital signal attached
* to the given loop.
*/
public Trigger leftPaddle2(EventLoop loop) {
return button(SteamController.Button.LEFT_PADDLE_2, loop);
}
/**
* Constructs a Trigger instance around the Left Touchpad button's digital signal.
*
* @return a Trigger instance representing the Left Touchpad button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #leftTouchpad(EventLoop)
*/
public Trigger leftTouchpad() {
return leftTouchpad(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Left Touchpad button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Left Touchpad button's digital signal attached
* to the given loop.
*/
public Trigger leftTouchpad(EventLoop loop) {
return button(SteamController.Button.LEFT_TOUCHPAD, loop);
}
/**
* Constructs a Trigger instance around the Right Touchpad button's digital signal.
*
* @return a Trigger instance representing the Right Touchpad button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #rightTouchpad(EventLoop)
*/
public Trigger rightTouchpad() {
return rightTouchpad(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Right Touchpad button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Right Touchpad button's digital signal attached
* to the given loop.
*/
public Trigger rightTouchpad(EventLoop loop) {
return button(SteamController.Button.RIGHT_TOUCHPAD, loop);
}
/**
* Constructs a Trigger instance around the Left Stick Touch button's digital signal.
*
* @return a Trigger instance representing the Left Stick Touch button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #leftStickTouch(EventLoop)
*/
public Trigger leftStickTouch() {
return leftStickTouch(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Left Stick Touch button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Left Stick Touch button's digital signal attached
* to the given loop.
*/
public Trigger leftStickTouch(EventLoop loop) {
return button(SteamController.Button.LEFT_STICK_TOUCH, loop);
}
/**
* Constructs a Trigger instance around the Right Stick Touch button's digital signal.
*
* @return a Trigger instance representing the Right Stick Touch button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #rightStickTouch(EventLoop)
*/
public Trigger rightStickTouch() {
return rightStickTouch(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Right Stick Touch button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Right Stick Touch button's digital signal attached
* to the given loop.
*/
public Trigger rightStickTouch(EventLoop loop) {
return button(SteamController.Button.RIGHT_STICK_TOUCH, loop);
}
/**
* Constructs a Trigger instance around the Left Grip Touch button's digital signal.
*
* @return a Trigger instance representing the Left Grip Touch button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #leftGripTouch(EventLoop)
*/
public Trigger leftGripTouch() {
return leftGripTouch(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Left Grip Touch button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Left Grip Touch button's digital signal attached
* to the given loop.
*/
public Trigger leftGripTouch(EventLoop loop) {
return button(SteamController.Button.LEFT_GRIP_TOUCH, loop);
}
/**
* Constructs a Trigger instance around the Right Grip Touch button's digital signal.
*
* @return a Trigger instance representing the Right Grip Touch button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #rightGripTouch(EventLoop)
*/
public Trigger rightGripTouch() {
return rightGripTouch(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Right Grip Touch button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Right Grip Touch button's digital signal attached
* to the given loop.
*/
public Trigger rightGripTouch(EventLoop loop) {
return button(SteamController.Button.RIGHT_GRIP_TOUCH, loop);
}
/**
* 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.
* @param loop the event loop instance to attach the Trigger to.
* @return a Trigger instance that is true when the Left Trigger axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger leftTrigger(double threshold, EventLoop loop) {
return axisGreaterThan(
SteamController.Axis.LEFT_TRIGGER, threshold, loop);
}
/**
* 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.
* @return a Trigger instance that is true when the Left Trigger axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger leftTrigger(double threshold) {
return leftTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 0.5.
*
* @return a Trigger instance that is true when the Left Trigger axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger leftTrigger() {
return leftTrigger(0.5);
}
/**
* 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.
* @param loop the event loop instance to attach the Trigger to.
* @return a Trigger instance that is true when the Right Trigger axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger rightTrigger(double threshold, EventLoop loop) {
return axisGreaterThan(
SteamController.Axis.RIGHT_TRIGGER, threshold, loop);
}
/**
* 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.
* @return a Trigger instance that is true when the Right Trigger axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger rightTrigger(double threshold) {
return rightTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 0.5.
*
* @return a Trigger instance that is true when the Right Trigger axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger rightTrigger() {
return rightTrigger(0.5);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(SteamController.Axis axis, double threshold) {
return m_hid.axisLessThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the trigger to
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(
SteamController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisLessThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(SteamController.Axis axis, double threshold) {
return m_hid.axisGreaterThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(
SteamController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is greater than the
* provided threshold.
*/
public Trigger axisMagnitudeGreaterThan(
SteamController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command
* scheduler button loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
*/
public Trigger axisMagnitudeGreaterThan(SteamController.Axis axis, double threshold) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
}
/**
* Get the value of the axis.
*
* @param axis The axis to read
* @return The value of the axis.
*/
public double getAxis(SteamController.Axis axis) {
return m_hid.getRawAxis(axis.value);
}
/**
* Get the Left X value of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return m_controller.getLeftX();
}
/**
* Get the Left Y value of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return m_controller.getLeftY();
}
/**
* Get the Right X value of the controller.
*
* @return The axis value.
*/
public double getRightX() {
return m_controller.getRightX();
}
/**
* Get the Right Y value of the controller.
*
* @return The axis value.
*/
public double getRightY() {
return m_controller.getRightY();
}
/**
* Get the Left Trigger value of the controller.
*
* @return The axis value.
*/
public double getLeftTrigger() {
return m_controller.getLeftTrigger();
}
/**
* Get the Right Trigger value of the controller.
*
* @return The axis value.
*/
public double getRightTrigger() {
return m_controller.getRightTrigger();
}
}

View File

@@ -0,0 +1,674 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
package org.wpilib.command2.button;
import java.util.Objects;
import org.wpilib.command2.CommandScheduler;
import org.wpilib.driverstation.Switch2GCController;
import org.wpilib.event.EventLoop;
/**
* A version of {@link Switch2GCController} with {@link Trigger} factories for command-based.
*
* @see Switch2GCController
*/
@SuppressWarnings("MethodName")
public class CommandSwitch2GCController {
private final CommandGenericHID m_hid;
private final Switch2GCController m_controller;
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandSwitch2GCController(int port) {
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new Switch2GCController(m_hid.getHID());
}
/**
* Construct an instance of a controller with a Switch2GCController object.
*
* @param controller The Switch2GCController object to use for this controller.
*/
public CommandSwitch2GCController(Switch2GCController controller) {
m_controller =
Objects.requireNonNull(controller, "Provided Switch2GCController cannot be null");
m_hid = new CommandGenericHID(m_controller.getHID());
}
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
public Switch2GCController getController() {
return m_controller;
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @return an event instance representing the button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #button(Switch2GCController.Button, EventLoop)
*/
public Trigger button(Switch2GCController.Button button) {
return button(button, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the button's digital signal attached to the given loop.
*/
public Trigger button(Switch2GCController.Button button, EventLoop loop) {
return m_hid.button(button.value, loop);
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @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() {
return a(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the A button's digital signal attached
* to the given loop.
*/
public Trigger a(EventLoop loop) {
return button(Switch2GCController.Button.A, loop);
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @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() {
return x(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the X button's digital signal attached
* to the given loop.
*/
public Trigger x(EventLoop loop) {
return button(Switch2GCController.Button.X, loop);
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @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() {
return b(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the B button's digital signal attached
* to the given loop.
*/
public Trigger b(EventLoop loop) {
return button(Switch2GCController.Button.B, loop);
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @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() {
return y(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Y button's digital signal attached
* to the given loop.
*/
public Trigger y(EventLoop loop) {
return button(Switch2GCController.Button.Y, loop);
}
/**
* Constructs a Trigger instance around the Home button's digital signal.
*
* @return a Trigger instance representing the Home button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #home(EventLoop)
*/
public Trigger home() {
return home(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Home button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Home button's digital signal attached
* to the given loop.
*/
public Trigger home(EventLoop loop) {
return button(Switch2GCController.Button.HOME, loop);
}
/**
* 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 button(Switch2GCController.Button.START, loop);
}
/**
* Constructs a Trigger instance around the ZL button's digital signal.
*
* @return a Trigger instance representing the ZL button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #ZL(EventLoop)
*/
public Trigger ZL() {
return ZL(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the ZL button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the ZL button's digital signal attached
* to the given loop.
*/
public Trigger ZL(EventLoop loop) {
return button(Switch2GCController.Button.ZL, loop);
}
/**
* Constructs a Trigger instance around the Z button's digital signal.
*
* @return a Trigger instance representing the Z button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #Z(EventLoop)
*/
public Trigger Z() {
return Z(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Z button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Z button's digital signal attached
* to the given loop.
*/
public Trigger Z(EventLoop loop) {
return button(Switch2GCController.Button.Z, loop);
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadUp(EventLoop)
*/
public Trigger dpadUp() {
return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the given loop.
*/
public Trigger dpadUp(EventLoop loop) {
return button(Switch2GCController.Button.DPAD_UP, loop);
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadDown(EventLoop)
*/
public Trigger dpadDown() {
return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the given loop.
*/
public Trigger dpadDown(EventLoop loop) {
return button(Switch2GCController.Button.DPAD_DOWN, loop);
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadLeft(EventLoop)
*/
public Trigger dpadLeft() {
return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the given loop.
*/
public Trigger dpadLeft(EventLoop loop) {
return button(Switch2GCController.Button.DPAD_LEFT, loop);
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadRight(EventLoop)
*/
public Trigger dpadRight() {
return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the given loop.
*/
public Trigger dpadRight(EventLoop loop) {
return button(Switch2GCController.Button.DPAD_RIGHT, loop);
}
/**
* Constructs a Trigger instance around the Capture button's digital signal.
*
* @return a Trigger instance representing the Capture button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #capture(EventLoop)
*/
public Trigger capture() {
return capture(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Capture button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Capture button's digital signal attached
* to the given loop.
*/
public Trigger capture(EventLoop loop) {
return button(Switch2GCController.Button.CAPTURE, loop);
}
/**
* Constructs a Trigger instance around the C button's digital signal.
*
* @return a Trigger instance representing the C button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #C(EventLoop)
*/
public Trigger C() {
return C(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the C button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the C button's digital signal attached
* to the given loop.
*/
public Trigger C(EventLoop loop) {
return button(Switch2GCController.Button.C, loop);
}
/**
* Constructs a Trigger instance around the L button's digital signal.
*
* @return a Trigger instance representing the L button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #L(EventLoop)
*/
public Trigger L() {
return L(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the L button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the L button's digital signal attached
* to the given loop.
*/
public Trigger L(EventLoop loop) {
return button(Switch2GCController.Button.L, loop);
}
/**
* Constructs a Trigger instance around the R button's digital signal.
*
* @return a Trigger instance representing the R button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #R(EventLoop)
*/
public Trigger R() {
return R(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the R button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the R button's digital signal attached
* to the given loop.
*/
public Trigger R(EventLoop loop) {
return button(Switch2GCController.Button.R, loop);
}
/**
* Constructs a Trigger instance around the axis value of the L 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.
* @param loop the event loop instance to attach the Trigger to.
* @return a Trigger instance that is true when the L Trigger axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger LTrigger(double threshold, EventLoop loop) {
return axisGreaterThan(
Switch2GCController.Axis.L_TRIGGER, threshold, loop);
}
/**
* Constructs a Trigger instance around the axis value of the L 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.
* @return a Trigger instance that is true when the L Trigger axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger LTrigger(double threshold) {
return LTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the L Trigger. The returned
* trigger will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the L Trigger axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger LTrigger() {
return LTrigger(0.5);
}
/**
* Constructs a Trigger instance around the axis value of the R 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.
* @param loop the event loop instance to attach the Trigger to.
* @return a Trigger instance that is true when the R Trigger axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger RTrigger(double threshold, EventLoop loop) {
return axisGreaterThan(
Switch2GCController.Axis.R_TRIGGER, threshold, loop);
}
/**
* Constructs a Trigger instance around the axis value of the R 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.
* @return a Trigger instance that is true when the R Trigger axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger RTrigger(double threshold) {
return RTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the R Trigger. The returned
* trigger will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the R Trigger axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger RTrigger() {
return RTrigger(0.5);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(Switch2GCController.Axis axis, double threshold) {
return m_hid.axisLessThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the trigger to
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(
Switch2GCController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisLessThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(Switch2GCController.Axis axis, double threshold) {
return m_hid.axisGreaterThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(
Switch2GCController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is greater than the
* provided threshold.
*/
public Trigger axisMagnitudeGreaterThan(
Switch2GCController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command
* scheduler button loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
*/
public Trigger axisMagnitudeGreaterThan(Switch2GCController.Axis axis, double threshold) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
}
/**
* Get the value of the axis.
*
* @param axis The axis to read
* @return The value of the axis.
*/
public double getAxis(Switch2GCController.Axis axis) {
return m_hid.getRawAxis(axis.value);
}
/**
* Get the Left X value of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return m_controller.getLeftX();
}
/**
* Get the Left Y value of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return m_controller.getLeftY();
}
/**
* Get the C Stick X value of the controller.
*
* @return The axis value.
*/
public double getCStickX() {
return m_controller.getCStickX();
}
/**
* Get the C Stick Y value of the controller.
*
* @return The axis value.
*/
public double getCStickY() {
return m_controller.getCStickY();
}
/**
* Get the L Trigger value of the controller.
*
* @return The axis value.
*/
public double getLTrigger() {
return m_controller.getLTrigger();
}
/**
* Get the R Trigger value of the controller.
*
* @return The axis value.
*/
public double getRTrigger() {
return m_controller.getRTrigger();
}
}

View File

@@ -0,0 +1,740 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
package org.wpilib.command2.button;
import java.util.Objects;
import org.wpilib.command2.CommandScheduler;
import org.wpilib.driverstation.Switch2ProController;
import org.wpilib.event.EventLoop;
/**
* A version of {@link Switch2ProController} with {@link Trigger} factories for command-based.
*
* @see Switch2ProController
*/
@SuppressWarnings("MethodName")
public class CommandSwitch2ProController {
private final CommandGenericHID m_hid;
private final Switch2ProController m_controller;
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandSwitch2ProController(int port) {
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new Switch2ProController(m_hid.getHID());
}
/**
* Construct an instance of a controller with a Switch2ProController object.
*
* @param controller The Switch2ProController object to use for this controller.
*/
public CommandSwitch2ProController(Switch2ProController controller) {
m_controller =
Objects.requireNonNull(controller, "Provided Switch2ProController cannot be null");
m_hid = new CommandGenericHID(m_controller.getHID());
}
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
public Switch2ProController getController() {
return m_controller;
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @return an event instance representing the button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #button(Switch2ProController.Button, EventLoop)
*/
public Trigger button(Switch2ProController.Button button) {
return button(button, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the button's digital signal attached to the given loop.
*/
public Trigger button(Switch2ProController.Button button, EventLoop loop) {
return m_hid.button(button.value, loop);
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @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() {
return b(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the B button's digital signal attached
* to the given loop.
*/
public Trigger b(EventLoop loop) {
return button(Switch2ProController.Button.B, loop);
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @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() {
return a(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the A button's digital signal attached
* to the given loop.
*/
public Trigger a(EventLoop loop) {
return button(Switch2ProController.Button.A, loop);
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @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() {
return y(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Y button's digital signal attached
* to the given loop.
*/
public Trigger y(EventLoop loop) {
return button(Switch2ProController.Button.Y, loop);
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @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() {
return x(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the X button's digital signal attached
* to the given loop.
*/
public Trigger x(EventLoop loop) {
return button(Switch2ProController.Button.X, loop);
}
/**
* Constructs a Trigger instance around the Minus button's digital signal.
*
* @return a Trigger instance representing the Minus button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #minus(EventLoop)
*/
public Trigger minus() {
return minus(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Minus button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Minus button's digital signal attached
* to the given loop.
*/
public Trigger minus(EventLoop loop) {
return button(Switch2ProController.Button.MINUS, loop);
}
/**
* Constructs a Trigger instance around the Home button's digital signal.
*
* @return a Trigger instance representing the Home button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #home(EventLoop)
*/
public Trigger home() {
return home(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Home button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Home button's digital signal attached
* to the given loop.
*/
public Trigger home(EventLoop loop) {
return button(Switch2ProController.Button.HOME, loop);
}
/**
* Constructs a Trigger instance around the Plus button's digital signal.
*
* @return a Trigger instance representing the Plus button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #plus(EventLoop)
*/
public Trigger plus() {
return plus(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Plus button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Plus button's digital signal attached
* to the given loop.
*/
public Trigger plus(EventLoop loop) {
return button(Switch2ProController.Button.PLUS, loop);
}
/**
* 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 button(Switch2ProController.Button.LEFT_STICK, loop);
}
/**
* 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 button(Switch2ProController.Button.RIGHT_STICK, loop);
}
/**
* Constructs a Trigger instance around the L button's digital signal.
*
* @return a Trigger instance representing the L button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #L(EventLoop)
*/
public Trigger L() {
return L(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the L button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the L button's digital signal attached
* to the given loop.
*/
public Trigger L(EventLoop loop) {
return button(Switch2ProController.Button.L, loop);
}
/**
* Constructs a Trigger instance around the R button's digital signal.
*
* @return a Trigger instance representing the R button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #R(EventLoop)
*/
public Trigger R() {
return R(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the R button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the R button's digital signal attached
* to the given loop.
*/
public Trigger R(EventLoop loop) {
return button(Switch2ProController.Button.R, loop);
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadUp(EventLoop)
*/
public Trigger dpadUp() {
return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the given loop.
*/
public Trigger dpadUp(EventLoop loop) {
return button(Switch2ProController.Button.DPAD_UP, loop);
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadDown(EventLoop)
*/
public Trigger dpadDown() {
return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the given loop.
*/
public Trigger dpadDown(EventLoop loop) {
return button(Switch2ProController.Button.DPAD_DOWN, loop);
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadLeft(EventLoop)
*/
public Trigger dpadLeft() {
return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the given loop.
*/
public Trigger dpadLeft(EventLoop loop) {
return button(Switch2ProController.Button.DPAD_LEFT, loop);
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadRight(EventLoop)
*/
public Trigger dpadRight() {
return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the given loop.
*/
public Trigger dpadRight(EventLoop loop) {
return button(Switch2ProController.Button.DPAD_RIGHT, loop);
}
/**
* Constructs a Trigger instance around the Capture button's digital signal.
*
* @return a Trigger instance representing the Capture button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #capture(EventLoop)
*/
public Trigger capture() {
return capture(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Capture button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Capture button's digital signal attached
* to the given loop.
*/
public Trigger capture(EventLoop loop) {
return button(Switch2ProController.Button.CAPTURE, loop);
}
/**
* Constructs a Trigger instance around the GR button's digital signal.
*
* @return a Trigger instance representing the GR button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #GR(EventLoop)
*/
public Trigger GR() {
return GR(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the GR button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the GR button's digital signal attached
* to the given loop.
*/
public Trigger GR(EventLoop loop) {
return button(Switch2ProController.Button.GR, loop);
}
/**
* Constructs a Trigger instance around the GL button's digital signal.
*
* @return a Trigger instance representing the GL button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #GL(EventLoop)
*/
public Trigger GL() {
return GL(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the GL button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the GL button's digital signal attached
* to the given loop.
*/
public Trigger GL(EventLoop loop) {
return button(Switch2ProController.Button.GL, loop);
}
/**
* Constructs a Trigger instance around the C button's digital signal.
*
* @return a Trigger instance representing the C button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #C(EventLoop)
*/
public Trigger C() {
return C(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the C button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the C button's digital signal attached
* to the given loop.
*/
public Trigger C(EventLoop loop) {
return button(Switch2ProController.Button.C, loop);
}
/**
* Constructs a Trigger instance around the axis value of the ZL. 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 ZL axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger ZL(double threshold, EventLoop loop) {
return axisGreaterThan(
Switch2ProController.Axis.ZL, threshold, loop);
}
/**
* Constructs a Trigger instance around the axis value of the ZL. 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 ZL axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger ZL(double threshold) {
return ZL(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the ZL. The returned
* trigger will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the ZL axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger ZL() {
return ZL(0.5);
}
/**
* Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger ZR(double threshold, EventLoop loop) {
return axisGreaterThan(
Switch2ProController.Axis.ZR, threshold, loop);
}
/**
* Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger ZR(double threshold) {
return ZR(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the ZR. The returned
* trigger will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the ZR axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger ZR() {
return ZR(0.5);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(Switch2ProController.Axis axis, double threshold) {
return m_hid.axisLessThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the trigger to
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(
Switch2ProController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisLessThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(Switch2ProController.Axis axis, double threshold) {
return m_hid.axisGreaterThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(
Switch2ProController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is greater than the
* provided threshold.
*/
public Trigger axisMagnitudeGreaterThan(
Switch2ProController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command
* scheduler button loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
*/
public Trigger axisMagnitudeGreaterThan(Switch2ProController.Axis axis, double threshold) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
}
/**
* Get the value of the axis.
*
* @param axis The axis to read
* @return The value of the axis.
*/
public double getAxis(Switch2ProController.Axis axis) {
return m_hid.getRawAxis(axis.value);
}
/**
* Get the Left X value of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return m_controller.getLeftX();
}
/**
* Get the Left Y value of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return m_controller.getLeftY();
}
/**
* Get the Right X value of the controller.
*
* @return The axis value.
*/
public double getRightX() {
return m_controller.getRightX();
}
/**
* Get the Right Y value of the controller.
*
* @return The axis value.
*/
public double getRightY() {
return m_controller.getRightY();
}
/**
* Get the ZL value of the controller.
*
* @return The axis value.
*/
public double getZL() {
return m_controller.getZL();
}
/**
* Get the ZR value of the controller.
*
* @return The axis value.
*/
public double getZR() {
return m_controller.getZR();
}
}

View File

@@ -0,0 +1,591 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
package org.wpilib.command2.button;
import java.util.Objects;
import org.wpilib.command2.CommandScheduler;
import org.wpilib.driverstation.SwitchN64Controller;
import org.wpilib.event.EventLoop;
/**
* A version of {@link SwitchN64Controller} with {@link Trigger} factories for command-based.
*
* @see SwitchN64Controller
*/
@SuppressWarnings("MethodName")
public class CommandSwitchN64Controller {
private final CommandGenericHID m_hid;
private final SwitchN64Controller m_controller;
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandSwitchN64Controller(int port) {
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new SwitchN64Controller(m_hid.getHID());
}
/**
* Construct an instance of a controller with a SwitchN64Controller object.
*
* @param controller The SwitchN64Controller object to use for this controller.
*/
public CommandSwitchN64Controller(SwitchN64Controller controller) {
m_controller =
Objects.requireNonNull(controller, "Provided SwitchN64Controller cannot be null");
m_hid = new CommandGenericHID(m_controller.getHID());
}
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
public SwitchN64Controller getController() {
return m_controller;
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @return an event instance representing the button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #button(SwitchN64Controller.Button, EventLoop)
*/
public Trigger button(SwitchN64Controller.Button button) {
return button(button, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the button's digital signal attached to the given loop.
*/
public Trigger button(SwitchN64Controller.Button button, EventLoop loop) {
return m_hid.button(button.value, loop);
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @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() {
return a(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the A button's digital signal attached
* to the given loop.
*/
public Trigger a(EventLoop loop) {
return button(SwitchN64Controller.Button.A, loop);
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @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() {
return b(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the B button's digital signal attached
* to the given loop.
*/
public Trigger b(EventLoop loop) {
return button(SwitchN64Controller.Button.B, loop);
}
/**
* Constructs a Trigger instance around the C Left button's digital signal.
*
* @return a Trigger instance representing the C Left button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #CLeft(EventLoop)
*/
public Trigger CLeft() {
return CLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the C Left button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the C Left button's digital signal attached
* to the given loop.
*/
public Trigger CLeft(EventLoop loop) {
return button(SwitchN64Controller.Button.C_LEFT, loop);
}
/**
* Constructs a Trigger instance around the C Up button's digital signal.
*
* @return a Trigger instance representing the C Up button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #CUp(EventLoop)
*/
public Trigger CUp() {
return CUp(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the C Up button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the C Up button's digital signal attached
* to the given loop.
*/
public Trigger CUp(EventLoop loop) {
return button(SwitchN64Controller.Button.C_UP, loop);
}
/**
* Constructs a Trigger instance around the Capture button's digital signal.
*
* @return a Trigger instance representing the Capture button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #capture(EventLoop)
*/
public Trigger capture() {
return capture(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Capture button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Capture button's digital signal attached
* to the given loop.
*/
public Trigger capture(EventLoop loop) {
return button(SwitchN64Controller.Button.CAPTURE, loop);
}
/**
* Constructs a Trigger instance around the Home button's digital signal.
*
* @return a Trigger instance representing the Home button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #home(EventLoop)
*/
public Trigger home() {
return home(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Home button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Home button's digital signal attached
* to the given loop.
*/
public Trigger home(EventLoop loop) {
return button(SwitchN64Controller.Button.HOME, loop);
}
/**
* 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 button(SwitchN64Controller.Button.START, loop);
}
/**
* Constructs a Trigger instance around the C Down button's digital signal.
*
* @return a Trigger instance representing the C Down button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #CDown(EventLoop)
*/
public Trigger CDown() {
return CDown(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the C Down button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the C Down button's digital signal attached
* to the given loop.
*/
public Trigger CDown(EventLoop loop) {
return button(SwitchN64Controller.Button.C_DOWN, loop);
}
/**
* Constructs a Trigger instance around the L button's digital signal.
*
* @return a Trigger instance representing the L button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #L(EventLoop)
*/
public Trigger L() {
return L(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the L button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the L button's digital signal attached
* to the given loop.
*/
public Trigger L(EventLoop loop) {
return button(SwitchN64Controller.Button.L, loop);
}
/**
* Constructs a Trigger instance around the R button's digital signal.
*
* @return a Trigger instance representing the R button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #R(EventLoop)
*/
public Trigger R() {
return R(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the R button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the R button's digital signal attached
* to the given loop.
*/
public Trigger R(EventLoop loop) {
return button(SwitchN64Controller.Button.R, loop);
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadUp(EventLoop)
*/
public Trigger dpadUp() {
return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the given loop.
*/
public Trigger dpadUp(EventLoop loop) {
return button(SwitchN64Controller.Button.DPAD_UP, loop);
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadDown(EventLoop)
*/
public Trigger dpadDown() {
return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the given loop.
*/
public Trigger dpadDown(EventLoop loop) {
return button(SwitchN64Controller.Button.DPAD_DOWN, loop);
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadLeft(EventLoop)
*/
public Trigger dpadLeft() {
return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the given loop.
*/
public Trigger dpadLeft(EventLoop loop) {
return button(SwitchN64Controller.Button.DPAD_LEFT, loop);
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadRight(EventLoop)
*/
public Trigger dpadRight() {
return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the given loop.
*/
public Trigger dpadRight(EventLoop loop) {
return button(SwitchN64Controller.Button.DPAD_RIGHT, loop);
}
/**
* Constructs a Trigger instance around the C Right button's digital signal.
*
* @return a Trigger instance representing the C Right button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #CRight(EventLoop)
*/
public Trigger CRight() {
return CRight(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the C Right button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the C Right button's digital signal attached
* to the given loop.
*/
public Trigger CRight(EventLoop loop) {
return button(SwitchN64Controller.Button.C_RIGHT, loop);
}
/**
* Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger ZR(double threshold, EventLoop loop) {
return axisGreaterThan(
SwitchN64Controller.Axis.ZR, threshold, loop);
}
/**
* Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger ZR(double threshold) {
return ZR(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the ZR. The returned
* trigger will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the ZR axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger ZR() {
return ZR(0.5);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(SwitchN64Controller.Axis axis, double threshold) {
return m_hid.axisLessThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the trigger to
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(
SwitchN64Controller.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisLessThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(SwitchN64Controller.Axis axis, double threshold) {
return m_hid.axisGreaterThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(
SwitchN64Controller.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is greater than the
* provided threshold.
*/
public Trigger axisMagnitudeGreaterThan(
SwitchN64Controller.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command
* scheduler button loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
*/
public Trigger axisMagnitudeGreaterThan(SwitchN64Controller.Axis axis, double threshold) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
}
/**
* Get the value of the axis.
*
* @param axis The axis to read
* @return The value of the axis.
*/
public double getAxis(SwitchN64Controller.Axis axis) {
return m_hid.getRawAxis(axis.value);
}
/**
* Get the Left X value of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return m_controller.getLeftX();
}
/**
* Get the Left Y value of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return m_controller.getLeftY();
}
/**
* Get the Z Axis value of the controller.
*
* @return The axis value.
*/
public double getZAxis() {
return m_controller.getZAxis();
}
/**
* Get the ZR value of the controller.
*
* @return The axis value.
*/
public double getZR() {
return m_controller.getZR();
}
}

View File

@@ -0,0 +1,674 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
package org.wpilib.command2.button;
import java.util.Objects;
import org.wpilib.command2.CommandScheduler;
import org.wpilib.driverstation.SwitchProController;
import org.wpilib.event.EventLoop;
/**
* A version of {@link SwitchProController} with {@link Trigger} factories for command-based.
*
* @see SwitchProController
*/
@SuppressWarnings("MethodName")
public class CommandSwitchProController {
private final CommandGenericHID m_hid;
private final SwitchProController m_controller;
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandSwitchProController(int port) {
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new SwitchProController(m_hid.getHID());
}
/**
* Construct an instance of a controller with a SwitchProController object.
*
* @param controller The SwitchProController object to use for this controller.
*/
public CommandSwitchProController(SwitchProController controller) {
m_controller =
Objects.requireNonNull(controller, "Provided SwitchProController cannot be null");
m_hid = new CommandGenericHID(m_controller.getHID());
}
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
public SwitchProController getController() {
return m_controller;
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @return an event instance representing the button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #button(SwitchProController.Button, EventLoop)
*/
public Trigger button(SwitchProController.Button button) {
return button(button, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the button's digital signal attached to the given loop.
*/
public Trigger button(SwitchProController.Button button, EventLoop loop) {
return m_hid.button(button.value, loop);
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @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() {
return b(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the B button's digital signal attached
* to the given loop.
*/
public Trigger b(EventLoop loop) {
return button(SwitchProController.Button.B, loop);
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @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() {
return a(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the A button's digital signal attached
* to the given loop.
*/
public Trigger a(EventLoop loop) {
return button(SwitchProController.Button.A, loop);
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @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() {
return y(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Y button's digital signal attached
* to the given loop.
*/
public Trigger y(EventLoop loop) {
return button(SwitchProController.Button.Y, loop);
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @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() {
return x(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the X button's digital signal attached
* to the given loop.
*/
public Trigger x(EventLoop loop) {
return button(SwitchProController.Button.X, loop);
}
/**
* Constructs a Trigger instance around the Minus button's digital signal.
*
* @return a Trigger instance representing the Minus button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #minus(EventLoop)
*/
public Trigger minus() {
return minus(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Minus button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Minus button's digital signal attached
* to the given loop.
*/
public Trigger minus(EventLoop loop) {
return button(SwitchProController.Button.MINUS, loop);
}
/**
* Constructs a Trigger instance around the Home button's digital signal.
*
* @return a Trigger instance representing the Home button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #home(EventLoop)
*/
public Trigger home() {
return home(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Home button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Home button's digital signal attached
* to the given loop.
*/
public Trigger home(EventLoop loop) {
return button(SwitchProController.Button.HOME, loop);
}
/**
* Constructs a Trigger instance around the Plus button's digital signal.
*
* @return a Trigger instance representing the Plus button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #plus(EventLoop)
*/
public Trigger plus() {
return plus(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Plus button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Plus button's digital signal attached
* to the given loop.
*/
public Trigger plus(EventLoop loop) {
return button(SwitchProController.Button.PLUS, loop);
}
/**
* 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 button(SwitchProController.Button.LEFT_STICK, loop);
}
/**
* 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 button(SwitchProController.Button.RIGHT_STICK, loop);
}
/**
* Constructs a Trigger instance around the L button's digital signal.
*
* @return a Trigger instance representing the L button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #L(EventLoop)
*/
public Trigger L() {
return L(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the L button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the L button's digital signal attached
* to the given loop.
*/
public Trigger L(EventLoop loop) {
return button(SwitchProController.Button.L, loop);
}
/**
* Constructs a Trigger instance around the R button's digital signal.
*
* @return a Trigger instance representing the R button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #R(EventLoop)
*/
public Trigger R() {
return R(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the R button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the R button's digital signal attached
* to the given loop.
*/
public Trigger R(EventLoop loop) {
return button(SwitchProController.Button.R, loop);
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadUp(EventLoop)
*/
public Trigger dpadUp() {
return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the given loop.
*/
public Trigger dpadUp(EventLoop loop) {
return button(SwitchProController.Button.DPAD_UP, loop);
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadDown(EventLoop)
*/
public Trigger dpadDown() {
return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the given loop.
*/
public Trigger dpadDown(EventLoop loop) {
return button(SwitchProController.Button.DPAD_DOWN, loop);
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadLeft(EventLoop)
*/
public Trigger dpadLeft() {
return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the given loop.
*/
public Trigger dpadLeft(EventLoop loop) {
return button(SwitchProController.Button.DPAD_LEFT, loop);
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadRight(EventLoop)
*/
public Trigger dpadRight() {
return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the given loop.
*/
public Trigger dpadRight(EventLoop loop) {
return button(SwitchProController.Button.DPAD_RIGHT, loop);
}
/**
* Constructs a Trigger instance around the Capture button's digital signal.
*
* @return a Trigger instance representing the Capture button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #capture(EventLoop)
*/
public Trigger capture() {
return capture(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Capture button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Capture button's digital signal attached
* to the given loop.
*/
public Trigger capture(EventLoop loop) {
return button(SwitchProController.Button.CAPTURE, loop);
}
/**
* Constructs a Trigger instance around the axis value of the ZL. 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 ZL axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger ZL(double threshold, EventLoop loop) {
return axisGreaterThan(
SwitchProController.Axis.ZL, threshold, loop);
}
/**
* Constructs a Trigger instance around the axis value of the ZL. 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 ZL axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger ZL(double threshold) {
return ZL(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the ZL. The returned
* trigger will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the ZL axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger ZL() {
return ZL(0.5);
}
/**
* Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger ZR(double threshold, EventLoop loop) {
return axisGreaterThan(
SwitchProController.Axis.ZR, threshold, loop);
}
/**
* Constructs a Trigger instance around the axis value of the ZR. 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 ZR axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger ZR(double threshold) {
return ZR(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the axis value of the ZR. The returned
* trigger will be true when the axis value is greater than 0.5.
*
* @return a Trigger instance that is true when the ZR axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger ZR() {
return ZR(0.5);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(SwitchProController.Axis axis, double threshold) {
return m_hid.axisLessThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the trigger to
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(
SwitchProController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisLessThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(SwitchProController.Axis axis, double threshold) {
return m_hid.axisGreaterThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(
SwitchProController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is greater than the
* provided threshold.
*/
public Trigger axisMagnitudeGreaterThan(
SwitchProController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command
* scheduler button loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
*/
public Trigger axisMagnitudeGreaterThan(SwitchProController.Axis axis, double threshold) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
}
/**
* Get the value of the axis.
*
* @param axis The axis to read
* @return The value of the axis.
*/
public double getAxis(SwitchProController.Axis axis) {
return m_hid.getRawAxis(axis.value);
}
/**
* Get the Left X value of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return m_controller.getLeftX();
}
/**
* Get the Left Y value of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return m_controller.getLeftY();
}
/**
* Get the Right X value of the controller.
*
* @return The axis value.
*/
public double getRightX() {
return m_controller.getRightX();
}
/**
* Get the Right Y value of the controller.
*
* @return The axis value.
*/
public double getRightY() {
return m_controller.getRightY();
}
/**
* Get the ZL value of the controller.
*
* @return The axis value.
*/
public double getZL() {
return m_controller.getZL();
}
/**
* Get the ZR value of the controller.
*
* @return The axis value.
*/
public double getZR() {
return m_controller.getZR();
}
}

View File

@@ -0,0 +1,652 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
package org.wpilib.command2.button;
import java.util.Objects;
import org.wpilib.command2.CommandScheduler;
import org.wpilib.driverstation.XboxController;
import org.wpilib.event.EventLoop;
/**
* A version of {@link XboxController} with {@link Trigger} factories for command-based.
*
* @see XboxController
*/
@SuppressWarnings("MethodName")
public class CommandXboxController {
private final CommandGenericHID m_hid;
private final XboxController m_controller;
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandXboxController(int port) {
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_controller = new XboxController(m_hid.getHID());
}
/**
* Construct an instance of a controller with a XboxController object.
*
* @param controller The XboxController object to use for this controller.
*/
public CommandXboxController(XboxController controller) {
m_controller =
Objects.requireNonNull(controller, "Provided XboxController cannot be null");
m_hid = new CommandGenericHID(m_controller.getHID());
}
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
public XboxController getController() {
return m_controller;
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @return an event instance representing the button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #button(XboxController.Button, EventLoop)
*/
public Trigger button(XboxController.Button button) {
return button(button, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @param loop the event loop instance to attach the event to.
* @return an event instance representing the button's digital signal attached to the given loop.
*/
public Trigger button(XboxController.Button button, EventLoop loop) {
return m_hid.button(button.value, loop);
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @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() {
return a(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the A button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the A button's digital signal attached
* to the given loop.
*/
public Trigger a(EventLoop loop) {
return button(XboxController.Button.A, loop);
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @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() {
return b(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the B button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the B button's digital signal attached
* to the given loop.
*/
public Trigger b(EventLoop loop) {
return button(XboxController.Button.B, loop);
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @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() {
return x(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the X button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the X button's digital signal attached
* to the given loop.
*/
public Trigger x(EventLoop loop) {
return button(XboxController.Button.X, loop);
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @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() {
return y(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Y button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Y button's digital signal attached
* to the given loop.
*/
public Trigger y(EventLoop loop) {
return button(XboxController.Button.Y, loop);
}
/**
* Constructs a Trigger instance around the View button's digital signal.
*
* @return a Trigger instance representing the View button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #view(EventLoop)
*/
public Trigger view() {
return view(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the View button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the View button's digital signal attached
* to the given loop.
*/
public Trigger view(EventLoop loop) {
return button(XboxController.Button.VIEW, loop);
}
/**
* Constructs a Trigger instance around the Xbox button's digital signal.
*
* @return a Trigger instance representing the Xbox button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #xbox(EventLoop)
*/
public Trigger xbox() {
return xbox(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Xbox button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Xbox button's digital signal attached
* to the given loop.
*/
public Trigger xbox(EventLoop loop) {
return button(XboxController.Button.XBOX, loop);
}
/**
* Constructs a Trigger instance around the Menu button's digital signal.
*
* @return a Trigger instance representing the Menu button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #menu(EventLoop)
*/
public Trigger menu() {
return menu(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Menu button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Menu button's digital signal attached
* to the given loop.
*/
public Trigger menu(EventLoop loop) {
return button(XboxController.Button.MENU, loop);
}
/**
* 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 button(XboxController.Button.LEFT_STICK, loop);
}
/**
* 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 button(XboxController.Button.RIGHT_STICK, loop);
}
/**
* Constructs a Trigger instance around the Left Bumper button's digital signal.
*
* @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 button(XboxController.Button.LEFT_BUMPER, loop);
}
/**
* 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 button(XboxController.Button.RIGHT_BUMPER, loop);
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadUp(EventLoop)
*/
public Trigger dpadUp() {
return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Up button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Up button's digital signal attached
* to the given loop.
*/
public Trigger dpadUp(EventLoop loop) {
return button(XboxController.Button.DPAD_UP, loop);
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadDown(EventLoop)
*/
public Trigger dpadDown() {
return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Down button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Down button's digital signal attached
* to the given loop.
*/
public Trigger dpadDown(EventLoop loop) {
return button(XboxController.Button.DPAD_DOWN, loop);
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadLeft(EventLoop)
*/
public Trigger dpadLeft() {
return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Left button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Left button's digital signal attached
* to the given loop.
*/
public Trigger dpadLeft(EventLoop loop) {
return button(XboxController.Button.DPAD_LEFT, loop);
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #dpadRight(EventLoop)
*/
public Trigger dpadRight() {
return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the Dpad Right button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the Dpad Right button's digital signal attached
* to the given loop.
*/
public Trigger dpadRight(EventLoop loop) {
return button(XboxController.Button.DPAD_RIGHT, loop);
}
/**
* 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.
* @param loop the event loop instance to attach the Trigger to.
* @return a Trigger instance that is true when the Left Trigger axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger leftTrigger(double threshold, EventLoop loop) {
return axisGreaterThan(
XboxController.Axis.LEFT_TRIGGER, threshold, loop);
}
/**
* 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.
* @return a Trigger instance that is true when the Left Trigger axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger leftTrigger(double threshold) {
return leftTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 0.5.
*
* @return a Trigger instance that is true when the Left Trigger axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger leftTrigger() {
return leftTrigger(0.5);
}
/**
* 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.
* @param loop the event loop instance to attach the Trigger to.
* @return a Trigger instance that is true when the Right Trigger axis exceeds the provided
* threshold, attached to the given event loop
*/
public Trigger rightTrigger(double threshold, EventLoop loop) {
return axisGreaterThan(
XboxController.Axis.RIGHT_TRIGGER, threshold, loop);
}
/**
* 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.
* @return a Trigger instance that is true when the Right Trigger axis exceeds the provided
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
* button loop}.
*/
public Trigger rightTrigger(double threshold) {
return rightTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* 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 0.5.
*
* @return a Trigger instance that is true when the Right Trigger axis exceeds 0.5,
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
* loop}.
*/
public Trigger rightTrigger() {
return rightTrigger(0.5);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(XboxController.Axis axis, double threshold) {
return m_hid.axisLessThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the trigger to
* @return a Trigger instance that is true when the axis value is less than the provided
* threshold.
*/
public Trigger axisLessThan(
XboxController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisLessThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
* loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(XboxController.Axis axis, double threshold) {
return m_hid.axisGreaterThan(axis.value, threshold);
}
/**
* Constructs a Trigger instance that is true when the axis value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis value is greater than the provided
* threshold.
*/
public Trigger axisGreaterThan(
XboxController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is greater than the
* provided threshold.
*/
public Trigger axisMagnitudeGreaterThan(
XboxController.Axis axis, double threshold, EventLoop loop) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
}
/**
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
* threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command
* scheduler button loop}.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
*/
public Trigger axisMagnitudeGreaterThan(XboxController.Axis axis, double threshold) {
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
}
/**
* Get the value of the axis.
*
* @param axis The axis to read
* @return The value of the axis.
*/
public double getAxis(XboxController.Axis axis) {
return m_hid.getRawAxis(axis.value);
}
/**
* Get the Left X value of the controller.
*
* @return The axis value.
*/
public double getLeftX() {
return m_controller.getLeftX();
}
/**
* Get the Left Y value of the controller.
*
* @return The axis value.
*/
public double getLeftY() {
return m_controller.getLeftY();
}
/**
* Get the Right X value of the controller.
*
* @return The axis value.
*/
public double getRightX() {
return m_controller.getRightX();
}
/**
* Get the Right Y value of the controller.
*
* @return The axis value.
*/
public double getRightY() {
return m_controller.getRightY();
}
/**
* Get the Left Trigger value of the controller.
*
* @return The axis value.
*/
public double getLeftTrigger() {
return m_controller.getLeftTrigger();
}
/**
* Get the Right Trigger value of the controller.
*
* @return The axis value.
*/
public double getRightTrigger() {
return m_controller.getRightTrigger();
}
}

View File

@@ -0,0 +1,202 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY
#include "wpi/commands2/button/CommandDualSenseController.hpp"
using namespace wpi::cmd;
CommandDualSenseController::CommandDualSenseController(int port)
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)} {
m_ownedController =
std::make_unique<wpi::DualSenseController>(m_hid->GetHID());
m_controller = m_ownedController.get();
}
CommandDualSenseController::CommandDualSenseController(
wpi::DualSenseController* controller)
: m_ownedHid{std::make_unique<CommandGenericHID>(controller->GetHID())},
m_hid{m_ownedHid.get()},
m_controller{controller} {}
CommandGenericHID& CommandDualSenseController::GetHID() {
return *m_hid;
}
wpi::DualSenseController&
CommandDualSenseController::GetController() {
return *m_controller;
}
const wpi::DualSenseController&
CommandDualSenseController::GetController() const {
return *m_controller;
}
Trigger CommandDualSenseController::Button(
enum wpi::DualSenseController::Button button,
wpi::EventLoop* loop) const {
return m_hid->Button(static_cast<int>(button), loop);
}
Trigger CommandDualSenseController::Cross(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::CROSS,
loop);
}
Trigger CommandDualSenseController::Circle(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::CIRCLE,
loop);
}
Trigger CommandDualSenseController::Square(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::SQUARE,
loop);
}
Trigger CommandDualSenseController::Triangle(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::TRIANGLE,
loop);
}
Trigger CommandDualSenseController::Create(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::CREATE,
loop);
}
Trigger CommandDualSenseController::PS(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::PS,
loop);
}
Trigger CommandDualSenseController::Options(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::OPTIONS,
loop);
}
Trigger CommandDualSenseController::L3(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::L3,
loop);
}
Trigger CommandDualSenseController::R3(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::R3,
loop);
}
Trigger CommandDualSenseController::L1(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::L1,
loop);
}
Trigger CommandDualSenseController::R1(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::R1,
loop);
}
Trigger CommandDualSenseController::DpadUp(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::DPAD_UP,
loop);
}
Trigger CommandDualSenseController::DpadDown(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::DPAD_DOWN,
loop);
}
Trigger CommandDualSenseController::DpadLeft(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::DPAD_LEFT,
loop);
}
Trigger CommandDualSenseController::DpadRight(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::DPAD_RIGHT,
loop);
}
Trigger CommandDualSenseController::Microphone(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::MICROPHONE,
loop);
}
Trigger CommandDualSenseController::Touchpad(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseController::Button::TOUCHPAD,
loop);
}
Trigger CommandDualSenseController::L2(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::DualSenseController::Axis::L2,
threshold, loop);
}
Trigger CommandDualSenseController::R2(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::DualSenseController::Axis::R2,
threshold, loop);
}
Trigger CommandDualSenseController::AxisLessThan(
wpi::DualSenseController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisLessThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandDualSenseController::AxisGreaterThan(
wpi::DualSenseController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisGreaterThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandDualSenseController::AxisMagnitudeGreaterThan(
wpi::DualSenseController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisMagnitudeGreaterThan(static_cast<int>(axis), threshold,
loop);
}
double CommandDualSenseController::GetLeftX() const {
return m_controller->GetLeftX();
}
double CommandDualSenseController::GetLeftY() const {
return m_controller->GetLeftY();
}
double CommandDualSenseController::GetRightX() const {
return m_controller->GetRightX();
}
double CommandDualSenseController::GetRightY() const {
return m_controller->GetRightY();
}
double CommandDualSenseController::GetL2() const {
return m_controller->GetL2();
}
double CommandDualSenseController::GetR2() const {
return m_controller->GetR2();
}

View File

@@ -0,0 +1,226 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#include "wpi/commands2/button/CommandDualSenseEdgeController.hpp"
using namespace wpi::cmd;
CommandDualSenseEdgeController::CommandDualSenseEdgeController(int port)
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)} {
m_ownedController =
std::make_unique<wpi::DualSenseEdgeController>(m_hid->GetHID());
m_controller = m_ownedController.get();
}
CommandDualSenseEdgeController::CommandDualSenseEdgeController(
wpi::DualSenseEdgeController* controller)
: m_ownedHid{std::make_unique<CommandGenericHID>(controller->GetHID())},
m_hid{m_ownedHid.get()},
m_controller{controller} {}
CommandGenericHID& CommandDualSenseEdgeController::GetHID() {
return *m_hid;
}
wpi::DualSenseEdgeController&
CommandDualSenseEdgeController::GetController() {
return *m_controller;
}
const wpi::DualSenseEdgeController&
CommandDualSenseEdgeController::GetController() const {
return *m_controller;
}
Trigger CommandDualSenseEdgeController::Button(
enum wpi::DualSenseEdgeController::Button button,
wpi::EventLoop* loop) const {
return m_hid->Button(static_cast<int>(button), loop);
}
Trigger CommandDualSenseEdgeController::Cross(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::CROSS,
loop);
}
Trigger CommandDualSenseEdgeController::Circle(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::CIRCLE,
loop);
}
Trigger CommandDualSenseEdgeController::Square(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::SQUARE,
loop);
}
Trigger CommandDualSenseEdgeController::Triangle(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::TRIANGLE,
loop);
}
Trigger CommandDualSenseEdgeController::Create(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::CREATE,
loop);
}
Trigger CommandDualSenseEdgeController::PS(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::PS,
loop);
}
Trigger CommandDualSenseEdgeController::Options(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::OPTIONS,
loop);
}
Trigger CommandDualSenseEdgeController::L3(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::L3,
loop);
}
Trigger CommandDualSenseEdgeController::R3(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::R3,
loop);
}
Trigger CommandDualSenseEdgeController::L1(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::L1,
loop);
}
Trigger CommandDualSenseEdgeController::R1(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::R1,
loop);
}
Trigger CommandDualSenseEdgeController::DpadUp(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::DPAD_UP,
loop);
}
Trigger CommandDualSenseEdgeController::DpadDown(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::DPAD_DOWN,
loop);
}
Trigger CommandDualSenseEdgeController::DpadLeft(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::DPAD_LEFT,
loop);
}
Trigger CommandDualSenseEdgeController::DpadRight(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::DPAD_RIGHT,
loop);
}
Trigger CommandDualSenseEdgeController::Microphone(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::MICROPHONE,
loop);
}
Trigger CommandDualSenseEdgeController::RightPaddle1(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::RIGHT_PADDLE_1,
loop);
}
Trigger CommandDualSenseEdgeController::LeftPaddle1(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::LEFT_PADDLE_1,
loop);
}
Trigger CommandDualSenseEdgeController::Touchpad(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::TOUCHPAD,
loop);
}
Trigger CommandDualSenseEdgeController::LeftFunction(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::LEFT_FUNCTION,
loop);
}
Trigger CommandDualSenseEdgeController::RightFunction(
wpi::EventLoop* loop) const {
return Button(wpi::DualSenseEdgeController::Button::RIGHT_FUNCTION,
loop);
}
Trigger CommandDualSenseEdgeController::L2(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::DualSenseEdgeController::Axis::L2,
threshold, loop);
}
Trigger CommandDualSenseEdgeController::R2(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::DualSenseEdgeController::Axis::R2,
threshold, loop);
}
Trigger CommandDualSenseEdgeController::AxisLessThan(
wpi::DualSenseEdgeController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisLessThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandDualSenseEdgeController::AxisGreaterThan(
wpi::DualSenseEdgeController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisGreaterThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandDualSenseEdgeController::AxisMagnitudeGreaterThan(
wpi::DualSenseEdgeController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisMagnitudeGreaterThan(static_cast<int>(axis), threshold,
loop);
}
double CommandDualSenseEdgeController::GetLeftX() const {
return m_controller->GetLeftX();
}
double CommandDualSenseEdgeController::GetLeftY() const {
return m_controller->GetLeftY();
}
double CommandDualSenseEdgeController::GetRightX() const {
return m_controller->GetRightX();
}
double CommandDualSenseEdgeController::GetRightY() const {
return m_controller->GetRightY();
}
double CommandDualSenseEdgeController::GetL2() const {
return m_controller->GetL2();
}
double CommandDualSenseEdgeController::GetR2() const {
return m_controller->GetR2();
}

View File

@@ -0,0 +1,196 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#include "wpi/commands2/button/CommandDualShock4Controller.hpp"
using namespace wpi::cmd;
CommandDualShock4Controller::CommandDualShock4Controller(int port)
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)} {
m_ownedController =
std::make_unique<wpi::DualShock4Controller>(m_hid->GetHID());
m_controller = m_ownedController.get();
}
CommandDualShock4Controller::CommandDualShock4Controller(
wpi::DualShock4Controller* controller)
: m_ownedHid{std::make_unique<CommandGenericHID>(controller->GetHID())},
m_hid{m_ownedHid.get()},
m_controller{controller} {}
CommandGenericHID& CommandDualShock4Controller::GetHID() {
return *m_hid;
}
wpi::DualShock4Controller&
CommandDualShock4Controller::GetController() {
return *m_controller;
}
const wpi::DualShock4Controller&
CommandDualShock4Controller::GetController() const {
return *m_controller;
}
Trigger CommandDualShock4Controller::Button(
enum wpi::DualShock4Controller::Button button,
wpi::EventLoop* loop) const {
return m_hid->Button(static_cast<int>(button), loop);
}
Trigger CommandDualShock4Controller::Cross(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::CROSS,
loop);
}
Trigger CommandDualShock4Controller::Circle(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::CIRCLE,
loop);
}
Trigger CommandDualShock4Controller::Square(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::SQUARE,
loop);
}
Trigger CommandDualShock4Controller::Triangle(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::TRIANGLE,
loop);
}
Trigger CommandDualShock4Controller::Share(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::SHARE,
loop);
}
Trigger CommandDualShock4Controller::PS(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::PS,
loop);
}
Trigger CommandDualShock4Controller::Options(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::OPTIONS,
loop);
}
Trigger CommandDualShock4Controller::L3(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::L3,
loop);
}
Trigger CommandDualShock4Controller::R3(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::R3,
loop);
}
Trigger CommandDualShock4Controller::L1(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::L1,
loop);
}
Trigger CommandDualShock4Controller::R1(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::R1,
loop);
}
Trigger CommandDualShock4Controller::DpadUp(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::DPAD_UP,
loop);
}
Trigger CommandDualShock4Controller::DpadDown(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::DPAD_DOWN,
loop);
}
Trigger CommandDualShock4Controller::DpadLeft(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::DPAD_LEFT,
loop);
}
Trigger CommandDualShock4Controller::DpadRight(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::DPAD_RIGHT,
loop);
}
Trigger CommandDualShock4Controller::Touchpad(
wpi::EventLoop* loop) const {
return Button(wpi::DualShock4Controller::Button::TOUCHPAD,
loop);
}
Trigger CommandDualShock4Controller::L2(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::DualShock4Controller::Axis::L2,
threshold, loop);
}
Trigger CommandDualShock4Controller::R2(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::DualShock4Controller::Axis::R2,
threshold, loop);
}
Trigger CommandDualShock4Controller::AxisLessThan(
wpi::DualShock4Controller::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisLessThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandDualShock4Controller::AxisGreaterThan(
wpi::DualShock4Controller::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisGreaterThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandDualShock4Controller::AxisMagnitudeGreaterThan(
wpi::DualShock4Controller::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisMagnitudeGreaterThan(static_cast<int>(axis), threshold,
loop);
}
double CommandDualShock4Controller::GetLeftX() const {
return m_controller->GetLeftX();
}
double CommandDualShock4Controller::GetLeftY() const {
return m_controller->GetLeftY();
}
double CommandDualShock4Controller::GetRightX() const {
return m_controller->GetRightX();
}
double CommandDualShock4Controller::GetRightY() const {
return m_controller->GetRightY();
}
double CommandDualShock4Controller::GetL2() const {
return m_controller->GetL2();
}
double CommandDualShock4Controller::GetR2() const {
return m_controller->GetR2();
}

View File

@@ -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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#include "wpi/commands2/button/CommandGameCubeController.hpp"
using namespace wpi::cmd;
CommandGameCubeController::CommandGameCubeController(int port)
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)} {
m_ownedController =
std::make_unique<wpi::GameCubeController>(m_hid->GetHID());
m_controller = m_ownedController.get();
}
CommandGameCubeController::CommandGameCubeController(
wpi::GameCubeController* controller)
: m_ownedHid{std::make_unique<CommandGenericHID>(controller->GetHID())},
m_hid{m_ownedHid.get()},
m_controller{controller} {}
CommandGenericHID& CommandGameCubeController::GetHID() {
return *m_hid;
}
wpi::GameCubeController&
CommandGameCubeController::GetController() {
return *m_controller;
}
const wpi::GameCubeController&
CommandGameCubeController::GetController() const {
return *m_controller;
}
Trigger CommandGameCubeController::Button(
enum wpi::GameCubeController::Button button,
wpi::EventLoop* loop) const {
return m_hid->Button(static_cast<int>(button), loop);
}
Trigger CommandGameCubeController::A(
wpi::EventLoop* loop) const {
return Button(wpi::GameCubeController::Button::A,
loop);
}
Trigger CommandGameCubeController::X(
wpi::EventLoop* loop) const {
return Button(wpi::GameCubeController::Button::X,
loop);
}
Trigger CommandGameCubeController::B(
wpi::EventLoop* loop) const {
return Button(wpi::GameCubeController::Button::B,
loop);
}
Trigger CommandGameCubeController::Y(
wpi::EventLoop* loop) const {
return Button(wpi::GameCubeController::Button::Y,
loop);
}
Trigger CommandGameCubeController::Start(
wpi::EventLoop* loop) const {
return Button(wpi::GameCubeController::Button::START,
loop);
}
Trigger CommandGameCubeController::Z(
wpi::EventLoop* loop) const {
return Button(wpi::GameCubeController::Button::Z,
loop);
}
Trigger CommandGameCubeController::DpadUp(
wpi::EventLoop* loop) const {
return Button(wpi::GameCubeController::Button::DPAD_UP,
loop);
}
Trigger CommandGameCubeController::DpadDown(
wpi::EventLoop* loop) const {
return Button(wpi::GameCubeController::Button::DPAD_DOWN,
loop);
}
Trigger CommandGameCubeController::DpadLeft(
wpi::EventLoop* loop) const {
return Button(wpi::GameCubeController::Button::DPAD_LEFT,
loop);
}
Trigger CommandGameCubeController::DpadRight(
wpi::EventLoop* loop) const {
return Button(wpi::GameCubeController::Button::DPAD_RIGHT,
loop);
}
Trigger CommandGameCubeController::L(
wpi::EventLoop* loop) const {
return Button(wpi::GameCubeController::Button::L,
loop);
}
Trigger CommandGameCubeController::R(
wpi::EventLoop* loop) const {
return Button(wpi::GameCubeController::Button::R,
loop);
}
Trigger CommandGameCubeController::LTrigger(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::GameCubeController::Axis::L_TRIGGER,
threshold, loop);
}
Trigger CommandGameCubeController::RTrigger(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::GameCubeController::Axis::R_TRIGGER,
threshold, loop);
}
Trigger CommandGameCubeController::AxisLessThan(
wpi::GameCubeController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisLessThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandGameCubeController::AxisGreaterThan(
wpi::GameCubeController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisGreaterThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandGameCubeController::AxisMagnitudeGreaterThan(
wpi::GameCubeController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisMagnitudeGreaterThan(static_cast<int>(axis), threshold,
loop);
}
double CommandGameCubeController::GetLeftX() const {
return m_controller->GetLeftX();
}
double CommandGameCubeController::GetLeftY() const {
return m_controller->GetLeftY();
}
double CommandGameCubeController::GetCStickX() const {
return m_controller->GetCStickX();
}
double CommandGameCubeController::GetCStickY() const {
return m_controller->GetCStickY();
}
double CommandGameCubeController::GetLTrigger() const {
return m_controller->GetLTrigger();
}
double CommandGameCubeController::GetRTrigger() const {
return m_controller->GetRTrigger();
}

View File

@@ -0,0 +1,190 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#include "wpi/commands2/button/CommandLogitechF310Controller.hpp"
using namespace wpi::cmd;
CommandLogitechF310Controller::CommandLogitechF310Controller(int port)
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)} {
m_ownedController =
std::make_unique<wpi::LogitechF310Controller>(m_hid->GetHID());
m_controller = m_ownedController.get();
}
CommandLogitechF310Controller::CommandLogitechF310Controller(
wpi::LogitechF310Controller* controller)
: m_ownedHid{std::make_unique<CommandGenericHID>(controller->GetHID())},
m_hid{m_ownedHid.get()},
m_controller{controller} {}
CommandGenericHID& CommandLogitechF310Controller::GetHID() {
return *m_hid;
}
wpi::LogitechF310Controller&
CommandLogitechF310Controller::GetController() {
return *m_controller;
}
const wpi::LogitechF310Controller&
CommandLogitechF310Controller::GetController() const {
return *m_controller;
}
Trigger CommandLogitechF310Controller::Button(
enum wpi::LogitechF310Controller::Button button,
wpi::EventLoop* loop) const {
return m_hid->Button(static_cast<int>(button), loop);
}
Trigger CommandLogitechF310Controller::A(
wpi::EventLoop* loop) const {
return Button(wpi::LogitechF310Controller::Button::A,
loop);
}
Trigger CommandLogitechF310Controller::B(
wpi::EventLoop* loop) const {
return Button(wpi::LogitechF310Controller::Button::B,
loop);
}
Trigger CommandLogitechF310Controller::X(
wpi::EventLoop* loop) const {
return Button(wpi::LogitechF310Controller::Button::X,
loop);
}
Trigger CommandLogitechF310Controller::Y(
wpi::EventLoop* loop) const {
return Button(wpi::LogitechF310Controller::Button::Y,
loop);
}
Trigger CommandLogitechF310Controller::Back(
wpi::EventLoop* loop) const {
return Button(wpi::LogitechF310Controller::Button::BACK,
loop);
}
Trigger CommandLogitechF310Controller::Logitech(
wpi::EventLoop* loop) const {
return Button(wpi::LogitechF310Controller::Button::LOGITECH,
loop);
}
Trigger CommandLogitechF310Controller::Start(
wpi::EventLoop* loop) const {
return Button(wpi::LogitechF310Controller::Button::START,
loop);
}
Trigger CommandLogitechF310Controller::LeftStick(
wpi::EventLoop* loop) const {
return Button(wpi::LogitechF310Controller::Button::LEFT_STICK,
loop);
}
Trigger CommandLogitechF310Controller::RightStick(
wpi::EventLoop* loop) const {
return Button(wpi::LogitechF310Controller::Button::RIGHT_STICK,
loop);
}
Trigger CommandLogitechF310Controller::LeftBumper(
wpi::EventLoop* loop) const {
return Button(wpi::LogitechF310Controller::Button::LEFT_BUMPER,
loop);
}
Trigger CommandLogitechF310Controller::RightBumper(
wpi::EventLoop* loop) const {
return Button(wpi::LogitechF310Controller::Button::RIGHT_BUMPER,
loop);
}
Trigger CommandLogitechF310Controller::DpadUp(
wpi::EventLoop* loop) const {
return Button(wpi::LogitechF310Controller::Button::DPAD_UP,
loop);
}
Trigger CommandLogitechF310Controller::DpadDown(
wpi::EventLoop* loop) const {
return Button(wpi::LogitechF310Controller::Button::DPAD_DOWN,
loop);
}
Trigger CommandLogitechF310Controller::DpadLeft(
wpi::EventLoop* loop) const {
return Button(wpi::LogitechF310Controller::Button::DPAD_LEFT,
loop);
}
Trigger CommandLogitechF310Controller::DpadRight(
wpi::EventLoop* loop) const {
return Button(wpi::LogitechF310Controller::Button::DPAD_RIGHT,
loop);
}
Trigger CommandLogitechF310Controller::LeftTrigger(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::LogitechF310Controller::Axis::LEFT_TRIGGER,
threshold, loop);
}
Trigger CommandLogitechF310Controller::RightTrigger(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::LogitechF310Controller::Axis::RIGHT_TRIGGER,
threshold, loop);
}
Trigger CommandLogitechF310Controller::AxisLessThan(
wpi::LogitechF310Controller::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisLessThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandLogitechF310Controller::AxisGreaterThan(
wpi::LogitechF310Controller::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisGreaterThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandLogitechF310Controller::AxisMagnitudeGreaterThan(
wpi::LogitechF310Controller::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisMagnitudeGreaterThan(static_cast<int>(axis), threshold,
loop);
}
double CommandLogitechF310Controller::GetLeftX() const {
return m_controller->GetLeftX();
}
double CommandLogitechF310Controller::GetLeftY() const {
return m_controller->GetLeftY();
}
double CommandLogitechF310Controller::GetRightX() const {
return m_controller->GetRightX();
}
double CommandLogitechF310Controller::GetRightY() const {
return m_controller->GetRightY();
}
double CommandLogitechF310Controller::GetLeftTrigger() const {
return m_controller->GetLeftTrigger();
}
double CommandLogitechF310Controller::GetRightTrigger() const {
return m_controller->GetRightTrigger();
}

View File

@@ -9,88 +9,108 @@
using namespace wpi::cmd;
CommandNiDsPS4Controller::CommandNiDsPS4Controller(int port)
: CommandGenericHID(port), m_hid{wpi::NiDsPS4Controller(port)} {}
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)},
m_controller{m_hid->GetHID()} {}
wpi::NiDsPS4Controller& CommandNiDsPS4Controller::GetHID() {
return m_hid;
CommandGenericHID& CommandNiDsPS4Controller::GetHID() {
return *m_hid;
}
wpi::NiDsPS4Controller&
CommandNiDsPS4Controller::GetNiDsPS4Controller() {
return m_controller;
}
Trigger CommandNiDsPS4Controller::Square(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS4Controller::Button::kSquare, loop);
return m_hid->Button(
wpi::NiDsPS4Controller::Button::kSquare, loop);
}
Trigger CommandNiDsPS4Controller::Cross(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS4Controller::Button::kCross, loop);
return m_hid->Button(
wpi::NiDsPS4Controller::Button::kCross, loop);
}
Trigger CommandNiDsPS4Controller::Circle(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS4Controller::Button::kCircle, loop);
return m_hid->Button(
wpi::NiDsPS4Controller::Button::kCircle, loop);
}
Trigger CommandNiDsPS4Controller::Triangle(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS4Controller::Button::kTriangle, loop);
return m_hid->Button(
wpi::NiDsPS4Controller::Button::kTriangle, loop);
}
Trigger CommandNiDsPS4Controller::L1(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS4Controller::Button::kL1, loop);
return m_hid->Button(
wpi::NiDsPS4Controller::Button::kL1, loop);
}
Trigger CommandNiDsPS4Controller::R1(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS4Controller::Button::kR1, loop);
return m_hid->Button(
wpi::NiDsPS4Controller::Button::kR1, loop);
}
Trigger CommandNiDsPS4Controller::L2(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS4Controller::Button::kL2, loop);
return m_hid->Button(
wpi::NiDsPS4Controller::Button::kL2, loop);
}
Trigger CommandNiDsPS4Controller::R2(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS4Controller::Button::kR2, loop);
return m_hid->Button(
wpi::NiDsPS4Controller::Button::kR2, loop);
}
Trigger CommandNiDsPS4Controller::Share(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS4Controller::Button::kShare, loop);
return m_hid->Button(
wpi::NiDsPS4Controller::Button::kShare, loop);
}
Trigger CommandNiDsPS4Controller::Options(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS4Controller::Button::kOptions, loop);
return m_hid->Button(
wpi::NiDsPS4Controller::Button::kOptions, loop);
}
Trigger CommandNiDsPS4Controller::L3(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS4Controller::Button::kL3, loop);
return m_hid->Button(
wpi::NiDsPS4Controller::Button::kL3, loop);
}
Trigger CommandNiDsPS4Controller::R3(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS4Controller::Button::kR3, loop);
return m_hid->Button(
wpi::NiDsPS4Controller::Button::kR3, loop);
}
Trigger CommandNiDsPS4Controller::PS(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS4Controller::Button::kPS, loop);
return m_hid->Button(
wpi::NiDsPS4Controller::Button::kPS, loop);
}
Trigger CommandNiDsPS4Controller::Touchpad(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS4Controller::Button::kTouchpad, loop);
return m_hid->Button(
wpi::NiDsPS4Controller::Button::kTouchpad, loop);
}
double CommandNiDsPS4Controller::GetLeftX() const {
return m_hid.GetLeftX();
return m_controller.GetLeftX();
}
double CommandNiDsPS4Controller::GetLeftY() const {
return m_hid.GetLeftY();
return m_controller.GetLeftY();
}
double CommandNiDsPS4Controller::GetRightX() const {
return m_hid.GetRightX();
return m_controller.GetRightX();
}
double CommandNiDsPS4Controller::GetRightY() const {
return m_hid.GetRightY();
return m_controller.GetRightY();
}
double CommandNiDsPS4Controller::GetL2Axis() const {
return m_hid.GetL2Axis();
return m_controller.GetL2Axis();
}
double CommandNiDsPS4Controller::GetR2Axis() const {
return m_hid.GetR2Axis();
return m_controller.GetR2Axis();
}

View File

@@ -9,88 +9,108 @@
using namespace wpi::cmd;
CommandNiDsPS5Controller::CommandNiDsPS5Controller(int port)
: CommandGenericHID(port), m_hid{wpi::NiDsPS5Controller(port)} {}
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)},
m_controller{m_hid->GetHID()} {}
wpi::NiDsPS5Controller& CommandNiDsPS5Controller::GetHID() {
return m_hid;
CommandGenericHID& CommandNiDsPS5Controller::GetHID() {
return *m_hid;
}
wpi::NiDsPS5Controller&
CommandNiDsPS5Controller::GetNiDsPS5Controller() {
return m_controller;
}
Trigger CommandNiDsPS5Controller::Square(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS5Controller::Button::kSquare, loop);
return m_hid->Button(
wpi::NiDsPS5Controller::Button::kSquare, loop);
}
Trigger CommandNiDsPS5Controller::Cross(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS5Controller::Button::kCross, loop);
return m_hid->Button(
wpi::NiDsPS5Controller::Button::kCross, loop);
}
Trigger CommandNiDsPS5Controller::Circle(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS5Controller::Button::kCircle, loop);
return m_hid->Button(
wpi::NiDsPS5Controller::Button::kCircle, loop);
}
Trigger CommandNiDsPS5Controller::Triangle(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS5Controller::Button::kTriangle, loop);
return m_hid->Button(
wpi::NiDsPS5Controller::Button::kTriangle, loop);
}
Trigger CommandNiDsPS5Controller::L1(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS5Controller::Button::kL1, loop);
return m_hid->Button(
wpi::NiDsPS5Controller::Button::kL1, loop);
}
Trigger CommandNiDsPS5Controller::R1(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS5Controller::Button::kR1, loop);
return m_hid->Button(
wpi::NiDsPS5Controller::Button::kR1, loop);
}
Trigger CommandNiDsPS5Controller::L2(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS5Controller::Button::kL2, loop);
return m_hid->Button(
wpi::NiDsPS5Controller::Button::kL2, loop);
}
Trigger CommandNiDsPS5Controller::R2(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS5Controller::Button::kR2, loop);
return m_hid->Button(
wpi::NiDsPS5Controller::Button::kR2, loop);
}
Trigger CommandNiDsPS5Controller::Create(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS5Controller::Button::kCreate, loop);
return m_hid->Button(
wpi::NiDsPS5Controller::Button::kCreate, loop);
}
Trigger CommandNiDsPS5Controller::Options(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS5Controller::Button::kOptions, loop);
return m_hid->Button(
wpi::NiDsPS5Controller::Button::kOptions, loop);
}
Trigger CommandNiDsPS5Controller::L3(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS5Controller::Button::kL3, loop);
return m_hid->Button(
wpi::NiDsPS5Controller::Button::kL3, loop);
}
Trigger CommandNiDsPS5Controller::R3(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS5Controller::Button::kR3, loop);
return m_hid->Button(
wpi::NiDsPS5Controller::Button::kR3, loop);
}
Trigger CommandNiDsPS5Controller::PS(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS5Controller::Button::kPS, loop);
return m_hid->Button(
wpi::NiDsPS5Controller::Button::kPS, loop);
}
Trigger CommandNiDsPS5Controller::Touchpad(wpi::EventLoop* loop) const {
return Button(wpi::NiDsPS5Controller::Button::kTouchpad, loop);
return m_hid->Button(
wpi::NiDsPS5Controller::Button::kTouchpad, loop);
}
double CommandNiDsPS5Controller::GetLeftX() const {
return m_hid.GetLeftX();
return m_controller.GetLeftX();
}
double CommandNiDsPS5Controller::GetLeftY() const {
return m_hid.GetLeftY();
return m_controller.GetLeftY();
}
double CommandNiDsPS5Controller::GetRightX() const {
return m_hid.GetRightX();
return m_controller.GetRightX();
}
double CommandNiDsPS5Controller::GetRightY() const {
return m_hid.GetRightY();
return m_controller.GetRightY();
}
double CommandNiDsPS5Controller::GetL2Axis() const {
return m_hid.GetL2Axis();
return m_controller.GetL2Axis();
}
double CommandNiDsPS5Controller::GetR2Axis() const {
return m_hid.GetR2Axis();
return m_controller.GetR2Axis();
}

View File

@@ -9,84 +9,105 @@
using namespace wpi::cmd;
CommandNiDsStadiaController::CommandNiDsStadiaController(int port)
: CommandGenericHID(port), m_hid{wpi::NiDsStadiaController(port)} {}
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)},
m_controller{m_hid->GetHID()} {}
wpi::NiDsStadiaController& CommandNiDsStadiaController::GetHID() {
return m_hid;
CommandGenericHID& CommandNiDsStadiaController::GetHID() {
return *m_hid;
}
wpi::NiDsStadiaController&
CommandNiDsStadiaController::GetNiDsStadiaController() {
return m_controller;
}
Trigger CommandNiDsStadiaController::A(wpi::EventLoop* loop) const {
return Button(wpi::NiDsStadiaController::Button::kA, loop);
return m_hid->Button(
wpi::NiDsStadiaController::Button::kA, loop);
}
Trigger CommandNiDsStadiaController::B(wpi::EventLoop* loop) const {
return Button(wpi::NiDsStadiaController::Button::kB, loop);
return m_hid->Button(
wpi::NiDsStadiaController::Button::kB, loop);
}
Trigger CommandNiDsStadiaController::X(wpi::EventLoop* loop) const {
return Button(wpi::NiDsStadiaController::Button::kX, loop);
return m_hid->Button(
wpi::NiDsStadiaController::Button::kX, loop);
}
Trigger CommandNiDsStadiaController::Y(wpi::EventLoop* loop) const {
return Button(wpi::NiDsStadiaController::Button::kY, loop);
return m_hid->Button(
wpi::NiDsStadiaController::Button::kY, loop);
}
Trigger CommandNiDsStadiaController::LeftBumper(wpi::EventLoop* loop) const {
return Button(wpi::NiDsStadiaController::Button::kLeftBumper, loop);
return m_hid->Button(
wpi::NiDsStadiaController::Button::kLeftBumper, loop);
}
Trigger CommandNiDsStadiaController::RightBumper(wpi::EventLoop* loop) const {
return Button(wpi::NiDsStadiaController::Button::kRightBumper, loop);
return m_hid->Button(
wpi::NiDsStadiaController::Button::kRightBumper, loop);
}
Trigger CommandNiDsStadiaController::LeftStick(wpi::EventLoop* loop) const {
return Button(wpi::NiDsStadiaController::Button::kLeftStick, loop);
return m_hid->Button(
wpi::NiDsStadiaController::Button::kLeftStick, loop);
}
Trigger CommandNiDsStadiaController::RightStick(wpi::EventLoop* loop) const {
return Button(wpi::NiDsStadiaController::Button::kRightStick, loop);
return m_hid->Button(
wpi::NiDsStadiaController::Button::kRightStick, loop);
}
Trigger CommandNiDsStadiaController::Ellipses(wpi::EventLoop* loop) const {
return Button(wpi::NiDsStadiaController::Button::kEllipses, loop);
return m_hid->Button(
wpi::NiDsStadiaController::Button::kEllipses, loop);
}
Trigger CommandNiDsStadiaController::Hamburger(wpi::EventLoop* loop) const {
return Button(wpi::NiDsStadiaController::Button::kHamburger, loop);
return m_hid->Button(
wpi::NiDsStadiaController::Button::kHamburger, loop);
}
Trigger CommandNiDsStadiaController::Stadia(wpi::EventLoop* loop) const {
return Button(wpi::NiDsStadiaController::Button::kStadia, loop);
return m_hid->Button(
wpi::NiDsStadiaController::Button::kStadia, loop);
}
Trigger CommandNiDsStadiaController::RightTrigger(wpi::EventLoop* loop) const {
return Button(wpi::NiDsStadiaController::Button::kRightTrigger, loop);
return m_hid->Button(
wpi::NiDsStadiaController::Button::kRightTrigger, loop);
}
Trigger CommandNiDsStadiaController::LeftTrigger(wpi::EventLoop* loop) const {
return Button(wpi::NiDsStadiaController::Button::kLeftTrigger, loop);
return m_hid->Button(
wpi::NiDsStadiaController::Button::kLeftTrigger, loop);
}
Trigger CommandNiDsStadiaController::Google(wpi::EventLoop* loop) const {
return Button(wpi::NiDsStadiaController::Button::kGoogle, loop);
return m_hid->Button(
wpi::NiDsStadiaController::Button::kGoogle, loop);
}
Trigger CommandNiDsStadiaController::Frame(wpi::EventLoop* loop) const {
return Button(wpi::NiDsStadiaController::Button::kFrame, loop);
return m_hid->Button(
wpi::NiDsStadiaController::Button::kFrame, loop);
}
double CommandNiDsStadiaController::GetLeftX() const {
return m_hid.GetLeftX();
return m_controller.GetLeftX();
}
double CommandNiDsStadiaController::GetRightX() const {
return m_hid.GetRightX();
return m_controller.GetRightX();
}
double CommandNiDsStadiaController::GetLeftY() const {
return m_hid.GetLeftY();
return m_controller.GetLeftY();
}
double CommandNiDsStadiaController::GetRightY() const {
return m_hid.GetRightY();
return m_controller.GetRightY();
}

View File

@@ -9,86 +9,100 @@
using namespace wpi::cmd;
CommandNiDsXboxController::CommandNiDsXboxController(int port)
: CommandGenericHID(port), m_hid{wpi::NiDsXboxController(port)} {}
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)},
m_controller{m_hid->GetHID()} {}
wpi::NiDsXboxController& CommandNiDsXboxController::GetHID() {
return m_hid;
CommandGenericHID& CommandNiDsXboxController::GetHID() {
return *m_hid;
}
wpi::NiDsXboxController&
CommandNiDsXboxController::GetNiDsXboxController() {
return m_controller;
}
Trigger CommandNiDsXboxController::A(wpi::EventLoop* loop) const {
return Button(wpi::NiDsXboxController::Button::kA, loop);
return m_hid->Button(
wpi::NiDsXboxController::Button::kA, loop);
}
Trigger CommandNiDsXboxController::B(wpi::EventLoop* loop) const {
return Button(wpi::NiDsXboxController::Button::kB, loop);
return m_hid->Button(
wpi::NiDsXboxController::Button::kB, loop);
}
Trigger CommandNiDsXboxController::X(wpi::EventLoop* loop) const {
return Button(wpi::NiDsXboxController::Button::kX, loop);
return m_hid->Button(
wpi::NiDsXboxController::Button::kX, loop);
}
Trigger CommandNiDsXboxController::Y(wpi::EventLoop* loop) const {
return Button(wpi::NiDsXboxController::Button::kY, loop);
return m_hid->Button(
wpi::NiDsXboxController::Button::kY, loop);
}
Trigger CommandNiDsXboxController::LeftBumper(wpi::EventLoop* loop) const {
return Button(wpi::NiDsXboxController::Button::kLeftBumper, loop);
return m_hid->Button(
wpi::NiDsXboxController::Button::kLeftBumper, loop);
}
Trigger CommandNiDsXboxController::RightBumper(wpi::EventLoop* loop) const {
return Button(wpi::NiDsXboxController::Button::kRightBumper, loop);
return m_hid->Button(
wpi::NiDsXboxController::Button::kRightBumper, loop);
}
Trigger CommandNiDsXboxController::Back(wpi::EventLoop* loop) const {
return Button(wpi::NiDsXboxController::Button::kBack, loop);
return m_hid->Button(
wpi::NiDsXboxController::Button::kBack, loop);
}
Trigger CommandNiDsXboxController::Start(wpi::EventLoop* loop) const {
return Button(wpi::NiDsXboxController::Button::kStart, loop);
return m_hid->Button(
wpi::NiDsXboxController::Button::kStart, loop);
}
Trigger CommandNiDsXboxController::LeftStick(wpi::EventLoop* loop) const {
return Button(wpi::NiDsXboxController::Button::kLeftStick, loop);
return m_hid->Button(
wpi::NiDsXboxController::Button::kLeftStick, loop);
}
Trigger CommandNiDsXboxController::RightStick(wpi::EventLoop* loop) const {
return Button(wpi::NiDsXboxController::Button::kRightStick, loop);
return m_hid->Button(
wpi::NiDsXboxController::Button::kRightStick, loop);
}
Trigger CommandNiDsXboxController::LeftTrigger(double threshold,
wpi::EventLoop* loop) const {
return Trigger(loop, [this, threshold] {
return m_hid.GetLeftTriggerAxis() > threshold;
});
return m_hid->AxisGreaterThan(
wpi::NiDsXboxController::Axis::kLeftTrigger, threshold, loop);
}
Trigger CommandNiDsXboxController::RightTrigger(double threshold,
wpi::EventLoop* loop) const {
return Trigger(loop, [this, threshold] {
return m_hid.GetRightTriggerAxis() > threshold;
});
return m_hid->AxisGreaterThan(
wpi::NiDsXboxController::Axis::kRightTrigger, threshold, loop);
}
double CommandNiDsXboxController::GetLeftX() const {
return m_hid.GetLeftX();
return m_controller.GetLeftX();
}
double CommandNiDsXboxController::GetRightX() const {
return m_hid.GetRightX();
return m_controller.GetRightX();
}
double CommandNiDsXboxController::GetLeftY() const {
return m_hid.GetLeftY();
return m_controller.GetLeftY();
}
double CommandNiDsXboxController::GetRightY() const {
return m_hid.GetRightY();
return m_controller.GetRightY();
}
double CommandNiDsXboxController::GetLeftTriggerAxis() const {
return m_hid.GetLeftTriggerAxis();
return m_controller.GetLeftTriggerAxis();
}
double CommandNiDsXboxController::GetRightTriggerAxis() const {
return m_hid.GetRightTriggerAxis();
return m_controller.GetRightTriggerAxis();
}

View File

@@ -0,0 +1,256 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#include "wpi/commands2/button/CommandSteamController.hpp"
using namespace wpi::cmd;
CommandSteamController::CommandSteamController(int port)
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)} {
m_ownedController =
std::make_unique<wpi::SteamController>(m_hid->GetHID());
m_controller = m_ownedController.get();
}
CommandSteamController::CommandSteamController(
wpi::SteamController* controller)
: m_ownedHid{std::make_unique<CommandGenericHID>(controller->GetHID())},
m_hid{m_ownedHid.get()},
m_controller{controller} {}
CommandGenericHID& CommandSteamController::GetHID() {
return *m_hid;
}
wpi::SteamController&
CommandSteamController::GetController() {
return *m_controller;
}
const wpi::SteamController&
CommandSteamController::GetController() const {
return *m_controller;
}
Trigger CommandSteamController::Button(
enum wpi::SteamController::Button button,
wpi::EventLoop* loop) const {
return m_hid->Button(static_cast<int>(button), loop);
}
Trigger CommandSteamController::A(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::A,
loop);
}
Trigger CommandSteamController::B(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::B,
loop);
}
Trigger CommandSteamController::X(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::X,
loop);
}
Trigger CommandSteamController::Y(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::Y,
loop);
}
Trigger CommandSteamController::Menu(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::MENU,
loop);
}
Trigger CommandSteamController::Steam(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::STEAM,
loop);
}
Trigger CommandSteamController::View(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::VIEW,
loop);
}
Trigger CommandSteamController::LeftStick(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::LEFT_STICK,
loop);
}
Trigger CommandSteamController::RightStick(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::RIGHT_STICK,
loop);
}
Trigger CommandSteamController::LeftBumper(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::LEFT_BUMPER,
loop);
}
Trigger CommandSteamController::RightBumper(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::RIGHT_BUMPER,
loop);
}
Trigger CommandSteamController::DpadUp(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::DPAD_UP,
loop);
}
Trigger CommandSteamController::DpadDown(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::DPAD_DOWN,
loop);
}
Trigger CommandSteamController::DpadLeft(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::DPAD_LEFT,
loop);
}
Trigger CommandSteamController::DpadRight(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::DPAD_RIGHT,
loop);
}
Trigger CommandSteamController::QAM(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::QAM,
loop);
}
Trigger CommandSteamController::RightPaddle1(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::RIGHT_PADDLE_1,
loop);
}
Trigger CommandSteamController::LeftPaddle1(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::LEFT_PADDLE_1,
loop);
}
Trigger CommandSteamController::RightPaddle2(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::RIGHT_PADDLE_2,
loop);
}
Trigger CommandSteamController::LeftPaddle2(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::LEFT_PADDLE_2,
loop);
}
Trigger CommandSteamController::LeftTouchpad(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::LEFT_TOUCHPAD,
loop);
}
Trigger CommandSteamController::RightTouchpad(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::RIGHT_TOUCHPAD,
loop);
}
Trigger CommandSteamController::LeftStickTouch(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::LEFT_STICK_TOUCH,
loop);
}
Trigger CommandSteamController::RightStickTouch(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::RIGHT_STICK_TOUCH,
loop);
}
Trigger CommandSteamController::LeftGripTouch(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::LEFT_GRIP_TOUCH,
loop);
}
Trigger CommandSteamController::RightGripTouch(
wpi::EventLoop* loop) const {
return Button(wpi::SteamController::Button::RIGHT_GRIP_TOUCH,
loop);
}
Trigger CommandSteamController::LeftTrigger(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::SteamController::Axis::LEFT_TRIGGER,
threshold, loop);
}
Trigger CommandSteamController::RightTrigger(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::SteamController::Axis::RIGHT_TRIGGER,
threshold, loop);
}
Trigger CommandSteamController::AxisLessThan(
wpi::SteamController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisLessThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandSteamController::AxisGreaterThan(
wpi::SteamController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisGreaterThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandSteamController::AxisMagnitudeGreaterThan(
wpi::SteamController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisMagnitudeGreaterThan(static_cast<int>(axis), threshold,
loop);
}
double CommandSteamController::GetLeftX() const {
return m_controller->GetLeftX();
}
double CommandSteamController::GetLeftY() const {
return m_controller->GetLeftY();
}
double CommandSteamController::GetRightX() const {
return m_controller->GetRightX();
}
double CommandSteamController::GetRightY() const {
return m_controller->GetRightY();
}
double CommandSteamController::GetLeftTrigger() const {
return m_controller->GetLeftTrigger();
}
double CommandSteamController::GetRightTrigger() const {
return m_controller->GetRightTrigger();
}

View File

@@ -0,0 +1,196 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#include "wpi/commands2/button/CommandSwitch2GCController.hpp"
using namespace wpi::cmd;
CommandSwitch2GCController::CommandSwitch2GCController(int port)
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)} {
m_ownedController =
std::make_unique<wpi::Switch2GCController>(m_hid->GetHID());
m_controller = m_ownedController.get();
}
CommandSwitch2GCController::CommandSwitch2GCController(
wpi::Switch2GCController* controller)
: m_ownedHid{std::make_unique<CommandGenericHID>(controller->GetHID())},
m_hid{m_ownedHid.get()},
m_controller{controller} {}
CommandGenericHID& CommandSwitch2GCController::GetHID() {
return *m_hid;
}
wpi::Switch2GCController&
CommandSwitch2GCController::GetController() {
return *m_controller;
}
const wpi::Switch2GCController&
CommandSwitch2GCController::GetController() const {
return *m_controller;
}
Trigger CommandSwitch2GCController::Button(
enum wpi::Switch2GCController::Button button,
wpi::EventLoop* loop) const {
return m_hid->Button(static_cast<int>(button), loop);
}
Trigger CommandSwitch2GCController::A(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::A,
loop);
}
Trigger CommandSwitch2GCController::X(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::X,
loop);
}
Trigger CommandSwitch2GCController::B(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::B,
loop);
}
Trigger CommandSwitch2GCController::Y(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::Y,
loop);
}
Trigger CommandSwitch2GCController::Home(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::HOME,
loop);
}
Trigger CommandSwitch2GCController::Start(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::START,
loop);
}
Trigger CommandSwitch2GCController::ZL(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::ZL,
loop);
}
Trigger CommandSwitch2GCController::Z(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::Z,
loop);
}
Trigger CommandSwitch2GCController::DpadUp(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::DPAD_UP,
loop);
}
Trigger CommandSwitch2GCController::DpadDown(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::DPAD_DOWN,
loop);
}
Trigger CommandSwitch2GCController::DpadLeft(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::DPAD_LEFT,
loop);
}
Trigger CommandSwitch2GCController::DpadRight(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::DPAD_RIGHT,
loop);
}
Trigger CommandSwitch2GCController::Capture(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::CAPTURE,
loop);
}
Trigger CommandSwitch2GCController::C(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::C,
loop);
}
Trigger CommandSwitch2GCController::L(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::L,
loop);
}
Trigger CommandSwitch2GCController::R(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2GCController::Button::R,
loop);
}
Trigger CommandSwitch2GCController::LTrigger(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::Switch2GCController::Axis::L_TRIGGER,
threshold, loop);
}
Trigger CommandSwitch2GCController::RTrigger(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::Switch2GCController::Axis::R_TRIGGER,
threshold, loop);
}
Trigger CommandSwitch2GCController::AxisLessThan(
wpi::Switch2GCController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisLessThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandSwitch2GCController::AxisGreaterThan(
wpi::Switch2GCController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisGreaterThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandSwitch2GCController::AxisMagnitudeGreaterThan(
wpi::Switch2GCController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisMagnitudeGreaterThan(static_cast<int>(axis), threshold,
loop);
}
double CommandSwitch2GCController::GetLeftX() const {
return m_controller->GetLeftX();
}
double CommandSwitch2GCController::GetLeftY() const {
return m_controller->GetLeftY();
}
double CommandSwitch2GCController::GetCStickX() const {
return m_controller->GetCStickX();
}
double CommandSwitch2GCController::GetCStickY() const {
return m_controller->GetCStickY();
}
double CommandSwitch2GCController::GetLTrigger() const {
return m_controller->GetLTrigger();
}
double CommandSwitch2GCController::GetRTrigger() const {
return m_controller->GetRTrigger();
}

View File

@@ -0,0 +1,214 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#include "wpi/commands2/button/CommandSwitch2ProController.hpp"
using namespace wpi::cmd;
CommandSwitch2ProController::CommandSwitch2ProController(int port)
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)} {
m_ownedController =
std::make_unique<wpi::Switch2ProController>(m_hid->GetHID());
m_controller = m_ownedController.get();
}
CommandSwitch2ProController::CommandSwitch2ProController(
wpi::Switch2ProController* controller)
: m_ownedHid{std::make_unique<CommandGenericHID>(controller->GetHID())},
m_hid{m_ownedHid.get()},
m_controller{controller} {}
CommandGenericHID& CommandSwitch2ProController::GetHID() {
return *m_hid;
}
wpi::Switch2ProController&
CommandSwitch2ProController::GetController() {
return *m_controller;
}
const wpi::Switch2ProController&
CommandSwitch2ProController::GetController() const {
return *m_controller;
}
Trigger CommandSwitch2ProController::Button(
enum wpi::Switch2ProController::Button button,
wpi::EventLoop* loop) const {
return m_hid->Button(static_cast<int>(button), loop);
}
Trigger CommandSwitch2ProController::B(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::B,
loop);
}
Trigger CommandSwitch2ProController::A(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::A,
loop);
}
Trigger CommandSwitch2ProController::Y(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::Y,
loop);
}
Trigger CommandSwitch2ProController::X(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::X,
loop);
}
Trigger CommandSwitch2ProController::Minus(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::MINUS,
loop);
}
Trigger CommandSwitch2ProController::Home(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::HOME,
loop);
}
Trigger CommandSwitch2ProController::Plus(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::PLUS,
loop);
}
Trigger CommandSwitch2ProController::LeftStick(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::LEFT_STICK,
loop);
}
Trigger CommandSwitch2ProController::RightStick(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::RIGHT_STICK,
loop);
}
Trigger CommandSwitch2ProController::L(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::L,
loop);
}
Trigger CommandSwitch2ProController::R(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::R,
loop);
}
Trigger CommandSwitch2ProController::DpadUp(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::DPAD_UP,
loop);
}
Trigger CommandSwitch2ProController::DpadDown(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::DPAD_DOWN,
loop);
}
Trigger CommandSwitch2ProController::DpadLeft(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::DPAD_LEFT,
loop);
}
Trigger CommandSwitch2ProController::DpadRight(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::DPAD_RIGHT,
loop);
}
Trigger CommandSwitch2ProController::Capture(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::CAPTURE,
loop);
}
Trigger CommandSwitch2ProController::GR(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::GR,
loop);
}
Trigger CommandSwitch2ProController::GL(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::GL,
loop);
}
Trigger CommandSwitch2ProController::C(
wpi::EventLoop* loop) const {
return Button(wpi::Switch2ProController::Button::C,
loop);
}
Trigger CommandSwitch2ProController::ZL(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::Switch2ProController::Axis::ZL,
threshold, loop);
}
Trigger CommandSwitch2ProController::ZR(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::Switch2ProController::Axis::ZR,
threshold, loop);
}
Trigger CommandSwitch2ProController::AxisLessThan(
wpi::Switch2ProController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisLessThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandSwitch2ProController::AxisGreaterThan(
wpi::Switch2ProController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisGreaterThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandSwitch2ProController::AxisMagnitudeGreaterThan(
wpi::Switch2ProController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisMagnitudeGreaterThan(static_cast<int>(axis), threshold,
loop);
}
double CommandSwitch2ProController::GetLeftX() const {
return m_controller->GetLeftX();
}
double CommandSwitch2ProController::GetLeftY() const {
return m_controller->GetLeftY();
}
double CommandSwitch2ProController::GetRightX() const {
return m_controller->GetRightX();
}
double CommandSwitch2ProController::GetRightY() const {
return m_controller->GetRightY();
}
double CommandSwitch2ProController::GetZL() const {
return m_controller->GetZL();
}
double CommandSwitch2ProController::GetZR() const {
return m_controller->GetZR();
}

View File

@@ -0,0 +1,175 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#include "wpi/commands2/button/CommandSwitchN64Controller.hpp"
using namespace wpi::cmd;
CommandSwitchN64Controller::CommandSwitchN64Controller(int port)
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)} {
m_ownedController =
std::make_unique<wpi::SwitchN64Controller>(m_hid->GetHID());
m_controller = m_ownedController.get();
}
CommandSwitchN64Controller::CommandSwitchN64Controller(
wpi::SwitchN64Controller* controller)
: m_ownedHid{std::make_unique<CommandGenericHID>(controller->GetHID())},
m_hid{m_ownedHid.get()},
m_controller{controller} {}
CommandGenericHID& CommandSwitchN64Controller::GetHID() {
return *m_hid;
}
wpi::SwitchN64Controller&
CommandSwitchN64Controller::GetController() {
return *m_controller;
}
const wpi::SwitchN64Controller&
CommandSwitchN64Controller::GetController() const {
return *m_controller;
}
Trigger CommandSwitchN64Controller::Button(
enum wpi::SwitchN64Controller::Button button,
wpi::EventLoop* loop) const {
return m_hid->Button(static_cast<int>(button), loop);
}
Trigger CommandSwitchN64Controller::A(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchN64Controller::Button::A,
loop);
}
Trigger CommandSwitchN64Controller::B(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchN64Controller::Button::B,
loop);
}
Trigger CommandSwitchN64Controller::CLeft(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchN64Controller::Button::C_LEFT,
loop);
}
Trigger CommandSwitchN64Controller::CUp(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchN64Controller::Button::C_UP,
loop);
}
Trigger CommandSwitchN64Controller::Capture(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchN64Controller::Button::CAPTURE,
loop);
}
Trigger CommandSwitchN64Controller::Home(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchN64Controller::Button::HOME,
loop);
}
Trigger CommandSwitchN64Controller::Start(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchN64Controller::Button::START,
loop);
}
Trigger CommandSwitchN64Controller::CDown(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchN64Controller::Button::C_DOWN,
loop);
}
Trigger CommandSwitchN64Controller::L(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchN64Controller::Button::L,
loop);
}
Trigger CommandSwitchN64Controller::R(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchN64Controller::Button::R,
loop);
}
Trigger CommandSwitchN64Controller::DpadUp(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchN64Controller::Button::DPAD_UP,
loop);
}
Trigger CommandSwitchN64Controller::DpadDown(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchN64Controller::Button::DPAD_DOWN,
loop);
}
Trigger CommandSwitchN64Controller::DpadLeft(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchN64Controller::Button::DPAD_LEFT,
loop);
}
Trigger CommandSwitchN64Controller::DpadRight(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchN64Controller::Button::DPAD_RIGHT,
loop);
}
Trigger CommandSwitchN64Controller::CRight(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchN64Controller::Button::C_RIGHT,
loop);
}
Trigger CommandSwitchN64Controller::ZR(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::SwitchN64Controller::Axis::ZR,
threshold, loop);
}
Trigger CommandSwitchN64Controller::AxisLessThan(
wpi::SwitchN64Controller::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisLessThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandSwitchN64Controller::AxisGreaterThan(
wpi::SwitchN64Controller::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisGreaterThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandSwitchN64Controller::AxisMagnitudeGreaterThan(
wpi::SwitchN64Controller::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisMagnitudeGreaterThan(static_cast<int>(axis), threshold,
loop);
}
double CommandSwitchN64Controller::GetLeftX() const {
return m_controller->GetLeftX();
}
double CommandSwitchN64Controller::GetLeftY() const {
return m_controller->GetLeftY();
}
double CommandSwitchN64Controller::GetZAxis() const {
return m_controller->GetZAxis();
}
double CommandSwitchN64Controller::GetZR() const {
return m_controller->GetZR();
}

View File

@@ -0,0 +1,196 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#include "wpi/commands2/button/CommandSwitchProController.hpp"
using namespace wpi::cmd;
CommandSwitchProController::CommandSwitchProController(int port)
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)} {
m_ownedController =
std::make_unique<wpi::SwitchProController>(m_hid->GetHID());
m_controller = m_ownedController.get();
}
CommandSwitchProController::CommandSwitchProController(
wpi::SwitchProController* controller)
: m_ownedHid{std::make_unique<CommandGenericHID>(controller->GetHID())},
m_hid{m_ownedHid.get()},
m_controller{controller} {}
CommandGenericHID& CommandSwitchProController::GetHID() {
return *m_hid;
}
wpi::SwitchProController&
CommandSwitchProController::GetController() {
return *m_controller;
}
const wpi::SwitchProController&
CommandSwitchProController::GetController() const {
return *m_controller;
}
Trigger CommandSwitchProController::Button(
enum wpi::SwitchProController::Button button,
wpi::EventLoop* loop) const {
return m_hid->Button(static_cast<int>(button), loop);
}
Trigger CommandSwitchProController::B(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::B,
loop);
}
Trigger CommandSwitchProController::A(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::A,
loop);
}
Trigger CommandSwitchProController::Y(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::Y,
loop);
}
Trigger CommandSwitchProController::X(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::X,
loop);
}
Trigger CommandSwitchProController::Minus(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::MINUS,
loop);
}
Trigger CommandSwitchProController::Home(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::HOME,
loop);
}
Trigger CommandSwitchProController::Plus(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::PLUS,
loop);
}
Trigger CommandSwitchProController::LeftStick(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::LEFT_STICK,
loop);
}
Trigger CommandSwitchProController::RightStick(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::RIGHT_STICK,
loop);
}
Trigger CommandSwitchProController::L(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::L,
loop);
}
Trigger CommandSwitchProController::R(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::R,
loop);
}
Trigger CommandSwitchProController::DpadUp(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::DPAD_UP,
loop);
}
Trigger CommandSwitchProController::DpadDown(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::DPAD_DOWN,
loop);
}
Trigger CommandSwitchProController::DpadLeft(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::DPAD_LEFT,
loop);
}
Trigger CommandSwitchProController::DpadRight(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::DPAD_RIGHT,
loop);
}
Trigger CommandSwitchProController::Capture(
wpi::EventLoop* loop) const {
return Button(wpi::SwitchProController::Button::CAPTURE,
loop);
}
Trigger CommandSwitchProController::ZL(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::SwitchProController::Axis::ZL,
threshold, loop);
}
Trigger CommandSwitchProController::ZR(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::SwitchProController::Axis::ZR,
threshold, loop);
}
Trigger CommandSwitchProController::AxisLessThan(
wpi::SwitchProController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisLessThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandSwitchProController::AxisGreaterThan(
wpi::SwitchProController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisGreaterThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandSwitchProController::AxisMagnitudeGreaterThan(
wpi::SwitchProController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisMagnitudeGreaterThan(static_cast<int>(axis), threshold,
loop);
}
double CommandSwitchProController::GetLeftX() const {
return m_controller->GetLeftX();
}
double CommandSwitchProController::GetLeftY() const {
return m_controller->GetLeftY();
}
double CommandSwitchProController::GetRightX() const {
return m_controller->GetRightX();
}
double CommandSwitchProController::GetRightY() const {
return m_controller->GetRightY();
}
double CommandSwitchProController::GetZL() const {
return m_controller->GetZL();
}
double CommandSwitchProController::GetZR() const {
return m_controller->GetZR();
}

View File

@@ -0,0 +1,190 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#include "wpi/commands2/button/CommandXboxController.hpp"
using namespace wpi::cmd;
CommandXboxController::CommandXboxController(int port)
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)} {
m_ownedController =
std::make_unique<wpi::XboxController>(m_hid->GetHID());
m_controller = m_ownedController.get();
}
CommandXboxController::CommandXboxController(
wpi::XboxController* controller)
: m_ownedHid{std::make_unique<CommandGenericHID>(controller->GetHID())},
m_hid{m_ownedHid.get()},
m_controller{controller} {}
CommandGenericHID& CommandXboxController::GetHID() {
return *m_hid;
}
wpi::XboxController&
CommandXboxController::GetController() {
return *m_controller;
}
const wpi::XboxController&
CommandXboxController::GetController() const {
return *m_controller;
}
Trigger CommandXboxController::Button(
enum wpi::XboxController::Button button,
wpi::EventLoop* loop) const {
return m_hid->Button(static_cast<int>(button), loop);
}
Trigger CommandXboxController::A(
wpi::EventLoop* loop) const {
return Button(wpi::XboxController::Button::A,
loop);
}
Trigger CommandXboxController::B(
wpi::EventLoop* loop) const {
return Button(wpi::XboxController::Button::B,
loop);
}
Trigger CommandXboxController::X(
wpi::EventLoop* loop) const {
return Button(wpi::XboxController::Button::X,
loop);
}
Trigger CommandXboxController::Y(
wpi::EventLoop* loop) const {
return Button(wpi::XboxController::Button::Y,
loop);
}
Trigger CommandXboxController::View(
wpi::EventLoop* loop) const {
return Button(wpi::XboxController::Button::VIEW,
loop);
}
Trigger CommandXboxController::Xbox(
wpi::EventLoop* loop) const {
return Button(wpi::XboxController::Button::XBOX,
loop);
}
Trigger CommandXboxController::Menu(
wpi::EventLoop* loop) const {
return Button(wpi::XboxController::Button::MENU,
loop);
}
Trigger CommandXboxController::LeftStick(
wpi::EventLoop* loop) const {
return Button(wpi::XboxController::Button::LEFT_STICK,
loop);
}
Trigger CommandXboxController::RightStick(
wpi::EventLoop* loop) const {
return Button(wpi::XboxController::Button::RIGHT_STICK,
loop);
}
Trigger CommandXboxController::LeftBumper(
wpi::EventLoop* loop) const {
return Button(wpi::XboxController::Button::LEFT_BUMPER,
loop);
}
Trigger CommandXboxController::RightBumper(
wpi::EventLoop* loop) const {
return Button(wpi::XboxController::Button::RIGHT_BUMPER,
loop);
}
Trigger CommandXboxController::DpadUp(
wpi::EventLoop* loop) const {
return Button(wpi::XboxController::Button::DPAD_UP,
loop);
}
Trigger CommandXboxController::DpadDown(
wpi::EventLoop* loop) const {
return Button(wpi::XboxController::Button::DPAD_DOWN,
loop);
}
Trigger CommandXboxController::DpadLeft(
wpi::EventLoop* loop) const {
return Button(wpi::XboxController::Button::DPAD_LEFT,
loop);
}
Trigger CommandXboxController::DpadRight(
wpi::EventLoop* loop) const {
return Button(wpi::XboxController::Button::DPAD_RIGHT,
loop);
}
Trigger CommandXboxController::LeftTrigger(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::XboxController::Axis::LEFT_TRIGGER,
threshold, loop);
}
Trigger CommandXboxController::RightTrigger(
double threshold, wpi::EventLoop* loop) const {
return AxisGreaterThan(
wpi::XboxController::Axis::RIGHT_TRIGGER,
threshold, loop);
}
Trigger CommandXboxController::AxisLessThan(
wpi::XboxController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisLessThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandXboxController::AxisGreaterThan(
wpi::XboxController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisGreaterThan(static_cast<int>(axis), threshold, loop);
}
Trigger CommandXboxController::AxisMagnitudeGreaterThan(
wpi::XboxController::Axis axis, double threshold,
wpi::EventLoop* loop) const {
return m_hid->AxisMagnitudeGreaterThan(static_cast<int>(axis), threshold,
loop);
}
double CommandXboxController::GetLeftX() const {
return m_controller->GetLeftX();
}
double CommandXboxController::GetLeftY() const {
return m_controller->GetLeftY();
}
double CommandXboxController::GetRightX() const {
return m_controller->GetRightX();
}
double CommandXboxController::GetRightY() const {
return m_controller->GetRightY();
}
double CommandXboxController::GetLeftTrigger() const {
return m_controller->GetLeftTrigger();
}
double CommandXboxController::GetRightTrigger() const {
return m_controller->GetRightTrigger();
}

View File

@@ -0,0 +1,432 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#pragma once
#include <memory>
#include "wpi/driverstation/DualSenseController.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/commands2/button/Trigger.hpp"
namespace wpi::cmd {
/**
* A version of {@link wpi::DualSenseController} with {@link Trigger}
* factories for command-based.
*
* @see wpi::DualSenseController
*/
class CommandDualSenseController {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit CommandDualSenseController(int port);
/**
* Construct an instance of a controller with a DualSenseController object.
*
* @param controller The DualSenseController object to use for this controller.
*/
explicit CommandDualSenseController(wpi::DualSenseController* controller);
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
CommandGenericHID& GetHID();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
wpi::DualSenseController& GetController();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
const wpi::DualSenseController& GetController() const;
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @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(enum wpi::DualSenseController::Button button,
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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(
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger 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 a Trigger instance representing the PS button's
* digital signal attached to the given loop.
*/
Trigger PS(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the L 3 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 L 3 button's
* digital signal attached to the given loop.
*/
Trigger L3(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the R 3 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 R 3 button's
* digital signal attached to the given loop.
*/
Trigger R3(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the L 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 L 1 button's
* digital signal attached to the given loop.
*/
Trigger L1(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the R 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 R 1 button's
* digital signal attached to the given loop.
*/
Trigger R1(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's
* digital signal attached to the given loop.
*/
Trigger DpadUp(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's
* digital signal attached to the given loop.
*/
Trigger DpadDown(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's
* digital signal attached to the given loop.
*/
Trigger DpadLeft(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's
* digital signal attached to the given loop.
*/
Trigger DpadRight(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Microphone 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 Microphone button's
* digital signal attached to the given loop.
*/
Trigger Microphone(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the axis value of the
* L 2. The returned Trigger will be true when the axis value
* is greater than 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 L 2 axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger L2(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the axis value of the
* R 2. The returned Trigger will be true when the axis value
* is greater than 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 R 2 axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger R2(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is less than
* {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read, starting at 0.
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is less than
* the provided threshold.
*/
Trigger AxisLessThan(
wpi::DualSenseController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is greater
* than {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is greater than
* the provided threshold.
*/
Trigger AxisGreaterThan(
wpi::DualSenseController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis magnitude value is
* greater than {@code threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is
* greater than the provided threshold.
*/
Trigger AxisMagnitudeGreaterThan(
wpi::DualSenseController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Get the Left X value of the controller.
*
* @return the axis value.
*/
double GetLeftX() const;
/**
* Get the Left Y value of the controller.
*
* @return the axis value.
*/
double GetLeftY() const;
/**
* Get the Right X value of the controller.
*
* @return the axis value.
*/
double GetRightX() const;
/**
* Get the Right Y value of the controller.
*
* @return the axis value.
*/
double GetRightY() const;
/**
* Get the L 2 value of the controller.
*
* @return the axis value.
*/
double GetL2() const;
/**
* Get the R 2 value of the controller.
*
* @return the axis value.
*/
double GetR2() const;
private:
std::unique_ptr<CommandGenericHID> m_ownedHid;
CommandGenericHID* m_hid = nullptr;
std::unique_ptr<wpi::DualSenseController> m_ownedController;
wpi::DualSenseController* m_controller = nullptr;
};
} // namespace wpi::cmd

View File

@@ -0,0 +1,484 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#pragma once
#include <memory>
#include "wpi/driverstation/DualSenseEdgeController.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/commands2/button/Trigger.hpp"
namespace wpi::cmd {
/**
* A version of {@link wpi::DualSenseEdgeController} with {@link Trigger}
* factories for command-based.
*
* @see wpi::DualSenseEdgeController
*/
class CommandDualSenseEdgeController {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit CommandDualSenseEdgeController(int port);
/**
* Construct an instance of a controller with a DualSenseEdgeController object.
*
* @param controller The DualSenseEdgeController object to use for this controller.
*/
explicit CommandDualSenseEdgeController(wpi::DualSenseEdgeController* controller);
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
CommandGenericHID& GetHID();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
wpi::DualSenseEdgeController& GetController();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
const wpi::DualSenseEdgeController& GetController() const;
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @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(enum wpi::DualSenseEdgeController::Button button,
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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(
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger 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 a Trigger instance representing the PS button's
* digital signal attached to the given loop.
*/
Trigger PS(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the L 3 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 L 3 button's
* digital signal attached to the given loop.
*/
Trigger L3(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the R 3 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 R 3 button's
* digital signal attached to the given loop.
*/
Trigger R3(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the L 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 L 1 button's
* digital signal attached to the given loop.
*/
Trigger L1(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the R 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 R 1 button's
* digital signal attached to the given loop.
*/
Trigger R1(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's
* digital signal attached to the given loop.
*/
Trigger DpadUp(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's
* digital signal attached to the given loop.
*/
Trigger DpadDown(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's
* digital signal attached to the given loop.
*/
Trigger DpadLeft(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's
* digital signal attached to the given loop.
*/
Trigger DpadRight(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Microphone 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 Microphone button's
* digital signal attached to the given loop.
*/
Trigger Microphone(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Right Paddle 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 Paddle 1 button's
* digital signal attached to the given loop.
*/
Trigger RightPaddle1(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Left Paddle 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 Paddle 1 button's
* digital signal attached to the given loop.
*/
Trigger LeftPaddle1(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Left Function 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 Function button's
* digital signal attached to the given loop.
*/
Trigger LeftFunction(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Right Function 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 Function button's
* digital signal attached to the given loop.
*/
Trigger RightFunction(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the axis value of the
* L 2. The returned Trigger will be true when the axis value
* is greater than 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 L 2 axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger L2(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the axis value of the
* R 2. The returned Trigger will be true when the axis value
* is greater than 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 R 2 axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger R2(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is less than
* {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read, starting at 0.
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is less than
* the provided threshold.
*/
Trigger AxisLessThan(
wpi::DualSenseEdgeController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is greater
* than {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is greater than
* the provided threshold.
*/
Trigger AxisGreaterThan(
wpi::DualSenseEdgeController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis magnitude value is
* greater than {@code threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is
* greater than the provided threshold.
*/
Trigger AxisMagnitudeGreaterThan(
wpi::DualSenseEdgeController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Get the Left X value of the controller.
*
* @return the axis value.
*/
double GetLeftX() const;
/**
* Get the Left Y value of the controller.
*
* @return the axis value.
*/
double GetLeftY() const;
/**
* Get the Right X value of the controller.
*
* @return the axis value.
*/
double GetRightX() const;
/**
* Get the Right Y value of the controller.
*
* @return the axis value.
*/
double GetRightY() const;
/**
* Get the L 2 value of the controller.
*
* @return the axis value.
*/
double GetL2() const;
/**
* Get the R 2 value of the controller.
*
* @return the axis value.
*/
double GetR2() const;
private:
std::unique_ptr<CommandGenericHID> m_ownedHid;
CommandGenericHID* m_hid = nullptr;
std::unique_ptr<wpi::DualSenseEdgeController> m_ownedController;
wpi::DualSenseEdgeController* m_controller = nullptr;
};
} // namespace wpi::cmd

View File

@@ -0,0 +1,419 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#pragma once
#include <memory>
#include "wpi/driverstation/DualShock4Controller.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/commands2/button/Trigger.hpp"
namespace wpi::cmd {
/**
* A version of {@link wpi::DualShock4Controller} with {@link Trigger}
* factories for command-based.
*
* @see wpi::DualShock4Controller
*/
class CommandDualShock4Controller {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit CommandDualShock4Controller(int port);
/**
* Construct an instance of a controller with a DualShock4Controller object.
*
* @param controller The DualShock4Controller object to use for this controller.
*/
explicit CommandDualShock4Controller(wpi::DualShock4Controller* controller);
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
CommandGenericHID& GetHID();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
wpi::DualShock4Controller& GetController();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
const wpi::DualShock4Controller& GetController() const;
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @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(enum wpi::DualShock4Controller::Button button,
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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(
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger 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 a Trigger instance representing the PS button's
* digital signal attached to the given loop.
*/
Trigger PS(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the L 3 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 L 3 button's
* digital signal attached to the given loop.
*/
Trigger L3(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the R 3 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 R 3 button's
* digital signal attached to the given loop.
*/
Trigger R3(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the L 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 L 1 button's
* digital signal attached to the given loop.
*/
Trigger L1(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the R 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 R 1 button's
* digital signal attached to the given loop.
*/
Trigger R1(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's
* digital signal attached to the given loop.
*/
Trigger DpadUp(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's
* digital signal attached to the given loop.
*/
Trigger DpadDown(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's
* digital signal attached to the given loop.
*/
Trigger DpadLeft(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's
* digital signal attached to the given loop.
*/
Trigger DpadRight(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the axis value of the
* L 2. The returned Trigger will be true when the axis value
* is greater than 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 L 2 axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger L2(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the axis value of the
* R 2. The returned Trigger will be true when the axis value
* is greater than 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 R 2 axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger R2(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is less than
* {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read, starting at 0.
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is less than
* the provided threshold.
*/
Trigger AxisLessThan(
wpi::DualShock4Controller::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is greater
* than {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is greater than
* the provided threshold.
*/
Trigger AxisGreaterThan(
wpi::DualShock4Controller::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis magnitude value is
* greater than {@code threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is
* greater than the provided threshold.
*/
Trigger AxisMagnitudeGreaterThan(
wpi::DualShock4Controller::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Get the Left X value of the controller.
*
* @return the axis value.
*/
double GetLeftX() const;
/**
* Get the Left Y value of the controller.
*
* @return the axis value.
*/
double GetLeftY() const;
/**
* Get the Right X value of the controller.
*
* @return the axis value.
*/
double GetRightX() const;
/**
* Get the Right Y value of the controller.
*
* @return the axis value.
*/
double GetRightY() const;
/**
* Get the L 2 value of the controller.
*
* @return the axis value.
*/
double GetL2() const;
/**
* Get the R 2 value of the controller.
*
* @return the axis value.
*/
double GetR2() const;
private:
std::unique_ptr<CommandGenericHID> m_ownedHid;
CommandGenericHID* m_hid = nullptr;
std::unique_ptr<wpi::DualShock4Controller> m_ownedController;
wpi::DualShock4Controller* m_controller = nullptr;
};
} // namespace wpi::cmd

View File

@@ -0,0 +1,367 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#pragma once
#include <memory>
#include "wpi/driverstation/GameCubeController.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/commands2/button/Trigger.hpp"
namespace wpi::cmd {
/**
* A version of {@link wpi::GameCubeController} with {@link Trigger}
* factories for command-based.
*
* @see wpi::GameCubeController
*/
class CommandGameCubeController {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit CommandGameCubeController(int port);
/**
* Construct an instance of a controller with a GameCubeController object.
*
* @param controller The GameCubeController object to use for this controller.
*/
explicit CommandGameCubeController(wpi::GameCubeController* controller);
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
CommandGenericHID& GetHID();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
wpi::GameCubeController& GetController();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
const wpi::GameCubeController& GetController() const;
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @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(enum wpi::GameCubeController::Button button,
wpi::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* 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(
wpi::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(
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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 a Trigger instance representing the Start button's
* digital signal attached to the given loop.
*/
Trigger Start(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Z 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 Z button's
* digital signal attached to the given loop.
*/
Trigger Z(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's
* digital signal attached to the given loop.
*/
Trigger DpadUp(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's
* digital signal attached to the given loop.
*/
Trigger DpadDown(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's
* digital signal attached to the given loop.
*/
Trigger DpadLeft(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's
* digital signal attached to the given loop.
*/
Trigger DpadRight(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the L 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 L button's
* digital signal attached to the given loop.
*/
Trigger L(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the R 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 R button's
* digital signal attached to the given loop.
*/
Trigger R(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the axis value of the
* L Trigger. The returned Trigger will be true when the axis value
* is greater than 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 L Trigger axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger LTrigger(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the axis value of the
* R Trigger. The returned Trigger will be true when the axis value
* is greater than 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 R Trigger axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger RTrigger(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is less than
* {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read, starting at 0.
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is less than
* the provided threshold.
*/
Trigger AxisLessThan(
wpi::GameCubeController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is greater
* than {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is greater than
* the provided threshold.
*/
Trigger AxisGreaterThan(
wpi::GameCubeController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis magnitude value is
* greater than {@code threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is
* greater than the provided threshold.
*/
Trigger AxisMagnitudeGreaterThan(
wpi::GameCubeController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Get the Left X value of the controller.
*
* @return the axis value.
*/
double GetLeftX() const;
/**
* Get the Left Y value of the controller.
*
* @return the axis value.
*/
double GetLeftY() const;
/**
* Get the C Stick X value of the controller.
*
* @return the axis value.
*/
double GetCStickX() const;
/**
* Get the C Stick Y value of the controller.
*
* @return the axis value.
*/
double GetCStickY() const;
/**
* Get the L Trigger value of the controller.
*
* @return the axis value.
*/
double GetLTrigger() const;
/**
* Get the R Trigger value of the controller.
*
* @return the axis value.
*/
double GetRTrigger() const;
private:
std::unique_ptr<CommandGenericHID> m_ownedHid;
CommandGenericHID* m_hid = nullptr;
std::unique_ptr<wpi::GameCubeController> m_ownedController;
wpi::GameCubeController* m_controller = nullptr;
};
} // namespace wpi::cmd

View File

@@ -0,0 +1,406 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#pragma once
#include <memory>
#include "wpi/driverstation/LogitechF310Controller.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/commands2/button/Trigger.hpp"
namespace wpi::cmd {
/**
* A version of {@link wpi::LogitechF310Controller} with {@link Trigger}
* factories for command-based.
*
* @see wpi::LogitechF310Controller
*/
class CommandLogitechF310Controller {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit CommandLogitechF310Controller(int port);
/**
* Construct an instance of a controller with a LogitechF310Controller object.
*
* @param controller The LogitechF310Controller object to use for this controller.
*/
explicit CommandLogitechF310Controller(wpi::LogitechF310Controller* controller);
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
CommandGenericHID& GetHID();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
wpi::LogitechF310Controller& GetController();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
const wpi::LogitechF310Controller& GetController() const;
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @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(enum wpi::LogitechF310Controller::Button button,
wpi::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* 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(
wpi::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(
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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 a Trigger instance representing the Back button's
* digital signal attached to the given loop.
*/
Trigger Back(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Logitech 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 Logitech button's
* digital signal attached to the given loop.
*/
Trigger Logitech(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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 a Trigger instance representing the Start button's
* digital signal attached to the given loop.
*/
Trigger Start(
wpi::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(
wpi::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(
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's
* digital signal attached to the given loop.
*/
Trigger DpadUp(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's
* digital signal attached to the given loop.
*/
Trigger DpadDown(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's
* digital signal attached to the given loop.
*/
Trigger DpadLeft(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's
* digital signal attached to the given loop.
*/
Trigger DpadRight(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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 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 Left Trigger axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger LeftTrigger(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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 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 Right Trigger axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger RightTrigger(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is less than
* {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read, starting at 0.
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is less than
* the provided threshold.
*/
Trigger AxisLessThan(
wpi::LogitechF310Controller::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is greater
* than {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is greater than
* the provided threshold.
*/
Trigger AxisGreaterThan(
wpi::LogitechF310Controller::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis magnitude value is
* greater than {@code threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is
* greater than the provided threshold.
*/
Trigger AxisMagnitudeGreaterThan(
wpi::LogitechF310Controller::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Get the Left X value of the controller.
*
* @return the axis value.
*/
double GetLeftX() const;
/**
* Get the Left Y value of the controller.
*
* @return the axis value.
*/
double GetLeftY() const;
/**
* Get the Right X value of the controller.
*
* @return the axis value.
*/
double GetRightX() const;
/**
* Get the Right Y value of the controller.
*
* @return the axis value.
*/
double GetRightY() const;
/**
* Get the Left Trigger value of the controller.
*
* @return the axis value.
*/
double GetLeftTrigger() const;
/**
* Get the Right Trigger value of the controller.
*
* @return the axis value.
*/
double GetRightTrigger() const;
private:
std::unique_ptr<CommandGenericHID> m_ownedHid;
CommandGenericHID* m_hid = nullptr;
std::unique_ptr<wpi::LogitechF310Controller> m_ownedController;
wpi::LogitechF310Controller* m_controller = nullptr;
};
} // namespace wpi::cmd

View File

@@ -6,11 +6,10 @@
#pragma once
#include "wpi/driverstation/NiDsPS4Controller.hpp"
#include "wpi/commands2/button/Trigger.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/Trigger.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/driverstation/NiDsPS4Controller.hpp"
namespace wpi::cmd {
/**
@@ -19,7 +18,7 @@ namespace wpi::cmd {
*
* @see wpi::NiDsPS4Controller
*/
class CommandNiDsPS4Controller : public CommandGenericHID {
class CommandNiDsPS4Controller {
public:
/**
* Construct an instance of a controller.
@@ -30,11 +29,18 @@ class CommandNiDsPS4Controller : public CommandGenericHID {
explicit CommandNiDsPS4Controller(int port);
/**
* Get the underlying GenericHID object.
* Get the underlying CommandGenericHID object.
*
* @return the wrapped GenericHID object
* @return the wrapped CommandGenericHID object
*/
wpi::NiDsPS4Controller& GetHID();
CommandGenericHID& GetHID();
/**
* Get the underlying NiDsPS4Controller object.
*
* @return the wrapped NiDsPS4Controller object
*/
wpi::NiDsPS4Controller& GetNiDsPS4Controller();
/**
* Constructs a Trigger instance around the square button's
@@ -249,6 +255,7 @@ class CommandNiDsPS4Controller : public CommandGenericHID {
double GetR2Axis() const;
private:
wpi::NiDsPS4Controller m_hid;
CommandGenericHID* m_hid;
wpi::NiDsPS4Controller m_controller;
};
} // namespace wpi::cmd

View File

@@ -6,11 +6,10 @@
#pragma once
#include "wpi/driverstation/NiDsPS5Controller.hpp"
#include "wpi/commands2/button/Trigger.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/Trigger.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/driverstation/NiDsPS5Controller.hpp"
namespace wpi::cmd {
/**
@@ -19,7 +18,7 @@ namespace wpi::cmd {
*
* @see wpi::NiDsPS5Controller
*/
class CommandNiDsPS5Controller : public CommandGenericHID {
class CommandNiDsPS5Controller {
public:
/**
* Construct an instance of a controller.
@@ -30,11 +29,18 @@ class CommandNiDsPS5Controller : public CommandGenericHID {
explicit CommandNiDsPS5Controller(int port);
/**
* Get the underlying GenericHID object.
* Get the underlying CommandGenericHID object.
*
* @return the wrapped GenericHID object
* @return the wrapped CommandGenericHID object
*/
wpi::NiDsPS5Controller& GetHID();
CommandGenericHID& GetHID();
/**
* Get the underlying NiDsPS5Controller object.
*
* @return the wrapped NiDsPS5Controller object
*/
wpi::NiDsPS5Controller& GetNiDsPS5Controller();
/**
* Constructs a Trigger instance around the square button's
@@ -249,6 +255,7 @@ class CommandNiDsPS5Controller : public CommandGenericHID {
double GetR2Axis() const;
private:
wpi::NiDsPS5Controller m_hid;
CommandGenericHID* m_hid;
wpi::NiDsPS5Controller m_controller;
};
} // namespace wpi::cmd

View File

@@ -6,11 +6,10 @@
#pragma once
#include "wpi/driverstation/NiDsStadiaController.hpp"
#include "wpi/commands2/button/Trigger.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/Trigger.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/driverstation/NiDsStadiaController.hpp"
namespace wpi::cmd {
/**
@@ -19,7 +18,7 @@ namespace wpi::cmd {
*
* @see wpi::NiDsStadiaController
*/
class CommandNiDsStadiaController : public CommandGenericHID {
class CommandNiDsStadiaController {
public:
/**
* Construct an instance of a controller.
@@ -30,11 +29,18 @@ class CommandNiDsStadiaController : public CommandGenericHID {
explicit CommandNiDsStadiaController(int port);
/**
* Get the underlying GenericHID object.
* Get the underlying CommandGenericHID object.
*
* @return the wrapped GenericHID object
* @return the wrapped CommandGenericHID object
*/
wpi::NiDsStadiaController& GetHID();
CommandGenericHID& GetHID();
/**
* Get the underlying NiDsStadiaController object.
*
* @return the wrapped NiDsStadiaController object
*/
wpi::NiDsStadiaController& GetNiDsStadiaController();
/**
* Constructs a Trigger instance around the A button's
@@ -245,6 +251,7 @@ class CommandNiDsStadiaController : public CommandGenericHID {
double GetRightY() const;
private:
wpi::NiDsStadiaController m_hid;
CommandGenericHID* m_hid;
wpi::NiDsStadiaController m_controller;
};
} // namespace wpi::cmd

View File

@@ -6,11 +6,10 @@
#pragma once
#include "wpi/driverstation/NiDsXboxController.hpp"
#include "wpi/commands2/button/Trigger.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/Trigger.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/driverstation/NiDsXboxController.hpp"
namespace wpi::cmd {
/**
@@ -19,7 +18,7 @@ namespace wpi::cmd {
*
* @see wpi::NiDsXboxController
*/
class CommandNiDsXboxController : public CommandGenericHID {
class CommandNiDsXboxController {
public:
/**
* Construct an instance of a controller.
@@ -30,11 +29,18 @@ class CommandNiDsXboxController : public CommandGenericHID {
explicit CommandNiDsXboxController(int port);
/**
* Get the underlying GenericHID object.
* Get the underlying CommandGenericHID object.
*
* @return the wrapped GenericHID object
* @return the wrapped CommandGenericHID object
*/
wpi::NiDsXboxController& GetHID();
CommandGenericHID& GetHID();
/**
* Get the underlying NiDsXboxController object.
*
* @return the wrapped NiDsXboxController object
*/
wpi::NiDsXboxController& GetNiDsXboxController();
/**
* Constructs a Trigger instance around the A button's
@@ -235,6 +241,7 @@ class CommandNiDsXboxController : public CommandGenericHID {
double GetRightTriggerAxis() const;
private:
wpi::NiDsXboxController m_hid;
CommandGenericHID* m_hid;
wpi::NiDsXboxController m_controller;
};
} // namespace wpi::cmd

View File

@@ -0,0 +1,549 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#pragma once
#include <memory>
#include "wpi/driverstation/SteamController.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/commands2/button/Trigger.hpp"
namespace wpi::cmd {
/**
* A version of {@link wpi::SteamController} with {@link Trigger}
* factories for command-based.
*
* @see wpi::SteamController
*/
class CommandSteamController {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit CommandSteamController(int port);
/**
* Construct an instance of a controller with a SteamController object.
*
* @param controller The SteamController object to use for this controller.
*/
explicit CommandSteamController(wpi::SteamController* controller);
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
CommandGenericHID& GetHID();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
wpi::SteamController& GetController();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
const wpi::SteamController& GetController() const;
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @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(enum wpi::SteamController::Button button,
wpi::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* 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(
wpi::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(
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Menu 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 Menu button's
* digital signal attached to the given loop.
*/
Trigger Menu(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Steam 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 Steam button's
* digital signal attached to the given loop.
*/
Trigger Steam(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the View 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 View button's
* digital signal attached to the given loop.
*/
Trigger View(
wpi::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(
wpi::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(
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's
* digital signal attached to the given loop.
*/
Trigger DpadUp(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's
* digital signal attached to the given loop.
*/
Trigger DpadDown(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's
* digital signal attached to the given loop.
*/
Trigger DpadLeft(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's
* digital signal attached to the given loop.
*/
Trigger DpadRight(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the QAM 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 QAM button's
* digital signal attached to the given loop.
*/
Trigger QAM(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Right Paddle 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 Paddle 1 button's
* digital signal attached to the given loop.
*/
Trigger RightPaddle1(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Left Paddle 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 Paddle 1 button's
* digital signal attached to the given loop.
*/
Trigger LeftPaddle1(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Right Paddle 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 Paddle 2 button's
* digital signal attached to the given loop.
*/
Trigger RightPaddle2(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Left Paddle 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 Paddle 2 button's
* digital signal attached to the given loop.
*/
Trigger LeftPaddle2(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Left 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 Left Touchpad button's
* digital signal attached to the given loop.
*/
Trigger LeftTouchpad(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Right 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 Right Touchpad button's
* digital signal attached to the given loop.
*/
Trigger RightTouchpad(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Left Stick Touch 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 Touch button's
* digital signal attached to the given loop.
*/
Trigger LeftStickTouch(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Right Stick Touch 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 Touch button's
* digital signal attached to the given loop.
*/
Trigger RightStickTouch(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Left Grip Touch 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 Grip Touch button's
* digital signal attached to the given loop.
*/
Trigger LeftGripTouch(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Right Grip Touch 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 Grip Touch button's
* digital signal attached to the given loop.
*/
Trigger RightGripTouch(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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 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 Left Trigger axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger LeftTrigger(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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 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 Right Trigger axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger RightTrigger(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is less than
* {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read, starting at 0.
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is less than
* the provided threshold.
*/
Trigger AxisLessThan(
wpi::SteamController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is greater
* than {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is greater than
* the provided threshold.
*/
Trigger AxisGreaterThan(
wpi::SteamController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis magnitude value is
* greater than {@code threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is
* greater than the provided threshold.
*/
Trigger AxisMagnitudeGreaterThan(
wpi::SteamController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Get the Left X value of the controller.
*
* @return the axis value.
*/
double GetLeftX() const;
/**
* Get the Left Y value of the controller.
*
* @return the axis value.
*/
double GetLeftY() const;
/**
* Get the Right X value of the controller.
*
* @return the axis value.
*/
double GetRightX() const;
/**
* Get the Right Y value of the controller.
*
* @return the axis value.
*/
double GetRightY() const;
/**
* Get the Left Trigger value of the controller.
*
* @return the axis value.
*/
double GetLeftTrigger() const;
/**
* Get the Right Trigger value of the controller.
*
* @return the axis value.
*/
double GetRightTrigger() const;
private:
std::unique_ptr<CommandGenericHID> m_ownedHid;
CommandGenericHID* m_hid = nullptr;
std::unique_ptr<wpi::SteamController> m_ownedController;
wpi::SteamController* m_controller = nullptr;
};
} // namespace wpi::cmd

View File

@@ -0,0 +1,419 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#pragma once
#include <memory>
#include "wpi/driverstation/Switch2GCController.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/commands2/button/Trigger.hpp"
namespace wpi::cmd {
/**
* A version of {@link wpi::Switch2GCController} with {@link Trigger}
* factories for command-based.
*
* @see wpi::Switch2GCController
*/
class CommandSwitch2GCController {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit CommandSwitch2GCController(int port);
/**
* Construct an instance of a controller with a Switch2GCController object.
*
* @param controller The Switch2GCController object to use for this controller.
*/
explicit CommandSwitch2GCController(wpi::Switch2GCController* controller);
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
CommandGenericHID& GetHID();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
wpi::Switch2GCController& GetController();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
const wpi::Switch2GCController& GetController() const;
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @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(enum wpi::Switch2GCController::Button button,
wpi::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* 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(
wpi::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(
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Home 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 Home button's
* digital signal attached to the given loop.
*/
Trigger Home(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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 a Trigger instance representing the Start button's
* digital signal attached to the given loop.
*/
Trigger Start(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the ZL 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 ZL button's
* digital signal attached to the given loop.
*/
Trigger ZL(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Z 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 Z button's
* digital signal attached to the given loop.
*/
Trigger Z(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's
* digital signal attached to the given loop.
*/
Trigger DpadUp(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's
* digital signal attached to the given loop.
*/
Trigger DpadDown(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's
* digital signal attached to the given loop.
*/
Trigger DpadLeft(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's
* digital signal attached to the given loop.
*/
Trigger DpadRight(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Capture 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 Capture button's
* digital signal attached to the given loop.
*/
Trigger Capture(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the C 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 C button's
* digital signal attached to the given loop.
*/
Trigger C(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the L 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 L button's
* digital signal attached to the given loop.
*/
Trigger L(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the R 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 R button's
* digital signal attached to the given loop.
*/
Trigger R(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the axis value of the
* L Trigger. The returned Trigger will be true when the axis value
* is greater than 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 L Trigger axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger LTrigger(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the axis value of the
* R Trigger. The returned Trigger will be true when the axis value
* is greater than 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 R Trigger axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger RTrigger(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is less than
* {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read, starting at 0.
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is less than
* the provided threshold.
*/
Trigger AxisLessThan(
wpi::Switch2GCController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is greater
* than {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is greater than
* the provided threshold.
*/
Trigger AxisGreaterThan(
wpi::Switch2GCController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis magnitude value is
* greater than {@code threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is
* greater than the provided threshold.
*/
Trigger AxisMagnitudeGreaterThan(
wpi::Switch2GCController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Get the Left X value of the controller.
*
* @return the axis value.
*/
double GetLeftX() const;
/**
* Get the Left Y value of the controller.
*
* @return the axis value.
*/
double GetLeftY() const;
/**
* Get the C Stick X value of the controller.
*
* @return the axis value.
*/
double GetCStickX() const;
/**
* Get the C Stick Y value of the controller.
*
* @return the axis value.
*/
double GetCStickY() const;
/**
* Get the L Trigger value of the controller.
*
* @return the axis value.
*/
double GetLTrigger() const;
/**
* Get the R Trigger value of the controller.
*
* @return the axis value.
*/
double GetRTrigger() const;
private:
std::unique_ptr<CommandGenericHID> m_ownedHid;
CommandGenericHID* m_hid = nullptr;
std::unique_ptr<wpi::Switch2GCController> m_ownedController;
wpi::Switch2GCController* m_controller = nullptr;
};
} // namespace wpi::cmd

View File

@@ -0,0 +1,458 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#pragma once
#include <memory>
#include "wpi/driverstation/Switch2ProController.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/commands2/button/Trigger.hpp"
namespace wpi::cmd {
/**
* A version of {@link wpi::Switch2ProController} with {@link Trigger}
* factories for command-based.
*
* @see wpi::Switch2ProController
*/
class CommandSwitch2ProController {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit CommandSwitch2ProController(int port);
/**
* Construct an instance of a controller with a Switch2ProController object.
*
* @param controller The Switch2ProController object to use for this controller.
*/
explicit CommandSwitch2ProController(wpi::Switch2ProController* controller);
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
CommandGenericHID& GetHID();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
wpi::Switch2ProController& GetController();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
const wpi::Switch2ProController& GetController() const;
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @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(enum wpi::Switch2ProController::Button button,
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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(
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Minus 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 Minus button's
* digital signal attached to the given loop.
*/
Trigger Minus(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Home 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 Home button's
* digital signal attached to the given loop.
*/
Trigger Home(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Plus 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 Plus button's
* digital signal attached to the given loop.
*/
Trigger Plus(
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the L 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 L button's
* digital signal attached to the given loop.
*/
Trigger L(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the R 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 R button's
* digital signal attached to the given loop.
*/
Trigger R(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's
* digital signal attached to the given loop.
*/
Trigger DpadUp(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's
* digital signal attached to the given loop.
*/
Trigger DpadDown(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's
* digital signal attached to the given loop.
*/
Trigger DpadLeft(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's
* digital signal attached to the given loop.
*/
Trigger DpadRight(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Capture 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 Capture button's
* digital signal attached to the given loop.
*/
Trigger Capture(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the GR 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 GR button's
* digital signal attached to the given loop.
*/
Trigger GR(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the GL 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 GL button's
* digital signal attached to the given loop.
*/
Trigger GL(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the C 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 C button's
* digital signal attached to the given loop.
*/
Trigger C(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the axis value of the
* ZL. The returned Trigger will be true when the axis value
* is greater than 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 ZL axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger ZL(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the axis value of the
* ZR. The returned Trigger will be true when the axis value
* is greater than 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 ZR axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger ZR(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is less than
* {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read, starting at 0.
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is less than
* the provided threshold.
*/
Trigger AxisLessThan(
wpi::Switch2ProController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is greater
* than {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is greater than
* the provided threshold.
*/
Trigger AxisGreaterThan(
wpi::Switch2ProController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis magnitude value is
* greater than {@code threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is
* greater than the provided threshold.
*/
Trigger AxisMagnitudeGreaterThan(
wpi::Switch2ProController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Get the Left X value of the controller.
*
* @return the axis value.
*/
double GetLeftX() const;
/**
* Get the Left Y value of the controller.
*
* @return the axis value.
*/
double GetLeftY() const;
/**
* Get the Right X value of the controller.
*
* @return the axis value.
*/
double GetRightX() const;
/**
* Get the Right Y value of the controller.
*
* @return the axis value.
*/
double GetRightY() const;
/**
* Get the ZL value of the controller.
*
* @return the axis value.
*/
double GetZL() const;
/**
* Get the ZR value of the controller.
*
* @return the axis value.
*/
double GetZR() const;
private:
std::unique_ptr<CommandGenericHID> m_ownedHid;
CommandGenericHID* m_hid = nullptr;
std::unique_ptr<wpi::Switch2ProController> m_ownedController;
wpi::Switch2ProController* m_controller = nullptr;
};
} // namespace wpi::cmd

View File

@@ -0,0 +1,374 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#pragma once
#include <memory>
#include "wpi/driverstation/SwitchN64Controller.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/commands2/button/Trigger.hpp"
namespace wpi::cmd {
/**
* A version of {@link wpi::SwitchN64Controller} with {@link Trigger}
* factories for command-based.
*
* @see wpi::SwitchN64Controller
*/
class CommandSwitchN64Controller {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit CommandSwitchN64Controller(int port);
/**
* Construct an instance of a controller with a SwitchN64Controller object.
*
* @param controller The SwitchN64Controller object to use for this controller.
*/
explicit CommandSwitchN64Controller(wpi::SwitchN64Controller* controller);
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
CommandGenericHID& GetHID();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
wpi::SwitchN64Controller& GetController();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
const wpi::SwitchN64Controller& GetController() const;
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @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(enum wpi::SwitchN64Controller::Button button,
wpi::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* 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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the C Left 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 C Left button's
* digital signal attached to the given loop.
*/
Trigger CLeft(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the C Up 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 C Up button's
* digital signal attached to the given loop.
*/
Trigger CUp(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Capture 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 Capture button's
* digital signal attached to the given loop.
*/
Trigger Capture(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Home 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 Home button's
* digital signal attached to the given loop.
*/
Trigger Home(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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 a Trigger instance representing the Start button's
* digital signal attached to the given loop.
*/
Trigger Start(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the C Down 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 C Down button's
* digital signal attached to the given loop.
*/
Trigger CDown(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the L 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 L button's
* digital signal attached to the given loop.
*/
Trigger L(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the R 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 R button's
* digital signal attached to the given loop.
*/
Trigger R(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's
* digital signal attached to the given loop.
*/
Trigger DpadUp(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's
* digital signal attached to the given loop.
*/
Trigger DpadDown(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's
* digital signal attached to the given loop.
*/
Trigger DpadLeft(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's
* digital signal attached to the given loop.
*/
Trigger DpadRight(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the C Right 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 C Right button's
* digital signal attached to the given loop.
*/
Trigger CRight(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the axis value of the
* ZR. The returned Trigger will be true when the axis value
* is greater than 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 ZR axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger ZR(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is less than
* {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read, starting at 0.
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is less than
* the provided threshold.
*/
Trigger AxisLessThan(
wpi::SwitchN64Controller::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is greater
* than {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is greater than
* the provided threshold.
*/
Trigger AxisGreaterThan(
wpi::SwitchN64Controller::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis magnitude value is
* greater than {@code threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is
* greater than the provided threshold.
*/
Trigger AxisMagnitudeGreaterThan(
wpi::SwitchN64Controller::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Get the Left X value of the controller.
*
* @return the axis value.
*/
double GetLeftX() const;
/**
* Get the Left Y value of the controller.
*
* @return the axis value.
*/
double GetLeftY() const;
/**
* Get the Z Axis value of the controller.
*
* @return the axis value.
*/
double GetZAxis() const;
/**
* Get the ZR value of the controller.
*
* @return the axis value.
*/
double GetZR() const;
private:
std::unique_ptr<CommandGenericHID> m_ownedHid;
CommandGenericHID* m_hid = nullptr;
std::unique_ptr<wpi::SwitchN64Controller> m_ownedController;
wpi::SwitchN64Controller* m_controller = nullptr;
};
} // namespace wpi::cmd

View File

@@ -0,0 +1,419 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#pragma once
#include <memory>
#include "wpi/driverstation/SwitchProController.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/commands2/button/Trigger.hpp"
namespace wpi::cmd {
/**
* A version of {@link wpi::SwitchProController} with {@link Trigger}
* factories for command-based.
*
* @see wpi::SwitchProController
*/
class CommandSwitchProController {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit CommandSwitchProController(int port);
/**
* Construct an instance of a controller with a SwitchProController object.
*
* @param controller The SwitchProController object to use for this controller.
*/
explicit CommandSwitchProController(wpi::SwitchProController* controller);
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
CommandGenericHID& GetHID();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
wpi::SwitchProController& GetController();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
const wpi::SwitchProController& GetController() const;
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @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(enum wpi::SwitchProController::Button button,
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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(
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Minus 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 Minus button's
* digital signal attached to the given loop.
*/
Trigger Minus(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Home 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 Home button's
* digital signal attached to the given loop.
*/
Trigger Home(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Plus 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 Plus button's
* digital signal attached to the given loop.
*/
Trigger Plus(
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the L 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 L button's
* digital signal attached to the given loop.
*/
Trigger L(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the R 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 R button's
* digital signal attached to the given loop.
*/
Trigger R(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's
* digital signal attached to the given loop.
*/
Trigger DpadUp(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's
* digital signal attached to the given loop.
*/
Trigger DpadDown(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's
* digital signal attached to the given loop.
*/
Trigger DpadLeft(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's
* digital signal attached to the given loop.
*/
Trigger DpadRight(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Capture 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 Capture button's
* digital signal attached to the given loop.
*/
Trigger Capture(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the axis value of the
* ZL. The returned Trigger will be true when the axis value
* is greater than 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 ZL axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger ZL(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the axis value of the
* ZR. The returned Trigger will be true when the axis value
* is greater than 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 ZR axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger ZR(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is less than
* {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read, starting at 0.
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is less than
* the provided threshold.
*/
Trigger AxisLessThan(
wpi::SwitchProController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is greater
* than {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is greater than
* the provided threshold.
*/
Trigger AxisGreaterThan(
wpi::SwitchProController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis magnitude value is
* greater than {@code threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is
* greater than the provided threshold.
*/
Trigger AxisMagnitudeGreaterThan(
wpi::SwitchProController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Get the Left X value of the controller.
*
* @return the axis value.
*/
double GetLeftX() const;
/**
* Get the Left Y value of the controller.
*
* @return the axis value.
*/
double GetLeftY() const;
/**
* Get the Right X value of the controller.
*
* @return the axis value.
*/
double GetRightX() const;
/**
* Get the Right Y value of the controller.
*
* @return the axis value.
*/
double GetRightY() const;
/**
* Get the ZL value of the controller.
*
* @return the axis value.
*/
double GetZL() const;
/**
* Get the ZR value of the controller.
*
* @return the axis value.
*/
double GetZR() const;
private:
std::unique_ptr<CommandGenericHID> m_ownedHid;
CommandGenericHID* m_hid = nullptr;
std::unique_ptr<wpi::SwitchProController> m_ownedController;
wpi::SwitchProController* m_controller = nullptr;
};
} // namespace wpi::cmd

View File

@@ -0,0 +1,406 @@
// 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 ./commandsv2/generate_hids.py. DO NOT MODIFY
#pragma once
#include <memory>
#include "wpi/driverstation/XboxController.hpp"
#include "wpi/commands2/CommandScheduler.hpp"
#include "wpi/commands2/button/CommandGenericHID.hpp"
#include "wpi/commands2/button/Trigger.hpp"
namespace wpi::cmd {
/**
* A version of {@link wpi::XboxController} with {@link Trigger}
* factories for command-based.
*
* @see wpi::XboxController
*/
class CommandXboxController {
public:
/**
* Construct an instance of a controller.
*
* @param port The port index on the Driver Station that the controller is
* plugged into.
*/
explicit CommandXboxController(int port);
/**
* Construct an instance of a controller with a XboxController object.
*
* @param controller The XboxController object to use for this controller.
*/
explicit CommandXboxController(wpi::XboxController* controller);
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
CommandGenericHID& GetHID();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
wpi::XboxController& GetController();
/**
* Get the wrapped controller object.
*
* @return the wrapped controller object
*/
const wpi::XboxController& GetController() const;
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button
* @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(enum wpi::XboxController::Button button,
wpi::EventLoop* loop = CommandScheduler::GetInstance()
.GetDefaultButtonLoop()) const;
/**
* 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(
wpi::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(
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the View 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 View button's
* digital signal attached to the given loop.
*/
Trigger View(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Xbox 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 Xbox button's
* digital signal attached to the given loop.
*/
Trigger Xbox(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Menu 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 Menu button's
* digital signal attached to the given loop.
*/
Trigger Menu(
wpi::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(
wpi::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(
wpi::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(
wpi::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(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Up 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 Dpad Up button's
* digital signal attached to the given loop.
*/
Trigger DpadUp(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Down 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 Dpad Down button's
* digital signal attached to the given loop.
*/
Trigger DpadDown(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Left 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 Dpad Left button's
* digital signal attached to the given loop.
*/
Trigger DpadLeft(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance around the Dpad Right 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 Dpad Right button's
* digital signal attached to the given loop.
*/
Trigger DpadRight(
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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 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 Left Trigger axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger LeftTrigger(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* 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 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 Right Trigger axis
* exceeds the provided threshold, attached to the given loop
*/
Trigger RightTrigger(
double threshold = 0.5,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is less than
* {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read, starting at 0.
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is less than
* the provided threshold.
*/
Trigger AxisLessThan(
wpi::XboxController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis value is greater
* than {@code threshold}, attached to {@link
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
* button loop}.
* @param axis The axis to read
* @param threshold The value below which this trigger should return true.
* @param loop the event loop instance to attach the event to. Defaults to
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
* scheduler button loop}.
* @return a Trigger instance that is true when the axis value is greater than
* the provided threshold.
*/
Trigger AxisGreaterThan(
wpi::XboxController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Constructs a Trigger instance that is true when the axis magnitude value is
* greater than {@code threshold}, attached to the given loop.
*
* @param axis The axis to read
* @param threshold The value above which this trigger should return true.
* @param loop the event loop instance to attach the trigger to.
* @return a Trigger instance that is true when the axis magnitude value is
* greater than the provided threshold.
*/
Trigger AxisMagnitudeGreaterThan(
wpi::XboxController::Axis axis, double threshold,
wpi::EventLoop* loop =
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
/**
* Get the Left X value of the controller.
*
* @return the axis value.
*/
double GetLeftX() const;
/**
* Get the Left Y value of the controller.
*
* @return the axis value.
*/
double GetLeftY() const;
/**
* Get the Right X value of the controller.
*
* @return the axis value.
*/
double GetRightX() const;
/**
* Get the Right Y value of the controller.
*
* @return the axis value.
*/
double GetRightY() const;
/**
* Get the Left Trigger value of the controller.
*
* @return the axis value.
*/
double GetLeftTrigger() const;
/**
* Get the Right Trigger value of the controller.
*
* @return the axis value.
*/
double GetRightTrigger() const;
private:
std::unique_ptr<CommandGenericHID> m_ownedHid;
CommandGenericHID* m_hid = nullptr;
std::unique_ptr<wpi::XboxController> m_ownedController;
wpi::XboxController* m_controller = nullptr;
};
} // namespace wpi::cmd

View File

@@ -4,7 +4,9 @@
package org.wpilib.command2.button;
import java.util.Objects;
import org.wpilib.command2.CommandScheduler;
import org.wpilib.driverstation.DriverStation;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.event.EventLoop;
@@ -14,8 +16,9 @@ import org.wpilib.event.EventLoop;
* @see Gamepad
*/
@SuppressWarnings("MethodName")
public class CommandGamepad extends CommandGenericHID {
private final Gamepad m_hid;
public class CommandGamepad {
private final CommandGenericHID m_hid;
private final Gamepad m_gamepad;
/**
* Construct an instance of a controller.
@@ -23,20 +26,61 @@ public class CommandGamepad extends CommandGenericHID {
* @param port The port index on the Driver Station that the controller is plugged into.
*/
public CommandGamepad(int port) {
super(port);
m_hid = new Gamepad(port);
m_hid = CommandGenericHID.getCommandGenericHID(port);
m_gamepad = DriverStation.getGamepad(port);
}
/**
* Get the underlying GenericHID object.
* Construct an instance of a controller with a Gamepad object.
*
* @return the wrapped GenericHID object
* @param gamepad The Gamepad object to use for this controller.
*/
@Override
public Gamepad getHID() {
public CommandGamepad(Gamepad gamepad) {
m_gamepad = Objects.requireNonNull(gamepad, "Provided gamepad cannot be null");
m_hid = new CommandGenericHID(m_gamepad.getHID());
}
/**
* Get the underlying CommandGenericHID object.
*
* @return the wrapped CommandGenericHID object
*/
public CommandGenericHID getHID() {
return m_hid;
}
/**
* Get the underlying Gamepad object.
*
* @return the wrapped Gamepad object
*/
public Gamepad getGamepad() {
return m_gamepad;
}
/**
* Constructs an event instance around this button's digital signal.
*
* @param button the button index
* @return an event instance representing the button's digital signal attached to the {@link
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #button(int, EventLoop)
*/
public Trigger button(int button) {
return m_hid.button(button);
}
/**
* 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.
* @return an event instance representing the button's digital signal attached to the given loop.
*/
public Trigger button(int button, EventLoop loop) {
return m_hid.button(button, loop);
}
/**
* Constructs an event instance around this button's digital signal.
*
@@ -46,7 +90,7 @@ public class CommandGamepad extends CommandGenericHID {
* @see #button(Gamepad.Button, EventLoop)
*/
public Trigger button(Gamepad.Button button) {
return super.button(button.value);
return button(button.value);
}
/**
@@ -61,91 +105,91 @@ public class CommandGamepad extends CommandGenericHID {
}
/**
* Constructs a Trigger instance around the South Face button's digital signal.
* Constructs a Trigger instance around the Face Down button's digital signal.
*
* @return a Trigger instance representing the South Face button's digital signal attached to the
* @return a Trigger instance representing the Face Down button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #southFace(EventLoop)
* @see #faceDown(EventLoop)
*/
public Trigger southFace() {
return southFace(CommandScheduler.getInstance().getDefaultButtonLoop());
public Trigger faceDown() {
return faceDown(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the South Face button's digital signal.
* Constructs a Trigger instance around the Face Down button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the South Face button's digital signal attached to the
* @return a Trigger instance representing the Face Down button's digital signal attached to the
* given loop.
*/
public Trigger southFace(EventLoop loop) {
return button(Gamepad.Button.SOUTH_FACE, loop);
public Trigger faceDown(EventLoop loop) {
return button(Gamepad.Button.FACE_DOWN, loop);
}
/**
* Constructs a Trigger instance around the East Face button's digital signal.
* Constructs a Trigger instance around the Face Right button's digital signal.
*
* @return a Trigger instance representing the East Face button's digital signal attached to the
* @return a Trigger instance representing the Face Right button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #eastFace(EventLoop)
* @see #faceRight(EventLoop)
*/
public Trigger eastFace() {
return eastFace(CommandScheduler.getInstance().getDefaultButtonLoop());
public Trigger faceRight() {
return faceRight(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the East Face button's digital signal.
* Constructs a Trigger instance around the Face Right button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the East Face button's digital signal attached to the
* @return a Trigger instance representing the Face Right button's digital signal attached to the
* given loop.
*/
public Trigger eastFace(EventLoop loop) {
return button(Gamepad.Button.EAST_FACE, loop);
public Trigger faceRight(EventLoop loop) {
return button(Gamepad.Button.FACE_RIGHT, loop);
}
/**
* Constructs a Trigger instance around the West Face button's digital signal.
* Constructs a Trigger instance around the Face Left button's digital signal.
*
* @return a Trigger instance representing the West Face button's digital signal attached to the
* @return a Trigger instance representing the Face Left button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #westFace(EventLoop)
* @see #faceLeft(EventLoop)
*/
public Trigger westFace() {
return westFace(CommandScheduler.getInstance().getDefaultButtonLoop());
public Trigger faceLeft() {
return faceLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the West Face button's digital signal.
* Constructs a Trigger instance around the Face Left button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the West Face button's digital signal attached to the
* @return a Trigger instance representing the Face Left button's digital signal attached to the
* given loop.
*/
public Trigger westFace(EventLoop loop) {
return button(Gamepad.Button.WEST_FACE, loop);
public Trigger faceLeft(EventLoop loop) {
return button(Gamepad.Button.FACE_LEFT, loop);
}
/**
* Constructs a Trigger instance around the North Face button's digital signal.
* Constructs a Trigger instance around the Face Up button's digital signal.
*
* @return a Trigger instance representing the North Face button's digital signal attached to the
* @return a Trigger instance representing the Face Up button's digital signal attached to the
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
* @see #northFace(EventLoop)
* @see #faceUp(EventLoop)
*/
public Trigger northFace() {
return northFace(CommandScheduler.getInstance().getDefaultButtonLoop());
public Trigger faceUp() {
return faceUp(CommandScheduler.getInstance().getDefaultButtonLoop());
}
/**
* Constructs a Trigger instance around the North Face button's digital signal.
* Constructs a Trigger instance around the Face Up button's digital signal.
*
* @param loop the event loop instance to attach the event to.
* @return a Trigger instance representing the North Face button's digital signal attached to the
* @return a Trigger instance representing the Face Up button's digital signal attached to the
* given loop.
*/
public Trigger northFace(EventLoop loop) {
return button(Gamepad.Button.NORTH_FACE, loop);
public Trigger faceUp(EventLoop loop) {
return button(Gamepad.Button.FACE_UP, loop);
}
/**
@@ -721,7 +765,7 @@ public class CommandGamepad extends CommandGenericHID {
* threshold.
*/
public Trigger axisLessThan(Gamepad.Axis axis, double threshold) {
return super.axisLessThan(axis.value, threshold);
return m_hid.axisLessThan(axis.value, threshold);
}
/**
@@ -735,7 +779,7 @@ public class CommandGamepad extends CommandGenericHID {
* threshold.
*/
public Trigger axisLessThan(Gamepad.Axis axis, double threshold, EventLoop loop) {
return super.axisLessThan(axis.value, threshold, loop);
return m_hid.axisLessThan(axis.value, threshold, loop);
}
/**
@@ -749,7 +793,7 @@ public class CommandGamepad extends CommandGenericHID {
* threshold.
*/
public Trigger axisGreaterThan(Gamepad.Axis axis, double threshold) {
return super.axisGreaterThan(axis.value, threshold);
return m_hid.axisGreaterThan(axis.value, threshold);
}
/**
@@ -763,7 +807,7 @@ public class CommandGamepad extends CommandGenericHID {
* threshold.
*/
public Trigger axisGreaterThan(Gamepad.Axis axis, double threshold, EventLoop loop) {
return super.axisGreaterThan(axis.value, threshold, loop);
return m_hid.axisGreaterThan(axis.value, threshold, loop);
}
/**
@@ -777,7 +821,7 @@ public class CommandGamepad extends CommandGenericHID {
* provided threshold.
*/
public Trigger axisMagnitudeGreaterThan(Gamepad.Axis axis, double threshold, EventLoop loop) {
return super.axisMagnitudeGreaterThan(axis.value, threshold, loop);
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
}
/**
@@ -790,7 +834,7 @@ public class CommandGamepad extends CommandGenericHID {
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
*/
public Trigger axisMagnitudeGreaterThan(Gamepad.Axis axis, double threshold) {
return super.axisMagnitudeGreaterThan(axis.value, threshold);
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
}
/**
@@ -800,7 +844,7 @@ public class CommandGamepad extends CommandGenericHID {
* @return The value of the axis.
*/
public double getAxis(Gamepad.Axis axis) {
return getRawAxis(axis.value);
return m_hid.getRawAxis(axis.value);
}
/**
@@ -809,7 +853,7 @@ public class CommandGamepad extends CommandGenericHID {
* @return The axis value.
*/
public double getLeftX() {
return m_hid.getLeftX();
return m_gamepad.getLeftX();
}
/**
@@ -818,7 +862,7 @@ public class CommandGamepad extends CommandGenericHID {
* @return The axis value.
*/
public double getLeftY() {
return m_hid.getLeftY();
return m_gamepad.getLeftY();
}
/**
@@ -827,7 +871,7 @@ public class CommandGamepad extends CommandGenericHID {
* @return The axis value.
*/
public double getRightX() {
return m_hid.getRightX();
return m_gamepad.getRightX();
}
/**
@@ -836,26 +880,26 @@ public class CommandGamepad extends CommandGenericHID {
* @return The axis value.
*/
public double getRightY() {
return m_hid.getRightY();
return m_gamepad.getRightY();
}
/**
* 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].
* Get the left trigger 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 getLeftTriggerAxis() {
return m_hid.getLeftTriggerAxis();
public double getLeftTrigger() {
return m_gamepad.getLeftTrigger();
}
/**
* 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].
* Get the right trigger 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 getRightTriggerAxis() {
return m_hid.getRightTriggerAxis();
public double getRightTrigger() {
return m_gamepad.getRightTrigger();
}
}

Some files were not shown because too many files have changed in this diff Show More