[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:
Peter Johnson
2020-07-15 23:48:09 -07:00
committed by GitHub
parent b9feb81226
commit c2cc90b27d
49 changed files with 3068 additions and 1621 deletions

View File

@@ -0,0 +1,119 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/AddressableLEDSim.h"
#include <memory>
#include <stdexcept>
#include <utility>
#include <hal/simulation/AddressableLEDData.h>
using namespace frc;
using namespace frc::sim;
AddressableLEDSim::AddressableLEDSim() : m_index{0} {}
AddressableLEDSim::AddressableLEDSim(const AddressableLED& addressableLED)
: m_index{0} {}
AddressableLEDSim AddressableLEDSim::CreateForChannel(int pwmChannel) {
int index = HALSIM_FindAddressableLEDForChannel(pwmChannel);
if (index < 0)
throw std::out_of_range("no addressable LED found for PWM channel");
return AddressableLEDSim{index};
}
AddressableLEDSim AddressableLEDSim::CreateForIndex(int index) {
return AddressableLEDSim{index};
}
std::unique_ptr<CallbackStore> AddressableLEDSim::RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAddressableLEDInitializedCallback);
store->SetUid(HALSIM_RegisterAddressableLEDInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool AddressableLEDSim::GetInitialized() const {
return HALSIM_GetAddressableLEDInitialized(m_index);
}
void AddressableLEDSim::SetInitialized(bool initialized) {
HALSIM_SetAddressableLEDInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore> AddressableLEDSim::RegisterOutputPortCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAddressableLEDOutputPortCallback);
store->SetUid(HALSIM_RegisterAddressableLEDOutputPortCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int AddressableLEDSim::GetOutputPort() const {
return HALSIM_GetAddressableLEDOutputPort(m_index);
}
void AddressableLEDSim::SetOutputPort(int outputPort) {
HALSIM_SetAddressableLEDOutputPort(m_index, outputPort);
}
std::unique_ptr<CallbackStore> AddressableLEDSim::RegisterLengthCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAddressableLEDLengthCallback);
store->SetUid(HALSIM_RegisterAddressableLEDLengthCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int AddressableLEDSim::GetLength() const {
return HALSIM_GetAddressableLEDLength(m_index);
}
void AddressableLEDSim::SetLength(int length) {
HALSIM_SetAddressableLEDLength(m_index, length);
}
std::unique_ptr<CallbackStore> AddressableLEDSim::RegisterRunningCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAddressableLEDRunningCallback);
store->SetUid(HALSIM_RegisterAddressableLEDRunningCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int AddressableLEDSim::GetRunning() const {
return HALSIM_GetAddressableLEDRunning(m_index);
}
void AddressableLEDSim::SetRunning(bool running) {
HALSIM_SetAddressableLEDRunning(m_index, running);
}
std::unique_ptr<CallbackStore> AddressableLEDSim::RegisterDataCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAddressableLEDDataCallback);
store->SetUid(HALSIM_RegisterAddressableLEDDataCallback(
m_index, &ConstBufferCallbackStoreThunk, store.get()));
return store;
}
int AddressableLEDSim::GetData(struct HAL_AddressableLEDData* data) const {
return HALSIM_GetAddressableLEDData(m_index, data);
}
void AddressableLEDSim::SetData(struct HAL_AddressableLEDData* data,
int length) {
HALSIM_SetAddressableLEDData(m_index, data, length);
}

View File

