2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2020-07-15 23:48:09 -07:00
|
|
|
|
|
|
|
|
#include "frc/simulation/XboxControllerSim.h"
|
|
|
|
|
|
|
|
|
|
#include "frc/XboxController.h"
|
|
|
|
|
|
|
|
|
|
using namespace frc;
|
|
|
|
|
using namespace frc::sim;
|
|
|
|
|
|
|
|
|
|
XboxControllerSim::XboxControllerSim(const XboxController& joystick)
|
|
|
|
|
: GenericHIDSim{joystick} {
|
|
|
|
|
SetAxisCount(6);
|
|
|
|
|
SetButtonCount(10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XboxControllerSim::XboxControllerSim(int port) : GenericHIDSim{port} {
|
|
|
|
|
SetAxisCount(6);
|
|
|
|
|
SetButtonCount(10);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-14 20:00:46 +03:00
|
|
|
void XboxControllerSim::SetLeftX(double value) {
|
|
|
|
|
SetRawAxis(XboxController::Axis::kLeftX, value);
|
2020-07-15 23:48:09 -07:00
|
|
|
}
|
|
|
|
|
|
2021-08-14 20:00:46 +03:00
|
|
|
void XboxControllerSim::SetRightX(double value) {
|
|
|
|
|
SetRawAxis(XboxController::Axis::kRightX, value);
|
2020-07-15 23:48:09 -07:00
|
|
|
}
|
|
|
|
|
|
2021-08-14 20:00:46 +03:00
|
|
|
void XboxControllerSim::SetLeftY(double value) {
|
|
|
|
|
SetRawAxis(XboxController::Axis::kLeftY, value);
|
2020-07-15 23:48:09 -07:00
|
|
|
}
|
|
|
|
|
|
2021-08-14 20:00:46 +03:00
|
|
|
void XboxControllerSim::SetRightY(double value) {
|
|
|
|
|
SetRawAxis(XboxController::Axis::kRightY, value);
|
2020-07-15 23:48:09 -07:00
|
|
|
}
|
|
|
|
|
|
2021-08-14 20:00:46 +03:00
|
|
|
void XboxControllerSim::SetLeftTriggerAxis(double value) {
|
|
|
|
|
SetRawAxis(XboxController::Axis::kLeftTrigger, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void XboxControllerSim::SetRightTriggerAxis(double value) {
|
|
|
|
|
SetRawAxis(XboxController::Axis::kRightTrigger, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void XboxControllerSim::SetLeftBumper(bool state) {
|
|
|
|
|
SetRawButton(XboxController::Button::kLeftBumper, state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void XboxControllerSim::SetRightBumper(bool state) {
|
|
|
|
|
SetRawButton(XboxController::Button::kRightBumper, state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void XboxControllerSim::SetLeftStickButton(bool state) {
|
|
|
|
|
SetRawButton(XboxController::Button::kLeftStick, state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void XboxControllerSim::SetRightStickButton(bool state) {
|
|
|
|
|
SetRawButton(XboxController::Button::kRightStick, state);
|
2020-07-15 23:48:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void XboxControllerSim::SetAButton(bool state) {
|
2021-08-14 20:00:46 +03:00
|
|
|
SetRawButton(XboxController::Button::kA, state);
|
2020-07-15 23:48:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void XboxControllerSim::SetBButton(bool state) {
|
2021-08-14 20:00:46 +03:00
|
|
|
SetRawButton(XboxController::Button::kB, state);
|
2020-07-15 23:48:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void XboxControllerSim::SetXButton(bool state) {
|
2021-08-14 20:00:46 +03:00
|
|
|
SetRawButton(XboxController::Button::kX, state);
|
2020-07-15 23:48:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void XboxControllerSim::SetYButton(bool state) {
|
2021-08-14 20:00:46 +03:00
|
|
|
SetRawButton(XboxController::Button::kY, state);
|
2020-07-15 23:48:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void XboxControllerSim::SetBackButton(bool state) {
|
2021-08-14 20:00:46 +03:00
|
|
|
SetRawButton(XboxController::Button::kBack, state);
|
2020-07-15 23:48:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void XboxControllerSim::SetStartButton(bool state) {
|
2021-08-14 20:00:46 +03:00
|
|
|
SetRawButton(XboxController::Button::kStart, state);
|
2020-07-15 23:48:09 -07:00
|
|
|
}
|