parseInputs method

  1. @override
List<Message> parseInputs(
  1. GamepadState state
)
override

Return a list of commands based on the current state of the gamepad.

Implementation

@override
List<Message> parseInputs(GamepadState state) => [
  if (tubeMode) ...[
    if (bumperFlag == -1) ScienceCommand(carousel: CarouselCommand.PREV_TUBE),
    if (bumperFlag == 1) ScienceCommand(carousel: CarouselCommand.NEXT_TUBE),
  ] else ...[
    if (state.normalShoulder != 0) ScienceCommand(carouselMotor: carouselIncrement * state.normalShoulder),
  ],

  if (state.normalLeftY != 0) ScienceCommand(subsurfaceMotor: subsurfaceIncrement * state.normalLeftY),
  if (state.normalRightY != 0) ScienceCommand(scoopMotor: scoopIncrement * state.normalRightY),

  if (state.buttonA) ScienceCommand(pumps: PumpState.PUMP_ON)
  else ScienceCommand(pumps: PumpState.PUMP_OFF),

  if (state.buttonB) ScienceCommand(funnel: ServoState.SERVO_OPEN)
  else ScienceCommand(funnel: ServoState.SERVO_CLOSE),

  if (state.dpadUp) ScienceCommand(scoop: ServoState.SERVO_OPEN),
  if (state.dpadDown) ScienceCommand(scoop: ServoState.SERVO_CLOSE),

  if (state.buttonStart) ScienceCommand(calibrate: true),
  if (state.buttonBack) ScienceCommand(stop: true),
];