FRC2706 / 2019-2706-Robot-Code

The main robot code for the FIRST 2019 challenge: Deep Space
MIT License
2 stars 0 forks source link

System for easy bindings to button combinations #144

Open KyleRAnderson opened 5 years ago

KyleRAnderson commented 5 years ago

Currently there are actually a number of cases where combinations of buttons on the operator and driver joysticks should be pressed to activate certain commands, yet we don't have an easy way of doing these each time.

As it is right now, one button activates a command and then the command itself handles the rest of the input. This isn't great because ideally commands should just perform actions and not deal with input/output.

I tried to do this sort of thing with FluidTrigger but for FluidTrigger to work, multiple of the same buttons would get checked each tick.

My proposed solution would be a modification of FluidTrigger such that you specify some fluid constant button bindings which may be involved in the combination and then you add commands with conditions. Something like:

new FluidTrigger(fluidConstantBinding1, fluidConstantBinding2) {
    @Override
    protected Command getCommand() {
        if (areAnyPressed(fluidConstantBinding1, fluidConstantBinding2)  {
            return someCommand;
        } else if (areAllPressed(fluidConstantBinding1, fluidConstantBinding2) {
            return anotherCommand;
        }
    } 

(this wouldn't be the exact way it would work, just a demonstration of the ease with which I want this to be done).