I don’t think it’s possible. Button.whenPressed() calls Trigger.whenActive(), which adds a ButtonScheduler to the Scheduler’s internal list of buttons. I don’t think there’s a way to remove it. I believe there is an alternative, though.
Custom buttons are pretty easy to make, they just need a get() method. So, if you want an easy way to disable a certain button binding, have a variable:
Button doubleBoundButton; // this is the button you want to trigger differently at different times
boolean initialBindingEnabled = true;
Button initialBinding = new Button() {
public boolean get() {
return initialBindingEnabled && doubleBoundButton.get();
}
},
secondaryBinding = new Button() {
public boolean get() {
return !initialBindingEnabled && doubleBoundButton.get();
}
};
Wow -that is some pretty snappy code! I have never seen the override of a get in a new before, but I’m a relative novice at java. Can any public method be overridden for an instance of a class in Java? I will give it a try tomorrow night.
Btw, do you have a link to the source of the wpilib? There are times when I would like to understand more about what is going on behind the scenes.
lil something i made, allows you to assign different commands to different modes than set the mode of the button (e.g. set A to lock for drive, B for climb in climbing than set the mode of all the buttons to 2 when u want to climb)
Button source code is in C:\Users\yourname\sunspotfrcsdk\lib\wpilibj.src.zip
to your override question… Yeah you can override any public method. You can also use super.(method) to refer to the method that you were overriding
In Java, you can override any non-final method, and anonymous classes (new ClassName() { /* stuff */ }) let you make individual variables with specific versions of methods, instead of having to make a new class every time you want to make a tiny change.
In the sunspotfrcsdk folder (which should be in your user directory), in its lib directory, there are wpilibj.src.zip and wpilibj.project.zip. The src one just has the source files, and the project one is a full netbeans project. The more complicated aspects of command-based programming are in edu.wpi.first.wpilibj.command and edu.wpi.first.wpilibj.buttons.
Everything except primitives is a pointer in Java. You might prefer to call them references, but references are themselves just less flexible (and less dangerous) pointers.