GenericHID

class wpilib.interfaces.GenericHID(port)[source]

Bases: object

GenericHID Interface.

class HIDType[source]

Bases: enum.IntEnum

An enumeration.

kHID1stPerson = 24
kHIDDriving = 22
kHIDFlight = 23
kHIDGamepad = 21
kHIDJoystick = 20
kUnknown = -1
kXInputArcadePad = 19
kXInputArcadeStick = 3
kXInputDancePad = 5
kXInputDrumKit = 8
kXInputFlightStick = 4
kXInputGamepad = 1
kXInputGuitar = 6
kXInputGuitar2 = 7
kXInputGuitar3 = 11
kXInputUnknown = 0
kXInputWheel = 2
class Hand[source]

Bases: enum.IntEnum

Which hand the Human Interface Device is associated with.

kLeft = 0

Left Hand

kRight = 1

Right Hand

class RumbleType[source]

Bases: enum.IntEnum

Represents a rumble output on the JoyStick.

kLeftRumble = 0

Left Hand

kRightRumble = 1

Right Hand

getAxisCount()[source]

Get the number of axes for the HID

Return type:int
Returns:The number of axis for the current HID
getButtonCount()[source]

For the current HID, return the number of buttons.

Return type:int
getName()[source]

Get the name of the HID.

Return type:str
Returns:the name of the HID.
getPOV(pov=0)[source]

Get the angle in degrees 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:pov (int) – The index of the POV to read (starting at 0)
Return type:int
Returns:the angle of the POV in degrees, or -1 if the POV is not pressed.
getPOVCount()[source]

For the current HID, return the number of POVs.

Return type:int
getPort()[source]

Get the port number of the HID.

Return type:int
Returns:The port number of the HID.
getRawAxis(axis)[source]

Get the raw axis.

Parameters:axis (int) – index of the axis
Return type:float
Returns:the raw value of the selected axis
getRawButton(button)[source]

Get the button value (starting at button 1).

Parameters:button (int) – The button number to be read (starting at 1)
Return type:bool
Returns:The state of the button.
getRawButtonPressed(button)[source]

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

Parameters:button (int) – The button index, beginning at 1.
Return type:bool
Returns:Whether the button was pressed since the last check.

New in version 2018.0.0.

getRawButtonReleased(button)[source]

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

Parameters:button (int) – The button index, beginning at 1.
Return type:bool
Returns:Whether the button was released since the last check.

New in version 2018.0.0.

getType()[source]

Get the type of the HID.

Return type:HIDType
Returns:the type of the HID.
getX(hand=<Hand.kRight: 1>)[source]

Get the x position of HID.

Parameters:hand (Hand) – which hand, left or right
Return type:float
Returns:the x position
getY(hand=<Hand.kRight: 1>)[source]

Get the y position of the HID.

Parameters:hand (Hand) – which hand, left or right
Return type:float
Returns:the y position
setOutput(outputNumber, value)[source]

Set a single HID output value for the HID.

Parameters:
  • outputNumber (int) – The index of the output to set (1-32)
  • value (bool) – The value to set the output to
Return type:

None

setOutputs(value)[source]

Set all HID output values for the HID.

Parameters:value (int) – The 32 bit output value (1 bit for each output)
Return type:None
setRumble(type, value)[source]

Set the rumble output for the HID. The DS currently supports 2 rumble values, left rumble and right rumble.

Parameters:
  • type (RumbleType) – Which rumble value to set
  • value (float) – The normalized value (0 to 1) to set the rumble to
Return type:

None