WPILibC++ 2024.3.2
frc::sim::GenericHIDSim Class Reference

Class to control a simulated generic joystick. More...

#include <frc/simulation/GenericHIDSim.h>

Inheritance diagram for frc::sim::GenericHIDSim:
frc::sim::JoystickSim frc::sim::PS4ControllerSim frc::sim::PS5ControllerSim frc::sim::XboxControllerSim

Public Member Functions

 GenericHIDSim (const GenericHID &joystick)
 Constructs from a GenericHID object. More...
 
 GenericHIDSim (int port)
 Constructs from a joystick port number. More...
 
void NotifyNewData ()
 Updates joystick data so that new values are visible to the user program. More...
 
void SetRawButton (int button, bool value)
 Set the value of a given button. More...
 
void SetRawAxis (int axis, double value)
 Set the value of a given axis. More...
 
void SetPOV (int pov, int value)
 Set the value of a given POV. More...
 
void SetPOV (int value)
 Set the value of the default POV (port 0). More...
 
void SetAxisCount (int count)
 Set the axis count of this device. More...
 
void SetPOVCount (int count)
 Set the POV count of this device. More...
 
void SetButtonCount (int count)
 Set the button count of this device. More...
 
void SetType (GenericHID::HIDType type)
 Set the type of this device. More...
 
void SetName (const char *name)
 Set the name of this device. More...
 
void SetAxisType (int axis, int type)
 Set the type of an axis. More...
 
bool GetOutput (int outputNumber)
 Read the output of a button. More...
 
int64_t GetOutputs ()
 Get the encoded 16-bit integer that passes button values. More...
 
double GetRumble (GenericHID::RumbleType type)
 Get the joystick rumble. More...
 

Protected Attributes

int m_port
 GenericHID port. More...
 

Detailed Description

Class to control a simulated generic joystick.

Constructor & Destructor Documentation

◆ GenericHIDSim() [1/2]

frc::sim::GenericHIDSim::GenericHIDSim ( const GenericHID joystick)
explicit

Constructs from a GenericHID object.

Parameters
joystickjoystick to simulate

◆ GenericHIDSim() [2/2]

frc::sim::GenericHIDSim::GenericHIDSim ( int  port)
explicit

Constructs from a joystick port number.

Parameters
portport number

Member Function Documentation

◆ GetOutput()

bool frc::sim::GenericHIDSim::GetOutput ( int  outputNumber)

Read the output of a button.

Parameters
outputNumberthe button number
Returns
the value of the button (true = pressed)

◆ GetOutputs()

int64_t frc::sim::GenericHIDSim::GetOutputs ( )

Get the encoded 16-bit integer that passes button values.

Returns
the button values

◆ GetRumble()

double frc::sim::GenericHIDSim::GetRumble ( GenericHID::RumbleType  type)

Get the joystick rumble.

Parameters
typethe rumble to read
Returns
the rumble value

◆ NotifyNewData()

void frc::sim::GenericHIDSim::NotifyNewData ( )

Updates joystick data so that new values are visible to the user program.

◆ SetAxisCount()

void frc::sim::GenericHIDSim::SetAxisCount ( int  count)

Set the axis count of this device.

Parameters
countthe new axis count

◆ SetAxisType()

void frc::sim::GenericHIDSim::SetAxisType ( int  axis,
int  type 
)

Set the type of an axis.

Parameters
axisthe axis
typethe type

◆ SetButtonCount()

void frc::sim::GenericHIDSim::SetButtonCount ( int  count)

Set the button count of this device.

Parameters
countthe new button count

◆ SetName()

void frc::sim::GenericHIDSim::SetName ( const char *  name)

Set the name of this device.

Parameters
namethe new device name

◆ SetPOV() [1/2]

void frc::sim::GenericHIDSim::SetPOV ( int  pov,
int  value 
)

Set the value of a given POV.

Parameters
povthe POV to set
valuethe new value

◆ SetPOV() [2/2]

void frc::sim::GenericHIDSim::SetPOV ( int  value)

Set the value of the default POV (port 0).

Parameters
valuethe new value

◆ SetPOVCount()

void frc::sim::GenericHIDSim::SetPOVCount ( int  count)

Set the POV count of this device.

Parameters
countthe new POV count

◆ SetRawAxis()

void frc::sim::GenericHIDSim::SetRawAxis ( int  axis,
double  value 
)

Set the value of a given axis.

Parameters
axisthe axis to set
valuethe new value

◆ SetRawButton()

void frc::sim::GenericHIDSim::SetRawButton ( int  button,
bool  value 
)

Set the value of a given button.

Parameters
buttonthe button to set
valuethe new value

◆ SetType()

void frc::sim::GenericHIDSim::SetType ( GenericHID::HIDType  type)

Set the type of this device.

Parameters
typethe new device type

Member Data Documentation

◆ m_port

int frc::sim::GenericHIDSim::m_port
protected

GenericHID port.


The documentation for this class was generated from the following file: