Class LogitechF310Controller

java.lang.Object
org.wpilib.driverstation.LogitechF310Controller
All Implemented Interfaces:
HIDDevice, TelemetryLoggable

public class LogitechF310Controller extends Object implements HIDDevice, TelemetryLoggable
Handle input from LogitechF310 controllers connected to the Driver Station.

This class handles LogitechF310 input that comes from the Driver Station. Each time a value is requested the most recent value is returned.

  • Field Details

    • TOUCHPAD_COUNT

      public static final int TOUCHPAD_COUNT
      The number of touchpads supported by this controller.
      See Also:
    • SUPPORTS_RUMBLE

      public static final boolean SUPPORTS_RUMBLE
      Whether this controller supports main rumble motors.
      See Also:
    • SUPPORTS_TRIGGER_RUMBLE

      public static final boolean SUPPORTS_TRIGGER_RUMBLE
      Whether this controller supports trigger rumble motors.
      See Also:
    • SUPPORTS_MONO_LED

      public static final boolean SUPPORTS_MONO_LED
      Whether this controller supports mono LED output.
      See Also:
    • SUPPORTS_RGB_LED

      public static final boolean SUPPORTS_RGB_LED
      Whether this controller supports RGB LED output.
      See Also:
  • Constructor Details

    • LogitechF310Controller

      public LogitechF310Controller(int port)
      Construct an instance of a controller.
      Parameters:
      port - The port index on the Driver Station that the controller is plugged into.
    • LogitechF310Controller

      public LogitechF310Controller(GenericHID hid)
      Construct an instance of a controller with a GenericHID object.
      Parameters:
      hid - The GenericHID object to use for this controller.
  • Method Details

    • getHID

      public GenericHID getHID()
      Get the underlying GenericHID object.
      Specified by:
      getHID in interface HIDDevice
      Returns:
      the wrapped GenericHID object
    • getSupportedOutputCapabilities

      public static EnumSet<GenericHID.SupportedOutput> getSupportedOutputCapabilities()
      Get the supported outputs expected for this controller type.
      Returns:
      the expected supported outputs
    • getPort

      public int getPort()
      Get the port number of the HID.
      Returns:
      The port number of the HID.
    • isConnected

      public boolean isConnected()
      Get if the HID is connected.
      Returns:
      true if the HID is connected
    • getLeftX

      public double getLeftX()
      Get the Left X value of the controller.

      A deadband of 0.1 is applied by default. Use setLeftXDeadband(double) to change it.

      Returns:
      The axis value.
    • setLeftXDeadband

      public void setLeftXDeadband(double deadband)
      Set the deadband for the Left X axis.

      The deadband is clamped to [0, 1).

      Parameters:
      deadband - The deadband to apply.
    • getLeftY

      public double getLeftY()
      Get the Left Y value of the controller.

      A deadband of 0.1 is applied by default. Use setLeftYDeadband(double) to change it.

      Returns:
      The axis value.
    • setLeftYDeadband

      public void setLeftYDeadband(double deadband)
      Set the deadband for the Left Y axis.

      The deadband is clamped to [0, 1).

      Parameters:
      deadband - The deadband to apply.
    • getRightX

      public double getRightX()
      Get the Right X value of the controller.

      A deadband of 0.1 is applied by default. Use setRightXDeadband(double) to change it.

      Returns:
      The axis value.
    • setRightXDeadband

      public void setRightXDeadband(double deadband)
      Set the deadband for the Right X axis.

      The deadband is clamped to [0, 1).

      Parameters:
      deadband - The deadband to apply.
    • getRightY

      public double getRightY()
      Get the Right Y value of the controller.

      A deadband of 0.1 is applied by default. Use setRightYDeadband(double) to change it.

      Returns:
      The axis value.
    • setRightYDeadband

      public void setRightYDeadband(double deadband)
      Set the deadband for the Right Y axis.

      The deadband is clamped to [0, 1).

      Parameters:
      deadband - The deadband to apply.
    • getLeftTrigger

      public double getLeftTrigger()
      Get the Left Trigger value of the controller.

      A deadband of 0.01 is applied by default. Use setLeftTriggerDeadband(double) to change it.

      Returns:
      The axis value.
    • setLeftTriggerDeadband

      public void setLeftTriggerDeadband(double deadband)
      Set the deadband for the Left Trigger axis.

      The deadband is clamped to [0, 1).

      Parameters:
      deadband - The deadband to apply.
    • getRightTrigger

      public double getRightTrigger()
      Get the Right Trigger value of the controller.

      A deadband of 0.01 is applied by default. Use setRightTriggerDeadband(double) to change it.

      Returns:
      The axis value.
    • setRightTriggerDeadband

      public void setRightTriggerDeadband(double deadband)
      Set the deadband for the Right Trigger axis.

      The deadband is clamped to [0, 1).

      Parameters:
      deadband - The deadband to apply.
    • getAxis

      public double getAxis(LogitechF310Controller.Axis axis)
      Get the value of the axis.
      Parameters:
      axis - The axis to read
      Returns:
      The axis value.
    • axisLessThan

      public BooleanEvent axisLessThan(LogitechF310Controller.Axis axis, double threshold, EventLoop loop)
      Constructs an event instance that is true when the axis value is less than threshold.
      Parameters:
      axis - The axis to read.
      threshold - The value below which this event should return true.
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance that is true when the axis value is less than the provided threshold.
    • axisGreaterThan

      public BooleanEvent axisGreaterThan(LogitechF310Controller.Axis axis, double threshold, EventLoop loop)
      Constructs an event instance that is true when the axis value is greater than threshold.
      Parameters:
      axis - The axis to read.
      threshold - The value above which this event should return true.
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance that is true when the axis value is greater than the provided threshold.
    • getAButton

      public boolean getAButton()
      Read the value of the A button on the controller.
      Returns:
      The state of the button.
    • getAButtonPressed

      public boolean getAButtonPressed()
      Whether the A button was pressed since the last check.
      Returns:
      Whether the button was pressed since the last check.
    • getAButtonReleased

      public boolean getAButtonReleased()
      Whether the A button was released since the last check.
      Returns:
      Whether the button was released since the last check.
    • a

      public BooleanEvent a(EventLoop loop)
      Constructs an event instance around the A button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the A button's digital signal attached to the given loop.
    • getBButton

      public boolean getBButton()
      Read the value of the B button on the controller.
      Returns:
      The state of the button.
    • getBButtonPressed

      public boolean getBButtonPressed()
      Whether the B button was pressed since the last check.
      Returns:
      Whether the button was pressed since the last check.
    • getBButtonReleased

      public boolean getBButtonReleased()
      Whether the B button was released since the last check.
      Returns:
      Whether the button was released since the last check.
    • b

      public BooleanEvent b(EventLoop loop)
      Constructs an event instance around the B button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the B button's digital signal attached to the given loop.
    • getXButton

      public boolean getXButton()
      Read the value of the X button on the controller.
      Returns:
      The state of the button.
    • getXButtonPressed

      public boolean getXButtonPressed()
      Whether the X button was pressed since the last check.
      Returns:
      Whether the button was pressed since the last check.
    • getXButtonReleased

      public boolean getXButtonReleased()
      Whether the X button was released since the last check.
      Returns:
      Whether the button was released since the last check.
    • x

      public BooleanEvent x(EventLoop loop)
      Constructs an event instance around the X button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the X button's digital signal attached to the given loop.
    • getYButton

      public boolean getYButton()
      Read the value of the Y button on the controller.
      Returns:
      The state of the button.
    • getYButtonPressed

      public boolean getYButtonPressed()
      Whether the Y button was pressed since the last check.
      Returns:
      Whether the button was pressed since the last check.
    • getYButtonReleased

      public boolean getYButtonReleased()
      Whether the Y button was released since the last check.
      Returns:
      Whether the button was released since the last check.
    • y

      public BooleanEvent y(EventLoop loop)
      Constructs an event instance around the Y button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the Y button's digital signal attached to the given loop.
    • getBackButton

      public boolean getBackButton()
      Read the value of the Back button on the controller.
      Returns:
      The state of the button.
    • getBackButtonPressed

      public boolean getBackButtonPressed()
      Whether the Back button was pressed since the last check.
      Returns:
      Whether the button was pressed since the last check.
    • getBackButtonReleased

      public boolean getBackButtonReleased()
      Whether the Back button was released since the last check.
      Returns:
      Whether the button was released since the last check.
    • back

      public BooleanEvent back(EventLoop loop)
      Constructs an event instance around the Back button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the Back button's digital signal attached to the given loop.
    • getLogitechButton

      public boolean getLogitechButton()
      Read the value of the Logitech button on the controller.
      Returns:
      The state of the button.
    • getLogitechButtonPressed

      public boolean getLogitechButtonPressed()
      Whether the Logitech button was pressed since the last check.
      Returns:
      Whether the button was pressed since the last check.
    • getLogitechButtonReleased

      public boolean getLogitechButtonReleased()
      Whether the Logitech button was released since the last check.
      Returns:
      Whether the button was released since the last check.
    • logitech

      public BooleanEvent logitech(EventLoop loop)
      Constructs an event instance around the Logitech button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the Logitech button's digital signal attached to the given loop.
    • getStartButton

      public boolean getStartButton()
      Read the value of the Start button on the controller.
      Returns:
      The state of the button.
    • getStartButtonPressed

      public boolean getStartButtonPressed()
      Whether the Start button was pressed since the last check.
      Returns:
      Whether the button was pressed since the last check.
    • getStartButtonReleased

      public boolean getStartButtonReleased()
      Whether the Start button was released since the last check.
      Returns:
      Whether the button was released since the last check.
    • start

      public BooleanEvent start(EventLoop loop)
      Constructs an event instance around the Start button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the Start button's digital signal attached to the given loop.
    • getLeftStickButton

      public boolean getLeftStickButton()
      Read the value of the Left Stick button on the controller.
      Returns:
      The state of the button.
    • getLeftStickButtonPressed

      public boolean getLeftStickButtonPressed()
      Whether the Left Stick button was pressed since the last check.
      Returns:
      Whether the button was pressed since the last check.
    • getLeftStickButtonReleased

      public boolean getLeftStickButtonReleased()
      Whether the Left Stick button was released since the last check.
      Returns:
      Whether the button was released since the last check.
    • leftStick

      public BooleanEvent leftStick(EventLoop loop)
      Constructs an event instance around the Left Stick button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the Left Stick button's digital signal attached to the given loop.
    • getRightStickButton

      public boolean getRightStickButton()
      Read the value of the Right Stick button on the controller.
      Returns:
      The state of the button.
    • getRightStickButtonPressed

      public boolean getRightStickButtonPressed()
      Whether the Right Stick button was pressed since the last check.
      Returns:
      Whether the button was pressed since the last check.
    • getRightStickButtonReleased

      public boolean getRightStickButtonReleased()
      Whether the Right Stick button was released since the last check.
      Returns:
      Whether the button was released since the last check.
    • rightStick

      public BooleanEvent rightStick(EventLoop loop)
      Constructs an event instance around the Right Stick button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the Right Stick button's digital signal attached to the given loop.
    • getLeftBumperButton

      public boolean getLeftBumperButton()
      Read the value of the Left Bumper button on the controller.
      Returns:
      The state of the button.
    • getLeftBumperButtonPressed

      public boolean getLeftBumperButtonPressed()
      Whether the Left Bumper button was pressed since the last check.
      Returns:
      Whether the button was pressed since the last check.
    • getLeftBumperButtonReleased

      public boolean getLeftBumperButtonReleased()
      Whether the Left Bumper button was released since the last check.
      Returns:
      Whether the button was released since the last check.
    • leftBumper

      public BooleanEvent leftBumper(EventLoop loop)
      Constructs an event instance around the Left Bumper button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the Left Bumper button's digital signal attached to the given loop.
    • getRightBumperButton

      public boolean getRightBumperButton()
      Read the value of the Right Bumper button on the controller.
      Returns:
      The state of the button.
    • getRightBumperButtonPressed

      public boolean getRightBumperButtonPressed()
      Whether the Right Bumper button was pressed since the last check.
      Returns:
      Whether the button was pressed since the last check.
    • getRightBumperButtonReleased

      public boolean getRightBumperButtonReleased()
      Whether the Right Bumper button was released since the last check.
      Returns:
      Whether the button was released since the last check.
    • rightBumper

      public BooleanEvent rightBumper(EventLoop loop)
      Constructs an event instance around the Right Bumper button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the Right Bumper button's digital signal attached to the given loop.
    • getDpadUpButton

      public boolean getDpadUpButton()
      Read the value of the Dpad Up button on the controller.
      Returns:
      The state of the button.
    • getDpadUpButtonPressed

      public boolean getDpadUpButtonPressed()
      Whether the Dpad Up button was pressed since the last check.
      Returns:
      Whether the button was pressed since the last check.
    • getDpadUpButtonReleased

      public boolean getDpadUpButtonReleased()
      Whether the Dpad Up button was released since the last check.
      Returns:
      Whether the button was released since the last check.
    • dpadUp

      public BooleanEvent dpadUp(EventLoop loop)
      Constructs an event instance around the Dpad Up button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the Dpad Up button's digital signal attached to the given loop.
    • getDpadDownButton

      public boolean getDpadDownButton()
      Read the value of the Dpad Down button on the controller.
      Returns:
      The state of the button.
    • getDpadDownButtonPressed

      public boolean getDpadDownButtonPressed()
      Whether the Dpad Down button was pressed since the last check.
      Returns:
      Whether the button was pressed since the last check.
    • getDpadDownButtonReleased

      public boolean getDpadDownButtonReleased()
      Whether the Dpad Down button was released since the last check.
      Returns:
      Whether the button was released since the last check.
    • dpadDown

      public BooleanEvent dpadDown(EventLoop loop)
      Constructs an event instance around the Dpad Down button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the Dpad Down button's digital signal attached to the given loop.
    • getDpadLeftButton

      public boolean getDpadLeftButton()
      Read the value of the Dpad Left button on the controller.
      Returns:
      The state of the button.
    • getDpadLeftButtonPressed

      public boolean getDpadLeftButtonPressed()
      Whether the Dpad Left button was pressed since the last check.
      Returns:
      Whether the button was pressed since the last check.
    • getDpadLeftButtonReleased

      public boolean getDpadLeftButtonReleased()
      Whether the Dpad Left button was released since the last check.
      Returns:
      Whether the button was released since the last check.
    • dpadLeft

      public BooleanEvent dpadLeft(EventLoop loop)
      Constructs an event instance around the Dpad Left button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the Dpad Left button's digital signal attached to the given loop.
    • getDpadRightButton

      public boolean getDpadRightButton()
      Read the value of the Dpad Right button on the controller.
      Returns:
      The state of the button.
    • getDpadRightButtonPressed

      public boolean getDpadRightButtonPressed()
      Whether the Dpad Right button was pressed since the last check.
      Returns:
      Whether the button was pressed since the last check.
    • getDpadRightButtonReleased

      public boolean getDpadRightButtonReleased()
      Whether the Dpad Right button was released since the last check.
      Returns:
      Whether the button was released since the last check.
    • dpadRight

      public BooleanEvent dpadRight(EventLoop loop)
      Constructs an event instance around the Dpad Right button's digital signal.
      Parameters:
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the Dpad Right button's digital signal attached to the given loop.
    • getButton

      public boolean getButton(LogitechF310Controller.Button button)
      Get the button value.
      Parameters:
      button - The button to read
      Returns:
      The state of the button.
    • getButtonPressed

      public boolean getButtonPressed(LogitechF310Controller.Button button)
      Whether the button was pressed since the last check.
      Parameters:
      button - The button to read
      Returns:
      Whether the button was pressed since the last check.
    • getButtonReleased

      public boolean getButtonReleased(LogitechF310Controller.Button button)
      Whether the button was released since the last check.
      Parameters:
      button - The button to read
      Returns:
      Whether the button was released since the last check.
    • button

      public BooleanEvent button(LogitechF310Controller.Button button, EventLoop loop)
      Constructs an event instance around this button's digital signal.
      Parameters:
      button - the button
      loop - the event loop instance to attach the event to.
      Returns:
      an event instance representing the button's digital signal attached to the given loop.
    • setLeds

      public void setLeds(int r, int g, int b)
      Set leds on the controller.
      Parameters:
      r - Red value from 0-255
      g - Green value from 0-255
      b - Blue value from 0-255
    • setRumble

      public void setRumble(GenericHID.RumbleType type, double value)
      Set the rumble output for the HID.
      Parameters:
      type - Which rumble value to set
      value - The normalized value (0 to 1) to set the rumble to
    • getTelemetryType

      public String getTelemetryType()
      Description copied from interface: TelemetryLoggable
      Gets the telemetry table type. Default is no specified table type (null). A mismatch in type during logging results in a reported warning, so this should always return the same value.
      Specified by:
      getTelemetryType in interface TelemetryLoggable
      Returns:
      Table type
    • logTo

      public void logTo(TelemetryTable table)
      Description copied from interface: TelemetryLoggable
      Logs the object to a TelemetryTable.
      Specified by:
      logTo in interface TelemetryLoggable
      Parameters:
      table - telemetry table