GenericHID

class wpilib.interfaces.GenericHID(port: int)

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: int)

Bases: pybind11_object

Members:

kUnknown

kXInputUnknown

kXInputGamepad

kXInputWheel

kXInputArcadeStick

kXInputFlightStick

kXInputDancePad

kXInputGuitar

kXInputGuitar2

kXInputDrumKit

kXInputGuitar3

kXInputArcadePad

kHIDJoystick

kHIDGamepad

kHIDDriving

kHIDFlight

kHID1stPerson

kHID1stPerson = <HIDType.kHID1stPerson: 24>
kHIDDriving = <HIDType.kHIDDriving: 22>
kHIDFlight = <HIDType.kHIDFlight: 23>
kHIDGamepad = <HIDType.kHIDGamepad: 21>
kHIDJoystick = <HIDType.kHIDJoystick: 20>
kUnknown = <HIDType.kUnknown: -1>
kXInputArcadePad = <HIDType.kXInputArcadePad: 19>
kXInputArcadeStick = <HIDType.kXInputArcadeStick: 3>
kXInputDancePad = <HIDType.kXInputDancePad: 5>
kXInputDrumKit = <HIDType.kXInputDrumKit: 8>
kXInputFlightStick = <HIDType.kXInputFlightStick: 4>
kXInputGamepad = <HIDType.kXInputGamepad: 1>
kXInputGuitar = <HIDType.kXInputGuitar: 6>
kXInputGuitar2 = <HIDType.kXInputGuitar2: 7>
kXInputGuitar3 = <HIDType.kXInputGuitar3: 11>
kXInputUnknown = <HIDType.kXInputUnknown: 0>
kXInputWheel = <HIDType.kXInputWheel: 2>
property name
property value
POV(*args, **kwargs)

Overloaded function.

  1. POV(self: wpilib.interfaces._interfaces.GenericHID, angle: int, loop: wpilib.event._event.EventLoop) -> wpilib.event._event.BooleanEvent

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

The POV angles start at 0 in the up direction, and increase clockwise (eg right is 90, upper-left is 315).

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

  • angle – POV angle in degrees, or -1 for the center / not pressed.

Returns:

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

  1. POV(self: wpilib.interfaces._interfaces.GenericHID, pov: int, angle: int, loop: wpilib.event._event.EventLoop) -> wpilib.event._event.BooleanEvent

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

The POV angles start at 0 in the up direction, and increase clockwise (eg right is 90, upper-left is 315).

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 in degrees, or -1 for the center / not pressed.

Returns:

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

POVCenter(loop: wpilib.event._event.EventLoop) wpilib.event._event.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.event._event.EventLoop) wpilib.event._event.BooleanEvent

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

Returns:

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

POVDownLeft(loop: wpilib.event._event.EventLoop) wpilib.event._event.BooleanEvent

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

Returns:

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

POVDownRight(loop: wpilib.event._event.EventLoop) wpilib.event._event.BooleanEvent

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

Returns:

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

POVLeft(loop: wpilib.event._event.EventLoop) wpilib.event._event.BooleanEvent

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

Returns:

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

POVRight(loop: wpilib.event._event.EventLoop) wpilib.event._event.BooleanEvent

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

Returns:

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

POVUp(loop: wpilib.event._event.EventLoop) wpilib.event._event.BooleanEvent

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

Returns:

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

POVUpLeft(loop: wpilib.event._event.EventLoop) wpilib.event._event.BooleanEvent

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

Returns:

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

POVUpRight(loop: wpilib.event._event.EventLoop) wpilib.event._event.BooleanEvent

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

Returns:

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

class RumbleType(value: int)

Bases: pybind11_object

Members:

kLeftRumble

kRightRumble

kBothRumble

kBothRumble = <RumbleType.kBothRumble: 2>
kLeftRumble = <RumbleType.kLeftRumble: 0>
kRightRumble = <RumbleType.kRightRumble: 1>
property name
property value
axisGreaterThan(axis: int, threshold: float, loop: wpilib.event._event.EventLoop) wpilib.event._event.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: int, threshold: float, loop: wpilib.event._event.EventLoop) wpilib.event._event.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: int, loop: wpilib.event._event.EventLoop) wpilib.event._event.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.

getAxisCount() int

Get the number of axes for the HID.

Returns:

the number of axis for the current HID

getAxisType(axis: int) int

Get the axis type of a joystick axis.

Returns:

the axis type of a joystick axis.

getButtonCount() int

Get the number of buttons for the HID.

Returns:

the number of buttons on the current HID

getName() str

Get the name of the HID.

Returns:

the name of the HID.

getPOV(pov: int = 0) int

Get the angle in degrees of a POV on the HID.

The POV angles start at 0 in the up direction, and increase clockwise (e.g. right is 90, upper-left is 315).

Parameters:

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

Returns:

the angle of the POV in degrees, or -1 if the POV is not pressed.

getPOVCount() int

Get the number of POVs for the HID.

Returns:

the number of POVs for the current HID

getPort() int

Get the port number of the HID.

Returns:

The port number of the HID.

getRawAxis(axis: int) float

Get the value of the axis.

Parameters:

axis – The axis to read, starting at 0.

Returns:

The value of the axis.

getRawButton(button: int) 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: int) 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 1.

Returns:

Whether the button was pressed since the last check.

getRawButtonReleased(button: int) 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 1.

Returns:

Whether the button was released since the last check.

getType() wpilib.interfaces._interfaces.GenericHID.HIDType

Get the type of the HID.

Returns:

the type of the HID.

isConnected() bool

Get if the HID is connected.

Returns:

true if the HID is connected

setOutput(outputNumber: int, value: bool) None

Set a single HID output value for the HID.

Parameters:
  • outputNumber – The index of the output to set (1-32)

  • value – The value to set the output to

setOutputs(value: int) None

Set all output values for the HID.

Parameters:

value – The 32 bit output value (1 bit for each output)

setRumble(type: wpilib.interfaces._interfaces.GenericHID.RumbleType, value: float) None

Set the rumble output for the HID.

The DS currently supports 2 rumble values, left rumble and right rumble.

Parameters:
  • type – Which rumble value to set

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