Class FtcGamepad


public class FtcGamepad extends TrcGameController
This class implements the platform dependent gamepad. It provides monitoring of the gamepad buttons. If the caller of this class provides a button notification handler, it will call it when there are button events.
  • Field Details

  • Constructor Details

    • FtcGamepad

      public FtcGamepad(String instanceName, com.qualcomm.robotcore.hardware.Gamepad gamepad, double deadbandThreshold)
      Constructor: Create an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      gamepad - specifies the gamepad associated with this instance.
      deadbandThreshold - specifies the deadband of the gamepad analog sticks.
    • FtcGamepad

      public FtcGamepad(String instanceName, com.qualcomm.robotcore.hardware.Gamepad gamepad)
      Constructor: Create an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      gamepad - specifies the gamepad associated with this instance.
  • Method Details

    • setButtonEventHandler

      public void setButtonEventHandler(FtcGamepad.ButtonEventHandler buttonEventHandler)
      This method sets the button event handler.
      Parameters:
      buttonEventHandler - specifies button event notification handler, null to disable event notification.
    • setLeftStickInverted

      public void setLeftStickInverted(boolean xInverted, boolean yInverted)
      This method inverts the left analog stick axes.
      Parameters:
      xInverted - specifies true if inverting the x-axis, false otherwise.
      yInverted - specifies true if inverting the y-axis, false otherwise.
    • setRightStickInverted

      public void setRightStickInverted(boolean xInverted, boolean yInverted)
      This method inverts the right analog stick axes.
      Parameters:
      xInverted - specifies true if inverting the x-axis, false otherwise.
      yInverted - specifies true if inverting the y-axis, false otherwise.
    • getLeftStickX

      public double getLeftStickX(double cubicCoefficient)
      This method returns the x-axis value of the left stick using the cubic polynomial curve.
      Parameters:
      cubicCoefficient - specifies the cubic coefficient.
      Returns:
      x-axis value of the left stick.
    • getLeftStickX

      public double getLeftStickX(boolean doExp)
      This method returns the x-axis value of the left stick.
      Parameters:
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      x-axis value of the left stick.
    • getLeftStickX

      public double getLeftStickX()
      This method returns the x-axis value of the left stick.
      Returns:
      x-axis value of the left stick.
    • getLeftStickY

      public double getLeftStickY(double cubicCoefficient)
      This method returns the y-axis value of the left stick using the cubic polynomial curve.
      Parameters:
      cubicCoefficient - specifies the cubic coefficient.
      Returns:
      y-axis value of the left stick.
    • getLeftStickY

      public double getLeftStickY(boolean doExp)
      This method returns the y-axis value of the left stick.
      Parameters:
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      y-axis value of the left stick.
    • getLeftStickY

      public double getLeftStickY()
      This method returns the y-axis value of the left stick.
      Returns:
      y-axis value of the left stick.
    • getRightStickX

      public double getRightStickX(double cubicCoefficient)
      This method returns the x-axis value of the right stick using the cubic polynomial curve.
      Parameters:
      cubicCoefficient - specifies the cubic coefficient.
      Returns:
      x-axis value of the right stick.
    • getRightStickX

      public double getRightStickX(boolean doExp)
      This method returns the x-axis value of the right stick.
      Parameters:
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      x-axis value of the right stick.
    • getRightStickX

      public double getRightStickX()
      This method returns the x-axis value of the right stick.
      Returns:
      x-axis value of the right stick.
    • getRightStickY

      public double getRightStickY(double cubicCoefficient)
      This method returns the y-axis value of the right stick using the cubic polynomial curve.
      Parameters:
      cubicCoefficient - specifies the cubic coefficient.
      Returns:
      y-axis value of the right stick.
    • getRightStickY

      public double getRightStickY(boolean doExp)
      This method returns the y-axis value of the right stick.
      Parameters:
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      y-axis value of the right stick.
    • getRightStickY

      public double getRightStickY()
      This method returns the y-axis value of the right stick.
      Returns:
      y-axis value of the right stick.
    • getLeftTrigger

      public double getLeftTrigger(double cubicCoefficient)
      This method returns the left trigger value using the cubic polynomial curve.
      Parameters:
      cubicCoefficient - specifies the cubic coefficient.
      Returns:
      left trigger value.
    • getLeftTrigger

      public double getLeftTrigger(boolean doExp)
      This method returns the left trigger value.
      Parameters:
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      left trigger value.
    • getLeftTrigger

      public double getLeftTrigger()
      This method returns the left trigger value.
      Returns:
      left trigger value.
    • getRightTrigger

      public double getRightTrigger(double cubicCoefficient)
      This method returns the right trigger value using the cubic polynomial curve.
      Parameters:
      cubicCoefficient - specifies the cubic coefficient.
      Returns:
      right trigger value.
    • getRightTrigger

      public double getRightTrigger(boolean doExp)
      This method returns the right trigger value.
      Parameters:
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      right trigger value.
    • getRightTrigger

      public double getRightTrigger()
      This method returns the right trigger value.
      Returns:
      right trigger value.
    • getTrigger

      public double getTrigger(double cubicCoefficient)
      This method combines the left trigger and right trigger values to a value with a range of -1.0 to 1.0 using the cubic polynomial curve.
      Parameters:
      cubicCoefficient - specifies the cubic coefficient.
      Returns:
      combined left and right trigger value.
    • getTrigger

      public double getTrigger(boolean doExp)
      This method combines the left trigger and right trigger values to a value with a range of -1.0 to 1.0.
      Parameters:
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      combined left and right trigger value.
    • getTrigger

      public double getTrigger()
      This method combines the left trigger and right trigger values to a value with a range of -1.0 to 1.0.
      Returns:
      combined left and right trigger value.
    • getDriveInputs

      public double[] getDriveInputs(TrcGameController.DriveMode driveMode, boolean doExp, double drivePowerScale, double turnPowerScale)
      This method reads various joystick/gamepad control values and returns the drive powers for all three degrees of robot movement.
      Parameters:
      driveMode - specifies the drive mode which determines the control mappings.
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      drivePowerScale - specifies the scaling factor for drive power.
      turnPowerScale - specifies the scaling factor for turn power.
      Returns:
      an array of 3 values for x, y and rotation power.
    • getDriveInputs

      public double[] getDriveInputs(TrcGameController.DriveMode driveMode, boolean doExp)
      This method reads various joystick/gamepad control values and returns the drive powers for all three degrees of robot movement.
      Parameters:
      driveMode - specifies the drive mode which determines the control mappings.
      doExp - specifies true if the value should be raised exponentially, false otherwise. If the value is raised exponentially, it gives you more precise control on the low end values.
      Returns:
      an array of 3 values for x, y and rotation power.
    • getButtons

      public int getButtons()
      This method returns the button states in an integer by combining all the button states.
      Specified by:
      getButtons in class TrcGameController
      Returns:
      button states.
    • notifyButtonEvent

      protected void notifyButtonEvent(int buttonValue, boolean pressed)
      This method is called when a button event is detected. It translates the button value into button type and calls the button event handler.
      Specified by:
      notifyButtonEvent in class TrcGameController
      Parameters:
      buttonValue - specifies the button value that generated the event.
      pressed - specifies true if the button is pressed, false if it is released.