GenericHID

class wpilib.GenericHID(port: SupportsInt | SupportsIndex)

Bases: pybind11_object

Handle input from standard HID devices connected to the Driver Station.

This class handles standard input that comes from the Driver Station. Each time a value is requested the most recent value is returned. There is a single class instance for each device and the mapping of ports to hardware buttons depends on the code in the Driver Station.

class HIDType(value: SupportsInt | SupportsIndex)

Bases: pybind11_object

USB HID interface type.

Members:

UNKNOWN : Unknown.

STANDARD : Standard HID device.

XBOX_360 : Xbox 360 controller.

XBOX_ONE : Xbox One controller.

PS3 : PS3 controller.

PS4 : PS4 controller.

PS5 : PS5 controller.

SWITCH_PRO : Nintendo Switch Pro controller.

SWITCH_JOYCON_LEFT : Nintendo Switch Joycon Left controller.

SWITCH_JOYCON_RIGHT : Nintendo Switch Joycon Right controller.

SWITCH_JOYCON_PAIR : Nintendo Switch Joycon controller pair.

PS3 = <HIDType.PS3: 4>
PS4 = <HIDType.PS4: 5>
PS5 = <HIDType.PS5: 6>
STANDARD = <HIDType.STANDARD: 1>
SWITCH_JOYCON_LEFT = <HIDType.SWITCH_JOYCON_LEFT: 8>
SWITCH_JOYCON_PAIR = <HIDType.SWITCH_JOYCON_PAIR: 10>
SWITCH_JOYCON_RIGHT = <HIDType.SWITCH_JOYCON_RIGHT: 9>
SWITCH_PRO = <HIDType.SWITCH_PRO: 7>
UNKNOWN = <HIDType.UNKNOWN: 0>
XBOX_360 = <HIDType.XBOX_360: 2>
XBOX_ONE = <HIDType.XBOX_ONE: 3>
GenericHID.HIDType.name -> str
property value
POV(*args, **kwargs)

Overloaded function.

  1. POV(self: wpilib._wpilib.GenericHID, angle: wpilib._wpilib.POVDirection, loop: wpilib._wpilib.EventLoop) -> wpilib._wpilib.BooleanEvent

Constructs a BooleanEvent instance based around this angle of a POV on the HID.

Parameters:
  • loop – the event loop instance to attach the event to.

  • angle – POV angle.

Returns:

a BooleanEvent instance based around this angle of a POV on the HID.

  1. POV(self: wpilib._wpilib.GenericHID, pov: typing.SupportsInt | typing.SupportsIndex, angle: wpilib._wpilib.POVDirection, loop: wpilib._wpilib.EventLoop) -> wpilib._wpilib.BooleanEvent

Constructs a BooleanEvent instance based around this angle of a POV on the HID.

Parameters:
  • loop – the event loop instance to attach the event to.

  • pov – index of the POV to read (starting at 0). Defaults to 0.

  • angle – POV angle.

Returns:

a BooleanEvent instance based around this angle of a POV on the HID.

