blob: d420e34669de117c352aae01f9aaeacb09194c12 [file] [log] [blame]
Brian Silverman890a32a2018-03-11 15:41:56 -07001#include "ctre/phoenix/Tasking/ButtonMonitor.h"
2#include <GenericHID.h> // WPILIB
3
4#ifndef CTR_EXCLUDE_WPILIB_CLASSES
5
6namespace ctre {
7namespace phoenix {
8namespace tasking {
9
10ButtonMonitor::ButtonMonitor(frc::GenericHID * controller, int buttonIndex,
11 IButtonPressEventHandler * ButtonPressEventHandler) {
12 _gameCntrlr = controller;
13 _btnIdx = buttonIndex;
14 _handler = ButtonPressEventHandler;
15}
16ButtonMonitor::ButtonMonitor(const ButtonMonitor & rhs) {
17 _gameCntrlr = rhs._gameCntrlr;
18 _btnIdx = rhs._btnIdx;
19 _handler = rhs._handler;
20}
21
22void ButtonMonitor::Process() {
23 bool down = ((frc::GenericHID*)_gameCntrlr)->GetRawButton(_btnIdx);
24
25 if (!_isDown && down)
26 _handler->OnButtonPress(_btnIdx, down);
27
28 _isDown = down;
29}
30
31void ButtonMonitor::OnStart() {
32}
33void ButtonMonitor::OnLoop() {
34 Process();
35}
36bool ButtonMonitor::IsDone() {
37 return false;
38}
39void ButtonMonitor::OnStop() {
40}
41
42} // namespace tasking
43} // namespace phoenix
44} // namespace ctre
45
46#endif // CTR_EXCLUDE_WPILIB_CLASSES