Package edu.wpi.first.wpilibj.simulation
Class GenericHIDSim
java.lang.Object
edu.wpi.first.wpilibj.simulation.GenericHIDSim
- Direct Known Subclasses:
JoystickSim
,PS4ControllerSim
,PS5ControllerSim
,StadiaControllerSim
,XboxControllerSim
Class to control a simulated generic joystick.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionGenericHIDSim
(int port) Constructs from a joystick port number.GenericHIDSim
(GenericHID joystick) Constructs from a GenericHID object. -
Method Summary
Modifier and TypeMethodDescriptionboolean
getOutput
(int outputNumber) Read the output of a button.long
Get the encoded 16-bit integer that passes button values.double
Get the joystick rumble.void
Updates joystick data so that new values are visible to the user program.void
setAxisCount
(int count) Set the axis count of this device.void
setAxisType
(int axis, int type) Set the type of the provided axis channel.void
setButtonCount
(int count) Set the button count of this device.void
Set the name of this device.void
setPOV
(int value) Set the value of the default POV (port 0).void
setPOV
(int pov, int value) Set the value of a given POV.void
setPOVCount
(int count) Set the POV count of this device.void
setRawAxis
(int axis, double value) Set the value of a given axis.void
setRawButton
(int button, boolean value) Set the value of a given button.void
setType
(GenericHID.HIDType type) Set the type of this device.
-
Field Details
-
m_port
GenericHID port.
-
-
Constructor Details
-
GenericHIDSim
Constructs from a GenericHID object.- Parameters:
joystick
- joystick to simulate
-
GenericHIDSim
Constructs from a joystick port number.- Parameters:
port
- port number
-
-
Method Details
-
notifyNewData
Updates joystick data so that new values are visible to the user program. -
setRawButton
Set the value of a given button.- Parameters:
button
- the button to setvalue
- the new value
-
setRawAxis
Set the value of a given axis.- Parameters:
axis
- the axis to setvalue
- the new value
-
setPOV
Set the value of a given POV.- Parameters:
pov
- the POV to setvalue
- the new value
-
setPOV
Set the value of the default POV (port 0).- Parameters:
value
- the new value
-
setAxisCount
Set the axis count of this device.- Parameters:
count
- the new axis count
-
setPOVCount
Set the POV count of this device.- Parameters:
count
- the new POV count
-
setButtonCount
Set the button count of this device.- Parameters:
count
- the new button count
-
setType
Set the type of this device.- Parameters:
type
- the new device type
-
setName
Set the name of this device.- Parameters:
name
- the new device name
-
setAxisType
Set the type of the provided axis channel.- Parameters:
axis
- the axistype
- the type
-
getOutput
Read the output of a button.- Parameters:
outputNumber
- the button number- Returns:
- the value of the button (true = pressed)
-
getOutputs
Get the encoded 16-bit integer that passes button values.- Returns:
- the button values
-
getRumble
Get the joystick rumble.- Parameters:
type
- the rumble to read- Returns:
- the rumble value
-