2020-12-26 14:12:05 -08:00
|
|
|
// 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.
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
2023-06-08 00:01:06 -07:00
|
|
|
|
2025-06-29 18:32:26 -07:00
|
|
|
#include <frc/DriverStation.h>
|
2019-08-25 23:55:59 -04:00
|
|
|
#include <frc/GenericHID.h>
|
|
|
|
|
|
2023-07-10 12:56:18 -04:00
|
|
|
#include "Trigger.h"
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
namespace frc2 {
|
|
|
|
|
/**
|
|
|
|
|
* A class used to bind command scheduling to joystick POV presses. Can be
|
|
|
|
|
* composed with other buttons with the operators in Trigger.
|
|
|
|
|
*
|
2022-01-08 11:11:34 -08:00
|
|
|
* This class is provided by the NewCommands VendorDep
|
|
|
|
|
*
|
2019-08-25 23:55:59 -04:00
|
|
|
* @see Trigger
|
|
|
|
|
*/
|
2023-07-10 12:56:18 -04:00
|
|
|
class POVButton : public Trigger {
|
2019-08-25 23:55:59 -04:00
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* Creates a POVButton that commands can be bound to.
|
|
|
|
|
*
|
|
|
|
|
* @param joystick The joystick on which the button is located.
|
|
|
|
|
* @param angle The angle of the POV corresponding to a button press.
|
|
|
|
|
* @param povNumber The number of the POV on the joystick.
|
|
|
|
|
*/
|
2025-06-29 18:32:26 -07:00
|
|
|
POVButton(frc::GenericHID* joystick, frc::DriverStation::POVDirection angle,
|
|
|
|
|
int povNumber = 0)
|
2023-07-10 12:56:18 -04:00
|
|
|
: Trigger([joystick, angle, povNumber] {
|
2020-01-20 21:35:19 -08:00
|
|
|
return joystick->GetPOV(povNumber) == angle;
|
2020-01-12 17:57:28 -05:00
|
|
|
}) {}
|
2019-08-25 23:55:59 -04:00
|
|
|
};
|
|
|
|
|
} // namespace frc2
|