Gamepad
package com.arcrobotics.ftclib.gamepad
Last updated
Was this helpful?
package com.arcrobotics.ftclib.gamepad
Last updated
Was this helpful?
Was this helpful?
// these are from the GamepadButton class that is used
// for command-based frameworks
GamepadButton grabButton = new GamepadButton(
gamepad1, GamepadKeys.Button.A
);
GamepadButton releaseButton = new GamepadButton(
gamepad2, GamepadKeys.Button.B
);
GamepadEx gamepadEx = new GamepadEx(gamepad1);
gamepadEx.getButton(GamepadKeys.Button.A);
gamepadEx.getTrigger(GamepadKeys.Trigger.RIGHT_TRIGGER);
gamepadEx.getLeftY();
gamepadEx.getRightY();
gamepadEx.getLeftX();
gamepadEx.getRightX();
TriggerReader triggerReader = new TriggerReader(
gamepadEx, GamepadKeys.Trigger.RIGHT_TRIGGER
);
triggerReader.isDown();
triggerReader.readValue();
triggerReader.stateJustChanged();
triggerReader.wasJustPressed();
triggerReader.wasJustReleased();
ButtonReader reader = new ButtonReader(
gamepadEx, GamepadKeys.Button.A
);
reader.readValue();
reader.wasJustPressed();
reader.stateJustChanged();
reader.isDown();
reader.wasJustReleased();
// create the gamepad
GamepadEx myGamepad = new Gamepad(gamepad1);
/** The methods for using the ButtonReaders **/
myGamepad.wasJustPressed(GamepadKeys.Button.A);
myGamepad.stateJustChanged(GamepadKeys.Button.A);
myGamepad.isDown(GamepadKeys.Button.A);
myGamepad.wasJustReleased(GamepadKeys.Button.A);
// pass the GamepadKeys.Button that you want to read
// into the method argument
// to read all buttons at once, perform a single call
myGamepad.readButtons();
/*
this is the equivalent of calling readValue() once
for all your readers
*/
ToggleButtonReader toggleButtonReader = new ToggleButtonReader(
gamepadEx, GamepadKeys.Button.A
);
toggleButtonReader.getState();
GamepadEx toolOp = new GamepadEx(gamepad2);
ToggleButtonReader aReader = new ToggleButtonReader(
toolOp, GamepadKeys.Button.A
);
while (...) {
if (aReader.getState()) {
// if toggle state true
} else {
// if toggle state false
}
aReader.readValue();
}