/*----------------------------------------------------------------------------*/ /* Copyright (c) 2017-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. */ /*----------------------------------------------------------------------------*/ #pragma once #include #include #include "hal/simulation/DriverStationData.h" #include "hal/simulation/SimDataValue.h" namespace hal { struct JoystickOutputStore; class DriverStationData { HAL_SIMDATAVALUE_DEFINE_NAME(Enabled) HAL_SIMDATAVALUE_DEFINE_NAME(Autonomous) HAL_SIMDATAVALUE_DEFINE_NAME(Test) HAL_SIMDATAVALUE_DEFINE_NAME(EStop) HAL_SIMDATAVALUE_DEFINE_NAME(FmsAttached) HAL_SIMDATAVALUE_DEFINE_NAME(DsAttached) HAL_SIMDATAVALUE_DEFINE_NAME(AllianceStationId) HAL_SIMDATAVALUE_DEFINE_NAME(MatchTime) static LLVM_ATTRIBUTE_ALWAYS_INLINE HAL_Value MakeAllianceStationIdValue(HAL_AllianceStationID value) { return HAL_MakeEnum(value); } public: DriverStationData(); void ResetData(); void GetJoystickAxes(int32_t joystickNum, HAL_JoystickAxes* axes); void GetJoystickPOVs(int32_t joystickNum, HAL_JoystickPOVs* povs); void GetJoystickButtons(int32_t joystickNum, HAL_JoystickButtons* buttons); void GetJoystickDescriptor(int32_t joystickNum, HAL_JoystickDescriptor* descriptor); void GetJoystickOutputs(int32_t joystickNum, int64_t* outputs, int32_t* leftRumble, int32_t* rightRumble); void GetMatchInfo(HAL_MatchInfo* info); void FreeMatchInfo(const HAL_MatchInfo* info); void SetJoystickAxes(int32_t joystickNum, const HAL_JoystickAxes* axes); void SetJoystickPOVs(int32_t joystickNum, const HAL_JoystickPOVs* povs); void SetJoystickButtons(int32_t joystickNum, const HAL_JoystickButtons* buttons); void SetJoystickDescriptor(int32_t joystickNum, const HAL_JoystickDescriptor* descriptor); void SetJoystickOutputs(int32_t joystickNum, int64_t outputs, int32_t leftRumble, int32_t rightRumble); void SetMatchInfo(const HAL_MatchInfo* info); void NotifyNewData(); SimDataValue enabled{false}; SimDataValue autonomous{false}; SimDataValue test{false}; SimDataValue eStop{false}; SimDataValue fmsAttached{ false}; SimDataValue dsAttached{true}; SimDataValue allianceStationId{static_cast(0)}; SimDataValue matchTime{0.0}; private: wpi::spinlock m_joystickDataMutex; wpi::spinlock m_matchInfoMutex; std::unique_ptr m_joystickAxes; std::unique_ptr m_joystickPOVs; std::unique_ptr m_joystickButtons; std::unique_ptr m_joystickOutputs; std::unique_ptr m_joystickDescriptor; std::unique_ptr m_matchInfo; }; extern DriverStationData* SimDriverStationData; } // namespace hal