This is something my team is using
Code:
if (DriverButtons.X.changedDown)
{
if (HighGear)
{
Shifter.set(Value.kReverse);
} else {
Shifter.set(Value.kForward);
}
HighGear=!HighGear;
}
That involves our own code for the XboxControler which detects if it has changed state this run and consists of compering the last state with the current,
but if do not want a toggle then you can easily do
Code:
if (DriverButtons.X.current)
{
pistonArm.set(Value.kReverse);
}
else {
pistonArm.set(Value.kForward);
}
And do not forget to change DriverButtons.X.current to your own code that gets the current value of your button