@@ -0,0 +1,77 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/AnalogGyroSim.h"
#include <memory>
#include <utility>
#include <hal/simulation/AnalogGyroData.h>
#include "frc/AnalogGyro.h"
#include "frc/AnalogInput.h"
using namespace frc;
using namespace frc::sim;
AnalogGyroSim::AnalogGyroSim(const AnalogGyro& gyro)
: m_index{gyro.GetAnalogInput()->GetChannel()} {}
AnalogGyroSim::AnalogGyroSim(int channel) : m_index{channel} {}
std::unique_ptr<CallbackStore> AnalogGyroSim::RegisterAngleCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogGyroAngleCallback);
store->SetUid(HALSIM_RegisterAnalogGyroAngleCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double AnalogGyroSim::GetAngle() const {
return HALSIM_GetAnalogGyroAngle(m_index);
}
void AnalogGyroSim::SetAngle(double angle) {
HALSIM_SetAnalogGyroAngle(m_index, angle);
}
std::unique_ptr<CallbackStore> AnalogGyroSim::RegisterRateCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogGyroRateCallback);
store->SetUid(HALSIM_RegisterAnalogGyroRateCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double AnalogGyroSim::GetRate() const {
return HALSIM_GetAnalogGyroRate(m_index);
}
void AnalogGyroSim::SetRate(double rate) {
HALSIM_SetAnalogGyroRate(m_index, rate);
}
std::unique_ptr<CallbackStore> AnalogGyroSim::RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogGyroInitializedCallback);
store->SetUid(HALSIM_RegisterAnalogGyroInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool AnalogGyroSim::GetInitialized() const {
return HALSIM_GetAnalogGyroInitialized(m_index);
}
void AnalogGyroSim::SetInitialized(bool initialized) {
HALSIM_SetAnalogGyroInitialized(m_index, initialized);
}
void AnalogGyroSim::ResetData() { HALSIM_ResetAnalogGyroData(m_index); }

View File

@@ -0,0 +1,182 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/AnalogInputSim.h"
#include <memory>
#include <utility>
#include <hal/simulation/AnalogInData.h>
#include "frc/AnalogInput.h"
using namespace frc;
using namespace frc::sim;
AnalogInputSim::AnalogInputSim(const AnalogInput& analogInput)
: m_index{analogInput.GetChannel()} {}
AnalogInputSim::AnalogInputSim(int channel) : m_index{channel} {}
std::unique_ptr<CallbackStore> AnalogInputSim::RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogInInitializedCallback);
store->SetUid(HALSIM_RegisterAnalogInInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool AnalogInputSim::GetInitialized() const {
return HALSIM_GetAnalogInInitialized(m_index);
}
void AnalogInputSim::SetInitialized(bool initialized) {
HALSIM_SetAnalogInInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore> AnalogInputSim::RegisterAverageBitsCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogInAverageBitsCallback);
store->SetUid(HALSIM_RegisterAnalogInAverageBitsCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int AnalogInputSim::GetAverageBits() const {
return HALSIM_GetAnalogInAverageBits(m_index);
}
void AnalogInputSim::SetAverageBits(int averageBits) {
HALSIM_SetAnalogInAverageBits(m_index, averageBits);
}
std::unique_ptr<CallbackStore> AnalogInputSim::RegisterOversampleBitsCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogInOversampleBitsCallback);
store->SetUid(HALSIM_RegisterAnalogInOversampleBitsCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int AnalogInputSim::GetOversampleBits() const {
return HALSIM_GetAnalogInOversampleBits(m_index);
}
void AnalogInputSim::SetOversampleBits(int oversampleBits) {
HALSIM_SetAnalogInOversampleBits(m_index, oversampleBits);
}
std::unique_ptr<CallbackStore> AnalogInputSim::RegisterVoltageCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogInVoltageCallback);
store->SetUid(HALSIM_RegisterAnalogInVoltageCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double AnalogInputSim::GetVoltage() const {
return HALSIM_GetAnalogInVoltage(m_index);
}
void AnalogInputSim::SetVoltage(double voltage) {
HALSIM_SetAnalogInVoltage(m_index, voltage);
}
std::unique_ptr<CallbackStore>
AnalogInputSim::RegisterAccumulatorInitializedCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback,
&HALSIM_CancelAnalogInAccumulatorInitializedCallback);
store->SetUid(HALSIM_RegisterAnalogInAccumulatorInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool AnalogInputSim::GetAccumulatorInitialized() const {
return HALSIM_GetAnalogInAccumulatorInitialized(m_index);
}
void AnalogInputSim::SetAccumulatorInitialized(bool accumulatorInitialized) {
HALSIM_SetAnalogInAccumulatorInitialized(m_index, accumulatorInitialized);
}
std::unique_ptr<CallbackStore> AnalogInputSim::RegisterAccumulatorValueCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorValueCallback);
store->SetUid(HALSIM_RegisterAnalogInAccumulatorValueCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int64_t AnalogInputSim::GetAccumulatorValue() const {
return HALSIM_GetAnalogInAccumulatorValue(m_index);
}
void AnalogInputSim::SetAccumulatorValue(int64_t accumulatorValue) {
HALSIM_SetAnalogInAccumulatorValue(m_index, accumulatorValue);
}
std::unique_ptr<CallbackStore> AnalogInputSim::RegisterAccumulatorCountCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorCountCallback);
store->SetUid(HALSIM_RegisterAnalogInAccumulatorCountCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int64_t AnalogInputSim::GetAccumulatorCount() const {
return HALSIM_GetAnalogInAccumulatorCount(m_index);
}
void AnalogInputSim::SetAccumulatorCount(int64_t accumulatorCount) {
HALSIM_SetAnalogInAccumulatorCount(m_index, accumulatorCount);
}
std::unique_ptr<CallbackStore>
AnalogInputSim::RegisterAccumulatorCenterCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorCenterCallback);
store->SetUid(HALSIM_RegisterAnalogInAccumulatorCenterCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int AnalogInputSim::GetAccumulatorCenter() const {
return HALSIM_GetAnalogInAccumulatorCenter(m_index);
}
void AnalogInputSim::SetAccumulatorCenter(int accumulatorCenter) {
HALSIM_SetAnalogInAccumulatorCenter(m_index, accumulatorCenter);
}
std::unique_ptr<CallbackStore>
AnalogInputSim::RegisterAccumulatorDeadbandCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorDeadbandCallback);
store->SetUid(HALSIM_RegisterAnalogInAccumulatorDeadbandCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int AnalogInputSim::GetAccumulatorDeadband() const {
return HALSIM_GetAnalogInAccumulatorDeadband(m_index);
}
void AnalogInputSim::SetAccumulatorDeadband(int accumulatorDeadband) {
HALSIM_SetAnalogInAccumulatorDeadband(m_index, accumulatorDeadband);
}
void AnalogInputSim::ResetData() { HALSIM_ResetAnalogInData(m_index); }

View File

@@ -0,0 +1,59 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/AnalogOutputSim.h"
#include <memory>
#include <utility>
#include <hal/simulation/AnalogOutData.h>
#include "frc/AnalogOutput.h"
using namespace frc;
using namespace frc::sim;
AnalogOutputSim::AnalogOutputSim(const AnalogOutput& analogOutput)
: m_index{analogOutput.GetChannel()} {}
AnalogOutputSim::AnalogOutputSim(int channel) : m_index{channel} {}
std::unique_ptr<CallbackStore> AnalogOutputSim::RegisterVoltageCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogOutVoltageCallback);
store->SetUid(HALSIM_RegisterAnalogOutVoltageCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double AnalogOutputSim::GetVoltage() const {
return HALSIM_GetAnalogOutVoltage(m_index);
}
void AnalogOutputSim::SetVoltage(double voltage) {
HALSIM_SetAnalogOutVoltage(m_index, voltage);
}
std::unique_ptr<CallbackStore> AnalogOutputSim::RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogOutInitializedCallback);
store->SetUid(HALSIM_RegisterAnalogOutInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool AnalogOutputSim::GetInitialized() const {
return HALSIM_GetAnalogOutInitialized(m_index);
}
void AnalogOutputSim::SetInitialized(bool initialized) {
HALSIM_SetAnalogOutInitialized(m_index, initialized);
}
void AnalogOutputSim::ResetData() { HALSIM_ResetAnalogOutData(m_index); }

View File

@@ -0,0 +1,89 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/AnalogTriggerSim.h"
#include <memory>
#include <stdexcept>
#include <utility>
#include <hal/simulation/AnalogTriggerData.h>
#include "frc/AnalogTrigger.h"
using namespace frc;
using namespace frc::sim;
AnalogTriggerSim::AnalogTriggerSim(const AnalogTrigger& analogTrigger)
: m_index{analogTrigger.GetIndex()} {}
AnalogTriggerSim AnalogTriggerSim::CreateForChannel(int channel) {
int index = HALSIM_FindAnalogTriggerForChannel(channel);
if (index < 0) throw std::out_of_range("no analog trigger found for channel");
return AnalogTriggerSim{index};
}
AnalogTriggerSim AnalogTriggerSim::CreateForIndex(int index) {
return AnalogTriggerSim{index};
}
std::unique_ptr<CallbackStore> AnalogTriggerSim::RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAnalogTriggerInitializedCallback);
store->SetUid(HALSIM_RegisterAnalogTriggerInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool AnalogTriggerSim::GetInitialized() const {
return HALSIM_GetAnalogTriggerInitialized(m_index);
}
void AnalogTriggerSim::SetInitialized(bool initialized) {
HALSIM_SetAnalogTriggerInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore>
AnalogTriggerSim::RegisterTriggerLowerBoundCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback,
&HALSIM_CancelAnalogTriggerTriggerLowerBoundCallback);
store->SetUid(HALSIM_RegisterAnalogTriggerTriggerLowerBoundCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double AnalogTriggerSim::GetTriggerLowerBound() const {
return HALSIM_GetAnalogTriggerTriggerLowerBound(m_index);
}
void AnalogTriggerSim::SetTriggerLowerBound(double triggerLowerBound) {
HALSIM_SetAnalogTriggerTriggerLowerBound(m_index, triggerLowerBound);
}
std::unique_ptr<CallbackStore>
AnalogTriggerSim::RegisterTriggerUpperBoundCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback,
&HALSIM_CancelAnalogTriggerTriggerUpperBoundCallback);
store->SetUid(HALSIM_RegisterAnalogTriggerTriggerUpperBoundCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double AnalogTriggerSim::GetTriggerUpperBound() const {
return HALSIM_GetAnalogTriggerTriggerUpperBound(m_index);
}
void AnalogTriggerSim::SetTriggerUpperBound(double triggerUpperBound) {
HALSIM_SetAnalogTriggerTriggerUpperBound(m_index, triggerUpperBound);
}
void AnalogTriggerSim::ResetData() { HALSIM_ResetAnalogTriggerData(m_index); }

View File

@@ -0,0 +1,112 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/BuiltInAccelerometerSim.h"
#include <memory>
#include <utility>
#include <hal/simulation/AccelerometerData.h>
#include "frc/BuiltInAccelerometer.h"
using namespace frc;
using namespace frc::sim;
BuiltInAccelerometerSim::BuiltInAccelerometerSim() : m_index{0} {}
BuiltInAccelerometerSim::BuiltInAccelerometerSim(const BuiltInAccelerometer&)
: m_index{0} {}
std::unique_ptr<CallbackStore> BuiltInAccelerometerSim::RegisterActiveCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAccelerometerActiveCallback);
store->SetUid(HALSIM_RegisterAccelerometerActiveCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool BuiltInAccelerometerSim::GetActive() const {
return HALSIM_GetAccelerometerActive(m_index);
}
void BuiltInAccelerometerSim::SetActive(bool active) {
HALSIM_SetAccelerometerActive(m_index, active);
}
std::unique_ptr<CallbackStore> BuiltInAccelerometerSim::RegisterRangeCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAccelerometerRangeCallback);
store->SetUid(HALSIM_RegisterAccelerometerRangeCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
HAL_AccelerometerRange BuiltInAccelerometerSim::GetRange() const {
return HALSIM_GetAccelerometerRange(m_index);
}
void BuiltInAccelerometerSim::SetRange(HAL_AccelerometerRange range) {
HALSIM_SetAccelerometerRange(m_index, range);
}
std::unique_ptr<CallbackStore> BuiltInAccelerometerSim::RegisterXCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAccelerometerXCallback);
store->SetUid(HALSIM_RegisterAccelerometerXCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double BuiltInAccelerometerSim::GetX() const {
return HALSIM_GetAccelerometerX(m_index);
}
void BuiltInAccelerometerSim::SetX(double x) {
HALSIM_SetAccelerometerX(m_index, x);
}
std::unique_ptr<CallbackStore> BuiltInAccelerometerSim::RegisterYCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAccelerometerYCallback);
store->SetUid(HALSIM_RegisterAccelerometerYCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double BuiltInAccelerometerSim::GetY() const {
return HALSIM_GetAccelerometerY(m_index);
}
void BuiltInAccelerometerSim::SetY(double y) {
HALSIM_SetAccelerometerY(m_index, y);
}
std::unique_ptr<CallbackStore> BuiltInAccelerometerSim::RegisterZCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelAccelerometerZCallback);
store->SetUid(HALSIM_RegisterAccelerometerZCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double BuiltInAccelerometerSim::GetZ() const {
return HALSIM_GetAccelerometerZ(m_index);
}
void BuiltInAccelerometerSim::SetZ(double z) {
HALSIM_SetAccelerometerZ(m_index, z);
}
void BuiltInAccelerometerSim::ResetData() {
HALSIM_ResetAccelerometerData(m_index);
}

View File

@@ -7,6 +7,9 @@
#include "frc/simulation/CallbackStore.h"
using namespace frc;
using namespace frc::sim;
void frc::sim::CallbackStoreThunk(const char* name, void* param,
const HAL_Value* value) {
reinterpret_cast<CallbackStore*>(param)->callback(name, value);
@@ -18,3 +21,60 @@ void frc::sim::ConstBufferCallbackStoreThunk(const char* name, void* param,
reinterpret_cast<CallbackStore*>(param)->constBufferCallback(name, buffer,
count);
}
CallbackStore::CallbackStore(int32_t i, NotifyCallback cb,
CancelCallbackNoIndexFunc ccf)
: index(i), callback(cb), cancelType(NoIndex) {
this->ccnif = ccf;
}
CallbackStore::CallbackStore(int32_t i, int32_t u, NotifyCallback cb,
CancelCallbackFunc ccf)
: index(i), uid(u), callback(cb), cancelType(Normal) {
this->ccf = ccf;
}
CallbackStore::CallbackStore(int32_t i, int32_t c, int32_t u, NotifyCallback cb,
CancelCallbackChannelFunc ccf)
: index(i), channel(c), uid(u), callback(cb), cancelType(Channel) {
this->cccf = ccf;
}
CallbackStore::CallbackStore(int32_t i, ConstBufferCallback cb,
CancelCallbackNoIndexFunc ccf)
: index(i), constBufferCallback(cb), cancelType(NoIndex) {
this->ccnif = ccf;
}
CallbackStore::CallbackStore(int32_t i, int32_t u, ConstBufferCallback cb,
CancelCallbackFunc ccf)
: index(i), uid(u), constBufferCallback(cb), cancelType(Normal) {
this->ccf = ccf;
}
CallbackStore::CallbackStore(int32_t i, int32_t c, int32_t u,
ConstBufferCallback cb,
CancelCallbackChannelFunc ccf)
: index(i),
channel(c),
uid(u),
constBufferCallback(cb),
cancelType(Channel) {
this->cccf = ccf;
}
CallbackStore::~CallbackStore() {
switch (cancelType) {
case Normal:
ccf(index, uid);
break;
case Channel:
cccf(index, channel, uid);
break;
case NoIndex:
ccnif(uid);
break;
}
}
void CallbackStore::SetUid(int32_t uid) { this->uid = uid; }

View File

@@ -0,0 +1,104 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/DIOSim.h"
#include <memory>
#include <utility>
#include <hal/simulation/DIOData.h>
#include "frc/DigitalInput.h"
#include "frc/DigitalOutput.h"
using namespace frc;
using namespace frc::sim;
DIOSim::DIOSim(const DigitalInput& input) : m_index{input.GetChannel()} {}
DIOSim::DIOSim(const DigitalOutput& output) : m_index{output.GetChannel()} {}
DIOSim::DIOSim(int channel) : m_index{channel} {}
std::unique_ptr<CallbackStore> DIOSim::RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDIOInitializedCallback);
store->SetUid(HALSIM_RegisterDIOInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool DIOSim::GetInitialized() const {
return HALSIM_GetDIOInitialized(m_index);
}
void DIOSim::SetInitialized(bool initialized) {
HALSIM_SetDIOInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore> DIOSim::RegisterValueCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(m_index, -1, callback,
&HALSIM_CancelDIOValueCallback);
store->SetUid(HALSIM_RegisterDIOValueCallback(m_index, &CallbackStoreThunk,
store.get(), initialNotify));
return store;
}
bool DIOSim::GetValue() const { return HALSIM_GetDIOValue(m_index); }
void DIOSim::SetValue(bool value) { HALSIM_SetDIOValue(m_index, value); }
std::unique_ptr<CallbackStore> DIOSim::RegisterPulseLengthCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDIOPulseLengthCallback);
store->SetUid(HALSIM_RegisterDIOPulseLengthCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double DIOSim::GetPulseLength() const {
return HALSIM_GetDIOPulseLength(m_index);
}
void DIOSim::SetPulseLength(double pulseLength) {
HALSIM_SetDIOPulseLength(m_index, pulseLength);
}
std::unique_ptr<CallbackStore> DIOSim::RegisterIsInputCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDIOIsInputCallback);
store->SetUid(HALSIM_RegisterDIOIsInputCallback(m_index, &CallbackStoreThunk,
store.get(), initialNotify));
return store;
}
bool DIOSim::GetIsInput() const { return HALSIM_GetDIOIsInput(m_index); }
void DIOSim::SetIsInput(bool isInput) {
HALSIM_SetDIOIsInput(m_index, isInput);
}
std::unique_ptr<CallbackStore> DIOSim::RegisterFilterIndexCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDIOFilterIndexCallback);
store->SetUid(HALSIM_RegisterDIOFilterIndexCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int DIOSim::GetFilterIndex() const { return HALSIM_GetDIOFilterIndex(m_index); }
void DIOSim::SetFilterIndex(int filterIndex) {
HALSIM_SetDIOFilterIndex(m_index, filterIndex);
}
void DIOSim::ResetData() { HALSIM_ResetDIOData(m_index); }

View File

@@ -0,0 +1,81 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/DigitalPWMSim.h"
#include <memory>
#include <stdexcept>
#include <utility>
#include <hal/simulation/DigitalPWMData.h>
#include "frc/DigitalOutput.h"
using namespace frc;
using namespace frc::sim;
DigitalPWMSim::DigitalPWMSim(const DigitalOutput& digitalOutput)
: m_index{digitalOutput.GetChannel()} {}
DigitalPWMSim DigitalPWMSim::CreateForChannel(int channel) {
int index = HALSIM_FindDigitalPWMForChannel(channel);
if (index < 0) throw std::out_of_range("no digital PWM found for channel");
return DigitalPWMSim{index};
}
DigitalPWMSim DigitalPWMSim::CreateForIndex(int index) {
return DigitalPWMSim{index};
}
std::unique_ptr<CallbackStore> DigitalPWMSim::RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDigitalPWMInitializedCallback);
store->SetUid(HALSIM_RegisterDigitalPWMInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool DigitalPWMSim::GetInitialized() const {
return HALSIM_GetDigitalPWMInitialized(m_index);
}
void DigitalPWMSim::SetInitialized(bool initialized) {
HALSIM_SetDigitalPWMInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore> DigitalPWMSim::RegisterDutyCycleCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDigitalPWMDutyCycleCallback);
store->SetUid(HALSIM_RegisterDigitalPWMDutyCycleCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double DigitalPWMSim::GetDutyCycle() const {
return HALSIM_GetDigitalPWMDutyCycle(m_index);
}
void DigitalPWMSim::SetDutyCycle(double dutyCycle) {
HALSIM_SetDigitalPWMDutyCycle(m_index, dutyCycle);
}
std::unique_ptr<CallbackStore> DigitalPWMSim::RegisterPinCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDigitalPWMPinCallback);
store->SetUid(HALSIM_RegisterDigitalPWMPinCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int DigitalPWMSim::GetPin() const { return HALSIM_GetDigitalPWMPin(m_index); }
void DigitalPWMSim::SetPin(int pin) { HALSIM_SetDigitalPWMPin(m_index, pin); }
void DigitalPWMSim::ResetData() { HALSIM_ResetDigitalPWMData(m_index); }

View File

@@ -0,0 +1,255 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/DriverStationSim.h"
#include <memory>
#include <utility>
#include <hal/simulation/DriverStationData.h>
#include <hal/simulation/MockHooks.h>
#include "frc/DriverStation.h"
using namespace frc;
using namespace frc::sim;
std::unique_ptr<CallbackStore> DriverStationSim::RegisterEnabledCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelDriverStationEnabledCallback);
store->SetUid(HALSIM_RegisterDriverStationEnabledCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool DriverStationSim::GetEnabled() { return HALSIM_GetDriverStationEnabled(); }
void DriverStationSim::SetEnabled(bool enabled) {
HALSIM_SetDriverStationEnabled(enabled);
}
std::unique_ptr<CallbackStore> DriverStationSim::RegisterAutonomousCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelDriverStationAutonomousCallback);
store->SetUid(HALSIM_RegisterDriverStationAutonomousCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool DriverStationSim::GetAutonomous() {
return HALSIM_GetDriverStationAutonomous();
}
void DriverStationSim::SetAutonomous(bool autonomous) {
HALSIM_SetDriverStationAutonomous(autonomous);
}
std::unique_ptr<CallbackStore> DriverStationSim::RegisterTestCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelDriverStationTestCallback);
store->SetUid(HALSIM_RegisterDriverStationTestCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool DriverStationSim::GetTest() { return HALSIM_GetDriverStationTest(); }
void DriverStationSim::SetTest(bool test) { HALSIM_SetDriverStationTest(test); }
std::unique_ptr<CallbackStore> DriverStationSim::RegisterEStopCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelDriverStationEStopCallback);
store->SetUid(HALSIM_RegisterDriverStationEStopCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool DriverStationSim::GetEStop() { return HALSIM_GetDriverStationEStop(); }
void DriverStationSim::SetEStop(bool eStop) {
HALSIM_SetDriverStationEStop(eStop);
}
std::unique_ptr<CallbackStore> DriverStationSim::RegisterFmsAttachedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelDriverStationFmsAttachedCallback);
store->SetUid(HALSIM_RegisterDriverStationFmsAttachedCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool DriverStationSim::GetFmsAttached() {
return HALSIM_GetDriverStationFmsAttached();
}
void DriverStationSim::SetFmsAttached(bool fmsAttached) {
HALSIM_SetDriverStationFmsAttached(fmsAttached);
}
std::unique_ptr<CallbackStore> DriverStationSim::RegisterDsAttachedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelDriverStationDsAttachedCallback);
store->SetUid(HALSIM_RegisterDriverStationDsAttachedCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool DriverStationSim::GetDsAttached() {
return HALSIM_GetDriverStationDsAttached();
}
void DriverStationSim::SetDsAttached(bool dsAttached) {
HALSIM_SetDriverStationDsAttached(dsAttached);
}
std::unique_ptr<CallbackStore>
DriverStationSim::RegisterAllianceStationIdCallback(NotifyCallback callback,
bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelDriverStationAllianceStationIdCallback);
store->SetUid(HALSIM_RegisterDriverStationAllianceStationIdCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
HAL_AllianceStationID DriverStationSim::GetAllianceStationId() {
return HALSIM_GetDriverStationAllianceStationId();
}
void DriverStationSim::SetAllianceStationId(
HAL_AllianceStationID allianceStationId) {
HALSIM_SetDriverStationAllianceStationId(allianceStationId);
}
std::unique_ptr<CallbackStore> DriverStationSim::RegisterMatchTimeCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelDriverStationMatchTimeCallback);
store->SetUid(HALSIM_RegisterDriverStationMatchTimeCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double DriverStationSim::GetMatchTime() {
return HALSIM_GetDriverStationMatchTime();
}
void DriverStationSim::SetMatchTime(double matchTime) {
HALSIM_SetDriverStationMatchTime(matchTime);
}
void DriverStationSim::NotifyNewData() {
HALSIM_NotifyDriverStationNewData();
DriverStation::GetInstance().WaitForData();
}
void DriverStationSim::SetSendError(bool shouldSend) {
if (shouldSend) {
HALSIM_SetSendError(nullptr);
} else {
HALSIM_SetSendError([](HAL_Bool isError, int32_t errorCode,
HAL_Bool isLVCode, const char* details,
const char* location, const char* callStack,
HAL_Bool printMsg) { return 0; });
}
}
void DriverStationSim::SetSendConsoleLine(bool shouldSend) {
if (shouldSend) {
HALSIM_SetSendConsoleLine(nullptr);
} else {
HALSIM_SetSendConsoleLine([](const char* line) { return 0; });
}
}
int64_t DriverStationSim::GetJoystickOutputs(int stick) {
int64_t outputs = 0;
int32_t leftRumble;
int32_t rightRumble;
HALSIM_GetJoystickOutputs(stick, &outputs, &leftRumble, &rightRumble);
return outputs;
}
int DriverStationSim::GetJoystickRumble(int stick, int rumbleNum) {
int64_t outputs;
int32_t leftRumble = 0;
int32_t rightRumble = 0;
HALSIM_GetJoystickOutputs(stick, &outputs, &leftRumble, &rightRumble);
return rumbleNum == 0 ? leftRumble : rightRumble;
}
void DriverStationSim::SetJoystickButton(int stick, int button, bool state) {
HALSIM_SetJoystickButton(stick, button, state);
}
void DriverStationSim::SetJoystickAxis(int stick, int axis, double value) {
HALSIM_SetJoystickAxis(stick, axis, value);
}
void DriverStationSim::SetJoystickPOV(int stick, int pov, int value) {
HALSIM_SetJoystickPOV(stick, pov, value);
}
void DriverStationSim::SetJoystickButtons(int stick, uint32_t buttons) {
HALSIM_SetJoystickButtonsValue(stick, buttons);
}
void DriverStationSim::SetJoystickAxisCount(int stick, int count) {
HALSIM_SetJoystickAxisCount(stick, count);
}
void DriverStationSim::SetJoystickPOVCount(int stick, int count) {
HALSIM_SetJoystickPOVCount(stick, count);
}
void DriverStationSim::SetJoystickButtonCount(int stick, int count) {
HALSIM_SetJoystickButtonCount(stick, count);
}
void DriverStationSim::SetJoystickIsXbox(int stick, bool isXbox) {
HALSIM_SetJoystickIsXbox(stick, isXbox);
}
void DriverStationSim::SetJoystickType(int stick, int type) {
HALSIM_SetJoystickType(stick, type);
}
void DriverStationSim::SetJoystickName(int stick, const char* name) {
HALSIM_SetJoystickName(stick, name);
}
void DriverStationSim::SetJoystickAxisType(int stick, int axis, int type) {
HALSIM_SetJoystickAxisType(stick, axis, type);
}
void DriverStationSim::SetGameSpecificMessage(const char* message) {
HALSIM_SetGameSpecificMessage(message);
}
void DriverStationSim::SetEventName(const char* name) {
HALSIM_SetEventName(name);
}
void DriverStationSim::SetMatchType(DriverStation::MatchType type) {
HALSIM_SetMatchType(static_cast<HAL_MatchType>(static_cast<int>(type)));
}
void DriverStationSim::SetMatchNumber(int matchNumber) {
HALSIM_SetMatchNumber(matchNumber);
}
void DriverStationSim::SetReplayNumber(int replayNumber) {
HALSIM_SetReplayNumber(replayNumber);
}
void DriverStationSim::ResetData() { HALSIM_ResetDriverStationData(); }

View File

@@ -0,0 +1,85 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/DutyCycleSim.h"
#include <memory>
#include <stdexcept>
#include <utility>
#include <hal/simulation/DutyCycleData.h>
#include "frc/DutyCycle.h"
using namespace frc;
using namespace frc::sim;
DutyCycleSim::DutyCycleSim(const DutyCycle& dutyCycle)
: m_index{dutyCycle.GetFPGAIndex()} {}
DutyCycleSim DutyCycleSim::CreateForChannel(int channel) {
int index = HALSIM_FindDutyCycleForChannel(channel);
if (index < 0) throw std::out_of_range("no duty cycle found for channel");
return DutyCycleSim{index};
}
DutyCycleSim DutyCycleSim::CreateForIndex(int index) {
return DutyCycleSim{index};
}
std::unique_ptr<CallbackStore> DutyCycleSim::RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDutyCycleInitializedCallback);
store->SetUid(HALSIM_RegisterDutyCycleInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool DutyCycleSim::GetInitialized() const {
return HALSIM_GetDutyCycleInitialized(m_index);
}
void DutyCycleSim::SetInitialized(bool initialized) {
HALSIM_SetDutyCycleInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore> DutyCycleSim::RegisterFrequencyCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDutyCycleFrequencyCallback);
store->SetUid(HALSIM_RegisterDutyCycleFrequencyCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int DutyCycleSim::GetFrequency() const {
return HALSIM_GetDutyCycleFrequency(m_index);
}
void DutyCycleSim::SetFrequency(int count) {
HALSIM_SetDutyCycleFrequency(m_index, count);
}
std::unique_ptr<CallbackStore> DutyCycleSim::RegisterOutputCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelDutyCycleOutputCallback);
store->SetUid(HALSIM_RegisterDutyCycleOutputCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double DutyCycleSim::GetOutput() const {
return HALSIM_GetDutyCycleOutput(m_index);
}
void DutyCycleSim::SetOutput(double period) {
HALSIM_SetDutyCycleOutput(m_index, period);
}
void DutyCycleSim::ResetData() { HALSIM_ResetDutyCycleData(m_index); }

View File

@@ -0,0 +1,189 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/EncoderSim.h"
#include <memory>
#include <stdexcept>
#include <utility>
#include <hal/simulation/EncoderData.h>
#include "frc/Encoder.h"
using namespace frc;
using namespace frc::sim;
EncoderSim::EncoderSim(const Encoder& encoder)
: m_index{encoder.GetFPGAIndex()} {}
EncoderSim EncoderSim::CreateForChannel(int channel) {
int index = HALSIM_FindEncoderForChannel(channel);
if (index < 0) throw std::out_of_range("no encoder found for channel");
return EncoderSim{index};
}
EncoderSim EncoderSim::CreateForIndex(int index) { return EncoderSim{index}; }
std::unique_ptr<CallbackStore> EncoderSim::RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderInitializedCallback);
store->SetUid(HALSIM_RegisterEncoderInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool EncoderSim::GetInitialized() const {
return HALSIM_GetEncoderInitialized(m_index);
}
void EncoderSim::SetInitialized(bool initialized) {
HALSIM_SetEncoderInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore> EncoderSim::RegisterCountCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderCountCallback);
store->SetUid(HALSIM_RegisterEncoderCountCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int EncoderSim::GetCount() const { return HALSIM_GetEncoderCount(m_index); }
void EncoderSim::SetCount(int count) { HALSIM_SetEncoderCount(m_index, count); }
std::unique_ptr<CallbackStore> EncoderSim::RegisterPeriodCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderPeriodCallback);
store->SetUid(HALSIM_RegisterEncoderPeriodCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double EncoderSim::GetPeriod() const {
return HALSIM_GetEncoderPeriod(m_index);
}
void EncoderSim::SetPeriod(double period) {
HALSIM_SetEncoderPeriod(m_index, period);
}
std::unique_ptr<CallbackStore> EncoderSim::RegisterResetCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderResetCallback);
store->SetUid(HALSIM_RegisterEncoderResetCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool EncoderSim::GetReset() const { return HALSIM_GetEncoderReset(m_index); }
void EncoderSim::SetReset(bool reset) {
HALSIM_SetEncoderReset(m_index, reset);
}
std::unique_ptr<CallbackStore> EncoderSim::RegisterMaxPeriodCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderMaxPeriodCallback);
store->SetUid(HALSIM_RegisterEncoderMaxPeriodCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double EncoderSim::GetMaxPeriod() const {
return HALSIM_GetEncoderMaxPeriod(m_index);
}
void EncoderSim::SetMaxPeriod(double maxPeriod) {
HALSIM_SetEncoderMaxPeriod(m_index, maxPeriod);
}
std::unique_ptr<CallbackStore> EncoderSim::RegisterDirectionCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderDirectionCallback);
store->SetUid(HALSIM_RegisterEncoderDirectionCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool EncoderSim::GetDirection() const {
return HALSIM_GetEncoderDirection(m_index);
}
void EncoderSim::SetDirection(bool direction) {
HALSIM_SetEncoderDirection(m_index, direction);
}
std::unique_ptr<CallbackStore> EncoderSim::RegisterReverseDirectionCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderReverseDirectionCallback);
store->SetUid(HALSIM_RegisterEncoderReverseDirectionCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool EncoderSim::GetReverseDirection() const {
return HALSIM_GetEncoderReverseDirection(m_index);
}
void EncoderSim::SetReverseDirection(bool reverseDirection) {
HALSIM_SetEncoderReverseDirection(m_index, reverseDirection);
}
std::unique_ptr<CallbackStore> EncoderSim::RegisterSamplesToAverageCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderSamplesToAverageCallback);
store->SetUid(HALSIM_RegisterEncoderSamplesToAverageCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int EncoderSim::GetSamplesToAverage() const {
return HALSIM_GetEncoderSamplesToAverage(m_index);
}
void EncoderSim::SetSamplesToAverage(int samplesToAverage) {
HALSIM_SetEncoderSamplesToAverage(m_index, samplesToAverage);
}
std::unique_ptr<CallbackStore> EncoderSim::RegisterDistancePerPulseCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelEncoderDistancePerPulseCallback);
store->SetUid(HALSIM_RegisterEncoderDistancePerPulseCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double EncoderSim::GetDistancePerPulse() const {
return HALSIM_GetEncoderDistancePerPulse(m_index);
}
void EncoderSim::SetDistancePerPulse(double distancePerPulse) {
HALSIM_SetEncoderDistancePerPulse(m_index, distancePerPulse);
}
void EncoderSim::ResetData() { HALSIM_ResetEncoderData(m_index); }
void EncoderSim::SetDistance(double distance) {
HALSIM_SetEncoderDistance(m_index, distance);
}
double EncoderSim::GetDistance() { return HALSIM_GetEncoderDistance(m_index); }
void EncoderSim::SetRate(double rate) { HALSIM_SetEncoderRate(m_index, rate); }
double EncoderSim::GetRate() { return HALSIM_GetEncoderRate(m_index); }

View File

@@ -0,0 +1,74 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/GenericHIDSim.h"
#include "frc/GenericHID.h"
#include "frc/simulation/DriverStationSim.h"
using namespace frc;
using namespace frc::sim;
GenericHIDSim::GenericHIDSim(const GenericHID& joystick)
: m_port{joystick.GetPort()} {}
GenericHIDSim::GenericHIDSim(int port) : m_port{port} {}
void GenericHIDSim::NotifyNewData() { DriverStationSim::NotifyNewData(); }
void GenericHIDSim::SetRawButton(int button, bool value) {
DriverStationSim::SetJoystickButton(m_port, button, value);
}
void GenericHIDSim::SetRawAxis(int axis, double value) {
DriverStationSim::SetJoystickAxis(m_port, axis, value);
}
void GenericHIDSim::SetPOV(int pov, int value) {
DriverStationSim::SetJoystickPOV(m_port, pov, value);
}
void GenericHIDSim::SetPOV(int value) { SetPOV(0, value); }
void GenericHIDSim::SetAxisCount(int count) {
DriverStationSim::SetJoystickAxisCount(m_port, count);
}
void GenericHIDSim::SetPOVCount(int count) {
DriverStationSim::SetJoystickPOVCount(m_port, count);
}
void GenericHIDSim::SetButtonCount(int count) {
DriverStationSim::SetJoystickButtonCount(m_port, count);
}
void GenericHIDSim::SetType(GenericHID::HIDType type) {
DriverStationSim::SetJoystickType(m_port, type);
}
void GenericHIDSim::SetName(const char* name) {
DriverStationSim::SetJoystickName(m_port, name);
}
void GenericHIDSim::SetAxisType(int axis, int type) {
DriverStationSim::SetJoystickAxisType(m_port, axis, type);
}
bool GenericHIDSim::GetOutput(int outputNumber) {
int64_t outputs = GetOutputs();
return (outputs & (static_cast<int64_t>(1) << (outputNumber - 1))) != 0;
}
int64_t GenericHIDSim::GetOutputs() {
return DriverStationSim::GetJoystickOutputs(m_port);
}
double GenericHIDSim::GetRumble(GenericHID::RumbleType type) {
int value = DriverStationSim::GetJoystickRumble(
m_port, type == GenericHID::kLeftRumble ? 0 : 1);
return value / 65535.0;
}

View File

@@ -0,0 +1,63 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/JoystickSim.h"
#include "frc/Joystick.h"
#include "frc/simulation/GenericHIDSim.h"
using namespace frc;
using namespace frc::sim;
JoystickSim::JoystickSim(const Joystick& joystick)
: GenericHIDSim{joystick}, m_joystick{&joystick} {
// default to a reasonable joystick configuration
SetAxisCount(5);
SetButtonCount(12);
SetPOVCount(1);
}
JoystickSim::JoystickSim(int port) : GenericHIDSim{port} {
// default to a reasonable joystick configuration
SetAxisCount(5);
SetButtonCount(12);
SetPOVCount(1);
}
void JoystickSim::SetX(double value) {
SetRawAxis(
m_joystick ? m_joystick->GetXChannel() : Joystick::kDefaultXChannel,
value);
}
void JoystickSim::SetY(double value) {
SetRawAxis(
m_joystick ? m_joystick->GetYChannel() : Joystick::kDefaultYChannel,
value);
}
void JoystickSim::SetZ(double value) {
SetRawAxis(
m_joystick ? m_joystick->GetZChannel() : Joystick::kDefaultZChannel,
value);
}
void JoystickSim::SetTwist(double value) {
SetRawAxis(m_joystick ? m_joystick->GetTwistChannel()
: Joystick::kDefaultTwistChannel,
value);
}
void JoystickSim::SetThrottle(double value) {
SetRawAxis(m_joystick ? m_joystick->GetThrottleChannel()
: Joystick::kDefaultThrottleChannel,
value);
}
void JoystickSim::SetTrigger(bool state) { SetRawButton(1, state); }
void JoystickSim::SetTop(bool state) { SetRawButton(2, state); }

View File

@@ -0,0 +1,158 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/PCMSim.h"
#include <memory>
#include <utility>
#include <hal/simulation/PCMData.h>
#include "frc/Compressor.h"
#include "frc/SensorUtil.h"
using namespace frc;
using namespace frc::sim;
PCMSim::PCMSim() : m_index{SensorUtil::GetDefaultSolenoidModule()} {}
PCMSim::PCMSim(int module) : m_index{module} {}
PCMSim::PCMSim(const Compressor& compressor)
: m_index{compressor.GetModule()} {}
std::unique_ptr<CallbackStore> PCMSim::RegisterSolenoidInitializedCallback(
int channel, NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, channel, -1, callback,
&HALSIM_CancelPCMSolenoidInitializedCallback);
store->SetUid(HALSIM_RegisterPCMSolenoidInitializedCallback(
m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool PCMSim::GetSolenoidInitialized(int channel) const {
return HALSIM_GetPCMSolenoidInitialized(m_index, channel);
}
void PCMSim::SetSolenoidInitialized(int channel, bool solenoidInitialized) {
HALSIM_SetPCMSolenoidInitialized(m_index, channel, solenoidInitialized);
}
std::unique_ptr<CallbackStore> PCMSim::RegisterSolenoidOutputCallback(
int channel, NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, channel, -1, callback, &HALSIM_CancelPCMSolenoidOutputCallback);
store->SetUid(HALSIM_RegisterPCMSolenoidOutputCallback(
m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool PCMSim::GetSolenoidOutput(int channel) const {
return HALSIM_GetPCMSolenoidOutput(m_index, channel);
}
void PCMSim::SetSolenoidOutput(int channel, bool solenoidOutput) {
HALSIM_SetPCMSolenoidOutput(m_index, channel, solenoidOutput);
}
std::unique_ptr<CallbackStore> PCMSim::RegisterCompressorInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPCMCompressorInitializedCallback);
store->SetUid(HALSIM_RegisterPCMCompressorInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool PCMSim::GetCompressorInitialized() const {
return HALSIM_GetPCMCompressorInitialized(m_index);
}
void PCMSim::SetCompressorInitialized(bool compressorInitialized) {
HALSIM_SetPCMCompressorInitialized(m_index, compressorInitialized);
}
std::unique_ptr<CallbackStore> PCMSim::RegisterCompressorOnCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPCMCompressorOnCallback);
store->SetUid(HALSIM_RegisterPCMCompressorOnCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool PCMSim::GetCompressorOn() const {
return HALSIM_GetPCMCompressorOn(m_index);
}
void PCMSim::SetCompressorOn(bool compressorOn) {
HALSIM_SetPCMCompressorOn(m_index, compressorOn);
}
std::unique_ptr<CallbackStore> PCMSim::RegisterClosedLoopEnabledCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPCMClosedLoopEnabledCallback);
store->SetUid(HALSIM_RegisterPCMClosedLoopEnabledCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool PCMSim::GetClosedLoopEnabled() const {
return HALSIM_GetPCMClosedLoopEnabled(m_index);
}
void PCMSim::SetClosedLoopEnabled(bool closedLoopEnabled) {
HALSIM_SetPCMClosedLoopEnabled(m_index, closedLoopEnabled);
}
std::unique_ptr<CallbackStore> PCMSim::RegisterPressureSwitchCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPCMPressureSwitchCallback);
store->SetUid(HALSIM_RegisterPCMPressureSwitchCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool PCMSim::GetPressureSwitch() const {
return HALSIM_GetPCMPressureSwitch(m_index);
}
void PCMSim::SetPressureSwitch(bool pressureSwitch) {
HALSIM_SetPCMPressureSwitch(m_index, pressureSwitch);
}
std::unique_ptr<CallbackStore> PCMSim::RegisterCompressorCurrentCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPCMCompressorCurrentCallback);
store->SetUid(HALSIM_RegisterPCMCompressorCurrentCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double PCMSim::GetCompressorCurrent() const {
return HALSIM_GetPCMCompressorCurrent(m_index);
}
void PCMSim::SetCompressorCurrent(double compressorCurrent) {
HALSIM_SetPCMCompressorCurrent(m_index, compressorCurrent);
}
uint8_t PCMSim::GetAllSolenoidOutputs() const {
uint8_t ret = 0;
HALSIM_GetPCMAllSolenoids(m_index, &ret);
return ret;
}
void PCMSim::SetAllSolenoidOutputs(uint8_t outputs) {
HALSIM_SetPCMAllSolenoids(m_index, outputs);
}
void PCMSim::ResetData() { HALSIM_ResetPCMData(m_index); }

View File

@@ -0,0 +1,98 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/PDPSim.h"
#include <memory>
#include <utility>
#include <hal/simulation/PDPData.h>
#include "frc/PowerDistributionPanel.h"
using namespace frc;
using namespace frc::sim;
PDPSim::PDPSim(int module) : m_index{module} {}
PDPSim::PDPSim(const PowerDistributionPanel& pdp) : m_index{pdp.GetModule()} {}
std::unique_ptr<CallbackStore> PDPSim::RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPDPInitializedCallback);
store->SetUid(HALSIM_RegisterPDPInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool PDPSim::GetInitialized() const {
return HALSIM_GetPDPInitialized(m_index);
}
void PDPSim::SetInitialized(bool initialized) {
HALSIM_SetPDPInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore> PDPSim::RegisterTemperatureCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPDPTemperatureCallback);
store->SetUid(HALSIM_RegisterPDPTemperatureCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double PDPSim::GetTemperature() const {
return HALSIM_GetPDPTemperature(m_index);
}
void PDPSim::SetTemperature(double temperature) {
HALSIM_SetPDPTemperature(m_index, temperature);
}
std::unique_ptr<CallbackStore> PDPSim::RegisterVoltageCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPDPVoltageCallback);
store->SetUid(HALSIM_RegisterPDPVoltageCallback(m_index, &CallbackStoreThunk,
store.get(), initialNotify));
return store;
}
double PDPSim::GetVoltage() const { return HALSIM_GetPDPVoltage(m_index); }
void PDPSim::SetVoltage(double voltage) {
HALSIM_SetPDPVoltage(m_index, voltage);
}
std::unique_ptr<CallbackStore> PDPSim::RegisterCurrentCallback(
int channel, NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, channel, -1, callback, &HALSIM_CancelPDPCurrentCallback);
store->SetUid(HALSIM_RegisterPDPCurrentCallback(
m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double PDPSim::GetCurrent(int channel) const {
return HALSIM_GetPDPCurrent(m_index, channel);
}
void PDPSim::SetCurrent(int channel, double current) {
HALSIM_SetPDPCurrent(m_index, channel, current);
}
void PDPSim::GetAllCurrents(double* currents) const {
HALSIM_GetPDPAllCurrents(m_index, currents);
}
void PDPSim::SetAllCurrents(const double* currents) {
HALSIM_SetPDPAllCurrents(m_index, currents);
}
void PDPSim::ResetData() { HALSIM_ResetPDPData(m_index); }

View File

@@ -0,0 +1,114 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/PWMSim.h"
#include <memory>
#include <utility>
#include <hal/simulation/PWMData.h>
#include "frc/PWM.h"
using namespace frc;
using namespace frc::sim;
PWMSim::PWMSim(const PWM& pwm) : m_index{pwm.GetChannel()} {}
PWMSim::PWMSim(int channel) : m_index{channel} {}
std::unique_ptr<CallbackStore> PWMSim::RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPWMInitializedCallback);
store->SetUid(HALSIM_RegisterPWMInitializedCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool PWMSim::GetInitialized() const {
return HALSIM_GetPWMInitialized(m_index);
}
void PWMSim::SetInitialized(bool initialized) {
HALSIM_SetPWMInitialized(m_index, initialized);
}
std::unique_ptr<CallbackStore> PWMSim::RegisterRawValueCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPWMRawValueCallback);
store->SetUid(HALSIM_RegisterPWMRawValueCallback(m_index, &CallbackStoreThunk,
store.get(), initialNotify));
return store;
}
int PWMSim::GetRawValue() const { return HALSIM_GetPWMRawValue(m_index); }
void PWMSim::SetRawValue(int rawValue) {
HALSIM_SetPWMRawValue(m_index, rawValue);
}
std::unique_ptr<CallbackStore> PWMSim::RegisterSpeedCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(m_index, -1, callback,
&HALSIM_CancelPWMSpeedCallback);
store->SetUid(HALSIM_RegisterPWMSpeedCallback(m_index, &CallbackStoreThunk,
store.get(), initialNotify));
return store;
}
double PWMSim::GetSpeed() const { return HALSIM_GetPWMSpeed(m_index); }
void PWMSim::SetSpeed(double speed) { HALSIM_SetPWMSpeed(m_index, speed); }
std::unique_ptr<CallbackStore> PWMSim::RegisterPositionCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPWMPositionCallback);
store->SetUid(HALSIM_RegisterPWMPositionCallback(m_index, &CallbackStoreThunk,
store.get(), initialNotify));
return store;
}
double PWMSim::GetPosition() const { return HALSIM_GetPWMPosition(m_index); }
void PWMSim::SetPosition(double position) {
HALSIM_SetPWMPosition(m_index, position);
}
std::unique_ptr<CallbackStore> PWMSim::RegisterPeriodScaleCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPWMPeriodScaleCallback);
store->SetUid(HALSIM_RegisterPWMPeriodScaleCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int PWMSim::GetPeriodScale() const { return HALSIM_GetPWMPeriodScale(m_index); }
void PWMSim::SetPeriodScale(int periodScale) {
HALSIM_SetPWMPeriodScale(m_index, periodScale);
}
std::unique_ptr<CallbackStore> PWMSim::RegisterZeroLatchCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelPWMZeroLatchCallback);
store->SetUid(HALSIM_RegisterPWMZeroLatchCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool PWMSim::GetZeroLatch() const { return HALSIM_GetPWMZeroLatch(m_index); }
void PWMSim::SetZeroLatch(bool zeroLatch) {
HALSIM_SetPWMZeroLatch(m_index, zeroLatch);
}
void PWMSim::ResetData() { HALSIM_ResetPWMData(m_index); }

View File

@@ -0,0 +1,88 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/RelaySim.h"
#include <memory>
#include <utility>
#include <hal/simulation/RelayData.h>
#include "frc/Relay.h"
using namespace frc;
using namespace frc::sim;
RelaySim::RelaySim(const Relay& relay) : m_index{relay.GetChannel()} {}
RelaySim::RelaySim(int channel) : m_index{channel} {}
std::unique_ptr<CallbackStore> RelaySim::RegisterInitializedForwardCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRelayInitializedForwardCallback);
store->SetUid(HALSIM_RegisterRelayInitializedForwardCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool RelaySim::GetInitializedForward() const {
return HALSIM_GetRelayInitializedForward(m_index);
}
void RelaySim::SetInitializedForward(bool initializedForward) {
HALSIM_SetRelayInitializedForward(m_index, initializedForward);
}
std::unique_ptr<CallbackStore> RelaySim::RegisterInitializedReverseCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRelayInitializedReverseCallback);
store->SetUid(HALSIM_RegisterRelayInitializedReverseCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool RelaySim::GetInitializedReverse() const {
return HALSIM_GetRelayInitializedReverse(m_index);
}
void RelaySim::SetInitializedReverse(bool initializedReverse) {
HALSIM_SetRelayInitializedReverse(m_index, initializedReverse);
}
std::unique_ptr<CallbackStore> RelaySim::RegisterForwardCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRelayForwardCallback);
store->SetUid(HALSIM_RegisterRelayForwardCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool RelaySim::GetForward() const { return HALSIM_GetRelayForward(m_index); }
void RelaySim::SetForward(bool forward) {
HALSIM_SetRelayForward(m_index, forward);
}
std::unique_ptr<CallbackStore> RelaySim::RegisterReverseCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelRelayReverseCallback);
store->SetUid(HALSIM_RegisterRelayReverseCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool RelaySim::GetReverse() const { return HALSIM_GetRelayReverse(m_index); }
void RelaySim::SetReverse(bool reverse) {
HALSIM_SetRelayReverse(m_index, reverse);
}
void RelaySim::ResetData() { HALSIM_ResetRelayData(m_index); }

View File

@@ -0,0 +1,255 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/RoboRioSim.h"
#include <memory>
#include <utility>
#include <hal/simulation/RoboRioData.h>
using namespace frc;
using namespace frc::sim;
std::unique_ptr<CallbackStore> RoboRioSim::RegisterFPGAButtonCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelRoboRioFPGAButtonCallback);
store->SetUid(HALSIM_RegisterRoboRioFPGAButtonCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool RoboRioSim::GetFPGAButton() { return HALSIM_GetRoboRioFPGAButton(); }
void RoboRioSim::SetFPGAButton(bool fPGAButton) {
HALSIM_SetRoboRioFPGAButton(fPGAButton);
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterVInVoltageCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelRoboRioVInVoltageCallback);
store->SetUid(HALSIM_RegisterRoboRioVInVoltageCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double RoboRioSim::GetVInVoltage() { return HALSIM_GetRoboRioVInVoltage(); }
void RoboRioSim::SetVInVoltage(double vInVoltage) {
HALSIM_SetRoboRioVInVoltage(vInVoltage);
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterVInCurrentCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelRoboRioVInCurrentCallback);
store->SetUid(HALSIM_RegisterRoboRioVInCurrentCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double RoboRioSim::GetVInCurrent() { return HALSIM_GetRoboRioVInCurrent(); }
void RoboRioSim::SetVInCurrent(double vInCurrent) {
HALSIM_SetRoboRioVInCurrent(vInCurrent);
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserVoltage6VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelRoboRioUserVoltage6VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserVoltage6VCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double RoboRioSim::GetUserVoltage6V() {
return HALSIM_GetRoboRioUserVoltage6V();
}
void RoboRioSim::SetUserVoltage6V(double userVoltage6V) {
HALSIM_SetRoboRioUserVoltage6V(userVoltage6V);
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserCurrent6VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelRoboRioUserCurrent6VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserCurrent6VCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double RoboRioSim::GetUserCurrent6V() {
return HALSIM_GetRoboRioUserCurrent6V();
}
void RoboRioSim::SetUserCurrent6V(double userCurrent6V) {
HALSIM_SetRoboRioUserCurrent6V(userCurrent6V);
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserActive6VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelRoboRioUserActive6VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserActive6VCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool RoboRioSim::GetUserActive6V() { return HALSIM_GetRoboRioUserActive6V(); }
void RoboRioSim::SetUserActive6V(bool userActive6V) {
HALSIM_SetRoboRioUserActive6V(userActive6V);
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserVoltage5VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelRoboRioUserVoltage5VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserVoltage5VCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double RoboRioSim::GetUserVoltage5V() {
return HALSIM_GetRoboRioUserVoltage5V();
}
void RoboRioSim::SetUserVoltage5V(double userVoltage5V) {
HALSIM_SetRoboRioUserVoltage5V(userVoltage5V);
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserCurrent5VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelRoboRioUserCurrent5VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserCurrent5VCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double RoboRioSim::GetUserCurrent5V() {
return HALSIM_GetRoboRioUserCurrent5V();
}
void RoboRioSim::SetUserCurrent5V(double userCurrent5V) {
HALSIM_SetRoboRioUserCurrent5V(userCurrent5V);
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserActive5VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelRoboRioUserActive5VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserActive5VCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool RoboRioSim::GetUserActive5V() { return HALSIM_GetRoboRioUserActive5V(); }
void RoboRioSim::SetUserActive5V(bool userActive5V) {
HALSIM_SetRoboRioUserActive5V(userActive5V);
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserVoltage3V3Callback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelRoboRioUserVoltage3V3Callback);
store->SetUid(HALSIM_RegisterRoboRioUserVoltage3V3Callback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double RoboRioSim::GetUserVoltage3V3() {
return HALSIM_GetRoboRioUserVoltage3V3();
}
void RoboRioSim::SetUserVoltage3V3(double userVoltage3V3) {
HALSIM_SetRoboRioUserVoltage3V3(userVoltage3V3);
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserCurrent3V3Callback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelRoboRioUserCurrent3V3Callback);
store->SetUid(HALSIM_RegisterRoboRioUserCurrent3V3Callback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double RoboRioSim::GetUserCurrent3V3() {
return HALSIM_GetRoboRioUserCurrent3V3();
}
void RoboRioSim::SetUserCurrent3V3(double userCurrent3V3) {
HALSIM_SetRoboRioUserCurrent3V3(userCurrent3V3);
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserActive3V3Callback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelRoboRioUserActive3V3Callback);
store->SetUid(HALSIM_RegisterRoboRioUserActive3V3Callback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool RoboRioSim::GetUserActive3V3() { return HALSIM_GetRoboRioUserActive3V3(); }
void RoboRioSim::SetUserActive3V3(bool userActive3V3) {
HALSIM_SetRoboRioUserActive3V3(userActive3V3);
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserFaults6VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelRoboRioUserFaults6VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserFaults6VCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int RoboRioSim::GetUserFaults6V() { return HALSIM_GetRoboRioUserFaults6V(); }
void RoboRioSim::SetUserFaults6V(int userFaults6V) {
HALSIM_SetRoboRioUserFaults6V(userFaults6V);
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserFaults5VCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelRoboRioUserFaults5VCallback);
store->SetUid(HALSIM_RegisterRoboRioUserFaults5VCallback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int RoboRioSim::GetUserFaults5V() { return HALSIM_GetRoboRioUserFaults5V(); }
void RoboRioSim::SetUserFaults5V(int userFaults5V) {
HALSIM_SetRoboRioUserFaults5V(userFaults5V);
}
std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserFaults3V3Callback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
-1, callback, &HALSIM_CancelRoboRioUserFaults3V3Callback);
store->SetUid(HALSIM_RegisterRoboRioUserFaults3V3Callback(
&CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int RoboRioSim::GetUserFaults3V3() { return HALSIM_GetRoboRioUserFaults3V3(); }
void RoboRioSim::SetUserFaults3V3(int userFaults3V3) {
HALSIM_SetRoboRioUserFaults3V3(userFaults3V3);
}
void ResetData() { HALSIM_ResetRoboRioData(); }

View File

@@ -0,0 +1,107 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/SPIAccelerometerSim.h"
#include <memory>
#include <utility>
#include <hal/simulation/SPIAccelerometerData.h>
using namespace frc;
using namespace frc::sim;
SPIAccelerometerSim::SPIAccelerometerSim(int index) { m_index = index; }
std::unique_ptr<CallbackStore> SPIAccelerometerSim::RegisterActiveCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelSPIAccelerometerActiveCallback);
store->SetUid(HALSIM_RegisterSPIAccelerometerActiveCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
bool SPIAccelerometerSim::GetActive() const {
return HALSIM_GetSPIAccelerometerActive(m_index);
}
void SPIAccelerometerSim::SetActive(bool active) {
HALSIM_SetSPIAccelerometerActive(m_index, active);
}
std::unique_ptr<CallbackStore> SPIAccelerometerSim::RegisterRangeCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelSPIAccelerometerRangeCallback);
store->SetUid(HALSIM_RegisterSPIAccelerometerRangeCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
int SPIAccelerometerSim::GetRange() const {
return HALSIM_GetSPIAccelerometerRange(m_index);
}
void SPIAccelerometerSim::SetRange(int range) {
HALSIM_SetSPIAccelerometerRange(m_index, range);
}
std::unique_ptr<CallbackStore> SPIAccelerometerSim::RegisterXCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelSPIAccelerometerXCallback);
store->SetUid(HALSIM_RegisterSPIAccelerometerXCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double SPIAccelerometerSim::GetX() const {
return HALSIM_GetSPIAccelerometerX(m_index);
}
void SPIAccelerometerSim::SetX(double x) {
HALSIM_SetSPIAccelerometerX(m_index, x);
}
std::unique_ptr<CallbackStore> SPIAccelerometerSim::RegisterYCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelSPIAccelerometerYCallback);
store->SetUid(HALSIM_RegisterSPIAccelerometerYCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double SPIAccelerometerSim::GetY() const {
return HALSIM_GetSPIAccelerometerY(m_index);
}
void SPIAccelerometerSim::SetY(double y) {
HALSIM_SetSPIAccelerometerY(m_index, y);
}
std::unique_ptr<CallbackStore> SPIAccelerometerSim::RegisterZCallback(
NotifyCallback callback, bool initialNotify) {
auto store = std::make_unique<CallbackStore>(
m_index, -1, callback, &HALSIM_CancelSPIAccelerometerZCallback);
store->SetUid(HALSIM_RegisterSPIAccelerometerZCallback(
m_index, &CallbackStoreThunk, store.get(), initialNotify));
return store;
}
double SPIAccelerometerSim::GetZ() const {
return HALSIM_GetSPIAccelerometerZ(m_index);
}
void SPIAccelerometerSim::SetZ(double z) {
HALSIM_SetSPIAccelerometerZ(m_index, z);
}
void SPIAccelerometerSim::ResetData() {
HALSIM_ResetSPIAccelerometerData(m_index);
}

View File

@@ -0,0 +1,47 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/SimDeviceSim.h"
#include <string>
#include <vector>
#include <hal/SimDevice.h>
#include <hal/simulation/SimDeviceData.h>
using namespace frc;
using namespace frc::sim;
SimDeviceSim::SimDeviceSim(const char* name)
: m_handle{HALSIM_GetSimDeviceHandle(name)} {}
hal::SimValue SimDeviceSim::GetValue(const char* name) const {
return HALSIM_GetSimValueHandle(m_handle, name);
}
hal::SimDouble SimDeviceSim::GetDouble(const char* name) const {
return HALSIM_GetSimValueHandle(m_handle, name);
}
hal::SimEnum SimDeviceSim::GetEnum(const char* name) const {
return HALSIM_GetSimValueHandle(m_handle, name);
}
hal::SimBoolean SimDeviceSim::GetBoolean(const char* name) const {
return HALSIM_GetSimValueHandle(m_handle, name);
}
std::vector<std::string> SimDeviceSim::GetEnumOptions(hal::SimEnum val) {
int32_t numOptions;
const char** options = HALSIM_GetSimValueEnumOptions(val, &numOptions);
std::vector<std::string> rv;
rv.reserve(numOptions);
for (int32_t i = 0; i < numOptions; ++i) rv.emplace_back(options[i]);
return rv;
}
void SimDeviceSim::ResetData() { HALSIM_ResetSimDeviceData(); }

View File

@@ -0,0 +1,34 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "frc/simulation/SimHooks.h"
#include <hal/simulation/MockHooks.h>
namespace frc {
namespace sim {
void SetRuntimeType(HAL_RuntimeType type) { HALSIM_SetRuntimeType(type); }
void WaitForProgramStart() { HALSIM_WaitForProgramStart(); }
void SetProgramStarted() { HALSIM_SetProgramStarted(); }
bool GetProgramStarted() { return HALSIM_GetProgramStarted(); }
void RestartTiming() { HALSIM_RestartTiming(); }
void PauseTiming() { HALSIM_PauseTiming(); }
void ResumeTiming() { HALSIM_ResumeTiming(); }
bool IsTimingPaused() { return HALSIM_IsTimingPaused(); }
void StepTiming(uint64_t delta) { HALSIM_StepTiming(delta); }
} // namespace sim
} // namespace frc

View File

@@ -0,0 +1,90 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#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);
}
void XboxControllerSim::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 XboxControllerSim::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 XboxControllerSim::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 XboxControllerSim::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 XboxControllerSim::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 XboxControllerSim::SetAButton(bool state) {
SetRawButton(static_cast<int>(XboxController::Button::kA), state);
}
void XboxControllerSim::SetBButton(bool state) {
SetRawButton(static_cast<int>(XboxController::Button::kB), state);
}
void XboxControllerSim::SetXButton(bool state) {
SetRawButton(static_cast<int>(XboxController::Button::kX), state);
}
void XboxControllerSim::SetYButton(bool state) {
SetRawButton(static_cast<int>(XboxController::Button::kY), state);
}
void XboxControllerSim::SetBackButton(bool state) {
SetRawButton(static_cast<int>(XboxController::Button::kBack), state);
}
void XboxControllerSim::SetStartButton(bool state) {
SetRawButton(static_cast<int>(XboxController::Button::kStart), state);
}