mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
[sim] Move WPILib C++ sim implementations out of line (#2598)
This makes the sim classes consistent with the rest of the WPILibC classes.
This commit is contained in:
@@ -7,10 +7,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "frc/XboxController.h"
|
||||
#include "frc/simulation/GenericHIDSim.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class XboxController;
|
||||
|
||||
namespace sim {
|
||||
|
||||
/**
|
||||
@@ -23,88 +25,36 @@ class XboxControllerSim : public GenericHIDSim {
|
||||
*
|
||||
* @param joystick controller to simulate
|
||||
*/
|
||||
explicit XboxControllerSim(const XboxController& joystick)
|
||||
: GenericHIDSim{joystick} {
|
||||
SetAxisCount(6);
|
||||
SetButtonCount(10);
|
||||
}
|
||||
explicit XboxControllerSim(const XboxController& joystick);
|
||||
|
||||
/**
|
||||
* Constructs from a joystick port number.
|
||||
*
|
||||
* @param port port number
|
||||
*/
|
||||
explicit XboxControllerSim(int port) : GenericHIDSim{port} {
|
||||
SetAxisCount(6);
|
||||
SetButtonCount(10);
|
||||
}
|
||||
explicit XboxControllerSim(int port);
|
||||
|
||||
void SetX(GenericHID::JoystickHand hand, double value) {
|
||||
if (hand == GenericHID::kLeftHand) {
|
||||
SetRawAxis(static_cast<int>(XboxController::Axis::kLeftX), value);
|
||||
} else {
|
||||
SetRawAxis(static_cast<int>(XboxController::Axis::kRightX), value);
|
||||
}
|
||||
}
|
||||
void SetX(GenericHID::JoystickHand hand, double value);
|
||||
|
||||
void SetY(GenericHID::JoystickHand hand, double value) {
|
||||
if (hand == GenericHID::kLeftHand) {
|
||||
SetRawAxis(static_cast<int>(XboxController::Axis::kLeftY), value);
|
||||
} else {
|
||||
SetRawAxis(static_cast<int>(XboxController::Axis::kRightY), value);
|
||||
}
|
||||
}
|
||||
void SetY(GenericHID::JoystickHand hand, double value);
|
||||
|
||||
void SetTriggerAxis(GenericHID::JoystickHand hand, double value) {
|
||||
if (hand == GenericHID::kLeftHand) {
|
||||
SetRawAxis(static_cast<int>(XboxController::Axis::kLeftTrigger), value);
|
||||
} else {
|
||||
SetRawAxis(static_cast<int>(XboxController::Axis::kRightTrigger), value);
|
||||
}
|
||||
}
|
||||
void SetTriggerAxis(GenericHID::JoystickHand hand, double value);
|
||||
|
||||
void SetBumper(GenericHID::JoystickHand hand, bool state) {
|
||||
if (hand == GenericHID::kLeftHand) {
|
||||
SetRawButton(static_cast<int>(XboxController::Button::kBumperLeft),
|
||||
state);
|
||||
} else {
|
||||
SetRawButton(static_cast<int>(XboxController::Button::kBumperRight),
|
||||
state);
|
||||
}
|
||||
}
|
||||
void SetBumper(GenericHID::JoystickHand hand, bool state);
|
||||
|
||||
void SetStickButton(GenericHID::JoystickHand hand, bool state) {
|
||||
if (hand == GenericHID::kLeftHand) {
|
||||
SetRawButton(static_cast<int>(XboxController::Button::kStickLeft), state);
|
||||
} else {
|
||||
SetRawButton(static_cast<int>(XboxController::Button::kStickRight),
|
||||
state);
|
||||
}
|
||||
}
|
||||
void SetStickButton(GenericHID::JoystickHand hand, bool state);
|
||||
|
||||
void SetAButton(bool state) {
|
||||
SetRawButton(static_cast<int>(XboxController::Button::kA), state);
|
||||
}
|
||||
void SetAButton(bool state);
|
||||
|
||||
void SetBButton(bool state) {
|
||||
SetRawButton(static_cast<int>(XboxController::Button::kB), state);
|
||||
}
|
||||
void SetBButton(bool state);
|
||||
|
||||
void SetXButton(bool state) {
|
||||
SetRawButton(static_cast<int>(XboxController::Button::kX), state);
|
||||
}
|
||||
void SetXButton(bool state);
|
||||
|
||||
void SetYButton(bool state) {
|
||||
SetRawButton(static_cast<int>(XboxController::Button::kY), state);
|
||||
}
|
||||
void SetYButton(bool state);
|
||||
|
||||
void SetBackButton(bool state) {
|
||||
SetRawButton(static_cast<int>(XboxController::Button::kBack), state);
|
||||
}
|
||||
void SetBackButton(bool state);
|
||||
|
||||
void SetStartButton(bool state) {
|
||||
SetRawButton(static_cast<int>(XboxController::Button::kStart), state);
|
||||
}
|
||||
void SetStartButton(bool state);
|
||||
};
|
||||
|
||||
} // namespace sim
|
||||
|
||||
Reference in New Issue
Block a user