WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
GenericHIDSim.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <stdint.h>
8
11
12namespace wpi {
13
14class GenericHID;
15
16namespace sim {
17
18/**
19 * Class to control a simulated generic joystick.
20 */
22 public:
23 /**
24 * Constructs from a GenericHID object.
25 *
26 * @param joystick joystick to simulate
27 */
28 explicit GenericHIDSim(const GenericHID& joystick);
29
30 /**
31 * Constructs from a joystick port number.
32 *
33 * @param port port number
34 */
35 explicit GenericHIDSim(int port);
36
37 /**
38 * Updates joystick data so that new values are visible to the user program.
39 */
41
42 /**
43 * Set the value of a given button.
44 *
45 * @param button the button to set
46 * @param value the new value
47 */
48 void SetRawButton(int button, bool value);
49
50 /**
51 * Set the value of a given axis.
52 *
53 * @param axis the axis to set
54 * @param value the new value
55 */
56 void SetRawAxis(int axis, double value);
57
58 /**
59 * Set the value of a given POV.
60 *
61 * @param pov the POV to set
62 * @param value the new value
63 */
64 void SetPOV(int pov, DriverStation::POVDirection value);
65
66 /**
67 * Set the value of the default POV (port 0).
68 *
69 * @param value the new value
70 */
72
73 void SetAxesMaximumIndex(int maximumIndex);
74
75 /**
76 * Set the axis count of this device.
77 *
78 * @param count the new axis count
79 */
80 void SetAxesAvailable(int count);
81
82 void SetPOVsMaximumIndex(int maximumIndex);
83
84 /**
85 * Set the POV count of this device.
86 *
87 * @param count the new POV count
88 */
89 void SetPOVsAvailable(int count);
90
91 void SetButtonsMaximumIndex(int maximumIndex);
92
93 /**
94 * Set the button count of this device.
95 *
96 * @param count the new button count
97 */
98 void SetButtonsAvailable(uint64_t count);
99
100 /**
101 * Set the type of this device.
102 *
103 * @param type the new device type
104 */
106
108
109 /**
110 * Set the name of this device.
111 *
112 * @param name the new device name
113 */
114 void SetName(const char* name);
115
116 /**
117 * Get the value of set LEDs.
118 *
119 * @return the led color
120 */
121 int32_t GetLeds();
122
123 /**
124 * Get the joystick rumble.
125 *
126 * @param type the rumble to read
127 * @return the rumble value
128 */
130
131 protected:
132 /// GenericHID port.
134};
135
136} // namespace sim
137} // namespace wpi
@ name
Definition base.h:690
POVDirection
A controller POV direction.
Definition DriverStation.hpp:62
Handle input from standard HID devices connected to the Driver Station.
Definition GenericHID.hpp:26
RumbleType
Represents a rumble output on the Joystick.
Definition GenericHID.hpp:31
HIDType
USB HID interface type.
Definition GenericHID.hpp:63
SupportedOutputs
Represents the various outputs that a HID may support.
Definition GenericHID.hpp:45
void SetPOV(int pov, DriverStation::POVDirection value)
Set the value of a given POV.
GenericHIDSim(const GenericHID &joystick)
Constructs from a GenericHID object.
void SetButtonsMaximumIndex(int maximumIndex)
void SetRawButton(int button, bool value)
Set the value of a given button.
void SetButtonsAvailable(uint64_t count)
Set the button count of this device.
GenericHIDSim(int port)
Constructs from a joystick port number.
int32_t GetLeds()
Get the value of set LEDs.
double GetRumble(GenericHID::RumbleType type)
Get the joystick rumble.
void SetName(const char *name)
Set the name of this device.
void SetAxesAvailable(int count)
Set the axis count of this device.
void SetPOVsAvailable(int count)
Set the POV count of this device.
int m_port
GenericHID port.
Definition GenericHIDSim.hpp:133
void SetRawAxis(int axis, double value)
Set the value of a given axis.
void SetSupportedOutputs(GenericHID::SupportedOutputs supportedOutputs)
void SetPOV(DriverStation::POVDirection value)
Set the value of the default POV (port 0).
void SetPOVsMaximumIndex(int maximumIndex)
void NotifyNewData()
Updates joystick data so that new values are visible to the user program.
void SetGamepadType(GenericHID::HIDType type)
Set the type of this device.
void SetAxesMaximumIndex(int maximumIndex)
Definition CTREPCMSim.hpp:13
Definition CvSource.hpp:15