POVCenter(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent

Constructs a BooleanEvent instance based around the center (not pressed) of the default (index 0) POV on the HID.

Returns:

a BooleanEvent instance based around the center of a POV on the HID.

POVDown(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent

Constructs a BooleanEvent instance based around the down direction of the default (index 0) POV on the HID.

Returns:

a BooleanEvent instance based around the down direction of a POV on the HID.

POVDownLeft(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent

Constructs a BooleanEvent instance based around the down left direction of the default (index 0) POV on the HID.

Returns:

a BooleanEvent instance based around the down left direction of a POV on the HID.

POVDownRight(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent

Constructs a BooleanEvent instance based around the down right direction of the default (index 0) POV on the HID.

Returns:

a BooleanEvent instance based around the down right direction of a POV on the HID.

POVLeft(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent

Constructs a BooleanEvent instance based around the left direction of the default (index 0) POV on the HID.

Returns:

a BooleanEvent instance based around the left direction of a POV on the HID.

POVRight(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent

Constructs a BooleanEvent instance based around the right direction of the default (index 0) POV on the HID.

Returns:

a BooleanEvent instance based around the right direction of a POV on the HID.

POVUp(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent

Constructs a BooleanEvent instance based around the up direction of the default (index 0) POV on the HID.

Returns:

a BooleanEvent instance based around the up direction of a POV on the HID.

POVUpLeft(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent

Constructs a BooleanEvent instance based around the up left direction of the default (index 0) POV on the HID.

Returns:

a BooleanEvent instance based around the up left direction of a POV on the HID.

POVUpRight(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent

Constructs a BooleanEvent instance based around the up right direction of the default (index 0) POV on the HID.

Returns:

a BooleanEvent instance based around the up right direction of a POV on the HID.

class RumbleType(value: SupportsInt | SupportsIndex)

Bases: pybind11_object

Represents a rumble output on the Joystick.

Members:

LEFT_RUMBLE : Left rumble motor.

RIGHT_RUMBLE : Right rumble motor.

LEFT_TRIGGER_RUMBLE : Left trigger rumble motor.

RIGHT_TRIGGER_RUMBLE : Right trigger rumble motor.

LEFT_RUMBLE = <RumbleType.LEFT_RUMBLE: 0>
LEFT_TRIGGER_RUMBLE = <RumbleType.LEFT_TRIGGER_RUMBLE: 2>
RIGHT_RUMBLE = <RumbleType.RIGHT_RUMBLE: 1>
RIGHT_TRIGGER_RUMBLE = <RumbleType.RIGHT_TRIGGER_RUMBLE: 3>
GenericHID.RumbleType.name -> str
property value
class SupportedOutputs(value: SupportsInt | SupportsIndex)

Bases: pybind11_object

Represents the various outputs that a HID may support.

Members:

NONE : No outputs supported.

MONO_LED : Mono LED support.

RGB_LED : RGB LED support.

PLAYER_LED : Player LED support.

RUMBLE : Rumble support.

TRIGGER_RUMBLE : Trigger rumble support.

MONO_LED = <SupportedOutputs.MONO_LED: 1>
NONE = <SupportedOutputs.NONE: 0>
PLAYER_LED = <SupportedOutputs.PLAYER_LED: 4>
RGB_LED = <SupportedOutputs.RGB_LED: 2>
RUMBLE = <SupportedOutputs.RUMBLE: 8>
TRIGGER_RUMBLE = <SupportedOutputs.TRIGGER_RUMBLE: 16>
GenericHID.SupportedOutputs.name -> str
property value
axisGreaterThan(axis: SupportsInt | SupportsIndex, threshold: SupportsFloat | SupportsIndex, loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent

Constructs an event instance that is true when the axis value is greater than threshold

Parameters:
  • axis – The axis to read, starting at 0.

  • threshold – The value above which this trigger 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.

axisLessThan(axis: SupportsInt | SupportsIndex, threshold: SupportsFloat | SupportsIndex, loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent

Constructs an event instance that is true when the axis value is less than threshold

Parameters:
  • axis – The axis to read, starting at 0.

  • threshold – The value below which this trigger 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.

button(button: SupportsInt | SupportsIndex, loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent

Constructs an event instance around this button’s digital signal.

Parameters:
  • button – the button index

  • 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.

getAxesAvailable() int

Get the number of axes for the HID.

Returns:

the number of axis for the current HID

getAxesMaximumIndex() int
getButtonsAvailable() int

Get the number of buttons for the HID.

Returns:

the number of buttons on the current HID

getButtonsMaximumIndex() int
getGamepadType() wpilib._wpilib.GenericHID.HIDType

Get the type of the HID.

Returns:

the type of the HID.

getName() str

Get the name of the HID.

Returns:

the name of the HID.

getPOV(pov: SupportsInt | SupportsIndex = 0) wpilib._wpilib.POVDirection

Get the angle of a POV on the HID.

Parameters:

pov – The index of the POV to read (starting at 0)

Returns:

the angle of the POV.

getPOVsAvailable() int

Get the number of POVs for the HID.

Returns:

the number of POVs for the current HID

getPOVsMaximumIndex() int
getPort() int

Get the port number of the HID.

Returns:

The port number of the HID.

getRawAxis(axis: SupportsInt | SupportsIndex) float

Get the value of the axis.

Parameters:

axis – The axis to read, starting at 0.

Returns:

The value of the axis.

getRawButton(button: SupportsInt | SupportsIndex) bool

Get the button value (starting at button 1).

The buttons are returned in a single 16 bit value with one bit representing the state of each button. The appropriate button is returned as a boolean value.

This method returns true if the button is being held down at the time that this method is being called.

Parameters:

button – The button number to be read (starting at 1)

Returns:

The state of the button.

getRawButtonPressed(button: SupportsInt | SupportsIndex) bool

Whether the button was pressed since the last check. %Button indexes begin at 1.

This method returns true if the button went from not pressed to held down since the last time this method was called. This is useful if you only want to call a function once when you press the button.

Parameters:

button – The button index, beginning at 0.

Returns:

Whether the button was pressed since the last check.

getRawButtonReleased(button: SupportsInt | SupportsIndex) bool

Whether the button was released since the last check. %Button indexes begin at 1.

This method returns true if the button went from held down to not pressed since the last time this method was called. This is useful if you only want to call a function once when you release the button.

Parameters:

button – The button index, beginning at 0.

Returns:

Whether the button was released since the last check.

getSupportedOutputs() wpilib._wpilib.GenericHID.SupportedOutputs

Get the supported outputs of the HID.

Returns:

the supported outputs of the HID.

getTouchpadFinger(touchpad: SupportsInt | SupportsIndex, finger: SupportsInt | SupportsIndex) wpilib._wpilib.TouchpadFinger

Get the touchpad finger data.

Parameters:
  • touchpad – The touchpad to read.

  • finger – The finger to read.

Returns:

The touchpad finger data.

getTouchpadFingerAvailable(touchpad: SupportsInt | SupportsIndex, finger: SupportsInt | SupportsIndex) bool

Check if a touchpad finger is available.

Parameters:
  • touchpad – The touchpad to check.

  • finger – The finger to check.

Returns:

true if the touchpad finger is available.

isConnected() bool

Get if the HID is connected.

Returns:

true if the HID is connected

setLeds(r: SupportsInt | SupportsIndex, g: SupportsInt | SupportsIndex, b: SupportsInt | SupportsIndex) None

Set leds on the controller. If only mono is supported, the system will use the highest value passed in.

Parameters:
  • r – Red value from 0-255

  • g – Green value from 0-255

  • b – Blue value from 0-255

setRumble(type: wpilib._wpilib.GenericHID.RumbleType, value: SupportsFloat | SupportsIndex) None

Set the rumble output for the HID.

The DS currently supports 4 rumble values: left rumble, right rumble, left trigger rumble, and right trigger rumble.

Parameters:
  • type – Which rumble value to set

  • value – The normalized value (0 to 1) to set the rumble to