2015-01-11 16:02:49 -05:00
|
|
|
#include "OI.h"
|
2015-02-03 15:55:11 -05:00
|
|
|
#include "Commands/Elevator/Lower.h"
|
|
|
|
#include "Commands/Elevator/Raise.h"
|
2015-02-13 19:40:23 -05:00
|
|
|
#include "Commands/Collector/RollIn.h"
|
|
|
|
#include "Commands/Collector/RollOut.h"
|
2015-02-13 21:41:38 -05:00
|
|
|
#include "Commands/BinElevator/BinLower.h"
|
|
|
|
#include "Commands/BinElevator/BinRaise.h"
|
2015-02-21 08:43:19 -05:00
|
|
|
#include "Commands/BinElevator/BinCloseArms.h"
|
|
|
|
#include "Commands/BinElevator/BinOpenArms.h"
|
2015-02-24 12:02:30 -05:00
|
|
|
#include "Commands/Autonomous/CollectTote.h"
|
|
|
|
#include "Commands/Autonomous/ReleaseTote.h"
|
2015-02-08 07:13:57 -05:00
|
|
|
#include "Commands/Test/CheckRobot.h"
|
2015-03-09 07:25:11 -04:00
|
|
|
OI::OI(){
|
2015-02-07 17:04:16 -05:00
|
|
|
// Joysticks
|
2015-02-28 11:05:04 -05:00
|
|
|
leftController=new Joystick(0);
|
2015-01-17 12:21:16 -05:00
|
|
|
rightStick=new Joystick(1);
|
2015-02-28 11:05:04 -05:00
|
|
|
// Main buttons
|
|
|
|
leftA = new JoystickButton(leftController, 1);
|
|
|
|
leftB = new JoystickButton(leftController, 2);
|
|
|
|
leftX = new JoystickButton(leftController, 3);
|
|
|
|
leftY = new JoystickButton(leftController, 4);
|
|
|
|
// Left and right uttons
|
|
|
|
leftLB = new JoystickButton(leftController, 5);
|
|
|
|
leftRB = new JoystickButton(leftController, 6);
|
|
|
|
leftBack = new JoystickButton(leftController, 7);
|
|
|
|
leftStart = new JoystickButton(leftController, 8);
|
|
|
|
// Left, right stick press
|
|
|
|
leftLPress = new JoystickButton(leftController, 9);
|
|
|
|
leftRPress = new JoystickButton(leftController, 10);
|
2015-03-21 08:16:39 -04:00
|
|
|
|
|
|
|
// Commands
|
|
|
|
Raise *raise = new Raise(2.0);
|
|
|
|
Lower *lower = new Lower(2.0);
|
|
|
|
leftA->WhileHeld(raise);
|
|
|
|
leftA->CancelWhenPressed(lower);
|
|
|
|
leftB->WhenPressed(lower);
|
|
|
|
leftB->CancelWhenPressed(raise);
|
2015-01-17 12:21:16 -05:00
|
|
|
}
|
2015-02-28 11:05:04 -05:00
|
|
|
float OI::GetLeftAxis(std::string stick, std::string axis){
|
|
|
|
if(stick=="left"){
|
|
|
|
if(axis=="x"){
|
2015-03-21 08:16:39 -04:00
|
|
|
return leftController->GetRawAxis(0);
|
2015-02-28 11:05:04 -05:00
|
|
|
}else if(axis=="y"){
|
2015-03-21 08:16:39 -04:00
|
|
|
return -leftController->GetRawAxis(1);
|
2015-02-28 11:05:04 -05:00
|
|
|
}else if(axis=="trigger"){
|
|
|
|
//TODO: Figure out what axis this is
|
2015-03-21 08:16:39 -04:00
|
|
|
return leftController->GetRawAxis(4);
|
2015-02-28 11:05:04 -05:00
|
|
|
return -4;
|
|
|
|
}
|
|
|
|
}else if(stick=="right"){
|
|
|
|
if(axis=="x"){
|
2015-03-21 08:16:39 -04:00
|
|
|
return leftController->GetRawAxis(2);
|
2015-02-28 11:05:04 -05:00
|
|
|
}else if(axis=="y"){
|
2015-03-21 08:16:39 -04:00
|
|
|
return -leftController->GetRawAxis(3);
|
2015-02-28 11:05:04 -05:00
|
|
|
}else if(axis=="trigger"){
|
|
|
|
//TODO: Figure out what axis this is
|
2015-03-21 08:16:39 -04:00
|
|
|
return leftController->GetRawAxis(5);
|
2015-02-28 11:05:04 -05:00
|
|
|
return -4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//TODO: Fix this placeholder for NULL
|
|
|
|
return -5;
|
2015-01-17 12:21:16 -05:00
|
|
|
}
|
2015-02-28 11:05:04 -05:00
|
|
|
bool OI::GetLeftButton(std::string button){
|
|
|
|
if(button=="a"){
|
|
|
|
return leftA->Get();
|
|
|
|
}else if(button=="b"){
|
|
|
|
return leftB->Get();
|
|
|
|
}else if(button=="x"){
|
|
|
|
return leftX->Get();
|
|
|
|
}else if(button=="y"){
|
|
|
|
return leftY->Get();
|
|
|
|
}else if(button=="lb"){
|
|
|
|
return leftLB->Get();
|
|
|
|
}else if(button=="rb"){
|
|
|
|
return leftRB->Get();
|
|
|
|
}else if(button=="back"){
|
|
|
|
return leftBack->Get();
|
|
|
|
}else if(button=="start"){
|
|
|
|
return leftStart->Get();
|
|
|
|
}else if(button=="lpress"){
|
|
|
|
return leftLPress->Get();
|
|
|
|
}else if(button=="rpress"){
|
|
|
|
return leftRPress->Get();
|
|
|
|
}
|
|
|
|
return false;
|
2015-02-15 17:10:20 -05:00
|
|
|
}
|
2015-02-08 12:26:15 -05:00
|
|
|
// vim: ts=2:sw=2:et
|