WPILibC++ 2024.3.2
GenericHIDSim.h
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
9#include "frc/GenericHID.h"
10
11namespace frc {
12
13class GenericHID;
14
15namespace sim {
16
17/**
18 * Class to control a simulated generic joystick.
19 */
21 public:
22 /**
23 * Constructs from a GenericHID object.
24 *
25 * @param joystick joystick to simulate
26 */
27 explicit GenericHIDSim(const GenericHID& joystick);
28
29 /**
30 * Constructs from a joystick port number.
31 *
32 * @param port port number
33 */
34 explicit GenericHIDSim(int port);
35
36 /**
37 * Updates joystick data so that new values are visible to the user program.
38 */
40
41 /**
42 * Set the value of a given button.
43 *
44 * @param button the button to set
45 * @param value the new value
46 */
47 void SetRawButton(int button, bool value);
48
49 /**
50 * Set the value of a given axis.
51 *
52 * @param axis the axis to set
53 * @param value the new value
54 */
55 void SetRawAxis(int axis, double value);
56
57 /**
58 * Set the value of a given POV.
59 *
60 * @param pov the POV to set
61 * @param value the new value
62 */
63 void SetPOV(int pov, int value);
64
65 /**
66 * Set the value of the default POV (port 0).
67 *
68 * @param value the new value
69 */
70 void SetPOV(int value);
71
72 /**
73 * Set the axis count of this device.
74 *
75 * @param count the new axis count
76 */
78
79 /**
80 * Set the POV count of this device.
81 *
82 * @param count the new POV count
83 */
84 void SetPOVCount(int count);
85
86 /**
87 * Set the button count of this device.
88 *
89 * @param count the new button count
90 */
92
93 /**
94 * Set the type of this device.
95 *
96 * @param type the new device type
97 */
99
100 /**
101 * Set the name of this device.
102 *
103 * @param name the new device name
104 */
105 void SetName(const char* name);
106
107 /**
108 * Set the type of an axis.
109 *
110 * @param axis the axis
111 * @param type the type
112 */
113 void SetAxisType(int axis, int type);
114
115 /**
116 * Read the output of a button.
117 *
118 * @param outputNumber the button number
119 * @return the value of the button (true = pressed)
120 */
121 bool GetOutput(int outputNumber);
122
123 /**
124 * Get the encoded 16-bit integer that passes button values.
125 *
126 * @return the button values
127 */
128 int64_t GetOutputs();
129
130 /**
131 * Get the joystick rumble.
132 *
133 * @param type the rumble to read
134 * @return the rumble value
135 */
137
138 protected:
139 /// GenericHID port.
141};
142
143} // namespace sim
144} // namespace frc
Handle input from standard HID devices connected to the Driver Station.
Definition: GenericHID.h:24
RumbleType
Represents a rumble output on the Joystick.
Definition: GenericHID.h:29
HIDType
USB HID interface type.
Definition: GenericHID.h:41
Class to control a simulated generic joystick.
Definition: GenericHIDSim.h:20
void SetAxisCount(int count)
Set the axis count of this device.
GenericHIDSim(const GenericHID &joystick)
Constructs from a GenericHID object.
int64_t GetOutputs()
Get the encoded 16-bit integer that passes button values.
void NotifyNewData()
Updates joystick data so that new values are visible to the user program.
void SetRawButton(int button, bool value)
Set the value of a given button.
GenericHIDSim(int port)
Constructs from a joystick port number.
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 SetButtonCount(int count)
Set the button count of this device.
void SetType(GenericHID::HIDType type)
Set the type of this device.
bool GetOutput(int outputNumber)
Read the output of a button.
void SetRawAxis(int axis, double value)
Set the value of a given axis.
void SetPOVCount(int count)
Set the POV count of this device.
double GetRumble(GenericHID::RumbleType type)
Get the joystick rumble.
void SetName(const char *name)
Set the name of this device.
int m_port
GenericHID port.
Definition: GenericHIDSim.h:140
void SetAxisType(int axis, int type)
Set the type of an axis.
constexpr auto count() -> size_t
Definition: core.h:1203
type
Definition: core.h:556
Definition: AprilTagPoseEstimator.h:15