GenericHID

class wpilib.interfaces.GenericHID(self: wpilib.interfaces.GenericHID, port: int) → None

Bases: pybind11_builtins.pybind11_object

GenericHID Interface.

class HIDType(self: wpilib.interfaces._interfaces.GenericHID.HIDType, value: int) → None

Bases: pybind11_builtins.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
class Hand(self: wpilib.interfaces._interfaces.GenericHID.Hand, value: int) → None

Bases: pybind11_builtins.pybind11_object

Members:

kLeftHand

kRightHand

kLeftHand = <Hand.kLeftHand: 0>
kRightHand = <Hand.kRightHand: 1>
property name
class RumbleType(self: wpilib.interfaces._interfaces.GenericHID.RumbleType, value: int) → None

Bases: pybind11_builtins.pybind11_object

Members:

kLeftRumble

kRightRumble

kLeftRumble = <RumbleType.kLeftRumble: 0>
kRightRumble = <RumbleType.kRightRumble: 1>
property name
getAxisCount(self: wpilib.interfaces.GenericHID) → int

Get the number of axes for the HID.

Returns

the number of axis for the current HID

getAxisType(self: wpilib.interfaces.GenericHID, axis: int) → int

Get the axis type of a joystick axis.

Returns

the axis type of a joystick axis.

getButtonCount(self: wpilib.interfaces.GenericHID) → int

Get the number of buttons for the HID.

Returns

the number of buttons on the current HID

getName(self: wpilib.interfaces.GenericHID) → str

Get the name of the HID.

Returns

the name of the HID.

getPOV(self: wpilib.interfaces.GenericHID, 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(self: wpilib.interfaces.GenericHID) → int

Get the number of POVs for the HID.

Returns

the number of POVs for the current HID

getPort(self: wpilib.interfaces.GenericHID) → int

Get the port number of the HID.

Returns

The port number of the HID.

getRawAxis(self: wpilib.interfaces.GenericHID, 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(self: wpilib.interfaces.GenericHID, 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(self: wpilib.interfaces.GenericHID, 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(self: wpilib.interfaces.GenericHID, 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(self: wpilib.interfaces.GenericHID) → wpilib.interfaces._interfaces.GenericHID.HIDType

Get the type of the HID.

Returns

the type of the HID.

getX(hand: wpilib.interfaces._interfaces.GenericHID.Hand = <Hand.kRightHand: 1>) → float
getY(hand: wpilib.interfaces._interfaces.GenericHID.Hand = <Hand.kRightHand: 1>) → float
isConnected(self: wpilib.interfaces.GenericHID) → bool

Get if the HID is connected.

Returns

true if the HID is connected

setOutput(self: wpilib.interfaces.GenericHID, 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(self: wpilib.interfaces.GenericHID, value: int) → None

Set all output values for the HID.

Parameters

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

setRumble(self: wpilib.interfaces.GenericHID, 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