WPILibC++ 2027.0.0-alpha-2
Loading...
Searching...
No Matches
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/DriverStation.h"
10#include "frc/GenericHID.h"
11
12namespace frc {
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 /**
74 * Set the axis count of this device.
75 *
76 * @param count the new axis count
77 */
78 void SetAxisCount(int count);
79
80 /**
81 * Set the POV count of this device.
82 *
83 * @param count the new POV count
84 */
85 void SetPOVCount(int count);
86
87 /**
88 * Set the button count of this device.
89 *
90 * @param count the new button count
91 */
92 void SetButtonCount(int count);
93
94 /**
95 * Set the type of this device.
96 *
97 * @param type the new device type
98 */
100
101 /**
102 * Set the name of this device.
103 *
104 * @param name the new device name
105 */
106 void SetName(const char* name);
107
108 /**
109 * Set the type of an axis.
110 *
111 * @param axis the axis
112 * @param type the type
113 */
114 void SetAxisType(int axis, int type);
115
116 /**
117 * Read the output of a button.
118 *
119 * @param outputNumber the button number
120 * @return the value of the button (true = pressed)
121 */
122 bool GetOutput(int outputNumber);
123
124 /**
125 * Get the encoded 16-bit integer that passes button values.
126 *
127 * @return the button values
128 */
129 int64_t GetOutputs();
130
131 /**
132 * Get the joystick rumble.
133 *
134 * @param type the rumble to read
135 * @return the rumble value
136 */
138
139 protected:
140 /// GenericHID port.
142};
143
144} // namespace sim
145} // namespace frc
POVDirection
A controller POV direction.
Definition DriverStation.h:55
Handle input from standard HID devices connected to the Driver Station.
Definition GenericHID.h:26
RumbleType
Represents a rumble output on the Joystick.
Definition GenericHID.h:31
HIDType
USB HID interface type.
Definition GenericHID.h:43
Class to control a simulated generic joystick.
Definition GenericHIDSim.h:21
void SetAxisCount(int count)
Set the axis count of this device.
void SetPOV(int pov, DriverStation::POVDirection value)
Set the value of a given POV.
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 SetButtonCount(int count)
Set the button count of this device.
void SetType(GenericHID::HIDType type)
Set the type of this device.
void SetPOV(DriverStation::POVDirection value)
Set the value of the default POV (port 0).
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:141
void SetAxisType(int axis, int type)
Set the type of an axis.
Definition SystemServer.h:9