mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
[hal,wpilib,cmd] Update POVs to use enums (#7978)
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc/DriverStation.h>
|
||||
#include <frc/GenericHID.h>
|
||||
|
||||
#include "Trigger.h"
|
||||
@@ -49,133 +51,127 @@ class CommandGenericHID {
|
||||
/**
|
||||
* Constructs a Trigger instance based around this angle of a POV on the HID.
|
||||
*
|
||||
* <p>The POV angles start at 0 in the up direction, and increase clockwise
|
||||
* (eg right is 90, upper-left is 315).
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to
|
||||
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
|
||||
* scheduler button loop}.
|
||||
* @param angle POV angle in degrees, or -1 for the center / not pressed.
|
||||
* @param angle POV angle.
|
||||
* @return a Trigger instance based around this angle of a POV on the HID.
|
||||
*/
|
||||
Trigger POV(int angle,
|
||||
Trigger POV(frc::DriverStation::POVDirection angle,
|
||||
frc::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance based around this angle of a POV on the HID.
|
||||
*
|
||||
* <p>The POV angles start at 0 in the up direction, and increase clockwise
|
||||
* (eg right is 90, upper-left is 315).
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to
|
||||
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
|
||||
* scheduler button loop}.
|
||||
* @param pov index of the POV to read (starting at 0). Defaults to 0.
|
||||
* @param angle POV angle in degrees, or -1 for the center / not pressed.
|
||||
* @param angle POV angle.
|
||||
* @return a Trigger instance based around this angle of a POV on the HID.
|
||||
*/
|
||||
Trigger POV(int pov, int angle,
|
||||
Trigger POV(int pov, frc::DriverStation::POVDirection angle,
|
||||
frc::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance based around the 0 degree angle (up) of the
|
||||
* Constructs a Trigger instance based around the up direction of the
|
||||
* default (index 0) POV on the HID.
|
||||
*
|
||||
* @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 based around the 0 degree angle of a POV on the
|
||||
* @return a Trigger instance based around the up direction of a POV on the
|
||||
* HID.
|
||||
*/
|
||||
Trigger POVUp(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance based around the 45 degree angle (right up)
|
||||
* Constructs a Trigger instance based around the up right direction
|
||||
* of the default (index 0) POV on the HID.
|
||||
*
|
||||
* @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 based around the 45 degree angle of a POV on the
|
||||
* HID.
|
||||
* @return a Trigger instance based around the up right direction of a POV on
|
||||
* the HID.
|
||||
*/
|
||||
Trigger POVUpRight(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance based around the 90 degree angle (right) of
|
||||
* Constructs a Trigger instance based around the right direction of
|
||||
* the default (index 0) POV on the HID.
|
||||
*
|
||||
* @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 based around the 90 degree angle of a POV on the
|
||||
* @return a Trigger instance based around the right direction of a POV on the
|
||||
* HID.
|
||||
*/
|
||||
Trigger POVRight(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance based around the 135 degree angle (right
|
||||
* down) of the default (index 0) POV on the HID.
|
||||
* Constructs a Trigger instance based around the down right direction
|
||||
* of the default (index 0) POV on the HID.
|
||||
*
|
||||
* @return a Trigger instance based around the 135 degree angle of a POV on
|
||||
* the HID.
|
||||
* @return a Trigger instance based around the down right direction of a POV
|
||||
* on the HID.
|
||||
*/
|
||||
Trigger POVDownRight(
|
||||
frc::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance based around the 180 degree angle (down) of
|
||||
* Constructs a Trigger instance based around the down direction of
|
||||
* the default (index 0) POV on the HID.
|
||||
*
|
||||
* @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 based around the 180 degree angle of a POV on
|
||||
* @return a Trigger instance based around the down direction of a POV on
|
||||
* the HID.
|
||||
*/
|
||||
Trigger POVDown(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance based around the 225 degree angle (down left)
|
||||
* Constructs a Trigger instance based around the down left direction
|
||||
* of the default (index 0) POV on the HID.
|
||||
*
|
||||
* @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 based around the 225 degree angle of a POV on
|
||||
* @return a Trigger instance based around the down left direction of a POV on
|
||||
* the HID.
|
||||
*/
|
||||
Trigger POVDownLeft(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance based around the 270 degree angle (left) of
|
||||
* Constructs a Trigger instance based around the left direction of
|
||||
* the default (index 0) POV on the HID.
|
||||
*
|
||||
* @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 based around the 270 degree angle of a POV on
|
||||
* @return a Trigger instance based around the left direction of a POV on
|
||||
* the HID.
|
||||
*/
|
||||
Trigger POVLeft(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance based around the 315 degree angle (left up)
|
||||
* Constructs a Trigger instance based around the up left direction
|
||||
* of the default (index 0) POV on the HID.
|
||||
*
|
||||
* @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 based around the 315 degree angle of a POV on
|
||||
* @return a Trigger instance based around the up left direction of a POV on
|
||||
* the HID.
|
||||
*/
|
||||
Trigger POVUpLeft(frc::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc/DriverStation.h>
|
||||
#include <frc/GenericHID.h>
|
||||
|
||||
#include "Trigger.h"
|
||||
@@ -26,7 +27,8 @@ class POVButton : public Trigger {
|
||||
* @param angle The angle of the POV corresponding to a button press.
|
||||
* @param povNumber The number of the POV on the joystick.
|
||||
*/
|
||||
POVButton(frc::GenericHID* joystick, int angle, int povNumber = 0)
|
||||
POVButton(frc::GenericHID* joystick, frc::DriverStation::POVDirection angle,
|
||||
int povNumber = 0)
|
||||
: Trigger([joystick, angle, povNumber] {
|
||||
return joystick->GetPOV(povNumber) == angle;
|
||||
}) {}
|
||||
|
||||
Reference in New Issue
Block a user