View Single Post
  #1   Spotlight this post!  
Unread 16-03-2014, 18:21
jwakeman jwakeman is offline
Registered User
FRC #0063 (Red Barons)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: 16510
Posts: 182
jwakeman is just really nicejwakeman is just really nicejwakeman is just really nicejwakeman is just really nicejwakeman is just really nice
Remap Button Action

Using Command Based Java, is it safe and will it work to remap a Button action at run-time?

Example, in the OI class:

Code:
public Button stick2_B = new JoystickButton(stick2, RobotMap.XBOX_B); 
stick2_B.whenPressed(new Command1());
Later, in the execute method of a command I want to do:

Code:
if(SOME_CONDITION)
{
    oi.stick2_B.whenPressed(new Command2());
}
I've already confirmed it will compile so the question is really if it will behave correctly at run-time. Specifically do I need to do anything to de-register stick2_B as a trigger for Command1 or any other sort up cleanup first? I would just test it but I don't have access to a robot until later this week for obvious reasons. Please don't tell me it should work or you think it will work Only if you know from knowledge of the WPILib or experience. Thanks!
Reply With Quote