Quote:
Originally Posted by LFRobotics
@NWChen I tried that but it didn't work - THANKS though!
@notmattlythgoe In that case id like to do it - wouldn't it be a lot like the XBoxController class other than the fact that it extends the Joystick class - at least the getters would be the same
|
Yes the getters would be similar.
You'll want to get rid of the getRaw...() methods from the XBoxController class because you get those automatically from extending the Joystick class. Also remove the port and driver station fields since the Joystick class takes care of that communication for you.
Don't forget to include a single parameter constructor that calls the Joystick constructor.
Then what you'll want to do is create a list of static final variables that hold the mapping values for the buttons, this way you don't have to memorize what button maps to what value. I would also suggest using these static fields as the values in the getter methods, this way if you ever have to change the value you only have to change it in one place.
Example:
Code:
public static final int A_BUTTON = 0;
public static final int B_BUTTON = 1;
etc...
Code:
public boolean getButtonA() {
return getRawButton(A_BUTTON);
}
Then you can use it like so:
Code:
XBoxController joystick = new XBoxController(1);
private Button button = new JoystickButton(joystick, XBoxController.A_BUTTON);