My team does not have any Attack3 controllers for some reason, due to them getting lost. We did find and alternative as the Logitech controller for the FTC competitions. The issues are that the whole controller takes only one Joystick slot and I wanted to know if the there is code to separate the two joysticks on the controller for Tank Drive. And as a side question: Can you use XBOX or PS3 controllers for any movement.
As for the logitech controllers: Yes, there is code to separate the joysticks. However, you simply treat the whole controller as a single Joystick object.
Example:
Joystick logitechController = new Joystick(1);
//Read the y axis on the left joystick
logitechController.getRawAxis(leftYAxis); //<-- Experiment to find the exact //axis value
//Read the y axis on the right joystick
logitechController.getRawAxis(rightYAxis); // <-- find the right axis number
You’ll have to experiment a bit to find the correct axis numbers to make it work properly, and possibly invert the outputs (sometimes down is positive), but each joystick is really just two independent axis’ on the same “joystick” controller.
Also, you should be able to use any USB controller. Last year we used an XBOX controller. We just had to install a driver from the xbox/microsoft website.
Joystick joy1 = new Joystick(1); // create a joystick on USB port 1 (configured through driverstation)
joy1.getRawAxis(2); //this will return the left stick Y value
joy1.getRawAxis(5); //this will return the right stick Y value
You could also make all the axis and buttons contants, so it’s easier for everyone to know what axis/button you’re calling.
Just add this to either the same file, or an interface:
// Gamepad axis
public static final int kGamepadAxisLeftStickX = 1;
public static final int kGamepadAxisLeftStickY = 2;
public static final int kGamepadAxisShoulder = 3;
public static final int kGamepadAxisRightStickX = 4;
public static final int kGamepadAxisRightStickY = 5;
public static final int kGamepadAxisDpad = 6;
// Gamepad buttons
public static final int kGamepadButtonA = 1; // Bottom Button
public static final int kGamepadButtonB = 2; // Right Button
public static final int kGamepadButtonX = 3; // Left Button
public static final int kGamepadButtonY = 4; // Top Button
public static final int kGamepadButtonShoulderL = 5;
public static final int kGamepadButtonShoulderR = 6;
public static final int kGamepadButtonBack = 7;
public static final int kGamepadButtonStart = 8;
public static final int kGamepadButtonLeftStick = 9;
public static final int kGamepadButtonRightStick = 10;
public static final int kGamepadButtonMode = -1;
public static final int kGamepadButtonLogitech = -1;
Sorry, -1 is because we haven’t tested what buttons those two are yet.
So if those are in an interface and you implement it, this is how you can call it: